| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757 |
- /*!
- * jQuery JavaScript Library v1.5
- * http://jquery.com/
- *
- * Copyright 2011, John Resig
- * Dual licensed under the MIT or GPL Version 2 licenses.
- * http://jquery.org/license
- *
- * Includes Sizzle.js
- * http://sizzlejs.com/
- * Copyright 2011, The Dojo Foundation
- * Released under the MIT, BSD, and GPL Licenses.
- *
- * Date: Mon Jan 31 08:31:29 2011 -0500
- */
- (function( window, undefined ) {
- // Use the correct document accordingly with window argument (sandbox)
- var document = window.document;
- var jQuery = (function() {
- // Define a local copy of jQuery
- var jQuery = function( selector, context ) {
- // The jQuery object is actually just the init constructor 'enhanced'
- return new jQuery.fn.init( selector, context, rootjQuery );
- },
- // Map over jQuery in case of overwrite
- _jQuery = window.jQuery,
- // Map over the $ in case of overwrite
- _$ = window.$,
- // A central reference to the root jQuery(document)
- rootjQuery,
- // A simple way to check for HTML strings or ID strings
- // (both of which we optimize for)
- quickExpr = /^(?:[^<]*(<[\w\W]+>)[^>]*$|#([\w\-]+)$)/,
- // Check if a string has a non-whitespace character in it
- rnotwhite = /\S/,
- // Used for trimming whitespace
- trimLeft = /^\s+/,
- trimRight = /\s+$/,
- // Check for digits
- rdigit = /\d/,
- // Match a standalone tag
- rsingleTag = /^<(\w+)\s*\/?>(?:<\/\1>)?$/,
- // JSON RegExp
- rvalidchars = /^[\],:{}\s]*$/,
- rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,
- rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,
- rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g,
- // Useragent RegExp
- rwebkit = /(webkit)[ \/]([\w.]+)/,
- ropera = /(opera)(?:.*version)?[ \/]([\w.]+)/,
- rmsie = /(msie) ([\w.]+)/,
- rmozilla = /(mozilla)(?:.*? rv:([\w.]+))?/,
- // Keep a UserAgent string for use with jQuery.browser
- userAgent = navigator.userAgent,
- // For matching the engine and version of the browser
- browserMatch,
- // Has the ready events already been bound?
- readyBound = false,
- // The deferred used on DOM ready
- readyList,
- // Promise methods
- promiseMethods = "then done fail isResolved isRejected promise".split( " " ),
- // The ready event handler
- DOMContentLoaded,
- // Save a reference to some core methods
- toString = Object.prototype.toString,
- hasOwn = Object.prototype.hasOwnProperty,
- push = Array.prototype.push,
- slice = Array.prototype.slice,
- trim = String.prototype.trim,
- indexOf = Array.prototype.indexOf,
- // [[Class]] -> type pairs
- class2type = {};
- jQuery.fn = jQuery.prototype = {
- constructor: jQuery,
- init: function( selector, context, rootjQuery ) {
- var match, elem, ret, doc;
- // Handle $(""), $(null), or $(undefined)
- if ( !selector ) {
- return this;
- }
- // Handle $(DOMElement)
- if ( selector.nodeType ) {
- this.context = this[0] = selector;
- this.length = 1;
- return this;
- }
- // The body element only exists once, optimize finding it
- if ( selector === "body" && !context && document.body ) {
- this.context = document;
- this[0] = document.body;
- this.selector = "body";
- this.length = 1;
- return this;
- }
- // Handle HTML strings
- if ( typeof selector === "string" ) {
- // Are we dealing with HTML string or an ID?
- match = quickExpr.exec( selector );
- // Verify a match, and that no context was specified for #id
- if ( match && (match[1] || !context) ) {
- // HANDLE: $(html) -> $(array)
- if ( match[1] ) {
- context = context instanceof jQuery ? context[0] : context;
- doc = (context ? context.ownerDocument || context : document);
- // If a single string is passed in and it's a single tag
- // just do a createElement and skip the rest
- ret = rsingleTag.exec( selector );
- if ( ret ) {
- if ( jQuery.isPlainObject( context ) ) {
- selector = [ document.createElement( ret[1] ) ];
- jQuery.fn.attr.call( selector, context, true );
- } else {
- selector = [ doc.createElement( ret[1] ) ];
- }
- } else {
- ret = jQuery.buildFragment( [ match[1] ], [ doc ] );
- selector = (ret.cacheable ? jQuery.clone(ret.fragment) : ret.fragment).childNodes;
- }
- return jQuery.merge( this, selector );
- // HANDLE: $("#id")
- } else {
- elem = document.getElementById( match[2] );
- // Check parentNode to catch when Blackberry 4.6 returns
- // nodes that are no longer in the document #6963
- if ( elem && elem.parentNode ) {
- // Handle the case where IE and Opera return items
- // by name instead of ID
- if ( elem.id !== match[2] ) {
- return rootjQuery.find( selector );
- }
- // Otherwise, we inject the element directly into the jQuery object
- this.length = 1;
- this[0] = elem;
- }
- this.context = document;
- this.selector = selector;
- return this;
- }
- // HANDLE: $(expr, $(...))
- } else if ( !context || context.jquery ) {
- return (context || rootjQuery).find( selector );
- // HANDLE: $(expr, context)
- // (which is just equivalent to: $(context).find(expr)
- } else {
- return this.constructor( context ).find( selector );
- }
- // HANDLE: $(function)
- // Shortcut for document ready
- } else if ( jQuery.isFunction( selector ) ) {
- return rootjQuery.ready( selector );
- }
- if (selector.selector !== undefined) {
- this.selector = selector.selector;
- this.context = selector.context;
- }
- return jQuery.makeArray( selector, this );
- },
- // Start with an empty selector
- selector: "",
- // The current version of jQuery being used
- jquery: "1.5",
- // The default length of a jQuery object is 0
- length: 0,
- // The number of elements contained in the matched element set
- size: function() {
- return this.length;
- },
- toArray: function() {
- return slice.call( this, 0 );
- },
- // Get the Nth element in the matched element set OR
- // Get the whole matched element set as a clean array
- get: function( num ) {
- return num == null ?
- // Return a 'clean' array
- this.toArray() :
- // Return just the object
- ( num < 0 ? this[ this.length + num ] : this[ num ] );
- },
- // Take an array of elements and push it onto the stack
- // (returning the new matched element set)
- pushStack: function( elems, name, selector ) {
- // Build a new jQuery matched element set
- var ret = this.constructor();
- if ( jQuery.isArray( elems ) ) {
- push.apply( ret, elems );
- } else {
- jQuery.merge( ret, elems );
- }
- // Add the old object onto the stack (as a reference)
- ret.prevObject = this;
- ret.context = this.context;
- if ( name === "find" ) {
- ret.selector = this.selector + (this.selector ? " " : "") + selector;
- } else if ( name ) {
- ret.selector = this.selector + "." + name + "(" + selector + ")";
- }
- // Return the newly-formed element set
- return ret;
- },
- // Execute a callback for every element in the matched set.
- // (You can seed the arguments with an array of args, but this is
- // only used internally.)
- each: function( callback, args ) {
- return jQuery.each( this, callback, args );
- },
- ready: function( fn ) {
- // Attach the listeners
- jQuery.bindReady();
- // Add the callback
- readyList.done( fn );
- return this;
- },
- eq: function( i ) {
- return i === -1 ?
- this.slice( i ) :
- this.slice( i, +i + 1 );
- },
- first: function() {
- return this.eq( 0 );
- },
- last: function() {
- return this.eq( -1 );
- },
- slice: function() {
- return this.pushStack( slice.apply( this, arguments ),
- "slice", slice.call(arguments).join(",") );
- },
- map: function( callback ) {
- return this.pushStack( jQuery.map(this, function( elem, i ) {
- return callback.call( elem, i, elem );
- }));
- },
- end: function() {
- return this.prevObject || this.constructor(null);
- },
- // For internal use only.
- // Behaves like an Array's method, not like a jQuery method.
- push: push,
- sort: [].sort,
- splice: [].splice
- };
- // Give the init function the jQuery prototype for later instantiation
- jQuery.fn.init.prototype = jQuery.fn;
- jQuery.extend = jQuery.fn.extend = function() {
- var options, name, src, copy, copyIsArray, clone,
- target = arguments[0] || {},
- i = 1,
- length = arguments.length,
- deep = false;
- // Handle a deep copy situation
- if ( typeof target === "boolean" ) {
- deep = target;
- target = arguments[1] || {};
- // skip the boolean and the target
- i = 2;
- }
- // Handle case when target is a string or something (possible in deep copy)
- if ( typeof target !== "object" && !jQuery.isFunction(target) ) {
- target = {};
- }
- // extend jQuery itself if only one argument is passed
- if ( length === i ) {
- target = this;
- --i;
- }
- for ( ; i < length; i++ ) {
- // Only deal with non-null/undefined values
- if ( (options = arguments[ i ]) != null ) {
- // Extend the base object
- for ( name in options ) {
- src = target[ name ];
- copy = options[ name ];
- // Prevent never-ending loop
- if ( target === copy ) {
- continue;
- }
- // Recurse if we're merging plain objects or arrays
- if ( deep && copy && ( jQuery.isPlainObject(copy) || (copyIsArray = jQuery.isArray(copy)) ) ) {
- if ( copyIsArray ) {
- copyIsArray = false;
- clone = src && jQuery.isArray(src) ? src : [];
- } else {
- clone = src && jQuery.isPlainObject(src) ? src : {};
- }
- // Never move original objects, clone them
- target[ name ] = jQuery.extend( deep, clone, copy );
- // Don't bring in undefined values
- } else if ( copy !== undefined ) {
- target[ name ] = copy;
- }
- }
- }
- }
- // Return the modified object
- return target;
- };
- jQuery.extend({
- noConflict: function( deep ) {
- window.$ = _$;
- if ( deep ) {
- window.jQuery = _jQuery;
- }
- return jQuery;
- },
- // Is the DOM ready to be used? Set to true once it occurs.
- isReady: false,
- // A counter to track how many items to wait for before
- // the ready event fires. See #6781
- readyWait: 1,
- // Handle when the DOM is ready
- ready: function( wait ) {
- // A third-party is pushing the ready event forwards
- if ( wait === true ) {
- jQuery.readyWait--;
- }
- // Make sure that the DOM is not already loaded
- if ( !jQuery.readyWait || (wait !== true && !jQuery.isReady) ) {
- // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
- if ( !document.body ) {
- return setTimeout( jQuery.ready, 1 );
- }
- // Remember that the DOM is ready
- jQuery.isReady = true;
- // If a normal DOM Ready event fired, decrement, and wait if need be
- if ( wait !== true && --jQuery.readyWait > 0 ) {
- return;
- }
- // If there are functions bound, to execute
- readyList.resolveWith( document, [ jQuery ] );
- // Trigger any bound ready events
- if ( jQuery.fn.trigger ) {
- jQuery( document ).trigger( "ready" ).unbind( "ready" );
- }
- }
- },
- bindReady: function() {
- if ( readyBound ) {
- return;
- }
- readyBound = true;
- // Catch cases where $(document).ready() is called after the
- // browser event has already occurred.
- if ( document.readyState === "complete" ) {
- // Handle it asynchronously to allow scripts the opportunity to delay ready
- return setTimeout( jQuery.ready, 1 );
- }
- // Mozilla, Opera and webkit nightlies currently support this event
- if ( document.addEventListener ) {
- // Use the handy event callback
- document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false );
- // A fallback to window.onload, that will always work
- window.addEventListener( "load", jQuery.ready, false );
- // If IE event model is used
- } else if ( document.attachEvent ) {
- // ensure firing before onload,
- // maybe late but safe also for iframes
- document.attachEvent("onreadystatechange", DOMContentLoaded);
- // A fallback to window.onload, that will always work
- window.attachEvent( "onload", jQuery.ready );
- // If IE and not a frame
- // continually check to see if the document is ready
- var toplevel = false;
- try {
- toplevel = window.frameElement == null;
- } catch(e) {}
- if ( document.documentElement.doScroll && toplevel ) {
- doScrollCheck();
- }
- }
- },
- // See test/unit/core.js for details concerning isFunction.
- // Since version 1.3, DOM methods and functions like alert
- // aren't supported. They return false on IE (#2968).
- isFunction: function( obj ) {
- return jQuery.type(obj) === "function";
- },
- isArray: Array.isArray || function( obj ) {
- return jQuery.type(obj) === "array";
- },
- // A crude way of determining if an object is a window
- isWindow: function( obj ) {
- return obj && typeof obj === "object" && "setInterval" in obj;
- },
- isNaN: function( obj ) {
- return obj == null || !rdigit.test( obj ) || isNaN( obj );
- },
- type: function( obj ) {
- return obj == null ?
- String( obj ) :
- class2type[ toString.call(obj) ] || "object";
- },
- isPlainObject: function( obj ) {
- // Must be an Object.
- // Because of IE, we also have to check the presence of the constructor property.
- // Make sure that DOM nodes and window objects don't pass through, as well
- if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
- return false;
- }
- // Not own constructor property must be Object
- if ( obj.constructor &&
- !hasOwn.call(obj, "constructor") &&
- !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
- return false;
- }
- // Own properties are enumerated firstly, so to speed up,
- // if last one is own, then all properties are own.
- var key;
- for ( key in obj ) {}
- return key === undefined || hasOwn.call( obj, key );
- },
- isEmptyObject: function( obj ) {
- for ( var name in obj ) {
- return false;
- }
- return true;
- },
- error: function( msg ) {
- throw msg;
- },
- parseJSON: function( data ) {
- if ( typeof data !== "string" || !data ) {
- return null;
- }
- // Make sure leading/trailing whitespace is removed (IE can't handle it)
- data = jQuery.trim( data );
- // Make sure the incoming data is actual JSON
- // Logic borrowed from http://json.org/json2.js
- if ( rvalidchars.test(data.replace(rvalidescape, "@")
- .replace(rvalidtokens, "]")
- .replace(rvalidbraces, "")) ) {
- // Try to use the native JSON parser first
- return window.JSON && window.JSON.parse ?
- window.JSON.parse( data ) :
- (new Function("return " + data))();
- } else {
- jQuery.error( "Invalid JSON: " + data );
- }
- },
- // Cross-browser xml parsing
- // (xml & tmp used internally)
- parseXML: function( data , xml , tmp ) {
- if ( window.DOMParser ) { // Standard
- tmp = new DOMParser();
- xml = tmp.parseFromString( data , "text/xml" );
- } else { // IE
- xml = new ActiveXObject( "Microsoft.XMLDOM" );
- xml.async = "false";
- xml.loadXML( data );
- }
- tmp = xml.documentElement;
- if ( ! tmp || ! tmp.nodeName || tmp.nodeName === "parsererror" ) {
- jQuery.error( "Invalid XML: " + data );
- }
- return xml;
- },
- noop: function() {},
- // Evalulates a script in a global context
- globalEval: function( data ) {
- if ( data && rnotwhite.test(data) ) {
- // Inspired by code by Andrea Giammarchi
- // http://webreflection.blogspot.com/2007/08/global-scope-evaluation-and-dom.html
- var head = document.getElementsByTagName("head")[0] || document.documentElement,
- script = document.createElement("script");
- script.type = "text/javascript";
- if ( jQuery.support.scriptEval() ) {
- script.appendChild( document.createTextNode( data ) );
- } else {
- script.text = data;
- }
- // Use insertBefore instead of appendChild to circumvent an IE6 bug.
- // This arises when a base node is used (#2709).
- head.insertBefore( script, head.firstChild );
- head.removeChild( script );
- }
- },
- nodeName: function( elem, name ) {
- return elem.nodeName && elem.nodeName.toUpperCase() === name.toUpperCase();
- },
- // args is for internal usage only
- each: function( object, callback, args ) {
- var name, i = 0,
- length = object.length,
- isObj = length === undefined || jQuery.isFunction(object);
- if ( args ) {
- if ( isObj ) {
- for ( name in object ) {
- if ( callback.apply( object[ name ], args ) === false ) {
- break;
- }
- }
- } else {
- for ( ; i < length; ) {
- if ( callback.apply( object[ i++ ], args ) === false ) {
- break;
- }
- }
- }
- // A special, fast, case for the most common use of each
- } else {
- if ( isObj ) {
- for ( name in object ) {
- if ( callback.call( object[ name ], name, object[ name ] ) === false ) {
- break;
- }
- }
- } else {
- for ( var value = object[0];
- i < length && callback.call( value, i, value ) !== false; value = object[++i] ) {}
- }
- }
- return object;
- },
- // Use native String.trim function wherever possible
- trim: trim ?
- function( text ) {
- return text == null ?
- "" :
- trim.call( text );
- } :
- // Otherwise use our own trimming functionality
- function( text ) {
- return text == null ?
- "" :
- text.toString().replace( trimLeft, "" ).replace( trimRight, "" );
- },
- // results is for internal usage only
- makeArray: function( array, results ) {
- var ret = results || [];
- if ( array != null ) {
- // The window, strings (and functions) also have 'length'
- // The extra typeof function check is to prevent crashes
- // in Safari 2 (See: #3039)
- // Tweaked logic slightly to handle Blackberry 4.7 RegExp issues #6930
- var type = jQuery.type(array);
- if ( array.length == null || type === "string" || type === "function" || type === "regexp" || jQuery.isWindow( array ) ) {
- push.call( ret, array );
- } else {
- jQuery.merge( ret, array );
- }
- }
- return ret;
- },
- inArray: function( elem, array ) {
- if ( array.indexOf ) {
- return array.indexOf( elem );
- }
- for ( var i = 0, length = array.length; i < length; i++ ) {
- if ( array[ i ] === elem ) {
- return i;
- }
- }
- return -1;
- },
- merge: function( first, second ) {
- var i = first.length,
- j = 0;
- if ( typeof second.length === "number" ) {
- for ( var l = second.length; j < l; j++ ) {
- first[ i++ ] = second[ j ];
- }
- } else {
- while ( second[j] !== undefined ) {
- first[ i++ ] = second[ j++ ];
- }
- }
- first.length = i;
- return first;
- },
- grep: function( elems, callback, inv ) {
- var ret = [], retVal;
- inv = !!inv;
- // Go through the array, only saving the items
- // that pass the validator function
- for ( var i = 0, length = elems.length; i < length; i++ ) {
- retVal = !!callback( elems[ i ], i );
- if ( inv !== retVal ) {
- ret.push( elems[ i ] );
- }
- }
- return ret;
- },
- // arg is for internal usage only
- map: function( elems, callback, arg ) {
- var ret = [], value;
- // Go through the array, translating each of the items to their
- // new value (or values).
- for ( var i = 0, length = elems.length; i < length; i++ ) {
- value = callback( elems[ i ], i, arg );
- if ( value != null ) {
- ret[ ret.length ] = value;
- }
- }
- // Flatten any nested arrays
- return ret.concat.apply( [], ret );
- },
- // A global GUID counter for objects
- guid: 1,
- proxy: function( fn, proxy, thisObject ) {
- if ( arguments.length === 2 ) {
- if ( typeof proxy === "string" ) {
- thisObject = fn;
- fn = thisObject[ proxy ];
- proxy = undefined;
- } else if ( proxy && !jQuery.isFunction( proxy ) ) {
- thisObject = proxy;
- proxy = undefined;
- }
- }
- if ( !proxy && fn ) {
- proxy = function() {
- return fn.apply( thisObject || this, arguments );
- };
- }
- // Set the guid of unique handler to the same of original handler, so it can be removed
- if ( fn ) {
- proxy.guid = fn.guid = fn.guid || proxy.guid || jQuery.guid++;
- }
- // So proxy can be declared as an argument
- return proxy;
- },
- // Mutifunctional method to get and set values to a collection
- // The value/s can be optionally by executed if its a function
- access: function( elems, key, value, exec, fn, pass ) {
- var length = elems.length;
- // Setting many attributes
- if ( typeof key === "object" ) {
- for ( var k in key ) {
- jQuery.access( elems, k, key[k], exec, fn, value );
- }
- return elems;
- }
- // Setting one attribute
- if ( value !== undefined ) {
- // Optionally, function values get executed if exec is true
- exec = !pass && exec && jQuery.isFunction(value);
- for ( var i = 0; i < length; i++ ) {
- fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass );
- }
- return elems;
- }
- // Getting an attribute
- return length ? fn( elems[0], key ) : undefined;
- },
- now: function() {
- return (new Date()).getTime();
- },
- // Create a simple deferred (one callbacks list)
- _Deferred: function() {
- var // callbacks list
- callbacks = [],
- // stored [ context , args ]
- fired,
- // to avoid firing when already doing so
- firing,
- // flag to know if the deferred has been cancelled
- cancelled,
- // the deferred itself
- deferred = {
- // done( f1, f2, ...)
- done: function() {
- if ( !cancelled ) {
- var args = arguments,
- i,
- length,
- elem,
- type,
- _fired;
- if ( fired ) {
- _fired = fired;
- fired = 0;
- }
- for ( i = 0, length = args.length; i < length; i++ ) {
- elem = args[ i ];
- type = jQuery.type( elem );
- if ( type === "array" ) {
- deferred.done.apply( deferred, elem );
- } else if ( type === "function" ) {
- callbacks.push( elem );
- }
- }
- if ( _fired ) {
- deferred.resolveWith( _fired[ 0 ], _fired[ 1 ] );
- }
- }
- return this;
- },
- // resolve with given context and args
- resolveWith: function( context, args ) {
- if ( !cancelled && !fired && !firing ) {
- firing = 1;
- try {
- while( callbacks[ 0 ] ) {
- callbacks.shift().apply( context, args );
- }
- }
- finally {
- fired = [ context, args ];
- firing = 0;
- }
- }
- return this;
- },
- // resolve with this as context and given arguments
- resolve: function() {
- deferred.resolveWith( jQuery.isFunction( this.promise ) ? this.promise() : this, arguments );
- return this;
- },
- // Has this deferred been resolved?
- isResolved: function() {
- return !!( firing || fired );
- },
- // Cancel
- cancel: function() {
- cancelled = 1;
- callbacks = [];
- return this;
- }
- };
- return deferred;
- },
- // Full fledged deferred (two callbacks list)
- Deferred: function( func ) {
- var deferred = jQuery._Deferred(),
- failDeferred = jQuery._Deferred(),
- promise;
- // Add errorDeferred methods, then and promise
- jQuery.extend( deferred, {
- then: function( doneCallbacks, failCallbacks ) {
- deferred.done( doneCallbacks ).fail( failCallbacks );
- return this;
- },
- fail: failDeferred.done,
- rejectWith: failDeferred.resolveWith,
- reject: failDeferred.resolve,
- isRejected: failDeferred.isResolved,
- // Get a promise for this deferred
- // If obj is provided, the promise aspect is added to the object
- promise: function( obj , i /* internal */ ) {
- if ( obj == null ) {
- if ( promise ) {
- return promise;
- }
- promise = obj = {};
- }
- i = promiseMethods.length;
- while( i-- ) {
- obj[ promiseMethods[ i ] ] = deferred[ promiseMethods[ i ] ];
- }
- return obj;
- }
- } );
- // Make sure only one callback list will be used
- deferred.then( failDeferred.cancel, deferred.cancel );
- // Unexpose cancel
- delete deferred.cancel;
- // Call given func if any
- if ( func ) {
- func.call( deferred, deferred );
- }
- return deferred;
- },
- // Deferred helper
- when: function( object ) {
- var args = arguments,
- length = args.length,
- deferred = length <= 1 && object && jQuery.isFunction( object.promise ) ?
- object :
- jQuery.Deferred(),
- promise = deferred.promise(),
- resolveArray;
- if ( length > 1 ) {
- resolveArray = new Array( length );
- jQuery.each( args, function( index, element ) {
- jQuery.when( element ).then( function( value ) {
- resolveArray[ index ] = arguments.length > 1 ? slice.call( arguments, 0 ) : value;
- if( ! --length ) {
- deferred.resolveWith( promise, resolveArray );
- }
- }, deferred.reject );
- } );
- } else if ( deferred !== object ) {
- deferred.resolve( object );
- }
- return promise;
- },
- // Use of jQuery.browser is frowned upon.
- // More details: http://docs.jquery.com/Utilities/jQuery.browser
- uaMatch: function( ua ) {
- ua = ua.toLowerCase();
- var match = rwebkit.exec( ua ) ||
- ropera.exec( ua ) ||
- rmsie.exec( ua ) ||
- ua.indexOf("compatible") < 0 && rmozilla.exec( ua ) ||
- [];
- return { browser: match[1] || "", version: match[2] || "0" };
- },
- sub: function() {
- function jQuerySubclass( selector, context ) {
- return new jQuerySubclass.fn.init( selector, context );
- }
- jQuery.extend( true, jQuerySubclass, this );
- jQuerySubclass.superclass = this;
- jQuerySubclass.fn = jQuerySubclass.prototype = this();
- jQuerySubclass.fn.constructor = jQuerySubclass;
- jQuerySubclass.subclass = this.subclass;
- jQuerySubclass.fn.init = function init( selector, context ) {
- if ( context && context instanceof jQuery && !(context instanceof jQuerySubclass) ) {
- context = jQuerySubclass(context);
- }
- return jQuery.fn.init.call( this, selector, context, rootjQuerySubclass );
- };
- jQuerySubclass.fn.init.prototype = jQuerySubclass.fn;
- var rootjQuerySubclass = jQuerySubclass(document);
- return jQuerySubclass;
- },
- browser: {}
- });
- // Create readyList deferred
- readyList = jQuery._Deferred();
- // Populate the class2type map
- jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
- class2type[ "[object " + name + "]" ] = name.toLowerCase();
- });
- browserMatch = jQuery.uaMatch( userAgent );
- if ( browserMatch.browser ) {
- jQuery.browser[ browserMatch.browser ] = true;
- jQuery.browser.version = browserMatch.version;
- }
- // Deprecated, use jQuery.browser.webkit instead
- if ( jQuery.browser.webkit ) {
- jQuery.browser.safari = true;
- }
- if ( indexOf ) {
- jQuery.inArray = function( elem, array ) {
- return indexOf.call( array, elem );
- };
- }
- // IE doesn't match non-breaking spaces with \s
- if ( rnotwhite.test( "\xA0" ) ) {
- trimLeft = /^[\s\xA0]+/;
- trimRight = /[\s\xA0]+$/;
- }
- // All jQuery objects should point back to these
- rootjQuery = jQuery(document);
- // Cleanup functions for the document ready method
- if ( document.addEventListener ) {
- DOMContentLoaded = function() {
- document.removeEventListener( "DOMContentLoaded", DOMContentLoaded, false );
- jQuery.ready();
- };
- } else if ( document.attachEvent ) {
- DOMContentLoaded = function() {
- // Make sure body exists, at least, in case IE gets a little overzealous (ticket #5443).
- if ( document.readyState === "complete" ) {
- document.detachEvent( "onreadystatechange", DOMContentLoaded );
- jQuery.ready();
- }
- };
- }
- // The DOM ready check for Internet Explorer
- function doScrollCheck() {
- if ( jQuery.isReady ) {
- return;
- }
- try {
- // If IE is used, use the trick by Diego Perini
- // http://javascript.nwbox.com/IEContentLoaded/
- document.documentElement.doScroll("left");
- } catch(e) {
- setTimeout( doScrollCheck, 1 );
- return;
- }
- // and execute any waiting functions
- jQuery.ready();
- }
- // Expose jQuery to the global object
- return (window.jQuery = window.$ = jQuery);
- })();
- (function() {
- jQuery.support = {};
- var div = document.createElement("div");
- div.style.display = "none";
- div.innerHTML = " <link/><table></table><a href='/a' style='color:red;float:left;opacity:.55;'>a</a><input type='checkbox'/>";
- var all = div.getElementsByTagName("*"),
- a = div.getElementsByTagName("a")[0],
- select = document.createElement("select"),
- opt = select.appendChild( document.createElement("option") );
- // Can't get basic test support
- if ( !all || !all.length || !a ) {
- return;
- }
- jQuery.support = {
- // IE strips leading whitespace when .innerHTML is used
- leadingWhitespace: div.firstChild.nodeType === 3,
- // Make sure that tbody elements aren't automatically inserted
- // IE will insert them into empty tables
- tbody: !div.getElementsByTagName("tbody").length,
- // Make sure that link elements get serialized correctly by innerHTML
- // This requires a wrapper element in IE
- htmlSerialize: !!div.getElementsByTagName("link").length,
- // Get the style information from getAttribute
- // (IE uses .cssText insted)
- style: /red/.test( a.getAttribute("style") ),
- // Make sure that URLs aren't manipulated
- // (IE normalizes it by default)
- hrefNormalized: a.getAttribute("href") === "/a",
- // Make sure that element opacity exists
- // (IE uses filter instead)
- // Use a regex to work around a WebKit issue. See #5145
- opacity: /^0.55$/.test( a.style.opacity ),
- // Verify style float existence
- // (IE uses styleFloat instead of cssFloat)
- cssFloat: !!a.style.cssFloat,
- // Make sure that if no value is specified for a checkbox
- // that it defaults to "on".
- // (WebKit defaults to "" instead)
- checkOn: div.getElementsByTagName("input")[0].value === "on",
- // Make sure that a selected-by-default option has a working selected property.
- // (WebKit defaults to false instead of true, IE too, if it's in an optgroup)
- optSelected: opt.selected,
- // Will be defined later
- deleteExpando: true,
- optDisabled: false,
- checkClone: false,
- _scriptEval: null,
- noCloneEvent: true,
- boxModel: null,
- inlineBlockNeedsLayout: false,
- shrinkWrapBlocks: false,
- reliableHiddenOffsets: true
- };
- // Make sure that the options inside disabled selects aren't marked as disabled
- // (WebKit marks them as diabled)
- select.disabled = true;
- jQuery.support.optDisabled = !opt.disabled;
- jQuery.support.scriptEval = function() {
- if ( jQuery.support._scriptEval === null ) {
- var root = document.documentElement,
- script = document.createElement("script"),
- id = "script" + jQuery.now();
- script.type = "text/javascript";
- try {
- script.appendChild( document.createTextNode( "window." + id + "=1;" ) );
- } catch(e) {}
- root.insertBefore( script, root.firstChild );
- // Make sure that the execution of code works by injecting a script
- // tag with appendChild/createTextNode
- // (IE doesn't support this, fails, and uses .text instead)
- if ( window[ id ] ) {
- jQuery.support._scriptEval = true;
- delete window[ id ];
- } else {
- jQuery.support._scriptEval = false;
- }
- root.removeChild( script );
- // release memory in IE
- root = script = id = null;
- }
- return jQuery.support._scriptEval;
- };
- // Test to see if it's possible to delete an expando from an element
- // Fails in Internet Explorer
- try {
- delete div.test;
- } catch(e) {
- jQuery.support.deleteExpando = false;
- }
- if ( div.attachEvent && div.fireEvent ) {
- div.attachEvent("onclick", function click() {
- // Cloning a node shouldn't copy over any
- // bound event handlers (IE does this)
- jQuery.support.noCloneEvent = false;
- div.detachEvent("onclick", click);
- });
- div.cloneNode(true).fireEvent("onclick");
- }
- div = document.createElement("div");
- div.innerHTML = "<input type='radio' name='radiotest' checked='checked'/>";
- var fragment = document.createDocumentFragment();
- fragment.appendChild( div.firstChild );
- // WebKit doesn't clone checked state correctly in fragments
- jQuery.support.checkClone = fragment.cloneNode(true).cloneNode(true).lastChild.checked;
- // Figure out if the W3C box model works as expected
- // document.body must exist before we can do this
- jQuery(function() {
- var div = document.createElement("div"),
- body = document.getElementsByTagName("body")[0];
- // Frameset documents with no body should not run this code
- if ( !body ) {
- return;
- }
- div.style.width = div.style.paddingLeft = "1px";
- body.appendChild( div );
- jQuery.boxModel = jQuery.support.boxModel = div.offsetWidth === 2;
- if ( "zoom" in div.style ) {
- // Check if natively block-level elements act like inline-block
- // elements when setting their display to 'inline' and giving
- // them layout
- // (IE < 8 does this)
- div.style.display = "inline";
- div.style.zoom = 1;
- jQuery.support.inlineBlockNeedsLayout = div.offsetWidth === 2;
- // Check if elements with layout shrink-wrap their children
- // (IE 6 does this)
- div.style.display = "";
- div.innerHTML = "<div style='width:4px;'></div>";
- jQuery.support.shrinkWrapBlocks = div.offsetWidth !== 2;
- }
- div.innerHTML = "<table><tr><td style='padding:0;border:0;display:none'></td><td>t</td></tr></table>";
- var tds = div.getElementsByTagName("td");
- // Check if table cells still have offsetWidth/Height when they are set
- // to display:none and there are still other visible table cells in a
- // table row; if so, offsetWidth/Height are not reliable for use when
- // determining if an element has been hidden directly using
- // display:none (it is still safe to use offsets if a parent element is
- // hidden; don safety goggles and see bug #4512 for more information).
- // (only IE 8 fails this test)
- jQuery.support.reliableHiddenOffsets = tds[0].offsetHeight === 0;
- tds[0].style.display = "";
- tds[1].style.display = "none";
- // Check if empty table cells still have offsetWidth/Height
- // (IE < 8 fail this test)
- jQuery.support.reliableHiddenOffsets = jQuery.support.reliableHiddenOffsets && tds[0].offsetHeight === 0;
- div.innerHTML = "";
- body.removeChild( div ).style.display = "none";
- div = tds = null;
- });
- // Technique from Juriy Zaytsev
- // http://thinkweb2.com/projects/prototype/detecting-event-support-without-browser-sniffing/
- var eventSupported = function( eventName ) {
- var el = document.createElement("div");
- eventName = "on" + eventName;
- // We only care about the case where non-standard event systems
- // are used, namely in IE. Short-circuiting here helps us to
- // avoid an eval call (in setAttribute) which can cause CSP
- // to go haywire. See: https://developer.mozilla.org/en/Security/CSP
- if ( !el.attachEvent ) {
- return true;
- }
- var isSupported = (eventName in el);
- if ( !isSupported ) {
- el.setAttribute(eventName, "return;");
- isSupported = typeof el[eventName] === "function";
- }
- el = null;
- return isSupported;
- };
- jQuery.support.submitBubbles = eventSupported("submit");
- jQuery.support.changeBubbles = eventSupported("change");
- // release memory in IE
- div = all = a = null;
- })();
- var rbrace = /^(?:\{.*\}|\[.*\])$/;
- jQuery.extend({
- cache: {},
- // Please use with caution
- uuid: 0,
- // Unique for each copy of jQuery on the page
- // Non-digits removed to match rinlinejQuery
- expando: "jQuery" + ( jQuery.fn.jquery + Math.random() ).replace( /\D/g, "" ),
- // The following elements throw uncatchable exceptions if you
- // attempt to add expando properties to them.
- noData: {
- "embed": true,
- // Ban all objects except for Flash (which handle expandos)
- "object": "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",
- "applet": true
- },
- hasData: function( elem ) {
- elem = elem.nodeType ? jQuery.cache[ elem[jQuery.expando] ] : elem[ jQuery.expando ];
- return !!elem && !jQuery.isEmptyObject(elem);
- },
- data: function( elem, name, data, pvt /* Internal Use Only */ ) {
- if ( !jQuery.acceptData( elem ) ) {
- return;
- }
- var internalKey = jQuery.expando, getByName = typeof name === "string", thisCache,
- // We have to handle DOM nodes and JS objects differently because IE6-7
- // can't GC object references properly across the DOM-JS boundary
- isNode = elem.nodeType,
- // Only DOM nodes need the global jQuery cache; JS object data is
- // attached directly to the object so GC can occur automatically
- cache = isNode ? jQuery.cache : elem,
- // Only defining an ID for JS objects if its cache already exists allows
- // the code to shortcut on the same path as a DOM node with no cache
- id = isNode ? elem[ jQuery.expando ] : elem[ jQuery.expando ] && jQuery.expando;
- // Avoid doing any more work than we need to when trying to get data on an
- // object that has no data at all
- if ( (!id || (pvt && id && !cache[ id ][ internalKey ])) && getByName && data === undefined ) {
- return;
- }
- if ( !id ) {
- // Only DOM nodes need a new unique ID for each element since their data
- // ends up in the global cache
- if ( isNode ) {
- elem[ jQuery.expando ] = id = ++jQuery.uuid;
- } else {
- id = jQuery.expando;
- }
- }
- if ( !cache[ id ] ) {
- cache[ id ] = {};
- }
- // An object can be passed to jQuery.data instead of a key/value pair; this gets
- // shallow copied over onto the existing cache
- if ( typeof name === "object" ) {
- if ( pvt ) {
- cache[ id ][ internalKey ] = jQuery.extend(cache[ id ][ internalKey ], name);
- } else {
- cache[ id ] = jQuery.extend(cache[ id ], name);
- }
- }
- thisCache = cache[ id ];
- // Internal jQuery data is stored in a separate object inside the object's data
- // cache in order to avoid key collisions between internal data and user-defined
- // data
- if ( pvt ) {
- if ( !thisCache[ internalKey ] ) {
- thisCache[ internalKey ] = {};
- }
- thisCache = thisCache[ internalKey ];
- }
- if ( data !== undefined ) {
- thisCache[ name ] = data;
- }
- // TODO: This is a hack for 1.5 ONLY. It will be removed in 1.6. Users should
- // not attempt to inspect the internal events object using jQuery.data, as this
- // internal data object is undocumented and subject to change.
- if ( name === "events" && !thisCache[name] ) {
- return thisCache[ internalKey ] && thisCache[ internalKey ].events;
- }
- return getByName ? thisCache[ name ] : thisCache;
- },
- removeData: function( elem, name, pvt /* Internal Use Only */ ) {
- if ( !jQuery.acceptData( elem ) ) {
- return;
- }
- var internalKey = jQuery.expando, isNode = elem.nodeType,
- // See jQuery.data for more information
- cache = isNode ? jQuery.cache : elem,
- // See jQuery.data for more information
- id = isNode ? elem[ jQuery.expando ] : jQuery.expando;
- // If there is already no cache entry for this object, there is no
- // purpose in continuing
- if ( !cache[ id ] ) {
- return;
- }
- if ( name ) {
- var thisCache = pvt ? cache[ id ][ internalKey ] : cache[ id ];
- if ( thisCache ) {
- delete thisCache[ name ];
- // If there is no data left in the cache, we want to continue
- // and let the cache object itself get destroyed
- if ( !jQuery.isEmptyObject(thisCache) ) {
- return;
- }
- }
- }
- // See jQuery.data for more information
- if ( pvt ) {
- delete cache[ id ][ internalKey ];
- // Don't destroy the parent cache unless the internal data object
- // had been the only thing left in it
- if ( !jQuery.isEmptyObject(cache[ id ]) ) {
- return;
- }
- }
- var internalCache = cache[ id ][ internalKey ];
- // Browsers that fail expando deletion also refuse to delete expandos on
- // the window, but it will allow it on all other JS objects; other browsers
- // don't care
- if ( jQuery.support.deleteExpando || cache != window ) {
- delete cache[ id ];
- } else {
- cache[ id ] = null;
- }
- // We destroyed the entire user cache at once because it's faster than
- // iterating through each key, but we need to continue to persist internal
- // data if it existed
- if ( internalCache ) {
- cache[ id ] = {};
- cache[ id ][ internalKey ] = internalCache;
- // Otherwise, we need to eliminate the expando on the node to avoid
- // false lookups in the cache for entries that no longer exist
- } else if ( isNode ) {
- // IE does not allow us to delete expando properties from nodes,
- // nor does it have a removeAttribute function on Document nodes;
- // we must handle all of these cases
- if ( jQuery.support.deleteExpando ) {
- delete elem[ jQuery.expando ];
- } else if ( elem.removeAttribute ) {
- elem.removeAttribute( jQuery.expando );
- } else {
- elem[ jQuery.expando ] = null;
- }
- }
- },
- // For internal use only.
- _data: function( elem, name, data ) {
- return jQuery.data( elem, name, data, true );
- },
- // A method for determining if a DOM node can handle the data expando
- acceptData: function( elem ) {
- if ( elem.nodeName ) {
- var match = jQuery.noData[ elem.nodeName.toLowerCase() ];
- if ( match ) {
- return !(match === true || elem.getAttribute("classid") !== match);
- }
- }
- return true;
- }
- });
- jQuery.fn.extend({
- data: function( key, value ) {
- var data = null;
- if ( typeof key === "undefined" ) {
- if ( this.length ) {
- data = jQuery.data( this[0] );
- if ( this[0].nodeType === 1 ) {
- var attr = this[0].attributes, name;
- for ( var i = 0, l = attr.length; i < l; i++ ) {
- name = attr[i].name;
- if ( name.indexOf( "data-" ) === 0 ) {
- name = name.substr( 5 );
- dataAttr( this[0], name, data[ name ] );
- }
- }
- }
- }
- return data;
- } else if ( typeof key === "object" ) {
- return this.each(function() {
- jQuery.data( this, key );
- });
- }
- var parts = key.split(".");
- parts[1] = parts[1] ? "." + parts[1] : "";
- if ( value === undefined ) {
- data = this.triggerHandler("getData" + parts[1] + "!", [parts[0]]);
- // Try to fetch any internally stored data first
- if ( data === undefined && this.length ) {
- data = jQuery.data( this[0], key );
- data = dataAttr( this[0], key, data );
- }
- return data === undefined && parts[1] ?
- this.data( parts[0] ) :
- data;
- } else {
- return this.each(function() {
- var $this = jQuery( this ),
- args = [ parts[0], value ];
- $this.triggerHandler( "setData" + parts[1] + "!", args );
- jQuery.data( this, key, value );
- $this.triggerHandler( "changeData" + parts[1] + "!", args );
- });
- }
- },
- removeData: function( key ) {
- return this.each(function() {
- jQuery.removeData( this, key );
- });
- }
- });
- function dataAttr( elem, key, data ) {
- // If nothing was found internally, try to fetch any
- // data from the HTML5 data-* attribute
- if ( data === undefined && elem.nodeType === 1 ) {
- data = elem.getAttribute( "data-" + key );
- if ( typeof data === "string" ) {
- try {
- data = data === "true" ? true :
- data === "false" ? false :
- data === "null" ? null :
- !jQuery.isNaN( data ) ? parseFloat( data ) :
- rbrace.test( data ) ? jQuery.parseJSON( data ) :
- data;
- } catch( e ) {}
- // Make sure we set the data so it isn't changed later
- jQuery.data( elem, key, data );
- } else {
- data = undefined;
- }
- }
- return data;
- }
- jQuery.extend({
- queue: function( elem, type, data ) {
- if ( !elem ) {
- return;
- }
- type = (type || "fx") + "queue";
- var q = jQuery._data( elem, type );
- // Speed up dequeue by getting out quickly if this is just a lookup
- if ( !data ) {
- return q || [];
- }
- if ( !q || jQuery.isArray(data) ) {
- q = jQuery._data( elem, type, jQuery.makeArray(data) );
- } else {
- q.push( data );
- }
- return q;
- },
- dequeue: function( elem, type ) {
- type = type || "fx";
- var queue = jQuery.queue( elem, type ),
- fn = queue.shift();
- // If the fx queue is dequeued, always remove the progress sentinel
- if ( fn === "inprogress" ) {
- fn = queue.shift();
- }
- if ( fn ) {
- // Add a progress sentinel to prevent the fx queue from being
- // automatically dequeued
- if ( type === "fx" ) {
- queue.unshift("inprogress");
- }
- fn.call(elem, function() {
- jQuery.dequeue(elem, type);
- });
- }
- if ( !queue.length ) {
- jQuery.removeData( elem, type + "queue", true );
- }
- }
- });
- jQuery.fn.extend({
- queue: function( type, data ) {
- if ( typeof type !== "string" ) {
- data = type;
- type = "fx";
- }
- if ( data === undefined ) {
- return jQuery.queue( this[0], type );
- }
- return this.each(function( i ) {
- var queue = jQuery.queue( this, type, data );
- if ( type === "fx" && queue[0] !== "inprogress" ) {
- jQuery.dequeue( this, type );
- }
- });
- },
- dequeue: function( type ) {
- return this.each(function() {
- jQuery.dequeue( this, type );
- });
- },
- // Based off of the plugin by Clint Helfers, with permission.
- // http://blindsignals.com/index.php/2009/07/jquery-delay/
- delay: function( time, type ) {
- time = jQuery.fx ? jQuery.fx.speeds[time] || time : time;
- type = type || "fx";
- return this.queue( type, function() {
- var elem = this;
- setTimeout(function() {
- jQuery.dequeue( elem, type );
- }, time );
- });
- },
- clearQueue: function( type ) {
- return this.queue( type || "fx", [] );
- }
- });
- var rclass = /[\n\t\r]/g,
- rspaces = /\s+/,
- rreturn = /\r/g,
- rspecialurl = /^(?:href|src|style)$/,
- rtype = /^(?:button|input)$/i,
- rfocusable = /^(?:button|input|object|select|textarea)$/i,
- rclickable = /^a(?:rea)?$/i,
- rradiocheck = /^(?:radio|checkbox)$/i;
- jQuery.props = {
- "for": "htmlFor",
- "class": "className",
- readonly: "readOnly",
- maxlength: "maxLength",
- cellspacing: "cellSpacing",
- rowspan: "rowSpan",
- colspan: "colSpan",
- tabindex: "tabIndex",
- usemap: "useMap",
- frameborder: "frameBorder"
- };
- jQuery.fn.extend({
- attr: function( name, value ) {
- return jQuery.access( this, name, value, true, jQuery.attr );
- },
- removeAttr: function( name, fn ) {
- return this.each(function(){
- jQuery.attr( this, name, "" );
- if ( this.nodeType === 1 ) {
- this.removeAttribute( name );
- }
- });
- },
- addClass: function( value ) {
- if ( jQuery.isFunction(value) ) {
- return this.each(function(i) {
- var self = jQuery(this);
- self.addClass( value.call(this, i, self.attr("class")) );
- });
- }
- if ( value && typeof value === "string" ) {
- var classNames = (value || "").split( rspaces );
- for ( var i = 0, l = this.length; i < l; i++ ) {
- var elem = this[i];
- if ( elem.nodeType === 1 ) {
- if ( !elem.className ) {
- elem.className = value;
- } else {
- var className = " " + elem.className + " ",
- setClass = elem.className;
- for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
- if ( className.indexOf( " " + classNames[c] + " " ) < 0 ) {
- setClass += " " + classNames[c];
- }
- }
- elem.className = jQuery.trim( setClass );
- }
- }
- }
- }
- return this;
- },
- removeClass: function( value ) {
- if ( jQuery.isFunction(value) ) {
- return this.each(function(i) {
- var self = jQuery(this);
- self.removeClass( value.call(this, i, self.attr("class")) );
- });
- }
- if ( (value && typeof value === "string") || value === undefined ) {
- var classNames = (value || "").split( rspaces );
- for ( var i = 0, l = this.length; i < l; i++ ) {
- var elem = this[i];
- if ( elem.nodeType === 1 && elem.className ) {
- if ( value ) {
- var className = (" " + elem.className + " ").replace(rclass, " ");
- for ( var c = 0, cl = classNames.length; c < cl; c++ ) {
- className = className.replace(" " + classNames[c] + " ", " ");
- }
- elem.className = jQuery.trim( className );
- } else {
- elem.className = "";
- }
- }
- }
- }
- return this;
- },
- toggleClass: function( value, stateVal ) {
- var type = typeof value,
- isBool = typeof stateVal === "boolean";
- if ( jQuery.isFunction( value ) ) {
- return this.each(function(i) {
- var self = jQuery(this);
- self.toggleClass( value.call(this, i, self.attr("class"), stateVal), stateVal );
- });
- }
- return this.each(function() {
- if ( type === "string" ) {
- // toggle individual class names
- var className,
- i = 0,
- self = jQuery( this ),
- state = stateVal,
- classNames = value.split( rspaces );
- while ( (className = classNames[ i++ ]) ) {
- // check each className given, space seperated list
- state = isBool ? state : !self.hasClass( className );
- self[ state ? "addClass" : "removeClass" ]( className );
- }
- } else if ( type === "undefined" || type === "boolean" ) {
- if ( this.className ) {
- // store className if set
- jQuery._data( this, "__className__", this.className );
- }
- // toggle whole className
- this.className = this.className || value === false ? "" : jQuery._data( this, "__className__" ) || "";
- }
- });
- },
- hasClass: function( selector ) {
- var className = " " + selector + " ";
- for ( var i = 0, l = this.length; i < l; i++ ) {
- if ( (" " + this[i].className + " ").replace(rclass, " ").indexOf( className ) > -1 ) {
- return true;
- }
- }
- return false;
- },
- val: function( value ) {
- if ( !arguments.length ) {
- var elem = this[0];
- if ( elem ) {
- if ( jQuery.nodeName( elem, "option" ) ) {
- // attributes.value is undefined in Blackberry 4.7 but
- // uses .value. See #6932
- var val = elem.attributes.value;
- return !val || val.specified ? elem.value : elem.text;
- }
- // We need to handle select boxes special
- if ( jQuery.nodeName( elem, "select" ) ) {
- var index = elem.selectedIndex,
- values = [],
- options = elem.options,
- one = elem.type === "select-one";
- // Nothing was selected
- if ( index < 0 ) {
- return null;
- }
- // Loop through all the selected options
- for ( var i = one ? index : 0, max = one ? index + 1 : options.length; i < max; i++ ) {
- var option = options[ i ];
- // Don't return options that are disabled or in a disabled optgroup
- if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) &&
- (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) {
- // Get the specific value for the option
- value = jQuery(option).val();
- // We don't need an array for one selects
- if ( one ) {
- return value;
- }
- // Multi-Selects return an array
- values.push( value );
- }
- }
- return values;
- }
- // Handle the case where in Webkit "" is returned instead of "on" if a value isn't specified
- if ( rradiocheck.test( elem.type ) && !jQuery.support.checkOn ) {
- return elem.getAttribute("value") === null ? "on" : elem.value;
- }
- // Everything else, we just grab the value
- return (elem.value || "").replace(rreturn, "");
- }
- return undefined;
- }
- var isFunction = jQuery.isFunction(value);
- return this.each(function(i) {
- var self = jQuery(this), val = value;
- if ( this.nodeType !== 1 ) {
- return;
- }
- if ( isFunction ) {
- val = value.call(this, i, self.val());
- }
- // Treat null/undefined as ""; convert numbers to string
- if ( val == null ) {
- val = "";
- } else if ( typeof val === "number" ) {
- val += "";
- } else if ( jQuery.isArray(val) ) {
- val = jQuery.map(val, function (value) {
- return value == null ? "" : value + "";
- });
- }
- if ( jQuery.isArray(val) && rradiocheck.test( this.type ) ) {
- this.checked = jQuery.inArray( self.val(), val ) >= 0;
- } else if ( jQuery.nodeName( this, "select" ) ) {
- var values = jQuery.makeArray(val);
- jQuery( "option", this ).each(function() {
- this.selected = jQuery.inArray( jQuery(this).val(), values ) >= 0;
- });
- if ( !values.length ) {
- this.selectedIndex = -1;
- }
- } else {
- this.value = val;
- }
- });
- }
- });
- jQuery.extend({
- attrFn: {
- val: true,
- css: true,
- html: true,
- text: true,
- data: true,
- width: true,
- height: true,
- offset: true
- },
- attr: function( elem, name, value, pass ) {
- // don't get/set attributes on text, comment and attribute nodes
- if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || elem.nodeType === 2 ) {
- return undefined;
- }
- if ( pass && name in jQuery.attrFn ) {
- return jQuery(elem)[name](value);
- }
- var notxml = elem.nodeType !== 1 || !jQuery.isXMLDoc( elem ),
- // Whether we are setting (or getting)
- set = value !== undefined;
- // Try to normalize/fix the name
- name = notxml && jQuery.props[ name ] || name;
- // Only do all the following if this is a node (faster for style)
- if ( elem.nodeType === 1 ) {
- // These attributes require special treatment
- var special = rspecialurl.test( name );
- // Safari mis-reports the default selected property of an option
- // Accessing the parent's selectedIndex property fixes it
- if ( name === "selected" && !jQuery.support.optSelected ) {
- var parent = elem.parentNode;
- if ( parent ) {
- parent.selectedIndex;
- // Make sure that it also works with optgroups, see #5701
- if ( parent.parentNode ) {
- parent.parentNode.selectedIndex;
- }
- }
- }
- // If applicable, access the attribute via the DOM 0 way
- // 'in' checks fail in Blackberry 4.7 #6931
- if ( (name in elem || elem[ name ] !== undefined) && notxml && !special ) {
- if ( set ) {
- // We can't allow the type property to be changed (since it causes problems in IE)
- if ( name === "type" && rtype.test( elem.nodeName ) && elem.parentNode ) {
- jQuery.error( "type property can't be changed" );
- }
- if ( value === null ) {
- if ( elem.nodeType === 1 ) {
- elem.removeAttribute( name );
- }
- } else {
- elem[ name ] = value;
- }
- }
- // browsers index elements by id/name on forms, give priority to attributes.
- if ( jQuery.nodeName( elem, "form" ) && elem.getAttributeNode(name) ) {
- return elem.getAttributeNode( name ).nodeValue;
- }
- // elem.tabIndex doesn't always return the correct value when it hasn't been explicitly set
- // http://fluidproject.org/blog/2008/01/09/getting-setting-and-removing-tabindex-values-with-javascript/
- if ( name === "tabIndex" ) {
- var attributeNode = elem.getAttributeNode( "tabIndex" );
- return attributeNode && attributeNode.specified ?
- attributeNode.value :
- rfocusable.test( elem.nodeName ) || rclickable.test( elem.nodeName ) && elem.href ?
- 0 :
- undefined;
- }
- return elem[ name ];
- }
- if ( !jQuery.support.style && notxml && name === "style" ) {
- if ( set ) {
- elem.style.cssText = "" + value;
- }
- return elem.style.cssText;
- }
- if ( set ) {
- // convert the value to a string (all browsers do this but IE) see #1070
- elem.setAttribute( name, "" + value );
- }
- // Ensure that missing attributes return undefined
- // Blackberry 4.7 returns "" from getAttribute #6938
- if ( !elem.attributes[ name ] && (elem.hasAttribute && !elem.hasAttribute( name )) ) {
- return undefined;
- }
- var attr = !jQuery.support.hrefNormalized && notxml && special ?
- // Some attributes require a special call on IE
- elem.getAttribute( name, 2 ) :
- elem.getAttribute( name );
- // Non-existent attributes return null, we normalize to undefined
- return attr === null ? undefined : attr;
- }
- // Handle everything which isn't a DOM element node
- if ( set ) {
- elem[ name ] = value;
- }
- return elem[ name ];
- }
- });
- var rnamespaces = /\.(.*)$/,
- rformElems = /^(?:textarea|input|select)$/i,
- rperiod = /\./g,
- rspace = / /g,
- rescape = /[^\w\s.|`]/g,
- fcleanup = function( nm ) {
- return nm.replace(rescape, "\\$&");
- },
- eventKey = "events";
- /*
- * A number of helper functions used for managing events.
- * Many of the ideas behind this code originated from
- * Dean Edwards' addEvent library.
- */
- jQuery.event = {
- // Bind an event to an element
- // Original by Dean Edwards
- add: function( elem, types, handler, data ) {
- if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
- return;
- }
- // For whatever reason, IE has trouble passing the window object
- // around, causing it to be cloned in the process
- if ( jQuery.isWindow( elem ) && ( elem !== window && !elem.frameElement ) ) {
- elem = window;
- }
- if ( handler === false ) {
- handler = returnFalse;
- } else if ( !handler ) {
- // Fixes bug #7229. Fix recommended by jdalton
- return;
- }
- var handleObjIn, handleObj;
- if ( handler.handler ) {
- handleObjIn = handler;
- handler = handleObjIn.handler;
- }
- // Make sure that the function being executed has a unique ID
- if ( !handler.guid ) {
- handler.guid = jQuery.guid++;
- }
- // Init the element's event structure
- var elemData = jQuery._data( elem );
- // If no elemData is found then we must be trying to bind to one of the
- // banned noData elements
- if ( !elemData ) {
- return;
- }
- var events = elemData[ eventKey ],
- eventHandle = elemData.handle;
- if ( typeof events === "function" ) {
- // On plain objects events is a fn that holds the the data
- // which prevents this data from being JSON serialized
- // the function does not need to be called, it just contains the data
- eventHandle = events.handle;
- events = events.events;
- } else if ( !events ) {
- if ( !elem.nodeType ) {
- // On plain objects, create a fn that acts as the holder
- // of the values to avoid JSON serialization of event data
- elemData[ eventKey ] = elemData = function(){};
- }
- elemData.events = events = {};
- }
- if ( !eventHandle ) {
- elemData.handle = eventHandle = function() {
- // Handle the second event of a trigger and when
- // an event is called after a page has unloaded
- return typeof jQuery !== "undefined" && !jQuery.event.triggered ?
- jQuery.event.handle.apply( eventHandle.elem, arguments ) :
- undefined;
- };
- }
- // Add elem as a property of the handle function
- // This is to prevent a memory leak with non-native events in IE.
- eventHandle.elem = elem;
- // Handle multiple events separated by a space
- // jQuery(...).bind("mouseover mouseout", fn);
- types = types.split(" ");
- var type, i = 0, namespaces;
- while ( (type = types[ i++ ]) ) {
- handleObj = handleObjIn ?
- jQuery.extend({}, handleObjIn) :
- { handler: handler, data: data };
- // Namespaced event handlers
- if ( type.indexOf(".") > -1 ) {
- namespaces = type.split(".");
- type = namespaces.shift();
- handleObj.namespace = namespaces.slice(0).sort().join(".");
- } else {
- namespaces = [];
- handleObj.namespace = "";
- }
- handleObj.type = type;
- if ( !handleObj.guid ) {
- handleObj.guid = handler.guid;
- }
- // Get the current list of functions bound to this event
- var handlers = events[ type ],
- special = jQuery.event.special[ type ] || {};
- // Init the event handler queue
- if ( !handlers ) {
- handlers = events[ type ] = [];
- // Check for a special event handler
- // Only use addEventListener/attachEvent if the special
- // events handler returns false
- if ( !special.setup || special.setup.call( elem, data, namespaces, eventHandle ) === false ) {
- // Bind the global event handler to the element
- if ( elem.addEventListener ) {
- elem.addEventListener( type, eventHandle, false );
- } else if ( elem.attachEvent ) {
- elem.attachEvent( "on" + type, eventHandle );
- }
- }
- }
- if ( special.add ) {
- special.add.call( elem, handleObj );
- if ( !handleObj.handler.guid ) {
- handleObj.handler.guid = handler.guid;
- }
- }
- // Add the function to the element's handler list
- handlers.push( handleObj );
- // Keep track of which events have been used, for global triggering
- jQuery.event.global[ type ] = true;
- }
- // Nullify elem to prevent memory leaks in IE
- elem = null;
- },
- global: {},
- // Detach an event or set of events from an element
- remove: function( elem, types, handler, pos ) {
- // don't do events on text and comment nodes
- if ( elem.nodeType === 3 || elem.nodeType === 8 ) {
- return;
- }
- if ( handler === false ) {
- handler = returnFalse;
- }
- var ret, type, fn, j, i = 0, all, namespaces, namespace, special, eventType, handleObj, origType,
- elemData = jQuery.hasData( elem ) && jQuery._data( elem ),
- events = elemData && elemData[ eventKey ];
- if ( !elemData || !events ) {
- return;
- }
- if ( typeof events === "function" ) {
- elemData = events;
- events = events.events;
- }
- // types is actually an event object here
- if ( types && types.type ) {
- handler = types.handler;
- types = types.type;
- }
- // Unbind all events for the element
- if ( !types || typeof types === "string" && types.charAt(0) === "." ) {
- types = types || "";
- for ( type in events ) {
- jQuery.event.remove( elem, type + types );
- }
- return;
- }
- // Handle multiple events separated by a space
- // jQuery(...).unbind("mouseover mouseout", fn);
- types = types.split(" ");
- while ( (type = types[ i++ ]) ) {
- origType = type;
- handleObj = null;
- all = type.indexOf(".") < 0;
- namespaces = [];
- if ( !all ) {
- // Namespaced event handlers
- namespaces = type.split(".");
- type = namespaces.shift();
- namespace = new RegExp("(^|\\.)" +
- jQuery.map( namespaces.slice(0).sort(), fcleanup ).join("\\.(?:.*\\.)?") + "(\\.|$)");
- }
- eventType = events[ type ];
- if ( !eventType ) {
- continue;
- }
- if ( !handler ) {
- for ( j = 0; j < eventType.length; j++ ) {
- handleObj = eventType[ j ];
- if ( all || namespace.test( handleObj.namespace ) ) {
- jQuery.event.remove( elem, origType, handleObj.handler, j );
- eventType.splice( j--, 1 );
- }
- }
- continue;
- }
- special = jQuery.event.special[ type ] || {};
- for ( j = pos || 0; j < eventType.length; j++ ) {
- handleObj = eventType[ j ];
- if ( handler.guid === handleObj.guid ) {
- // remove the given handler for the given type
- if ( all || namespace.test( handleObj.namespace ) ) {
- if ( pos == null ) {
- eventType.splice( j--, 1 );
- }
- if ( special.remove ) {
- special.remove.call( elem, handleObj );
- }
- }
- if ( pos != null ) {
- break;
- }
- }
- }
- // remove generic event handler if no more handlers exist
- if ( eventType.length === 0 || pos != null && eventType.length === 1 ) {
- if ( !special.teardown || special.teardown.call( elem, namespaces ) === false ) {
- jQuery.removeEvent( elem, type, elemData.handle );
- }
- ret = null;
- delete events[ type ];
- }
- }
- // Remove the expando if it's no longer used
- if ( jQuery.isEmptyObject( events ) ) {
- var handle = elemData.handle;
- if ( handle ) {
- handle.elem = null;
- }
- delete elemData.events;
- delete elemData.handle;
- if ( typeof elemData === "function" ) {
- jQuery.removeData( elem, eventKey, true );
- } else if ( jQuery.isEmptyObject( elemData ) ) {
- jQuery.removeData( elem, undefined, true );
- }
- }
- },
- // bubbling is internal
- trigger: function( event, data, elem /*, bubbling */ ) {
- // Event object or event type
- var type = event.type || event,
- bubbling = arguments[3];
- if ( !bubbling ) {
- event = typeof event === "object" ?
- // jQuery.Event object
- event[ jQuery.expando ] ? event :
- // Object literal
- jQuery.extend( jQuery.Event(type), event ) :
- // Just the event type (string)
- jQuery.Event(type);
- if ( type.indexOf("!") >= 0 ) {
- event.type = type = type.slice(0, -1);
- event.exclusive = true;
- }
- // Handle a global trigger
- if ( !elem ) {
- // Don't bubble custom events when global (to avoid too much overhead)
- event.stopPropagation();
- // Only trigger if we've ever bound an event for it
- if ( jQuery.event.global[ type ] ) {
- // XXX This code smells terrible. event.js should not be directly
- // inspecting the data cache
- jQuery.each( jQuery.cache, function() {
- // internalKey variable is just used to make it easier to find
- // and potentially change this stuff later; currently it just
- // points to jQuery.expando
- var internalKey = jQuery.expando,
- internalCache = this[ internalKey ];
- if ( internalCache && internalCache.events && internalCache.events[type] ) {
- jQuery.event.trigger( event, data, internalCache.handle.elem );
- }
- });
- }
- }
- // Handle triggering a single element
- // don't do events on text and comment nodes
- if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) {
- return undefined;
- }
- // Clean up in case it is reused
- event.result = undefined;
- event.target = elem;
- // Clone the incoming data, if any
- data = jQuery.makeArray( data );
- data.unshift( event );
- }
- event.currentTarget = elem;
- // Trigger the event, it is assumed that "handle" is a function
- var handle = elem.nodeType ?
- jQuery._data( elem, "handle" ) :
- (jQuery._data( elem, eventKey ) || {}).handle;
- if ( handle ) {
- handle.apply( elem, data );
- }
- var parent = elem.parentNode || elem.ownerDocument;
- // Trigger an inline bound script
- try {
- if ( !(elem && elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()]) ) {
- if ( elem[ "on" + type ] && elem[ "on" + type ].apply( elem, data ) === false ) {
- event.result = false;
- event.preventDefault();
- }
- }
- // prevent IE from throwing an error for some elements with some event types, see #3533
- } catch (inlineError) {}
- if ( !event.isPropagationStopped() && parent ) {
- jQuery.event.trigger( event, data, parent, true );
- } else if ( !event.isDefaultPrevented() ) {
- var old,
- target = event.target,
- targetType = type.replace( rnamespaces, "" ),
- isClick = jQuery.nodeName( target, "a" ) && targetType === "click",
- special = jQuery.event.special[ targetType ] || {};
- if ( (!special._default || special._default.call( elem, event ) === false) &&
- !isClick && !(target && target.nodeName && jQuery.noData[target.nodeName.toLowerCase()]) ) {
- try {
- if ( target[ targetType ] ) {
- // Make sure that we don't accidentally re-trigger the onFOO events
- old = target[ "on" + targetType ];
- if ( old ) {
- target[ "on" + targetType ] = null;
- }
- jQuery.event.triggered = true;
- target[ targetType ]();
- }
- // prevent IE from throwing an error for some elements with some event types, see #3533
- } catch (triggerError) {}
- if ( old ) {
- target[ "on" + targetType ] = old;
- }
- jQuery.event.triggered = false;
- }
- }
- },
- handle: function( event ) {
- var all, handlers, namespaces, namespace_re, events,
- namespace_sort = [],
- args = jQuery.makeArray( arguments );
- event = args[0] = jQuery.event.fix( event || window.event );
- event.currentTarget = this;
- // Namespaced event handlers
- all = event.type.indexOf(".") < 0 && !event.exclusive;
- if ( !all ) {
- namespaces = event.type.split(".");
- event.type = namespaces.shift();
- namespace_sort = namespaces.slice(0).sort();
- namespace_re = new RegExp("(^|\\.)" + namespace_sort.join("\\.(?:.*\\.)?") + "(\\.|$)");
- }
- event.namespace = event.namespace || namespace_sort.join(".");
- events = jQuery._data(this, eventKey);
- if ( typeof events === "function" ) {
- events = events.events;
- }
- handlers = (events || {})[ event.type ];
- if ( events && handlers ) {
- // Clone the handlers to prevent manipulation
- handlers = handlers.slice(0);
- for ( var j = 0, l = handlers.length; j < l; j++ ) {
- var handleObj = handlers[ j ];
- // Filter the functions by class
- if ( all || namespace_re.test( handleObj.namespace ) ) {
- // Pass in a reference to the handler function itself
- // So that we can later remove it
- event.handler = handleObj.handler;
- event.data = handleObj.data;
- event.handleObj = handleObj;
- var ret = handleObj.handler.apply( this, args );
- if ( ret !== undefined ) {
- event.result = ret;
- if ( ret === false ) {
- event.preventDefault();
- event.stopPropagation();
- }
- }
- if ( event.isImmediatePropagationStopped() ) {
- break;
- }
- }
- }
- }
- return event.result;
- },
- props: "altKey attrChange attrName bubbles button cancelable charCode clientX clientY ctrlKey currentTarget data detail eventPhase fromElement handler keyCode layerX layerY metaKey newValue offsetX offsetY pageX pageY prevValue relatedNode relatedTarget screenX screenY shiftKey srcElement target toElement view wheelDelta which".split(" "),
- fix: function( event ) {
- if ( event[ jQuery.expando ] ) {
- return event;
- }
- // store a copy of the original event object
- // and "clone" to set read-only properties
- var originalEvent = event;
- event = jQuery.Event( originalEvent );
- for ( var i = this.props.length, prop; i; ) {
- prop = this.props[ --i ];
- event[ prop ] = originalEvent[ prop ];
- }
- // Fix target property, if necessary
- if ( !event.target ) {
- // Fixes #1925 where srcElement might not be defined either
- event.target = event.srcElement || document;
- }
- // check if target is a textnode (safari)
- if ( event.target.nodeType === 3 ) {
- event.target = event.target.parentNode;
- }
- // Add relatedTarget, if necessary
- if ( !event.relatedTarget && event.fromElement ) {
- event.relatedTarget = event.fromElement === event.target ? event.toElement : event.fromElement;
- }
- // Calculate pageX/Y if missing and clientX/Y available
- if ( event.pageX == null && event.clientX != null ) {
- var doc = document.documentElement,
- body = document.body;
- event.pageX = event.clientX + (doc && doc.scrollLeft || body && body.scrollLeft || 0) - (doc && doc.clientLeft || body && body.clientLeft || 0);
- event.pageY = event.clientY + (doc && doc.scrollTop || body && body.scrollTop || 0) - (doc && doc.clientTop || body && body.clientTop || 0);
- }
- // Add which for key events
- if ( event.which == null && (event.charCode != null || event.keyCode != null) ) {
- event.which = event.charCode != null ? event.charCode : event.keyCode;
- }
- // Add metaKey to non-Mac browsers (use ctrl for PC's and Meta for Macs)
- if ( !event.metaKey && event.ctrlKey ) {
- event.metaKey = event.ctrlKey;
- }
- // Add which for click: 1 === left; 2 === middle; 3 === right
- // Note: button is not normalized, so don't use it
- if ( !event.which && event.button !== undefined ) {
- event.which = (event.button & 1 ? 1 : ( event.button & 2 ? 3 : ( event.button & 4 ? 2 : 0 ) ));
- }
- return event;
- },
- // Deprecated, use jQuery.guid instead
- guid: 1E8,
- // Deprecated, use jQuery.proxy instead
- proxy: jQuery.proxy,
- special: {
- ready: {
- // Make sure the ready event is setup
- setup: jQuery.bindReady,
- teardown: jQuery.noop
- },
- live: {
- add: function( handleObj ) {
- jQuery.event.add( this,
- liveConvert( handleObj.origType, handleObj.selector ),
- jQuery.extend({}, handleObj, {handler: liveHandler, guid: handleObj.handler.guid}) );
- },
- remove: function( handleObj ) {
- jQuery.event.remove( this, liveConvert( handleObj.origType, handleObj.selector ), handleObj );
- }
- },
- beforeunload: {
- setup: function( data, namespaces, eventHandle ) {
- // We only want to do this special case on windows
- if ( jQuery.isWindow( this ) ) {
- this.onbeforeunload = eventHandle;
- }
- },
- teardown: function( namespaces, eventHandle ) {
- if ( this.onbeforeunload === eventHandle ) {
- this.onbeforeunload = null;
- }
- }
- }
- }
- };
- jQuery.removeEvent = document.removeEventListener ?
- function( elem, type, handle ) {
- if ( elem.removeEventListener ) {
- elem.removeEventListener( type, handle, false );
- }
- } :
- function( elem, type, handle ) {
- if ( elem.detachEvent ) {
- elem.detachEvent( "on" + type, handle );
- }
- };
- jQuery.Event = function( src ) {
- // Allow instantiation without the 'new' keyword
- if ( !this.preventDefault ) {
- return new jQuery.Event( src );
- }
- // Event object
- if ( src && src.type ) {
- this.originalEvent = src;
- this.type = src.type;
- // Events bubbling up the document may have been marked as prevented
- // by a handler lower down the tree; reflect the correct value.
- this.isDefaultPrevented = (src.defaultPrevented || src.returnValue === false ||
- src.getPreventDefault && src.getPreventDefault()) ? returnTrue : returnFalse;
- // Event type
- } else {
- this.type = src;
- }
- // timeStamp is buggy for some events on Firefox(#3843)
- // So we won't rely on the native value
- this.timeStamp = jQuery.now();
- // Mark it as fixed
- this[ jQuery.expando ] = true;
- };
- function returnFalse() {
- return false;
- }
- function returnTrue() {
- return true;
- }
- // jQuery.Event is based on DOM3 Events as specified by the ECMAScript Language Binding
- // http://www.w3.org/TR/2003/WD-DOM-Level-3-Events-20030331/ecma-script-binding.html
- jQuery.Event.prototype = {
- preventDefault: function() {
- this.isDefaultPrevented = returnTrue;
- var e = this.originalEvent;
- if ( !e ) {
- return;
- }
- // if preventDefault exists run it on the original event
- if ( e.preventDefault ) {
- e.preventDefault();
- // otherwise set the returnValue property of the original event to false (IE)
- } else {
- e.returnValue = false;
- }
- },
- stopPropagation: function() {
- this.isPropagationStopped = returnTrue;
- var e = this.originalEvent;
- if ( !e ) {
- return;
- }
- // if stopPropagation exists run it on the original event
- if ( e.stopPropagation ) {
- e.stopPropagation();
- }
- // otherwise set the cancelBubble property of the original event to true (IE)
- e.cancelBubble = true;
- },
- stopImmediatePropagation: function() {
- this.isImmediatePropagationStopped = returnTrue;
- this.stopPropagation();
- },
- isDefaultPrevented: returnFalse,
- isPropagationStopped: returnFalse,
- isImmediatePropagationStopped: returnFalse
- };
- // Checks if an event happened on an element within another element
- // Used in jQuery.event.special.mouseenter and mouseleave handlers
- var withinElement = function( event ) {
- // Check if mouse(over|out) are still within the same parent element
- var parent = event.relatedTarget;
- // Firefox sometimes assigns relatedTarget a XUL element
- // which we cannot access the parentNode property of
- try {
- // Traverse up the tree
- while ( parent && parent !== this ) {
- parent = parent.parentNode;
- }
- if ( parent !== this ) {
- // set the correct event type
- event.type = event.data;
- // handle event if we actually just moused on to a non sub-element
- jQuery.event.handle.apply( this, arguments );
- }
- // assuming we've left the element since we most likely mousedover a xul element
- } catch(e) { }
- },
- // In case of event delegation, we only need to rename the event.type,
- // liveHandler will take care of the rest.
- delegate = function( event ) {
- event.type = event.data;
- jQuery.event.handle.apply( this, arguments );
- };
- // Create mouseenter and mouseleave events
- jQuery.each({
- mouseenter: "mouseover",
- mouseleave: "mouseout"
- }, function( orig, fix ) {
- jQuery.event.special[ orig ] = {
- setup: function( data ) {
- jQuery.event.add( this, fix, data && data.selector ? delegate : withinElement, orig );
- },
- teardown: function( data ) {
- jQuery.event.remove( this, fix, data && data.selector ? delegate : withinElement );
- }
- };
- });
- // submit delegation
- if ( !jQuery.support.submitBubbles ) {
- jQuery.event.special.submit = {
- setup: function( data, namespaces ) {
- if ( this.nodeName && this.nodeName.toLowerCase() !== "form" ) {
- jQuery.event.add(this, "click.specialSubmit", function( e ) {
- var elem = e.target,
- type = elem.type;
- if ( (type === "submit" || type === "image") && jQuery( elem ).closest("form").length ) {
- e.liveFired = undefined;
- return trigger( "submit", this, arguments );
- }
- });
- jQuery.event.add(this, "keypress.specialSubmit", function( e ) {
- var elem = e.target,
- type = elem.type;
- if ( (type === "text" || type === "password") && jQuery( elem ).closest("form").length && e.keyCode === 13 ) {
- e.liveFired = undefined;
- return trigger( "submit", this, arguments );
- }
- });
- } else {
- return false;
- }
- },
- teardown: function( namespaces ) {
- jQuery.event.remove( this, ".specialSubmit" );
- }
- };
- }
- // change delegation, happens here so we have bind.
- if ( !jQuery.support.changeBubbles ) {
- var changeFilters,
- getVal = function( elem ) {
- var type = elem.type, val = elem.value;
- if ( type === "radio" || type === "checkbox" ) {
- val = elem.checked;
- } else if ( type === "select-multiple" ) {
- val = elem.selectedIndex > -1 ?
- jQuery.map( elem.options, function( elem ) {
- return elem.selected;
- }).join("-") :
- "";
- } else if ( elem.nodeName.toLowerCase() === "select" ) {
- val = elem.selectedIndex;
- }
- return val;
- },
- testChange = function testChange( e ) {
- var elem = e.target, data, val;
- if ( !rformElems.test( elem.nodeName ) || elem.readOnly ) {
- return;
- }
- data = jQuery._data( elem, "_change_data" );
- val = getVal(elem);
- // the current data will be also retrieved by beforeactivate
- if ( e.type !== "focusout" || elem.type !== "radio" ) {
- jQuery._data( elem, "_change_data", val );
- }
- if ( data === undefined || val === data ) {
- return;
- }
- if ( data != null || val ) {
- e.type = "change";
- e.liveFired = undefined;
- return jQuery.event.trigger( e, arguments[1], elem );
- }
- };
- jQuery.event.special.change = {
- filters: {
- focusout: testChange,
- beforedeactivate: testChange,
- click: function( e ) {
- var elem = e.target, type = elem.type;
- if ( type === "radio" || type === "checkbox" || elem.nodeName.toLowerCase() === "select" ) {
- return testChange.call( this, e );
- }
- },
- // Change has to be called before submit
- // Keydown will be called before keypress, which is used in submit-event delegation
- keydown: function( e ) {
- var elem = e.target, type = elem.type;
- if ( (e.keyCode === 13 && elem.nodeName.toLowerCase() !== "textarea") ||
- (e.keyCode === 32 && (type === "checkbox" || type === "radio")) ||
- type === "select-multiple" ) {
- return testChange.call( this, e );
- }
- },
- // Beforeactivate happens also before the previous element is blurred
- // with this event you can't trigger a change event, but you can store
- // information
- beforeactivate: function( e ) {
- var elem = e.target;
- jQuery._data( elem, "_change_data", getVal(elem) );
- }
- },
- setup: function( data, namespaces ) {
- if ( this.type === "file" ) {
- return false;
- }
- for ( var type in changeFilters ) {
- jQuery.event.add( this, type + ".specialChange", changeFilters[type] );
- }
- return rformElems.test( this.nodeName );
- },
- teardown: function( namespaces ) {
- jQuery.event.remove( this, ".specialChange" );
- return rformElems.test( this.nodeName );
- }
- };
- changeFilters = jQuery.event.special.change.filters;
- // Handle when the input is .focus()'d
- changeFilters.focus = changeFilters.beforeactivate;
- }
- function trigger( type, elem, args ) {
- args[0].type = type;
- return jQuery.event.handle.apply( elem, args );
- }
- // Create "bubbling" focus and blur events
- if ( document.addEventListener ) {
- jQuery.each({ focus: "focusin", blur: "focusout" }, function( orig, fix ) {
- jQuery.event.special[ fix ] = {
- setup: function() {
- this.addEventListener( orig, handler, true );
- },
- teardown: function() {
- this.removeEventListener( orig, handler, true );
- }
- };
- function handler( e ) {
- e = jQuery.event.fix( e );
- e.type = fix;
- return jQuery.event.handle.call( this, e );
- }
- });
- }
- jQuery.each(["bind", "one"], function( i, name ) {
- jQuery.fn[ name ] = function( type, data, fn ) {
- // Handle object literals
- if ( typeof type === "object" ) {
- for ( var key in type ) {
- this[ name ](key, data, type[key], fn);
- }
- return this;
- }
- if ( jQuery.isFunction( data ) || data === false ) {
- fn = data;
- data = undefined;
- }
- var handler = name === "one" ? jQuery.proxy( fn, function( event ) {
- jQuery( this ).unbind( event, handler );
- return fn.apply( this, arguments );
- }) : fn;
- if ( type === "unload" && name !== "one" ) {
- this.one( type, data, fn );
- } else {
- for ( var i = 0, l = this.length; i < l; i++ ) {
- jQuery.event.add( this[i], type, handler, data );
- }
- }
- return this;
- };
- });
- jQuery.fn.extend({
- unbind: function( type, fn ) {
- // Handle object literals
- if ( typeof type === "object" && !type.preventDefault ) {
- for ( var key in type ) {
- this.unbind(key, type[key]);
- }
- } else {
- for ( var i = 0, l = this.length; i < l; i++ ) {
- jQuery.event.remove( this[i], type, fn );
- }
- }
- return this;
- },
- delegate: function( selector, types, data, fn ) {
- return this.live( types, data, fn, selector );
- },
- undelegate: function( selector, types, fn ) {
- if ( arguments.length === 0 ) {
- return this.unbind( "live" );
- } else {
- return this.die( types, null, fn, selector );
- }
- },
- trigger: function( type, data ) {
- return this.each(function() {
- jQuery.event.trigger( type, data, this );
- });
- },
- triggerHandler: function( type, data ) {
- if ( this[0] ) {
- var event = jQuery.Event( type );
- event.preventDefault();
- event.stopPropagation();
- jQuery.event.trigger( event, data, this[0] );
- return event.result;
- }
- },
- toggle: function( fn ) {
- // Save reference to arguments for access in closure
- var args = arguments,
- i = 1;
- // link all the functions, so any of them can unbind this click handler
- while ( i < args.length ) {
- jQuery.proxy( fn, args[ i++ ] );
- }
- return this.click( jQuery.proxy( fn, function( event ) {
- // Figure out which function to execute
- var lastToggle = ( jQuery._data( this, "lastToggle" + fn.guid ) || 0 ) % i;
- jQuery._data( this, "lastToggle" + fn.guid, lastToggle + 1 );
- // Make sure that clicks stop
- event.preventDefault();
- // and execute the function
- return args[ lastToggle ].apply( this, arguments ) || false;
- }));
- },
- hover: function( fnOver, fnOut ) {
- return this.mouseenter( fnOver ).mouseleave( fnOut || fnOver );
- }
- });
- var liveMap = {
- focus: "focusin",
- blur: "focusout",
- mouseenter: "mouseover",
- mouseleave: "mouseout"
- };
- jQuery.each(["live", "die"], function( i, name ) {
- jQuery.fn[ name ] = function( types, data, fn, origSelector /* Internal Use Only */ ) {
- var type, i = 0, match, namespaces, preType,
- selector = origSelector || this.selector,
- context = origSelector ? this : jQuery( this.context );
- if ( typeof types === "object" && !types.preventDefault ) {
- for ( var key in types ) {
- context[ name ]( key, data, types[key], selector );
- }
- return this;
- }
- if ( jQuery.isFunction( data ) ) {
- fn = data;
- data = undefined;
- }
- types = (types || "").split(" ");
- while ( (type = types[ i++ ]) != null ) {
- match = rnamespaces.exec( type );
- namespaces = "";
- if ( match ) {
- namespaces = match[0];
- type = type.replace( rnamespaces, "" );
- }
- if ( type === "hover" ) {
- types.push( "mouseenter" + namespaces, "mouseleave" + namespaces );
- continue;
- }
- preType = type;
- if ( type === "focus" || type === "blur" ) {
- types.push( liveMap[ type ] + namespaces );
- type = type + namespaces;
- } else {
- type = (liveMap[ type ] || type) + namespaces;
- }
- if ( name === "live" ) {
- // bind live handler
- for ( var j = 0, l = context.length; j < l; j++ ) {
- jQuery.event.add( context[j], "live." + liveConvert( type, selector ),
- { data: data, selector: selector, handler: fn, origType: type, origHandler: fn, preType: preType } );
- }
- } else {
- // unbind live handler
- context.unbind( "live." + liveConvert( type, selector ), fn );
- }
- }
- return this;
- };
- });
- function liveHandler( event ) {
- var stop, maxLevel, related, match, handleObj, elem, j, i, l, data, close, namespace, ret,
- elems = [],
- selectors = [],
- events = jQuery._data( this, eventKey );
- if ( typeof events === "function" ) {
- events = events.events;
- }
- // Make sure we avoid non-left-click bubbling in Firefox (#3861) and disabled elements in IE (#6911)
- if ( event.liveFired === this || !events || !events.live || event.target.disabled || event.button && event.type === "click" ) {
- return;
- }
- if ( event.namespace ) {
- namespace = new RegExp("(^|\\.)" + event.namespace.split(".").join("\\.(?:.*\\.)?") + "(\\.|$)");
- }
- event.liveFired = this;
- var live = events.live.slice(0);
- for ( j = 0; j < live.length; j++ ) {
- handleObj = live[j];
- if ( handleObj.origType.replace( rnamespaces, "" ) === event.type ) {
- selectors.push( handleObj.selector );
- } else {
- live.splice( j--, 1 );
- }
- }
- match = jQuery( event.target ).closest( selectors, event.currentTarget );
- for ( i = 0, l = match.length; i < l; i++ ) {
- close = match[i];
- for ( j = 0; j < live.length; j++ ) {
- handleObj = live[j];
- if ( close.selector === handleObj.selector && (!namespace || namespace.test( handleObj.namespace )) ) {
- elem = close.elem;
- related = null;
- // Those two events require additional checking
- if ( handleObj.preType === "mouseenter" || handleObj.preType === "mouseleave" ) {
- event.type = handleObj.preType;
- related = jQuery( event.relatedTarget ).closest( handleObj.selector )[0];
- }
- if ( !related || related !== elem ) {
- elems.push({ elem: elem, handleObj: handleObj, level: close.level });
- }
- }
- }
- }
- for ( i = 0, l = elems.length; i < l; i++ ) {
- match = elems[i];
- if ( maxLevel && match.level > maxLevel ) {
- break;
- }
- event.currentTarget = match.elem;
- event.data = match.handleObj.data;
- event.handleObj = match.handleObj;
- ret = match.handleObj.origHandler.apply( match.elem, arguments );
- if ( ret === false || event.isPropagationStopped() ) {
- maxLevel = match.level;
- if ( ret === false ) {
- stop = false;
- }
- if ( event.isImmediatePropagationStopped() ) {
- break;
- }
- }
- }
- return stop;
- }
- function liveConvert( type, selector ) {
- return (type && type !== "*" ? type + "." : "") + selector.replace(rperiod, "`").replace(rspace, "&");
- }
- jQuery.each( ("blur focus focusin focusout load resize scroll unload click dblclick " +
- "mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave " +
- "change select submit keydown keypress keyup error").split(" "), function( i, name ) {
- // Handle event binding
- jQuery.fn[ name ] = function( data, fn ) {
- if ( fn == null ) {
- fn = data;
- data = null;
- }
- return arguments.length > 0 ?
- this.bind( name, data, fn ) :
- this.trigger( name );
- };
- if ( jQuery.attrFn ) {
- jQuery.attrFn[ name ] = true;
- }
- });
- /*!
- * Sizzle CSS Selector Engine
- * Copyright 2011, The Dojo Foundation
- * Released under the MIT, BSD, and GPL Licenses.
- * More information: http://sizzlejs.com/
- */
- (function(){
- var chunker = /((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^\[\]]*\]|['"][^'"]*['"]|[^\[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,
- done = 0,
- toString = Object.prototype.toString,
- hasDuplicate = false,
- baseHasDuplicate = true;
- // Here we check if the JavaScript engine is using some sort of
- // optimization where it does not always call our comparision
- // function. If that is the case, discard the hasDuplicate value.
- // Thus far that includes Google Chrome.
- [0, 0].sort(function() {
- baseHasDuplicate = false;
- return 0;
- });
- var Sizzle = function( selector, context, results, seed ) {
- results = results || [];
- context = context || document;
- var origContext = context;
- if ( context.nodeType !== 1 && context.nodeType !== 9 ) {
- return [];
- }
-
- if ( !selector || typeof selector !== "string" ) {
- return results;
- }
- var m, set, checkSet, extra, ret, cur, pop, i,
- prune = true,
- contextXML = Sizzle.isXML( context ),
- parts = [],
- soFar = selector;
-
- // Reset the position of the chunker regexp (start from head)
- do {
- chunker.exec( "" );
- m = chunker.exec( soFar );
- if ( m ) {
- soFar = m[3];
-
- parts.push( m[1] );
-
- if ( m[2] ) {
- extra = m[3];
- break;
- }
- }
- } while ( m );
- if ( parts.length > 1 && origPOS.exec( selector ) ) {
- if ( parts.length === 2 && Expr.relative[ parts[0] ] ) {
- set = posProcess( parts[0] + parts[1], context );
- } else {
- set = Expr.relative[ parts[0] ] ?
- [ context ] :
- Sizzle( parts.shift(), context );
- while ( parts.length ) {
- selector = parts.shift();
- if ( Expr.relative[ selector ] ) {
- selector += parts.shift();
- }
-
- set = posProcess( selector, set );
- }
- }
- } else {
- // Take a shortcut and set the context if the root selector is an ID
- // (but not if it'll be faster if the inner selector is an ID)
- if ( !seed && parts.length > 1 && context.nodeType === 9 && !contextXML &&
- Expr.match.ID.test(parts[0]) && !Expr.match.ID.test(parts[parts.length - 1]) ) {
- ret = Sizzle.find( parts.shift(), context, contextXML );
- context = ret.expr ?
- Sizzle.filter( ret.expr, ret.set )[0] :
- ret.set[0];
- }
- if ( context ) {
- ret = seed ?
- { expr: parts.pop(), set: makeArray(seed) } :
- Sizzle.find( parts.pop(), parts.length === 1 && (parts[0] === "~" || parts[0] === "+") && context.parentNode ? context.parentNode : context, contextXML );
- set = ret.expr ?
- Sizzle.filter( ret.expr, ret.set ) :
- ret.set;
- if ( parts.length > 0 ) {
- checkSet = makeArray( set );
- } else {
- prune = false;
- }
- while ( parts.length ) {
- cur = parts.pop();
- pop = cur;
- if ( !Expr.relative[ cur ] ) {
- cur = "";
- } else {
- pop = parts.pop();
- }
- if ( pop == null ) {
- pop = context;
- }
- Expr.relative[ cur ]( checkSet, pop, contextXML );
- }
- } else {
- checkSet = parts = [];
- }
- }
- if ( !checkSet ) {
- checkSet = set;
- }
- if ( !checkSet ) {
- Sizzle.error( cur || selector );
- }
- if ( toString.call(checkSet) === "[object Array]" ) {
- if ( !prune ) {
- results.push.apply( results, checkSet );
- } else if ( context && context.nodeType === 1 ) {
- for ( i = 0; checkSet[i] != null; i++ ) {
- if ( checkSet[i] && (checkSet[i] === true || checkSet[i].nodeType === 1 && Sizzle.contains(context, checkSet[i])) ) {
- results.push( set[i] );
- }
- }
- } else {
- for ( i = 0; checkSet[i] != null; i++ ) {
- if ( checkSet[i] && checkSet[i].nodeType === 1 ) {
- results.push( set[i] );
- }
- }
- }
- } else {
- makeArray( checkSet, results );
- }
- if ( extra ) {
- Sizzle( extra, origContext, results, seed );
- Sizzle.uniqueSort( results );
- }
- return results;
- };
- Sizzle.uniqueSort = function( results ) {
- if ( sortOrder ) {
- hasDuplicate = baseHasDuplicate;
- results.sort( sortOrder );
- if ( hasDuplicate ) {
- for ( var i = 1; i < results.length; i++ ) {
- if ( results[i] === results[ i - 1 ] ) {
- results.splice( i--, 1 );
- }
- }
- }
- }
- return results;
- };
- Sizzle.matches = function( expr, set ) {
- return Sizzle( expr, null, null, set );
- };
- Sizzle.matchesSelector = function( node, expr ) {
- return Sizzle( expr, null, null, [node] ).length > 0;
- };
- Sizzle.find = function( expr, context, isXML ) {
- var set;
- if ( !expr ) {
- return [];
- }
- for ( var i = 0, l = Expr.order.length; i < l; i++ ) {
- var match,
- type = Expr.order[i];
-
- if ( (match = Expr.leftMatch[ type ].exec( expr )) ) {
- var left = match[1];
- match.splice( 1, 1 );
- if ( left.substr( left.length - 1 ) !== "\\" ) {
- match[1] = (match[1] || "").replace(/\\/g, "");
- set = Expr.find[ type ]( match, context, isXML );
- if ( set != null ) {
- expr = expr.replace( Expr.match[ type ], "" );
- break;
- }
- }
- }
- }
- if ( !set ) {
- set = typeof context.getElementsByTagName !== "undefined" ?
- context.getElementsByTagName( "*" ) :
- [];
- }
- return { set: set, expr: expr };
- };
- Sizzle.filter = function( expr, set, inplace, not ) {
- var match, anyFound,
- old = expr,
- result = [],
- curLoop = set,
- isXMLFilter = set && set[0] && Sizzle.isXML( set[0] );
- while ( expr && set.length ) {
- for ( var type in Expr.filter ) {
- if ( (match = Expr.leftMatch[ type ].exec( expr )) != null && match[2] ) {
- var found, item,
- filter = Expr.filter[ type ],
- left = match[1];
- anyFound = false;
- match.splice(1,1);
- if ( left.substr( left.length - 1 ) === "\\" ) {
- continue;
- }
- if ( curLoop === result ) {
- result = [];
- }
- if ( Expr.preFilter[ type ] ) {
- match = Expr.preFilter[ type ]( match, curLoop, inplace, result, not, isXMLFilter );
- if ( !match ) {
- anyFound = found = true;
- } else if ( match === true ) {
- continue;
- }
- }
- if ( match ) {
- for ( var i = 0; (item = curLoop[i]) != null; i++ ) {
- if ( item ) {
- found = filter( item, match, i, curLoop );
- var pass = not ^ !!found;
- if ( inplace && found != null ) {
- if ( pass ) {
- anyFound = true;
- } else {
- curLoop[i] = false;
- }
- } else if ( pass ) {
- result.push( item );
- anyFound = true;
- }
- }
- }
- }
- if ( found !== undefined ) {
- if ( !inplace ) {
- curLoop = result;
- }
- expr = expr.replace( Expr.match[ type ], "" );
- if ( !anyFound ) {
- return [];
- }
- break;
- }
- }
- }
- // Improper expression
- if ( expr === old ) {
- if ( anyFound == null ) {
- Sizzle.error( expr );
- } else {
- break;
- }
- }
- old = expr;
- }
- return curLoop;
- };
- Sizzle.error = function( msg ) {
- throw "Syntax error, unrecognized expression: " + msg;
- };
- var Expr = Sizzle.selectors = {
- order: [ "ID", "NAME", "TAG" ],
- match: {
- ID: /#((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
- CLASS: /\.((?:[\w\u00c0-\uFFFF\-]|\\.)+)/,
- NAME: /\[name=['"]*((?:[\w\u00c0-\uFFFF\-]|\\.)+)['"]*\]/,
- ATTR: /\[\s*((?:[\w\u00c0-\uFFFF\-]|\\.)+)\s*(?:(\S?=)\s*(?:(['"])(.*?)\3|(#?(?:[\w\u00c0-\uFFFF\-]|\\.)*)|)|)\s*\]/,
- TAG: /^((?:[\w\u00c0-\uFFFF\*\-]|\\.)+)/,
- CHILD: /:(only|nth|last|first)-child(?:\(\s*(even|odd|(?:[+\-]?\d+|(?:[+\-]?\d*)?n\s*(?:[+\-]\s*\d+)?))\s*\))?/,
- POS: /:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^\-]|$)/,
- PSEUDO: /:((?:[\w\u00c0-\uFFFF\-]|\\.)+)(?:\((['"]?)((?:\([^\)]+\)|[^\(\)]*)+)\2\))?/
- },
- leftMatch: {},
- attrMap: {
- "class": "className",
- "for": "htmlFor"
- },
- attrHandle: {
- href: function( elem ) {
- return elem.getAttribute( "href" );
- }
- },
- relative: {
- "+": function(checkSet, part){
- var isPartStr = typeof part === "string",
- isTag = isPartStr && !/\W/.test( part ),
- isPartStrNotTag = isPartStr && !isTag;
- if ( isTag ) {
- part = part.toLowerCase();
- }
- for ( var i = 0, l = checkSet.length, elem; i < l; i++ ) {
- if ( (elem = checkSet[i]) ) {
- while ( (elem = elem.previousSibling) && elem.nodeType !== 1 ) {}
- checkSet[i] = isPartStrNotTag || elem && elem.nodeName.toLowerCase() === part ?
- elem || false :
- elem === part;
- }
- }
- if ( isPartStrNotTag ) {
- Sizzle.filter( part, checkSet, true );
- }
- },
- ">": function( checkSet, part ) {
- var elem,
- isPartStr = typeof part === "string",
- i = 0,
- l = checkSet.length;
- if ( isPartStr && !/\W/.test( part ) ) {
- part = part.toLowerCase();
- for ( ; i < l; i++ ) {
- elem = checkSet[i];
- if ( elem ) {
- var parent = elem.parentNode;
- checkSet[i] = parent.nodeName.toLowerCase() === part ? parent : false;
- }
- }
- } else {
- for ( ; i < l; i++ ) {
- elem = checkSet[i];
- if ( elem ) {
- checkSet[i] = isPartStr ?
- elem.parentNode :
- elem.parentNode === part;
- }
- }
- if ( isPartStr ) {
- Sizzle.filter( part, checkSet, true );
- }
- }
- },
- "": function(checkSet, part, isXML){
- var nodeCheck,
- doneName = done++,
- checkFn = dirCheck;
- if ( typeof part === "string" && !/\W/.test(part) ) {
- part = part.toLowerCase();
- nodeCheck = part;
- checkFn = dirNodeCheck;
- }
- checkFn( "parentNode", part, doneName, checkSet, nodeCheck, isXML );
- },
- "~": function( checkSet, part, isXML ) {
- var nodeCheck,
- doneName = done++,
- checkFn = dirCheck;
- if ( typeof part === "string" && !/\W/.test( part ) ) {
- part = part.toLowerCase();
- nodeCheck = part;
- checkFn = dirNodeCheck;
- }
- checkFn( "previousSibling", part, doneName, checkSet, nodeCheck, isXML );
- }
- },
- find: {
- ID: function( match, context, isXML ) {
- if ( typeof context.getElementById !== "undefined" && !isXML ) {
- var m = context.getElementById(match[1]);
- // Check parentNode to catch when Blackberry 4.6 returns
- // nodes that are no longer in the document #6963
- return m && m.parentNode ? [m] : [];
- }
- },
- NAME: function( match, context ) {
- if ( typeof context.getElementsByName !== "undefined" ) {
- var ret = [],
- results = context.getElementsByName( match[1] );
- for ( var i = 0, l = results.length; i < l; i++ ) {
- if ( results[i].getAttribute("name") === match[1] ) {
- ret.push( results[i] );
- }
- }
- return ret.length === 0 ? null : ret;
- }
- },
- TAG: function( match, context ) {
- if ( typeof context.getElementsByTagName !== "undefined" ) {
- return context.getElementsByTagName( match[1] );
- }
- }
- },
- preFilter: {
- CLASS: function( match, curLoop, inplace, result, not, isXML ) {
- match = " " + match[1].replace(/\\/g, "") + " ";
- if ( isXML ) {
- return match;
- }
- for ( var i = 0, elem; (elem = curLoop[i]) != null; i++ ) {
- if ( elem ) {
- if ( not ^ (elem.className && (" " + elem.className + " ").replace(/[\t\n\r]/g, " ").indexOf(match) >= 0) ) {
- if ( !inplace ) {
- result.push( elem );
- }
- } else if ( inplace ) {
- curLoop[i] = false;
- }
- }
- }
- return false;
- },
- ID: function( match ) {
- return match[1].replace(/\\/g, "");
- },
- TAG: function( match, curLoop ) {
- return match[1].toLowerCase();
- },
- CHILD: function( match ) {
- if ( match[1] === "nth" ) {
- if ( !match[2] ) {
- Sizzle.error( match[0] );
- }
- match[2] = match[2].replace(/^\+|\s*/g, '');
- // parse equations like 'even', 'odd', '5', '2n', '3n+2', '4n-1', '-n+6'
- var test = /(-?)(\d*)(?:n([+\-]?\d*))?/.exec(
- match[2] === "even" && "2n" || match[2] === "odd" && "2n+1" ||
- !/\D/.test( match[2] ) && "0n+" + match[2] || match[2]);
- // calculate the numbers (first)n+(last) including if they are negative
- match[2] = (test[1] + (test[2] || 1)) - 0;
- match[3] = test[3] - 0;
- }
- else if ( match[2] ) {
- Sizzle.error( match[0] );
- }
- // TODO: Move to normal caching system
- match[0] = done++;
- return match;
- },
- ATTR: function( match, curLoop, inplace, result, not, isXML ) {
- var name = match[1] = match[1].replace(/\\/g, "");
-
- if ( !isXML && Expr.attrMap[name] ) {
- match[1] = Expr.attrMap[name];
- }
- // Handle if an un-quoted value was used
- match[4] = ( match[4] || match[5] || "" ).replace(/\\/g, "");
- if ( match[2] === "~=" ) {
- match[4] = " " + match[4] + " ";
- }
- return match;
- },
- PSEUDO: function( match, curLoop, inplace, result, not ) {
- if ( match[1] === "not" ) {
- // If we're dealing with a complex expression, or a simple one
- if ( ( chunker.exec(match[3]) || "" ).length > 1 || /^\w/.test(match[3]) ) {
- match[3] = Sizzle(match[3], null, null, curLoop);
- } else {
- var ret = Sizzle.filter(match[3], curLoop, inplace, true ^ not);
- if ( !inplace ) {
- result.push.apply( result, ret );
- }
- return false;
- }
- } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) {
- return true;
- }
-
- return match;
- },
- POS: function( match ) {
- match.unshift( true );
- return match;
- }
- },
-
- filters: {
- enabled: function( elem ) {
- return elem.disabled === false && elem.type !== "hidden";
- },
- disabled: function( elem ) {
- return elem.disabled === true;
- },
- checked: function( elem ) {
- return elem.checked === true;
- },
-
- selected: function( elem ) {
- // Accessing this property makes selected-by-default
- // options in Safari work properly
- elem.parentNode.selectedIndex;
-
- return elem.selected === true;
- },
- parent: function( elem ) {
- return !!elem.firstChild;
- },
- empty: function( elem ) {
- return !elem.firstChild;
- },
- has: function( elem, i, match ) {
- return !!Sizzle( match[3], elem ).length;
- },
- header: function( elem ) {
- return (/h\d/i).test( elem.nodeName );
- },
- text: function( elem ) {
- return "text" === elem.type;
- },
- radio: function( elem ) {
- return "radio" === elem.type;
- },
- checkbox: function( elem ) {
- return "checkbox" === elem.type;
- },
- file: function( elem ) {
- return "file" === elem.type;
- },
- password: function( elem ) {
- return "password" === elem.type;
- },
- submit: function( elem ) {
- return "submit" === elem.type;
- },
- image: function( elem ) {
- return "image" === elem.type;
- },
- reset: function( elem ) {
- return "reset" === elem.type;
- },
- button: function( elem ) {
- return "button" === elem.type || elem.nodeName.toLowerCase() === "button";
- },
- input: function( elem ) {
- return (/input|select|textarea|button/i).test( elem.nodeName );
- }
- },
- setFilters: {
- first: function( elem, i ) {
- return i === 0;
- },
- last: function( elem, i, match, array ) {
- return i === array.length - 1;
- },
- even: function( elem, i ) {
- return i % 2 === 0;
- },
- odd: function( elem, i ) {
- return i % 2 === 1;
- },
- lt: function( elem, i, match ) {
- return i < match[3] - 0;
- },
- gt: function( elem, i, match ) {
- return i > match[3] - 0;
- },
- nth: function( elem, i, match ) {
- return match[3] - 0 === i;
- },
- eq: function( elem, i, match ) {
- return match[3] - 0 === i;
- }
- },
- filter: {
- PSEUDO: function( elem, match, i, array ) {
- var name = match[1],
- filter = Expr.filters[ name ];
- if ( filter ) {
- return filter( elem, i, match, array );
- } else if ( name === "contains" ) {
- return (elem.textContent || elem.innerText || Sizzle.getText([ elem ]) || "").indexOf(match[3]) >= 0;
- } else if ( name === "not" ) {
- var not = match[3];
- for ( var j = 0, l = not.length; j < l; j++ ) {
- if ( not[j] === elem ) {
- return false;
- }
- }
- return true;
- } else {
- Sizzle.error( name );
- }
- },
- CHILD: function( elem, match ) {
- var type = match[1],
- node = elem;
- switch ( type ) {
- case "only":
- case "first":
- while ( (node = node.previousSibling) ) {
- if ( node.nodeType === 1 ) {
- return false;
- }
- }
- if ( type === "first" ) {
- return true;
- }
- node = elem;
- case "last":
- while ( (node = node.nextSibling) ) {
- if ( node.nodeType === 1 ) {
- return false;
- }
- }
- return true;
- case "nth":
- var first = match[2],
- last = match[3];
- if ( first === 1 && last === 0 ) {
- return true;
- }
-
- var doneName = match[0],
- parent = elem.parentNode;
-
- if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) {
- var count = 0;
-
- for ( node = parent.firstChild; node; node = node.nextSibling ) {
- if ( node.nodeType === 1 ) {
- node.nodeIndex = ++count;
- }
- }
- parent.sizcache = doneName;
- }
-
- var diff = elem.nodeIndex - last;
- if ( first === 0 ) {
- return diff === 0;
- } else {
- return ( diff % first === 0 && diff / first >= 0 );
- }
- }
- },
- ID: function( elem, match ) {
- return elem.nodeType === 1 && elem.getAttribute("id") === match;
- },
- TAG: function( elem, match ) {
- return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match;
- },
-
- CLASS: function( elem, match ) {
- return (" " + (elem.className || elem.getAttribute("class")) + " ")
- .indexOf( match ) > -1;
- },
- ATTR: function( elem, match ) {
- var name = match[1],
- result = Expr.attrHandle[ name ] ?
- Expr.attrHandle[ name ]( elem ) :
- elem[ name ] != null ?
- elem[ name ] :
- elem.getAttribute( name ),
- value = result + "",
- type = match[2],
- check = match[4];
- return result == null ?
- type === "!=" :
- type === "=" ?
- value === check :
- type === "*=" ?
- value.indexOf(check) >= 0 :
- type === "~=" ?
- (" " + value + " ").indexOf(check) >= 0 :
- !check ?
- value && result !== false :
- type === "!=" ?
- value !== check :
- type === "^=" ?
- value.indexOf(check) === 0 :
- type === "$=" ?
- value.substr(value.length - check.length) === check :
- type === "|=" ?
- value === check || value.substr(0, check.length + 1) === check + "-" :
- false;
- },
- POS: function( elem, match, i, array ) {
- var name = match[2],
- filter = Expr.setFilters[ name ];
- if ( filter ) {
- return filter( elem, i, match, array );
- }
- }
- }
- };
- var origPOS = Expr.match.POS,
- fescape = function(all, num){
- return "\\" + (num - 0 + 1);
- };
- for ( var type in Expr.match ) {
- Expr.match[ type ] = new RegExp( Expr.match[ type ].source + (/(?![^\[]*\])(?![^\(]*\))/.source) );
- Expr.leftMatch[ type ] = new RegExp( /(^(?:.|\r|\n)*?)/.source + Expr.match[ type ].source.replace(/\\(\d+)/g, fescape) );
- }
- var makeArray = function( array, results ) {
- array = Array.prototype.slice.call( array, 0 );
- if ( results ) {
- results.push.apply( results, array );
- return results;
- }
-
- return array;
- };
- // Perform a simple check to determine if the browser is capable of
- // converting a NodeList to an array using builtin methods.
- // Also verifies that the returned array holds DOM nodes
- // (which is not the case in the Blackberry browser)
- try {
- Array.prototype.slice.call( document.documentElement.childNodes, 0 )[0].nodeType;
- // Provide a fallback method if it does not work
- } catch( e ) {
- makeArray = function( array, results ) {
- var i = 0,
- ret = results || [];
- if ( toString.call(array) === "[object Array]" ) {
- Array.prototype.push.apply( ret, array );
- } else {
- if ( typeof array.length === "number" ) {
- for ( var l = array.length; i < l; i++ ) {
- ret.push( array[i] );
- }
- } else {
- for ( ; array[i]; i++ ) {
- ret.push( array[i] );
- }
- }
- }
- return ret;
- };
- }
- var sortOrder, siblingCheck;
- if ( document.documentElement.compareDocumentPosition ) {
- sortOrder = function( a, b ) {
- if ( a === b ) {
- hasDuplicate = true;
- return 0;
- }
- if ( !a.compareDocumentPosition || !b.compareDocumentPosition ) {
- return a.compareDocumentPosition ? -1 : 1;
- }
- return a.compareDocumentPosition(b) & 4 ? -1 : 1;
- };
- } else {
- sortOrder = function( a, b ) {
- var al, bl,
- ap = [],
- bp = [],
- aup = a.parentNode,
- bup = b.parentNode,
- cur = aup;
- // The nodes are identical, we can exit early
- if ( a === b ) {
- hasDuplicate = true;
- return 0;
- // If the nodes are siblings (or identical) we can do a quick check
- } else if ( aup === bup ) {
- return siblingCheck( a, b );
- // If no parents were found then the nodes are disconnected
- } else if ( !aup ) {
- return -1;
- } else if ( !bup ) {
- return 1;
- }
- // Otherwise they're somewhere else in the tree so we need
- // to build up a full list of the parentNodes for comparison
- while ( cur ) {
- ap.unshift( cur );
- cur = cur.parentNode;
- }
- cur = bup;
- while ( cur ) {
- bp.unshift( cur );
- cur = cur.parentNode;
- }
- al = ap.length;
- bl = bp.length;
- // Start walking down the tree looking for a discrepancy
- for ( var i = 0; i < al && i < bl; i++ ) {
- if ( ap[i] !== bp[i] ) {
- return siblingCheck( ap[i], bp[i] );
- }
- }
- // We ended someplace up the tree so do a sibling check
- return i === al ?
- siblingCheck( a, bp[i], -1 ) :
- siblingCheck( ap[i], b, 1 );
- };
- siblingCheck = function( a, b, ret ) {
- if ( a === b ) {
- return ret;
- }
- var cur = a.nextSibling;
- while ( cur ) {
- if ( cur === b ) {
- return -1;
- }
- cur = cur.nextSibling;
- }
- return 1;
- };
- }
- // Utility function for retreiving the text value of an array of DOM nodes
- Sizzle.getText = function( elems ) {
- var ret = "", elem;
- for ( var i = 0; elems[i]; i++ ) {
- elem = elems[i];
- // Get the text from text nodes and CDATA nodes
- if ( elem.nodeType === 3 || elem.nodeType === 4 ) {
- ret += elem.nodeValue;
- // Traverse everything else, except comment nodes
- } else if ( elem.nodeType !== 8 ) {
- ret += Sizzle.getText( elem.childNodes );
- }
- }
- return ret;
- };
- // Check to see if the browser returns elements by name when
- // querying by getElementById (and provide a workaround)
- (function(){
- // We're going to inject a fake input element with a specified name
- var form = document.createElement("div"),
- id = "script" + (new Date()).getTime(),
- root = document.documentElement;
- form.innerHTML = "<a name='" + id + "'/>";
- // Inject it into the root element, check its status, and remove it quickly
- root.insertBefore( form, root.firstChild );
- // The workaround has to do additional checks after a getElementById
- // Which slows things down for other browsers (hence the branching)
- if ( document.getElementById( id ) ) {
- Expr.find.ID = function( match, context, isXML ) {
- if ( typeof context.getElementById !== "undefined" && !isXML ) {
- var m = context.getElementById(match[1]);
- return m ?
- m.id === match[1] || typeof m.getAttributeNode !== "undefined" && m.getAttributeNode("id").nodeValue === match[1] ?
- [m] :
- undefined :
- [];
- }
- };
- Expr.filter.ID = function( elem, match ) {
- var node = typeof elem.getAttributeNode !== "undefined" && elem.getAttributeNode("id");
- return elem.nodeType === 1 && node && node.nodeValue === match;
- };
- }
- root.removeChild( form );
- // release memory in IE
- root = form = null;
- })();
- (function(){
- // Check to see if the browser returns only elements
- // when doing getElementsByTagName("*")
- // Create a fake element
- var div = document.createElement("div");
- div.appendChild( document.createComment("") );
- // Make sure no comments are found
- if ( div.getElementsByTagName("*").length > 0 ) {
- Expr.find.TAG = function( match, context ) {
- var results = context.getElementsByTagName( match[1] );
- // Filter out possible comments
- if ( match[1] === "*" ) {
- var tmp = [];
- for ( var i = 0; results[i]; i++ ) {
- if ( results[i].nodeType === 1 ) {
- tmp.push( results[i] );
- }
- }
- results = tmp;
- }
- return results;
- };
- }
- // Check to see if an attribute returns normalized href attributes
- div.innerHTML = "<a href='#'></a>";
- if ( div.firstChild && typeof div.firstChild.getAttribute !== "undefined" &&
- div.firstChild.getAttribute("href") !== "#" ) {
- Expr.attrHandle.href = function( elem ) {
- return elem.getAttribute( "href", 2 );
- };
- }
- // release memory in IE
- div = null;
- })();
- if ( document.querySelectorAll ) {
- (function(){
- var oldSizzle = Sizzle,
- div = document.createElement("div"),
- id = "__sizzle__";
- div.innerHTML = "<p class='TEST'></p>";
- // Safari can't handle uppercase or unicode characters when
- // in quirks mode.
- if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) {
- return;
- }
-
- Sizzle = function( query, context, extra, seed ) {
- context = context || document;
- // Only use querySelectorAll on non-XML documents
- // (ID selectors don't work in non-HTML documents)
- if ( !seed && !Sizzle.isXML(context) ) {
- // See if we find a selector to speed up
- var match = /^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec( query );
-
- if ( match && (context.nodeType === 1 || context.nodeType === 9) ) {
- // Speed-up: Sizzle("TAG")
- if ( match[1] ) {
- return makeArray( context.getElementsByTagName( query ), extra );
-
- // Speed-up: Sizzle(".CLASS")
- } else if ( match[2] && Expr.find.CLASS && context.getElementsByClassName ) {
- return makeArray( context.getElementsByClassName( match[2] ), extra );
- }
- }
-
- if ( context.nodeType === 9 ) {
- // Speed-up: Sizzle("body")
- // The body element only exists once, optimize finding it
- if ( query === "body" && context.body ) {
- return makeArray( [ context.body ], extra );
-
- // Speed-up: Sizzle("#ID")
- } else if ( match && match[3] ) {
- var elem = context.getElementById( match[3] );
- // Check parentNode to catch when Blackberry 4.6 returns
- // nodes that are no longer in the document #6963
- if ( elem && elem.parentNode ) {
- // Handle the case where IE and Opera return items
- // by name instead of ID
- if ( elem.id === match[3] ) {
- return makeArray( [ elem ], extra );
- }
-
- } else {
- return makeArray( [], extra );
- }
- }
-
- try {
- return makeArray( context.querySelectorAll(query), extra );
- } catch(qsaError) {}
- // qSA works strangely on Element-rooted queries
- // We can work around this by specifying an extra ID on the root
- // and working up from there (Thanks to Andrew Dupont for the technique)
- // IE 8 doesn't work on object elements
- } else if ( context.nodeType === 1 && context.nodeName.toLowerCase() !== "object" ) {
- var old = context.getAttribute( "id" ),
- nid = old || id,
- hasParent = context.parentNode,
- relativeHierarchySelector = /^\s*[+~]/.test( query );
- if ( !old ) {
- context.setAttribute( "id", nid );
- } else {
- nid = nid.replace( /'/g, "\\$&" );
- }
- if ( relativeHierarchySelector && hasParent ) {
- context = context.parentNode;
- }
- try {
- if ( !relativeHierarchySelector || hasParent ) {
- return makeArray( context.querySelectorAll( "[id='" + nid + "'] " + query ), extra );
- }
- } catch(pseudoError) {
- } finally {
- if ( !old ) {
- context.removeAttribute( "id" );
- }
- }
- }
- }
-
- return oldSizzle(query, context, extra, seed);
- };
- for ( var prop in oldSizzle ) {
- Sizzle[ prop ] = oldSizzle[ prop ];
- }
- // release memory in IE
- div = null;
- })();
- }
- (function(){
- var html = document.documentElement,
- matches = html.matchesSelector || html.mozMatchesSelector || html.webkitMatchesSelector || html.msMatchesSelector,
- pseudoWorks = false;
- try {
- // This should fail with an exception
- // Gecko does not error, returns false instead
- matches.call( document.documentElement, "[test!='']:sizzle" );
-
- } catch( pseudoError ) {
- pseudoWorks = true;
- }
- if ( matches ) {
- Sizzle.matchesSelector = function( node, expr ) {
- // Make sure that attribute selectors are quoted
- expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']");
- if ( !Sizzle.isXML( node ) ) {
- try {
- if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) {
- return matches.call( node, expr );
- }
- } catch(e) {}
- }
- return Sizzle(expr, null, null, [node]).length > 0;
- };
- }
- })();
- (function(){
- var div = document.createElement("div");
- div.innerHTML = "<div class='test e'></div><div class='test'></div>";
- // Opera can't find a second classname (in 9.6)
- // Also, make sure that getElementsByClassName actually exists
- if ( !div.getElementsByClassName || div.getElementsByClassName("e").length === 0 ) {
- return;
- }
- // Safari caches class attributes, doesn't catch changes (in 3.2)
- div.lastChild.className = "e";
- if ( div.getElementsByClassName("e").length === 1 ) {
- return;
- }
-
- Expr.order.splice(1, 0, "CLASS");
- Expr.find.CLASS = function( match, context, isXML ) {
- if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) {
- return context.getElementsByClassName(match[1]);
- }
- };
- // release memory in IE
- div = null;
- })();
- function dirNodeCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
- for ( var i = 0, l = checkSet.length; i < l; i++ ) {
- var elem = checkSet[i];
- if ( elem ) {
- var match = false;
- elem = elem[dir];
- while ( elem ) {
- if ( elem.sizcache === doneName ) {
- match = checkSet[elem.sizset];
- break;
- }
- if ( elem.nodeType === 1 && !isXML ){
- elem.sizcache = doneName;
- elem.sizset = i;
- }
- if ( elem.nodeName.toLowerCase() === cur ) {
- match = elem;
- break;
- }
- elem = elem[dir];
- }
- checkSet[i] = match;
- }
- }
- }
- function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) {
- for ( var i = 0, l = checkSet.length; i < l; i++ ) {
- var elem = checkSet[i];
- if ( elem ) {
- var match = false;
-
- elem = elem[dir];
- while ( elem ) {
- if ( elem.sizcache === doneName ) {
- match = checkSet[elem.sizset];
- break;
- }
- if ( elem.nodeType === 1 ) {
- if ( !isXML ) {
- elem.sizcache = doneName;
- elem.sizset = i;
- }
- if ( typeof cur !== "string" ) {
- if ( elem === cur ) {
- match = true;
- break;
- }
- } else if ( Sizzle.filter( cur, [elem] ).length > 0 ) {
- match = elem;
- break;
- }
- }
- elem = elem[dir];
- }
- checkSet[i] = match;
- }
- }
- }
- if ( document.documentElement.contains ) {
- Sizzle.contains = function( a, b ) {
- return a !== b && (a.contains ? a.contains(b) : true);
- };
- } else if ( document.documentElement.compareDocumentPosition ) {
- Sizzle.contains = function( a, b ) {
- return !!(a.compareDocumentPosition(b) & 16);
- };
- } else {
- Sizzle.contains = function() {
- return false;
- };
- }
- Sizzle.isXML = function( elem ) {
- // documentElement is verified for cases where it doesn't yet exist
- // (such as loading iframes in IE - #4833)
- var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement;
- return documentElement ? documentElement.nodeName !== "HTML" : false;
- };
- var posProcess = function( selector, context ) {
- var match,
- tmpSet = [],
- later = "",
- root = context.nodeType ? [context] : context;
- // Position selectors must be done after the filter
- // And so must :not(positional) so we move all PSEUDOs to the end
- while ( (match = Expr.match.PSEUDO.exec( selector )) ) {
- later += match[0];
- selector = selector.replace( Expr.match.PSEUDO, "" );
- }
- selector = Expr.relative[selector] ? selector + "*" : selector;
- for ( var i = 0, l = root.length; i < l; i++ ) {
- Sizzle( selector, root[i], tmpSet );
- }
- return Sizzle.filter( later, tmpSet );
- };
- // EXPOSE
- jQuery.find = Sizzle;
- jQuery.expr = Sizzle.selectors;
- jQuery.expr[":"] = jQuery.expr.filters;
- jQuery.unique = Sizzle.uniqueSort;
- jQuery.text = Sizzle.getText;
- jQuery.isXMLDoc = Sizzle.isXML;
- jQuery.contains = Sizzle.contains;
- })();
- var runtil = /Until$/,
- rparentsprev = /^(?:parents|prevUntil|prevAll)/,
- // Note: This RegExp should be improved, or likely pulled from Sizzle
- rmultiselector = /,/,
- isSimple = /^.[^:#\[\.,]*$/,
- slice = Array.prototype.slice,
- POS = jQuery.expr.match.POS,
- // methods guaranteed to produce a unique set when starting from a unique set
- guaranteedUnique = {
- children: true,
- contents: true,
- next: true,
- prev: true
- };
- jQuery.fn.extend({
- find: function( selector ) {
- var ret = this.pushStack( "", "find", selector ),
- length = 0;
- for ( var i = 0, l = this.length; i < l; i++ ) {
- length = ret.length;
- jQuery.find( selector, this[i], ret );
- if ( i > 0 ) {
- // Make sure that the results are unique
- for ( var n = length; n < ret.length; n++ ) {
- for ( var r = 0; r < length; r++ ) {
- if ( ret[r] === ret[n] ) {
- ret.splice(n--, 1);
- break;
- }
- }
- }
- }
- }
- return ret;
- },
- has: function( target ) {
- var targets = jQuery( target );
- return this.filter(function() {
- for ( var i = 0, l = targets.length; i < l; i++ ) {
- if ( jQuery.contains( this, targets[i] ) ) {
- return true;
- }
- }
- });
- },
- not: function( selector ) {
- return this.pushStack( winnow(this, selector, false), "not", selector);
- },
- filter: function( selector ) {
- return this.pushStack( winnow(this, selector, true), "filter", selector );
- },
- is: function( selector ) {
- return !!selector && jQuery.filter( selector, this ).length > 0;
- },
- closest: function( selectors, context ) {
- var ret = [], i, l, cur = this[0];
- if ( jQuery.isArray( selectors ) ) {
- var match, selector,
- matches = {},
- level = 1;
- if ( cur && selectors.length ) {
- for ( i = 0, l = selectors.length; i < l; i++ ) {
- selector = selectors[i];
- if ( !matches[selector] ) {
- matches[selector] = jQuery.expr.match.POS.test( selector ) ?
- jQuery( selector, context || this.context ) :
- selector;
- }
- }
- while ( cur && cur.ownerDocument && cur !== context ) {
- for ( selector in matches ) {
- match = matches[selector];
- if ( match.jquery ? match.index(cur) > -1 : jQuery(cur).is(match) ) {
- ret.push({ selector: selector, elem: cur, level: level });
- }
- }
- cur = cur.parentNode;
- level++;
- }
- }
- return ret;
- }
- var pos = POS.test( selectors ) ?
- jQuery( selectors, context || this.context ) : null;
- for ( i = 0, l = this.length; i < l; i++ ) {
- cur = this[i];
- while ( cur ) {
- if ( pos ? pos.index(cur) > -1 : jQuery.find.matchesSelector(cur, selectors) ) {
- ret.push( cur );
- break;
- } else {
- cur = cur.parentNode;
- if ( !cur || !cur.ownerDocument || cur === context ) {
- break;
- }
- }
- }
- }
- ret = ret.length > 1 ? jQuery.unique(ret) : ret;
- return this.pushStack( ret, "closest", selectors );
- },
- // Determine the position of an element within
- // the matched set of elements
- index: function( elem ) {
- if ( !elem || typeof elem === "string" ) {
- return jQuery.inArray( this[0],
- // If it receives a string, the selector is used
- // If it receives nothing, the siblings are used
- elem ? jQuery( elem ) : this.parent().children() );
- }
- // Locate the position of the desired element
- return jQuery.inArray(
- // If it receives a jQuery object, the first element is used
- elem.jquery ? elem[0] : elem, this );
- },
- add: function( selector, context ) {
- var set = typeof selector === "string" ?
- jQuery( selector, context ) :
- jQuery.makeArray( selector ),
- all = jQuery.merge( this.get(), set );
- return this.pushStack( isDisconnected( set[0] ) || isDisconnected( all[0] ) ?
- all :
- jQuery.unique( all ) );
- },
- andSelf: function() {
- return this.add( this.prevObject );
- }
- });
- // A painfully simple check to see if an element is disconnected
- // from a document (should be improved, where feasible).
- function isDisconnected( node ) {
- return !node || !node.parentNode || node.parentNode.nodeType === 11;
- }
- jQuery.each({
- parent: function( elem ) {
- var parent = elem.parentNode;
- return parent && parent.nodeType !== 11 ? parent : null;
- },
- parents: function( elem ) {
- return jQuery.dir( elem, "parentNode" );
- },
- parentsUntil: function( elem, i, until ) {
- return jQuery.dir( elem, "parentNode", until );
- },
- next: function( elem ) {
- return jQuery.nth( elem, 2, "nextSibling" );
- },
- prev: function( elem ) {
- return jQuery.nth( elem, 2, "previousSibling" );
- },
- nextAll: function( elem ) {
- return jQuery.dir( elem, "nextSibling" );
- },
- prevAll: function( elem ) {
- return jQuery.dir( elem, "previousSibling" );
- },
- nextUntil: function( elem, i, until ) {
- return jQuery.dir( elem, "nextSibling", until );
- },
- prevUntil: function( elem, i, until ) {
- return jQuery.dir( elem, "previousSibling", until );
- },
- siblings: function( elem ) {
- return jQuery.sibling( elem.parentNode.firstChild, elem );
- },
- children: function( elem ) {
- return jQuery.sibling( elem.firstChild );
- },
- contents: function( elem ) {
- return jQuery.nodeName( elem, "iframe" ) ?
- elem.contentDocument || elem.contentWindow.document :
- jQuery.makeArray( elem.childNodes );
- }
- }, function( name, fn ) {
- jQuery.fn[ name ] = function( until, selector ) {
- var ret = jQuery.map( this, fn, until ),
- // The variable 'args' was introduced in
- // https://github.com/jquery/jquery/commit/52a0238
- // to work around a bug in Chrome 10 (Dev) and should be removed when the bug is fixed.
- // http://code.google.com/p/v8/issues/detail?id=1050
- args = slice.call(arguments);
- if ( !runtil.test( name ) ) {
- selector = until;
- }
- if ( selector && typeof selector === "string" ) {
- ret = jQuery.filter( selector, ret );
- }
- ret = this.length > 1 && !guaranteedUnique[ name ] ? jQuery.unique( ret ) : ret;
- if ( (this.length > 1 || rmultiselector.test( selector )) && rparentsprev.test( name ) ) {
- ret = ret.reverse();
- }
- return this.pushStack( ret, name, args.join(",") );
- };
- });
- jQuery.extend({
- filter: function( expr, elems, not ) {
- if ( not ) {
- expr = ":not(" + expr + ")";
- }
- return elems.length === 1 ?
- jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] :
- jQuery.find.matches(expr, elems);
- },
- dir: function( elem, dir, until ) {
- var matched = [],
- cur = elem[ dir ];
- while ( cur && cur.nodeType !== 9 && (until === undefined || cur.nodeType !== 1 || !jQuery( cur ).is( until )) ) {
- if ( cur.nodeType === 1 ) {
- matched.push( cur );
- }
- cur = cur[dir];
- }
- return matched;
- },
- nth: function( cur, result, dir, elem ) {
- result = result || 1;
- var num = 0;
- for ( ; cur; cur = cur[dir] ) {
- if ( cur.nodeType === 1 && ++num === result ) {
- break;
- }
- }
- return cur;
- },
- sibling: function( n, elem ) {
- var r = [];
- for ( ; n; n = n.nextSibling ) {
- if ( n.nodeType === 1 && n !== elem ) {
- r.push( n );
- }
- }
- return r;
- }
- });
- // Implement the identical functionality for filter and not
- function winnow( elements, qualifier, keep ) {
- if ( jQuery.isFunction( qualifier ) ) {
- return jQuery.grep(elements, function( elem, i ) {
- var retVal = !!qualifier.call( elem, i, elem );
- return retVal === keep;
- });
- } else if ( qualifier.nodeType ) {
- return jQuery.grep(elements, function( elem, i ) {
- return (elem === qualifier) === keep;
- });
- } else if ( typeof qualifier === "string" ) {
- var filtered = jQuery.grep(elements, function( elem ) {
- return elem.nodeType === 1;
- });
- if ( isSimple.test( qualifier ) ) {
- return jQuery.filter(qualifier, filtered, !keep);
- } else {
- qualifier = jQuery.filter( qualifier, filtered );
- }
- }
- return jQuery.grep(elements, function( elem, i ) {
- return (jQuery.inArray( elem, qualifier ) >= 0) === keep;
- });
- }
- var rinlinejQuery = / jQuery\d+="(?:\d+|null)"/g,
- rleadingWhitespace = /^\s+/,
- rxhtmlTag = /<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,
- rtagName = /<([\w:]+)/,
- rtbody = /<tbody/i,
- rhtml = /<|&#?\w+;/,
- rnocache = /<(?:script|object|embed|option|style)/i,
- // checked="checked" or checked (html5)
- rchecked = /checked\s*(?:[^=]|=\s*.checked.)/i,
- wrapMap = {
- option: [ 1, "<select multiple='multiple'>", "</select>" ],
- legend: [ 1, "<fieldset>", "</fieldset>" ],
- thead: [ 1, "<table>", "</table>" ],
- tr: [ 2, "<table><tbody>", "</tbody></table>" ],
- td: [ 3, "<table><tbody><tr>", "</tr></tbody></table>" ],
- col: [ 2, "<table><tbody></tbody><colgroup>", "</colgroup></table>" ],
- area: [ 1, "<map>", "</map>" ],
- _default: [ 0, "", "" ]
- };
- wrapMap.optgroup = wrapMap.option;
- wrapMap.tbody = wrapMap.tfoot = wrapMap.colgroup = wrapMap.caption = wrapMap.thead;
- wrapMap.th = wrapMap.td;
- // IE can't serialize <link> and <script> tags normally
- if ( !jQuery.support.htmlSerialize ) {
- wrapMap._default = [ 1, "div<div>", "</div>" ];
- }
- jQuery.fn.extend({
- text: function( text ) {
- if ( jQuery.isFunction(text) ) {
- return this.each(function(i) {
- var self = jQuery( this );
- self.text( text.call(this, i, self.text()) );
- });
- }
- if ( typeof text !== "object" && text !== undefined ) {
- return this.empty().append( (this[0] && this[0].ownerDocument || document).createTextNode( text ) );
- }
- return jQuery.text( this );
- },
- wrapAll: function( html ) {
- if ( jQuery.isFunction( html ) ) {
- return this.each(function(i) {
- jQuery(this).wrapAll( html.call(this, i) );
- });
- }
- if ( this[0] ) {
- // The elements to wrap the target around
- var wrap = jQuery( html, this[0].ownerDocument ).eq(0).clone(true);
- if ( this[0].parentNode ) {
- wrap.insertBefore( this[0] );
- }
- wrap.map(function() {
- var elem = this;
- while ( elem.firstChild && elem.firstChild.nodeType === 1 ) {
- elem = elem.firstChild;
- }
- return elem;
- }).append(this);
- }
- return this;
- },
- wrapInner: function( html ) {
- if ( jQuery.isFunction( html ) ) {
- return this.each(function(i) {
- jQuery(this).wrapInner( html.call(this, i) );
- });
- }
- return this.each(function() {
- var self = jQuery( this ),
- contents = self.contents();
- if ( contents.length ) {
- contents.wrapAll( html );
- } else {
- self.append( html );
- }
- });
- },
- wrap: function( html ) {
- return this.each(function() {
- jQuery( this ).wrapAll( html );
- });
- },
- unwrap: function() {
- return this.parent().each(function() {
- if ( !jQuery.nodeName( this, "body" ) ) {
- jQuery( this ).replaceWith( this.childNodes );
- }
- }).end();
- },
- append: function() {
- return this.domManip(arguments, true, function( elem ) {
- if ( this.nodeType === 1 ) {
- this.appendChild( elem );
- }
- });
- },
- prepend: function() {
- return this.domManip(arguments, true, function( elem ) {
- if ( this.nodeType === 1 ) {
- this.insertBefore( elem, this.firstChild );
- }
- });
- },
- before: function() {
- if ( this[0] && this[0].parentNode ) {
- return this.domManip(arguments, false, function( elem ) {
- this.parentNode.insertBefore( elem, this );
- });
- } else if ( arguments.length ) {
- var set = jQuery(arguments[0]);
- set.push.apply( set, this.toArray() );
- return this.pushStack( set, "before", arguments );
- }
- },
- after: function() {
- if ( this[0] && this[0].parentNode ) {
- return this.domManip(arguments, false, function( elem ) {
- this.parentNode.insertBefore( elem, this.nextSibling );
- });
- } else if ( arguments.length ) {
- var set = this.pushStack( this, "after", arguments );
- set.push.apply( set, jQuery(arguments[0]).toArray() );
- return set;
- }
- },
- // keepData is for internal use only--do not document
- remove: function( selector, keepData ) {
- for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
- if ( !selector || jQuery.filter( selector, [ elem ] ).length ) {
- if ( !keepData && elem.nodeType === 1 ) {
- jQuery.cleanData( elem.getElementsByTagName("*") );
- jQuery.cleanData( [ elem ] );
- }
- if ( elem.parentNode ) {
- elem.parentNode.removeChild( elem );
- }
- }
- }
- return this;
- },
- empty: function() {
- for ( var i = 0, elem; (elem = this[i]) != null; i++ ) {
- // Remove element nodes and prevent memory leaks
- if ( elem.nodeType === 1 ) {
- jQuery.cleanData( elem.getElementsByTagName("*") );
- }
- // Remove any remaining nodes
- while ( elem.firstChild ) {
- elem.removeChild( elem.firstChild );
- }
- }
- return this;
- },
- clone: function( dataAndEvents, deepDataAndEvents ) {
- dataAndEvents = dataAndEvents == null ? true : dataAndEvents;
- deepDataAndEvents = deepDataAndEvents == null ? dataAndEvents : deepDataAndEvents;
- return this.map( function () {
- return jQuery.clone( this, dataAndEvents, deepDataAndEvents );
- });
- },
- html: function( value ) {
- if ( value === undefined ) {
- return this[0] && this[0].nodeType === 1 ?
- this[0].innerHTML.replace(rinlinejQuery, "") :
- null;
- // See if we can take a shortcut and just use innerHTML
- } else if ( typeof value === "string" && !rnocache.test( value ) &&
- (jQuery.support.leadingWhitespace || !rleadingWhitespace.test( value )) &&
- !wrapMap[ (rtagName.exec( value ) || ["", ""])[1].toLowerCase() ] ) {
- value = value.replace(rxhtmlTag, "<$1></$2>");
- try {
- for ( var i = 0, l = this.length; i < l; i++ ) {
- // Remove element nodes and prevent memory leaks
- if ( this[i].nodeType === 1 ) {
- jQuery.cleanData( this[i].getElementsByTagName("*") );
- this[i].innerHTML = value;
- }
- }
- // If using innerHTML throws an exception, use the fallback method
- } catch(e) {
- this.empty().append( value );
- }
- } else if ( jQuery.isFunction( value ) ) {
- this.each(function(i){
- var self = jQuery( this );
- self.html( value.call(this, i, self.html()) );
- });
- } else {
- this.empty().append( value );
- }
- return this;
- },
- replaceWith: function( value ) {
- if ( this[0] && this[0].parentNode ) {
- // Make sure that the elements are removed from the DOM before they are inserted
- // this can help fix replacing a parent with child elements
- if ( jQuery.isFunction( value ) ) {
- return this.each(function(i) {
- var self = jQuery(this), old = self.html();
- self.replaceWith( value.call( this, i, old ) );
- });
- }
- if ( typeof value !== "string" ) {
- value = jQuery( value ).detach();
- }
- return this.each(function() {
- var next = this.nextSibling,
- parent = this.parentNode;
- jQuery( this ).remove();
- if ( next ) {
- jQuery(next).before( value );
- } else {
- jQuery(parent).append( value );
- }
- });
- } else {
- return this.pushStack( jQuery(jQuery.isFunction(value) ? value() : value), "replaceWith", value );
- }
- },
- detach: function( selector ) {
- return this.remove( selector, true );
- },
- domManip: function( args, table, callback ) {
- var results, first, fragment, parent,
- value = args[0],
- scripts = [];
- // We can't cloneNode fragments that contain checked, in WebKit
- if ( !jQuery.support.checkClone && arguments.length === 3 && typeof value === "string" && rchecked.test( value ) ) {
- return this.each(function() {
- jQuery(this).domManip( args, table, callback, true );
- });
- }
- if ( jQuery.isFunction(value) ) {
- return this.each(function(i) {
- var self = jQuery(this);
- args[0] = value.call(this, i, table ? self.html() : undefined);
- self.domManip( args, table, callback );
- });
- }
- if ( this[0] ) {
- parent = value && value.parentNode;
- // If we're in a fragment, just use that instead of building a new one
- if ( jQuery.support.parentNode && parent && parent.nodeType === 11 && parent.childNodes.length === this.length ) {
- results = { fragment: parent };
- } else {
- results = jQuery.buildFragment( args, this, scripts );
- }
- fragment = results.fragment;
- if ( fragment.childNodes.length === 1 ) {
- first = fragment = fragment.firstChild;
- } else {
- first = fragment.firstChild;
- }
- if ( first ) {
- table = table && jQuery.nodeName( first, "tr" );
- for ( var i = 0, l = this.length, lastIndex = l - 1; i < l; i++ ) {
- callback.call(
- table ?
- root(this[i], first) :
- this[i],
- // Make sure that we do not leak memory by inadvertently discarding
- // the original fragment (which might have attached data) instead of
- // using it; in addition, use the original fragment object for the last
- // item instead of first because it can end up being emptied incorrectly
- // in certain situations (Bug #8070).
- // Fragments from the fragment cache must always be cloned and never used
- // in place.
- results.cacheable || (l > 1 && i < lastIndex) ?
- jQuery.clone( fragment, true, true ) :
- fragment
- );
- }
- }
- if ( scripts.length ) {
- jQuery.each( scripts, evalScript );
- }
- }
- return this;
- }
- });
- function root( elem, cur ) {
- return jQuery.nodeName(elem, "table") ?
- (elem.getElementsByTagName("tbody")[0] ||
- elem.appendChild(elem.ownerDocument.createElement("tbody"))) :
- elem;
- }
- function cloneCopyEvent( src, dest ) {
- if ( dest.nodeType !== 1 || !jQuery.hasData( src ) ) {
- return;
- }
- var internalKey = jQuery.expando,
- oldData = jQuery.data( src ),
- curData = jQuery.data( dest, oldData );
- // Switch to use the internal data object, if it exists, for the next
- // stage of data copying
- if ( (oldData = oldData[ internalKey ]) ) {
- var events = oldData.events;
- curData = curData[ internalKey ] = jQuery.extend({}, oldData);
- if ( events ) {
- delete curData.handle;
- curData.events = {};
- for ( var type in events ) {
- for ( var i = 0, l = events[ type ].length; i < l; i++ ) {
- jQuery.event.add( dest, type, events[ type ][ i ], events[ type ][ i ].data );
- }
- }
- }
- }
- }
- function cloneFixAttributes(src, dest) {
- // We do not need to do anything for non-Elements
- if ( dest.nodeType !== 1 ) {
- return;
- }
- var nodeName = dest.nodeName.toLowerCase();
- // clearAttributes removes the attributes, which we don't want,
- // but also removes the attachEvent events, which we *do* want
- dest.clearAttributes();
- // mergeAttributes, in contrast, only merges back on the
- // original attributes, not the events
- dest.mergeAttributes(src);
- // IE6-8 fail to clone children inside object elements that use
- // the proprietary classid attribute value (rather than the type
- // attribute) to identify the type of content to display
- if ( nodeName === "object" ) {
- dest.outerHTML = src.outerHTML;
- } else if ( nodeName === "input" && (src.type === "checkbox" || src.type === "radio") ) {
- // IE6-8 fails to persist the checked state of a cloned checkbox
- // or radio button. Worse, IE6-7 fail to give the cloned element
- // a checked appearance if the defaultChecked value isn't also set
- if ( src.checked ) {
- dest.defaultChecked = dest.checked = src.checked;
- }
- // IE6-7 get confused and end up setting the value of a cloned
- // checkbox/radio button to an empty string instead of "on"
- if ( dest.value !== src.value ) {
- dest.value = src.value;
- }
- // IE6-8 fails to return the selected option to the default selected
- // state when cloning options
- } else if ( nodeName === "option" ) {
- dest.selected = src.defaultSelected;
- // IE6-8 fails to set the defaultValue to the correct value when
- // cloning other types of input fields
- } else if ( nodeName === "input" || nodeName === "textarea" ) {
- dest.defaultValue = src.defaultValue;
- }
- // Event data gets referenced instead of copied if the expando
- // gets copied too
- dest.removeAttribute( jQuery.expando );
- }
- function getAll( elem ) {
- if ( "getElementsByTagName" in elem ) {
- return elem.getElementsByTagName( "*" );
- } else if ( "querySelectorAll" in elem ) {
- return elem.querySelectorAll( "*" );
- } else {
- return [];
- }
- }
- jQuery.buildFragment = function( args, nodes, scripts ) {
- var fragment, cacheable, cacheresults,
- doc = (nodes && nodes[0] ? nodes[0].ownerDocument || nodes[0] : document);
- // Only cache "small" (1/2 KB) HTML strings that are associated with the main document
- // Cloning options loses the selected state, so don't cache them
- // IE 6 doesn't like it when you put <object> or <embed> elements in a fragment
- // Also, WebKit does not clone 'checked' attributes on cloneNode, so don't cache
- if ( args.length === 1 && typeof args[0] === "string" && args[0].length < 512 && doc === document &&
- args[0].charAt(0) === "<" && !rnocache.test( args[0] ) && (jQuery.support.checkClone || !rchecked.test( args[0] )) ) {
- cacheable = true;
- cacheresults = jQuery.fragments[ args[0] ];
- if ( cacheresults ) {
- if ( cacheresults !== 1 ) {
- fragment = cacheresults;
- }
- }
- }
- if ( !fragment ) {
- fragment = doc.createDocumentFragment();
- jQuery.clean( args, doc, fragment, scripts );
- }
- if ( cacheable ) {
- jQuery.fragments[ args[0] ] = cacheresults ? fragment : 1;
- }
- return { fragment: fragment, cacheable: cacheable };
- };
- jQuery.fragments = {};
- jQuery.each({
- appendTo: "append",
- prependTo: "prepend",
- insertBefore: "before",
- insertAfter: "after",
- replaceAll: "replaceWith"
- }, function( name, original ) {
- jQuery.fn[ name ] = function( selector ) {
- var ret = [],
- insert = jQuery( selector ),
- parent = this.length === 1 && this[0].parentNode;
- if ( parent && parent.nodeType === 11 && parent.childNodes.length === 1 && insert.length === 1 ) {
- insert[ original ]( this[0] );
- return this;
- } else {
- for ( var i = 0, l = insert.length; i < l; i++ ) {
- var elems = (i > 0 ? this.clone(true) : this).get();
- jQuery( insert[i] )[ original ]( elems );
- ret = ret.concat( elems );
- }
- return this.pushStack( ret, name, insert.selector );
- }
- };
- });
- jQuery.extend({
- clone: function( elem, dataAndEvents, deepDataAndEvents ) {
- var clone = elem.cloneNode(true),
- srcElements,
- destElements,
- i;
- if ( !jQuery.support.noCloneEvent && (elem.nodeType === 1 || elem.nodeType === 11) && !jQuery.isXMLDoc(elem) ) {
- // IE copies events bound via attachEvent when using cloneNode.
- // Calling detachEvent on the clone will also remove the events
- // from the original. In order to get around this, we use some
- // proprietary methods to clear the events. Thanks to MooTools
- // guys for this hotness.
- // Using Sizzle here is crazy slow, so we use getElementsByTagName
- // instead
- srcElements = getAll(elem);
- destElements = getAll(clone);
- // Weird iteration because IE will replace the length property
- // with an element if you are cloning the body and one of the
- // elements on the page has a name or id of "length"
- for ( i = 0; srcElements[i]; ++i ) {
- cloneFixAttributes( srcElements[i], destElements[i] );
- }
- cloneFixAttributes( elem, clone );
- }
- // Copy the events from the original to the clone
- if ( dataAndEvents ) {
- cloneCopyEvent( elem, clone );
- if ( deepDataAndEvents && "getElementsByTagName" in elem ) {
- srcElements =getAll(elem);
- destElements = getAll(clone);
- if ( srcElements.length ) {
- for ( i = 0; srcElements[i]; ++i ) {
- cloneCopyEvent( srcElements[i], destElements[i] );
- }
- }
- }
- }
- // Return the cloned set
- return clone;
- },
- clean: function( elems, context, fragment, scripts ) {
- context = context || document;
- // !context.createElement fails in IE with an error but returns typeof 'object'
- if ( typeof context.createElement === "undefined" ) {
- context = context.ownerDocument || context[0] && context[0].ownerDocument || document;
- }
- var ret = [];
- for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
- if ( typeof elem === "number" ) {
- elem += "";
- }
- if ( !elem ) {
- continue;
- }
- // Convert html string into DOM nodes
- if ( typeof elem === "string" && !rhtml.test( elem ) ) {
- elem = context.createTextNode( elem );
- } else if ( typeof elem === "string" ) {
- // Fix "XHTML"-style tags in all browsers
- elem = elem.replace(rxhtmlTag, "<$1></$2>");
- // Trim whitespace, otherwise indexOf won't work as expected
- var tag = (rtagName.exec( elem ) || ["", ""])[1].toLowerCase(),
- wrap = wrapMap[ tag ] || wrapMap._default,
- depth = wrap[0],
- div = context.createElement("div");
- // Go to html and back, then peel off extra wrappers
- div.innerHTML = wrap[1] + elem + wrap[2];
- // Move to the right depth
- while ( depth-- ) {
- div = div.lastChild;
- }
- // Remove IE's autoinserted <tbody> from table fragments
- if ( !jQuery.support.tbody ) {
- // String was a <table>, *may* have spurious <tbody>
- var hasBody = rtbody.test(elem),
- tbody = tag === "table" && !hasBody ?
- div.firstChild && div.firstChild.childNodes :
- // String was a bare <thead> or <tfoot>
- wrap[1] === "<table>" && !hasBody ?
- div.childNodes :
- [];
- for ( var j = tbody.length - 1; j >= 0 ; --j ) {
- if ( jQuery.nodeName( tbody[ j ], "tbody" ) && !tbody[ j ].childNodes.length ) {
- tbody[ j ].parentNode.removeChild( tbody[ j ] );
- }
- }
- }
- // IE completely kills leading whitespace when innerHTML is used
- if ( !jQuery.support.leadingWhitespace && rleadingWhitespace.test( elem ) ) {
- div.insertBefore( context.createTextNode( rleadingWhitespace.exec(elem)[0] ), div.firstChild );
- }
- elem = div.childNodes;
- }
- if ( elem.nodeType ) {
- ret.push( elem );
- } else {
- ret = jQuery.merge( ret, elem );
- }
- }
- if ( fragment ) {
- for ( i = 0; ret[i]; i++ ) {
- if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) {
- scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] );
- } else {
- if ( ret[i].nodeType === 1 ) {
- ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) );
- }
- fragment.appendChild( ret[i] );
- }
- }
- }
- return ret;
- },
- cleanData: function( elems ) {
- var data, id, cache = jQuery.cache, internalKey = jQuery.expando, special = jQuery.event.special,
- deleteExpando = jQuery.support.deleteExpando;
- for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
- if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) {
- continue;
- }
- id = elem[ jQuery.expando ];
- if ( id ) {
- data = cache[ id ] && cache[ id ][ internalKey ];
- if ( data && data.events ) {
- for ( var type in data.events ) {
- if ( special[ type ] ) {
- jQuery.event.remove( elem, type );
- // This is a shortcut to avoid jQuery.event.remove's overhead
- } else {
- jQuery.removeEvent( elem, type, data.handle );
- }
- }
- // Null the DOM reference to avoid IE6/7/8 leak (#7054)
- if ( data.handle ) {
- data.handle.elem = null;
- }
- }
- if ( deleteExpando ) {
- delete elem[ jQuery.expando ];
- } else if ( elem.removeAttribute ) {
- elem.removeAttribute( jQuery.expando );
- }
- delete cache[ id ];
- }
- }
- }
- });
- function evalScript( i, elem ) {
- if ( elem.src ) {
- jQuery.ajax({
- url: elem.src,
- async: false,
- dataType: "script"
- });
- } else {
- jQuery.globalEval( elem.text || elem.textContent || elem.innerHTML || "" );
- }
- if ( elem.parentNode ) {
- elem.parentNode.removeChild( elem );
- }
- }
- var ralpha = /alpha\([^)]*\)/i,
- ropacity = /opacity=([^)]*)/,
- rdashAlpha = /-([a-z])/ig,
- rupper = /([A-Z])/g,
- rnumpx = /^-?\d+(?:px)?$/i,
- rnum = /^-?\d/,
- cssShow = { position: "absolute", visibility: "hidden", display: "block" },
- cssWidth = [ "Left", "Right" ],
- cssHeight = [ "Top", "Bottom" ],
- curCSS,
- getComputedStyle,
- currentStyle,
- fcamelCase = function( all, letter ) {
- return letter.toUpperCase();
- };
- jQuery.fn.css = function( name, value ) {
- // Setting 'undefined' is a no-op
- if ( arguments.length === 2 && value === undefined ) {
- return this;
- }
- return jQuery.access( this, name, value, true, function( elem, name, value ) {
- return value !== undefined ?
- jQuery.style( elem, name, value ) :
- jQuery.css( elem, name );
- });
- };
- jQuery.extend({
- // Add in style property hooks for overriding the default
- // behavior of getting and setting a style property
- cssHooks: {
- opacity: {
- get: function( elem, computed ) {
- if ( computed ) {
- // We should always get a number back from opacity
- var ret = curCSS( elem, "opacity", "opacity" );
- return ret === "" ? "1" : ret;
- } else {
- return elem.style.opacity;
- }
- }
- }
- },
- // Exclude the following css properties to add px
- cssNumber: {
- "zIndex": true,
- "fontWeight": true,
- "opacity": true,
- "zoom": true,
- "lineHeight": true
- },
- // Add in properties whose names you wish to fix before
- // setting or getting the value
- cssProps: {
- // normalize float css property
- "float": jQuery.support.cssFloat ? "cssFloat" : "styleFloat"
- },
- // Get and set the style property on a DOM Node
- style: function( elem, name, value, extra ) {
- // Don't set styles on text and comment nodes
- if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 || !elem.style ) {
- return;
- }
- // Make sure that we're working with the right name
- var ret, origName = jQuery.camelCase( name ),
- style = elem.style, hooks = jQuery.cssHooks[ origName ];
- name = jQuery.cssProps[ origName ] || origName;
- // Check if we're setting a value
- if ( value !== undefined ) {
- // Make sure that NaN and null values aren't set. See: #7116
- if ( typeof value === "number" && isNaN( value ) || value == null ) {
- return;
- }
- // If a number was passed in, add 'px' to the (except for certain CSS properties)
- if ( typeof value === "number" && !jQuery.cssNumber[ origName ] ) {
- value += "px";
- }
- // If a hook was provided, use that value, otherwise just set the specified value
- if ( !hooks || !("set" in hooks) || (value = hooks.set( elem, value )) !== undefined ) {
- // Wrapped to prevent IE from throwing errors when 'invalid' values are provided
- // Fixes bug #5509
- try {
- style[ name ] = value;
- } catch(e) {}
- }
- } else {
- // If a hook was provided get the non-computed value from there
- if ( hooks && "get" in hooks && (ret = hooks.get( elem, false, extra )) !== undefined ) {
- return ret;
- }
- // Otherwise just get the value from the style object
- return style[ name ];
- }
- },
- css: function( elem, name, extra ) {
- // Make sure that we're working with the right name
- var ret, origName = jQuery.camelCase( name ),
- hooks = jQuery.cssHooks[ origName ];
- name = jQuery.cssProps[ origName ] || origName;
- // If a hook was provided get the computed value from there
- if ( hooks && "get" in hooks && (ret = hooks.get( elem, true, extra )) !== undefined ) {
- return ret;
- // Otherwise, if a way to get the computed value exists, use that
- } else if ( curCSS ) {
- return curCSS( elem, name, origName );
- }
- },
- // A method for quickly swapping in/out CSS properties to get correct calculations
- swap: function( elem, options, callback ) {
- var old = {};
- // Remember the old values, and insert the new ones
- for ( var name in options ) {
- old[ name ] = elem.style[ name ];
- elem.style[ name ] = options[ name ];
- }
- callback.call( elem );
- // Revert the old values
- for ( name in options ) {
- elem.style[ name ] = old[ name ];
- }
- },
- camelCase: function( string ) {
- return string.replace( rdashAlpha, fcamelCase );
- }
- });
- // DEPRECATED, Use jQuery.css() instead
- jQuery.curCSS = jQuery.css;
- jQuery.each(["height", "width"], function( i, name ) {
- jQuery.cssHooks[ name ] = {
- get: function( elem, computed, extra ) {
- var val;
- if ( computed ) {
- if ( elem.offsetWidth !== 0 ) {
- val = getWH( elem, name, extra );
- } else {
- jQuery.swap( elem, cssShow, function() {
- val = getWH( elem, name, extra );
- });
- }
- if ( val <= 0 ) {
- val = curCSS( elem, name, name );
- if ( val === "0px" && currentStyle ) {
- val = currentStyle( elem, name, name );
- }
- if ( val != null ) {
- // Should return "auto" instead of 0, use 0 for
- // temporary backwards-compat
- return val === "" || val === "auto" ? "0px" : val;
- }
- }
- if ( val < 0 || val == null ) {
- val = elem.style[ name ];
- // Should return "auto" instead of 0, use 0 for
- // temporary backwards-compat
- return val === "" || val === "auto" ? "0px" : val;
- }
- return typeof val === "string" ? val : val + "px";
- }
- },
- set: function( elem, value ) {
- if ( rnumpx.test( value ) ) {
- // ignore negative width and height values #1599
- value = parseFloat(value);
- if ( value >= 0 ) {
- return value + "px";
- }
- } else {
- return value;
- }
- }
- };
- });
- if ( !jQuery.support.opacity ) {
- jQuery.cssHooks.opacity = {
- get: function( elem, computed ) {
- // IE uses filters for opacity
- return ropacity.test((computed && elem.currentStyle ? elem.currentStyle.filter : elem.style.filter) || "") ?
- (parseFloat(RegExp.$1) / 100) + "" :
- computed ? "1" : "";
- },
- set: function( elem, value ) {
- var style = elem.style;
- // IE has trouble with opacity if it does not have layout
- // Force it by setting the zoom level
- style.zoom = 1;
- // Set the alpha filter to set the opacity
- var opacity = jQuery.isNaN(value) ?
- "" :
- "alpha(opacity=" + value * 100 + ")",
- filter = style.filter || "";
- style.filter = ralpha.test(filter) ?
- filter.replace(ralpha, opacity) :
- style.filter + ' ' + opacity;
- }
- };
- }
- if ( document.defaultView && document.defaultView.getComputedStyle ) {
- getComputedStyle = function( elem, newName, name ) {
- var ret, defaultView, computedStyle;
- name = name.replace( rupper, "-$1" ).toLowerCase();
- if ( !(defaultView = elem.ownerDocument.defaultView) ) {
- return undefined;
- }
- if ( (computedStyle = defaultView.getComputedStyle( elem, null )) ) {
- ret = computedStyle.getPropertyValue( name );
- if ( ret === "" && !jQuery.contains( elem.ownerDocument.documentElement, elem ) ) {
- ret = jQuery.style( elem, name );
- }
- }
- return ret;
- };
- }
- if ( document.documentElement.currentStyle ) {
- currentStyle = function( elem, name ) {
- var left,
- ret = elem.currentStyle && elem.currentStyle[ name ],
- rsLeft = elem.runtimeStyle && elem.runtimeStyle[ name ],
- style = elem.style;
- // From the awesome hack by Dean Edwards
- // http://erik.eae.net/archives/2007/07/27/18.54.15/#comment-102291
- // If we're not dealing with a regular pixel number
- // but a number that has a weird ending, we need to convert it to pixels
- if ( !rnumpx.test( ret ) && rnum.test( ret ) ) {
- // Remember the original values
- left = style.left;
- // Put in the new values to get a computed value out
- if ( rsLeft ) {
- elem.runtimeStyle.left = elem.currentStyle.left;
- }
- style.left = name === "fontSize" ? "1em" : (ret || 0);
- ret = style.pixelLeft + "px";
- // Revert the changed values
- style.left = left;
- if ( rsLeft ) {
- elem.runtimeStyle.left = rsLeft;
- }
- }
- return ret === "" ? "auto" : ret;
- };
- }
- curCSS = getComputedStyle || currentStyle;
- function getWH( elem, name, extra ) {
- var which = name === "width" ? cssWidth : cssHeight,
- val = name === "width" ? elem.offsetWidth : elem.offsetHeight;
- if ( extra === "border" ) {
- return val;
- }
- jQuery.each( which, function() {
- if ( !extra ) {
- val -= parseFloat(jQuery.css( elem, "padding" + this )) || 0;
- }
- if ( extra === "margin" ) {
- val += parseFloat(jQuery.css( elem, "margin" + this )) || 0;
- } else {
- val -= parseFloat(jQuery.css( elem, "border" + this + "Width" )) || 0;
- }
- });
- return val;
- }
- if ( jQuery.expr && jQuery.expr.filters ) {
- jQuery.expr.filters.hidden = function( elem ) {
- var width = elem.offsetWidth,
- height = elem.offsetHeight;
- return (width === 0 && height === 0) || (!jQuery.support.reliableHiddenOffsets && (elem.style.display || jQuery.css( elem, "display" )) === "none");
- };
- jQuery.expr.filters.visible = function( elem ) {
- return !jQuery.expr.filters.hidden( elem );
- };
- }
- var r20 = /%20/g,
- rbracket = /\[\]$/,
- rCRLF = /\r?\n/g,
- rhash = /#.*$/,
- rheaders = /^(.*?):\s*(.*?)\r?$/mg, // IE leaves an \r character at EOL
- rinput = /^(?:color|date|datetime|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,
- rnoContent = /^(?:GET|HEAD)$/,
- rprotocol = /^\/\//,
- rquery = /\?/,
- rscript = /<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi,
- rselectTextarea = /^(?:select|textarea)/i,
- rspacesAjax = /\s+/,
- rts = /([?&])_=[^&]*/,
- rurl = /^(\w+:)\/\/([^\/?#:]+)(?::(\d+))?/,
- // Keep a copy of the old load method
- _load = jQuery.fn.load,
- /* Prefilters
- * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example)
- * 2) These are called:
- * - BEFORE asking for a transport
- * - AFTER param serialization (s.data is a string if s.processData is true)
- * 3) key is the dataType
- * 4) the catchall symbol "*" can be used
- * 5) execution will start with transport dataType and THEN continue down to "*" if needed
- */
- prefilters = {},
- /* Transports bindings
- * 1) key is the dataType
- * 2) the catchall symbol "*" can be used
- * 3) selection will start with transport dataType and THEN go to "*" if needed
- */
- transports = {};
- // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport
- function addToPrefiltersOrTransports( structure ) {
- // dataTypeExpression is optional and defaults to "*"
- return function( dataTypeExpression, func ) {
- if ( typeof dataTypeExpression !== "string" ) {
- func = dataTypeExpression;
- dataTypeExpression = "*";
- }
- if ( jQuery.isFunction( func ) ) {
- var dataTypes = dataTypeExpression.toLowerCase().split( rspacesAjax ),
- i = 0,
- length = dataTypes.length,
- dataType,
- list,
- placeBefore;
- // For each dataType in the dataTypeExpression
- for(; i < length; i++ ) {
- dataType = dataTypes[ i ];
- // We control if we're asked to add before
- // any existing element
- placeBefore = /^\+/.test( dataType );
- if ( placeBefore ) {
- dataType = dataType.substr( 1 ) || "*";
- }
- list = structure[ dataType ] = structure[ dataType ] || [];
- // then we add to the structure accordingly
- list[ placeBefore ? "unshift" : "push" ]( func );
- }
- }
- };
- }
- //Base inspection function for prefilters and transports
- function inspectPrefiltersOrTransports( structure, options, originalOptions, jXHR,
- dataType /* internal */, inspected /* internal */ ) {
- dataType = dataType || options.dataTypes[ 0 ];
- inspected = inspected || {};
- inspected[ dataType ] = true;
- var list = structure[ dataType ],
- i = 0,
- length = list ? list.length : 0,
- executeOnly = ( structure === prefilters ),
- selection;
- for(; i < length && ( executeOnly || !selection ); i++ ) {
- selection = list[ i ]( options, originalOptions, jXHR );
- // If we got redirected to another dataType
- // we try there if not done already
- if ( typeof selection === "string" ) {
- if ( inspected[ selection ] ) {
- selection = undefined;
- } else {
- options.dataTypes.unshift( selection );
- selection = inspectPrefiltersOrTransports(
- structure, options, originalOptions, jXHR, selection, inspected );
- }
- }
- }
- // If we're only executing or nothing was selected
- // we try the catchall dataType if not done already
- if ( ( executeOnly || !selection ) && !inspected[ "*" ] ) {
- selection = inspectPrefiltersOrTransports(
- structure, options, originalOptions, jXHR, "*", inspected );
- }
- // unnecessary when only executing (prefilters)
- // but it'll be ignored by the caller in that case
- return selection;
- }
- jQuery.fn.extend({
- load: function( url, params, callback ) {
- if ( typeof url !== "string" && _load ) {
- return _load.apply( this, arguments );
- // Don't do a request if no elements are being requested
- } else if ( !this.length ) {
- return this;
- }
- var off = url.indexOf( " " );
- if ( off >= 0 ) {
- var selector = url.slice( off, url.length );
- url = url.slice( 0, off );
- }
- // Default to a GET request
- var type = "GET";
- // If the second parameter was provided
- if ( params ) {
- // If it's a function
- if ( jQuery.isFunction( params ) ) {
- // We assume that it's the callback
- callback = params;
- params = null;
- // Otherwise, build a param string
- } else if ( typeof params === "object" ) {
- params = jQuery.param( params, jQuery.ajaxSettings.traditional );
- type = "POST";
- }
- }
- var self = this;
- // Request the remote document
- jQuery.ajax({
- url: url,
- type: type,
- dataType: "html",
- data: params,
- // Complete callback (responseText is used internally)
- complete: function( jXHR, status, responseText ) {
- // Store the response as specified by the jXHR object
- responseText = jXHR.responseText;
- // If successful, inject the HTML into all the matched elements
- if ( jXHR.isResolved() ) {
- // #4825: Get the actual response in case
- // a dataFilter is present in ajaxSettings
- jXHR.done(function( r ) {
- responseText = r;
- });
- // See if a selector was specified
- self.html( selector ?
- // Create a dummy div to hold the results
- jQuery("<div>")
- // inject the contents of the document in, removing the scripts
- // to avoid any 'Permission Denied' errors in IE
- .append(responseText.replace(rscript, ""))
- // Locate the specified elements
- .find(selector) :
- // If not, just inject the full result
- responseText );
- }
- if ( callback ) {
- self.each( callback, [ responseText, status, jXHR ] );
- }
- }
- });
- return this;
- },
- serialize: function() {
- return jQuery.param( this.serializeArray() );
- },
- serializeArray: function() {
- return this.map(function(){
- return this.elements ? jQuery.makeArray( this.elements ) : this;
- })
- .filter(function(){
- return this.name && !this.disabled &&
- ( this.checked || rselectTextarea.test( this.nodeName ) ||
- rinput.test( this.type ) );
- })
- .map(function( i, elem ){
- var val = jQuery( this ).val();
- return val == null ?
- null :
- jQuery.isArray( val ) ?
- jQuery.map( val, function( val, i ){
- return { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
- }) :
- { name: elem.name, value: val.replace( rCRLF, "\r\n" ) };
- }).get();
- }
- });
- // Attach a bunch of functions for handling common AJAX events
- jQuery.each( "ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split( " " ), function( i, o ){
- jQuery.fn[ o ] = function( f ){
- return this.bind( o, f );
- };
- } );
- jQuery.each( [ "get", "post" ], function( i, method ) {
- jQuery[ method ] = function( url, data, callback, type ) {
- // shift arguments if data argument was omitted
- if ( jQuery.isFunction( data ) ) {
- type = type || callback;
- callback = data;
- data = null;
- }
- return jQuery.ajax({
- type: method,
- url: url,
- data: data,
- success: callback,
- dataType: type
- });
- };
- } );
- jQuery.extend({
- getScript: function( url, callback ) {
- return jQuery.get( url, null, callback, "script" );
- },
- getJSON: function( url, data, callback ) {
- return jQuery.get( url, data, callback, "json" );
- },
- ajaxSetup: function( settings ) {
- jQuery.extend( true, jQuery.ajaxSettings, settings );
- if ( settings.context ) {
- jQuery.ajaxSettings.context = settings.context;
- }
- },
- ajaxSettings: {
- url: location.href,
- global: true,
- type: "GET",
- contentType: "application/x-www-form-urlencoded",
- processData: true,
- async: true,
- /*
- timeout: 0,
- data: null,
- dataType: null,
- username: null,
- password: null,
- cache: null,
- traditional: false,
- headers: {},
- crossDomain: null,
- */
- accepts: {
- xml: "application/xml, text/xml",
- html: "text/html",
- text: "text/plain",
- json: "application/json, text/javascript",
- "*": "*/*"
- },
- contents: {
- xml: /xml/,
- html: /html/,
- json: /json/
- },
- responseFields: {
- xml: "responseXML",
- text: "responseText"
- },
- // List of data converters
- // 1) key format is "source_type destination_type" (a single space in-between)
- // 2) the catchall symbol "*" can be used for source_type
- converters: {
- // Convert anything to text
- "* text": window.String,
- // Text to html (true = no transformation)
- "text html": true,
- // Evaluate text as a json expression
- "text json": jQuery.parseJSON,
- // Parse text as xml
- "text xml": jQuery.parseXML
- }
- },
- ajaxPrefilter: addToPrefiltersOrTransports( prefilters ),
- ajaxTransport: addToPrefiltersOrTransports( transports ),
- // Main method
- ajax: function( url, options ) {
- // If options is not an object,
- // we simulate pre-1.5 signature
- if ( typeof options !== "object" ) {
- options = url;
- url = undefined;
- }
- // Force options to be an object
- options = options || {};
- var // Create the final options object
- s = jQuery.extend( true, {}, jQuery.ajaxSettings, options ),
- // Callbacks contexts
- // We force the original context if it exists
- // or take it from jQuery.ajaxSettings otherwise
- // (plain objects used as context get extended)
- callbackContext =
- ( s.context = ( "context" in options ? options : jQuery.ajaxSettings ).context ) || s,
- globalEventContext = callbackContext === s ? jQuery.event : jQuery( callbackContext ),
- // Deferreds
- deferred = jQuery.Deferred(),
- completeDeferred = jQuery._Deferred(),
- // Status-dependent callbacks
- statusCode = s.statusCode || {},
- // Headers (they are sent all at once)
- requestHeaders = {},
- // Response headers
- responseHeadersString,
- responseHeaders,
- // transport
- transport,
- // timeout handle
- timeoutTimer,
- // Cross-domain detection vars
- loc = document.location,
- protocol = loc.protocol || "http:",
- parts,
- // The jXHR state
- state = 0,
- // Loop variable
- i,
- // Fake xhr
- jXHR = {
- readyState: 0,
- // Caches the header
- setRequestHeader: function( name, value ) {
- if ( state === 0 ) {
- requestHeaders[ name.toLowerCase() ] = value;
- }
- return this;
- },
- // Raw string
- getAllResponseHeaders: function() {
- return state === 2 ? responseHeadersString : null;
- },
- // Builds headers hashtable if needed
- getResponseHeader: function( key ) {
- var match;
- if ( state === 2 ) {
- if ( !responseHeaders ) {
- responseHeaders = {};
- while( ( match = rheaders.exec( responseHeadersString ) ) ) {
- responseHeaders[ match[1].toLowerCase() ] = match[ 2 ];
- }
- }
- match = responseHeaders[ key.toLowerCase() ];
- }
- return match || null;
- },
- // Cancel the request
- abort: function( statusText ) {
- statusText = statusText || "abort";
- if ( transport ) {
- transport.abort( statusText );
- }
- done( 0, statusText );
- return this;
- }
- };
- // Callback for when everything is done
- // It is defined here because jslint complains if it is declared
- // at the end of the function (which would be more logical and readable)
- function done( status, statusText, responses, headers) {
- // Called once
- if ( state === 2 ) {
- return;
- }
- // State is "done" now
- state = 2;
- // Clear timeout if it exists
- if ( timeoutTimer ) {
- clearTimeout( timeoutTimer );
- }
- // Dereference transport for early garbage collection
- // (no matter how long the jXHR object will be used)
- transport = undefined;
- // Cache response headers
- responseHeadersString = headers || "";
- // Set readyState
- jXHR.readyState = status ? 4 : 0;
- var isSuccess,
- success,
- error,
- response = responses ? ajaxHandleResponses( s, jXHR, responses ) : undefined,
- lastModified,
- etag;
- // If successful, handle type chaining
- if ( status >= 200 && status < 300 || status === 304 ) {
- // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
- if ( s.ifModified ) {
- if ( ( lastModified = jXHR.getResponseHeader( "Last-Modified" ) ) ) {
- jQuery.lastModified[ s.url ] = lastModified;
- }
- if ( ( etag = jXHR.getResponseHeader( "Etag" ) ) ) {
- jQuery.etag[ s.url ] = etag;
- }
- }
- // If not modified
- if ( status === 304 ) {
- statusText = "notmodified";
- isSuccess = true;
- // If we have data
- } else {
- try {
- success = ajaxConvert( s, response );
- statusText = "success";
- isSuccess = true;
- } catch(e) {
- // We have a parsererror
- statusText = "parsererror";
- error = e;
- }
- }
- } else {
- // We extract error from statusText
- // then normalize statusText and status for non-aborts
- error = statusText;
- if( status ) {
- statusText = "error";
- if ( status < 0 ) {
- status = 0;
- }
- }
- }
- // Set data for the fake xhr object
- jXHR.status = status;
- jXHR.statusText = statusText;
- // Success/Error
- if ( isSuccess ) {
- deferred.resolveWith( callbackContext, [ success, statusText, jXHR ] );
- } else {
- deferred.rejectWith( callbackContext, [ jXHR, statusText, error ] );
- }
- // Status-dependent callbacks
- jXHR.statusCode( statusCode );
- statusCode = undefined;
- if ( s.global ) {
- globalEventContext.trigger( "ajax" + ( isSuccess ? "Success" : "Error" ),
- [ jXHR, s, isSuccess ? success : error ] );
- }
- // Complete
- completeDeferred.resolveWith( callbackContext, [ jXHR, statusText ] );
- if ( s.global ) {
- globalEventContext.trigger( "ajaxComplete", [ jXHR, s] );
- // Handle the global AJAX counter
- if ( !( --jQuery.active ) ) {
- jQuery.event.trigger( "ajaxStop" );
- }
- }
- }
- // Attach deferreds
- deferred.promise( jXHR );
- jXHR.success = jXHR.done;
- jXHR.error = jXHR.fail;
- jXHR.complete = completeDeferred.done;
- // Status-dependent callbacks
- jXHR.statusCode = function( map ) {
- if ( map ) {
- var tmp;
- if ( state < 2 ) {
- for( tmp in map ) {
- statusCode[ tmp ] = [ statusCode[tmp], map[tmp] ];
- }
- } else {
- tmp = map[ jXHR.status ];
- jXHR.then( tmp, tmp );
- }
- }
- return this;
- };
- // Remove hash character (#7531: and string promotion)
- // Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
- // We also use the url parameter if available
- s.url = ( "" + ( url || s.url ) ).replace( rhash, "" ).replace( rprotocol, protocol + "//" );
- // Extract dataTypes list
- s.dataTypes = jQuery.trim( s.dataType || "*" ).toLowerCase().split( rspacesAjax );
- // Determine if a cross-domain request is in order
- if ( !s.crossDomain ) {
- parts = rurl.exec( s.url.toLowerCase() );
- s.crossDomain = !!( parts &&
- ( parts[ 1 ] != protocol || parts[ 2 ] != loc.hostname ||
- ( parts[ 3 ] || ( parts[ 1 ] === "http:" ? 80 : 443 ) ) !=
- ( loc.port || ( protocol === "http:" ? 80 : 443 ) ) )
- );
- }
- // Convert data if not already a string
- if ( s.data && s.processData && typeof s.data !== "string" ) {
- s.data = jQuery.param( s.data, s.traditional );
- }
- // Apply prefilters
- inspectPrefiltersOrTransports( prefilters, s, options, jXHR );
- // Uppercase the type
- s.type = s.type.toUpperCase();
- // Determine if request has content
- s.hasContent = !rnoContent.test( s.type );
- // Watch for a new set of requests
- if ( s.global && jQuery.active++ === 0 ) {
- jQuery.event.trigger( "ajaxStart" );
- }
- // More options handling for requests with no content
- if ( !s.hasContent ) {
- // If data is available, append data to url
- if ( s.data ) {
- s.url += ( rquery.test( s.url ) ? "&" : "?" ) + s.data;
- }
- // Add anti-cache in url if needed
- if ( s.cache === false ) {
- var ts = jQuery.now(),
- // try replacing _= if it is there
- ret = s.url.replace( rts, "$1_=" + ts );
- // if nothing was replaced, add timestamp to the end
- s.url = ret + ( (ret === s.url ) ? ( rquery.test( s.url ) ? "&" : "?" ) + "_=" + ts : "" );
- }
- }
- // Set the correct header, if data is being sent
- if ( s.data && s.hasContent && s.contentType !== false || options.contentType ) {
- requestHeaders[ "content-type" ] = s.contentType;
- }
- // Set the If-Modified-Since and/or If-None-Match header, if in ifModified mode.
- if ( s.ifModified ) {
- if ( jQuery.lastModified[ s.url ] ) {
- requestHeaders[ "if-modified-since" ] = jQuery.lastModified[ s.url ];
- }
- if ( jQuery.etag[ s.url ] ) {
- requestHeaders[ "if-none-match" ] = jQuery.etag[ s.url ];
- }
- }
- // Set the Accepts header for the server, depending on the dataType
- requestHeaders.accept = s.dataTypes[ 0 ] && s.accepts[ s.dataTypes[0] ] ?
- s.accepts[ s.dataTypes[0] ] + ( s.dataTypes[ 0 ] !== "*" ? ", */*; q=0.01" : "" ) :
- s.accepts[ "*" ];
- // Check for headers option
- for ( i in s.headers ) {
- requestHeaders[ i.toLowerCase() ] = s.headers[ i ];
- }
- // Allow custom headers/mimetypes and early abort
- if ( s.beforeSend && ( s.beforeSend.call( callbackContext, jXHR, s ) === false || state === 2 ) ) {
- // Abort if not done already
- done( 0, "abort" );
- // Return false
- jXHR = false;
- } else {
- // Install callbacks on deferreds
- for ( i in { success: 1, error: 1, complete: 1 } ) {
- jXHR[ i ]( s[ i ] );
- }
- // Get transport
- transport = inspectPrefiltersOrTransports( transports, s, options, jXHR );
- // If no transport, we auto-abort
- if ( !transport ) {
- done( -1, "No Transport" );
- } else {
- // Set state as sending
- state = jXHR.readyState = 1;
- // Send global event
- if ( s.global ) {
- globalEventContext.trigger( "ajaxSend", [ jXHR, s ] );
- }
- // Timeout
- if ( s.async && s.timeout > 0 ) {
- timeoutTimer = setTimeout( function(){
- jXHR.abort( "timeout" );
- }, s.timeout );
- }
- try {
- transport.send( requestHeaders, done );
- } catch (e) {
- // Propagate exception as error if not done
- if ( status < 2 ) {
- done( -1, e );
- // Simply rethrow otherwise
- } else {
- jQuery.error( e );
- }
- }
- }
- }
- return jXHR;
- },
- // Serialize an array of form elements or a set of
- // key/values into a query string
- param: function( a, traditional ) {
- var s = [],
- add = function( key, value ) {
- // If value is a function, invoke it and return its value
- value = jQuery.isFunction( value ) ? value() : value;
- s[ s.length ] = encodeURIComponent( key ) + "=" + encodeURIComponent( value );
- };
- // Set traditional to true for jQuery <= 1.3.2 behavior.
- if ( traditional === undefined ) {
- traditional = jQuery.ajaxSettings.traditional;
- }
- // If an array was passed in, assume that it is an array of form elements.
- if ( jQuery.isArray( a ) || a.jquery ) {
- // Serialize the form elements
- jQuery.each( a, function() {
- add( this.name, this.value );
- } );
- } else {
- // If traditional, encode the "old" way (the way 1.3.2 or older
- // did it), otherwise encode params recursively.
- for ( var prefix in a ) {
- buildParams( prefix, a[ prefix ], traditional, add );
- }
- }
- // Return the resulting serialization
- return s.join( "&" ).replace( r20, "+" );
- }
- });
- function buildParams( prefix, obj, traditional, add ) {
- if ( jQuery.isArray( obj ) && obj.length ) {
- // Serialize array item.
- jQuery.each( obj, function( i, v ) {
- if ( traditional || rbracket.test( prefix ) ) {
- // Treat each array item as a scalar.
- add( prefix, v );
- } else {
- // If array item is non-scalar (array or object), encode its
- // numeric index to resolve deserialization ambiguity issues.
- // Note that rack (as of 1.0.0) can't currently deserialize
- // nested arrays properly, and attempting to do so may cause
- // a server error. Possible fixes are to modify rack's
- // deserialization algorithm or to provide an option or flag
- // to force array serialization to be shallow.
- buildParams( prefix + "[" + ( typeof v === "object" || jQuery.isArray(v) ? i : "" ) + "]", v, traditional, add );
- }
- });
- } else if ( !traditional && obj != null && typeof obj === "object" ) {
- // If we see an array here, it is empty and should be treated as an empty
- // object
- if ( jQuery.isArray( obj ) || jQuery.isEmptyObject( obj ) ) {
- add( prefix, "" );
- // Serialize object item.
- } else {
- jQuery.each( obj, function( k, v ) {
- buildParams( prefix + "[" + k + "]", v, traditional, add );
- });
- }
- } else {
- // Serialize scalar item.
- add( prefix, obj );
- }
- }
- // This is still on the jQuery object... for now
- // Want to move this to jQuery.ajax some day
- jQuery.extend({
- // Counter for holding the number of active queries
- active: 0,
- // Last-Modified header cache for next request
- lastModified: {},
- etag: {}
- });
- /* Handles responses to an ajax request:
- * - sets all responseXXX fields accordingly
- * - finds the right dataType (mediates between content-type and expected dataType)
- * - returns the corresponding response
- */
- function ajaxHandleResponses( s, jXHR, responses ) {
- var contents = s.contents,
- dataTypes = s.dataTypes,
- responseFields = s.responseFields,
- ct,
- type,
- finalDataType,
- firstDataType;
- // Fill responseXXX fields
- for( type in responseFields ) {
- if ( type in responses ) {
- jXHR[ responseFields[type] ] = responses[ type ];
- }
- }
- // Remove auto dataType and get content-type in the process
- while( dataTypes[ 0 ] === "*" ) {
- dataTypes.shift();
- if ( ct === undefined ) {
- ct = jXHR.getResponseHeader( "content-type" );
- }
- }
- // Check if we're dealing with a known content-type
- if ( ct ) {
- for ( type in contents ) {
- if ( contents[ type ] && contents[ type ].test( ct ) ) {
- dataTypes.unshift( type );
- break;
- }
- }
- }
- // Check to see if we have a response for the expected dataType
- if ( dataTypes[ 0 ] in responses ) {
- finalDataType = dataTypes[ 0 ];
- } else {
- // Try convertible dataTypes
- for ( type in responses ) {
- if ( !dataTypes[ 0 ] || s.converters[ type + " " + dataTypes[0] ] ) {
- finalDataType = type;
- break;
- }
- if ( !firstDataType ) {
- firstDataType = type;
- }
- }
- // Or just use first one
- finalDataType = finalDataType || firstDataType;
- }
- // If we found a dataType
- // We add the dataType to the list if needed
- // and return the corresponding response
- if ( finalDataType ) {
- if ( finalDataType !== dataTypes[ 0 ] ) {
- dataTypes.unshift( finalDataType );
- }
- return responses[ finalDataType ];
- }
- }
- // Chain conversions given the request and the original response
- function ajaxConvert( s, response ) {
- // Apply the dataFilter if provided
- if ( s.dataFilter ) {
- response = s.dataFilter( response, s.dataType );
- }
- var dataTypes = s.dataTypes,
- converters = s.converters,
- i,
- length = dataTypes.length,
- tmp,
- // Current and previous dataTypes
- current = dataTypes[ 0 ],
- prev,
- // Conversion expression
- conversion,
- // Conversion function
- conv,
- // Conversion functions (transitive conversion)
- conv1,
- conv2;
- // For each dataType in the chain
- for( i = 1; i < length; i++ ) {
- // Get the dataTypes
- prev = current;
- current = dataTypes[ i ];
- // If current is auto dataType, update it to prev
- if( current === "*" ) {
- current = prev;
- // If no auto and dataTypes are actually different
- } else if ( prev !== "*" && prev !== current ) {
- // Get the converter
- conversion = prev + " " + current;
- conv = converters[ conversion ] || converters[ "* " + current ];
- // If there is no direct converter, search transitively
- if ( !conv ) {
- conv2 = undefined;
- for( conv1 in converters ) {
- tmp = conv1.split( " " );
- if ( tmp[ 0 ] === prev || tmp[ 0 ] === "*" ) {
- conv2 = converters[ tmp[1] + " " + current ];
- if ( conv2 ) {
- conv1 = converters[ conv1 ];
- if ( conv1 === true ) {
- conv = conv2;
- } else if ( conv2 === true ) {
- conv = conv1;
- }
- break;
- }
- }
- }
- }
- // If we found no converter, dispatch an error
- if ( !( conv || conv2 ) ) {
- jQuery.error( "No conversion from " + conversion.replace(" "," to ") );
- }
- // If found converter is not an equivalence
- if ( conv !== true ) {
- // Convert with 1 or 2 converters accordingly
- response = conv ? conv( response ) : conv2( conv1(response) );
- }
- }
- }
- return response;
- }
- var jsc = jQuery.now(),
- jsre = /(\=)\?(&|$)|()\?\?()/i;
- // Default jsonp settings
- jQuery.ajaxSetup({
- jsonp: "callback",
- jsonpCallback: function() {
- return jQuery.expando + "_" + ( jsc++ );
- }
- });
- // Detect, normalize options and install callbacks for jsonp requests
- jQuery.ajaxPrefilter( "json jsonp", function( s, originalSettings, dataIsString /* internal */ ) {
- dataIsString = ( typeof s.data === "string" );
- if ( s.dataTypes[ 0 ] === "jsonp" ||
- originalSettings.jsonpCallback ||
- originalSettings.jsonp != null ||
- s.jsonp !== false && ( jsre.test( s.url ) ||
- dataIsString && jsre.test( s.data ) ) ) {
- var responseContainer,
- jsonpCallback = s.jsonpCallback =
- jQuery.isFunction( s.jsonpCallback ) ? s.jsonpCallback() : s.jsonpCallback,
- previous = window[ jsonpCallback ],
- url = s.url,
- data = s.data,
- replace = "$1" + jsonpCallback + "$2";
- if ( s.jsonp !== false ) {
- url = url.replace( jsre, replace );
- if ( s.url === url ) {
- if ( dataIsString ) {
- data = data.replace( jsre, replace );
- }
- if ( s.data === data ) {
- // Add callback manually
- url += (/\?/.test( url ) ? "&" : "?") + s.jsonp + "=" + jsonpCallback;
- }
- }
- }
- s.url = url;
- s.data = data;
- window[ jsonpCallback ] = function( response ) {
- responseContainer = [ response ];
- };
- s.complete = [ function() {
- // Set callback back to previous value
- window[ jsonpCallback ] = previous;
- // Call if it was a function and we have a response
- if ( previous) {
- if ( responseContainer && jQuery.isFunction( previous ) ) {
- window[ jsonpCallback ] ( responseContainer[ 0 ] );
- }
- } else {
- // else, more memory leak avoidance
- try{
- delete window[ jsonpCallback ];
- } catch( e ) {}
- }
- }, s.complete ];
- // Use data converter to retrieve json after script execution
- s.converters["script json"] = function() {
- if ( ! responseContainer ) {
- jQuery.error( jsonpCallback + " was not called" );
- }
- return responseContainer[ 0 ];
- };
- // force json dataType
- s.dataTypes[ 0 ] = "json";
- // Delegate to script
- return "script";
- }
- } );
- // Install script dataType
- jQuery.ajaxSetup({
- accepts: {
- script: "text/javascript, application/javascript"
- },
- contents: {
- script: /javascript/
- },
- converters: {
- "text script": function( text ) {
- jQuery.globalEval( text );
- return text;
- }
- }
- });
- // Handle cache's special case and global
- jQuery.ajaxPrefilter( "script", function( s ) {
- if ( s.cache === undefined ) {
- s.cache = false;
- }
- if ( s.crossDomain ) {
- s.type = "GET";
- s.global = false;
- }
- } );
- // Bind script tag hack transport
- jQuery.ajaxTransport( "script", function(s) {
- // This transport only deals with cross domain requests
- if ( s.crossDomain ) {
- var script,
- head = document.getElementsByTagName( "head" )[ 0 ] || document.documentElement;
- return {
- send: function( _, callback ) {
- script = document.createElement( "script" );
- script.async = "async";
- if ( s.scriptCharset ) {
- script.charset = s.scriptCharset;
- }
- script.src = s.url;
- // Attach handlers for all browsers
- script.onload = script.onreadystatechange = function( _, isAbort ) {
- if ( !script.readyState || /loaded|complete/.test( script.readyState ) ) {
- // Handle memory leak in IE
- script.onload = script.onreadystatechange = null;
- // Remove the script
- if ( head && script.parentNode ) {
- head.removeChild( script );
- }
- // Dereference the script
- script = undefined;
- // Callback if not abort
- if ( !isAbort ) {
- callback( 200, "success" );
- }
- }
- };
- // Use insertBefore instead of appendChild to circumvent an IE6 bug.
- // This arises when a base node is used (#2709 and #4378).
- head.insertBefore( script, head.firstChild );
- },
- abort: function() {
- if ( script ) {
- script.onload( 0, 1 );
- }
- }
- };
- }
- } );
- var // Next active xhr id
- xhrId = jQuery.now(),
- // active xhrs
- xhrs = {},
- // #5280: see below
- xhrUnloadAbortInstalled,
- // XHR used to determine supports properties
- testXHR;
- // Create the request object
- // (This is still attached to ajaxSettings for backward compatibility)
- jQuery.ajaxSettings.xhr = window.ActiveXObject ?
- /* Microsoft failed to properly
- * implement the XMLHttpRequest in IE7 (can't request local files),
- * so we use the ActiveXObject when it is available
- * Additionally XMLHttpRequest can be disabled in IE7/IE8 so
- * we need a fallback.
- */
- function() {
- if ( window.location.protocol !== "file:" ) {
- try {
- return new window.XMLHttpRequest();
- } catch( xhrError ) {}
- }
- try {
- return new window.ActiveXObject("Microsoft.XMLHTTP");
- } catch( activeError ) {}
- } :
- // For all other browsers, use the standard XMLHttpRequest object
- function() {
- return new window.XMLHttpRequest();
- };
- // Test if we can create an xhr object
- try {
- testXHR = jQuery.ajaxSettings.xhr();
- } catch( xhrCreationException ) {}
- //Does this browser support XHR requests?
- jQuery.support.ajax = !!testXHR;
- // Does this browser support crossDomain XHR requests
- jQuery.support.cors = testXHR && ( "withCredentials" in testXHR );
- // No need for the temporary xhr anymore
- testXHR = undefined;
- // Create transport if the browser can provide an xhr
- if ( jQuery.support.ajax ) {
- jQuery.ajaxTransport(function( s ) {
- // Cross domain only allowed if supported through XMLHttpRequest
- if ( !s.crossDomain || jQuery.support.cors ) {
- var callback;
- return {
- send: function( headers, complete ) {
- // #5280: we need to abort on unload or IE will keep connections alive
- if ( !xhrUnloadAbortInstalled ) {
- xhrUnloadAbortInstalled = 1;
- jQuery(window).bind( "unload", function() {
- // Abort all pending requests
- jQuery.each( xhrs, function( _, xhr ) {
- if ( xhr.onreadystatechange ) {
- xhr.onreadystatechange( 1 );
- }
- } );
- } );
- }
- // Get a new xhr
- var xhr = s.xhr(),
- handle;
- // Open the socket
- // Passing null username, generates a login popup on Opera (#2865)
- if ( s.username ) {
- xhr.open( s.type, s.url, s.async, s.username, s.password );
- } else {
- xhr.open( s.type, s.url, s.async );
- }
- // Requested-With header
- // Not set for crossDomain requests with no content
- // (see why at http://trac.dojotoolkit.org/ticket/9486)
- // Won't change header if already provided
- if ( !( s.crossDomain && !s.hasContent ) && !headers["x-requested-with"] ) {
- headers[ "x-requested-with" ] = "XMLHttpRequest";
- }
- // Need an extra try/catch for cross domain requests in Firefox 3
- try {
- jQuery.each( headers, function( key, value ) {
- xhr.setRequestHeader( key, value );
- } );
- } catch( _ ) {}
- // Do send the request
- // This may raise an exception which is actually
- // handled in jQuery.ajax (so no try/catch here)
- xhr.send( ( s.hasContent && s.data ) || null );
- // Listener
- callback = function( _, isAbort ) {
- // Was never called and is aborted or complete
- if ( callback && ( isAbort || xhr.readyState === 4 ) ) {
- // Only called once
- callback = 0;
- // Do not keep as active anymore
- if ( handle ) {
- xhr.onreadystatechange = jQuery.noop;
- delete xhrs[ handle ];
- }
- // If it's an abort
- if ( isAbort ) {
- // Abort it manually if needed
- if ( xhr.readyState !== 4 ) {
- xhr.abort();
- }
- } else {
- // Get info
- var status = xhr.status,
- statusText,
- responseHeaders = xhr.getAllResponseHeaders(),
- responses = {},
- xml = xhr.responseXML;
- // Construct response list
- if ( xml && xml.documentElement /* #4958 */ ) {
- responses.xml = xml;
- }
- responses.text = xhr.responseText;
- // Firefox throws an exception when accessing
- // statusText for faulty cross-domain requests
- try {
- statusText = xhr.statusText;
- } catch( e ) {
- // We normalize with Webkit giving an empty statusText
- statusText = "";
- }
- // Filter status for non standard behaviours
- status =
- // Opera returns 0 when it should be 304
- // Webkit returns 0 for failing cross-domain no matter the real status
- status === 0 ?
- (
- // Webkit, Firefox: filter out faulty cross-domain requests
- !s.crossDomain || statusText ?
- (
- // Opera: filter out real aborts #6060
- responseHeaders ?
- 304 :
- 0
- ) :
- // We assume 302 but could be anything cross-domain related
- 302
- ) :
- (
- // IE sometimes returns 1223 when it should be 204 (see #1450)
- status == 1223 ?
- 204 :
- status
- );
- // Call complete
- complete( status, statusText, responses, responseHeaders );
- }
- }
- };
- // if we're in sync mode or it's in cache
- // and has been retrieved directly (IE6 & IE7)
- // we need to manually fire the callback
- if ( !s.async || xhr.readyState === 4 ) {
- callback();
- } else {
- // Add to list of active xhrs
- handle = xhrId++;
- xhrs[ handle ] = xhr;
- xhr.onreadystatechange = callback;
- }
- },
- abort: function() {
- if ( callback ) {
- callback(0,1);
- }
- }
- };
- }
- });
- }
- var elemdisplay = {},
- rfxtypes = /^(?:toggle|show|hide)$/,
- rfxnum = /^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,
- timerId,
- fxAttrs = [
- // height animations
- [ "height", "marginTop", "marginBottom", "paddingTop", "paddingBottom" ],
- // width animations
- [ "width", "marginLeft", "marginRight", "paddingLeft", "paddingRight" ],
- // opacity animations
- [ "opacity" ]
- ];
- jQuery.fn.extend({
- show: function( speed, easing, callback ) {
- var elem, display;
- if ( speed || speed === 0 ) {
- return this.animate( genFx("show", 3), speed, easing, callback);
- } else {
- for ( var i = 0, j = this.length; i < j; i++ ) {
- elem = this[i];
- display = elem.style.display;
- // Reset the inline display of this element to learn if it is
- // being hidden by cascaded rules or not
- if ( !jQuery._data(elem, "olddisplay") && display === "none" ) {
- display = elem.style.display = "";
- }
- // Set elements which have been overridden with display: none
- // in a stylesheet to whatever the default browser style is
- // for such an element
- if ( display === "" && jQuery.css( elem, "display" ) === "none" ) {
- jQuery._data(elem, "olddisplay", defaultDisplay(elem.nodeName));
- }
- }
- // Set the display of most of the elements in a second loop
- // to avoid the constant reflow
- for ( i = 0; i < j; i++ ) {
- elem = this[i];
- display = elem.style.display;
- if ( display === "" || display === "none" ) {
- elem.style.display = jQuery._data(elem, "olddisplay") || "";
- }
- }
- return this;
- }
- },
- hide: function( speed, easing, callback ) {
- if ( speed || speed === 0 ) {
- return this.animate( genFx("hide", 3), speed, easing, callback);
- } else {
- for ( var i = 0, j = this.length; i < j; i++ ) {
- var display = jQuery.css( this[i], "display" );
- if ( display !== "none" && !jQuery._data( this[i], "olddisplay" ) ) {
- jQuery._data( this[i], "olddisplay", display );
- }
- }
- // Set the display of the elements in a second loop
- // to avoid the constant reflow
- for ( i = 0; i < j; i++ ) {
- this[i].style.display = "none";
- }
- return this;
- }
- },
- // Save the old toggle function
- _toggle: jQuery.fn.toggle,
- toggle: function( fn, fn2, callback ) {
- var bool = typeof fn === "boolean";
- if ( jQuery.isFunction(fn) && jQuery.isFunction(fn2) ) {
- this._toggle.apply( this, arguments );
- } else if ( fn == null || bool ) {
- this.each(function() {
- var state = bool ? fn : jQuery(this).is(":hidden");
- jQuery(this)[ state ? "show" : "hide" ]();
- });
- } else {
- this.animate(genFx("toggle", 3), fn, fn2, callback);
- }
- return this;
- },
- fadeTo: function( speed, to, easing, callback ) {
- return this.filter(":hidden").css("opacity", 0).show().end()
- .animate({opacity: to}, speed, easing, callback);
- },
- animate: function( prop, speed, easing, callback ) {
- var optall = jQuery.speed(speed, easing, callback);
- if ( jQuery.isEmptyObject( prop ) ) {
- return this.each( optall.complete );
- }
- return this[ optall.queue === false ? "each" : "queue" ](function() {
- // XXX 'this' does not always have a nodeName when running the
- // test suite
- var opt = jQuery.extend({}, optall), p,
- isElement = this.nodeType === 1,
- hidden = isElement && jQuery(this).is(":hidden"),
- self = this;
- for ( p in prop ) {
- var name = jQuery.camelCase( p );
- if ( p !== name ) {
- prop[ name ] = prop[ p ];
- delete prop[ p ];
- p = name;
- }
- if ( prop[p] === "hide" && hidden || prop[p] === "show" && !hidden ) {
- return opt.complete.call(this);
- }
- if ( isElement && ( p === "height" || p === "width" ) ) {
- // Make sure that nothing sneaks out
- // Record all 3 overflow attributes because IE does not
- // change the overflow attribute when overflowX and
- // overflowY are set to the same value
- opt.overflow = [ this.style.overflow, this.style.overflowX, this.style.overflowY ];
- // Set display property to inline-block for height/width
- // animations on inline elements that are having width/height
- // animated
- if ( jQuery.css( this, "display" ) === "inline" &&
- jQuery.css( this, "float" ) === "none" ) {
- if ( !jQuery.support.inlineBlockNeedsLayout ) {
- this.style.display = "inline-block";
- } else {
- var display = defaultDisplay(this.nodeName);
- // inline-level elements accept inline-block;
- // block-level elements need to be inline with layout
- if ( display === "inline" ) {
- this.style.display = "inline-block";
- } else {
- this.style.display = "inline";
- this.style.zoom = 1;
- }
- }
- }
- }
- if ( jQuery.isArray( prop[p] ) ) {
- // Create (if needed) and add to specialEasing
- (opt.specialEasing = opt.specialEasing || {})[p] = prop[p][1];
- prop[p] = prop[p][0];
- }
- }
- if ( opt.overflow != null ) {
- this.style.overflow = "hidden";
- }
- opt.curAnim = jQuery.extend({}, prop);
- jQuery.each( prop, function( name, val ) {
- var e = new jQuery.fx( self, opt, name );
- if ( rfxtypes.test(val) ) {
- e[ val === "toggle" ? hidden ? "show" : "hide" : val ]( prop );
- } else {
- var parts = rfxnum.exec(val),
- start = e.cur() || 0;
- if ( parts ) {
- var end = parseFloat( parts[2] ),
- unit = parts[3] || "px";
- // We need to compute starting value
- if ( unit !== "px" ) {
- jQuery.style( self, name, (end || 1) + unit);
- start = ((end || 1) / e.cur()) * start;
- jQuery.style( self, name, start + unit);
- }
- // If a +=/-= token was provided, we're doing a relative animation
- if ( parts[1] ) {
- end = ((parts[1] === "-=" ? -1 : 1) * end) + start;
- }
- e.custom( start, end, unit );
- } else {
- e.custom( start, val, "" );
- }
- }
- });
- // For JS strict compliance
- return true;
- });
- },
- stop: function( clearQueue, gotoEnd ) {
- var timers = jQuery.timers;
- if ( clearQueue ) {
- this.queue([]);
- }
- this.each(function() {
- // go in reverse order so anything added to the queue during the loop is ignored
- for ( var i = timers.length - 1; i >= 0; i-- ) {
- if ( timers[i].elem === this ) {
- if (gotoEnd) {
- // force the next step to be the last
- timers[i](true);
- }
- timers.splice(i, 1);
- }
- }
- });
- // start the next in the queue if the last step wasn't forced
- if ( !gotoEnd ) {
- this.dequeue();
- }
- return this;
- }
- });
- function genFx( type, num ) {
- var obj = {};
- jQuery.each( fxAttrs.concat.apply([], fxAttrs.slice(0,num)), function() {
- obj[ this ] = type;
- });
- return obj;
- }
- // Generate shortcuts for custom animations
- jQuery.each({
- slideDown: genFx("show", 1),
- slideUp: genFx("hide", 1),
- slideToggle: genFx("toggle", 1),
- fadeIn: { opacity: "show" },
- fadeOut: { opacity: "hide" },
- fadeToggle: { opacity: "toggle" }
- }, function( name, props ) {
- jQuery.fn[ name ] = function( speed, easing, callback ) {
- return this.animate( props, speed, easing, callback );
- };
- });
- jQuery.extend({
- speed: function( speed, easing, fn ) {
- var opt = speed && typeof speed === "object" ? jQuery.extend({}, speed) : {
- complete: fn || !fn && easing ||
- jQuery.isFunction( speed ) && speed,
- duration: speed,
- easing: fn && easing || easing && !jQuery.isFunction(easing) && easing
- };
- opt.duration = jQuery.fx.off ? 0 : typeof opt.duration === "number" ? opt.duration :
- opt.duration in jQuery.fx.speeds ? jQuery.fx.speeds[opt.duration] : jQuery.fx.speeds._default;
- // Queueing
- opt.old = opt.complete;
- opt.complete = function() {
- if ( opt.queue !== false ) {
- jQuery(this).dequeue();
- }
- if ( jQuery.isFunction( opt.old ) ) {
- opt.old.call( this );
- }
- };
- return opt;
- },
- easing: {
- linear: function( p, n, firstNum, diff ) {
- return firstNum + diff * p;
- },
- swing: function( p, n, firstNum, diff ) {
- return ((-Math.cos(p*Math.PI)/2) + 0.5) * diff + firstNum;
- }
- },
- timers: [],
- fx: function( elem, options, prop ) {
- this.options = options;
- this.elem = elem;
- this.prop = prop;
- if ( !options.orig ) {
- options.orig = {};
- }
- }
- });
- jQuery.fx.prototype = {
- // Simple function for setting a style value
- update: function() {
- if ( this.options.step ) {
- this.options.step.call( this.elem, this.now, this );
- }
- (jQuery.fx.step[this.prop] || jQuery.fx.step._default)( this );
- },
- // Get the current size
- cur: function() {
- if ( this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null) ) {
- return this.elem[ this.prop ];
- }
- var r = parseFloat( jQuery.css( this.elem, this.prop ) );
- return r || 0;
- },
- // Start an animation from one number to another
- custom: function( from, to, unit ) {
- var self = this,
- fx = jQuery.fx;
- this.startTime = jQuery.now();
- this.start = from;
- this.end = to;
- this.unit = unit || this.unit || "px";
- this.now = this.start;
- this.pos = this.state = 0;
- function t( gotoEnd ) {
- return self.step(gotoEnd);
- }
- t.elem = this.elem;
- if ( t() && jQuery.timers.push(t) && !timerId ) {
- timerId = setInterval(fx.tick, fx.interval);
- }
- },
- // Simple 'show' function
- show: function() {
- // Remember where we started, so that we can go back to it later
- this.options.orig[this.prop] = jQuery.style( this.elem, this.prop );
- this.options.show = true;
- // Begin the animation
- // Make sure that we start at a small width/height to avoid any
- // flash of content
- this.custom(this.prop === "width" || this.prop === "height" ? 1 : 0, this.cur());
- // Start by showing the element
- jQuery( this.elem ).show();
- },
- // Simple 'hide' function
- hide: function() {
- // Remember where we started, so that we can go back to it later
- this.options.orig[this.prop] = jQuery.style( this.elem, this.prop );
- this.options.hide = true;
- // Begin the animation
- this.custom(this.cur(), 0);
- },
- // Each step of an animation
- step: function( gotoEnd ) {
- var t = jQuery.now(), done = true;
- if ( gotoEnd || t >= this.options.duration + this.startTime ) {
- this.now = this.end;
- this.pos = this.state = 1;
- this.update();
- this.options.curAnim[ this.prop ] = true;
- for ( var i in this.options.curAnim ) {
- if ( this.options.curAnim[i] !== true ) {
- done = false;
- }
- }
- if ( done ) {
- // Reset the overflow
- if ( this.options.overflow != null && !jQuery.support.shrinkWrapBlocks ) {
- var elem = this.elem,
- options = this.options;
- jQuery.each( [ "", "X", "Y" ], function (index, value) {
- elem.style[ "overflow" + value ] = options.overflow[index];
- } );
- }
- // Hide the element if the "hide" operation was done
- if ( this.options.hide ) {
- jQuery(this.elem).hide();
- }
- // Reset the properties, if the item has been hidden or shown
- if ( this.options.hide || this.options.show ) {
- for ( var p in this.options.curAnim ) {
- jQuery.style( this.elem, p, this.options.orig[p] );
- }
- }
- // Execute the complete function
- this.options.complete.call( this.elem );
- }
- return false;
- } else {
- var n = t - this.startTime;
- this.state = n / this.options.duration;
- // Perform the easing function, defaults to swing
- var specialEasing = this.options.specialEasing && this.options.specialEasing[this.prop];
- var defaultEasing = this.options.easing || (jQuery.easing.swing ? "swing" : "linear");
- this.pos = jQuery.easing[specialEasing || defaultEasing](this.state, n, 0, 1, this.options.duration);
- this.now = this.start + ((this.end - this.start) * this.pos);
- // Perform the next step of the animation
- this.update();
- }
- return true;
- }
- };
- jQuery.extend( jQuery.fx, {
- tick: function() {
- var timers = jQuery.timers;
- for ( var i = 0; i < timers.length; i++ ) {
- if ( !timers[i]() ) {
- timers.splice(i--, 1);
- }
- }
- if ( !timers.length ) {
- jQuery.fx.stop();
- }
- },
- interval: 13,
- stop: function() {
- clearInterval( timerId );
- timerId = null;
- },
- speeds: {
- slow: 600,
- fast: 200,
- // Default speed
- _default: 400
- },
- step: {
- opacity: function( fx ) {
- jQuery.style( fx.elem, "opacity", fx.now );
- },
- _default: function( fx ) {
- if ( fx.elem.style && fx.elem.style[ fx.prop ] != null ) {
- fx.elem.style[ fx.prop ] = (fx.prop === "width" || fx.prop === "height" ? Math.max(0, fx.now) : fx.now) + fx.unit;
- } else {
- fx.elem[ fx.prop ] = fx.now;
- }
- }
- }
- });
- if ( jQuery.expr && jQuery.expr.filters ) {
- jQuery.expr.filters.animated = function( elem ) {
- return jQuery.grep(jQuery.timers, function( fn ) {
- return elem === fn.elem;
- }).length;
- };
- }
- function defaultDisplay( nodeName ) {
- if ( !elemdisplay[ nodeName ] ) {
- var elem = jQuery("<" + nodeName + ">").appendTo("body"),
- display = elem.css("display");
- elem.remove();
- if ( display === "none" || display === "" ) {
- display = "block";
- }
- elemdisplay[ nodeName ] = display;
- }
- return elemdisplay[ nodeName ];
- }
- var rtable = /^t(?:able|d|h)$/i,
- rroot = /^(?:body|html)$/i;
- if ( "getBoundingClientRect" in document.documentElement ) {
- jQuery.fn.offset = function( options ) {
- var elem = this[0], box;
- if ( options ) {
- return this.each(function( i ) {
- jQuery.offset.setOffset( this, options, i );
- });
- }
- if ( !elem || !elem.ownerDocument ) {
- return null;
- }
- if ( elem === elem.ownerDocument.body ) {
- return jQuery.offset.bodyOffset( elem );
- }
- try {
- box = elem.getBoundingClientRect();
- } catch(e) {}
- var doc = elem.ownerDocument,
- docElem = doc.documentElement;
- // Make sure we're not dealing with a disconnected DOM node
- if ( !box || !jQuery.contains( docElem, elem ) ) {
- return box ? { top: box.top, left: box.left } : { top: 0, left: 0 };
- }
- var body = doc.body,
- win = getWindow(doc),
- clientTop = docElem.clientTop || body.clientTop || 0,
- clientLeft = docElem.clientLeft || body.clientLeft || 0,
- scrollTop = (win.pageYOffset || jQuery.support.boxModel && docElem.scrollTop || body.scrollTop ),
- scrollLeft = (win.pageXOffset || jQuery.support.boxModel && docElem.scrollLeft || body.scrollLeft),
- top = box.top + scrollTop - clientTop,
- left = box.left + scrollLeft - clientLeft;
- return { top: top, left: left };
- };
- } else {
- jQuery.fn.offset = function( options ) {
- var elem = this[0];
- if ( options ) {
- return this.each(function( i ) {
- jQuery.offset.setOffset( this, options, i );
- });
- }
- if ( !elem || !elem.ownerDocument ) {
- return null;
- }
- if ( elem === elem.ownerDocument.body ) {
- return jQuery.offset.bodyOffset( elem );
- }
- jQuery.offset.initialize();
- var computedStyle,
- offsetParent = elem.offsetParent,
- prevOffsetParent = elem,
- doc = elem.ownerDocument,
- docElem = doc.documentElement,
- body = doc.body,
- defaultView = doc.defaultView,
- prevComputedStyle = defaultView ? defaultView.getComputedStyle( elem, null ) : elem.currentStyle,
- top = elem.offsetTop,
- left = elem.offsetLeft;
- while ( (elem = elem.parentNode) && elem !== body && elem !== docElem ) {
- if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) {
- break;
- }
- computedStyle = defaultView ? defaultView.getComputedStyle(elem, null) : elem.currentStyle;
- top -= elem.scrollTop;
- left -= elem.scrollLeft;
- if ( elem === offsetParent ) {
- top += elem.offsetTop;
- left += elem.offsetLeft;
- if ( jQuery.offset.doesNotAddBorder && !(jQuery.offset.doesAddBorderForTableAndCells && rtable.test(elem.nodeName)) ) {
- top += parseFloat( computedStyle.borderTopWidth ) || 0;
- left += parseFloat( computedStyle.borderLeftWidth ) || 0;
- }
- prevOffsetParent = offsetParent;
- offsetParent = elem.offsetParent;
- }
- if ( jQuery.offset.subtractsBorderForOverflowNotVisible && computedStyle.overflow !== "visible" ) {
- top += parseFloat( computedStyle.borderTopWidth ) || 0;
- left += parseFloat( computedStyle.borderLeftWidth ) || 0;
- }
- prevComputedStyle = computedStyle;
- }
- if ( prevComputedStyle.position === "relative" || prevComputedStyle.position === "static" ) {
- top += body.offsetTop;
- left += body.offsetLeft;
- }
- if ( jQuery.offset.supportsFixedPosition && prevComputedStyle.position === "fixed" ) {
- top += Math.max( docElem.scrollTop, body.scrollTop );
- left += Math.max( docElem.scrollLeft, body.scrollLeft );
- }
- return { top: top, left: left };
- };
- }
- jQuery.offset = {
- initialize: function() {
- var body = document.body, container = document.createElement("div"), innerDiv, checkDiv, table, td, bodyMarginTop = parseFloat( jQuery.css(body, "marginTop") ) || 0,
- html = "<div style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;'><div></div></div><table style='position:absolute;top:0;left:0;margin:0;border:5px solid #000;padding:0;width:1px;height:1px;' cellpadding='0' cellspacing='0'><tr><td></td></tr></table>";
- jQuery.extend( container.style, { position: "absolute", top: 0, left: 0, margin: 0, border: 0, width: "1px", height: "1px", visibility: "hidden" } );
- container.innerHTML = html;
- body.insertBefore( container, body.firstChild );
- innerDiv = container.firstChild;
- checkDiv = innerDiv.firstChild;
- td = innerDiv.nextSibling.firstChild.firstChild;
- this.doesNotAddBorder = (checkDiv.offsetTop !== 5);
- this.doesAddBorderForTableAndCells = (td.offsetTop === 5);
- checkDiv.style.position = "fixed";
- checkDiv.style.top = "20px";
- // safari subtracts parent border width here which is 5px
- this.supportsFixedPosition = (checkDiv.offsetTop === 20 || checkDiv.offsetTop === 15);
- checkDiv.style.position = checkDiv.style.top = "";
- innerDiv.style.overflow = "hidden";
- innerDiv.style.position = "relative";
- this.subtractsBorderForOverflowNotVisible = (checkDiv.offsetTop === -5);
- this.doesNotIncludeMarginInBodyOffset = (body.offsetTop !== bodyMarginTop);
- body.removeChild( container );
- body = container = innerDiv = checkDiv = table = td = null;
- jQuery.offset.initialize = jQuery.noop;
- },
- bodyOffset: function( body ) {
- var top = body.offsetTop,
- left = body.offsetLeft;
- jQuery.offset.initialize();
- if ( jQuery.offset.doesNotIncludeMarginInBodyOffset ) {
- top += parseFloat( jQuery.css(body, "marginTop") ) || 0;
- left += parseFloat( jQuery.css(body, "marginLeft") ) || 0;
- }
- return { top: top, left: left };
- },
- setOffset: function( elem, options, i ) {
- var position = jQuery.css( elem, "position" );
- // set position first, in-case top/left are set even on static elem
- if ( position === "static" ) {
- elem.style.position = "relative";
- }
- var curElem = jQuery( elem ),
- curOffset = curElem.offset(),
- curCSSTop = jQuery.css( elem, "top" ),
- curCSSLeft = jQuery.css( elem, "left" ),
- calculatePosition = (position === "absolute" && jQuery.inArray('auto', [curCSSTop, curCSSLeft]) > -1),
- props = {}, curPosition = {}, curTop, curLeft;
- // need to be able to calculate position if either top or left is auto and position is absolute
- if ( calculatePosition ) {
- curPosition = curElem.position();
- }
- curTop = calculatePosition ? curPosition.top : parseInt( curCSSTop, 10 ) || 0;
- curLeft = calculatePosition ? curPosition.left : parseInt( curCSSLeft, 10 ) || 0;
- if ( jQuery.isFunction( options ) ) {
- options = options.call( elem, i, curOffset );
- }
- if (options.top != null) {
- props.top = (options.top - curOffset.top) + curTop;
- }
- if (options.left != null) {
- props.left = (options.left - curOffset.left) + curLeft;
- }
- if ( "using" in options ) {
- options.using.call( elem, props );
- } else {
- curElem.css( props );
- }
- }
- };
- jQuery.fn.extend({
- position: function() {
- if ( !this[0] ) {
- return null;
- }
- var elem = this[0],
- // Get *real* offsetParent
- offsetParent = this.offsetParent(),
- // Get correct offsets
- offset = this.offset(),
- parentOffset = rroot.test(offsetParent[0].nodeName) ? { top: 0, left: 0 } : offsetParent.offset();
- // Subtract element margins
- // note: when an element has margin: auto the offsetLeft and marginLeft
- // are the same in Safari causing offset.left to incorrectly be 0
- offset.top -= parseFloat( jQuery.css(elem, "marginTop") ) || 0;
- offset.left -= parseFloat( jQuery.css(elem, "marginLeft") ) || 0;
- // Add offsetParent borders
- parentOffset.top += parseFloat( jQuery.css(offsetParent[0], "borderTopWidth") ) || 0;
- parentOffset.left += parseFloat( jQuery.css(offsetParent[0], "borderLeftWidth") ) || 0;
- // Subtract the two offsets
- return {
- top: offset.top - parentOffset.top,
- left: offset.left - parentOffset.left
- };
- },
- offsetParent: function() {
- return this.map(function() {
- var offsetParent = this.offsetParent || document.body;
- while ( offsetParent && (!rroot.test(offsetParent.nodeName) && jQuery.css(offsetParent, "position") === "static") ) {
- offsetParent = offsetParent.offsetParent;
- }
- return offsetParent;
- });
- }
- });
- // Create scrollLeft and scrollTop methods
- jQuery.each( ["Left", "Top"], function( i, name ) {
- var method = "scroll" + name;
- jQuery.fn[ method ] = function(val) {
- var elem = this[0], win;
- if ( !elem ) {
- return null;
- }
- if ( val !== undefined ) {
- // Set the scroll offset
- return this.each(function() {
- win = getWindow( this );
- if ( win ) {
- win.scrollTo(
- !i ? val : jQuery(win).scrollLeft(),
- i ? val : jQuery(win).scrollTop()
- );
- } else {
- this[ method ] = val;
- }
- });
- } else {
- win = getWindow( elem );
- // Return the scroll offset
- return win ? ("pageXOffset" in win) ? win[ i ? "pageYOffset" : "pageXOffset" ] :
- jQuery.support.boxModel && win.document.documentElement[ method ] ||
- win.document.body[ method ] :
- elem[ method ];
- }
- };
- });
- function getWindow( elem ) {
- return jQuery.isWindow( elem ) ?
- elem :
- elem.nodeType === 9 ?
- elem.defaultView || elem.parentWindow :
- false;
- }
- // Create innerHeight, innerWidth, outerHeight and outerWidth methods
- jQuery.each([ "Height", "Width" ], function( i, name ) {
- var type = name.toLowerCase();
- // innerHeight and innerWidth
- jQuery.fn["inner" + name] = function() {
- return this[0] ?
- parseFloat( jQuery.css( this[0], type, "padding" ) ) :
- null;
- };
- // outerHeight and outerWidth
- jQuery.fn["outer" + name] = function( margin ) {
- return this[0] ?
- parseFloat( jQuery.css( this[0], type, margin ? "margin" : "border" ) ) :
- null;
- };
- jQuery.fn[ type ] = function( size ) {
- // Get window width or height
- var elem = this[0];
- if ( !elem ) {
- return size == null ? null : this;
- }
- if ( jQuery.isFunction( size ) ) {
- return this.each(function( i ) {
- var self = jQuery( this );
- self[ type ]( size.call( this, i, self[ type ]() ) );
- });
- }
- if ( jQuery.isWindow( elem ) ) {
- // Everyone else use document.documentElement or document.body depending on Quirks vs Standards mode
- // 3rd condition allows Nokia support, as it supports the docElem prop but not CSS1Compat
- var docElemProp = elem.document.documentElement[ "client" + name ];
- return elem.document.compatMode === "CSS1Compat" && docElemProp ||
- elem.document.body[ "client" + name ] || docElemProp;
- // Get document width or height
- } else if ( elem.nodeType === 9 ) {
- // Either scroll[Width/Height] or offset[Width/Height], whichever is greater
- return Math.max(
- elem.documentElement["client" + name],
- elem.body["scroll" + name], elem.documentElement["scroll" + name],
- elem.body["offset" + name], elem.documentElement["offset" + name]
- );
- // Get or set width or height on the element
- } else if ( size === undefined ) {
- var orig = jQuery.css( elem, type ),
- ret = parseFloat( orig );
- return jQuery.isNaN( ret ) ? orig : ret;
- // Set the width or height on the element (default to pixels if value is unitless)
- } else {
- return this.css( type, typeof size === "string" ? size : size + "px" );
- }
- };
- });
- })(window);
- /*!
- * jQuery UI 1.8.5
- *
- * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
- * Dual licensed under the MIT or GPL Version 2 licenses.
- * http://jquery.org/license
- *
- * http://docs.jquery.com/UI
- */
- (function( $, undefined ) {
- // prevent duplicate loading
- // this is only a problem because we proxy existing functions
- // and we don't want to double proxy them
- $.ui = $.ui || {};
- if ( $.ui.version ) {
- return;
- }
- $.extend( $.ui, {
- version: "1.8.5",
- keyCode: {
- ALT: 18,
- BACKSPACE: 8,
- CAPS_LOCK: 20,
- COMMA: 188,
- COMMAND: 91,
- COMMAND_LEFT: 91, // COMMAND
- COMMAND_RIGHT: 93,
- CONTROL: 17,
- DELETE: 46,
- DOWN: 40,
- END: 35,
- ENTER: 13,
- ESCAPE: 27,
- HOME: 36,
- INSERT: 45,
- LEFT: 37,
- MENU: 93, // COMMAND_RIGHT
- NUMPAD_ADD: 107,
- NUMPAD_DECIMAL: 110,
- NUMPAD_DIVIDE: 111,
- NUMPAD_ENTER: 108,
- NUMPAD_MULTIPLY: 106,
- NUMPAD_SUBTRACT: 109,
- PAGE_DOWN: 34,
- PAGE_UP: 33,
- PERIOD: 190,
- RIGHT: 39,
- SHIFT: 16,
- SPACE: 32,
- TAB: 9,
- UP: 38,
- WINDOWS: 91 // COMMAND
- }
- });
- // plugins
- $.fn.extend({
- _focus: $.fn.focus,
- focus: function( delay, fn ) {
- return typeof delay === "number" ?
- this.each(function() {
- var elem = this;
- setTimeout(function() {
- $( elem ).focus();
- if ( fn ) {
- fn.call( elem );
- }
- }, delay );
- }) :
- this._focus.apply( this, arguments );
- },
- scrollParent: function() {
- var scrollParent;
- if (($.browser.msie && (/(static|relative)/).test(this.css('position'))) || (/absolute/).test(this.css('position'))) {
- scrollParent = this.parents().filter(function() {
- return (/(relative|absolute|fixed)/).test($.curCSS(this,'position',1)) && (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));
- }).eq(0);
- } else {
- scrollParent = this.parents().filter(function() {
- return (/(auto|scroll)/).test($.curCSS(this,'overflow',1)+$.curCSS(this,'overflow-y',1)+$.curCSS(this,'overflow-x',1));
- }).eq(0);
- }
- return (/fixed/).test(this.css('position')) || !scrollParent.length ? $(document) : scrollParent;
- },
- zIndex: function( zIndex ) {
- if ( zIndex !== undefined ) {
- return this.css( "zIndex", zIndex );
- }
- if ( this.length ) {
- var elem = $( this[ 0 ] ), position, value;
- while ( elem.length && elem[ 0 ] !== document ) {
- // Ignore z-index if position is set to a value where z-index is ignored by the browser
- // This makes behavior of this function consistent across browsers
- // WebKit always returns auto if the element is positioned
- position = elem.css( "position" );
- if ( position === "absolute" || position === "relative" || position === "fixed" ) {
- // IE returns 0 when zIndex is not specified
- // other browsers return a string
- // we ignore the case of nested elements with an explicit value of 0
- // <div style="z-index: -10;"><div style="z-index: 0;"></div></div>
- value = parseInt( elem.css( "zIndex" ) );
- if ( !isNaN( value ) && value != 0 ) {
- return value;
- }
- }
- elem = elem.parent();
- }
- }
- return 0;
- },
-
- disableSelection: function() {
- return this.bind(
- "mousedown.ui-disableSelection selectstart.ui-disableSelection",
- function( event ) {
- event.preventDefault();
- });
- },
- enableSelection: function() {
- return this.unbind( ".ui-disableSelection" );
- }
- });
- $.each( [ "Width", "Height" ], function( i, name ) {
- var side = name === "Width" ? [ "Left", "Right" ] : [ "Top", "Bottom" ],
- type = name.toLowerCase(),
- orig = {
- innerWidth: $.fn.innerWidth,
- innerHeight: $.fn.innerHeight,
- outerWidth: $.fn.outerWidth,
- outerHeight: $.fn.outerHeight
- };
- function reduce( elem, size, border, margin ) {
- $.each( side, function() {
- size -= parseFloat( $.curCSS( elem, "padding" + this, true) ) || 0;
- if ( border ) {
- size -= parseFloat( $.curCSS( elem, "border" + this + "Width", true) ) || 0;
- }
- if ( margin ) {
- size -= parseFloat( $.curCSS( elem, "margin" + this, true) ) || 0;
- }
- });
- return size;
- }
- $.fn[ "inner" + name ] = function( size ) {
- if ( size === undefined ) {
- return orig[ "inner" + name ].call( this );
- }
- return this.each(function() {
- $.style( this, type, reduce( this, size ) + "px" );
- });
- };
- $.fn[ "outer" + name] = function( size, margin ) {
- if ( typeof size !== "number" ) {
- return orig[ "outer" + name ].call( this, size );
- }
- return this.each(function() {
- $.style( this, type, reduce( this, size, true, margin ) + "px" );
- });
- };
- });
- // selectors
- function visible( element ) {
- return !$( element ).parents().andSelf().filter(function() {
- return $.curCSS( this, "visibility" ) === "hidden" ||
- $.expr.filters.hidden( this );
- }).length;
- }
- $.extend( $.expr[ ":" ], {
- data: function( elem, i, match ) {
- return !!$.data( elem, match[ 3 ] );
- },
- focusable: function( element ) {
- var nodeName = element.nodeName.toLowerCase(),
- tabIndex = $.attr( element, "tabindex" );
- if ( "area" === nodeName ) {
- var map = element.parentNode,
- mapName = map.name,
- img;
- if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
- return false;
- }
- img = $( "img[usemap=#" + mapName + "]" )[0];
- return !!img && visible( img );
- }
- return ( /input|select|textarea|button|object/.test( nodeName )
- ? !element.disabled
- : "a" == nodeName
- ? element.href || !isNaN( tabIndex )
- : !isNaN( tabIndex ))
- // the element and all of its ancestors must be visible
- && visible( element );
- },
- tabbable: function( element ) {
- var tabIndex = $.attr( element, "tabindex" );
- return ( isNaN( tabIndex ) || tabIndex >= 0 ) && $( element ).is( ":focusable" );
- }
- });
- // support
- $(function() {
- var div = document.createElement( "div" ),
- body = document.body;
- $.extend( div.style, {
- minHeight: "100px",
- height: "auto",
- padding: 0,
- borderWidth: 0
- });
- $.support.minHeight = body.appendChild( div ).offsetHeight === 100;
- // set display to none to avoid a layout bug in IE
- // http://dev.jquery.com/ticket/4014
- body.removeChild( div ).style.display = "none";
- });
- // deprecated
- $.extend( $.ui, {
- // $.ui.plugin is deprecated. Use the proxy pattern instead.
- plugin: {
- add: function( module, option, set ) {
- var proto = $.ui[ module ].prototype;
- for ( var i in set ) {
- proto.plugins[ i ] = proto.plugins[ i ] || [];
- proto.plugins[ i ].push( [ option, set[ i ] ] );
- }
- },
- call: function( instance, name, args ) {
- var set = instance.plugins[ name ];
- if ( !set || !instance.element[ 0 ].parentNode ) {
- return;
- }
-
- for ( var i = 0; i < set.length; i++ ) {
- if ( instance.options[ set[ i ][ 0 ] ] ) {
- set[ i ][ 1 ].apply( instance.element, args );
- }
- }
- }
- },
-
- // will be deprecated when we switch to jQuery 1.4 - use jQuery.contains()
- contains: function( a, b ) {
- return document.compareDocumentPosition ?
- a.compareDocumentPosition( b ) & 16 :
- a !== b && a.contains( b );
- },
-
- // only used by resizable
- hasScroll: function( el, a ) {
-
- //If overflow is hidden, the element might have extra content, but the user wants to hide it
- if ( $( el ).css( "overflow" ) === "hidden") {
- return false;
- }
-
- var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
- has = false;
-
- if ( el[ scroll ] > 0 ) {
- return true;
- }
-
- // TODO: determine which cases actually cause this to happen
- // if the element doesn't have the scroll set, see if it's possible to
- // set the scroll
- el[ scroll ] = 1;
- has = ( el[ scroll ] > 0 );
- el[ scroll ] = 0;
- return has;
- },
-
- // these are odd functions, fix the API or move into individual plugins
- isOverAxis: function( x, reference, size ) {
- //Determines when x coordinate is over "b" element axis
- return ( x > reference ) && ( x < ( reference + size ) );
- },
- isOver: function( y, x, top, left, height, width ) {
- //Determines when x, y coordinates is over "b" element
- return $.ui.isOverAxis( y, top, height ) && $.ui.isOverAxis( x, left, width );
- }
- });
- })( jQuery );
- /*!
- * jQuery UI Widget 1.8.5
- *
- * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about)
- * Dual licensed under the MIT or GPL Version 2 licenses.
- * http://jquery.org/license
- *
- * http://docs.jquery.com/UI/Widget
- */
- (function( $, undefined ) {
- // jQuery 1.4+
- if ( $.cleanData ) {
- var _cleanData = $.cleanData;
- $.cleanData = function( elems ) {
- for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
- $( elem ).triggerHandler( "remove" );
- }
- _cleanData( elems );
- };
- } else {
- var _remove = $.fn.remove;
- $.fn.remove = function( selector, keepData ) {
- return this.each(function() {
- if ( !keepData ) {
- if ( !selector || $.filter( selector, [ this ] ).length ) {
- $( "*", this ).add( [ this ] ).each(function() {
- $( this ).triggerHandler( "remove" );
- });
- }
- }
- return _remove.call( $(this), selector, keepData );
- });
- };
- }
- $.widget = function( name, base, prototype ) {
- var namespace = name.split( "." )[ 0 ],
- fullName;
- name = name.split( "." )[ 1 ];
- fullName = namespace + "-" + name;
- if ( !prototype ) {
- prototype = base;
- base = $.Widget;
- }
- // create selector for plugin
- $.expr[ ":" ][ fullName ] = function( elem ) {
- return !!$.data( elem, name );
- };
- $[ namespace ] = $[ namespace ] || {};
- $[ namespace ][ name ] = function( options, element ) {
- // allow instantiation without initializing for simple inheritance
- if ( arguments.length ) {
- this._createWidget( options, element );
- }
- };
- var basePrototype = new base();
- // we need to make the options hash a property directly on the new instance
- // otherwise we'll modify the options hash on the prototype that we're
- // inheriting from
- // $.each( basePrototype, function( key, val ) {
- // if ( $.isPlainObject(val) ) {
- // basePrototype[ key ] = $.extend( {}, val );
- // }
- // });
- basePrototype.options = $.extend( true, {}, basePrototype.options );
- $[ namespace ][ name ].prototype = $.extend( true, basePrototype, {
- namespace: namespace,
- widgetName: name,
- widgetEventPrefix: $[ namespace ][ name ].prototype.widgetEventPrefix || name,
- widgetBaseClass: fullName
- }, prototype );
- $.widget.bridge( name, $[ namespace ][ name ] );
- };
- $.widget.bridge = function( name, object ) {
- $.fn[ name ] = function( options ) {
- var isMethodCall = typeof options === "string",
- args = Array.prototype.slice.call( arguments, 1 ),
- returnValue = this;
- // allow multiple hashes to be passed on init
- options = !isMethodCall && args.length ?
- $.extend.apply( null, [ true, options ].concat(args) ) :
- options;
- // prevent calls to internal methods
- if ( isMethodCall && options.substring( 0, 1 ) === "_" ) {
- return returnValue;
- }
- if ( isMethodCall ) {
- this.each(function() {
- var instance = $.data( this, name );
- if ( !instance ) {
- throw "cannot call methods on " + name + " prior to initialization; " +
- "attempted to call method '" + options + "'";
- }
- if ( !$.isFunction( instance[options] ) ) {
- throw "no such method '" + options + "' for " + name + " widget instance";
- }
- var methodValue = instance[ options ].apply( instance, args );
- if ( methodValue !== instance && methodValue !== undefined ) {
- returnValue = methodValue;
- return false;
- }
- });
- } else {
- this.each(function() {
- var instance = $.data( this, name );
- if ( instance ) {
- instance.option( options || {} )._init();
- } else {
- $.data( this, name, new object( options, this ) );
- }
- });
- }
- return returnValue;
- };
- };
- $.Widget = function( options, element ) {
- // allow instantiation without initializing for simple inheritance
- if ( arguments.length ) {
- this._createWidget( options, element );
- }
- };
- $.Widget.prototype = {
- widgetName: "widget",
- widgetEventPrefix: "",
- options: {
- disabled: false
- },
- _createWidget: function( options, element ) {
- // $.widget.bridge stores the plugin instance, but we do it anyway
- // so that it's stored even before the _create function runs
- $.data( element, this.widgetName, this );
- this.element = $( element );
- this.options = $.extend( true, {},
- this.options,
- $.metadata && $.metadata.get( element )[ this.widgetName ],
- options );
- var self = this;
- this.element.bind( "remove." + this.widgetName, function() {
- self.destroy();
- });
- this._create();
- this._init();
- },
- _create: function() {},
- _init: function() {},
- destroy: function() {
- this.element
- .unbind( "." + this.widgetName )
- .removeData( this.widgetName );
- this.widget()
- .unbind( "." + this.widgetName )
- .removeAttr( "aria-disabled" )
- .removeClass(
- this.widgetBaseClass + "-disabled " +
- "ui-state-disabled" );
- },
- widget: function() {
- return this.element;
- },
- option: function( key, value ) {
- var options = key,
- self = this;
- if ( arguments.length === 0 ) {
- // don't return a reference to the internal hash
- return $.extend( {}, self.options );
- }
- if (typeof key === "string" ) {
- if ( value === undefined ) {
- return this.options[ key ];
- }
- options = {};
- options[ key ] = value;
- }
- $.each( options, function( key, value ) {
- self._setOption( key, value );
- });
- return self;
- },
- _setOption: function( key, value ) {
- this.options[ key ] = value;
- if ( key === "disabled" ) {
- this.widget()
- [ value ? "addClass" : "removeClass"](
- this.widgetBaseClass + "-disabled" + " " +
- "ui-state-disabled" )
- .attr( "aria-disabled", value );
- }
- return this;
- },
- enable: function() {
- return this._setOption( "disabled", false );
- },
- disable: function() {
- return this._setOption( "disabled", true );
- },
- _trigger: function( type, event, data ) {
- var callback = this.options[ type ];
- event = $.Event( event );
- event.type = ( type === this.widgetEventPrefix ?
- type :
- this.widgetEventPrefix + type ).toLowerCase();
- data = data || {};
- // copy original event properties over to the new event
- // this would happen if we could call $.event.fix instead of $.Event
- // but we don't have a way to force an event to be fixed multiple times
- if ( event.originalEvent ) {
- for ( var i = $.event.props.length, prop; i; ) {
- prop = $.event.props[ --i ];
- event[ prop ] = event.originalEvent[ prop ];
- }
- }
- this.element.trigger( event, data );
- return !( $.isFunction(callback) &&
- callback.call( this.element[0], event, data ) === false ||
- event.isDefaultPrevented() );
- }
- };
- })( jQuery );
- /*!
- * jQuery Cookie Plugin v1.4.0
- * https://github.com/carhartl/jquery-cookie
- *
- * Copyright 2013 Klaus Hartl
- * Released under the MIT license
- */
- (function(factory) {
- if (typeof define === 'function' && define.amd) {
- // AMD. Register as anonymous module.
- define([ 'jquery' ], factory);
- } else {
- // Browser globals.
- factory(jQuery);
- }
- }(function($) {
- var pluses = /\+/g;
- function encode(s) {
- return config.raw ? s : encodeURIComponent(s);
- }
- function decode(s) {
- return config.raw ? s : decodeURIComponent(s);
- }
- function stringifyCookieValue(value) {
- return encode(config.json ? JSON.stringify(value) : String(value));
- }
- function parseCookieValue(s) {
- if (s.indexOf('"') === 0) {
- // This is a quoted cookie as according to RFC2068, unescape...
- s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
- }
- try {
- // Replace server-side written pluses with spaces.
- // If we can't decode the cookie, ignore it, it's unusable.
- s = decodeURIComponent(s.replace(pluses, ' '));
- } catch (e) {
- return;
- }
- try {
- // If we can't parse the cookie, ignore it, it's unusable.
- return config.json ? JSON.parse(s) : s;
- } catch (e) {
- }
- }
- function read(s, converter) {
- var value = config.raw ? s : parseCookieValue(s);
- return $.isFunction(converter) ? converter(value) : value;
- }
- var config = $.cookie = function(key, value, options) {
- // Write
- if (value !== undefined && !$.isFunction(value)) {
- options = $.extend({}, config.defaults, options);
- if (typeof options.expires === 'number') {
- var days = options.expires, t = options.expires = new Date();
- t.setDate(t.getDate() + days);
- }
- return (document.cookie = [
- encode(key),
- '=',
- stringifyCookieValue(value),
- options.expires ? '; expires='
- + options.expires.toUTCString() : '', // use
- // expires
- // attribute,
- // max-age
- // is not
- // supported
- // by IE
- options.path ? '; path=' + options.path : '',
- options.domain ? '; domain=' + options.domain : '',
- options.secure ? '; secure' : '' ].join(''));
- }
- // Read
- var result = key ? undefined : {};
- // To prevent the for loop in the first place assign an empty array
- // in case there are no cookies at all. Also prevents odd result when
- // calling $.cookie().
- var cookies = document.cookie ? document.cookie.split('; ') : [];
- for ( var i = 0, l = cookies.length; i < l; i++) {
- var parts = cookies[i].split('=');
- var name = decode(parts.shift());
- var cookie = parts.join('=');
- if (key && key === name) {
- // If second argument (value) is a function it's a converter...
- result = read(cookie, value);
- break;
- }
- // Prevent storing a cookie that we couldn't decode.
- if (!key && (cookie = read(cookie)) !== undefined) {
- result[name] = cookie;
- }
- }
- return result;
- };
- config.defaults = {};
- $.removeCookie = function(key, options) {
- if ($.cookie(key) !== undefined) {
- // Must not alter options, thus extending a fresh object...
- $.cookie(key, '', $.extend({}, options, {
- expires : -1
- }));
- return true;
- }
- return false;
- };
- }));
- // @preserve jQuery.floatThead 1.4.0 - http://mkoryak.github.io/floatThead/ - Copyright (c) 2012 - 2016 Misha Koryak
- // @license MIT
- /* @author Misha Koryak
- * @projectDescription lock a table header in place while scrolling - without breaking styles or events bound to the header
- *
- * Dependencies:
- * jquery 1.9.0 + [required] OR jquery 1.7.0 + jquery UI core
- *
- * http://mkoryak.github.io/floatThead/
- *
- * Tested on FF13+, Chrome 21+, IE8, IE9, IE10, IE11
- *
- */
- (function( $ ) {
- /**
- * provides a default config object. You can modify this after including this script if you want to change the init defaults
- * @type {Object}
- */
- $.floatThead = $.floatThead || {};
- $.floatThead.defaults = {
- headerCellSelector: 'tr:visible:first>*:visible', //thead cells are this.
- zIndex: 1001, //zindex of the floating thead (actually a container div)
- position: 'auto', // 'fixed', 'absolute', 'auto'. auto picks the best for your table scrolling type.
- top: 0, //String or function($table) - offset from top of window where the header should not pass above
- bottom: 0, //String or function($table) - offset from the bottom of the table where the header should stop scrolling
- scrollContainer: function($table) { // or boolean 'true' (use offsetParent) | function -> if the table has horizontal scroll bars then this is the container that has overflow:auto and causes those scroll bars
- return $([]);
- },
- responsiveContainer: function($table) { // only valid if scrollContainer is not used (ie window scrolling). this is the container which will control y scrolling at some mobile breakpoints
- return $([]);
- },
- getSizingRow: function($table, $cols, $fthCells){ // this is only called when using IE,
- // override it if the first row of the table is going to contain colgroups (any cell spans greater than one col)
- // it should return a jquery object containing a wrapped set of table cells comprising a row that contains no col spans and is visible
- return $table.find('tbody tr:visible:first>*:visible');
- },
- floatTableClass: 'floatThead-table',
- floatWrapperClass: 'floatThead-wrapper',
- floatContainerClass: 'floatThead-container',
- copyTableClass: true, //copy 'class' attribute from table into the floated table so that the styles match.
- enableAria: false, //will copy header text from the floated header back into the table for screen readers. Might cause the css styling to be off. beware!
- autoReflow: false, //(undocumented) - use MutationObserver api to reflow automatically when internal table DOM changes
- debug: false //print possible issues (that don't prevent script loading) to console, if console exists.
- };
- var util = window._;
- var canObserveMutations = typeof MutationObserver !== 'undefined';
- //browser stuff
- var ieVersion = function(){for(var a=3,b=document.createElement("b"),c=b.all||[];a = 1+a,b.innerHTML="<!--[if gt IE "+ a +"]><i><![endif]-->",c[0];);return 4<a?a:document.documentMode}();
- var isFF = /Gecko\//.test(navigator.userAgent);
- var isWebkit = /WebKit\//.test(navigator.userAgent);
- if(!(ieVersion || isFF || isWebkit)){
- ieVersion = 11; //yey a hack!
- }
- //safari 7 (and perhaps others) reports table width to be parent container's width if max-width is set on table. see: https://github.com/mkoryak/floatThead/issues/108
- var isTableWidthBug = function(){
- if(isWebkit) {
- var $test = $('<div style="width:0px"><table style="max-width:100%"><tr><th><div style="min-width:100px;">X</div></th></tr></table></div>');
- $("body").append($test);
- var ret = ($test.find("table").width() == 0);
- $test.remove();
- return ret;
- }
- return false;
- };
- var createElements = !isFF && !ieVersion; //FF can read width from <col> elements, but webkit cannot
- var $window = $(window);
- if(!window.matchMedia) {
- //these will be used by the plugin to go into print mode (destroy and remake itself)
- var _beforePrint = window.onbeforeprint;
- var _afterPrint = window.onafterprint;
- window.onbeforeprint = function () {
- _beforePrint && _beforePrint();
- $window.triggerHandler("beforeprint");
- };
- window.onafterprint = function () {
- _afterPrint && _afterPrint();
- $window.triggerHandler("afterprint");
- };
- }
- /**
- * @param debounceMs
- * @param cb
- */
- function windowResize(eventName, cb){
- if(ieVersion == 8){ //ie8 is crap: https://github.com/mkoryak/floatThead/issues/65
- var winWidth = $window.width();
- var debouncedCb = util.debounce(function(){
- var winWidthNew = $window.width();
- if(winWidth != winWidthNew){
- winWidth = winWidthNew;
- cb();
- }
- }, 1);
- $window.bind(eventName, debouncedCb);
- } else {
- $window.bind(eventName, util.debounce(cb, 1));
- }
- }
- function getTrueOffsetParent($elem) {
- var elem = $elem[0];
- var parent = elem.offsetParent;
- if (!parent) {
- parent = elem.parentElement;
- do {
- var pos = window
- .getComputedStyle(parent)
- .getPropertyValue('position');
- if (pos != 'static') break;
- if (parent.offsetParent) {
- parent = parent.offsetParent;
- break;
- }
- } while (parent = parent.parentElement)
- }
- if(parent == document.body){
- return $([]);
- }
- return $(parent);
- }
- function debug(str){
- window && window.console && window.console.error && window.console.error("jQuery.floatThead: " + str);
- }
- //returns fractional pixel widths
- function getOffsetWidth(el) {
- var rect = el.getBoundingClientRect();
- return rect.width || rect.right - rect.left;
- }
- /**
- * try to calculate the scrollbar width for your browser/os
- * @return {Number}
- */
- function scrollbarWidth() {
- var $div = $( //borrowed from anti-scroll
- '<div style="width:50px;height:50px;overflow-y:scroll;'
- + 'position:absolute;top:-200px;left:-200px;"><div style="height:100px;width:100%">'
- + '</div>'
- );
- $('body').append($div);
- var w1 = $div.innerWidth();
- var w2 = $('div', $div).innerWidth();
- $div.remove();
- return w1 - w2;
- }
- /**
- * Check if a given table has been datatableized (http://datatables.net)
- * @param $table
- * @return {Boolean}
- */
- function isDatatable($table){
- if($table.dataTableSettings){
- for(var i = 0; i < $table.dataTableSettings.length; i++){
- var table = $table.dataTableSettings[i].nTable;
- if($table[0] == table){
- return true;
- }
- }
- }
- return false;
- }
- function tableWidth($table, $fthCells, isOuter){
- // see: https://github.com/mkoryak/floatThead/issues/108
- var fn = isOuter ? "outerWidth": "width";
- if(isTableWidthBug && $table.css("max-width")){
- var w = 0;
- if(isOuter) {
- w += parseInt($table.css("borderLeft"), 10);
- w += parseInt($table.css("borderRight"), 10);
- }
- for(var i=0; i < $fthCells.length; i++){
- w += $fthCells.get(i).offsetWidth;
- }
- return w;
- } else {
- return $table[fn]();
- }
- }
- $.fn.floatThead = function(map){
- map = map || {};
- if(!util){ //may have been included after the script? lets try to grab it again.
- util = window._ || $.floatThead._;
- if(!util){
- throw new Error("jquery.floatThead-slim.js requires underscore. You should use the non-lite version since you do not have underscore.");
- }
- }
- if(ieVersion < 8){
- return this; //no more crappy browser support.
- }
- var mObs = null; //mutation observer lives in here if we can use it / make it
- if(util.isFunction(isTableWidthBug)) {
- isTableWidthBug = isTableWidthBug();
- }
- if(util.isString(map)){
- var command = map;
- var ret = this;
- this.filter('table').each(function(){
- var $this = $(this);
- var opts = $this.data('floatThead-lazy');
- if(opts){
- $this.floatThead(opts);
- }
- var obj = $this.data('floatThead-attached');
- if(obj && util.isFunction(obj[command])){
- var r = obj[command]();
- if(typeof r !== 'undefined'){
- ret = r;
- }
- }
- });
- return ret;
- }
- var opts = $.extend({}, $.floatThead.defaults || {}, map);
- $.each(map, function(key, val){
- if((!(key in $.floatThead.defaults)) && opts.debug){
- debug("Used ["+key+"] key to init plugin, but that param is not an option for the plugin. Valid options are: "+ (util.keys($.floatThead.defaults)).join(', '));
- }
- });
- if(opts.debug){
- var v = $.fn.jquery.split(".");
- if(parseInt(v[0], 10) == 1 && parseInt(v[1], 10) <= 7){
- debug("jQuery version "+$.fn.jquery+" detected! This plugin supports 1.8 or better, or 1.7.x with jQuery UI 1.8.24 -> http://jqueryui.com/resources/download/jquery-ui-1.8.24.zip")
- }
- }
- this.filter(':not(.'+opts.floatTableClass+')').each(function(){
- var floatTheadId = util.uniqueId();
- var $table = $(this);
- if($table.data('floatThead-attached')){
- return true; //continue the each loop
- }
- if(!$table.is('table')){
- throw new Error('jQuery.floatThead must be run on a table element. ex: $("table").floatThead();');
- }
- canObserveMutations = opts.autoReflow && canObserveMutations; //option defaults to false!
- var $header = $table.children('thead:first');
- var $tbody = $table.children('tbody:first');
- if($header.length == 0 || $tbody.length == 0){
- $table.data('floatThead-lazy', opts);
- $table.unbind("reflow").one('reflow', function(){
- $table.floatThead(opts);
- });
- return;
- }
- if($table.data('floatThead-lazy')){
- $table.unbind("reflow");
- }
- $table.data('floatThead-lazy', false);
- var headerFloated = true;
- var scrollingTop, scrollingBottom;
- var scrollbarOffset = {vertical: 0, horizontal: 0};
- var scWidth = scrollbarWidth();
- var lastColumnCount = 0; //used by columnNum()
- if(opts.scrollContainer === true){
- opts.scrollContainer = getTrueOffsetParent;
- }
- var $scrollContainer = opts.scrollContainer($table) || $([]); //guard against returned nulls
- var locked = $scrollContainer.length > 0;
- var $responsiveContainer = locked ? $([]) : opts.responsiveContainer($table) || $([]);
- var responsive = isResponsiveContainerActive();
- var useAbsolutePositioning = null;
- if(typeof opts.useAbsolutePositioning !== 'undefined'){
- opts.position = 'auto';
- if(opts.useAbsolutePositioning){
- opts.position = opts.useAbsolutePositioning ? 'absolute' : 'fixed';
- }
- debug("option 'useAbsolutePositioning' has been removed in v1.3.0, use `position:'"+opts.position+"'` instead. See docs for more info: http://mkoryak.github.io/floatThead/#options")
- }
- if(typeof opts.scrollingTop !== 'undefined'){
- opts.top = opts.scrollingTop;
- debug("option 'scrollingTop' has been renamed to 'top' in v1.3.0. See docs for more info: http://mkoryak.github.io/floatThead/#options");
- }
- if(typeof opts.scrollingBottom !== 'undefined'){
- opts.bottom = opts.scrollingBottom;
- debug("option 'scrollingBottom' has been renamed to 'bottom' in v1.3.0. See docs for more info: http://mkoryak.github.io/floatThead/#options");
- }
- if (opts.position == 'auto') {
- useAbsolutePositioning = null;
- } else if (opts.position == 'fixed') {
- useAbsolutePositioning = false;
- } else if (opts.position == 'absolute'){
- useAbsolutePositioning = true;
- } else if (opts.debug) {
- debug('Invalid value given to "position" option, valid is "fixed", "absolute" and "auto". You passed: ', opts.position);
- }
- if(useAbsolutePositioning == null){ //defaults: locked=true, !locked=false
- useAbsolutePositioning = locked;
- }
- var $caption = $table.find("caption");
- var haveCaption = $caption.length == 1;
- if(haveCaption){
- var captionAlignTop = ($caption.css("caption-side") || $caption.attr("align") || "top") === "top";
- }
- var $fthGrp = $('<fthfoot style="display:table-footer-group;border-spacing:0;height:0;border-collapse:collapse;visibility:hidden"/>');
- var wrappedContainer = false; //used with absolute positioning enabled. did we need to wrap the scrollContainer/table with a relative div?
- var $wrapper = $([]); //used when absolute positioning enabled - wraps the table and the float container
- var absoluteToFixedOnScroll = ieVersion <= 9 && !locked && useAbsolutePositioning; //on IE using absolute positioning doesn't look good with window scrolling, so we change position to fixed on scroll, and then change it back to absolute when done.
- var $floatTable = $("<table/>");
- var $floatColGroup = $("<colgroup/>");
- var $tableColGroup = $table.children('colgroup:first');
- var existingColGroup = true;
- if($tableColGroup.length == 0){
- $tableColGroup = $("<colgroup/>");
- existingColGroup = false;
- }
- var $fthRow = $('<fthtr style="display:table-row;border-spacing:0;height:0;border-collapse:collapse"/>'); //created unstyled elements (used for sizing the table because chrome can't read <col> width)
- var $floatContainer = $('<div style="overflow: hidden;" aria-hidden="true"></div>');
- var floatTableHidden = false; //this happens when the table is hidden and we do magic when making it visible
- var $newHeader = $("<thead/>");
- var $sizerRow = $('<tr class="size-row"/>');
- var $sizerCells = $([]);
- var $tableCells = $([]); //used for sizing - either $sizerCells or $tableColGroup cols. $tableColGroup cols are only created in chrome for borderCollapse:collapse because of a chrome bug.
- var $headerCells = $([]);
- var $fthCells = $([]); //created elements
- $newHeader.append($sizerRow);
- $table.prepend($tableColGroup);
- if(createElements){
- $fthGrp.append($fthRow);
- $table.append($fthGrp);
- }
- $floatTable.append($floatColGroup);
- $floatContainer.append($floatTable);
- if(opts.copyTableClass){
- $floatTable.attr('class', $table.attr('class'));
- }
- $floatTable.attr({ //copy over some deprecated table attributes that people still like to use. Good thing people don't use colgroups...
- 'cellpadding': $table.attr('cellpadding'),
- 'cellspacing': $table.attr('cellspacing'),
- 'border': $table.attr('border')
- });
- var tableDisplayCss = $table.css('display');
- $floatTable.css({
- 'borderCollapse': $table.css('borderCollapse'),
- 'border': $table.css('border'),
- 'display': tableDisplayCss
- });
- if(tableDisplayCss == 'none'){
- floatTableHidden = true;
- }
- $floatTable.addClass(opts.floatTableClass).css({'margin': 0, 'border-bottom-width': 0}); //must have no margins or you won't be able to click on things under floating table
- if(useAbsolutePositioning){
- var makeRelative = function($container, alwaysWrap){
- var positionCss = $container.css('position');
- var relativeToScrollContainer = (positionCss == "relative" || positionCss == "absolute");
- var $containerWrap = $container;
- if(!relativeToScrollContainer || alwaysWrap){
- var css = {"paddingLeft": $container.css('paddingLeft'), "paddingRight": $container.css('paddingRight')};
- $floatContainer.css(css);
- $containerWrap = $container.data('floatThead-containerWrap') || $container.wrap("<div class='"+opts.floatWrapperClass+"' style='position: relative; clear:both;'></div>").parent();
- $container.data('floatThead-containerWrap', $containerWrap); //multiple tables inside one scrolling container - #242
- wrappedContainer = true;
- }
- return $containerWrap;
- };
- if(locked){
- $wrapper = makeRelative($scrollContainer, true);
- $wrapper.prepend($floatContainer);
- } else {
- $wrapper = makeRelative($table);
- $table.before($floatContainer);
- }
- } else {
- $table.before($floatContainer);
- }
- $floatContainer.css({
- position: useAbsolutePositioning ? 'absolute' : 'fixed',
- marginTop: 0,
- top: useAbsolutePositioning ? 0 : 'auto',
- zIndex: opts.zIndex
- });
- $floatContainer.addClass(opts.floatContainerClass);
- updateScrollingOffsets();
- var layoutFixed = {'table-layout': 'fixed'};
- var layoutAuto = {'table-layout': $table.css('tableLayout') || 'auto'};
- var originalTableWidth = $table[0].style.width || ""; //setting this to auto is bad: #70
- var originalTableMinWidth = $table.css('minWidth') || "";
- function eventName(name){
- return name+'.fth-'+floatTheadId+'.floatTHead'
- }
- function setHeaderHeight(){
- var headerHeight = 0;
- $header.children("tr:visible").each(function(){
- headerHeight += $(this).outerHeight(true);
- });
- if($table.css('border-collapse') == 'collapse') {
- var tableBorderTopHeight = parseInt($table.css('border-top-width'), 10);
- var cellBorderTopHeight = parseInt($table.find("thead tr:first").find(">*:first").css('border-top-width'), 10);
- if(tableBorderTopHeight > cellBorderTopHeight) {
- headerHeight -= (tableBorderTopHeight / 2); //id love to see some docs where this magic recipe is found..
- }
- }
- $sizerRow.outerHeight(headerHeight);
- $sizerCells.outerHeight(headerHeight);
- }
- function setFloatWidth(){
- var tw = tableWidth($table, $fthCells, true);
- var $container = responsive ? $responsiveContainer : $scrollContainer;
- var width = $container.width() || tw;
- var floatContainerWidth = $container.css("overflow-y") != 'hidden' ? width - scrollbarOffset.vertical : width;
- $floatContainer.width(floatContainerWidth);
- if(locked){
- var percent = 100 * tw / (floatContainerWidth);
- $floatTable.css('width', percent+'%');
- } else {
- $floatTable.outerWidth(tw);
- }
- }
- function updateScrollingOffsets(){
- scrollingTop = (util.isFunction(opts.top) ? opts.top($table) : opts.top) || 0;
- scrollingBottom = (util.isFunction(opts.bottom) ? opts.bottom($table) : opts.bottom) || 0;
- }
- /**
- * get the number of columns and also rebuild resizer rows if the count is different than the last count
- */
- function columnNum(){
- var count;
- var $headerColumns = $header.find(opts.headerCellSelector);
- if(existingColGroup){
- count = $tableColGroup.find('col').length;
- } else {
- count = 0;
- $headerColumns.each(function () {
- count += parseInt(($(this).attr('colspan') || 1), 10);
- });
- }
- if(count != lastColumnCount){
- lastColumnCount = count;
- var cells = [], cols = [], psuedo = [], content;
- for(var x = 0; x < count; x++){
- if (opts.enableAria && (content = $headerColumns.eq(x).text()) ) {
- cells.push('<th scope="col" class="floatThead-col">' + content + '</th>');
- } else {
- cells.push('<th class="floatThead-col"/>');
- }
- cols.push('<col/>');
- psuedo.push("<fthtd style='display:table-cell;height:0;width:auto;'/>");
- }
- cols = cols.join('');
- cells = cells.join('');
- if(createElements){
- psuedo = psuedo.join('');
- $fthRow.html(psuedo);
- $fthCells = $fthRow.find('fthtd');
- }
- $sizerRow.html(cells);
- $sizerCells = $sizerRow.find("th");
- if(!existingColGroup){
- $tableColGroup.html(cols);
- }
- $tableCells = $tableColGroup.find('col');
- $floatColGroup.html(cols);
- $headerCells = $floatColGroup.find("col");
- }
- return count;
- }
- function refloat(){ //make the thing float
- if(!headerFloated){
- headerFloated = true;
- if(useAbsolutePositioning){ //#53, #56
- var tw = tableWidth($table, $fthCells, true);
- var wrapperWidth = $wrapper.width();
- if(tw > wrapperWidth){
- $table.css('minWidth', tw);
- }
- }
- $table.css(layoutFixed);
- $floatTable.css(layoutFixed);
- $floatTable.append($header); //append because colgroup must go first in chrome
- $tbody.before($newHeader);
- setHeaderHeight();
- }
- }
- function unfloat(){ //put the header back into the table
- if(headerFloated){
- headerFloated = false;
- if(useAbsolutePositioning){ //#53, #56
- $table.width(originalTableWidth);
- }
- $newHeader.detach();
- $table.prepend($header);
- $table.css(layoutAuto);
- $floatTable.css(layoutAuto);
- $table.css('minWidth', originalTableMinWidth); //this looks weird, but it's not a bug. Think about it!!
- $table.css('minWidth', tableWidth($table, $fthCells)); //#121
- }
- }
- var isHeaderFloatingLogical = false; //for the purpose of this event, the header is/isnt floating, even though the element
- //might be in some other state. this is what the header looks like to the user
- function triggerFloatEvent(isFloating){
- if(isHeaderFloatingLogical != isFloating){
- isHeaderFloatingLogical = isFloating;
- $table.triggerHandler("floatThead", [isFloating, $floatContainer])
- }
- }
- function changePositioning(isAbsolute){
- if(useAbsolutePositioning != isAbsolute){
- useAbsolutePositioning = isAbsolute;
- $floatContainer.css({
- position: useAbsolutePositioning ? 'absolute' : 'fixed'
- });
- }
- }
- function getSizingRow($table, $cols, $fthCells, ieVersion){
- if(createElements){
- return $fthCells;
- } else if(ieVersion) {
- return opts.getSizingRow($table, $cols, $fthCells);
- } else {
- return $cols;
- }
- }
- /**
- * returns a function that updates the floating header's cell widths.
- * @return {Function}
- */
- function reflow(){
- var i;
- var numCols = columnNum(); //if the tables columns changed dynamically since last time (datatables), rebuild the sizer rows and get a new count
- return function(){
- $tableCells = $tableColGroup.find('col');
- var $rowCells = getSizingRow($table, $tableCells, $fthCells, ieVersion);
- if($rowCells.length == numCols && numCols > 0){
- if(!existingColGroup){
- for(i=0; i < numCols; i++){
- $tableCells.eq(i).css('width', '');
- }
- }
- unfloat();
- var widths = [];
- for(i=0; i < numCols; i++){
- widths[i] = getOffsetWidth($rowCells.get(i));
- }
- for(i=0; i < numCols; i++){
- $headerCells.eq(i).width(widths[i]);
- $tableCells.eq(i).width(widths[i]);
- }
- refloat();
- } else {
- $floatTable.append($header);
- $table.css(layoutAuto);
- $floatTable.css(layoutAuto);
- setHeaderHeight();
- }
- $table.triggerHandler("reflowed", [$floatContainer]);
- };
- }
- function floatContainerBorderWidth(side){
- var border = $scrollContainer.css("border-"+side+"-width");
- var w = 0;
- if (border && ~border.indexOf('px')) {
- w = parseInt(border, 10);
- }
- return w;
- }
- function isResponsiveContainerActive(){
- return $responsiveContainer.css("overflow-x") == 'auto';
- }
- /**
- * first performs initial calculations that we expect to not change when the table, window, or scrolling container are scrolled.
- * returns a function that calculates the floating container's top and left coords. takes into account if we are using page scrolling or inner scrolling
- * @return {Function}
- */
- function calculateFloatContainerPosFn(){
- var scrollingContainerTop = $scrollContainer.scrollTop();
- //this floatEnd calc was moved out of the returned function because we assume the table height doesn't change (otherwise we must reinit by calling calculateFloatContainerPosFn)
- var floatEnd;
- var tableContainerGap = 0;
- var captionHeight = haveCaption ? $caption.outerHeight(true) : 0;
- var captionScrollOffset = captionAlignTop ? captionHeight : -captionHeight;
- var floatContainerHeight = $floatContainer.height();
- var tableOffset = $table.offset();
- var tableLeftGap = 0; //can be caused by border on container (only in locked mode)
- var tableTopGap = 0;
- if(locked){
- var containerOffset = $scrollContainer.offset();
- tableContainerGap = tableOffset.top - containerOffset.top + scrollingContainerTop;
- if(haveCaption && captionAlignTop){
- tableContainerGap += captionHeight;
- }
- tableLeftGap = floatContainerBorderWidth('left');
- tableTopGap = floatContainerBorderWidth('top');
- tableContainerGap -= tableTopGap;
- } else {
- floatEnd = tableOffset.top - scrollingTop - floatContainerHeight + scrollingBottom + scrollbarOffset.horizontal;
- }
- var windowTop = $window.scrollTop();
- var windowLeft = $window.scrollLeft();
- var scrollContainerLeft = (isResponsiveContainerActive() ? $responsiveContainer : $scrollContainer).scrollLeft();
- return function(eventType){
- responsive = isResponsiveContainerActive();
- var isTableHidden = $table[0].offsetWidth <= 0 && $table[0].offsetHeight <= 0;
- if(!isTableHidden && floatTableHidden) {
- floatTableHidden = false;
- setTimeout(function(){
- $table.triggerHandler("reflow");
- }, 1);
- return null;
- }
- if(isTableHidden){ //it's hidden
- floatTableHidden = true;
- if(!useAbsolutePositioning){
- return null;
- }
- }
- if(eventType == 'windowScroll'){
- windowTop = $window.scrollTop();
- windowLeft = $window.scrollLeft();
- } else if(eventType == 'containerScroll'){
- if($responsiveContainer.length){
- if(!responsive){
- return; //we dont care about the event if we arent responsive right now
- }
- scrollContainerLeft = $responsiveContainer.scrollLeft();
- } else {
- scrollingContainerTop = $scrollContainer.scrollTop();
- scrollContainerLeft = $scrollContainer.scrollLeft();
- }
- } else if(eventType != 'init') {
- windowTop = $window.scrollTop();
- windowLeft = $window.scrollLeft();
- scrollingContainerTop = $scrollContainer.scrollTop();
- scrollContainerLeft = (responsive ? $responsiveContainer : $scrollContainer).scrollLeft();
- }
- if(isWebkit && (windowTop < 0 || windowLeft < 0)){ //chrome overscroll effect at the top of the page - breaks fixed positioned floated headers
- return;
- }
- if(absoluteToFixedOnScroll){
- if(eventType == 'windowScrollDone'){
- changePositioning(true); //change to absolute
- } else {
- changePositioning(false); //change to fixed
- }
- } else if(eventType == 'windowScrollDone'){
- return null; //event is fired when they stop scrolling. ignore it if not 'absoluteToFixedOnScroll'
- }
- tableOffset = $table.offset();
- if(haveCaption && captionAlignTop){
- tableOffset.top += captionHeight;
- }
- var top, left;
- var tableHeight = $table.outerHeight();
- if(locked && useAbsolutePositioning){ //inner scrolling, absolute positioning
- if (tableContainerGap >= scrollingContainerTop) {
- var gap = tableContainerGap - scrollingContainerTop + tableTopGap;
- top = gap > 0 ? gap : 0;
- triggerFloatEvent(false);
- } else {
- top = wrappedContainer ? tableTopGap : scrollingContainerTop;
- //headers stop at the top of the viewport
- triggerFloatEvent(true);
- }
- left = tableLeftGap;
- } else if(!locked && useAbsolutePositioning) { //window scrolling, absolute positioning
- if(windowTop > floatEnd + tableHeight + captionScrollOffset){
- top = tableHeight - floatContainerHeight + captionScrollOffset; //scrolled past table
- } else if (tableOffset.top >= windowTop + scrollingTop) {
- top = 0; //scrolling to table
- unfloat();
- triggerFloatEvent(false);
- } else {
- top = scrollingTop + windowTop - tableOffset.top + tableContainerGap + (captionAlignTop ? captionHeight : 0);
- refloat(); //scrolling within table. header floated
- triggerFloatEvent(true);
- }
- left = scrollContainerLeft;
- } else if(locked && !useAbsolutePositioning){ //inner scrolling, fixed positioning
- if (tableContainerGap > scrollingContainerTop || scrollingContainerTop - tableContainerGap > tableHeight) {
- top = tableOffset.top - windowTop;
- unfloat();
- triggerFloatEvent(false);
- } else {
- top = tableOffset.top + scrollingContainerTop - windowTop - tableContainerGap;
- refloat();
- triggerFloatEvent(true);
- //headers stop at the top of the viewport
- }
- left = tableOffset.left + scrollContainerLeft - windowLeft;
- } else if(!locked && !useAbsolutePositioning) { //window scrolling, fixed positioning
- if(windowTop > floatEnd + tableHeight + captionScrollOffset){
- top = tableHeight + scrollingTop - windowTop + floatEnd + captionScrollOffset;
- //scrolled past the bottom of the table
- } else if (tableOffset.top > windowTop + scrollingTop) {
- top = tableOffset.top - windowTop;
- refloat();
- triggerFloatEvent(false); //this is a weird case, the header never gets unfloated and i have no no way to know
- //scrolled past the top of the table
- } else {
- //scrolling within the table
- top = scrollingTop;
- triggerFloatEvent(true);
- }
- left = tableOffset.left + scrollContainerLeft - windowLeft;
- }
- return {top: top, left: left};
- };
- }
- /**
- * returns a function that caches old floating container position and only updates css when the position changes
- * @return {Function}
- */
- function repositionFloatContainerFn(){
- var oldTop = null;
- var oldLeft = null;
- var oldScrollLeft = null;
- return function(pos, setWidth, setHeight){
- if(pos != null && (oldTop != pos.top || oldLeft != pos.left)){
- $floatContainer.css({
- top: pos.top,
- left: pos.left
- });
- oldTop = pos.top;
- oldLeft = pos.left;
- }
- if(setWidth){
- setFloatWidth();
- }
- if(setHeight){
- setHeaderHeight();
- }
- var scrollLeft = (responsive ? $responsiveContainer : $scrollContainer).scrollLeft();
- if(!useAbsolutePositioning || oldScrollLeft != scrollLeft){
- $floatContainer.scrollLeft(scrollLeft);
- oldScrollLeft = scrollLeft;
- }
- }
- }
- /**
- * checks if THIS table has scrollbars, and finds their widths
- */
- function calculateScrollBarSize(){ //this should happen after the floating table has been positioned
- if($scrollContainer.length){
- if($scrollContainer.data().perfectScrollbar){
- scrollbarOffset = {horizontal:0, vertical:0};
- } else {
- var sw = $scrollContainer.width(), sh = $scrollContainer.height(), th = $table.height(), tw = tableWidth($table, $fthCells);
- var offseth = sw < tw ? scWidth : 0;
- var offsetv = sh < th ? scWidth : 0;
- scrollbarOffset.horizontal = sw - offsetv < tw ? scWidth : 0;
- scrollbarOffset.vertical = sh - offseth < th ? scWidth : 0;
- }
- }
- }
- //finish up. create all calculation functions and bind them to events
- calculateScrollBarSize();
- var flow;
- var ensureReflow = function(){
- flow = reflow();
- flow();
- };
- ensureReflow();
- var calculateFloatContainerPos = calculateFloatContainerPosFn();
- var repositionFloatContainer = repositionFloatContainerFn();
- repositionFloatContainer(calculateFloatContainerPos('init'), true); //this must come after reflow because reflow changes scrollLeft back to 0 when it rips out the thead
- var windowScrollDoneEvent = util.debounce(function(){
- repositionFloatContainer(calculateFloatContainerPos('windowScrollDone'), false);
- }, 1);
- var windowScrollEvent = function(){
- repositionFloatContainer(calculateFloatContainerPos('windowScroll'), false);
- if(absoluteToFixedOnScroll){
- windowScrollDoneEvent();
- }
- };
- var containerScrollEvent = function(){
- repositionFloatContainer(calculateFloatContainerPos('containerScroll'), false);
- };
- var windowResizeEvent = function(){
- if($table.is(":hidden")){
- return;
- }
- updateScrollingOffsets();
- calculateScrollBarSize();
- ensureReflow();
- calculateFloatContainerPos = calculateFloatContainerPosFn();
- repositionFloatContainer = repositionFloatContainerFn();
- repositionFloatContainer(calculateFloatContainerPos('resize'), true, true);
- };
- var reflowEvent = util.debounce(function(){
- if($table.is(":hidden")){
- return;
- }
- calculateScrollBarSize();
- updateScrollingOffsets();
- ensureReflow();
- calculateFloatContainerPos = calculateFloatContainerPosFn();
- repositionFloatContainer(calculateFloatContainerPos('reflow'), true);
- }, 1);
- /////// printing stuff
- var beforePrint = function(){
- $table.floatThead('destroy', [true]);
- };
- var afterPrint = function(){
- $table.floatThead(opts);
- };
- var printEvent = function(mql){
- //make printing the table work properly on IE10+
- if(mql.matches) {
- beforePrint();
- } else {
- afterPrint();
- }
- };
- if(window.matchMedia){
- window.matchMedia("print").addListener(printEvent);
- } else {
- $window.bind('beforeprint', beforePrint);
- $window.bind('afterprint', afterPrint);
- }
- ////// end printing stuff
- if(locked){ //internal scrolling
- if(useAbsolutePositioning){
- $scrollContainer.bind(eventName('scroll'), containerScrollEvent);
- } else {
- $scrollContainer.bind(eventName('scroll'), containerScrollEvent);
- $window.bind(eventName('scroll'), windowScrollEvent);
- }
- } else { //window scrolling
- $responsiveContainer.bind(eventName('scroll'), containerScrollEvent);
- $window.bind(eventName('scroll'), windowScrollEvent);
- }
- $window.bind(eventName('load'), reflowEvent); //for tables with images
- windowResize(eventName('resize'), windowResizeEvent);
- $table.bind('reflow', reflowEvent);
- if(isDatatable($table)){
- $table
- .bind('filter', reflowEvent)
- .bind('sort', reflowEvent)
- .bind('page', reflowEvent);
- }
- $window.bind(eventName('shown.bs.tab'), reflowEvent); // people cant seem to figure out how to use this plugin with bs3 tabs... so this :P
- $window.bind(eventName('tabsactivate'), reflowEvent); // same thing for jqueryui
- if (canObserveMutations) {
- var mutationElement = null;
- if(util.isFunction(opts.autoReflow)){
- mutationElement = opts.autoReflow($table, $scrollContainer)
- }
- if(!mutationElement) {
- mutationElement = $scrollContainer.length ? $scrollContainer[0] : $table[0]
- }
- mObs = new MutationObserver(function(e){
- var wasTableRelated = function(nodes){
- return nodes && nodes[0] && (nodes[0].nodeName == "THEAD" || nodes[0].nodeName == "TD"|| nodes[0].nodeName == "TH");
- };
- for(var i=0; i < e.length; i++){
- if(!(wasTableRelated(e[i].addedNodes) || wasTableRelated(e[i].removedNodes))){
- reflowEvent();
- break;
- }
- }
- });
- mObs.observe(mutationElement, {
- childList: true,
- subtree: true
- });
- }
- //attach some useful functions to the table.
- $table.data('floatThead-attached', {
- destroy: function(e, isPrintEvent){
- var ns = '.fth-'+floatTheadId;
- unfloat();
- $table.css(layoutAuto);
- $tableColGroup.remove();
- createElements && $fthGrp.remove();
- if($newHeader.parent().length){ //only if it's in the DOM
- $newHeader.replaceWith($header);
- }
- triggerFloatEvent(false);
- if(canObserveMutations){
- mObs.disconnect();
- mObs = null;
- }
- $table.unbind('reflow reflowed');
- $scrollContainer.unbind(ns);
- $responsiveContainer.unbind(ns);
- if (wrappedContainer) {
- if ($scrollContainer.length) {
- $scrollContainer.unwrap();
- }
- else {
- $table.unwrap();
- }
- }
- if(locked){
- $scrollContainer.data('floatThead-containerWrap', false);
- } else {
- $table.data('floatThead-containerWrap', false);
- }
- $table.css('minWidth', originalTableMinWidth);
- $floatContainer.remove();
- $table.data('floatThead-attached', false);
- $window.unbind(ns);
- if(!isPrintEvent){
- //if we are in the middle of printing, we want this event to re-create the plugin
- window.matchMedia && window.matchMedia("print").removeListener(printEvent);
- beforePrint = afterPrint = function(){};
- }
- },
- reflow: function(){
- reflowEvent();
- },
- setHeaderHeight: function(){
- setHeaderHeight();
- },
- getFloatContainer: function(){
- return $floatContainer;
- },
- getRowGroups: function(){
- if(headerFloated){
- return $floatContainer.find('>table>thead').add($table.children("tbody,tfoot"));
- } else {
- return $table.children("thead,tbody,tfoot");
- }
- }
- });
- });
- return this;
- };
- })(jQuery);
- /* jQuery.floatThead.utils - http://mkoryak.github.io/floatThead/ - Copyright (c) 2012 - 2014 Misha Koryak
- * License: MIT
- *
- * This file is required if you do not use underscore in your project and you want to use floatThead.
- * It contains functions from underscore that the plugin uses.
- *
- * YOU DON'T NEED TO INCLUDE THIS IF YOU ALREADY INCLUDE UNDERSCORE!
- *
- */
- (function($){
- $.floatThead = $.floatThead || {};
- $.floatThead._ = window._ || (function(){
- var that = {};
- var hasOwnProperty = Object.prototype.hasOwnProperty, isThings = ['Arguments', 'Function', 'String', 'Number', 'Date', 'RegExp'];
- that.has = function(obj, key) {
- return hasOwnProperty.call(obj, key);
- };
- that.keys = function(obj) {
- if (obj !== Object(obj)) throw new TypeError('Invalid object');
- var keys = [];
- for (var key in obj) if (that.has(obj, key)) keys.push(key);
- return keys;
- };
- var idCounter = 0;
- that.uniqueId = function(prefix) {
- var id = ++idCounter + '';
- return prefix ? prefix + id : id;
- };
- $.each(isThings, function(){
- var name = this;
- that['is' + name] = function(obj) {
- return Object.prototype.toString.call(obj) == '[object ' + name + ']';
- };
- });
- that.debounce = function(func, wait, immediate) {
- var timeout, args, context, timestamp, result;
- return function() {
- context = this;
- args = arguments;
- timestamp = new Date();
- var later = function() {
- var last = (new Date()) - timestamp;
- if (last < wait) {
- timeout = setTimeout(later, wait - last);
- } else {
- timeout = null;
- if (!immediate) result = func.apply(context, args);
- }
- };
- var callNow = immediate && !timeout;
- if (!timeout) {
- timeout = setTimeout(later, wait);
- }
- if (callNow) result = func.apply(context, args);
- return result;
- };
- };
- return that;
- })();
- })(jQuery);
- /*************************************************************************
- jquery.dynatree.js
- Dynamic tree view control, with support for lazy loading of branches.
- Copyright (c) 2008-2010, Martin Wendt (http://wwWendt.de)
- Dual licensed under the MIT or GPL Version 2 licenses.
- http://code.google.com/p/dynatree/wiki/LicenseInfo
- A current version and some documentation is available at
- http://dynatree.googlecode.com/
- $Version: 0.5.4$
- $Revision: 329, 2010-05-05 08:04:39$
- @depends: jquery.js
- @depends: ui.core.js
- @depends: jquery.cookie.js
- *************************************************************************/
- /*************************************************************************
- * Debug functions
- */
- var _canLog = true;
- function _log(mode, msg) {
- /**
- * Usage: logMsg("%o was toggled", this);
- */
- if( !_canLog )
- return;
- // Remove first argument
- var args = Array.prototype.slice.apply(arguments, [1]);
- // Prepend timestamp
- var dt = new Date();
- var tag = dt.getHours()+":"+dt.getMinutes()+":"+dt.getSeconds()+"."+dt.getMilliseconds();
- args[0] = tag + " - " + args[0];
- try {
- switch( mode ) {
- case "info":
- window.console.info.apply(window.console, args);
- break;
- case "warn":
- window.console.warn.apply(window.console, args);
- break;
- default:
- window.console.log.apply(window.console, args);
- }
- } catch(e) {
- if( !window.console )
- _canLog = false; // Permanently disable, when logging is not supported by the browser
- }
- }
- function logMsg(msg) {
- Array.prototype.unshift.apply(arguments, ["debug"]);
- _log.apply(this, arguments);
- }
- // Forward declaration
- var getDynaTreePersistData = undefined;
- /*************************************************************************
- * Constants
- */
- var DTNodeStatus_Error = -1;
- var DTNodeStatus_Loading = 1;
- var DTNodeStatus_Ok = 0;
- // Start of local namespace
- ;(function($) {
- /*************************************************************************
- * Common tool functions.
- */
- var Class = {
- create: function() {
- return function() {
- this.initialize.apply(this, arguments);
- }
- }
- }
- /*************************************************************************
- * Class DynaTreeNode
- */
- var DynaTreeNode = Class.create();
- DynaTreeNode.prototype = {
- initialize: function(parent, tree, data) {
- /**
- * @constructor
- */
- this.parent = parent;
- this.tree = tree;
- if ( typeof data == "string" )
- data = { title: data };
- if( data.key == undefined )
- data.key = "_" + tree._nodeCount++;
- this.data = $.extend({}, $.ui.dynatree.nodedatadefaults, data);
- this.div = null; // not yet created
- this.span = null; // not yet created
- this.childList = null; // no subnodes yet
- // this.isRead = false; // Lazy content not yet read
- this.isLoading = false; // Lazy content is being loaded
- this.hasSubSel = false;
- },
- toString: function() {
- return "dtnode<" + this.data.key + ">: '" + this.data.title + "'";
- },
- toDict: function(recursive, callback) {
- var dict = $.extend({}, this.data);
- dict.activate = ( this.tree.activeNode === this );
- dict.focus = ( this.tree.focusNode === this );
- dict.expand = this.bExpanded;
- dict.select = this.bSelected;
- if( callback )
- callback(dict);
- if( recursive && this.childList ) {
- dict.children = [];
- for(var i=0; i<this.childList.length; i++ )
- dict.children.push(this.childList[i].toDict(true, callback));
- } else {
- delete dict.children;
- }
- return dict;
- },
- _getInnerHtml: function() {
- var opts = this.tree.options;
- var cache = this.tree.cache;
- // parent connectors
- var rootParent = opts.rootVisible ? null : this.tree.tnRoot;
- var bHideFirstExpander = (opts.rootVisible && opts.minExpandLevel>0) || opts.minExpandLevel>1;
- var bHideFirstConnector = opts.rootVisible || opts.minExpandLevel>0;
- var res = "";
- var p = this.parent;
- while( p ) {
- // Suppress first connector column, if visible top level is always expanded
- if ( bHideFirstConnector && p==rootParent )
- break;
- res = ( p.isLastSibling() ? cache.tagEmpty : cache.tagVline) + res;
- p = p.parent;
- }
- //@modify liguocai 2011-11-30 让顶层元素也有展开收缩的功能
- // connector (expanded, expandable or simple)
- //if( bHideFirstExpander && this.parent==rootParent ) {
- // skip connector
- //} else
- if ( this.childList || this.data.isLazy ) {
- res += cache.tagExpander;
- } else {
- res += cache.tagConnector;
- }
-
- // Checkbox mode
- if( opts.checkbox && this.data.hideCheckbox!=true && !this.data.isStatusNode ) {
- res += cache.tagCheckbox;
- }
-
- // folder or doctype icon
- if ( this.data.icon ) {
- res += "<img src='" + opts.imagePath + this.data.icon + "' alt='' />";
- } else if ( this.data.icon == false ) {
- // icon == false means 'no icon'
- } else {
- // icon == null means 'default icon'
- res += cache.tagNodeIcon;
- }
- // node name
- var tooltip = ( this.data && typeof this.data.tooltip == "string" ) ? " title='" + this.data.tooltip + "'" : "";
- res += "<a href='#' class='" + opts.classNames.title + "'" + tooltip + ">" + this.data.title + "</a>";
- return res;
- },
- _fixOrder: function() {
- /**
- * Make sure, that <div> order matches childList order.
- */
- var cl = this.childList;
- if( !cl )
- return;
- var childDiv = this.div.firstChild.nextSibling;
- for(var i=0; i<cl.length-1; i++) {
- var childNode1 = cl[i];
- var childNode2 = childDiv.firstChild.dtnode;
- if( childNode1 !== childNode2 ) {
- this.tree.logDebug("_fixOrder: mismatch at index " + i + ": " + childNode1 + " != " + childNode2);
- this.div.insertBefore(childNode1.div, childNode2.div);
- } else {
- childDiv = childDiv.nextSibling;
- }
- }
- },
-
- render: function(bDeep, bHidden) {
- /**
- * Create HTML markup for this node.
- *
- * <div> // This div contains the node's span and list of child div's.
- * <span id='key'>S S S A</span> // Span contains graphic spans and title <a> tag
- * <div>child1</div>
- * <div>child2</div>
- * </div>
- */
- // this.tree.logDebug("%o.render()", this);
- var opts = this.tree.options;
- var cn = opts.classNames;
- var isLastSib = this.isLastSibling();
- // ---
- if( ! this.div ) {
- this.span = document.createElement("span");
- this.span.dtnode = this;
- if( this.data.key )
- this.span.id = this.tree.options.idPrefix + this.data.key;
- this.div = document.createElement("div");
- this.div.appendChild(this.span);
-
- if ( this.parent ) {
- this.parent.div.appendChild(this.div);
- }
- if( this.parent==null && !this.tree.options.rootVisible )
- this.span.style.display = "none";
- }
- // set node connector images, links and text
- this.span.innerHTML = this._getInnerHtml();
- // hide this node, if parent is collapsed
- this.div.style.display = ( this.parent==null || this.parent.bExpanded ? "" : "none");
- // Set classes for current status
- var cnList = [];
- cnList.push( ( this.data.isFolder ) ? cn.folder : cn.document );
- if( this.bExpanded )
- cnList.push(cn.expanded);
- if( this.childList != null )
- cnList.push(cn.hasChildren);
- if( this.data.isLazy && this.childList==null )
- cnList.push(cn.lazy);
- if( isLastSib )
- cnList.push(cn.lastsib);
- if( this.bSelected )
- cnList.push(cn.selected);
- if( this.hasSubSel )
- cnList.push(cn.partsel);
- if( this.tree.activeNode === this )
- cnList.push(cn.active);
- if( this.data.addClass )
- cnList.push(this.data.addClass);
- // IE6 doesn't correctly evaluate multiple class names,
- // so we create combined class names that can be used in the CSS
- cnList.push(cn.combinedExpanderPrefix
- + (this.bExpanded ? "e" : "c")
- + (this.data.isLazy && this.childList==null ? "d" : "")
- + (isLastSib ? "l" : "")
- );
- cnList.push(cn.combinedIconPrefix
- + (this.bExpanded ? "e" : "c")
- + (this.data.isFolder ? "f" : "")
- );
- this.span.className = cnList.join(" ");
- if( bDeep && this.childList && (bHidden || this.bExpanded) ) {
- for(var i=0; i<this.childList.length; i++) {
- this.childList[i].render(bDeep, bHidden)
- }
- this._fixOrder();
- }
- },
- hasChildren: function() {
- return this.childList != null;
- },
- isLastSibling: function() {
- var p = this.parent;
- if ( !p ) return true;
- return p.childList[p.childList.length-1] === this;
- },
- prevSibling: function() {
- if( !this.parent ) return null;
- var ac = this.parent.childList;
- for(var i=1; i<ac.length; i++) // start with 1, so prev(first) = null
- if( ac[i] === this )
- return ac[i-1];
- return null;
- },
- nextSibling: function() {
- if( !this.parent ) return null;
- var ac = this.parent.childList;
- for(var i=0; i<ac.length-1; i++) // up to length-2, so next(last) = null
- if( ac[i] === this )
- return ac[i+1];
- return null;
- },
- _setStatusNode: function(data) {
- // Create, modify or remove the status child node (pass 'null', to remove it).
- var firstChild = ( this.childList ? this.childList[0] : null );
- if( !data ) {
- if ( firstChild ) {
- this.div.removeChild(firstChild.div);
- if( this.childList.length == 1 )
- this.childList = null;
- else
- this.childList.shift();
- }
- } else if ( firstChild ) {
- data.isStatusNode = true;
- firstChild.data = data;
- firstChild.render(false, false);
- } else {
- data.isStatusNode = true;
- firstChild = this.addChild(data);
- }
- },
- setLazyNodeStatus: function(lts, opts) {
- var tooltip = (opts && opts.tooltip) ? opts.tooltip : null;
- var info = (opts && opts.info) ? " (" + opts.info + ")" : "";
- switch( lts ) {
- case DTNodeStatus_Ok:
- this._setStatusNode(null);
- // this.isRead = true;
- this.isLoading = false;
- this.render(false, false);
- if( this.tree.options.autoFocus ) {
- if( this === this.tree.tnRoot && !this.tree.options.rootVisible && this.childList ) {
- // special case: using ajaxInit
- this.childList[0].focus();
- } else {
- this.focus();
- }
- }
- break;
- case DTNodeStatus_Loading:
- this.isLoading = true;
- this._setStatusNode({
- title: this.tree.options.strings.loading + info,
- tooltip: tooltip,
- addClass: this.tree.options.classNames.nodeWait
- });
- break;
- case DTNodeStatus_Error:
- this.isLoading = false;
- this._setStatusNode({
- title: this.tree.options.strings.loadError + info,
- tooltip: tooltip,
- addClass: this.tree.options.classNames.nodeError
- });
- break;
- default:
- throw "Bad LazyNodeStatus: '" + lts + "'.";
- }
- },
- _parentList: function(includeRoot, includeSelf) {
- var l = [];
- var dtn = includeSelf ? this : this.parent;
- while( dtn ) {
- if( includeRoot || dtn.parent )
- l.unshift(dtn);
- dtn = dtn.parent;
- };
- return l;
- },
- getLevel: function() {
- var level = 0;
- var dtn = this.parent;
- while( dtn ) {
- level++;
- dtn = dtn.parent;
- };
- return level;
- },
- _getTypeForOuterNodeEvent: function(event) {
- /** Return the inner node span (title, checkbox or expander) if
- * event.target points to the outer span.
- * This function should fix issue #93:
- * FF2 ignores empty spans, when generating events (returning the parent instead).
- */
- var cns = this.tree.options.classNames;
- var target = event.target;
- // Only process clicks on an outer node span (probably due to a FF2 event handling bug)
- if( target.className.indexOf(cns.folder)<0
- && target.className.indexOf(cns.document)<0 ) {
- return null
- }
- // Event coordinates, relative to outer node span:
- var eventX = event.pageX - target.offsetLeft;
- var eventY = event.pageY - target.offsetTop;
-
- for(var i=0; i<target.childNodes.length; i++) {
- var cn = target.childNodes[i];
- var x = cn.offsetLeft - target.offsetLeft;
- var y = cn.offsetTop - target.offsetTop;
- var nx = cn.clientWidth, ny = cn.clientHeight;
- // alert (cn.className + ": " + x + ", " + y + ", s:" + nx + ", " + ny);
- if( eventX>=x && eventX<=(x+nx) && eventY>=y && eventY<=(y+ny) ) {
- // alert("HIT "+ cn.className);
- if( cn.className==cns.title )
- return "title";
- else if( cn.className==cns.expander )
- return "expander";
- else if( cn.className==cns.checkbox )
- return "checkbox";
- else if( cn.className==cns.nodeIcon )
- return "icon";
- }
- }
- return "prefix";
- },
- getEventTargetType: function(event) {
- // Return the part of a node, that a click event occured on.
- // Note: there is no check, if the was fired on TIHS node.
- var tcn = event && event.target ? event.target.className : "";
- var cns = this.tree.options.classNames;
- if( tcn == cns.title )
- return "title";
- else if( tcn==cns.expander )
- return "expander";
- else if( tcn==cns.checkbox )
- return "checkbox";
- else if( tcn==cns.nodeIcon )
- return "icon";
- else if( tcn==cns.empty || tcn==cns.vline || tcn==cns.connector )
- return "prefix";
- else if( tcn.indexOf(cns.folder)>=0 || tcn.indexOf(cns.document)>=0 )
- // FIX issue #93
- return this._getTypeForOuterNodeEvent(event);
- return null;
- },
- isVisible: function() {
- // Return true, if all parents are expanded.
- var parents = this._parentList(true, false);
- for(var i=0; i<parents.length; i++)
- if( ! parents[i].bExpanded ) return false;
- return true;
- },
- makeVisible: function() {
- // Make sure, all parents are expanded
- var parents = this._parentList(true, false);
- for(var i=0; i<parents.length; i++)
- parents[i]._expand(true);
- },
- focus: function() {
- // TODO: check, if we already have focus
- // this.tree.logDebug("dtnode.focus(): %o", this);
- this.makeVisible();
- try {
- $(this.span).find(">a").focus();
- } catch(e) { }
- },
- _activate: function(flag, fireEvents) {
- // (De)Activate - but not focus - this node.
- this.tree.logDebug("dtnode._activate(%o, fireEvents=%o) - %o", flag, fireEvents, this);
- var opts = this.tree.options;
- if( this.data.isStatusNode )
- return;
- if ( fireEvents && opts.onQueryActivate && opts.onQueryActivate.call(this.span, flag, this) == false )
- return; // Callback returned false
-
- if( flag ) {
- // Activate
- if( this.tree.activeNode ) {
- if( this.tree.activeNode === this )
- return;
- this.tree.activeNode.deactivate();
- }
- if( opts.activeVisible )
- this.makeVisible();
- this.tree.activeNode = this;
- if( opts.persist )
- $.cookie(opts.cookieId+"-active", this.data.key, opts.cookie);
- this.tree.persistence.activeKey = this.data.key;
- $(this.span).addClass(opts.classNames.active);
- if ( fireEvents && opts.onActivate ) // Pass element as 'this' (jQuery convention)
- opts.onActivate.call(this.span, this);
- } else {
- // Deactivate
- if( this.tree.activeNode === this ) {
- var opts = this.tree.options;
- if ( opts.onQueryActivate && opts.onQueryActivate.call(this.span, false, this) == false )
- return; // Callback returned false
- $(this.span).removeClass(opts.classNames.active);
- if( opts.persist ) {
- // Note: we don't pass null, but ''. So the cookie is not deleted.
- // If we pass null, we also have to pass a COPY of opts, because $cookie will override opts.expires (issue 84)
- $.cookie(opts.cookieId+"-active", "", opts.cookie);
- }
- this.tree.persistence.activeKey = null;
- this.tree.activeNode = null;
- if ( fireEvents && opts.onDeactivate )
- opts.onDeactivate.call(this.span, this);
- }
- }
- },
- activate: function() {
- // Select - but not focus - this node.
- // this.tree.logDebug("dtnode.activate(): %o", this);
- this._activate(true, true);
- },
- deactivate: function() {
- // this.tree.logDebug("dtnode.deactivate(): %o", this);
- this._activate(false, true);
- },
- isActive: function() {
- return (this.tree.activeNode === this);
- },
-
- _userActivate: function() {
- // Handle user click / [space] / [enter], according to clickFolderMode.
- var activate = true;
- var expand = false;
- if ( this.data.isFolder ) {
- switch( this.tree.options.clickFolderMode ) {
- case 2:
- activate = false;
- expand = true;
- break;
- case 3:
- activate = expand = true;
- break;
- }
- }
- if( this.parent == null && this.tree.options.minExpandLevel>0 ) {
- expand = false;
- }
- if( expand ) {
- this.toggleExpand();
- this.focus();
- }
- if( activate ) {
- this.activate();
- }
- },
- _setSubSel: function(hasSubSel) {
- if( hasSubSel ) {
- this.hasSubSel = true;
- $(this.span).addClass(this.tree.options.classNames.partsel);
- } else {
- this.hasSubSel = false;
- $(this.span).removeClass(this.tree.options.classNames.partsel);
- }
- },
- _fixSelectionState: function() {
- // fix selection status, for multi-hier mode
- // this.tree.logDebug("_fixSelectionState(%o) - %o", this.bSelected, this);
- if( this.bSelected ) {
- // Select all children
- this.visit(function(dtnode){
- dtnode.parent._setSubSel(true);
- dtnode._select(true, false, false);
- });
- // Select parents, if all children are selected
- var p = this.parent;
- while( p ) {
- p._setSubSel(true);
- var allChildsSelected = true;
- for(var i=0; i<p.childList.length; i++) {
- var n = p.childList[i];
- if( !n.bSelected && !n.data.isStatusNode ) {
- allChildsSelected = false;
- break;
- }
- }
- if( allChildsSelected )
- p._select(true, false, false);
- p = p.parent;
- }
- } else {
- // Deselect all children
- this._setSubSel(false);
- this.visit(function(dtnode){
- dtnode._setSubSel(false);
- dtnode._select(false, false, false);
- });
- // Deselect parents, and recalc hasSubSel
- var p = this.parent;
- while( p ) {
- p._select(false, false, false);
- var isPartSel = false;
- for(var i=0; i<p.childList.length; i++) {
- if( p.childList[i].bSelected || p.childList[i].hasSubSel ) {
- isPartSel = true;
- break;
- }
- }
- p._setSubSel(isPartSel);
- p = p.parent;
- }
- }
- },
-
- _select: function(sel, fireEvents, deep) {
- // Select - but not focus - this node.
- // this.tree.logDebug("dtnode._select(%o) - %o", sel, this);
- var opts = this.tree.options;
- if( this.data.isStatusNode )
- return;
- //
- if( this.bSelected == sel ) {
- // this.tree.logDebug("dtnode._select(%o) IGNORED - %o", sel, this);
- return;
- }
- // Allow event listener to abort selection
- if ( fireEvents && opts.onQuerySelect && opts.onQuerySelect.call(this.span, sel, this) == false )
- return; // Callback returned false
-
- // Force single-selection
- if( opts.selectMode==1 && sel ) {
- this.tree.visit(function(dtnode){
- if( dtnode.bSelected ) {
- // Deselect; assuming that in selectMode:1 there's max. one other selected node
- dtnode._select(false, false, false);
- return false;
- }
- });
- }
- this.bSelected = sel;
- // this.tree._changeNodeList("select", this, sel);
-
- if( sel ) {
- if( opts.persist )
- this.tree.persistence.addSelect(this.data.key);
- $(this.span).addClass(opts.classNames.selected);
- if( deep && opts.selectMode==3 )
- this._fixSelectionState();
- if ( fireEvents && opts.onSelect )
- opts.onSelect.call(this.span, true, this);
- } else {
- if( opts.persist )
- this.tree.persistence.clearSelect(this.data.key);
-
- $(this.span).removeClass(opts.classNames.selected);
- if( deep && opts.selectMode==3 )
- this._fixSelectionState();
- if ( fireEvents && opts.onSelect )
- opts.onSelect.call(this.span, false, this);
- }
- },
- select: function(sel) {
- // Select - but not focus - this node.
- // this.tree.logDebug("dtnode.select(%o) - %o", sel, this);
- if( this.data.unselectable )
- return this.bSelected;
- return this._select(sel!=false, true, true);
- },
- toggleSelect: function() {
- // this.tree.logDebug("dtnode.toggleSelect() - %o", this);
- return this.select(!this.bSelected);
- },
- isSelected: function() {
- return this.bSelected;
- },
-
- _loadContent: function() {
- try {
- var opts = this.tree.options;
- this.tree.logDebug("_loadContent: start - %o", this);
- this.setLazyNodeStatus(DTNodeStatus_Loading);
- if( true == opts.onLazyRead.call(this.span, this) ) {
- // If function returns 'true', we assume that the loading is done:
- this.setLazyNodeStatus(DTNodeStatus_Ok);
- // Otherwise (i.e. if the loading was started as an asynchronous process)
- // the onLazyRead(dtnode) handler is expected to call dtnode.setLazyNodeStatus(DTNodeStatus_Ok/_Error) when done.
- this.tree.logDebug("_loadContent: succeeded - %o", this);
- }
- } catch(e) {
- // alert(e);
- this.setLazyNodeStatus(DTNodeStatus_Error);
- this.tree.logWarning("_loadContent: failed - %o", e);
- }
- },
-
- _expand: function(bExpand) {
- // this.tree.logDebug("dtnode._expand(%o) - %o", bExpand, this);
- if( this.bExpanded == bExpand ) {
- // this.tree.logDebug("dtnode._expand(%o) IGNORED - %o", bExpand, this);
- return;
- }
- var opts = this.tree.options;
- //@modify liguocai 2011-11-30 miniExpandLevel置为无效,以防阻止顶层元素打开
- //if( !bExpand && this.getLevel()<opts.minExpandLevel ) {
- // this.tree.logDebug("dtnode._expand(%o) forced expand - %o", bExpand, this);
- // return;
- //}
- if ( opts.onQueryExpand && opts.onQueryExpand.call(this.span, bExpand, this) == false )
- return; // Callback returned false
- this.bExpanded = bExpand;
- // Persist expand state
- if( opts.persist ) {
- if( bExpand )
- this.tree.persistence.addExpand(this.data.key);
- else
- this.tree.persistence.clearExpand(this.data.key);
- }
- this.render(false);
- // Auto-collapse mode: collapse all siblings
- if( this.bExpanded && this.parent && opts.autoCollapse ) {
- var parents = this._parentList(false, true);
- for(var i=0; i<parents.length; i++)
- parents[i].collapseSiblings();
- }
- // If the currently active node is now hidden, deactivate it
- if( opts.activeVisible && this.tree.activeNode && ! this.tree.activeNode.isVisible() ) {
- this.tree.activeNode.deactivate();
- }
- // Expanding a lazy node: set 'loading...' and call callback
- if( bExpand && this.data.isLazy && this.childList==null && !this.isLoading ) {
- this._loadContent();
- return;
- }
- // this.tree.logDebug("_expand: start div toggle - %o", this);
- var fxDuration = opts.fx ? (opts.fx.duration || 200) : 0;
- if( this.childList ) {
- for(var i=0; i<this.childList.length; i++ ) {
- var $child = $(this.childList[i].div);
- if( fxDuration ) {
- // This is a toggle, so only do it, if not already rendered (in)visible (issue 98)
- if( bExpand != $child.is(':visible') )
- $child.animate(opts.fx, fxDuration);
- } else {
- if( bExpand )
- $child.show();
- else
- $child.hide(); // TODO: this seems to be slow, when called the first time for an element
- }
- }
- }
-
- /* issue 109: using selector filter is really SLOW.
- // issue 98: only toggle, if render hasn't set visibility already:
- var filter = ">DIV" + (bExpand ? ":hidden" : ":visible");
-
- if( opts.fx ) {
- var duration = opts.fx.duration || 200;
- // $(">DIV", this.div).animate(opts.fx, duration);
- $(filter, this.div).animate(opts.fx, duration);
- } else {
- $(filter, this.div).toggle();
- // var $d = $(">DIV", this.div);
- // this.tree.logDebug("_expand: got div, start toggle - %o", this);
- // $d.toggle();
- }
- //*/
- // this.tree.logDebug("_expand: end div toggle - %o", this);
- if ( opts.onExpand )
- opts.onExpand.call(this.span, bExpand, this);
- },
- expand: function(flag) {
- if( !this.childList && !this.data.isLazy && flag )
- return; // Prevent expanding empty nodes
- if( this.parent == null && this.tree.options.minExpandLevel>0 && !flag )
- return; // Prevent collapsing the root
- this._expand(flag);
- },
- toggleExpand: function() {
- this.expand(!this.bExpanded);
- },
- collapseSiblings: function() {
- if( this.parent == null )
- return;
- var ac = this.parent.childList;
- for (var i=0; i<ac.length; i++) {
- if ( ac[i] !== this && ac[i].bExpanded )
- ac[i]._expand(false);
- }
- },
- onClick: function(event) {
- // this.tree.logDebug("dtnode.onClick(" + event.type + "): dtnode:" + this + ", button:" + event.button + ", which: " + event.which);
- var targetType = this.getEventTargetType(event);
- if( targetType == "expander" ) {
- // Clicking the expander icon always expands/collapses
- this.toggleExpand();
- this.focus(); // issue 95
- } else if( targetType == "checkbox" ) {
- // Clicking the checkbox always (de)selects
- this.toggleSelect();
- this.focus(); // issue 95
- } else {
- this._userActivate();
- // Chrome and Safari don't focus the a-tag on click
- this.span.getElementsByTagName("a")[0].focus();
- }
- // Make sure that clicks stop, otherwise <a href='#'> jumps to the top
- return false;
- },
- onDblClick: function(event) {
- // this.tree.logDebug("dtnode.onDblClick(" + event.type + "): dtnode:" + this + ", button:" + event.button + ", which: " + event.which);
- },
- onKeydown: function(event) {
- // this.tree.logDebug("dtnode.onKeydown(" + event.type + "): dtnode:" + this + ", charCode:" + event.charCode + ", keyCode: " + event.keyCode + ", which: " + event.which);
- var handled = true;
- // alert("keyDown" + event.which);
- switch( event.which ) {
- // charCodes:
- // case 43: // '+'
- case 107: // '+'
- case 187: // '+' @ Chrome, Safari
- if( !this.bExpanded ) this.toggleExpand();
- break;
- // case 45: // '-'
- case 109: // '-'
- case 189: // '+' @ Chrome, Safari
- if( this.bExpanded ) this.toggleExpand();
- break;
- //~ case 42: // '*'
- //~ break;
- //~ case 47: // '/'
- //~ break;
- // case 13: // <enter>
- // <enter> on a focused <a> tag seems to generate a click-event.
- // this._userActivate();
- // break;
- case 32: // <space>
- this._userActivate();
- break;
- case 8: // <backspace>
- if( this.parent )
- this.parent.focus();
- break;
- case 37: // <left>
- if( this.bExpanded ) {
- this.toggleExpand();
- this.focus();
- } else if( this.parent && (this.tree.options.rootVisible || this.parent.parent) ) {
- this.parent.focus();
- }
- break;
- case 39: // <right>
- if( !this.bExpanded && (this.childList || this.data.isLazy) ) {
- this.toggleExpand();
- this.focus();
- } else if( this.childList ) {
- this.childList[0].focus();
- }
- break;
- case 38: // <up>
- var sib = this.prevSibling();
- while( sib && sib.bExpanded && sib.childList )
- sib = sib.childList[sib.childList.length-1];
- if( !sib && this.parent && (this.tree.options.rootVisible || this.parent.parent) )
- sib = this.parent;
- if( sib ) sib.focus();
- break;
- case 40: // <down>
- var sib;
- if( this.bExpanded && this.childList ) {
- sib = this.childList[0];
- } else {
- var parents = this._parentList(false, true);
- for(var i=parents.length-1; i>=0; i--) {
- sib = parents[i].nextSibling();
- if( sib ) break;
- }
- }
- if( sib ) sib.focus();
- break;
- default:
- handled = false;
- }
- // Return false, if handled, to prevent default processing
- return !handled;
- },
- onKeypress: function(event) {
- // onKeypress is only hooked to allow user callbacks.
- // We don't process it, because IE and Safari don't fire keypress for cursor keys.
- // this.tree.logDebug("dtnode.onKeypress(" + event.type + "): dtnode:" + this + ", charCode:" + event.charCode + ", keyCode: " + event.keyCode + ", which: " + event.which);
- },
-
- onFocus: function(event) {
- // Handles blur and focus events.
- // this.tree.logDebug("dtnode.onFocus(%o): %o", event, this);
- var opts = this.tree.options;
- if ( event.type=="blur" || event.type=="focusout" ) {
- if ( opts.onBlur ) // Pass element as 'this' (jQuery convention)
- opts.onBlur.call(this.span, this);
- if( this.tree.tnFocused )
- $(this.tree.tnFocused.span).removeClass(opts.classNames.focused);
- this.tree.tnFocused = null;
- if( opts.persist )
- $.cookie(opts.cookieId+"-focus", "", opts.cookie);
- } else if ( event.type=="focus" || event.type=="focusin") {
- // Fix: sometimes the blur event is not generated
- if( this.tree.tnFocused && this.tree.tnFocused !== this ) {
- this.tree.logDebug("dtnode.onFocus: out of sync: curFocus: %o", this.tree.tnFocused);
- $(this.tree.tnFocused.span).removeClass(opts.classNames.focused);
- }
- this.tree.tnFocused = this;
- if ( opts.onFocus ) // Pass element as 'this' (jQuery convention)
- opts.onFocus.call(this.span, this);
- $(this.tree.tnFocused.span).addClass(opts.classNames.focused);
- if( opts.persist )
- $.cookie(opts.cookieId+"-focus", this.data.key, opts.cookie);
- }
- // TODO: return anything?
- // return false;
- },
- visit: function(fn, data, includeSelf) {
- // Call fn(dtnode, data) for all child nodes. Stop iteration, if fn() returns false.
- var n = 0;
- if( includeSelf == true ) {
- if( fn(this, data) == false )
- return 1;
- n++;
- }
- if ( this.childList )
- for (var i=0; i<this.childList.length; i++)
- n += this.childList[i].visit(fn, data, true);
- return n;
- },
- remove: function() {
- // Remove this node
- // this.tree.logDebug ("%o.remove()", this);
- if ( this === this.tree.root )
- return false;
- return this.parent.removeChild(this);
- },
- removeChild: function(tn) {
- // Remove tn from list of direct children.
- var ac = this.childList;
- if( ac.length == 1 ) {
- if( tn !== ac[0] )
- throw "removeChild: invalid child";
- return this.removeChildren();
- }
- if( tn === this.tree.activeNode )
- tn.deactivate();
- if( this.tree.options.persist ) {
- if( tn.bSelected )
- this.tree.persistence.clearSelect(tn.data.key);
- if ( tn.bExpanded )
- this.tree.persistence.clearExpand(tn.data.key);
- }
- tn.removeChildren(true);
- this.div.removeChild(tn.div);
- for(var i=0; i<ac.length; i++) {
- if( ac[i] === tn ) {
- this.childList.splice(i, 1);
- delete tn;
- break;
- }
- }
- },
- removeChildren: function(isRecursiveCall, retainPersistence) {
- // Remove all child nodes (more efficiently than recursive remove())
- // this.tree.logDebug ("%o.removeChildren(%o)", this, isRecursiveCall);
- var tree = this.tree;
- var ac = this.childList;
- if( ac ) {
- for(var i=0; i<ac.length; i++) {
- var tn=ac[i];
- // this.tree.logDebug ("del %o", tn);
- if ( tn === tree.activeNode && !retainPersistence )
- tn.deactivate();
- if( this.tree.options.persist && !retainPersistence ) {
- if( tn.bSelected )
- this.tree.persistence.clearSelect(tn.data.key);
- if ( tn.bExpanded )
- this.tree.persistence.clearExpand(tn.data.key);
- }
- tn.removeChildren(true, retainPersistence);
- this.div.removeChild(tn.div);
- delete tn;
- }
- this.childList = null;
- }
- if( ! isRecursiveCall ) {
- // this._expand(false);
- // this.isRead = false;
- this.isLoading = false;
- this.render(false, false);
- }
- },
- reload: function(force) {
- // Discard lazy content (and reload, if node was expanded).
- if( this.parent == null )
- return this.tree.reload();
-
- if( ! this.data.isLazy )
- throw "node.reload() requires lazy nodes.";
- if( this.bExpanded ) {
- this.expand(false);
- this.removeChildren();
- this.expand(true);
- } else {
- this.removeChildren();
- if( force )
- this._loadContent();
- }
- },
- _addChildNode: function(dtnode, beforeNode) {
- /**
- * Internal function to add one single DynatreeNode as a child.
- *
- */
- var tree = this.tree;
- var opts = tree.options;
- var pers = tree.persistence;
-
- // tree.logDebug("%o._addChildNode(%o)", this, dtnode);
-
- // --- Update and fix dtnode attributes if necessary
- dtnode.parent = this;
- // if( beforeNode && (beforeNode.parent !== this || beforeNode === dtnode ) )
- // throw "<beforeNode> must be another child of <this>";
- // --- Add dtnode as a child
- if ( this.childList==null ) {
- this.childList = [];
- } else if( ! beforeNode ) {
- // Fix 'lastsib'
- $(this.childList[this.childList.length-1].span).removeClass(opts.classNames.lastsib);
- }
- if( beforeNode ) {
- var iBefore = $.inArray(beforeNode, this.childList);
- if( iBefore < 0 )
- throw "<beforeNode> must be a child of <this>";
- this.childList.splice(iBefore, 0, dtnode);
- // alert(this.childList);
- } else {
- // Append node
- this.childList.push(dtnode);
- }
- // --- Handle persistence
- // Initial status is read from cookies, if persistence is active and
- // cookies are already present.
- // Otherwise the status is read from the data attributes and then persisted.
- var isInitializing = tree.isInitializing();
- if( opts.persist && pers.cookiesFound && isInitializing ) {
- // Init status from cookies
- // tree.logDebug("init from cookie, pa=%o, dk=%o", pers.activeKey, dtnode.data.key);
- if( pers.activeKey == dtnode.data.key )
- tree.activeNode = dtnode;
- if( pers.focusedKey == dtnode.data.key )
- tree.focusNode = dtnode;
- dtnode.bExpanded = ($.inArray(dtnode.data.key, pers.expandedKeyList) >= 0);
- dtnode.bSelected = ($.inArray(dtnode.data.key, pers.selectedKeyList) >= 0);
- // tree.logDebug(" key=%o, bSelected=%o", dtnode.data.key, dtnode.bSelected);
- } else {
- // Init status from data (Note: we write the cookies after the init phase)
- // tree.logDebug("init from data");
- if( dtnode.data.activate ) {
- tree.activeNode = dtnode;
- if( opts.persist )
- pers.activeKey = dtnode.data.key;
- }
- if( dtnode.data.focus ) {
- tree.focusNode = dtnode;
- if( opts.persist )
- pers.focusedKey = dtnode.data.key;
- }
- dtnode.bExpanded = ( dtnode.data.expand == true ); // Collapsed by default
- if( dtnode.bExpanded && opts.persist )
- pers.addExpand(dtnode.data.key);
- dtnode.bSelected = ( dtnode.data.select == true ); // Deselected by default
- /*
- Doesn't work, cause pers.selectedKeyList may be null
- if( dtnode.bSelected && opts.selectMode==1
- && pers.selectedKeyList && pers.selectedKeyList.length>0 ) {
- tree.logWarning("Ignored multi-selection in single-mode for %o", dtnode);
- dtnode.bSelected = false; // Fixing bad input data (multi selection for mode:1)
- }
- */
- if( dtnode.bSelected && opts.persist )
- pers.addSelect(dtnode.data.key);
- }
- // Always expand, if it's below minExpandLevel
- // tree.logDebug ("%o._addChildNode(%o), l=%o", this, dtnode, dtnode.getLevel());
- if ( opts.minExpandLevel >= dtnode.getLevel() ) {
- // tree.logDebug ("Force expand for %o", dtnode);
- this.bExpanded = true;
- }
- // In multi-hier mode, update the parents selection state
- // issue #82: only if not initializing, because the children may not exist yet
- // if( !dtnode.data.isStatusNode && opts.selectMode==3 && !isInitializing )
- // dtnode._fixSelectionState();
- // In multi-hier mode, update the parents selection state
- if( dtnode.bSelected && opts.selectMode==3 ) {
- var p = this;
- while( p ) {
- if( !p.hasSubSel )
- p._setSubSel(true);
- p = p.parent;
- }
- }
- // render this node and the new child
- if ( tree.bEnableUpdate )
- this.render(true, true);
- return dtnode;
- },
- addChild: function(obj, beforeNode) {
- /**
- * Add a node object as child.
- *
- * This should be the only place, where a DynaTreeNode is constructed!
- * (Except for the root node creation in the tree constructor)
- *
- * @param obj A JS object (may be recursive) or an array of those.
- * @param {DynaTreeNode} beforeNode (optional) sibling node.
- *
- * Data format: array of node objects, with optional 'children' attributes.
- * [
- * { title: "t1", isFolder: true, ... }
- * { title: "t2", isFolder: true, ...,
- * children: [
- * {title: "t2.1", ..},
- * {..}
- * ]
- * }
- * ]
- * A simple object is also accepted instead of an array.
- *
- */
- // this.tree.logDebug("%o.addChild(%o, %o)", this, obj, beforeNode);
- if( !obj || obj.length==0 ) // Passed null or undefined or empty array
- return;
- if( obj instanceof DynaTreeNode )
- return this._addChildNode(obj, beforeNode);
- if( !obj.length ) // Passed a single data object
- obj = [ obj ];
- var prevFlag = this.tree.enableUpdate(false);
- var tnFirst = null;
- for (var i=0; i<obj.length; i++) {
- var data = obj[i];
- var dtnode = this._addChildNode(new DynaTreeNode(this, this.tree, data), beforeNode);
- if( !tnFirst ) tnFirst = dtnode;
- // Add child nodes recursively
- if( data.children )
- dtnode.addChild(data.children, null);
- }
- this.tree.enableUpdate(prevFlag);
- return tnFirst;
- },
- append: function(obj) {
- this.tree.logWarning("node.append() is deprecated (use node.addChild() instead).");
- return this.addChild(obj, null);
- },
- appendAjax: function(ajaxOptions) {
- this.removeChildren(false, true);
- this.setLazyNodeStatus(DTNodeStatus_Loading);
- // Ajax option inheritance: $.ajaxSetup < $.ui.dynatree.defaults.ajaxDefaults < tree.options.ajaxDefaults < ajaxOptions
- var self = this;
- var orgSuccess = ajaxOptions.success;
- var orgError = ajaxOptions.error;
- var options = $.extend({}, this.tree.options.ajaxDefaults, ajaxOptions, {
- /*
- complete: function(req, textStatus){
- alert("ajax complete");
- },
- timeout: 5000, // 5 sec
- */
- success: function(data, textStatus){
- if("1"!=data.FHZ){//出错了,弹出错误提醒
- if("CSRF" == data.FHZ){
- showMsg(data.MSG||'',3);
- return;
- }else if("-1" == data.FHZ){
- _FW.oFtl.fnAlert(data.MSG||'');
- var prevPhase = self.tree.phase;
- self.tree.phase = "init";
- self.tree.phase = "postInit";
- self.setLazyNodeStatus(DTNodeStatus_Ok);
- self.tree.phase = prevPhase;
- return;
- }
- }
- // <this> is the request options
- // self.tree.logDebug("appendAjax().success");
- var prevPhase = self.tree.phase;
- self.tree.phase = "init";
- // self.append(data);
- self.addChild(data, null);
- self.tree.phase = "postInit";
- self.setLazyNodeStatus(DTNodeStatus_Ok);
- if( orgSuccess )
- orgSuccess.call(options, self);
- self.tree.phase = prevPhase;
- },
- error: function(XMLHttpRequest, textStatus, errorThrown){
- // <this> is the request options
- // self.tree.logWarning("appendAjax failed: %o:\n%o\n%o", textStatus, XMLHttpRequest, errorThrown);
- self.tree.logWarning("appendAjax failed:", textStatus, ":\n", XMLHttpRequest, "\n", errorThrown);
- self.setLazyNodeStatus(DTNodeStatus_Error, {info: textStatus, tooltip: ""+errorThrown});
- if( orgError )
- orgError.call(options, self, XMLHttpRequest, textStatus, errorThrown);
- },
- beforeSend:function(XMLHttpRequest ){
- var cToken = $.cookie(headtoken) || token;XMLHttpRequest.setRequestHeader(headtoken,cToken);
- }
- });
- $.ajax(options);
- },
- // --- end of class
- lastentry: undefined
- }
- /*************************************************************************
- * class DynaTreeStatus
- */
- var DynaTreeStatus = Class.create();
- DynaTreeStatus._getTreePersistData = function(cookieId, cookieOpts) {
- // Static member: Return persistence information from cookies
- var ts = new DynaTreeStatus(cookieId, cookieOpts);
- ts.read();
- return ts.toDict();
- }
- // Make available in global scope
- getDynaTreePersistData = DynaTreeStatus._getTreePersistData;
- DynaTreeStatus.prototype = {
- // Constructor
- initialize: function(cookieId, cookieOpts) {
- this._log("DynaTreeStatus: initialize");
- if( cookieId === undefined )
- cookieId = $.ui.dynatree.defaults.cookieId;
- cookieOpts = $.extend({}, $.ui.dynatree.defaults.cookie, cookieOpts);
-
- this.cookieId = cookieId;
- this.cookieOpts = cookieOpts;
- this.cookiesFound = undefined;
- this.activeKey = null;
- this.focusedKey = null;
- this.expandedKeyList = null;
- this.selectedKeyList = null;
- },
- // member functions
- _log: function(msg) {
- // this.logDebug("_changeNodeList(%o): nodeList:%o, idx:%o", mode, nodeList, idx);
- Array.prototype.unshift.apply(arguments, ["debug"]);
- _log.apply(this, arguments);
- },
- read: function() {
- this._log("DynaTreeStatus: read");
- // Read or init cookies.
- this.cookiesFound = false;
-
- var cookie = $.cookie(this.cookieId + "-active");
- this.activeKey = ( cookie == null ) ? "" : cookie;
- if( cookie != null ) this.cookiesFound = true;
- cookie = $.cookie(this.cookieId + "-focus");
- this.focusedKey = ( cookie == null ) ? "" : cookie;
- if( cookie != null ) this.cookiesFound = true;
- cookie = $.cookie(this.cookieId + "-expand");
- this.expandedKeyList = ( cookie == null ) ? [] : cookie.split(",");
- if( cookie != null ) this.cookiesFound = true;
- cookie = $.cookie(this.cookieId + "-select");
- this.selectedKeyList = ( cookie == null ) ? [] : cookie.split(",");
- if( cookie != null ) this.cookiesFound = true;
- },
- write: function() {
- this._log("DynaTreeStatus: write");
- $.cookie(this.cookieId + "-active", ( this.activeKey == null ) ? "" : this.activeKey, this.cookieOpts);
- $.cookie(this.cookieId + "-focus", ( this.focusedKey == null ) ? "" : this.focusedKey, this.cookieOpts);
- $.cookie(this.cookieId + "-expand", ( this.expandedKeyList == null ) ? "" : this.expandedKeyList.join(","), this.cookieOpts);
- $.cookie(this.cookieId + "-select", ( this.selectedKeyList == null ) ? "" : this.selectedKeyList.join(","), this.cookieOpts);
- },
- addExpand: function(key) {
- this._log("addExpand(%o)", key);
- if( $.inArray(key, this.expandedKeyList) < 0 ) {
- this.expandedKeyList.push(key);
- $.cookie(this.cookieId + "-expand", this.expandedKeyList.join(","), this.cookieOpts);
- }
- },
- clearExpand: function(key) {
- this._log("clearExpand(%o)", key);
- var idx = $.inArray(key, this.expandedKeyList);
- if( idx >= 0 ) {
- this.expandedKeyList.splice(idx, 1);
- $.cookie(this.cookieId + "-expand", this.expandedKeyList.join(","), this.cookieOpts);
- }
- },
- addSelect: function(key) {
- this._log("addSelect(%o)", key);
- if( $.inArray(key, this.selectedKeyList) < 0 ) {
- this.selectedKeyList.push(key);
- $.cookie(this.cookieId + "-select", this.selectedKeyList.join(","), this.cookieOpts);
- }
- },
- clearSelect: function(key) {
- this._log("clearSelect(%o)", key);
- var idx = $.inArray(key, this.selectedKeyList);
- if( idx >= 0 ) {
- this.selectedKeyList.splice(idx, 1);
- $.cookie(this.cookieId + "-select", this.selectedKeyList.join(","), this.cookieOpts);
- }
- },
- isReloading: function() {
- return this.cookiesFound == true;
- },
- toDict: function() {
- return {
- cookiesFound: this.cookiesFound,
- activeKey: this.activeKey,
- focusedKey: this.activeKey,
- expandedKeyList: this.expandedKeyList,
- selectedKeyList: this.selectedKeyList
- };
- },
- // --- end of class
- lastentry: undefined
- };
- /*************************************************************************
- * class DynaTree
- */
- var DynaTree = Class.create();
- // --- Static members ----------------------------------------------------------
- DynaTree.version = "$Version: 0.5.4$";
- /*
- DynaTree._initTree = function() {
- };
- DynaTree._bind = function() {
- };
- */
- //--- Class members ------------------------------------------------------------
- DynaTree.prototype = {
- // Constructor
- // initialize: function(divContainer, options) {
- initialize: function($widget) {
- // instance members
- this.phase = "init";
- this.$widget = $widget;
- this.options = $widget.options;
- this.$tree = $widget.element;
- // find container element
- this.divTree = this.$tree.get(0);
- },
- // member functions
- _load: function() {
- var $widget = this.$widget;
- var opts = this.options;
- this.bEnableUpdate = true;
- this._nodeCount = 1;
- this.activeNode = null;
- this.focusNode = null;
- // If a 'options.classNames' dictionary was passed, still use defaults
- // for undefined classes:
- if( opts.classNames !== $.ui.dynatree.defaults.classNames ) {
- opts.classNames = $.extend({}, $.ui.dynatree.defaults.classNames, opts.classNames);
- }
- // Guess skin path, if not specified
- if(!opts.imagePath) {
- $("script").each( function () {
- // Eclipse syntax parser breaks on this expression, so put it at the bottom:
- if( this.src.search(_rexDtLibName) >= 0 ) {
- if( this.src.indexOf("/")>=0 ) // issue #47
- opts.imagePath = this.src.slice(0, this.src.lastIndexOf("/")) + "/skin/";
- else
- opts.imagePath = "skin/";
- // logMsg("Guessing imagePath from '%s': '%s'", this.src, opts.imagePath);
- return false; // first match
- }
- });
- }
-
- this.persistence = new DynaTreeStatus(opts.cookieId, opts.cookie);
- if( opts.persist ) {
- if( !$.cookie )
- _log("warn", "Please include jquery.cookie.js to use persistence.");
- this.persistence.read();
- }
- this.logDebug("DynaTree.persistence: %o", this.persistence.toDict());
- // Cached tag strings
- this.cache = {
- tagEmpty: "<span class='" + opts.classNames.empty + "'></span>",
- tagVline: "<span class='" + opts.classNames.vline + "'></span>",
- tagExpander: "<span class='" + opts.classNames.expander + "'></span>",
- tagConnector: "<span class='" + opts.classNames.connector + "'></span>",
- tagNodeIcon: "<span class='" + opts.classNames.nodeIcon + "'></span>",
- tagCheckbox: "<span class='" + opts.classNames.checkbox + "'></span>",
- lastentry: undefined
- };
- // Clear container, in case it contained some 'waiting' or 'error' text
- // for clients that don't support JS.
- // We don't do this however, if we try to load from an embedded UL element.
- if( opts.children || (opts.initAjax && opts.initAjax.url) || opts.initId )
- $(this.divTree).empty();
- else if( this.divRoot )
- $(this.divRoot).remove();
- // create the root element
- this.tnRoot = new DynaTreeNode(null, this, {title: opts.title, key: "root"});
- this.tnRoot.data.isFolder = true;
- this.tnRoot.render(false, false);
- this.divRoot = this.tnRoot.div;
- this.divRoot.className = opts.classNames.container;
- // add root to container
- // TODO: this should be delayed until all children have been created for performance reasons
- this.divTree.appendChild(this.divRoot);
- var root = this.tnRoot;
- var isReloading = ( opts.persist && this.persistence.isReloading() );
- var isLazy = false;
- var prevFlag = this.enableUpdate(false);
- this.logDebug("Dynatree._load(): read tree structure...");
- // Init tree structure
- if( opts.children ) {
- // Read structure from node array
- root.addChild(opts.children);
- } else if( opts.initAjax && opts.initAjax.url ) {
- // Init tree from AJAX request
- isLazy = true;
- root.data.isLazy = true;
- this._reloadAjax();
- } else if( opts.initId ) {
- // Init tree from another UL element
- this._createFromTag(root, $("#"+opts.initId));
- } else {
- // Init tree from the first UL element inside the container <div>
- var $ul = this.$tree.find(">ul").hide();
- this._createFromTag(root, $ul);
- $ul.remove();
- }
-
- this._checkConsistency();
- // Render html markup
- this.logDebug("Dynatree._load(): render nodes...");
- this.enableUpdate(prevFlag);
-
- // bind event handlers
- this.logDebug("Dynatree._load(): bind events...");
- this.$widget.bind();
- // --- Post-load processing
- this.logDebug("Dynatree._load(): postInit...");
- this.phase = "postInit";
-
- // In persist mode, make sure that cookies are written, even if they are empty
- if( opts.persist ) {
- this.persistence.write();
- }
-
- // Set focus, if possible (this will also fire an event and write a cookie)
- if( this.focusNode && this.focusNode.isVisible() ) {
- this.logDebug("Focus on init: %o", this.focusNode);
- this.focusNode.focus();
- }
- if( !isLazy && opts.onPostInit ) {
- opts.onPostInit.call(this, isReloading, false);
- }
- this.phase = "idle";
- },
-
- _reloadAjax: function() {
- // Reload
- var opts = this.options;
- if( ! opts.initAjax || ! opts.initAjax.url )
- throw "tree.reload() requires 'initAjax' mode.";
- var pers = this.persistence;
- var ajaxOpts = $.extend({}, opts.initAjax);
- // Append cookie info to the request
- // this.logDebug("reloadAjax: key=%o, an.key:%o", pers.activeKey, this.activeNode?this.activeNode.data.key:"?");
- if( ajaxOpts.addActiveKey )
- ajaxOpts.data.activeKey = pers.activeKey;
- if( ajaxOpts.addFocusedKey )
- ajaxOpts.data.focusedKey = pers.focusedKey;
- if( ajaxOpts.addExpandedKeyList )
- ajaxOpts.data.expandedKeyList = pers.expandedKeyList.join(",");
- if( ajaxOpts.addSelectedKeyList )
- ajaxOpts.data.selectedKeyList = pers.selectedKeyList.join(",");
- // Set up onPostInit callback to be called when Ajax returns
- if( opts.onPostInit ) {
- if( ajaxOpts.success )
- this.logWarning("initAjax: success callback is ignored when onPostInit was specified.");
- if( ajaxOpts.error )
- this.logWarning("initAjax: error callback is ignored when onPostInit was specified.");
- var isReloading = pers.isReloading();
- ajaxOpts["success"] = function(dtnode) { opts.onPostInit.call(dtnode.tree, isReloading, false); };
- ajaxOpts["error"] = function(dtnode) { opts.onPostInit.call(dtnode.tree, isReloading, true); };
- }
- this.logDebug("Dynatree._init(): send Ajax request...");
- this.tnRoot.appendAjax(ajaxOpts);
- },
- toString: function() {
- return "DynaTree '" + this.options.title + "'";
- },
- toDict: function() {
- return this.tnRoot.toDict(true);
- },
-
- getPersistData: function() {
- return this.persistence.toDict();
- },
-
- logDebug: function(msg) {
- if( this.options.debugLevel >= 2 ) {
- Array.prototype.unshift.apply(arguments, ["debug"]);
- _log.apply(this, arguments);
- }
- },
- logInfo: function(msg) {
- if( this.options.debugLevel >= 1 ) {
- Array.prototype.unshift.apply(arguments, ["info"]);
- _log.apply(this, arguments);
- }
- },
- logWarning: function(msg) {
- Array.prototype.unshift.apply(arguments, ["warn"]);
- _log.apply(this, arguments);
- },
- isInitializing: function() {
- return ( this.phase=="init" || this.phase=="postInit" );
- },
- isReloading: function() {
- return ( this.phase=="init" || this.phase=="postInit" ) && this.options.persist && this.persistence.cookiesFound;
- },
- isUserEvent: function() {
- return ( this.phase=="userEvent" );
- },
- redraw: function() {
- this.logDebug("dynatree.redraw()...");
- this.tnRoot.render(true, true);
- this.logDebug("dynatree.redraw() done.");
- },
- reloadAjax: function() {
- this.logWarning("tree.reloadAjax() is deprecated since v0.5.2 (use reload() instead).");
- },
-
- reload: function() {
- this._load();
- },
-
- getRoot: function() {
- return this.tnRoot;
- },
- getNodeByKey: function(key) {
- // $("#...") has problems, if the key contains '.', so we use getElementById()
- // return $("#" + this.options.idPrefix + key).attr("dtnode");
- var el = document.getElementById(this.options.idPrefix + key);
- return ( el && el.dtnode ) ? el.dtnode : null;
- },
- getActiveNode: function() {
- return this.activeNode;
- },
-
- reactivate: function(setFocus) {
- // Re-fire onQueryActivate and onActivate events.
- var node = this.activeNode;
- // this.logDebug("reactivate %o", node);
- if( node ) {
- this.activeNode = null; // Force re-activating
- node.activate();
- if( setFocus )
- node.focus();
- }
- },
- getSelectedNodes: function(stopOnParents) {
- var nodeList = [];
- this.tnRoot.visit(function(dtnode){
- if( dtnode.bSelected ) {
- nodeList.push(dtnode);
- if( stopOnParents == true )
- return false; // stop processing this branch
- }
- });
- return nodeList;
- },
- activateKey: function(key) {
- var dtnode = (key === null) ? null : this.getNodeByKey(key);
- if( !dtnode ) {
- if( this.activeNode )
- this.activeNode.deactivate();
- this.activeNode = null;
- return null;
- }
- dtnode.focus();
- dtnode.activate();
- return dtnode;
- },
- selectKey: function(key, select) {
- var dtnode = this.getNodeByKey(key);
- if( !dtnode )
- return null;
- dtnode.select(select);
- return dtnode;
- },
- enableUpdate: function(bEnable) {
- if ( this.bEnableUpdate==bEnable )
- return bEnable;
- this.bEnableUpdate = bEnable;
- if ( bEnable )
- this.redraw();
- return !bEnable; // return previous value
- },
- visit: function(fn, data, includeRoot) {
- return this.tnRoot.visit(fn, data, includeRoot);
- },
- _createFromTag: function(parentTreeNode, $ulParent) {
- // Convert a <UL>...</UL> list into children of the parent tree node.
- var self = this;
- /*
- TODO: better?
- this.$lis = $("li:has(a[href])", this.element);
- this.$tabs = this.$lis.map(function() { return $("a", this)[0]; });
- */
- $ulParent.find(">li").each(function() {
- var $li = $(this);
- var $liSpan = $li.find(">span:first");
- var title;
- if( $liSpan.length ) {
- // If a <li><span> tag is specified, use it literally.
- title = $liSpan.html();
- } else {
- // If only a <li> tag is specified, use the trimmed string up to the next child <ul> tag.
- title = $li.html();
- var iPos = title.search(/<ul/i);
- if( iPos>=0 )
- title = $.trim(title.substring(0, iPos));
- else
- title = $.trim(title);
- // self.logDebug("%o", title);
- }
- // Parse node options from ID, title and class attributes
- var data = {
- title: title,
- isFolder: $li.hasClass("folder"),
- isLazy: $li.hasClass("lazy"),
- expand: $li.hasClass("expanded"),
- select: $li.hasClass("selected"),
- activate: $li.hasClass("active"),
- focus: $li.hasClass("focused")
- };
- if( $li.attr("title") )
- data.tooltip = $li.attr("title");
- if( $li.attr("id") )
- data.key = $li.attr("id");
- // If a data attribute is present, evaluate as a JavaScript object
- if( $li.attr("data") ) {
- var dataAttr = $.trim($li.attr("data"));
- if( dataAttr ) {
- if( dataAttr.charAt(0) != "{" )
- dataAttr = "{" + dataAttr + "}"
- try {
- $.extend(data, eval("(" + dataAttr + ")"));
- } catch(e) {
- throw ("Error parsing node data: " + e + "\ndata:\n'" + dataAttr + "'");
- }
- }
- }
- childNode = parentTreeNode.addChild(data);
- // Recursive reading of child nodes, if LI tag contains an UL tag
- var $ul = $li.find(">ul:first");
- if( $ul.length ) {
- self._createFromTag(childNode, $ul); // must use 'self', because 'this' is the each() context
- }
- });
- },
- _checkConsistency: function() {
- // this.logDebug("tree._checkConsistency() NOT IMPLEMENTED - %o", this);
- },
-
- // --- end of class
- lastentry: undefined
- };
- /*************************************************************************
- * widget $(..).dynatree
- */
- $.widget("ui.dynatree", {
- init: function() {
- // ui.core 1.6 renamed init() to _init(): this stub assures backward compatibility
- _log("warn", "ui.dynatree.init() was called; you should upgrade to ui.core.js v1.6 or higher.");
- return this._init();
- },
- _init: function() {
- if( parseFloat($.ui.version) < 1.8 ) {
- // jquery.ui.core 1.8 renamed _init() to _create(): this stub assures backward compatibility
- _log("info", "ui.dynatree._init() was called; consider upgrading to jquery.ui.core.js v1.8 or higher.");
- return this._create();
- }
- // jquery.ui.core 1.8 still uses _init() to perform "default functionality"
- _log("debug", "ui.dynatree._init() was called; no current default functionality.");
- },
- _create: function() {
- if( parseFloat($.ui.version) >= 1.8 ) {
- this.options = $.extend(true, {}, $[this.namespace][this.widgetName].defaults, this.options);
- }
- logMsg("Dynatree._create(): version='%s', debugLevel=%o.", DynaTree.version, this.options.debugLevel);
- var opts = this.options;
- // The widget framework supplies this.element and this.options.
- this.options.event += ".dynatree"; // namespace event
- var divTree = this.element.get(0);
- /* // Clear container, in case it contained some 'waiting' or 'error' text
- // for clients that don't support JS
- if( opts.children || (opts.initAjax && opts.initAjax.url) || opts.initId )
- $(divTree).empty();
- */
- // Create the DynaTree object
- this.tree = new DynaTree(this);
- this.tree._load();
- this.tree.logDebug("Dynatree._create(): done.");
- },
- bind: function() {
- var $this = this.element;
- var o = this.options;
- // Prevent duplicate binding
- this.unbind();
-
- // Tool function to get dtnode from the event target:
- function __getNodeFromElement(el) {
- var iMax = 5;
- while( el && iMax-- ) {
- if( el.dtnode ) return el.dtnode;
- el = el.parentNode;
- };
- return null;
- }
- var eventNames = "click.dynatree dblclick.dynatree";
- if( o.keyboard ) // Note: leading ' '!
- eventNames += " keypress.dynatree keydown.dynatree";
- $this.bind(eventNames, function(event){
- var dtnode = __getNodeFromElement(event.target);
- if( !dtnode )
- return true; // Allow bubbling of other events
- var prevPhase = dtnode.tree.phase;
- dtnode.tree.phase = "userEvent";
- try {
- dtnode.tree.logDebug("bind(%o): dtnode: %o", event, dtnode);
- switch(event.type) {
- case "click":
- return ( o.onClick && o.onClick(dtnode, event)===false ) ? false : dtnode.onClick(event);
- case "dblclick":
- return ( o.onDblClick && o.onDblClick(dtnode, event)===false ) ? false : dtnode.onDblClick(event);
- case "keydown":
- return ( o.onKeydown && o.onKeydown(dtnode, event)===false ) ? false : dtnode.onKeydown(event);
- case "keypress":
- return ( o.onKeypress && o.onKeypress(dtnode, event)===false ) ? false : dtnode.onKeypress(event);
- };
- } catch(e) {
- var _ = null; // issue 117
- // dtnode.tree.logError("bind(%o): dtnode: %o", event, dtnode);
- } finally {
- dtnode.tree.phase = prevPhase;
- }
- });
-
- // focus/blur don't bubble, i.e. are not delegated to parent <div> tags,
- // so we use the addEventListener capturing phase.
- // See http://www.howtocreate.co.uk/tutorials/javascript/domevents
- function __focusHandler(event) {
- // Handles blur and focus.
- // Fix event for IE:
- event = arguments[0] = $.event.fix( event || window.event );
- var dtnode = __getNodeFromElement(event.target);
- return dtnode ? dtnode.onFocus(event) : false;
- }
- var div = this.tree.divTree;
- if( div.addEventListener ) {
- div.addEventListener("focus", __focusHandler, true);
- div.addEventListener("blur", __focusHandler, true);
- } else {
- div.onfocusin = div.onfocusout = __focusHandler;
- }
- // EVENTS
- // disable click if event is configured to something else
- // if (!(/^click/).test(o.event))
- // this.$tabs.bind("click.tabs", function() { return false; });
-
- },
-
- unbind: function() {
- this.element.unbind(".dynatree");
- },
-
- /* TODO: we could handle option changes during runtime here (maybe to re-render, ...)
- setData: function(key, value) {
- this.tree.logDebug("dynatree.setData('" + key + "', '" + value + "')");
- },
- */
- enable: function() {
- this.bind();
- // Call default disable(): remove -disabled from css:
- $.widget.prototype.enable.apply(this, arguments);
- },
-
- disable: function() {
- this.unbind();
- // Call default disable(): add -disabled to css:
- $.widget.prototype.disable.apply(this, arguments);
- },
-
- // --- getter methods (i.e. NOT returning a reference to $)
- getTree: function() {
- return this.tree;
- },
- getRoot: function() {
- return this.tree.getRoot();
- },
- getActiveNode: function() {
- return this.tree.getActiveNode();
- },
- getSelectedNodes: function() {
- return this.tree.getSelectedNodes();
- },
- // ------------------------------------------------------------------------
- lastentry: undefined
- });
- // The following methods return a value (thus breaking the jQuery call chain):
- $.ui.dynatree.getter = "getTree getRoot getActiveNode getSelectedNodes";
- // Plugin default options:
- $.ui.dynatree.defaults = {
- title: "Dynatree root", // Name of the root node.
- rootVisible: false, // Set to true, to make the root node visible.
- minExpandLevel: 1, // 1: root node is not collapsible
- imagePath: null, // Path to a folder containing icons. Defaults to 'skin/' subdirectory.
- children: null, // Init tree structure from this object array.
- initId: null, // Init tree structure from a <ul> element with this ID.
- initAjax: null, // Ajax options used to initialize the tree strucuture.
- autoFocus: true, // Set focus to first child, when expanding or lazy-loading.
- keyboard: true, // Support keyboard navigation.
- persist: false, // Persist expand-status to a cookie
- autoCollapse: false, // Automatically collapse all siblings, when a node is expanded.
- clickFolderMode: 3, // 1:activate, 2:expand, 3:activate and expand
- activeVisible: true, // Make sure, active nodes are visible (expanded).
- checkbox: false, // Show checkboxes.
- selectMode: 2, // 1:single, 2:multi, 3:multi-hier
- fx: null, // Animations, e.g. null or { height: "toggle", duration: 200 }
- // Low level event handlers: onEvent(dtnode, event): return false, to stop default processing
- onClick: null, // null: generate focus, expand, activate, select events.
- onDblClick: null, // (No default actions.)
- onKeydown: null, // null: generate keyboard navigation (focus, expand, activate).
- onKeypress: null, // (No default actions.)
- onFocus: null, // null: set focus to node.
- onBlur: null, // null: remove focus from node.
- // Pre-event handlers onQueryEvent(flag, dtnode): return false, to stop processing
- onQueryActivate: null, // Callback(flag, dtnode) before a node is (de)activated.
- onQuerySelect: null, // Callback(flag, dtnode) before a node is (de)selected.
- onQueryExpand: null, // Callback(flag, dtnode) before a node is expanded/collpsed.
-
- // High level event handlers
- onPostInit: null, // Callback(isReloading, isError) when tree was (re)loaded.
- onActivate: null, // Callback(dtnode) when a node is activated.
- onDeactivate: null, // Callback(dtnode) when a node is deactivated.
- onSelect: null, // Callback(flag, dtnode) when a node is (de)selected.
- onExpand: null, // Callback(dtnode) when a node is expanded/collapsed.
- onLazyRead: null, // Callback(dtnode) when a lazy node is expanded for the first time.
-
- ajaxDefaults: { // Used by initAjax option
- cache: false, // false: Append random '_' argument to the request url to prevent caching.
- dataType: "json" // Expect json format and pass json object to callbacks.
- },
- strings: {
- loading: "Loading…",
- loadError: "Load error!"
- },
- idPrefix: "ui-dynatree-id-", // Used to generate node id's like <span id="ui-dynatree-id-<key>">.
- // cookieId: "ui-dynatree-cookie", // Choose a more unique name, to allow multiple trees.
- cookieId: "dynatree", // Choose a more unique name, to allow multiple trees.
- cookie: {
- expires: null //7, // Days or Date; null: session cookie
- // path: "/", // Defaults to current page
- // domain: "jquery.com",
- // secure: true
- },
- // Class names used, when rendering the HTML markup.
- // Note: if only single entries are passed for options.classNames, all other
- // values are still set to default.
- classNames: {
- container: "ui-dynatree-container",
- folder: "ui-dynatree-folder",
- document: "ui-dynatree-document",
-
- empty: "ui-dynatree-empty",
- vline: "ui-dynatree-vline",
- expander: "ui-dynatree-expander",
- connector: "ui-dynatree-connector",
- checkbox: "ui-dynatree-checkbox",
- nodeIcon: "ui-dynatree-icon",
- title: "ui-dynatree-title",
-
- nodeError: "ui-dynatree-statusnode-error",
- nodeWait: "ui-dynatree-statusnode-wait",
- hidden: "ui-dynatree-hidden",
- combinedExpanderPrefix: "ui-dynatree-exp-",
- combinedIconPrefix: "ui-dynatree-ico-",
- // disabled: "ui-dynatree-disabled",
- hasChildren: "ui-dynatree-has-children",
- active: "ui-dynatree-active",
- selected: "ui-dynatree-selected",
- expanded: "ui-dynatree-expanded",
- lazy: "ui-dynatree-lazy",
- focused: "ui-dynatree-focused",
- partsel: "ui-dynatree-partsel",
- lastsib: "ui-dynatree-lastsib"
- },
- debugLevel: 1,
- // ------------------------------------------------------------------------
- lastentry: undefined
- };
- /**
- * Reserved data attributes for a tree node.
- */
- $.ui.dynatree.nodedatadefaults = {
- title: null, // (required) Displayed name of the node (html is allowed here)
- key: null, // May be used with activate(), select(), find(), ...
- isFolder: false, // Use a folder icon. Also the node is expandable but not selectable.
- isLazy: false, // Call onLazyRead(), when the node is expanded for the first time to allow for delayed creation of children.
- tooltip: null, // Show this popup text.
- icon: null, // Use a custom image (filename relative to tree.options.imagePath). 'null' for default icon, 'false' for no icon.
- addClass: null, // Class name added to the node's span tag.
- activate: false, // Initial active status.
- focus: false, // Initial focused status.
- expand: false, // Initial expanded status.
- select: false, // Initial selected status.
- hideCheckbox: false, // Suppress checkbox display for this node.
- unselectable: false, // Prevent selection.
- // disabled: false,
- // The following attributes are only valid if passed to some functions:
- children: null, // Array of child nodes.
- // NOTE: we can also add custom attributes here.
- // This may then also be used in the onActivate(), onSelect() or onLazyTree() callbacks.
- // ------------------------------------------------------------------------
- lastentry: undefined
- };
- // ---------------------------------------------------------------------------
- })(jQuery);
- // Eclipse syntax parser breaks on this expression, so we put it at the bottom.
- var _rexDtLibName = /.*dynatree[^/]*\.js$/i;
- /*
- * Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
- * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * - Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * - Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * - Neither the name of Oracle nor the names of its
- * contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
- * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
- /*
- * deployJava.js
- *
- * This file is part of the Deployment Toolkit. It provides functions for web
- * pages to detect the presence of a JRE, install the latest JRE, and easily run
- * applets or Web Start programs. More Information on usage of the
- * Deployment Toolkit can be found in the Deployment Guide at:
- * http://docs.oracle.com/javase/6/docs/technotes/guides/jweb/index.html
- *
- * The "live" copy of this file may be found at :
- * http://java.com/js/deployJava.js.
- * For web pages provisioned using https, you may want to access the copy at:
- * https://java.com/js/deployJava.js.
- *
- * You are encouraged to link directly to the live copies.
- * The above files are stripped of comments and whitespace for performance,
- * You can access this file w/o the whitespace and comments removed at:
- * http://java.com/js/deployJava.txt.
- *
- */
- /* The following regular expression is used as the base for the parsing
- * of the version string. The version string could be either in the old format
- * (1.7.0_65, 1.7.0, 1.7) or in the new format (9.1.2.3, 9.1.2, 9.1, 9)
- * and must include only VNUM parts of the version string (the full
- * version string format is $VNUM(-$PRE)?(\+$BUILD)?(-$OPT)?, see JEP 223 for more details)
- *
- * ^ - Beginning of the string
- * ( - Capturing group 1
- * \\d+ - Match any digit one or more times
- * ) - Match once
- * (?: - Non capturing group
- * \\. - Match '.' character
- * ( - Capturing group 2
- * \\d+ - Match any digit one or more times
- * ) - Match once
- * (?: - Non capturing group
- * \\. - Match '.' character
- * ( - Capturing group 3
- * \\d+ - Match any digit one or more times
- * ) - Match once
- * (?: - Non capturing group
- * [_\\.] - Math '_' (old version format) or '.' (new version format)
- * ( - Capturing group 4
- * \\d+ - Match any digit one or more times
- * ) - Match once
- * )? - Match zero or one time
- * )? - Match zero or one time
- * )? - Match zero or one time
- *
- *
- *
- */
- var version_regex_base = "^(\\d+)(?:\\.(\\d+)(?:\\.(\\d+)(?:[_\\.](\\d+))?)?)?";
- /*
- * version_regex_base - see version_regex_base comment above
- * $ - End of the string
- *
- */
- var version_regex_strict = version_regex_base + "$";
- /*
- * version_regex_base - see version_regex_base comment above
- * ( - Capturing group 5
- * \\* - Match '*'
- * | - OR
- * \\+ - Match '+'
- * )? - Match zero or one time
- * $ - End of string
- *
- */
- var version_regex_with_family_modifier = version_regex_base + "(\\*|\\+)?$";
- var deployJava = function() {
- /** HTML attribute filter implementation */
- var hattrs = {
- core: [ 'id', 'class', 'title', 'style' ],
- i18n: [ 'lang', 'dir' ],
- events: [ 'onclick', 'ondblclick', 'onmousedown', 'onmouseup',
- 'onmouseover', 'onmousemove', 'onmouseout', 'onkeypress',
- 'onkeydown', 'onkeyup' ],
- applet: [ 'codebase', 'code', 'name', 'archive', 'object',
- 'width', 'height', 'alt', 'align', 'hspace', 'vspace' ],
- object: [ 'classid', 'codebase', 'codetype', 'data', 'type',
- 'archive', 'declare', 'standby', 'height', 'width', 'usemap',
- 'name', 'tabindex', 'align', 'border', 'hspace', 'vspace' ]
- };
- var object_valid_attrs = hattrs.object.concat(hattrs.core, hattrs.i18n,
- hattrs.events);
- var applet_valid_attrs = hattrs.applet.concat(hattrs.core);
- // generic log function, use console.log unless it isn't available
- // then revert to alert()
- function log(message) {
- if ( ! rv.debug ) {return};
- if (console.log) {
- console.log(message);
- } else {
- alert(message);
- }
- }
- //checks where given version string matches query
- //
- //NB: assume format is correct. Can add format check later if needed
- // from dtjava.js
- function versionCheckEx(query, version) {
- if (query == null || query.length == 0) return true;
- var c = query.charAt(query.length - 1);
- //if it is not explicit pattern but does not have update version then need to append *
- if (c != '+' && c != '*' && (query.indexOf('_') != -1 && c != '_')) {
- query = query + "*";
- c = '*';
- }
- query = query.substring(0, query.length - 1);
- //if query ends with ".", "_" then we want to strip it to allow match of "1.6.*" to shorter form such as "1.6"
- //TODO: add support for match of "1.7.0*" to "1.7"?
- if (query.length > 0) {
- var z = query.charAt(query.length - 1);
- if (z == '.' || z == '_') {
- query = query.substring(0, query.length - 1);
- }
- }
- if (c == '*') {
- //it is match if version starts from it
- return (version.indexOf(query) == 0);
- } else if (c == '+') {
- //match if query string is lexicographically smaller
- return query <= version;
- }
- return false;
- }
- function getWebStartLaunchIconURL() {
- var imageUrl = '//java.com/js/webstart.png';
- try {
- // for http/https; use protocol less url; use http for all other protocol
- return document.location.protocol.indexOf('http') != -1 ?
- imageUrl : 'http:' + imageUrl;
- } catch (err) {
- return 'http:' + imageUrl;
- }
- }
- // GetJava page
- function constructGetJavaURL(query) {
-
- var getJavaURL = 'http://java.com/dt-redirect';
- if (query == null || query.length == 0) return getJavaURL;
- if(query.charAt(0) == '&')
- {
- query = query.substring(1, query.length);
- }
- return getJavaURL + '?'+ query;
- }
- function arHas(ar, attr) {
- var len = ar.length;
- for (var i = 0; i < len; i++) {
- if (ar[i] === attr) return true;
- }
- return false;
- }
- function isValidAppletAttr(attr) {
- return arHas(applet_valid_attrs, attr.toLowerCase());
- }
- function isValidObjectAttr(attr) {
- return arHas(object_valid_attrs, attr.toLowerCase());
- }
- /**
- * returns true if we can enable DT plugin auto-install without chance of
- * deadlock on cert mismatch dialog
- *
- * requestedJREVersion param is optional - if null, it will be
- * treated as installing any JRE version
- *
- * DT plugin for 6uX only knows about JRE installer signed by SUN cert.
- * If it encounter Oracle signed JRE installer, it will have chance of
- * deadlock when running with IE. This function is to guard against this.
- */
- function enableWithoutCertMisMatchWorkaround(requestedJREVersion) {
- // Non-IE browser are okay
- if ('MSIE' != deployJava.browserName) return true;
- // if DT plugin is 10.0.0 or above, return true
- // This is because they are aware of both SUN and Oracle signature and
- // will not show cert mismatch dialog that might cause deadlock
- if (deployJava.compareVersionToPattern(deployJava.getPlugin().version,
- ["10", "0", "0"], false, true)) {
- return true;
- }
- // If we got there, DT plugin is 6uX
- if (requestedJREVersion == null) {
- // if requestedJREVersion is not defined - it means ANY.
- // can not guarantee it is safe to install ANY version because 6uX
- // DT does not know about Oracle certificates and may deadlock
- return false;
- }
- // 6u32 or earlier JRE installer used Sun certificate
- // 6u33+ uses Oracle's certificate
- // DT in JRE6 does not know about Oracle certificate => can only
- // install 6u32 or earlier without risk of deadlock
- return !versionCheckEx("1.6.0_33+", requestedJREVersion);
- }
- /* HTML attribute filters */
- var rv = {
- debug: null,
- /* version of deployJava.js */
- version: "20120801",
- firefoxJavaVersion: null,
- myInterval: null,
- preInstallJREList: null,
- returnPage: null,
- brand: null,
- locale: null,
- installType: null,
- EAInstallEnabled: false,
- EarlyAccessURL: null,
- // mime-type of the DeployToolkit plugin object
- oldMimeType: 'application/npruntime-scriptable-plugin;DeploymentToolkit',
- mimeType: 'application/java-deployment-toolkit',
- /* location of the Java Web Start launch button graphic is right next to
- * deployJava.js at:
- * http://java.com/js/webstart.png
- *
- * Use protocol less url here for http/https support
- */
- launchButtonPNG: getWebStartLaunchIconURL(),
- browserName: null,
- browserName2: null,
- /**
- * Returns an array of currently-installed JRE version strings.
- * Version strings are of the form #.#[.#[_#]], with the function returning
- * as much version information as it can determine, from just family
- * versions ("1.4.2", "1.5") through the full version ("1.5.0_06").
- *
- * Detection is done on a best-effort basis. Under some circumstances
- * only the highest installed JRE version will be detected, and
- * JREs older than 1.4.2 will not always be detected.
- */
- getJREs: function() {
- var list = new Array();
- if (this.isPluginInstalled()) {
- var plugin = this.getPlugin();
- var VMs = plugin.jvms;
- for (var i = 0; i < VMs.getLength(); i++) {
- list[i] = VMs.get(i).version;
- }
- } else {
- var browser = this.getBrowser();
- if (browser == 'MSIE') {
- if (this.testUsingActiveX('1.7.0')) {
- list[0] = '1.7.0';
- } else if (this.testUsingActiveX('1.6.0')) {
- list[0] = '1.6.0';
- } else if (this.testUsingActiveX('1.5.0')) {
- list[0] = '1.5.0';
- } else if (this.testUsingActiveX('1.4.2')) {
- list[0] = '1.4.2';
- } else if (this.testForMSVM()) {
- list[0] = '1.1';
- }
- } else if (browser == 'Netscape Family') {
- this.getJPIVersionUsingMimeType();
- if (this.firefoxJavaVersion != null) {
- list[0] = this.firefoxJavaVersion;
- } else if (this.testUsingMimeTypes('1.7')) {
- list[0] = '1.7.0';
- } else if (this.testUsingMimeTypes('1.6')) {
- list[0] = '1.6.0';
- } else if (this.testUsingMimeTypes('1.5')) {
- list[0] = '1.5.0';
- } else if (this.testUsingMimeTypes('1.4.2')) {
- list[0] = '1.4.2';
- } else if (this.browserName2 == 'Safari') {
- if (this.testUsingPluginsArray('1.7.0')) {
- list[0] = '1.7.0';
- } else if (this.testUsingPluginsArray('1.6')) {
- list[0] = '1.6.0';
- } else if (this.testUsingPluginsArray('1.5')) {
- list[0] = '1.5.0';
- } else if (this.testUsingPluginsArray('1.4.2')) {
- list[0] = '1.4.2';
- }
- }
- }
- }
- if (this.debug) {
- for (var i = 0; i < list.length; ++i) {
- log('[getJREs()] We claim to have detected Java SE ' + list[i]);
- }
- }
- return list;
- },
- /**
- * Triggers a JRE installation. The exact effect of triggering an
- * installation varies based on platform, browser, and if the
- * Deployment Toolkit plugin is installed.
- *
- * The requestVersion string is of the form #[.#[.#[_#]]][+|*],
- * which includes strings such as "1.4", "1.5.0*", and "1.6.0_02+".
- * A star (*) means "any version starting within this family" and
- * a plus (+) means "any version greater or equal to this".
- * "1.5.0*" * matches 1.5.0_06 but not 1.6.0_01, whereas
- * "1.5.0+" matches both.
- *
- * installCallback is an optional argument which holds a reference
- * to a javascript callback function for reporting install status.
- *
- * If the Deployment Toolkit plugin is not present, this will just call
- * this.installLatestJRE().
- */
- installJRE: function(requestVersion, installCallback) {
- var ret = false;
- if (this.isPluginInstalled() &&
- this.isAutoInstallEnabled(requestVersion)) {
- var installSucceeded = false;
- if (this.isCallbackSupported()) {
- installSucceeded =
- this.getPlugin().installJRE(requestVersion, installCallback);
- } else {
- installSucceeded = this.getPlugin().installJRE(requestVersion);
- }
- if (installSucceeded) {
- this.refresh();
- if (this.returnPage != null) {
- document.location = this.returnPage;
- }
- }
- return installSucceeded;
- } else {
- return this.installLatestJRE();
- }
- },
- /**
- * returns true if jre auto install for the requestedJREVersion is enabled
- * for the local system; false otherwise
- *
- * requestedJREVersion param is optional - if not specified, it will be
- * treated as installing any JRE version
- *
- * DT plugin for 6uX only knows about JRE installer signed by SUN cert.
- * If it encounter Oracle signed JRE installer, it will have chance of
- * deadlock when running with IE. This function is to guard against this.
- */
- isAutoInstallEnabled: function(requestedJREVersion) {
- // if no DT plugin, return false
- if (!this.isPluginInstalled()) return false;
- if (typeof requestedJREVersion == 'undefined') {
- requestedJREVersion = null;
- }
- return enableWithoutCertMisMatchWorkaround(requestedJREVersion);
- },
- /**
- * returns true if jre install callback is supported
- * callback support is added since dt plugin version 10.2.0 or above
- */
- isCallbackSupported: function() {
- return this.isPluginInstalled() &&
- this.compareVersionToPattern(this.getPlugin().version,
- ["10", "2", "0"], false, true);
- },
- /**
- * Triggers a JRE installation. The exact effect of triggering an
- * installation varies based on platform, browser, and if the
- * Deployment Toolkit plugin is installed.
- *
- * In the simplest case, the browser window will be redirected to the
- * java.com JRE installation page, and (if possible) a redirect back to
- * the current URL upon successful installation. The return redirect is
- * not always possible, as the JRE installation may require the browser to
- * be restarted.
- *
- * installCallback is an optional argument which holds a reference
- * to a javascript callback function for reporting install status.
- *
- * In the best case (when the Deployment Toolkit plugin is present), this
- * function will immediately cause a progress dialog to be displayed
- * as the JRE is downloaded and installed.
- */
- installLatestJRE: function(installCallback) {
- if (this.isPluginInstalled() && this.isAutoInstallEnabled()) {
- var installSucceeded = false;
- if (this.isCallbackSupported()) {
- installSucceeded = this.getPlugin().installLatestJRE(installCallback);
- } else {
- installSucceeded = this.getPlugin().installLatestJRE();
- }
- if (installSucceeded) {
- this.refresh();
- if (this.returnPage != null) {
- document.location = this.returnPage;
- }
- }
- return installSucceeded;
- } else {
- var browser = this.getBrowser();
- var platform = navigator.platform.toLowerCase();
- if ((this.EAInstallEnabled == 'true') &&
- (platform.indexOf('win') != -1) &&
- (this.EarlyAccessURL != null)) {
- this.preInstallJREList = this.getJREs();
- if (this.returnPage != null) {
- this.myInterval =
- setInterval("deployJava.poll()", 3000);
- }
- location.href = this.EarlyAccessURL;
- // we have to return false although there may be an install
- // in progress now, when complete it may go to return page
- return false;
- } else {
- if (browser == 'MSIE') {
- return this.IEInstall();
- } else if ((browser == 'Netscape Family') &&
- (platform.indexOf('win32') != -1)) {
- return this.FFInstall();
- } else {
- location.href = constructGetJavaURL(
- ((this.returnPage != null) ?
- ('&returnPage=' + this.returnPage) : '') +
- ((this.locale != null) ?
- ('&locale=' + this.locale) : '') +
- ((this.brand != null) ?
- ('&brand=' + this.brand) : ''));
- }
- // we have to return false although there may be an install
- // in progress now, when complete it may go to return page
- return false;
- }
- }
- },
- /**
- * Ensures that an appropriate JRE is installed and then runs an applet.
- * minimumVersion is of the form #[.#[.#[_#]]], and is the minimum
- * JRE version necessary to run this applet. minimumVersion is optional,
- * defaulting to the value "1.1" (which matches any JRE).
- * If an equal or greater JRE is detected, runApplet() will call
- * writeAppletTag(attributes, parameters) to output the applet tag,
- * otherwise it will call installJRE(minimumVersion + '+').
- *
- * After installJRE() is called, the script will attempt to detect that the
- * JRE installation has completed and begin running the applet, but there
- * are circumstances (such as when the JRE installation requires a browser
- * restart) when this cannot be fulfilled.
- *
- * As with writeAppletTag(), this function should only be called prior to
- * the web page being completely rendered. Note that version wildcards
- * (star (*) and plus (+)) are not supported, and including them in the
- * minimumVersion will result in an error message.
- */
- runApplet: function(attributes, parameters, minimumVersion) {
- if (minimumVersion == 'undefined' || minimumVersion == null) {
- minimumVersion = '1.1';
- }
- var matchData = minimumVersion.match(version_regex_strict);
- if (this.returnPage == null) {
- // if there is an install, come back here and run the applet
- this.returnPage = document.location;
- }
- if (matchData != null) {
- var browser = this.getBrowser();
- if (browser != '?') {
- if (this.versionCheck(minimumVersion + '+')) {
- this.writeAppletTag(attributes, parameters);
- } else if (this.installJRE(minimumVersion + '+')) {
- // after successful install we need to refresh page to pick
- // pick up new plugin
- this.refresh();
- location.href = document.location;
- this.writeAppletTag(attributes, parameters);
- }
- } else {
- // for unknown or Safari - just try to show applet
- this.writeAppletTag(attributes, parameters);
- }
- } else {
- log('[runApplet()] Invalid minimumVersion argument to runApplet():' +
- minimumVersion);
- }
- },
- /**
- * Outputs an applet tag with the specified attributes and parameters, where
- * both attributes and parameters are associative arrays. Each key/value
- * pair in attributes becomes an attribute of the applet tag itself, while
- * key/value pairs in parameters become <PARAM> tags. No version checking
- * or other special behaviors are performed; the tag is simply written to
- * the page using document.writeln().
- *
- * As document.writeln() is generally only safe to use while the page is
- * being rendered, you should never call this function after the page
- * has been completed.
- */
- writeAppletTag: function(attributes, parameters) {
- var startApplet = '<' + 'applet ';
- var params = '';
- var endApplet = '<' + '/' + 'applet' + '>';
- var addCodeAttribute = true;
- if (null == parameters || typeof parameters != 'object') {
- parameters = new Object();
- }
- for (var attribute in attributes) {
- if (! isValidAppletAttr(attribute)) {
- parameters[attribute] = attributes[attribute];
- } else {
- startApplet += (' ' +attribute+ '="' +attributes[attribute] + '"');
- if (attribute == 'code') {
- addCodeAttribute = false;
- }
- }
- }
- var codebaseParam = false;
- for (var parameter in parameters) {
- if (parameter == 'codebase_lookup') {
- codebaseParam = true;
- }
- // Originally, parameter 'object' was used for serialized
- // applets, later, to avoid confusion with object tag in IE
- // the 'java_object' was added. Plugin supports both.
- if (parameter == 'object' || parameter == 'java_object' ||
- parameter == 'java_code' ) {
- addCodeAttribute = false;
- }
- params += '<param name="' + parameter + '" value="' +
- parameters[parameter] + '"/>';
- }
- if (!codebaseParam) {
- params += '<param name="codebase_lookup" value="false"/>';
- }
- if (addCodeAttribute) {
- startApplet += (' code="dummy"');
- }
- startApplet += '>';
- document.write(startApplet + '\n' + params + '\n' + endApplet);
- },
-
- /**
- * Returns true if there is a matching JRE version currently installed
- * (among those detected by getJREs()). The versionPattern string is
- * of the form #[.#[.#[_#]]][+|*], which includes strings such as "1.4",
- * "1.5.0*", and "1.6.0_02+".
- * A star (*) means "any version within this family" and a plus (+) means
- * "any version greater or equal to the specified version". "1.5.0*"
- * matches 1.5.0_06 but not 1.6.0_01, whereas "1.5.0+" matches both.
- *
- * If the versionPattern does not include all four version components
- * but does not end with a star or plus, it will be treated as if it
- * ended with a star. "1.5" is exactly equivalent to "1.5*", and will
- * match any version number beginning with "1.5".
- *
- * If getJREs() is unable to detect the precise version number, a match
- * could be ambiguous. For example if getJREs() detects "1.5", there is
- * no way to know whether the JRE matches "1.5.0_06+". versionCheck()
- * compares only as much of the version information as could be detected,
- * so versionCheck("1.5.0_06+") would return true in in this case.
- *
- * Invalid versionPattern will result in a JavaScript error alert.
- * versionPatterns which are valid but do not match any existing JRE
- * release (e.g. "32.65+") will always return false.
- */
- versionCheck: function(versionPattern)
- {
- var index = 0;
- var matchData = versionPattern.match(version_regex_with_family_modifier);
- if (matchData != null) {
- // default is exact version match
- // examples:
- // local machine has 1.7.0_04 only installed
- // exact match request is "1.7.0_05": return false
- // family match request is "1.7.0*": return true
- // minimum match request is "1.6+": return true
- var familyMatch = false;
- var minMatch = false;
- var patternArray = new Array();
- for (var i = 1; i < matchData.length; ++i) {
- // browser dependency here.
- // Fx sets 'undefined', IE sets '' string for unmatched groups
- if ((typeof matchData[i] == 'string') && (matchData[i] != '')) {
- patternArray[index] = matchData[i];
- index++;
- }
- }
- if (patternArray[patternArray.length-1] == '+') {
- // + specified in request - doing a minimum match
- minMatch = true;
- familyMatch = false;
- patternArray.length--;
- } else if (patternArray[patternArray.length-1] == '*') {
- // * specified in request - doing a family match
- minMatch = false;
- familyMatch = true;
- patternArray.length--;
- } else if (patternArray.length < 4) {
- // versionPattern does not include all four version components
- // and does not end with a star or plus, it will be treated as
- // if it ended with a star. (family match)
- minMatch = false;
- familyMatch = true;
- }
- var list = this.getJREs();
- for (var i = 0; i < list.length; ++i) {
- if (this.compareVersionToPattern(list[i], patternArray,
- familyMatch, minMatch)) {
- return true;
- }
- }
- return false;
- } else {
- var msg = 'Invalid versionPattern passed to versionCheck: ' +
- versionPattern;
- log('[versionCheck()] ' + msg);
- alert(msg);
- return false;
- }
- },
- /**
- * Returns true if an installation of Java Web Start of the specified
- * minimumVersion can be detected. minimumVersion is optional, and
- * if not specified, '1.4.2' will be used.
- * (Versions earlier than 1.4.2 may not be detected.)
- */
- isWebStartInstalled: function(minimumVersion) {
- var browser = this.getBrowser();
- if (browser == '?') {
- // we really don't know - better to try to use it than reinstall
- return true;
- }
- if (minimumVersion == 'undefined' || minimumVersion == null) {
- minimumVersion = '1.4.2';
- }
- var retval = false;
- var matchData = minimumVersion.match(version_regex_strict);
- if (matchData != null) {
- retval = this.versionCheck(minimumVersion + '+');
- } else {
- log('[isWebStartInstaller()] Invalid minimumVersion argument to isWebStartInstalled(): ' + minimumVersion);
- retval = this.versionCheck('1.4.2+');
- }
- return retval;
- },
- // obtain JPI version using navigator.mimeTypes array
- // if found, set the version to this.firefoxJavaVersion
- getJPIVersionUsingMimeType: function() {
- // Walk through the full list of mime types.
- for (var i = 0; i < navigator.mimeTypes.length; ++i) {
- var s = navigator.mimeTypes[i].type;
- // The jpi-version is the plug-in version. This is the best
- // version to use.
- var m = s.match(/^application\/x-java-applet;jpi-version=(.*)$/);
- if (m != null) {
- this.firefoxJavaVersion = m[1];
- // Opera puts the latest sun JRE last not first
- if ('Opera' != this.browserName2) {
- break;
- }
- }
- }
- },
- // launch the specified JNLP application using the passed in jnlp file
- // the jnlp file does not need to have a codebase
- // this requires JRE 7 or above to work
- // if machine has no JRE 7 or above, we will try to auto-install and then launch
- // (function will return false if JRE auto-install failed)
- launchWebStartApplication: function(jnlp) {
- var uaString = navigator.userAgent.toLowerCase();
- this.getJPIVersionUsingMimeType();
- // make sure we are JRE 7 or above
- if (this.isWebStartInstalled('1.7.0') == false) {
- // perform latest JRE auto-install
- if ((this.installJRE('1.7.0+') == false) ||
- ((this.isWebStartInstalled('1.7.0') == false))) {
- return false;
- }
- }
- var jnlpDocbase = null;
- // use document.documentURI for docbase
- if (document.documentURI) {
- jnlpDocbase = document.documentURI;
- }
- // fallback to document.URL if documentURI not available
- if (jnlpDocbase == null) {
- jnlpDocbase = document.URL;
- }
- var browser = this.getBrowser();
- var launchTag;
- if (browser == 'MSIE') {
- launchTag = '<' +
- 'object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" ' +
- 'width="0" height="0">' +
- '<' + 'PARAM name="launchjnlp" value="' + jnlp + '"' + '>' +
- '<' + 'PARAM name="docbase" value="' + encodeURIComponent(jnlpDocbase) + '"' + '>' +
- '<' + '/' + 'object' + '>';
- } else if (browser == 'Netscape Family') {
- launchTag = '<' +
- 'embed type="application/x-java-applet;jpi-version=' +
- this.firefoxJavaVersion + '" ' +
- 'width="0" height="0" ' +
- 'launchjnlp="' + jnlp + '"' +
- 'docbase="' + encodeURIComponent(jnlpDocbase) + '"' +
- ' />';
- }
- if (document.body == 'undefined' || document.body == null) {
- document.write(launchTag);
- // go back to original page, otherwise current page becomes blank
- document.location = jnlpDocbase;
- } else {
- var divTag = document.createElement("div");
- divTag.id = "div1";
- divTag.style.position = "relative";
- divTag.style.left = "-10000px";
- divTag.style.margin = "0px auto";
- divTag.className ="dynamicDiv";
- divTag.innerHTML = launchTag;
- document.body.appendChild(divTag);
- }
- },
- createWebStartLaunchButtonEx: function(jnlp, minimumVersion) {
- if (this.returnPage == null) {
- // if there is an install, come back and run the jnlp file
- this.returnPage = jnlp;
- }
- var url = 'javascript:deployJava.launchWebStartApplication(\'' + jnlp +
- '\');';
- document.write('<' + 'a href="' + url +
- '" onMouseOver="window.status=\'\'; ' +
- 'return true;"><' + 'img ' +
- 'src="' + this.launchButtonPNG + '" ' +
- 'border="0" /><' + '/' + 'a' + '>');
- },
- /**
- * Outputs a launch button for the specified JNLP URL. When clicked, the
- * button will ensure that an appropriate JRE is installed and then launch
- * the JNLP application. minimumVersion is of the form #[.#[.#[_#]]], and
- * is the minimum JRE version necessary to run this JNLP application.
- * minimumVersion is optional, and if it is not specified, '1.4.2'
- * will be used.
- * If an appropriate JRE or Web Start installation is detected,
- * the JNLP application will be launched, otherwise installLatestJRE()
- * will be called.
- *
- * After installLatestJRE() is called, the script will attempt to detect
- * that the JRE installation has completed and launch the JNLP application,
- * but there are circumstances (such as when the JRE installation
- * requires a browser restart) when this cannot be fulfilled.
- */
- createWebStartLaunchButton: function(jnlp, minimumVersion) {
- if (this.returnPage == null) {
- // if there is an install, come back and run the jnlp file
- this.returnPage = jnlp;
- }
- var url = 'javascript:' +
- 'if (!deployJava.isWebStartInstalled("' +
- minimumVersion + '")) {' +
- 'if (deployJava.installLatestJRE()) {' +
- 'if (deployJava.launch("' + jnlp + '")) {}' +
- '}' +
- '} else {' +
- 'if (deployJava.launch("' + jnlp + '")) {}' +
- '}';
- document.write('<' + 'a href="' + url +
- '" onMouseOver="window.status=\'\'; ' +
- 'return true;"><' + 'img ' +
- 'src="' + this.launchButtonPNG + '" ' +
- 'border="0" /><' + '/' + 'a' + '>');
- },
- /**
- * Launch a JNLP application, (using the plugin if available)
- */
- launch: function(jnlp) {
- /*
- * Using the plugin to launch Java Web Start is disabled for the time being
- */
- document.location=jnlp;
- return true;
- },
- /*
- * returns true if the ActiveX or XPI plugin is installed
- */
- isPluginInstalled: function() {
- var plugin = this.getPlugin();
- if (plugin && plugin.jvms) {
- return true;
- } else {
- return false;
- }
- },
- /*
- * returns true if the plugin is installed and AutoUpdate is enabled
- */
- isAutoUpdateEnabled: function() {
- if (this.isPluginInstalled()) {
- return this.getPlugin().isAutoUpdateEnabled();
- }
- return false;
- },
- /*
- * sets AutoUpdate on if plugin is installed
- */
- setAutoUpdateEnabled: function() {
- if (this.isPluginInstalled()) {
- return this.getPlugin().setAutoUpdateEnabled();
- }
- return false;
- },
- /*
- * sets the preferred install type : null, online, kernel
- */
- setInstallerType: function(type) {
- this.installType = type;
- if (this.isPluginInstalled()) {
- return this.getPlugin().setInstallerType(type);
- }
- return false;
- },
- /*
- * sets additional package list - to be used by kernel installer
- */
- setAdditionalPackages: function(packageList) {
- if (this.isPluginInstalled()) {
- return this.getPlugin().setAdditionalPackages(
- packageList);
- }
- return false;
- },
- /*
- * sets preference to install Early Access versions if available
- */
- setEarlyAccess: function(enabled) {
- this.EAInstallEnabled = enabled;
- },
- /*
- * Determines if the next generation plugin (Plugin II) is default
- */
- isPlugin2: function() {
- if (this.isPluginInstalled()) {
- if (this.versionCheck('1.6.0_10+')) {
- try {
- return this.getPlugin().isPlugin2();
- } catch (err) {
- // older plugin w/o isPlugin2() function -
- }
- }
- }
- return false;
- },
- //support native DT plugin?
- allowPlugin: function() {
- this.getBrowser();
- // Safari and Opera browsers find the plugin but it
- // doesn't work, so until we can get it to work - don't use it.
- var ret = ('Safari' != this.browserName2 &&
- 'Opera' != this.browserName2);
- return ret;
- },
- getPlugin: function() {
- this.refresh();
- var ret = null;
- if (this.allowPlugin()) {
- ret = document.getElementById('deployJavaPlugin');
- }
- return ret;
- },
- compareVersionToPattern: function(version, patternArray,
- familyMatch, minMatch) {
- if (version == undefined || patternArray == undefined) {
- return false;
- }
- var matchData = version.match(version_regex_strict);
- if (matchData != null) {
- var index = 0;
- var result = new Array();
- for (var i = 1; i < matchData.length; ++i) {
- if ((typeof matchData[i] == 'string') && (matchData[i] != ''))
- {
- result[index] = matchData[i];
- index++;
- }
- }
- var l = Math.min(result.length, patternArray.length);
- // result contains what is installed in local machine
- // patternArray is what is being requested by application
- if (minMatch) {
- // minimum version match, return true if what we have (installed)
- // is greater or equal to what is requested. false otherwise.
- for (var i = 0; i < l; ++i) {
- var resultTemp = parseInt(result[i]);
- var patternArrayTemp = parseInt(patternArray[i]);
- if (resultTemp < patternArrayTemp) {
- return false;
- } else if (resultTemp > patternArrayTemp) {
- return true;
- }
- }
- return true;
- } else {
- for (var i = 0; i < l; ++i) {
- if (result[i] != patternArray[i]) return false;
- }
- if (familyMatch) {
- // family match - return true as long as what we have
- // (installed) matches up to the request pattern
- return true;
- } else {
- // exact match
- // result and patternArray needs to have exact same content
- return (result.length == patternArray.length);
- }
- }
- } else {
- return false;
- }
- },
- getBrowser: function() {
- if (this.browserName == null) {
- var browser = navigator.userAgent.toLowerCase();
- log('[getBrowser()] navigator.userAgent.toLowerCase() -> ' + browser);
- // order is important here. Safari userAgent contains mozilla,
- // IE 11 userAgent contains mozilla and netscape,
- // and Chrome userAgent contains both mozilla and safari.
- if ((browser.indexOf('msie') != -1) && (browser.indexOf('opera') == -1)) {
- this.browserName = 'MSIE';
- this.browserName2 = 'MSIE';
- } else if (browser.indexOf('trident') != -1 || browser.indexOf('Trident') != -1) {
- this.browserName = 'MSIE';
- this.browserName2 = 'MSIE';
- } else if (browser.indexOf('iphone') != -1) {
- // this included both iPhone and iPad
- this.browserName = 'Netscape Family';
- this.browserName2 = 'iPhone';
- } else if ((browser.indexOf('firefox') != -1) && (browser.indexOf('opera') == -1)) {
- this.browserName = 'Netscape Family';
- this.browserName2 = 'Firefox';
- } else if (browser.indexOf('chrome') != -1) {
- this.browserName = 'Netscape Family';
- this.browserName2 = 'Chrome';
- } else if (browser.indexOf('safari') != -1) {
- this.browserName = 'Netscape Family';
- this.browserName2 = 'Safari';
- } else if ((browser.indexOf('mozilla') != -1) && (browser.indexOf('opera') == -1)) {
- this.browserName = 'Netscape Family';
- this.browserName2 = 'Other';
- } else if (browser.indexOf('opera') != -1) {
- this.browserName = 'Netscape Family';
- this.browserName2 = 'Opera';
- } else {
- this.browserName = '?';
- this.browserName2 = 'unknown';
- }
- log('[getBrowser()] Detected browser name:'+ this.browserName +
- ', ' + this.browserName2);
- }
- return this.browserName;
- },
- testUsingActiveX: function(version) {
- var objectName = 'JavaWebStart.isInstalled.' + version + '.0';
- // we need the typeof check here for this to run on FF/Chrome
- // the check needs to be in place here - cannot even pass ActiveXObject
- // as arg to another function
- if (typeof ActiveXObject == 'undefined' || !ActiveXObject) {
- log('[testUsingActiveX()] Browser claims to be IE, but no ActiveXObject object?');
- return false;
- }
- try {
- return (new ActiveXObject(objectName) != null);
- } catch (exception) {
- return false;
- }
- },
- testForMSVM: function() {
- var clsid = '{08B0E5C0-4FCB-11CF-AAA5-00401C608500}';
- if (typeof oClientCaps != 'undefined') {
- var v = oClientCaps.getComponentVersion(clsid, "ComponentID");
- if ((v == '') || (v == '5,0,5000,0')) {
- return false;
- } else {
- return true;
- }
- } else {
- return false;
- }
- },
- testUsingMimeTypes: function(version) {
- if (!navigator.mimeTypes) {
- log ('[testUsingMimeTypes()] Browser claims to be Netscape family, but no mimeTypes[] array?');
- return false;
- }
- for (var i = 0; i < navigator.mimeTypes.length; ++i) {
- s = navigator.mimeTypes[i].type;
- var m = s.match(/^application\/x-java-applet\x3Bversion=(1\.8|1\.7|1\.6|1\.5|1\.4\.2)$/);
- if (m != null) {
- if (this.compareVersions(m[1], version)) {
- return true;
- }
- }
- }
- return false;
- },
- testUsingPluginsArray: function(version) {
- if ((!navigator.plugins) || (!navigator.plugins.length)) {
- return false;
- }
- var platform = navigator.platform.toLowerCase();
- for (var i = 0; i < navigator.plugins.length; ++i) {
- s = navigator.plugins[i].description;
- if (s.search(/^Java Switchable Plug-in (Cocoa)/) != -1) {
- // Safari on MAC
- if (this.compareVersions("1.5.0", version)) {
- return true;
- }
- } else if (s.search(/^Java/) != -1) {
- if (platform.indexOf('win') != -1) {
- // still can't tell - opera, safari on windows
- // return true for 1.5.0 and 1.6.0
- if (this.compareVersions("1.5.0", version) ||
- this.compareVersions("1.6.0", version)) {
- return true;
- }
- }
- }
- }
- // if above dosn't work on Apple or Windows, just allow 1.5.0
- if (this.compareVersions("1.5.0", version)) {
- return true;
- }
- return false;
- },
- IEInstall: function() {
- location.href = constructGetJavaURL(
- ((this.returnPage != null) ?
- ('&returnPage=' + this.returnPage) : '') +
- ((this.locale != null) ?
- ('&locale=' + this.locale) : '') +
- ((this.brand != null) ? ('&brand=' + this.brand) : ''));
- // should not actually get here
- return false;
- },
- done: function (name, result) {
- },
- FFInstall: function() {
- location.href = constructGetJavaURL(
- ((this.returnPage != null) ?
- ('&returnPage=' + this.returnPage) : '') +
- ((this.locale != null) ?
- ('&locale=' + this.locale) : '') +
- ((this.brand != null) ? ('&brand=' + this.brand) : '') +
- ((this.installType != null) ?
- ('&type=' + this.installType) : ''));
- // should not actually get here
- return false;
- },
- // return true if 'installed' (considered as a JRE version string) is
- // greater than or equal to 'required' (again, a JRE version string).
- compareVersions: function(installed, required) {
- var a = installed.split('.');
- var b = required.split('.');
- for (var i = 0; i < a.length; ++i) {
- a[i] = Number(a[i]);
- }
- for (var i = 0; i < b.length; ++i) {
- b[i] = Number(b[i]);
- }
- if (a.length == 2) {
- a[2] = 0;
- }
- if (a[0] > b[0]) return true;
- if (a[0] < b[0]) return false;
- if (a[1] > b[1]) return true;
- if (a[1] < b[1]) return false;
- if (a[2] > b[2]) return true;
- if (a[2] < b[2]) return false;
- return true;
- },
- enableAlerts: function() {
- // reset this so we can show the browser detection
- this.browserName = null;
- this.debug = true;
- },
- poll: function() {
- this.refresh();
- var postInstallJREList = this.getJREs();
- if ((this.preInstallJREList.length == 0) &&
- (postInstallJREList.length != 0)) {
- clearInterval(this.myInterval);
- if (this.returnPage != null) {
- location.href = this.returnPage;
- };
- }
- if ((this.preInstallJREList.length != 0) &&
- (postInstallJREList.length != 0) &&
- (this.preInstallJREList[0] != postInstallJREList[0])) {
- clearInterval(this.myInterval);
- if (this.returnPage != null) {
- location.href = this.returnPage;
- }
- }
- },
- writePluginTag: function() {
- var browser = this.getBrowser();
- if (browser == 'MSIE') {
- document.write('<' +
- 'object classid="clsid:CAFEEFAC-DEC7-0000-0001-ABCDEFFEDCBA" ' +
- 'id="deployJavaPlugin" width="0" height="0">' +
- '<' + '/' + 'object' + '>');
- } else if (browser == 'Netscape Family' && this.allowPlugin()) {
- this.writeEmbedTag();
- }
- },
- refresh: function() {
- navigator.plugins.refresh(false);
- var browser = this.getBrowser();
- if (browser == 'Netscape Family' && this.allowPlugin()) {
- var plugin = document.getElementById('deployJavaPlugin');
- // only do this again if no plugin
- if (plugin == null) {
- this.writeEmbedTag();
- }
- }
- },
- writeEmbedTag: function() {
- var written = false;
- if (navigator.mimeTypes != null) {
- for (var i=0; i < navigator.mimeTypes.length; i++) {
- if (navigator.mimeTypes[i].type == this.mimeType) {
- if (navigator.mimeTypes[i].enabledPlugin) {
- document.write('<' +
- 'embed id="deployJavaPlugin" type="' +
- this.mimeType + '" hidden="true" />');
- written = true;
- }
- }
- }
- // if we ddn't find new mimeType, look for old mimeType
- if (!written) for (var i=0; i < navigator.mimeTypes.length; i++) {
- if (navigator.mimeTypes[i].type == this.oldMimeType) {
- if (navigator.mimeTypes[i].enabledPlugin) {
- document.write('<' +
- 'embed id="deployJavaPlugin" type="' +
- this.oldMimeType + '" hidden="true" />');
- }
- }
- }
- }
- }
- }; // deployJava object
- rv.writePluginTag();
- if (rv.locale == null) {
- var loc = null;
- if (loc == null) try {
- loc = navigator.userLanguage;
- } catch (err) { }
- if (loc == null) try {
- loc = navigator.systemLanguage;
- } catch (err) { }
- if (loc == null) try {
- loc = navigator.language;
- } catch (err) { }
- if (loc != null) {
- loc.replace("-","_")
- rv.locale = loc;
- }
- }
- return rv;
- }();
- window.PINYIN_DICT = [["a","啊阿吖嗄腌锕"],["ai","爱埃挨哎唉哀皑癌蔼矮艾碍隘捱嗳嗌嫒瑷暧砹锿霭"],["an","安案按鞍氨俺暗岸胺谙埯揞犴庵桉铵鹌黯"],["ang","肮昂盎"],["ao","凹敖熬翱袄傲奥懊澳坳拗嗷岙廒遨媪骜獒聱螯鏊鳌鏖"],["ba","芭捌扒叭吧笆八疤巴拔跋靶把耙坝霸罢爸茇菝岜灞钯粑鲅魃"],["bai","白柏百摆佰败拜稗捭掰"],["ban","版般办斑班搬扳颁板扮拌伴瓣半绊阪坂钣瘢癍舨"],["bang","帮邦梆榜膀绑棒磅蚌镑傍谤蒡浜"],["bao","保报包苞胞褒剥薄雹堡饱宝抱暴豹鲍爆炮曝瀑勹葆孢煲鸨褓趵龅"],["bei","北备杯碑悲卑辈背贝钡倍狈惫焙被孛陂邶蓓呗悖碚鹎褙鐾鞴"],["ben","本奔苯笨夯畚坌锛"],["beng","蚌崩绷甭泵蹦迸嘣甏"],["bi","比必币毕逼鼻鄙笔彼碧蓖蔽毙毖庇痹闭敝弊辟壁臂避陛匕俾芘荜荸萆薜吡哔狴庳愎滗濞弼妣婢嬖璧贲睥畀铋秕裨筚箅篦舭襞跸髀"],["bian","变编边便鞭贬扁卞辨辩辫遍匾弁苄忭汴缏煸砭碥窆褊蝙笾鳊"],["biao","表标彪膘婊骠飑飙飚镖镳瘭裱鳔"],["bie","别鳖憋瘪蹩"],["bin","彬斌濒滨宾摈傧豳缤玢槟殡膑镔髌鬓"],["bing","并兵冰柄丙秉饼炳病屏禀邴摒槟"],["bo","播博柏剥薄玻菠拨钵波勃搏铂箔伯帛舶脖膊渤泊驳卜亳啵饽檗擘礴钹鹁簸跛踣"],["bu","不布部步捕卜哺补埠簿怖埔卟逋瓿晡钚钸醭"],["ca","擦嚓礤"],["cai","才采材彩猜裁财睬踩菜蔡"],["can","参餐蚕残惭惨灿孱骖璨粲黪"],["cang","藏苍舱仓沧伧"],["cao","操糙槽曹草嘈漕螬艚"],["ce","册策测厕侧恻"],["ceng","曾层蹭噌"],["cha","查插叉茬茶碴搽察岔差诧刹喳嚓猹馇汊姹杈楂槎檫锸镲衩"],["chai","差拆柴豺侪钗瘥虿"],["chan","产搀掺蝉馋谗缠铲阐颤冁谄蒇廛忏潺澶孱羼婵骣觇禅蟾躔"],["chang","场常长昌猖尝偿肠厂敞畅唱倡裳伥鬯苌菖徜怅惝阊娼嫦昶氅鲳"],["chao","超抄钞朝嘲潮巢吵炒绰剿怊晁焯耖"],["che","车扯撤掣彻澈坼砗"],["chen","称郴臣辰尘晨忱沉陈趁衬沈谌谶抻嗔宸琛榇碜龀"],["cheng","成程称城撑橙呈乘惩澄诚承逞骋秤丞埕枨柽塍瞠铖铛裎蛏酲"],["chi","持吃痴匙池迟弛驰耻齿侈尺赤翅斥炽傺墀茌叱哧啻嗤彳饬媸敕眵鸱瘛褫蚩螭笞篪豉踟魑"],["chong","重充冲虫崇宠茺忡憧铳舂艟"],["chou","抽酬畴踌稠愁筹仇绸瞅丑臭俦帱惆瘳雠"],["chu","出除处础初橱厨躇锄雏滁楚储矗搐触畜亍刍怵憷绌杵楮樗褚蜍蹰黜"],["chuai","揣搋啜嘬膪踹"],["chuan","传川穿椽船喘串舛遄氚钏舡"],["chuang","创疮窗幢床闯怆"],["chui","吹炊捶锤垂椎陲棰槌"],["chun","春椿醇唇淳纯蠢莼鹑蝽"],["chuo","戳绰啜辍踔龊"],["ci","次此词差疵茨磁雌辞慈瓷刺赐茈祠鹚糍"],["cong","从聪葱囱匆丛苁淙骢琮璁枞"],["cou","凑楱辏腠"],["cu","促粗醋簇卒蔟徂猝殂酢蹙蹴"],["cuan","蹿篡窜攒汆撺爨镩"],["cui","摧崔催脆瘁粹淬翠衰萃啐悴璀榱毳"],["cun","存村寸忖皴"],["cuo","错措磋撮搓挫厝嵯脞锉矬痤瘥鹾蹉"],["da","大达打答搭瘩耷哒嗒囗怛妲沓褡笪靼鞑"],["dai","代带呆歹傣戴殆贷袋待逮怠埭甙呔岱迨绐玳黛"],["dan","单但耽担丹郸掸胆旦氮惮淡诞弹蛋石儋凼萏菪啖澹宕殚赕眈疸瘅聃箪"],["dang","当挡党荡档谠砀铛裆"],["dao","到道导刀捣蹈倒岛祷稻悼盗叨氘焘纛"],["de","的地得德锝"],["deng","等登蹬灯瞪凳邓噔嶝戥磴镫簦"],["di","的地第底弟堤低滴迪敌笛狄涤翟嫡抵蒂帝递缔氐籴诋谛邸坻荻嘀娣柢棣觌祗砥碲睇镝羝骶"],["dian","电点典店颠掂滇碘靛垫佃甸惦奠淀殿丶阽坫巅玷钿癜癫簟踮"],["diao","调碉叼雕凋刁掉吊钓铞貂鲷"],["die","跌爹碟蝶迭谍叠垤堞揲喋牒瓞耋鲽"],["ding","定丁盯叮钉顶鼎锭订仃啶玎腚碇町疔耵酊"],["diu","丢铥"],["dong","动东冬董懂栋侗恫冻洞垌咚岽峒氡胨胴硐鸫"],["dou","都兜抖斗陡豆逗痘蔸钭窦蚪篼"],["du","都度读督毒犊独堵睹赌杜镀肚渡妒芏嘟渎椟牍蠹笃髑黩"],["duan","断段短端锻缎椴煅簖"],["dui","对堆兑队敦怼憝碓镦"],["dun","墩吨蹲敦顿囤钝盾遁沌炖砘礅盹趸"],["duo","多度掇哆夺垛躲朵跺舵剁惰堕咄哚沲缍铎裰踱"],["e","阿蛾峨鹅俄额讹娥恶厄扼遏鄂饿哦噩谔垩苊莪萼呃愕屙婀轭腭锇锷鹗颚鳄"],["en","恩蒽摁嗯"],["er","而二儿耳尔饵洱贰迩珥铒鸸鲕"],["fa","发法罚筏伐乏阀珐垡砝"],["fan","范藩帆番翻樊矾钒繁凡烦反返贩犯饭泛蕃蘩幡夂梵攵燔畈蹯"],["fang","方放访房坊芳肪防妨仿纺邡枋钫舫鲂"],["fei","费非菲啡飞肥匪诽吠肺废沸芾狒悱淝妃绯榧腓斐扉砩镄痱蜚篚翡霏鲱"],["fen","分份芬酚吩氛纷坟焚汾粉奋忿愤粪偾瀵棼鲼鼢"],["feng","风丰封枫蜂峰锋疯烽逢冯缝讽奉凤俸酆葑唪沣砜"],["fo","佛"],["fou","否缶"],["fu","服复府父负福富夫敷肤孵扶拂辐幅氟符伏俘浮涪袱弗甫抚辅俯釜斧脯腑腐赴副覆赋傅付阜腹讣附妇缚咐莆匐凫郛芙芾苻茯莩菔拊呋呒幞怫滏艴孚驸绂绋桴赙祓黻黼罘稃馥蚨蜉蝠蝮麸趺跗鲋鳆"],["ga","噶嘎夹轧垓尬尕尜旮钆"],["gai","改该概钙盖溉芥丐陔戤赅"],["gan","感敢干甘杆柑竿肝赶秆赣坩苷尴擀泔淦澉绀橄旰矸疳酐"],["gang","港冈刚钢缸肛纲岗杠戆罡筻"],["gao","告高篙皋膏羔糕搞镐稿睾诰郜藁缟槔槁杲锆"],["ge","个格合歌各革哥搁戈鸽胳疙割葛蛤阁隔铬咯鬲仡哿圪塥嗝纥搿膈硌镉袼颌虼舸骼"],["gei","给"],["gen","根跟亘茛哏艮"],["geng","更耕庚羹埂耿梗哽赓绠鲠"],["gong","公工供功共贡攻恭龚躬宫弓巩汞拱珙肱蚣觥"],["gou","构够购钩勾沟苟狗垢佝诟岣遘媾缑枸觏彀笱篝鞲"],["gu","告故辜菇咕箍估沽孤姑鼓古蛊骨谷股顾固雇贾嘏诂菰崮汩梏轱牯牿臌毂瞽罟钴锢鸪鹄痼蛄酤觚鲴鹘"],["gua","刮瓜剐寡挂褂卦诖呱栝胍鸹"],["guai","乖拐怪掴"],["guan","关管观棺官冠馆罐惯灌贯纶倌莞掼涫盥鹳矜鳏"],["guang","广光逛咣犷桄胱"],["gui","规瑰圭硅归龟闺轨鬼诡癸桂柜跪贵刽匦刿庋宄妫桧炅晷皈簋鲑鳜"],["gun","辊滚棍衮绲磙鲧"],["guo","国过果锅郭裹馘埚掴呙帼崞猓椁虢聒蜾蝈"],["ha","哈蛤铪"],["hai","还海孩骸氦亥害骇嗨胲醢"],["han","韩酣憨邯含涵寒函喊罕翰撼捍旱憾悍焊汗汉邗菡撖犴阚瀚晗焓顸颔蚶鼾"],["hang","行杭夯航吭沆绗颃"],["hao","好号壕嚎豪毫郝耗浩貉蒿薅嗥嚆濠灏昊皓颢蚝"],["he","何合呵喝荷菏核禾和盒貉阂河涸赫褐鹤贺诃劾壑嗬阖曷盍颌蚵翮"],["hei","嘿黑"],["hen","很痕狠恨"],["heng","哼亨横衡恒蘅珩桁"],["hong","轰哄烘虹鸿洪宏弘红黉訇讧荭蕻薨闳泓"],["hou","后候喉侯猴吼厚堠後逅瘊篌糇鲎骺"],["hu","户护乎互和呼忽瑚壶葫胡蝴狐糊湖弧虎唬沪冱唿囫岵猢怙惚浒滹琥槲轷觳烀煳戽扈祜瓠鹄鹕鹱笏醐斛鹘"],["hua","话华化划花哗猾滑画骅桦砉铧"],["huai","槐徊怀淮坏踝"],["huan","还欢环桓缓换患唤痪豢焕涣宦幻郇奂萑擐圜獾洹浣漶寰逭缳锾鲩鬟"],["huang","荒慌黄磺蝗簧皇凰惶煌晃幌恍谎隍徨湟潢遑璜肓癀蟥篁鳇"],["hui","会回恢挥灰辉徽蛔毁悔慧卉惠晦贿秽烩汇讳诲绘诙茴荟蕙咴喙隳洄彗缋珲桧晖恚虺蟪麾"],["hun","荤昏婚魂浑混诨馄阍溷珲"],["huo","活或获和豁伙火惑霍货祸劐藿攉嚯夥钬锪镬耠蠖"],["ji","系己机技计级积际及基击记济辑即几继集极给绩激圾畸稽箕肌饥迹讥鸡姬缉吉棘籍急疾汲嫉挤脊蓟冀季伎祭剂悸寄寂既忌妓纪藉骑亟乩剞佶偈墼芨芰荠蒺蕺掎叽咭哜唧岌嵴洎屐骥畿玑楫殛戟戢赍觊犄齑矶羁嵇稷瘠虮笈笄暨跻跽霁鲚鲫髻麂"],["jia","家加价佳嘉枷夹荚颊贾甲钾假稼架驾嫁茄伽郏葭岬浃迦珈戛胛恝铗镓痂瘕蛱笳袈跏"],["jian","间件建简荐见健检坚监减键歼尖笺煎兼肩艰奸缄茧柬碱硷拣捡俭剪槛鉴践贱箭舰剑饯渐溅涧僭谏谫菅蒹搛囝湔蹇謇缣枧楗戋戬牮犍毽腱睑锏鹣裥笕翦踺鲣鞯"],["jiang","江强僵姜将浆疆蒋桨奖讲匠酱降茳洚绛缰犟礓耩糨豇靓"],["jiao","教交校较蕉椒礁焦胶郊浇骄娇嚼搅铰矫侥脚狡角饺缴绞剿酵轿叫窖佼僬艽茭挢噍峤徼湫姣敫皎鹪蛟醮跤鲛"],["jie","接结解介界阶姐揭皆秸街截劫节桔杰捷睫竭洁戒藉芥借疥诫届讦诘拮喈嗟婕孑桀碣疖颉蚧羯鲒骱"],["jin","进今金近仅津尽巾筋斤襟紧锦谨靳晋禁烬浸劲卺荩堇噤馑廑妗缙瑾槿赆觐衿矜"],["jing","经京精境睛竞竟荆兢茎晶鲸惊粳井警景颈静敬镜径痉靖净刭儆阱菁獍憬泾迳弪婧肼胫腈旌箐"],["jiong","炯窘迥扃"],["jiu","就究酒揪纠玖韭久灸九厩救旧臼舅咎疚僦啾阄柩桕鸠鹫赳鬏"],["ju","具且据车举巨鞠拘狙疽居驹菊局咀矩沮聚拒距踞锯俱句惧炬剧倨讵苣苴莒掬遽屦琚枸椐榘榉橘犋飓钜锔窭裾趄醵踽龃雎鞫"],["juan","捐鹃娟倦眷卷绢鄄狷涓桊蠲锩镌隽"],["jue","觉决绝嚼撅攫抉掘倔爵诀厥劂谲矍蕨噘噱崛獗孓珏桷橛爝镢蹶觖"],["jun","均菌钧军君峻俊竣浚郡骏捃皲筠麇"],["ka","喀咖卡咯佧咔胩"],["kai","开揩楷凯慨剀垲蒈忾恺铠锎锴"],["kan","看槛刊堪勘坎砍侃莰阚戡龛瞰"],["kang","康慷糠扛抗亢炕伉闶钪"],["kao","考拷烤靠尻栲犒铐"],["ke","可科客课坷苛柯棵磕颗壳咳渴克刻嗑岢恪溘骒缂珂轲氪瞌钶锞稞疴窠颏蝌髁"],["ken","肯啃垦恳裉龈"],["keng","坑吭铿"],["kong","控空恐孔倥崆箜"],["kou","口抠扣寇芤蔻叩囗眍筘"],["ku","枯哭窟苦酷库裤刳堀喾绔骷"],["kua","夸垮挎跨胯侉"],["kuai","会快块筷侩蒯郐哙狯浍脍"],["kuan","款宽髋"],["kuang","况匡筐狂框矿眶旷诓诳邝圹夼哐纩贶"],["kui","亏盔岿窥葵奎魁傀馈愧溃馗匮夔隗蒉揆喹喟悝愦逵暌睽聩蝰篑跬"],["kun","坤昆捆困悃阃琨锟醌鲲髡"],["kuo","括扩廓阔蛞"],["la","垃拉喇蜡腊辣啦落剌邋旯砬瘌"],["lai","来莱赖崃徕涞濑赉睐铼癞籁"],["lan","览蓝婪栏拦篮阑兰澜谰揽懒缆烂滥岚漤榄斓罱镧褴"],["lang","琅榔狼廊郎朗浪蒗啷阆稂螂"],["lao","老捞劳牢佬姥酪烙涝潦唠崂忉栳铑铹痨耢醪"],["le","了乐勒仂叻泐鳓"],["lei","类雷镭蕾磊累儡垒擂肋泪羸诔嘞嫘缧檑耒酹"],["leng","棱楞冷塄愣"],["li","理里力立历离利丽厘梨犁黎篱狸漓李鲤礼莉荔吏栗厉励砾傈例俐痢粒沥隶璃哩俪俚郦坜苈莅蓠藜呖唳喱猁溧澧逦娌嫠骊缡枥栎轹膦戾砺詈罹锂鹂疠疬蛎蜊蠡笠篥粝醴跞雳鲡鳢黧"],["lia","俩"],["lian","联链连练脸莲镰廉怜涟帘敛恋炼蔹奁潋濂琏楝殓臁裢裣蠊鲢"],["liang","量两良亮俩粮凉梁粱辆晾谅墚莨椋锒踉靓魉"],["liao","了料疗撩聊僚燎寥辽潦撂镣廖蓼尥嘹獠寮缭钌鹩"],["lie","列裂烈劣猎冽埒捩咧洌趔躐鬣"],["lin","琳林磷霖临邻鳞淋凛赁吝拎蔺啉嶙廪懔遴檩辚瞵粼躏麟"],["ling","领另铃令玲菱零龄伶羚凌灵陵岭酃苓呤囹泠绫柃棂瓴聆蛉翎鲮"],["liu","留浏流溜琉榴硫馏刘瘤柳六遛骝绺旒熘锍镏鹨鎏"],["long","龙聋咙笼窿隆垄拢陇垅茏泷珑栊胧砻癃"],["lou","楼娄搂篓漏陋露偻蒌喽嵝镂瘘耧蝼髅"],["lu","录陆芦卢颅庐炉掳卤虏鲁麓碌露路赂鹿潞禄戮垆撸噜泸渌漉逯璐栌橹轳辂辘氇胪镥鸬鹭簏舻鲈"],["lv","律旅虑驴吕铝侣履屡缕氯率滤绿偻捋闾榈膂稆褛"],["luan","峦挛孪滦卵乱脔娈栾鸾銮"],["lue","略掠锊"],["lun","论抡轮伦仑沦纶囵"],["luo","络咯烙萝螺罗逻锣箩骡裸落洛骆倮蠃荦摞猡泺漯珞椤脶镙瘰跞雒"],["ma","码妈马麻玛蚂骂嘛吗抹唛犸杩蟆麽"],["mai","买埋麦卖迈脉劢荬霾"],["man","满瞒馒蛮蔓曼慢漫谩墁幔缦熳镘颟螨鳗鞔"],["mang","芒茫盲氓忙莽邙漭硭蟒"],["mao","贸猫茅锚毛矛铆卯茂冒帽貌袤茆峁泖瑁昴牦耄旄懋瞀蝥蟊髦"],["me","么麽"],["mei","没美每媒魅玫枚梅酶霉煤眉镁昧寐妹媚糜莓嵋猸浼湄楣镅鹛袂"],["men","们门闷扪焖懑钔"],["meng","盟萌蒙檬锰猛梦孟勐甍瞢懵朦礞虻蜢蠓艋艨"],["mi","密眯醚靡糜迷谜弥米秘觅泌蜜幂芈谧咪嘧猕汨宓弭脒祢敉縻麋"],["mian","面免棉眠绵冕勉娩缅沔渑湎腼眄"],["miao","描苗瞄藐秒渺庙妙喵邈缈缪杪淼眇鹋"],["mie","蔑灭乜咩蠛篾"],["min","民抿皿敏悯闽苠岷闵泯缗玟珉愍黾鳘"],["ming","明名命螟鸣铭冥茗溟暝瞑酩"],["miu","谬缪"],["mo","没模脉摸摹蘑膜磨摩魔抹末莫墨默沫漠寞陌谟茉蓦馍嫫嬷殁镆秣瘼耱貊貘麽"],["mou","谋牟某侔哞缪眸蛑鍪"],["mu","目母牟拇牡亩姆墓暮幕募慕木睦牧穆仫坶苜沐毪钼"],["na","那拿哪呐钠娜纳讷捺肭镎衲"],["nai","氖乃奶耐奈鼐佴艿萘柰"],["nan","男南难喃囝囡楠腩蝻赧"],["nang","囊攮囔馕曩"],["nao","脑挠恼闹淖孬垴呶猱瑙硇铙蛲"],["ne","呢讷"],["nei","内馁"],["nen","嫩恁"],["neng","能"],["ni","你妮霓倪泥尼拟匿腻逆溺伲坭蘼猊怩昵旎睨铌鲵"],["nian","年蔫拈碾撵捻念粘廿埝辇黏鲇鲶"],["niang","娘酿"],["niao","鸟尿茑嬲脲袅"],["nie","捏聂孽啮镊镍涅乜陧蘖嗫颞臬蹑"],["nin","您"],["ning","柠狞凝宁拧泞佞咛甯聍"],["niu","牛扭钮纽拗狃忸妞"],["nong","农脓浓弄侬哝"],["nu","努奴怒弩胬孥驽"],["nv","女恧钕衄"],["nuan","暖"],["nue","虐疟挪"],["nuo","娜懦糯诺傩搦喏锘"],["o","哦噢"],["ou","欧鸥殴藕呕偶沤讴怄瓯耦"],["pa","扒耙啪趴爬帕怕琶葩杷筢"],["pai","牌派排拍徘湃俳蒎哌"],["pan","攀潘盘磐盼畔判叛胖拚爿泮袢襻蟠蹒"],["pang","磅乓庞旁耪胖彷夂滂逄攵螃"],["pao","抛咆刨炮袍跑泡匏狍庖脬疱"],["pei","培配呸胚裴赔陪佩沛辔帔旆锫醅霈"],["pen","喷盆湓"],["peng","朋砰抨烹澎彭蓬棚硼篷膨鹏捧碰堋嘭怦蟛"],["pi","否被辟坯砒霹批披劈琵毗啤脾疲皮匹痞僻屁譬丕仳陴邳郫圮埤鼙芘擗噼庀淠媲纰枇甓罴铍癖疋蚍蜱貔"],["pian","片便篇偏骗谝骈犏胼翩蹁"],["piao","漂飘瓢票剽莩嘌嫖缥殍瞟螵"],["pie","撇瞥丿苤彡氕"],["pin","品频聘拼贫姘嫔榀牝颦"],["ping","评平冯乒坪苹萍凭瓶屏俜娉枰鲆"],["po","坡泼颇婆破魄迫粕叵鄱珀钋钷皤笸"],["pu","普暴扑铺仆莆葡菩蒲埔朴圃浦谱曝瀑匍噗溥濮璞氆镤镨蹼"],["qi","其企起期汽器启气奇缉欺栖戚妻七凄漆柒沏棋歧畦崎脐齐旗祈祁骑岂乞契砌迄弃泣讫亓俟圻芑芪萁萋葺蕲嘁屺岐汔淇骐绮琪琦杞桤槭耆祺憩碛颀蛴蜞綦鳍麒"],["qia","夹掐恰洽葜袷髂"],["qian","前钱牵扦钎铅千迁签仟谦乾黔钳潜遣浅谴堑嵌欠歉纤倩佥阡芊芡茜荨掮岍悭慊骞搴褰缱椠肷愆钤虔箝"],["qiang","强将枪呛腔羌墙蔷抢戕嫱樯戗炝锖锵镪襁蜣羟跄"],["qiao","壳橇锹敲悄桥瞧乔侨巧鞘撬翘峭俏窍削劁诮谯荞峤愀憔缲樵硗跷鞒"],["qie","且切茄怯窃郄惬慊妾挈锲箧趄"],["qin","亲钦侵秦琴勤芹擒禽寝沁芩揿吣嗪噙溱檎锓矜覃螓衾"],["qing","情请庆轻青氢倾卿清擎晴氰顷苘圊檠磬蜻罄綮謦鲭黥"],["qiong","琼穷邛茕穹蛩筇跫銎"],["qiu","求球秋丘邱囚酋泅俅巯犰湫逑遒楸赇虬蚯蝤裘糗鳅鼽"],["qu","区去取曲趋蛆躯屈驱渠娶龋趣诎劬苣蕖蘧岖衢阒璩觑氍朐祛磲鸲癯蛐蠼麴瞿黢"],["quan","全权圈颧醛泉痊拳犬券劝诠荃犭悛绻辁畎铨蜷筌鬈"],["que","确缺炔瘸却鹊榷雀阕阙悫"],["qun","裙群逡麇"],["ran","然燃冉染苒蚺髯"],["rang","让瓤壤攘嚷禳穰"],["rao","饶扰绕荛娆桡"],["re","惹热喏"],["ren","人任认壬仁忍韧刃妊纫仞荏饪轫稔衽"],["reng","扔仍"],["ri","日"],["rong","容戎茸蓉荣融熔溶绒冗嵘狨榕肜蝾"],["rou","揉柔肉糅蹂鞣"],["ru","如入茹蠕儒孺辱乳汝褥蓐薷嚅洳溽濡缛铷襦颥"],["ruan","软阮朊"],["rui","蕊瑞锐芮蕤枘睿蚋"],["run","闰润"],["ruo","若弱偌箬"],["sa","撒洒萨卅挲脎飒"],["sai","赛腮鳃塞噻"],["san","三叁伞散仨彡馓毵糁"],["sang","桑嗓丧搡磉颡"],["sao","搔骚扫嫂埽缫臊瘙鳋"],["se","色塞瑟涩啬铯穑"],["sen","森"],["seng","僧"],["sha","莎砂杀刹沙纱傻啥煞厦唼挲歃铩痧裟霎鲨"],["shai","筛晒酾"],["shan","删山珊苫杉煽衫闪陕擅赡膳善汕扇缮栅剡讪鄯埏芟潸姗嬗骟膻钐疝蟮舢跚鳝"],["shang","上商尚赏墒伤晌裳垧泷绱殇熵觞"],["shao","少绍鞘梢捎稍烧芍勺韶哨邵劭苕潲杓蛸筲艄"],["she","设社奢赊蛇舌舍赦摄射慑涉厍佘揲猞滠歙畲麝"],["shen","什身参深神甚申砷呻伸娠绅沈审婶肾慎渗诜谂莘葚哂渖椹胂矧蜃糁"],["sheng","生声乘甥牲升绳省盛剩胜圣嵊渑晟眚笙"],["shi","是时式什市实使事示始世施识视试师史十食势释失室匙狮湿诗尸虱石拾蚀矢屎驶士柿拭誓逝嗜噬适仕侍饰氏恃嘘谥埘莳蓍弑轼贳炻礻铈螫舐筮豕鲥鲺"],["shou","手首受授收售守寿瘦兽狩绶艏"],["shu","数术束输属殊述蔬枢梳抒叔舒淑疏书赎孰熟薯暑曙署蜀黍鼠树戍竖墅庶漱恕俞丨倏塾菽摅沭澍姝纾毹腧殳秫"],["shua","刷耍唰"],["shuai","率摔衰甩帅蟀"],["shuan","栓拴闩涮"],["shuang","霜双爽孀"],["shui","说水谁睡税"],["shun","吮瞬顺舜"],["shuo","数说硕朔烁蒴搠妁槊铄"],["si","司思似食四斯撕嘶私丝死肆寺嗣伺饲巳厮俟兕厶咝汜泗澌姒驷缌祀锶鸶耜蛳笥"],["song","松送耸怂颂宋讼诵凇菘崧嵩忪悚淞竦"],["sou","搜艘擞嗽叟薮嗖嗾馊溲飕瞍锼螋"],["su","速诉苏素酥俗粟僳塑溯宿肃缩夙谡蔌嗉愫涑簌觫稣"],["suan","算酸蒜狻"],["sui","虽随隋绥髓碎岁穗遂隧祟谇荽濉邃燧眭睢"],["sun","孙损笋荪狲飧榫隼"],["suo","所索莎蓑梭唆缩琐锁唢嗦嗍娑桫挲睃羧"],["ta","他它她塌塔獭挞蹋踏嗒闼溻漯遢榻沓铊趿鳎"],["tai","大态台胎苔抬泰酞太汰邰薹骀肽炱钛跆鲐"],["tan","坛弹坍摊贪瘫滩檀痰潭谭谈坦毯袒碳探叹炭郯澹昙忐钽锬覃"],["tang","汤塘搪堂棠膛唐糖倘躺淌趟烫傥帑惝溏瑭樘铴镗耥螗螳羰醣"],["tao","讨掏涛滔绦萄桃逃淘陶套鼗叨啕洮韬饕"],["te","特忒忑慝铽"],["teng","藤腾疼誊滕"],["ti","题提体梯剔踢锑蹄啼替嚏惕涕剃屉倜荑悌逖绨缇鹈裼醍"],["tian","天添填田甜恬舔腆掭忝阗殄畋"],["tiao","调条挑迢眺跳佻苕祧窕蜩笤粜龆鲦髫"],["tie","帖贴铁萜餮"],["ting","庭听厅烃汀廷停亭挺艇莛葶婷梃铤蜓霆"],["tong","同统通桐酮瞳铜彤童桶捅筒痛佟仝茼嗵恸潼砼"],["tou","投头偷透骰"],["tu","图突凸秃徒途涂屠土吐兔堍荼菟钍酴"],["tuan","团湍抟彖疃"],["tui","推颓腿蜕褪退忒煺"],["tun","囤褪吞屯臀氽饨暾豚"],["tuo","拖托脱鸵陀驮驼椭妥拓唾乇佗坨庹沱柝??橐砣箨酡跎鼍"],["wa","挖哇蛙洼娃瓦袜佤娲腽"],["wai","外歪崴"],["wan","完湾万晚玩蔓豌弯顽丸烷碗挽皖惋宛婉腕剜芄莞菀纨绾琬脘畹蜿"],["wang","网望汪王亡枉往旺忘妄罔惘辋魍"],["wei","为位威未围维委巍微危韦违桅唯惟潍苇萎伟伪尾纬蔚味畏胃喂魏渭谓尉慰卫偎诿隈隗圩葳薇帏帷崴嵬猥猬闱沩洧涠逶娓玮韪軎炜煨痿艉鲔"],["wen","文问闻稳瘟温蚊纹吻紊刎夂阌汶璺攵雯"],["weng","嗡翁瓮蓊蕹"],["wo","我挝蜗涡窝斡卧握沃倭莴喔幄渥肟硪龌"],["wu","务无误物午恶巫呜钨乌污诬屋芜梧吾吴毋武五捂舞伍侮坞戊雾晤勿悟兀仵阢邬圬芴唔庑怃忤寤迕妩婺骛杌牾焐鹉鹜痦蜈鋈鼯"],["xi","系息戏习希细西喜析栖昔熙硒矽晰嘻吸锡牺稀悉膝夕惜熄烯溪汐犀檄袭席媳铣洗隙僖兮隰郗茜菥葸蓰奚唏徙饩阋浠淅屣嬉玺樨曦觋欷歙熹禊禧皙穸裼蜥螅蟋舄舾羲粞翕醯蹊鼷"],["xia","下瞎虾匣霞辖暇峡侠狭厦夏吓呷狎遐瑕柙硖罅黠"],["xian","现限线显先见献衔险铣掀锨仙鲜纤咸贤舷闲涎弦嫌县腺馅羡宪陷冼苋莶藓岘猃暹娴氙燹祆鹇痫蚬筅籼酰跣跹霰"],["xiang","相想项享详象响香像向降厢镶箱襄湘乡翔祥巷橡芗葙饷庠骧缃蟓鲞飨"],["xiao","小销消效校萧硝霄削哮嚣宵淆晓孝肖啸笑哓崤潇逍骁绡枭枵蛸筱箫魈"],["xie","些谢械楔歇蝎鞋协挟携邪斜胁谐写卸蟹懈泄泻屑偕亵勰燮薤撷獬廨渫瀣邂绁缬榭榍颉蹀躞"],["xin","信新心欣薪芯锌辛忻衅囟馨莘昕歆镡鑫"],["xing","行形型性幸姓省星腥猩惺兴刑邢醒杏陉荇荥擤饧悻硎"],["xiong","兄凶胸匈汹雄熊芎"],["xiu","修秀臭休羞朽嗅锈袖绣咻岫馐庥溴鸺貅髹"],["xu","需许须序续墟戌虚嘘徐蓄酗叙旭畜恤絮婿绪吁诩勖圩蓿洫溆顼栩肷煦盱胥糈醑"],["xuan","选宣轩喧悬旋玄癣眩绚儇谖萱揎泫渲漩璇楦暄炫煊碹铉镟痃"],["xue","学削靴薛穴雪血谑噱泶踅鳕"],["xun","询训讯迅寻浚勋熏循旬驯巡殉汛逊巽郇埙荀荨蕈薰峋徇獯恂洵浔曛窨醺鲟"],["ya","压押鸦鸭呀丫芽牙蚜崖衙涯雅哑亚讶轧伢垭揠岈迓娅琊桠氩砑睚痖"],["yan","言研验眼严颜焉咽阉烟淹盐蜒岩延阎炎沿奄掩衍演艳堰燕厌砚雁唁彦焰宴谚殷厣赝剡俨偃兖谳郾鄢埏芫菸崦恹闫阏湮滟妍嫣琰檐晏胭腌焱罨筵酽趼魇餍鼹"],["yang","样央阳养殃鸯秧杨扬佯疡羊洋氧仰痒漾徉怏泱炀烊恙蛘鞅"],["yao","要邀腰妖瑶摇尧遥窑谣姚咬舀药耀钥夭爻吆崾徭幺珧杳轺曜肴铫鹞窈繇鳐麽"],["ye","业也页椰噎耶爷野冶掖叶曳腋夜液拽靥谒邺揶揲晔烨铘"],["yi","一以已意易议医移艺益义艾蛇壹揖铱依伊衣颐夷遗仪胰疑沂宜姨彝椅蚁倚乙矣抑邑屹亿役臆逸肄疫亦裔毅忆溢诣谊译异翼翌绎刈劓佚佾诒圯埸懿苡荑薏弈奕挹弋呓咦咿嗌噫峄嶷猗饴怿怡悒漪迤驿缢殪轶贻欹旖熠眙钇镒镱痍瘗癔翊蜴舣羿翳酏黟"],["yin","因音引银茵荫殷阴姻吟淫寅饮尹隐印胤鄞垠堙茚吲喑狺夤洇氤铟瘾窨蚓霪龈"],["ying","影应营英迎樱婴鹰缨莹萤荧蝇赢盈颖硬映嬴郢茔荥莺萦蓥撄嘤膺滢潆瀛瑛璎楹媵鹦瘿颍罂"],["yo","哟唷"],["yong","用拥永佣臃痈庸雍踊蛹咏泳涌恿勇俑壅墉喁慵邕镛甬鳙饔"],["you","有游由友优右邮幽悠忧尤铀犹油酉佑釉诱又幼卣攸侑莠莜莸尢呦囿宥柚猷牖铕疣蚰蚴蝣蝤繇鱿黝鼬"],["yu","于育语域娱与遇尉迂淤盂榆虞愚舆余俞逾鱼愉渝渔隅予雨屿禹宇羽玉芋郁吁喻峪御愈欲狱誉浴寓裕预豫驭粥禺毓伛俣谀谕萸蓣揄圄圉嵛狳饫馀庾阈鬻妪妤纡瑜昱觎腴欤於煜熨燠聿畲钰鹆鹬瘐瘀窬窳蜮蝓竽臾舁雩龉"],["yuan","员原源元院远鸳渊冤垣袁援辕园圆猿缘苑愿怨垸塬芫掾圜沅媛瑗橼爰眢鸢螈箢鼋"],["yue","说乐阅越曰约跃钥岳粤月悦龠哕瀹栎樾刖钺"],["yun","运耘云郧匀陨允蕴酝晕韵孕郓芸狁恽愠纭韫殒昀氲熨筠"],["za","匝砸杂咋拶咂"],["zai","在载子再栽哉灾宰崽甾"],["zan","暂咱攒赞瓒昝簪糌趱錾"],["zang","赃脏葬奘驵臧"],["zao","造遭糟凿藻枣早澡蚤躁噪皂灶燥唣"],["ze","责择则泽咋仄赜啧帻迮昃笮箦舴"],["zei","贼"],["zen","怎谮"],["zeng","增综曾憎赠缯甑罾锃"],["zha","扎喳渣札轧铡闸眨栅榨咋乍炸诈柞揸吒咤哳楂砟痄蚱齄"],["zhai","翟摘斋宅窄债寨砦瘵"],["zhan","站展战瞻毡詹粘沾盏斩辗崭蘸栈占湛绽谵搌旃"],["zhang","章长张樟彰漳掌涨杖丈帐账仗胀瘴障仉鄣幛嶂獐嫜璋蟑"],["zhao","着照找招朝昭沼赵罩兆肇召爪诏棹钊笊"],["zhe","这者着浙遮折哲蛰辙锗蔗乇谪摺柘辄磔鹧褶蜇螫赭"],["zhen","真圳珍斟甄砧臻贞针侦枕疹诊震振镇阵帧蓁浈缜桢椹榛轸赈胗朕祯畛稹鸩箴"],["zheng","正政整证争蒸挣睁征狰怔拯症郑诤峥徵钲铮筝"],["zhi","只之知制置址支直至织治质执职值致指志芝枝吱蜘肢脂汁植殖侄止趾旨纸挚掷帜峙智秩稚炙痔滞窒卮陟郅埴芷摭帙忮彘咫骘栉枳栀桎轵轾贽胝膣祉黹雉鸷痣蛭絷酯跖踬踯豸觯"],["zhong","中种重终盅忠钟衷肿仲众冢忪锺螽舯踵"],["zhou","州舟周洲诌粥轴肘帚咒皱宙昼骤荮啁妯纣绉胄碡籀繇酎"],["zhu","注主助筑属珠株蛛朱猪诸诛逐竹烛煮拄瞩嘱著柱蛀贮铸住祝驻伫侏邾苎茱洙渚潴杼槠橥炷铢疰瘃竺箸舳翥躅麈"],["zhua","挝抓爪"],["zhuai","拽"],["zhuan","专传转砖撰赚篆啭馔颛"],["zhuang","状装幢桩庄妆撞壮僮"],["zhui","椎锥追赘坠缀萑惴骓缒隹"],["zhun","准屯谆肫窀"],["zhuo","着捉拙卓桌琢茁酌啄灼浊倬诼擢浞涿濯禚斫镯"],["zi","自资子字咨兹姿滋淄孜紫仔籽滓渍谘茈呲嵫姊孳缁梓辎赀恣眦锱秭耔笫粢趑觜訾龇鲻髭"],["zong","综总鬃棕踪宗纵偬腙粽"],["zou","邹走奏揍诹陬鄹驺鲰"],["zu","组足租卒族祖诅阻俎菹镞"],["zuan","钻纂攥缵躜"],["zui","最嘴醉罪蕞觜"],["zun","尊遵撙樽鳟"],["zuo","作左昨佐柞做坐座阼唑嘬怍胙祚笮酢"]];
- var PINYIN_DICT_CACHE = {};
- for(var i=0,l=PINYIN_DICT.length; i<l; i++){
- var hans = PINYIN_DICT[i][1];
- for(var j=0,m=hans.length; j<m; j++){
- var han = hans.charAt(j);
- if(!PINYIN_DICT_CACHE[han]){
- PINYIN_DICT_CACHE[han] = new Array();
- }
- PINYIN_DICT_CACHE[han].push(PINYIN_DICT[i][0]);
- }
- }
- window.PINYIN_DICT = null;/**通用ajax服务的定义对象
- * services可以是单个服务对象,也可以是service服务数组
- * 具体服务的定义请参考appendServices成员函数
- */
- function Service(services){
- this.services=[];
- this.shareParameters={};
- /**添加共享参数,在这里统一设置共享参数
- */
- this.addShareParameters=function(shareParameters){
- this.shareParameters=shareParameters;
- return this;
- };
- /**
- * 批量调用一般服务
- * 入参可以是一个调用服务的数组或者单个调用服务
- * 每个调用服务有下面的属性
- * serviceId 服务Id,不可为空
- * method 服务方法名,不可为空
- * parameters 服务参数,必须是object,object的属性名代表参数名,属性值代表参数值。
- * transform:结果集的转换规则(返回结果集合List<Map<String,Object>>时才会用到):null(无转换)、'firstRow'(取首行)、'breakdown'(分列),值不区分大小写
- * shareResults 共享服务的返回结果,默认不共享false,如果后续服务需要使用到结果里面的参数,
- * 那么就需要明确指定。该参数可以是 boolean,array或者object,为true时表示全部共享;
- * 数组可以指定返回值中需要共享的值的名,这样返回值的键值对应关系共享;
- * object可以额外指定共享名的别名,当要求返回值以新的字段名共享、
- * 或者一个以多个新别名共享时就需要用到这种类型,object的属性名表示结果集中需要共享的字段名,
- * 属性值表示新的字段名;
- * 参数共享处理列表结果集时,整个结果集的数据存放在别名为空串的特殊key上。如果本业务没有返回结果,那么参数共享无效。
- * useShare 使用共享参数标志,定义方式与shareResults一样,意义正好想对应。该参数指明如果从共享参数中获取要的值。
- * shareNotNull 校验共享参数是否为空,作为useShare的附属属性。
- * 有时希望如果获取到的共享参数是空的,那么不继续执行,那么可以在这里指定哪些一定不能为空。
- * 目前只允许三种取值,null,true和别名数组,null表示不校验,true表示全校验,别名数组表示只校验指定的值(别名是指useShare中新的别名,并非共享池里面的共享别名)。
- */
- this.appendServices=function(services){
- if(!services){
- return this;
- }
- //默认按批量形式添加服务,如果是单个,那么用数组包装
- var tmp_services=services;
- if(!$.isArray(tmp_services)){
- tmp_services = [tmp_services];
- }
- //每个service必须有serviceId,method
- for(var index=0 ;index< tmp_services.length;index++){
- //检查必录项
- if(!tmp_services[index].serviceId||!tmp_services[index].method){
- _FW.oFtl.fnAlert('服务定义的serviceId和method不可为空');
- return this;
- }
- //检查可选项
- if(tmp_services[index].parameters){
- if(typeof tmp_services[index].parameters !='object'
- ||jQuery.isArray(tmp_services[index].parameters)){
- _FW.oFtl.fnAlert('服务定义的参数必须是map!');
- return;
- }
- }
- //如果指定了transform,那么值只能是规定的
- if(tmp_services[index].transform){
- if('FIRSTROW'!=tmp_services[index].transform.toUpperCase()
- &&'BREAKDOWN'!=tmp_services[index].transform.toUpperCase()){
- _FW.oFtl.fnAlert('transform属性不正确');
- return this;
- }
- }
- //shareResults
- //转换shareResults,统一转换成map,或者boolean
- shareResults = tmp_services[index].shareResults;
- if(shareResults){
- if(typeof shareResults =='boolean'){
- if(!shareResults){
- shareResults =null;
- }
- }else if(jQuery.isArray(shareResults)){
- //转化为map
- shareResults={};
- $.each(tmp_services[index].shareResults,function(indexInArray, valueOfElement){
- shareResults[valueOfElement]=valueOfElement;
- });
- tmp_services[index].shareResults =shareResults;
- }
- }
- //useShare
- useShare = tmp_services[index].useShare;
- if(useShare){
- if(typeof useShare =='boolean'){
- if(!useShare){
- tmp_services[index].useShare =null;
- }
- }else if(jQuery.isArray(useShare)){
- //转化为map
- useShare={};
- $.each(tmp_services[index].useShare,function(indexInArray, valueOfElement){
- useShare[valueOfElement]=valueOfElement;
- });
- tmp_services[index].useShare =useShare;
- }
- }
- //shareNotNull,只允许true和字符串数组
- shareNotNull = tmp_services[index].shareNotNull;
- if(shareNotNull){
- if(typeof shareNotNull !=='boolean' && !jQuery.isArray(shareNotNull)){
- _FW.oFtl.fnAlert('参数[shareNotNull]的取值必须是true或者字符串数组!');
- return this;
- }else if(shareNotNull ===false){
- tmp_services[index].shareNotNull = null;
- }
- }
- }
- this.services=this.services.concat(tmp_services);
- return this;
- };
- /**定义添加直接调用存储过程的服务
- * 可以批量添加存储过程。每个存储过程服务的有以下属性:
- * procName、parameters、shareResults、useShare,
- * 其中procName指明存储过程的名称,其他的请参考appendServices;parameters中的参数名不能是procName
- * 批量添加存储过程时,用数组存储各个存储过程作为参数传入即可。
- * ...
- */
- this.appendProc=function(procedures){
- if(!procedures){
- return this;
- }
- //默认按批量形式添加服务,如果是单个,那么用数组包装
- tmp_procedures=procedures;
- if(!$.isArray(tmp_procedures)){
- tmp_procedures = [tmp_procedures];
- }
- //遍历,一个一个的处理
- procedure_services =[];
- for (var index=0;index< tmp_procedures.length;index++){
- //必须有configId属性
- procedure = tmp_procedures[index];
- if(!procedure.procName){
- _FW.oFtl.fnAlert('存储过程服务必须指定procName属性');
- return this;
- }
- procedure = $.extend(true,{},procedure,
- {serviceId:'directJdbcService',method:'savePointProcedure'
- ,parameters:{'':procedure.procName}});
- //去掉存储过程名称
- delete procedure.procName;
- //添加到服务列表
- procedure_services.push(procedure);
- }
- return this.appendServices(procedure_services);
- };
- /**定义添加调用预定义查询语句的服务
- * 可以批量添加查询语句。每个查询服务的包括以下属性:
- * configId、transform、indices,parameters、shareResults、useShare。
- * configId是Mapper.xml中的配置ID(注意写上空间名)
- * parameters是传递给configId的参数
- * transform:结果集的转换规则:null(无转换)、'firstRow'(取首行)、'breakdown'(分列),值不区分大小写
- * ,该参数要求传入字符串数组类型,元素值指明参数Map中的一个参数名。
- * 其它属性将作为查询语句的备用参数。其他的请参考appendServices;
- * 批量添加查询服务时,用数组存储各个查询服务作为参数传入即可。
- * ...
- */
- this.appendQuery=function(querys){
- if(!querys){
- return this;
- }
- //默认按批量形式添加服务,如果是单个,那么用数组包装
- tmp_querys=querys;
- if(!$.isArray(tmp_querys)){
- tmp_querys = [tmp_querys];
- }
- //遍历,一个一个的处理
- query_services = [];
- for (var index=0;index<tmp_querys.length;index++){
- //必须有configId属性
- var query = tmp_querys[index];
- if(!query.configId){
- _FW.oFtl.fnAlert('查询服务必须指定configId属性');
- return this;
- }
- //参数索引放入参数串中
- query = $.extend(true,{},query,
- {serviceId:'commService',method:'query'
- ,parameters:{'_commDo':query.configId}});
-
- //去掉存储过程名称,和参数索引
- delete query.configId;
-
- //添加到服务列表
- query_services.push(query);
- }
- return this.appendServices(query_services);
- };
- /**定义触发ajax的事件
- * message:本次ajax请求的名称,可选。
- * success:处理成功后触发的函数,原型是function(data)。
- * error:处理是否时触发的函数,原型是function(XMLHttpRequest, textStatus, errorThrown);
- * async:同步或是异步,同步为false、异步是true
- */
- this.sentAjax=function(message,success,error,async){
- var that=this;
- if(this.services.length==0){
- _FW.oFtl.fnAlert('请至少添加一个服务');
- return;
- }
- var t_async = true;
- var t_message = message;
- var t_success = success;
- var t_error = error;
- if(jQuery.isFunction(message)){
- t_message = '正在请求服务,请稍候...';
- t_success =message;
- t_error = success;
- }else if (typeof message != 'string'){
- _FW.oFtl.fnAlert('入参错误,请检查程序!');
- return ;
- }
- if(async!=null&&typeof async=='boolean'){
- if(!async){
- t_async = false;
- }
- }
- var thisrequest={};
- $.ajax({
- url:contextPath+'/ajaxAdapter.do'
- ,data:{parameters:JSON.stringify(this.services),shareArguments:JSON.stringify(this.shareParameters)}
- ,dataType :'json'
- ,cache:false
- ,async:t_async
- ,contentType: "application/x-www-form-urlencoded; charset=utf-8"
- ,type:'post'
- ,error:function (request, textStatus, errorThrown) {
- if(!t_error){
- _FW.oFtl.fnAlert('数据请求错误!');
- }else{
- t_error(request, textStatus, errorThrown);
- }
- }
- ,success:function (data, textStatus) {
- if(data!=null && data[headtoken]!=null){
- token=data[headtoken];//更新全局变量token标志
- }
-
- //校验业务处理是否正确执行
- if("1"!=data.FHZ){//出错了,弹出错误提醒
- if ("loginTimeout" == data.FHZ) {
- if(window.confirm(data.MSG||'')){
- window.top.location.href=_selfUrl;
- }
- } else if("CSRF" == data.FHZ){
- showMsg(data.MSG||'',3);
- return;
- } else {
- if(t_error){
- t_error(data.MSG||'', 'serviceErr', data.MSG);
- }else{
- _FW.oFtl.fnAlert(data.MSG||'');
- }
- }
- }else if(!t_success){
- }else{
- t_success(data.RTN);
- }
- }
- ,beforeSend:function(XMLHttpRequest ){
- var cToken = $.cookie(headtoken) || token;XMLHttpRequest.setRequestHeader(headtoken,cToken);
- $.data(thisrequest,'msg',showMsg(t_message,-1));
- //createProgressBar();
- }
- ,complete:function( ){
- hideMsg($.data(thisrequest,'msg'));
- }
- });
- };
- //添加参数
- if(services){
- this.appendServices(services);
- }
- /**
- * 将JSON序列化为一个字符串,
- * 相对于JSON.stringify,{}中的键值对会按照key升序顺序输出。
- */
- function stringify(o){
- var toString = Object.prototype.toString;
- var s = "";
- if(null === o){
- return "null";
- }else if(undefined === o){
- return "undefined";
- }else if("[object Function]" === toString.call(o)){
- return "\"[object Function]\"";
- }else if("[object Object]" === toString.call(o)){
- s += "{";
- var arr = [];
- for(var key in o){
- arr.push(key);
- }
- arr.sort();
- for(var i in arr){
- var key = arr[i];
- s += "\"" + key + "\":" + stringify(o[key]) + ",";
- }
- s = s.substring(0,s.length-1);
- s += "}";
- }else if("[object Array]" === toString.call(o)){
- s += "[";
- for(var i in o){
- s += stringify(o[i]);
- if(i != o.length-1){
- s += ",";
- }
- }
- s += "]";
- }else if("[object Number]" === toString.call(o)){
- if(isFinite(o)){
- return "" + o;
- }else if(isNaN(o)){
- return "NaN";
- }else if(Infinity === o){
- return "Infinity";
- }
- }else if("[object String]" === toString.call(o)){
- return "\"" + o + "\"";
- }else if("[object Boolean]" === toString.call(o)){
- return true === o?"true":"false"
- }else if("[object RegExp]" === toString.call(o)){
- return "/"+ o.source +"/"
- + (o.global?"g":"")
- + (o.ignoreCase?"i":"")
- + (o.multiline?"m":"");
- }else{
- return "\"" + toString.call(o) + "\"";
- }
- return s;
- }
- }
- /**
- * 在页面的左上角显示错误消息
- * @param msg 消息内容
- * @param timeout 秒为单位,0或者负数表示不自动隐藏
- * @author 吴英德
- **/
- var framework_message_layer;
- var clearIntervalID;
- function showMsg(msg,delay){
- var recurrectLocation=function(){
- if(framework_message_layer==null)
- {clearInterval(clearIntervalID);return;}
- var posX,posY;
- if (window.innerHeight) {
- posX = window.pageXOffset;
- posY = window.pageYOffset;
- }
- else if (document.documentElement && document.documentElement.scrollTop) {
- posX = document.documentElement.scrollLeft;
- posY = document.documentElement.scrollTop;
- }
- else if (document.body) {
- posX = document.body.scrollLeft;
- posY = document.body.scrollTop;
- }
- framework_message_layer.style.top=String(posY+10)+'px';
- framework_message_layer.style.right=String(posX+10)+'px';
- };
- if(framework_message_layer == null){
- framework_message_layer=document.createElement('div');
- framework_message_layer.className='err_message_blank_board';
- document.body.appendChild(framework_message_layer);
- clearIntervalID=window.setInterval(recurrectLocation,100);
- recurrectLocation();
- }
- var my_div = document.createElement('div');
- my_div.className='err_message';
- //Element.extend(my_div);
- my_div.innerHTML=msg;
- //增加判断:已经存在的信息,则不再重复提示
- if ($(".err_message:contains("+msg+")",document.body).length == 0) {
- framework_message_layer.appendChild(my_div);
- recurrectLocation();
- }
- if(delay>0){
- setTimeout(function(){
- jQuery(my_div).remove();
- if(jQuery(framework_message_layer).is(':empty')){
- jQuery(framework_message_layer).remove();
- window.clearInterval(clearIntervalID);
- framework_message_layer=null;
- }
- },delay*1000);
- }else{
- return my_div;
- }
- }
- /**隐藏右上角对应的消息
- * @param object 某消息对象,来自showMsg的返回值
- */
- function hideMsg(object){
- jQuery(object).remove();
- }
|