12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333583345833558336583375833858339583405834158342583435834458345583465834758348583495835058351583525835358354583555835658357583585835958360583615836258363583645836558366583675836858369583705837158372583735837458375583765837758378583795838058381583825838358384583855838658387583885838958390583915839258393583945839558396583975839858399584005840158402584035840458405584065840758408584095841058411584125841358414584155841658417584185841958420584215842258423584245842558426584275842858429584305843158432584335843458435584365843758438584395844058441584425844358444584455844658447584485844958450584515845258453584545845558456584575845858459584605846158462584635846458465584665846758468584695847058471584725847358474584755847658477584785847958480584815848258483584845848558486584875848858489584905849158492584935849458495584965849758498584995850058501585025850358504585055850658507585085850958510585115851258513585145851558516585175851858519585205852158522585235852458525585265852758528585295853058531585325853358534585355853658537585385853958540585415854258543585445854558546585475854858549585505855158552585535855458555585565855758558585595856058561585625856358564585655856658567585685856958570585715857258573585745857558576585775857858579585805858158582585835858458585585865858758588585895859058591585925859358594585955859658597585985859958600586015860258603586045860558606586075860858609586105861158612586135861458615586165861758618586195862058621586225862358624586255862658627586285862958630586315863258633586345863558636586375863858639586405864158642586435864458645586465864758648586495865058651586525865358654586555865658657586585865958660586615866258663586645866558666586675866858669586705867158672586735867458675586765867758678586795868058681586825868358684586855868658687586885868958690586915869258693586945869558696586975869858699587005870158702587035870458705587065870758708587095871058711587125871358714587155871658717587185871958720587215872258723587245872558726587275872858729587305873158732587335873458735587365873758738587395874058741587425874358744587455874658747587485874958750587515875258753587545875558756587575875858759587605876158762587635876458765587665876758768587695877058771587725877358774587755877658777587785877958780587815878258783587845878558786587875878858789587905879158792587935879458795587965879758798587995880058801588025880358804588055880658807588085880958810588115881258813588145881558816588175881858819588205882158822588235882458825588265882758828588295883058831588325883358834588355883658837588385883958840588415884258843588445884558846588475884858849588505885158852588535885458855588565885758858588595886058861588625886358864588655886658867588685886958870588715887258873588745887558876588775887858879588805888158882588835888458885588865888758888588895889058891588925889358894588955889658897588985889958900589015890258903589045890558906589075890858909589105891158912589135891458915589165891758918589195892058921589225892358924589255892658927589285892958930589315893258933589345893558936589375893858939589405894158942589435894458945589465894758948589495895058951589525895358954589555895658957589585895958960589615896258963589645896558966589675896858969589705897158972589735897458975589765897758978589795898058981589825898358984589855898658987589885898958990589915899258993589945899558996589975899858999590005900159002590035900459005590065900759008590095901059011590125901359014590155901659017590185901959020590215902259023590245902559026590275902859029590305903159032590335903459035590365903759038590395904059041590425904359044590455904659047590485904959050590515905259053590545905559056590575905859059590605906159062590635906459065590665906759068590695907059071590725907359074590755907659077590785907959080590815908259083590845908559086590875908859089590905909159092590935909459095590965909759098590995910059101591025910359104591055910659107591085910959110591115911259113591145911559116591175911859119591205912159122591235912459125591265912759128591295913059131591325913359134591355913659137591385913959140591415914259143591445914559146591475914859149591505915159152591535915459155591565915759158591595916059161591625916359164591655916659167591685916959170591715917259173591745917559176591775917859179591805918159182591835918459185591865918759188591895919059191591925919359194591955919659197591985919959200592015920259203592045920559206592075920859209592105921159212592135921459215592165921759218592195922059221592225922359224592255922659227592285922959230592315923259233592345923559236592375923859239592405924159242592435924459245592465924759248592495925059251592525925359254592555925659257592585925959260592615926259263592645926559266592675926859269592705927159272592735927459275592765927759278592795928059281592825928359284592855928659287592885928959290592915929259293592945929559296592975929859299593005930159302593035930459305593065930759308593095931059311593125931359314593155931659317593185931959320593215932259323593245932559326593275932859329593305933159332593335933459335593365933759338593395934059341593425934359344593455934659347593485934959350593515935259353593545935559356593575935859359593605936159362593635936459365593665936759368593695937059371593725937359374593755937659377593785937959380593815938259383593845938559386593875938859389593905939159392593935939459395593965939759398593995940059401594025940359404594055940659407594085940959410594115941259413594145941559416594175941859419594205942159422594235942459425594265942759428594295943059431594325943359434594355943659437594385943959440594415944259443594445944559446594475944859449594505945159452594535945459455594565945759458594595946059461594625946359464594655946659467594685946959470594715947259473594745947559476594775947859479594805948159482594835948459485594865948759488594895949059491594925949359494594955949659497594985949959500595015950259503595045950559506595075950859509595105951159512595135951459515595165951759518595195952059521595225952359524595255952659527595285952959530595315953259533595345953559536595375953859539595405954159542595435954459545595465954759548595495955059551595525955359554595555955659557595585955959560595615956259563595645956559566595675956859569595705957159572595735957459575595765957759578595795958059581595825958359584595855958659587595885958959590595915959259593595945959559596595975959859599596005960159602596035960459605596065960759608596095961059611596125961359614596155961659617596185961959620596215962259623596245962559626596275962859629596305963159632596335963459635596365963759638596395964059641596425964359644596455964659647596485964959650596515965259653596545965559656596575965859659596605966159662596635966459665596665966759668596695967059671596725967359674596755967659677596785967959680596815968259683596845968559686596875968859689596905969159692596935969459695596965969759698596995970059701597025970359704597055970659707597085970959710597115971259713597145971559716597175971859719597205972159722597235972459725597265972759728597295973059731597325973359734597355973659737597385973959740597415974259743597445974559746597475974859749597505975159752597535975459755597565975759758597595976059761597625976359764597655976659767597685976959770597715977259773597745977559776597775977859779597805978159782597835978459785597865978759788597895979059791597925979359794597955979659797597985979959800598015980259803598045980559806598075980859809598105981159812598135981459815598165981759818598195982059821598225982359824598255982659827598285982959830598315983259833598345983559836598375983859839598405984159842598435984459845598465984759848598495985059851598525985359854598555985659857598585985959860598615986259863598645986559866598675986859869598705987159872598735987459875598765987759878598795988059881598825988359884598855988659887598885988959890598915989259893598945989559896598975989859899599005990159902599035990459905599065990759908599095991059911599125991359914599155991659917599185991959920599215992259923599245992559926599275992859929599305993159932599335993459935599365993759938599395994059941599425994359944599455994659947599485994959950599515995259953599545995559956599575995859959599605996159962599635996459965599665996759968599695997059971599725997359974599755997659977599785997959980599815998259983599845998559986599875998859989599905999159992599935999459995599965999759998599996000060001600026000360004600056000660007600086000960010600116001260013600146001560016600176001860019600206002160022600236002460025600266002760028600296003060031600326003360034600356003660037600386003960040600416004260043600446004560046600476004860049600506005160052600536005460055600566005760058600596006060061600626006360064600656006660067600686006960070600716007260073600746007560076600776007860079600806008160082600836008460085600866008760088600896009060091600926009360094600956009660097600986009960100601016010260103601046010560106601076010860109601106011160112601136011460115601166011760118601196012060121601226012360124601256012660127601286012960130601316013260133601346013560136601376013860139601406014160142601436014460145601466014760148601496015060151601526015360154601556015660157601586015960160601616016260163601646016560166601676016860169601706017160172601736017460175601766017760178601796018060181601826018360184601856018660187601886018960190601916019260193601946019560196601976019860199602006020160202602036020460205602066020760208602096021060211602126021360214602156021660217602186021960220602216022260223602246022560226602276022860229602306023160232602336023460235602366023760238602396024060241602426024360244602456024660247602486024960250602516025260253602546025560256602576025860259602606026160262602636026460265602666026760268602696027060271602726027360274602756027660277602786027960280602816028260283602846028560286602876028860289602906029160292602936029460295602966029760298602996030060301603026030360304603056030660307603086030960310603116031260313603146031560316603176031860319603206032160322603236032460325603266032760328603296033060331603326033360334603356033660337603386033960340603416034260343603446034560346603476034860349603506035160352603536035460355603566035760358603596036060361603626036360364603656036660367603686036960370603716037260373603746037560376603776037860379603806038160382603836038460385603866038760388603896039060391603926039360394603956039660397603986039960400604016040260403604046040560406604076040860409604106041160412604136041460415604166041760418604196042060421604226042360424604256042660427604286042960430604316043260433604346043560436604376043860439604406044160442604436044460445604466044760448604496045060451604526045360454604556045660457604586045960460604616046260463604646046560466604676046860469604706047160472604736047460475604766047760478604796048060481604826048360484604856048660487604886048960490604916049260493604946049560496604976049860499605006050160502605036050460505605066050760508605096051060511605126051360514605156051660517605186051960520605216052260523605246052560526605276052860529605306053160532605336053460535605366053760538605396054060541605426054360544605456054660547605486054960550605516055260553605546055560556605576055860559605606056160562605636056460565605666056760568605696057060571605726057360574605756057660577605786057960580605816058260583605846058560586605876058860589605906059160592605936059460595605966059760598605996060060601606026060360604606056060660607606086060960610606116061260613606146061560616606176061860619606206062160622606236062460625606266062760628606296063060631606326063360634606356063660637606386063960640606416064260643606446064560646606476064860649606506065160652606536065460655606566065760658606596066060661606626066360664606656066660667606686066960670606716067260673606746067560676606776067860679606806068160682606836068460685606866068760688606896069060691606926069360694606956069660697606986069960700607016070260703607046070560706607076070860709607106071160712607136071460715607166071760718607196072060721607226072360724607256072660727607286072960730607316073260733607346073560736607376073860739607406074160742607436074460745607466074760748607496075060751607526075360754607556075660757607586075960760607616076260763607646076560766607676076860769607706077160772607736077460775607766077760778607796078060781607826078360784607856078660787607886078960790607916079260793607946079560796607976079860799608006080160802608036080460805608066080760808608096081060811608126081360814608156081660817608186081960820608216082260823608246082560826608276082860829608306083160832608336083460835608366083760838608396084060841608426084360844608456084660847608486084960850608516085260853608546085560856608576085860859608606086160862608636086460865608666086760868608696087060871608726087360874608756087660877608786087960880608816088260883608846088560886608876088860889608906089160892608936089460895608966089760898608996090060901609026090360904609056090660907609086090960910609116091260913609146091560916609176091860919609206092160922609236092460925609266092760928609296093060931609326093360934609356093660937609386093960940609416094260943609446094560946609476094860949609506095160952609536095460955609566095760958609596096060961609626096360964609656096660967609686096960970609716097260973609746097560976609776097860979609806098160982609836098460985609866098760988609896099060991609926099360994609956099660997609986099961000610016100261003610046100561006610076100861009610106101161012610136101461015610166101761018610196102061021610226102361024610256102661027610286102961030610316103261033610346103561036610376103861039610406104161042610436104461045610466104761048610496105061051610526105361054610556105661057610586105961060610616106261063610646106561066610676106861069610706107161072610736107461075610766107761078610796108061081610826108361084610856108661087610886108961090610916109261093610946109561096610976109861099611006110161102611036110461105611066110761108611096111061111611126111361114611156111661117611186111961120611216112261123611246112561126611276112861129611306113161132611336113461135611366113761138611396114061141611426114361144611456114661147611486114961150611516115261153611546115561156611576115861159611606116161162611636116461165611666116761168611696117061171611726117361174611756117661177611786117961180611816118261183611846118561186611876118861189611906119161192611936119461195611966119761198611996120061201612026120361204612056120661207612086120961210612116121261213612146121561216612176121861219612206122161222612236122461225612266122761228612296123061231612326123361234612356123661237612386123961240612416124261243612446124561246612476124861249612506125161252612536125461255612566125761258612596126061261612626126361264612656126661267612686126961270612716127261273612746127561276612776127861279612806128161282612836128461285612866128761288612896129061291612926129361294612956129661297612986129961300613016130261303613046130561306613076130861309613106131161312613136131461315613166131761318613196132061321613226132361324613256132661327613286132961330613316133261333613346133561336613376133861339613406134161342613436134461345613466134761348613496135061351613526135361354613556135661357613586135961360613616136261363613646136561366613676136861369613706137161372613736137461375613766137761378613796138061381613826138361384613856138661387613886138961390613916139261393613946139561396613976139861399614006140161402614036140461405614066140761408614096141061411614126141361414614156141661417614186141961420614216142261423614246142561426614276142861429614306143161432614336143461435614366143761438614396144061441614426144361444614456144661447614486144961450614516145261453614546145561456614576145861459614606146161462614636146461465614666146761468614696147061471614726147361474614756147661477614786147961480614816148261483614846148561486614876148861489614906149161492614936149461495614966149761498614996150061501615026150361504615056150661507615086150961510615116151261513615146151561516615176151861519615206152161522615236152461525615266152761528615296153061531615326153361534615356153661537615386153961540615416154261543615446154561546615476154861549615506155161552615536155461555615566155761558615596156061561615626156361564615656156661567615686156961570615716157261573615746157561576615776157861579615806158161582615836158461585615866158761588615896159061591615926159361594615956159661597615986159961600616016160261603616046160561606616076160861609616106161161612616136161461615616166161761618616196162061621616226162361624616256162661627616286162961630616316163261633616346163561636616376163861639616406164161642616436164461645616466164761648616496165061651616526165361654616556165661657616586165961660616616166261663616646166561666616676166861669616706167161672616736167461675616766167761678616796168061681616826168361684616856168661687616886168961690616916169261693616946169561696616976169861699617006170161702617036170461705617066170761708617096171061711617126171361714617156171661717617186171961720617216172261723617246172561726617276172861729617306173161732617336173461735617366173761738617396174061741617426174361744617456174661747617486174961750617516175261753617546175561756617576175861759617606176161762617636176461765617666176761768617696177061771617726177361774617756177661777617786177961780617816178261783617846178561786617876178861789617906179161792617936179461795617966179761798617996180061801618026180361804618056180661807618086180961810618116181261813618146181561816618176181861819618206182161822618236182461825618266182761828618296183061831618326183361834618356183661837618386183961840618416184261843618446184561846618476184861849618506185161852618536185461855618566185761858618596186061861618626186361864618656186661867618686186961870618716187261873618746187561876618776187861879618806188161882618836188461885618866188761888618896189061891618926189361894618956189661897618986189961900619016190261903619046190561906619076190861909619106191161912619136191461915619166191761918619196192061921619226192361924619256192661927619286192961930619316193261933619346193561936619376193861939619406194161942619436194461945619466194761948619496195061951619526195361954619556195661957619586195961960619616196261963619646196561966619676196861969619706197161972619736197461975619766197761978619796198061981619826198361984619856198661987619886198961990619916199261993619946199561996619976199861999620006200162002620036200462005620066200762008620096201062011620126201362014620156201662017620186201962020620216202262023620246202562026620276202862029620306203162032620336203462035620366203762038620396204062041620426204362044620456204662047620486204962050620516205262053620546205562056620576205862059620606206162062620636206462065620666206762068620696207062071620726207362074620756207662077620786207962080620816208262083620846208562086620876208862089620906209162092620936209462095620966209762098620996210062101621026210362104621056210662107621086210962110621116211262113621146211562116621176211862119621206212162122621236212462125621266212762128621296213062131621326213362134621356213662137621386213962140621416214262143621446214562146621476214862149621506215162152621536215462155621566215762158621596216062161621626216362164621656216662167621686216962170621716217262173621746217562176621776217862179621806218162182621836218462185621866218762188621896219062191621926219362194621956219662197621986219962200622016220262203622046220562206622076220862209622106221162212622136221462215622166221762218622196222062221622226222362224622256222662227622286222962230622316223262233622346223562236622376223862239622406224162242622436224462245622466224762248622496225062251622526225362254622556225662257622586225962260622616226262263622646226562266622676226862269622706227162272622736227462275622766227762278622796228062281622826228362284622856228662287622886228962290622916229262293622946229562296622976229862299623006230162302623036230462305623066230762308623096231062311623126231362314623156231662317623186231962320623216232262323623246232562326623276232862329623306233162332623336233462335623366233762338623396234062341623426234362344623456234662347623486234962350623516235262353623546235562356623576235862359623606236162362623636236462365623666236762368623696237062371623726237362374623756237662377623786237962380623816238262383623846238562386623876238862389623906239162392623936239462395623966239762398623996240062401624026240362404624056240662407624086240962410624116241262413624146241562416624176241862419624206242162422624236242462425624266242762428624296243062431624326243362434624356243662437624386243962440624416244262443624446244562446624476244862449624506245162452624536245462455624566245762458624596246062461624626246362464624656246662467624686246962470624716247262473624746247562476624776247862479624806248162482624836248462485624866248762488624896249062491624926249362494624956249662497624986249962500625016250262503625046250562506625076250862509625106251162512625136251462515625166251762518625196252062521625226252362524625256252662527625286252962530625316253262533625346253562536625376253862539625406254162542625436254462545625466254762548625496255062551625526255362554625556255662557625586255962560625616256262563625646256562566625676256862569625706257162572625736257462575625766257762578625796258062581625826258362584625856258662587625886258962590625916259262593625946259562596625976259862599626006260162602626036260462605626066260762608626096261062611626126261362614626156261662617626186261962620626216262262623626246262562626626276262862629626306263162632626336263462635626366263762638626396264062641626426264362644626456264662647626486264962650626516265262653626546265562656626576265862659626606266162662626636266462665626666266762668626696267062671626726267362674626756267662677626786267962680626816268262683626846268562686626876268862689626906269162692626936269462695626966269762698626996270062701627026270362704627056270662707627086270962710627116271262713627146271562716627176271862719627206272162722627236272462725627266272762728627296273062731627326273362734627356273662737627386273962740627416274262743627446274562746627476274862749627506275162752627536275462755627566275762758627596276062761627626276362764627656276662767627686276962770627716277262773627746277562776627776277862779627806278162782627836278462785627866278762788627896279062791627926279362794627956279662797627986279962800628016280262803628046280562806628076280862809628106281162812628136281462815628166281762818628196282062821628226282362824628256282662827628286282962830628316283262833628346283562836628376283862839628406284162842628436284462845628466284762848628496285062851628526285362854628556285662857628586285962860628616286262863628646286562866628676286862869628706287162872628736287462875628766287762878628796288062881628826288362884628856288662887628886288962890628916289262893628946289562896628976289862899629006290162902629036290462905629066290762908629096291062911629126291362914629156291662917629186291962920629216292262923629246292562926629276292862929629306293162932629336293462935629366293762938629396294062941629426294362944629456294662947629486294962950629516295262953629546295562956629576295862959629606296162962629636296462965629666296762968629696297062971629726297362974629756297662977629786297962980629816298262983629846298562986629876298862989629906299162992629936299462995629966299762998629996300063001630026300363004630056300663007630086300963010630116301263013630146301563016630176301863019630206302163022630236302463025630266302763028630296303063031630326303363034630356303663037630386303963040630416304263043630446304563046630476304863049630506305163052630536305463055630566305763058630596306063061630626306363064630656306663067630686306963070630716307263073630746307563076630776307863079630806308163082630836308463085630866308763088630896309063091630926309363094630956309663097630986309963100631016310263103631046310563106631076310863109631106311163112631136311463115631166311763118631196312063121631226312363124631256312663127631286312963130631316313263133631346313563136631376313863139631406314163142631436314463145631466314763148631496315063151631526315363154631556315663157631586315963160631616316263163631646316563166631676316863169631706317163172631736317463175631766317763178631796318063181631826318363184631856318663187631886318963190631916319263193631946319563196631976319863199632006320163202632036320463205632066320763208632096321063211632126321363214632156321663217632186321963220632216322263223632246322563226632276322863229632306323163232632336323463235632366323763238632396324063241632426324363244632456324663247632486324963250632516325263253632546325563256632576325863259632606326163262632636326463265632666326763268632696327063271632726327363274632756327663277632786327963280632816328263283632846328563286632876328863289632906329163292632936329463295632966329763298632996330063301633026330363304633056330663307633086330963310633116331263313633146331563316633176331863319633206332163322633236332463325633266332763328633296333063331633326333363334633356333663337633386333963340633416334263343633446334563346633476334863349633506335163352633536335463355633566335763358633596336063361633626336363364633656336663367633686336963370633716337263373633746337563376633776337863379633806338163382633836338463385633866338763388633896339063391633926339363394633956339663397633986339963400634016340263403634046340563406634076340863409634106341163412634136341463415634166341763418634196342063421634226342363424634256342663427634286342963430634316343263433634346343563436634376343863439634406344163442634436344463445634466344763448634496345063451634526345363454634556345663457634586345963460634616346263463634646346563466634676346863469634706347163472634736347463475634766347763478634796348063481634826348363484634856348663487634886348963490634916349263493634946349563496634976349863499635006350163502635036350463505635066350763508635096351063511635126351363514635156351663517635186351963520635216352263523635246352563526635276352863529635306353163532635336353463535635366353763538635396354063541635426354363544635456354663547635486354963550635516355263553635546355563556635576355863559635606356163562635636356463565635666356763568635696357063571635726357363574635756357663577635786357963580635816358263583635846358563586635876358863589635906359163592635936359463595635966359763598635996360063601636026360363604636056360663607636086360963610636116361263613636146361563616636176361863619636206362163622636236362463625636266362763628636296363063631636326363363634636356363663637636386363963640636416364263643636446364563646636476364863649636506365163652636536365463655636566365763658636596366063661636626366363664636656366663667636686366963670636716367263673636746367563676636776367863679636806368163682636836368463685636866368763688636896369063691636926369363694636956369663697636986369963700637016370263703637046370563706637076370863709637106371163712637136371463715637166371763718637196372063721637226372363724637256372663727637286372963730637316373263733637346373563736637376373863739637406374163742637436374463745637466374763748637496375063751637526375363754637556375663757637586375963760637616376263763637646376563766637676376863769637706377163772637736377463775637766377763778637796378063781637826378363784637856378663787637886378963790637916379263793637946379563796637976379863799638006380163802638036380463805638066380763808638096381063811638126381363814638156381663817638186381963820638216382263823638246382563826638276382863829638306383163832638336383463835638366383763838638396384063841638426384363844638456384663847638486384963850638516385263853638546385563856638576385863859638606386163862638636386463865638666386763868638696387063871638726387363874638756387663877638786387963880638816388263883638846388563886638876388863889638906389163892638936389463895638966389763898638996390063901639026390363904639056390663907639086390963910639116391263913639146391563916639176391863919639206392163922639236392463925639266392763928639296393063931639326393363934639356393663937639386393963940639416394263943639446394563946639476394863949639506395163952639536395463955639566395763958639596396063961639626396363964639656396663967639686396963970639716397263973639746397563976639776397863979639806398163982639836398463985639866398763988639896399063991639926399363994639956399663997639986399964000640016400264003640046400564006640076400864009640106401164012640136401464015640166401764018640196402064021640226402364024640256402664027640286402964030640316403264033640346403564036640376403864039640406404164042640436404464045640466404764048640496405064051640526405364054640556405664057640586405964060640616406264063640646406564066640676406864069640706407164072640736407464075640766407764078640796408064081640826408364084640856408664087640886408964090640916409264093640946409564096640976409864099641006410164102641036410464105641066410764108641096411064111641126411364114641156411664117641186411964120641216412264123641246412564126641276412864129641306413164132641336413464135641366413764138641396414064141641426414364144641456414664147641486414964150641516415264153641546415564156641576415864159641606416164162641636416464165641666416764168641696417064171641726417364174641756417664177641786417964180641816418264183641846418564186641876418864189641906419164192641936419464195641966419764198641996420064201642026420364204642056420664207642086420964210642116421264213642146421564216642176421864219642206422164222642236422464225642266422764228642296423064231642326423364234642356423664237642386423964240642416424264243642446424564246642476424864249642506425164252642536425464255642566425764258642596426064261642626426364264642656426664267642686426964270642716427264273642746427564276642776427864279642806428164282642836428464285642866428764288642896429064291642926429364294642956429664297642986429964300643016430264303643046430564306643076430864309643106431164312643136431464315643166431764318643196432064321643226432364324643256432664327643286432964330643316433264333643346433564336643376433864339643406434164342643436434464345643466434764348643496435064351643526435364354643556435664357643586435964360643616436264363643646436564366643676436864369643706437164372643736437464375643766437764378643796438064381643826438364384643856438664387643886438964390643916439264393643946439564396643976439864399644006440164402644036440464405644066440764408644096441064411644126441364414644156441664417644186441964420644216442264423644246442564426644276442864429644306443164432644336443464435644366443764438644396444064441644426444364444644456444664447644486444964450644516445264453644546445564456644576445864459644606446164462644636446464465644666446764468644696447064471644726447364474644756447664477644786447964480644816448264483644846448564486644876448864489644906449164492644936449464495644966449764498644996450064501645026450364504645056450664507645086450964510645116451264513645146451564516645176451864519645206452164522645236452464525645266452764528645296453064531645326453364534645356453664537645386453964540645416454264543645446454564546645476454864549645506455164552645536455464555645566455764558645596456064561645626456364564645656456664567645686456964570645716457264573645746457564576645776457864579645806458164582645836458464585645866458764588645896459064591645926459364594645956459664597645986459964600646016460264603646046460564606646076460864609646106461164612646136461464615646166461764618646196462064621646226462364624646256462664627646286462964630646316463264633646346463564636646376463864639646406464164642646436464464645646466464764648646496465064651646526465364654646556465664657646586465964660646616466264663646646466564666646676466864669646706467164672646736467464675646766467764678646796468064681646826468364684646856468664687646886468964690646916469264693646946469564696646976469864699647006470164702647036470464705647066470764708647096471064711647126471364714647156471664717647186471964720647216472264723647246472564726647276472864729647306473164732647336473464735647366473764738647396474064741647426474364744647456474664747647486474964750647516475264753647546475564756647576475864759647606476164762647636476464765647666476764768647696477064771647726477364774647756477664777647786477964780647816478264783647846478564786647876478864789647906479164792647936479464795647966479764798647996480064801648026480364804648056480664807648086480964810648116481264813648146481564816648176481864819648206482164822648236482464825648266482764828648296483064831648326483364834648356483664837648386483964840648416484264843648446484564846648476484864849648506485164852648536485464855648566485764858648596486064861648626486364864648656486664867648686486964870648716487264873648746487564876648776487864879648806488164882648836488464885648866488764888648896489064891648926489364894648956489664897648986489964900649016490264903649046490564906649076490864909649106491164912649136491464915649166491764918649196492064921649226492364924649256492664927649286492964930649316493264933649346493564936649376493864939649406494164942649436494464945649466494764948649496495064951649526495364954649556495664957649586495964960649616496264963649646496564966649676496864969649706497164972649736497464975649766497764978649796498064981649826498364984649856498664987649886498964990649916499264993649946499564996649976499864999650006500165002650036500465005650066500765008650096501065011650126501365014650156501665017650186501965020650216502265023650246502565026650276502865029650306503165032650336503465035650366503765038650396504065041650426504365044650456504665047650486504965050650516505265053650546505565056650576505865059650606506165062650636506465065650666506765068650696507065071650726507365074650756507665077650786507965080650816508265083650846508565086650876508865089650906509165092650936509465095650966509765098650996510065101651026510365104651056510665107651086510965110651116511265113651146511565116651176511865119651206512165122651236512465125651266512765128651296513065131651326513365134651356513665137651386513965140651416514265143651446514565146651476514865149651506515165152651536515465155651566515765158651596516065161651626516365164651656516665167651686516965170651716517265173651746517565176651776517865179651806518165182651836518465185651866518765188651896519065191651926519365194651956519665197651986519965200652016520265203652046520565206652076520865209652106521165212652136521465215652166521765218652196522065221652226522365224652256522665227652286522965230652316523265233652346523565236652376523865239652406524165242652436524465245652466524765248652496525065251652526525365254652556525665257652586525965260652616526265263652646526565266652676526865269652706527165272652736527465275652766527765278652796528065281652826528365284652856528665287652886528965290652916529265293652946529565296652976529865299653006530165302653036530465305653066530765308653096531065311653126531365314653156531665317653186531965320653216532265323653246532565326653276532865329653306533165332653336533465335653366533765338653396534065341653426534365344653456534665347653486534965350653516535265353653546535565356653576535865359653606536165362653636536465365653666536765368653696537065371653726537365374653756537665377653786537965380653816538265383653846538565386653876538865389653906539165392653936539465395653966539765398653996540065401654026540365404654056540665407654086540965410654116541265413654146541565416654176541865419654206542165422654236542465425654266542765428654296543065431654326543365434654356543665437654386543965440654416544265443654446544565446654476544865449654506545165452654536545465455654566545765458654596546065461654626546365464654656546665467654686546965470654716547265473654746547565476654776547865479654806548165482654836548465485654866548765488654896549065491654926549365494654956549665497654986549965500655016550265503655046550565506655076550865509655106551165512655136551465515655166551765518655196552065521655226552365524655256552665527655286552965530655316553265533655346553565536655376553865539655406554165542655436554465545655466554765548655496555065551655526555365554655556555665557655586555965560655616556265563655646556565566655676556865569655706557165572655736557465575655766557765578655796558065581655826558365584655856558665587655886558965590655916559265593655946559565596655976559865599656006560165602656036560465605656066560765608656096561065611656126561365614656156561665617656186561965620656216562265623656246562565626656276562865629656306563165632656336563465635656366563765638656396564065641656426564365644656456564665647656486564965650656516565265653656546565565656656576565865659656606566165662656636566465665656666566765668656696567065671656726567365674656756567665677656786567965680656816568265683656846568565686656876568865689656906569165692656936569465695656966569765698656996570065701657026570365704657056570665707657086570965710657116571265713657146571565716657176571865719657206572165722657236572465725657266572765728657296573065731657326573365734657356573665737657386573965740657416574265743657446574565746657476574865749657506575165752657536575465755657566575765758657596576065761657626576365764657656576665767657686576965770657716577265773657746577565776657776577865779657806578165782657836578465785657866578765788657896579065791657926579365794657956579665797657986579965800658016580265803658046580565806658076580865809658106581165812658136581465815658166581765818658196582065821658226582365824658256582665827658286582965830658316583265833658346583565836658376583865839658406584165842658436584465845658466584765848658496585065851658526585365854658556585665857658586585965860658616586265863658646586565866658676586865869658706587165872658736587465875658766587765878658796588065881658826588365884658856588665887658886588965890658916589265893658946589565896658976589865899659006590165902659036590465905659066590765908659096591065911659126591365914659156591665917659186591965920659216592265923659246592565926659276592865929659306593165932659336593465935659366593765938659396594065941659426594365944659456594665947659486594965950659516595265953659546595565956659576595865959659606596165962659636596465965659666596765968659696597065971659726597365974659756597665977659786597965980659816598265983659846598565986659876598865989659906599165992659936599465995659966599765998659996600066001660026600366004660056600666007660086600966010660116601266013660146601566016660176601866019660206602166022660236602466025660266602766028660296603066031660326603366034660356603666037660386603966040660416604266043660446604566046660476604866049660506605166052660536605466055660566605766058660596606066061660626606366064660656606666067660686606966070660716607266073660746607566076660776607866079660806608166082660836608466085660866608766088660896609066091660926609366094660956609666097660986609966100661016610266103661046610566106661076610866109661106611166112661136611466115661166611766118661196612066121661226612366124661256612666127661286612966130661316613266133661346613566136661376613866139661406614166142661436614466145661466614766148661496615066151661526615366154661556615666157661586615966160661616616266163661646616566166661676616866169661706617166172661736617466175661766617766178661796618066181661826618366184661856618666187661886618966190661916619266193661946619566196661976619866199662006620166202662036620466205662066620766208662096621066211662126621366214662156621666217662186621966220662216622266223662246622566226662276622866229662306623166232662336623466235662366623766238662396624066241662426624366244662456624666247662486624966250662516625266253662546625566256662576625866259662606626166262662636626466265662666626766268662696627066271662726627366274662756627666277662786627966280662816628266283662846628566286662876628866289662906629166292662936629466295662966629766298662996630066301663026630366304663056630666307663086630966310663116631266313663146631566316663176631866319663206632166322663236632466325663266632766328663296633066331663326633366334663356633666337663386633966340663416634266343663446634566346663476634866349663506635166352663536635466355663566635766358663596636066361663626636366364663656636666367663686636966370663716637266373663746637566376663776637866379663806638166382663836638466385663866638766388663896639066391663926639366394663956639666397663986639966400664016640266403664046640566406664076640866409664106641166412664136641466415664166641766418664196642066421664226642366424664256642666427664286642966430664316643266433664346643566436664376643866439664406644166442664436644466445664466644766448664496645066451664526645366454664556645666457664586645966460664616646266463664646646566466664676646866469664706647166472664736647466475664766647766478664796648066481664826648366484664856648666487664886648966490664916649266493664946649566496664976649866499665006650166502665036650466505665066650766508665096651066511665126651366514665156651666517665186651966520665216652266523665246652566526665276652866529665306653166532665336653466535665366653766538665396654066541665426654366544665456654666547665486654966550665516655266553665546655566556665576655866559665606656166562665636656466565665666656766568665696657066571665726657366574665756657666577665786657966580665816658266583665846658566586665876658866589665906659166592665936659466595665966659766598665996660066601666026660366604666056660666607666086660966610666116661266613666146661566616666176661866619666206662166622666236662466625666266662766628666296663066631666326663366634666356663666637666386663966640666416664266643666446664566646666476664866649666506665166652666536665466655666566665766658666596666066661666626666366664666656666666667666686666966670666716667266673666746667566676666776667866679666806668166682666836668466685666866668766688666896669066691666926669366694666956669666697666986669966700667016670266703667046670566706667076670866709667106671166712667136671466715667166671766718667196672066721667226672366724667256672666727667286672966730667316673266733667346673566736667376673866739667406674166742667436674466745667466674766748667496675066751667526675366754667556675666757667586675966760667616676266763667646676566766667676676866769667706677166772667736677466775667766677766778667796678066781667826678366784667856678666787667886678966790667916679266793667946679566796667976679866799668006680166802668036680466805668066680766808668096681066811668126681366814668156681666817668186681966820668216682266823668246682566826668276682866829668306683166832668336683466835668366683766838668396684066841668426684366844668456684666847668486684966850668516685266853668546685566856668576685866859668606686166862668636686466865668666686766868668696687066871668726687366874668756687666877668786687966880668816688266883668846688566886668876688866889668906689166892668936689466895668966689766898668996690066901669026690366904669056690666907669086690966910669116691266913669146691566916669176691866919669206692166922669236692466925669266692766928669296693066931669326693366934669356693666937669386693966940669416694266943669446694566946669476694866949669506695166952669536695466955669566695766958669596696066961669626696366964669656696666967669686696966970669716697266973669746697566976669776697866979669806698166982669836698466985669866698766988669896699066991669926699366994669956699666997669986699967000670016700267003670046700567006670076700867009670106701167012670136701467015670166701767018670196702067021670226702367024670256702667027670286702967030670316703267033670346703567036670376703867039670406704167042670436704467045670466704767048670496705067051670526705367054670556705667057670586705967060670616706267063670646706567066670676706867069670706707167072670736707467075670766707767078670796708067081670826708367084670856708667087670886708967090670916709267093670946709567096670976709867099671006710167102671036710467105671066710767108671096711067111671126711367114671156711667117671186711967120671216712267123671246712567126671276712867129671306713167132671336713467135671366713767138671396714067141671426714367144671456714667147671486714967150671516715267153671546715567156671576715867159671606716167162671636716467165671666716767168671696717067171671726717367174671756717667177671786717967180671816718267183671846718567186671876718867189671906719167192671936719467195671966719767198671996720067201672026720367204672056720667207672086720967210672116721267213672146721567216672176721867219672206722167222672236722467225672266722767228672296723067231672326723367234672356723667237672386723967240672416724267243672446724567246672476724867249672506725167252672536725467255672566725767258672596726067261672626726367264672656726667267672686726967270672716727267273672746727567276672776727867279672806728167282672836728467285672866728767288672896729067291672926729367294672956729667297672986729967300673016730267303673046730567306673076730867309673106731167312673136731467315673166731767318673196732067321673226732367324673256732667327673286732967330673316733267333673346733567336673376733867339673406734167342673436734467345673466734767348673496735067351673526735367354673556735667357673586735967360673616736267363673646736567366673676736867369673706737167372673736737467375673766737767378673796738067381673826738367384673856738667387673886738967390673916739267393673946739567396673976739867399674006740167402674036740467405674066740767408674096741067411674126741367414674156741667417674186741967420674216742267423674246742567426674276742867429674306743167432674336743467435674366743767438674396744067441674426744367444674456744667447674486744967450674516745267453674546745567456674576745867459674606746167462674636746467465674666746767468674696747067471674726747367474674756747667477674786747967480674816748267483674846748567486674876748867489674906749167492674936749467495674966749767498674996750067501675026750367504675056750667507675086750967510675116751267513675146751567516675176751867519675206752167522675236752467525675266752767528675296753067531675326753367534675356753667537675386753967540675416754267543675446754567546675476754867549675506755167552675536755467555675566755767558675596756067561675626756367564675656756667567675686756967570675716757267573675746757567576675776757867579675806758167582675836758467585675866758767588675896759067591675926759367594675956759667597675986759967600676016760267603676046760567606676076760867609676106761167612676136761467615676166761767618676196762067621676226762367624676256762667627676286762967630676316763267633676346763567636676376763867639676406764167642676436764467645676466764767648676496765067651676526765367654676556765667657676586765967660676616766267663676646766567666676676766867669676706767167672676736767467675676766767767678676796768067681676826768367684676856768667687676886768967690676916769267693676946769567696676976769867699677006770167702677036770467705677066770767708677096771067711677126771367714677156771667717677186771967720677216772267723677246772567726677276772867729677306773167732677336773467735677366773767738677396774067741677426774367744677456774667747677486774967750677516775267753677546775567756677576775867759677606776167762677636776467765677666776767768677696777067771677726777367774677756777667777677786777967780677816778267783677846778567786677876778867789677906779167792677936779467795677966779767798677996780067801678026780367804678056780667807678086780967810678116781267813 |
- (function (global, factory) {
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
- typeof define === 'function' && define.amd ? define(['exports'], factory) :
- (factory((global.ionicBundle = global.ionicBundle || {})));
- }(this, (function (exports) { 'use strict';
-
- /*! *****************************************************************************
- Copyright (c) Microsoft Corporation. All rights reserved.
- Licensed under the Apache License, Version 2.0 (the "License"); you may not use
- this file except in compliance with the License. You may obtain a copy of the
- License at http://www.apache.org/licenses/LICENSE-2.0
-
- THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
- WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
- MERCHANTABLITY OR NON-INFRINGEMENT.
-
- See the Apache Version 2.0 License for specific language governing permissions
- and limitations under the License.
- ***************************************************************************** */
- /* global Reflect, Promise */
-
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
-
- function __extends$1(d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- function __values(o) {
- var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
- if (m) return m.call(o);
- return {
- next: function () {
- if (o && i >= o.length) o = void 0;
- return { value: o && o[i++], done: !o };
- }
- };
- }
-
- function __read(o, n) {
- var m = typeof Symbol === "function" && o[Symbol.iterator];
- if (!m) return o;
- var i = m.call(o), r, ar = [], e;
- try {
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
- }
- catch (error) { e = { error: error }; }
- finally {
- try {
- if (r && !r.done && (m = i["return"])) m.call(i);
- }
- finally { if (e) throw e.error; }
- }
- return ar;
- }
-
-
-
- function __await(v) {
- return this instanceof __await ? (this.v = v, this) : new __await(v);
- }
-
- var commonjsGlobal = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
-
-
-
-
-
- function createCommonjsModule(fn, module) {
- return module = { exports: {} }, fn(module, module.exports), module.exports;
- }
-
- // CommonJS / Node have global context exposed as "global" variable.
- // We don't want to include the whole node.d.ts this this compilation unit so we'll just fake
- // the global "global" var for now.
- var __window$1 = typeof window !== 'undefined' && window;
- var __self$1 = typeof self !== 'undefined' && typeof WorkerGlobalScope !== 'undefined' &&
- self instanceof WorkerGlobalScope && self;
- var __global$1 = typeof commonjsGlobal !== 'undefined' && commonjsGlobal;
- var _root = __window$1 || __global$1 || __self$1;
- var root_1 = _root;
- // Workaround Closure Compiler restriction: The body of a goog.module cannot use throw.
- // This is needed when used with angular/tsickle which inserts a goog.module statement.
- // Wrap in IIFE
- (function () {
- if (!_root) {
- throw new Error('RxJS could not find any global context (window, self, global)');
- }
- })();
-
- var root = {
- root: root_1
- };
-
- function isFunction(x) {
- return typeof x === 'function';
- }
- var isFunction_2 = isFunction;
-
- var isFunction_1 = {
- isFunction: isFunction_2
- };
-
- var isArray_1 = Array.isArray || (function (x) { return x && typeof x.length === 'number'; });
-
- var isArray = {
- isArray: isArray_1
- };
-
- function isObject(x) {
- return x != null && typeof x === 'object';
- }
- var isObject_2 = isObject;
-
- var isObject_1 = {
- isObject: isObject_2
- };
-
- // typeof any so that it we don't have to cast when comparing a result to the error object
- var errorObject_1 = { e: {} };
-
- var errorObject = {
- errorObject: errorObject_1
- };
-
- var tryCatchTarget;
- function tryCatcher() {
- try {
- return tryCatchTarget.apply(this, arguments);
- }
- catch (e) {
- errorObject.errorObject.e = e;
- return errorObject.errorObject;
- }
- }
- function tryCatch(fn) {
- tryCatchTarget = fn;
- return tryCatcher;
- }
- var tryCatch_2 = tryCatch;
-
-
- var tryCatch_1 = {
- tryCatch: tryCatch_2
- };
-
- var __extends$3 = (commonjsGlobal && commonjsGlobal.__extends) || function (d, b) {
- for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- /**
- * An error thrown when one or more errors have occurred during the
- * `unsubscribe` of a {@link Subscription}.
- */
- var UnsubscriptionError = (function (_super) {
- __extends$3(UnsubscriptionError, _super);
- function UnsubscriptionError(errors) {
- _super.call(this);
- this.errors = errors;
- var err = Error.call(this, errors ?
- errors.length + " errors occurred during unsubscription:\n " + errors.map(function (err, i) { return ((i + 1) + ") " + err.toString()); }).join('\n ') : '');
- this.name = err.name = 'UnsubscriptionError';
- this.stack = err.stack;
- this.message = err.message;
- }
- return UnsubscriptionError;
- }(Error));
- var UnsubscriptionError_2 = UnsubscriptionError;
-
- var UnsubscriptionError_1 = {
- UnsubscriptionError: UnsubscriptionError_2
- };
-
- /**
- * Represents a disposable resource, such as the execution of an Observable. A
- * Subscription has one important method, `unsubscribe`, that takes no argument
- * and just disposes the resource held by the subscription.
- *
- * Additionally, subscriptions may be grouped together through the `add()`
- * method, which will attach a child Subscription to the current Subscription.
- * When a Subscription is unsubscribed, all its children (and its grandchildren)
- * will be unsubscribed as well.
- *
- * @class Subscription
- */
- var Subscription = (function () {
- /**
- * @param {function(): void} [unsubscribe] A function describing how to
- * perform the disposal of resources when the `unsubscribe` method is called.
- */
- function Subscription(unsubscribe) {
- /**
- * A flag to indicate whether this Subscription has already been unsubscribed.
- * @type {boolean}
- */
- this.closed = false;
- this._parent = null;
- this._parents = null;
- this._subscriptions = null;
- if (unsubscribe) {
- this._unsubscribe = unsubscribe;
- }
- }
- /**
- * Disposes the resources held by the subscription. May, for instance, cancel
- * an ongoing Observable execution or cancel any other type of work that
- * started when the Subscription was created.
- * @return {void}
- */
- Subscription.prototype.unsubscribe = function () {
- var hasErrors = false;
- var errors;
- if (this.closed) {
- return;
- }
- var _a = this, _parent = _a._parent, _parents = _a._parents, _unsubscribe = _a._unsubscribe, _subscriptions = _a._subscriptions;
- this.closed = true;
- this._parent = null;
- this._parents = null;
- // null out _subscriptions first so any child subscriptions that attempt
- // to remove themselves from this subscription will noop
- this._subscriptions = null;
- var index = -1;
- var len = _parents ? _parents.length : 0;
- // if this._parent is null, then so is this._parents, and we
- // don't have to remove ourselves from any parent subscriptions.
- while (_parent) {
- _parent.remove(this);
- // if this._parents is null or index >= len,
- // then _parent is set to null, and the loop exits
- _parent = ++index < len && _parents[index] || null;
- }
- if (isFunction_1.isFunction(_unsubscribe)) {
- var trial = tryCatch_1.tryCatch(_unsubscribe).call(this);
- if (trial === errorObject.errorObject) {
- hasErrors = true;
- errors = errors || (errorObject.errorObject.e instanceof UnsubscriptionError_1.UnsubscriptionError ?
- flattenUnsubscriptionErrors(errorObject.errorObject.e.errors) : [errorObject.errorObject.e]);
- }
- }
- if (isArray.isArray(_subscriptions)) {
- index = -1;
- len = _subscriptions.length;
- while (++index < len) {
- var sub = _subscriptions[index];
- if (isObject_1.isObject(sub)) {
- var trial = tryCatch_1.tryCatch(sub.unsubscribe).call(sub);
- if (trial === errorObject.errorObject) {
- hasErrors = true;
- errors = errors || [];
- var err = errorObject.errorObject.e;
- if (err instanceof UnsubscriptionError_1.UnsubscriptionError) {
- errors = errors.concat(flattenUnsubscriptionErrors(err.errors));
- }
- else {
- errors.push(err);
- }
- }
- }
- }
- }
- if (hasErrors) {
- throw new UnsubscriptionError_1.UnsubscriptionError(errors);
- }
- };
- /**
- * Adds a tear down to be called during the unsubscribe() of this
- * Subscription.
- *
- * If the tear down being added is a subscription that is already
- * unsubscribed, is the same reference `add` is being called on, or is
- * `Subscription.EMPTY`, it will not be added.
- *
- * If this subscription is already in an `closed` state, the passed
- * tear down logic will be executed immediately.
- *
- * @param {TeardownLogic} teardown The additional logic to execute on
- * teardown.
- * @return {Subscription} Returns the Subscription used or created to be
- * added to the inner subscriptions list. This Subscription can be used with
- * `remove()` to remove the passed teardown logic from the inner subscriptions
- * list.
- */
- Subscription.prototype.add = function (teardown) {
- if (!teardown || (teardown === Subscription.EMPTY)) {
- return Subscription.EMPTY;
- }
- if (teardown === this) {
- return this;
- }
- var subscription = teardown;
- switch (typeof teardown) {
- case 'function':
- subscription = new Subscription(teardown);
- case 'object':
- if (subscription.closed || typeof subscription.unsubscribe !== 'function') {
- return subscription;
- }
- else if (this.closed) {
- subscription.unsubscribe();
- return subscription;
- }
- else if (typeof subscription._addParent !== 'function' /* quack quack */) {
- var tmp = subscription;
- subscription = new Subscription();
- subscription._subscriptions = [tmp];
- }
- break;
- default:
- throw new Error('unrecognized teardown ' + teardown + ' added to Subscription.');
- }
- var subscriptions = this._subscriptions || (this._subscriptions = []);
- subscriptions.push(subscription);
- subscription._addParent(this);
- return subscription;
- };
- /**
- * Removes a Subscription from the internal list of subscriptions that will
- * unsubscribe during the unsubscribe process of this Subscription.
- * @param {Subscription} subscription The subscription to remove.
- * @return {void}
- */
- Subscription.prototype.remove = function (subscription) {
- var subscriptions = this._subscriptions;
- if (subscriptions) {
- var subscriptionIndex = subscriptions.indexOf(subscription);
- if (subscriptionIndex !== -1) {
- subscriptions.splice(subscriptionIndex, 1);
- }
- }
- };
- Subscription.prototype._addParent = function (parent) {
- var _a = this, _parent = _a._parent, _parents = _a._parents;
- if (!_parent || _parent === parent) {
- // If we don't have a parent, or the new parent is the same as the
- // current parent, then set this._parent to the new parent.
- this._parent = parent;
- }
- else if (!_parents) {
- // If there's already one parent, but not multiple, allocate an Array to
- // store the rest of the parent Subscriptions.
- this._parents = [parent];
- }
- else if (_parents.indexOf(parent) === -1) {
- // Only add the new parent to the _parents list if it's not already there.
- _parents.push(parent);
- }
- };
- Subscription.EMPTY = (function (empty) {
- empty.closed = true;
- return empty;
- }(new Subscription()));
- return Subscription;
- }());
- var Subscription_2 = Subscription;
- function flattenUnsubscriptionErrors(errors) {
- return errors.reduce(function (errs, err) { return errs.concat((err instanceof UnsubscriptionError_1.UnsubscriptionError) ? err.errors : err); }, []);
- }
-
- var Subscription_1 = {
- Subscription: Subscription_2
- };
-
- var empty = {
- closed: true,
- next: function (value) { },
- error: function (err) { throw err; },
- complete: function () { }
- };
-
- var Observer = {
- empty: empty
- };
-
- var rxSubscriber = createCommonjsModule(function (module, exports) {
- "use strict";
-
- var Symbol = root.root.Symbol;
- exports.rxSubscriber = (typeof Symbol === 'function' && typeof Symbol.for === 'function') ?
- Symbol.for('rxSubscriber') : '@@rxSubscriber';
- /**
- * @deprecated use rxSubscriber instead
- */
- exports.$$rxSubscriber = exports.rxSubscriber;
- });
-
- var __extends$2 = (commonjsGlobal && commonjsGlobal.__extends) || function (d, b) {
- for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
-
-
-
-
- /**
- * Implements the {@link Observer} interface and extends the
- * {@link Subscription} class. While the {@link Observer} is the public API for
- * consuming the values of an {@link Observable}, all Observers get converted to
- * a Subscriber, in order to provide Subscription-like capabilities such as
- * `unsubscribe`. Subscriber is a common type in RxJS, and crucial for
- * implementing operators, but it is rarely used as a public API.
- *
- * @class Subscriber<T>
- */
- var Subscriber = (function (_super) {
- __extends$2(Subscriber, _super);
- /**
- * @param {Observer|function(value: T): void} [destinationOrNext] A partially
- * defined Observer or a `next` callback function.
- * @param {function(e: ?any): void} [error] The `error` callback of an
- * Observer.
- * @param {function(): void} [complete] The `complete` callback of an
- * Observer.
- */
- function Subscriber(destinationOrNext, error, complete) {
- _super.call(this);
- this.syncErrorValue = null;
- this.syncErrorThrown = false;
- this.syncErrorThrowable = false;
- this.isStopped = false;
- switch (arguments.length) {
- case 0:
- this.destination = Observer.empty;
- break;
- case 1:
- if (!destinationOrNext) {
- this.destination = Observer.empty;
- break;
- }
- if (typeof destinationOrNext === 'object') {
- if (destinationOrNext instanceof Subscriber) {
- this.destination = destinationOrNext;
- this.destination.add(this);
- }
- else {
- this.syncErrorThrowable = true;
- this.destination = new SafeSubscriber(this, destinationOrNext);
- }
- break;
- }
- default:
- this.syncErrorThrowable = true;
- this.destination = new SafeSubscriber(this, destinationOrNext, error, complete);
- break;
- }
- }
- Subscriber.prototype[rxSubscriber.rxSubscriber] = function () { return this; };
- /**
- * A static factory for a Subscriber, given a (potentially partial) definition
- * of an Observer.
- * @param {function(x: ?T): void} [next] The `next` callback of an Observer.
- * @param {function(e: ?any): void} [error] The `error` callback of an
- * Observer.
- * @param {function(): void} [complete] The `complete` callback of an
- * Observer.
- * @return {Subscriber<T>} A Subscriber wrapping the (partially defined)
- * Observer represented by the given arguments.
- */
- Subscriber.create = function (next, error, complete) {
- var subscriber = new Subscriber(next, error, complete);
- subscriber.syncErrorThrowable = false;
- return subscriber;
- };
- /**
- * The {@link Observer} callback to receive notifications of type `next` from
- * the Observable, with a value. The Observable may call this method 0 or more
- * times.
- * @param {T} [value] The `next` value.
- * @return {void}
- */
- Subscriber.prototype.next = function (value) {
- if (!this.isStopped) {
- this._next(value);
- }
- };
- /**
- * The {@link Observer} callback to receive notifications of type `error` from
- * the Observable, with an attached {@link Error}. Notifies the Observer that
- * the Observable has experienced an error condition.
- * @param {any} [err] The `error` exception.
- * @return {void}
- */
- Subscriber.prototype.error = function (err) {
- if (!this.isStopped) {
- this.isStopped = true;
- this._error(err);
- }
- };
- /**
- * The {@link Observer} callback to receive a valueless notification of type
- * `complete` from the Observable. Notifies the Observer that the Observable
- * has finished sending push-based notifications.
- * @return {void}
- */
- Subscriber.prototype.complete = function () {
- if (!this.isStopped) {
- this.isStopped = true;
- this._complete();
- }
- };
- Subscriber.prototype.unsubscribe = function () {
- if (this.closed) {
- return;
- }
- this.isStopped = true;
- _super.prototype.unsubscribe.call(this);
- };
- Subscriber.prototype._next = function (value) {
- this.destination.next(value);
- };
- Subscriber.prototype._error = function (err) {
- this.destination.error(err);
- this.unsubscribe();
- };
- Subscriber.prototype._complete = function () {
- this.destination.complete();
- this.unsubscribe();
- };
- Subscriber.prototype._unsubscribeAndRecycle = function () {
- var _a = this, _parent = _a._parent, _parents = _a._parents;
- this._parent = null;
- this._parents = null;
- this.unsubscribe();
- this.closed = false;
- this.isStopped = false;
- this._parent = _parent;
- this._parents = _parents;
- return this;
- };
- return Subscriber;
- }(Subscription_1.Subscription));
- var Subscriber_2 = Subscriber;
- /**
- * We need this JSDoc comment for affecting ESDoc.
- * @ignore
- * @extends {Ignored}
- */
- var SafeSubscriber = (function (_super) {
- __extends$2(SafeSubscriber, _super);
- function SafeSubscriber(_parentSubscriber, observerOrNext, error, complete) {
- _super.call(this);
- this._parentSubscriber = _parentSubscriber;
- var next;
- var context = this;
- if (isFunction_1.isFunction(observerOrNext)) {
- next = observerOrNext;
- }
- else if (observerOrNext) {
- next = observerOrNext.next;
- error = observerOrNext.error;
- complete = observerOrNext.complete;
- if (observerOrNext !== Observer.empty) {
- context = Object.create(observerOrNext);
- if (isFunction_1.isFunction(context.unsubscribe)) {
- this.add(context.unsubscribe.bind(context));
- }
- context.unsubscribe = this.unsubscribe.bind(this);
- }
- }
- this._context = context;
- this._next = next;
- this._error = error;
- this._complete = complete;
- }
- SafeSubscriber.prototype.next = function (value) {
- if (!this.isStopped && this._next) {
- var _parentSubscriber = this._parentSubscriber;
- if (!_parentSubscriber.syncErrorThrowable) {
- this.__tryOrUnsub(this._next, value);
- }
- else if (this.__tryOrSetError(_parentSubscriber, this._next, value)) {
- this.unsubscribe();
- }
- }
- };
- SafeSubscriber.prototype.error = function (err) {
- if (!this.isStopped) {
- var _parentSubscriber = this._parentSubscriber;
- if (this._error) {
- if (!_parentSubscriber.syncErrorThrowable) {
- this.__tryOrUnsub(this._error, err);
- this.unsubscribe();
- }
- else {
- this.__tryOrSetError(_parentSubscriber, this._error, err);
- this.unsubscribe();
- }
- }
- else if (!_parentSubscriber.syncErrorThrowable) {
- this.unsubscribe();
- throw err;
- }
- else {
- _parentSubscriber.syncErrorValue = err;
- _parentSubscriber.syncErrorThrown = true;
- this.unsubscribe();
- }
- }
- };
- SafeSubscriber.prototype.complete = function () {
- var _this = this;
- if (!this.isStopped) {
- var _parentSubscriber = this._parentSubscriber;
- if (this._complete) {
- var wrappedComplete = function () { return _this._complete.call(_this._context); };
- if (!_parentSubscriber.syncErrorThrowable) {
- this.__tryOrUnsub(wrappedComplete);
- this.unsubscribe();
- }
- else {
- this.__tryOrSetError(_parentSubscriber, wrappedComplete);
- this.unsubscribe();
- }
- }
- else {
- this.unsubscribe();
- }
- }
- };
- SafeSubscriber.prototype.__tryOrUnsub = function (fn, value) {
- try {
- fn.call(this._context, value);
- }
- catch (err) {
- this.unsubscribe();
- throw err;
- }
- };
- SafeSubscriber.prototype.__tryOrSetError = function (parent, fn, value) {
- try {
- fn.call(this._context, value);
- }
- catch (err) {
- parent.syncErrorValue = err;
- parent.syncErrorThrown = true;
- return true;
- }
- return false;
- };
- SafeSubscriber.prototype._unsubscribe = function () {
- var _parentSubscriber = this._parentSubscriber;
- this._context = null;
- this._parentSubscriber = null;
- _parentSubscriber.unsubscribe();
- };
- return SafeSubscriber;
- }(Subscriber));
-
- var Subscriber_1 = {
- Subscriber: Subscriber_2
- };
-
- function toSubscriber(nextOrObserver, error, complete) {
- if (nextOrObserver) {
- if (nextOrObserver instanceof Subscriber_1.Subscriber) {
- return nextOrObserver;
- }
- if (nextOrObserver[rxSubscriber.rxSubscriber]) {
- return nextOrObserver[rxSubscriber.rxSubscriber]();
- }
- }
- if (!nextOrObserver && !error && !complete) {
- return new Subscriber_1.Subscriber(Observer.empty);
- }
- return new Subscriber_1.Subscriber(nextOrObserver, error, complete);
- }
- var toSubscriber_2 = toSubscriber;
-
- var toSubscriber_1 = {
- toSubscriber: toSubscriber_2
- };
-
- var observable = createCommonjsModule(function (module, exports) {
- "use strict";
-
- function getSymbolObservable(context) {
- var $$observable;
- var Symbol = context.Symbol;
- if (typeof Symbol === 'function') {
- if (Symbol.observable) {
- $$observable = Symbol.observable;
- }
- else {
- $$observable = Symbol('observable');
- Symbol.observable = $$observable;
- }
- }
- else {
- $$observable = '@@observable';
- }
- return $$observable;
- }
- exports.getSymbolObservable = getSymbolObservable;
- exports.observable = getSymbolObservable(root.root);
- /**
- * @deprecated use observable instead
- */
- exports.$$observable = exports.observable;
- });
-
- /**
- * A representation of any set of values over any amount of time. This is the most basic building block
- * of RxJS.
- *
- * @class Observable<T>
- */
- var Observable = (function () {
- /**
- * @constructor
- * @param {Function} subscribe the function that is called when the Observable is
- * initially subscribed to. This function is given a Subscriber, to which new values
- * can be `next`ed, or an `error` method can be called to raise an error, or
- * `complete` can be called to notify of a successful completion.
- */
- function Observable(subscribe) {
- this._isScalar = false;
- if (subscribe) {
- this._subscribe = subscribe;
- }
- }
- /**
- * Creates a new Observable, with this Observable as the source, and the passed
- * operator defined as the new observable's operator.
- * @method lift
- * @param {Operator} operator the operator defining the operation to take on the observable
- * @return {Observable} a new observable with the Operator applied
- */
- Observable.prototype.lift = function (operator) {
- var observable$$1 = new Observable();
- observable$$1.source = this;
- observable$$1.operator = operator;
- return observable$$1;
- };
- /**
- * Invokes an execution of an Observable and registers Observer handlers for notifications it will emit.
- *
- * <span class="informal">Use it when you have all these Observables, but still nothing is happening.</span>
- *
- * `subscribe` is not a regular operator, but a method that calls Observable's internal `subscribe` function. It
- * might be for example a function that you passed to a {@link create} static factory, but most of the time it is
- * a library implementation, which defines what and when will be emitted by an Observable. This means that calling
- * `subscribe` is actually the moment when Observable starts its work, not when it is created, as it is often
- * thought.
- *
- * Apart from starting the execution of an Observable, this method allows you to listen for values
- * that an Observable emits, as well as for when it completes or errors. You can achieve this in two
- * following ways.
- *
- * The first way is creating an object that implements {@link Observer} interface. It should have methods
- * defined by that interface, but note that it should be just a regular JavaScript object, which you can create
- * yourself in any way you want (ES6 class, classic function constructor, object literal etc.). In particular do
- * not attempt to use any RxJS implementation details to create Observers - you don't need them. Remember also
- * that your object does not have to implement all methods. If you find yourself creating a method that doesn't
- * do anything, you can simply omit it. Note however, that if `error` method is not provided, all errors will
- * be left uncaught.
- *
- * The second way is to give up on Observer object altogether and simply provide callback functions in place of its methods.
- * This means you can provide three functions as arguments to `subscribe`, where first function is equivalent
- * of a `next` method, second of an `error` method and third of a `complete` method. Just as in case of Observer,
- * if you do not need to listen for something, you can omit a function, preferably by passing `undefined` or `null`,
- * since `subscribe` recognizes these functions by where they were placed in function call. When it comes
- * to `error` function, just as before, if not provided, errors emitted by an Observable will be thrown.
- *
- * Whatever style of calling `subscribe` you use, in both cases it returns a Subscription object.
- * This object allows you to call `unsubscribe` on it, which in turn will stop work that an Observable does and will clean
- * up all resources that an Observable used. Note that cancelling a subscription will not call `complete` callback
- * provided to `subscribe` function, which is reserved for a regular completion signal that comes from an Observable.
- *
- * Remember that callbacks provided to `subscribe` are not guaranteed to be called asynchronously.
- * It is an Observable itself that decides when these functions will be called. For example {@link of}
- * by default emits all its values synchronously. Always check documentation for how given Observable
- * will behave when subscribed and if its default behavior can be modified with a {@link Scheduler}.
- *
- * @example <caption>Subscribe with an Observer</caption>
- * const sumObserver = {
- * sum: 0,
- * next(value) {
- * console.log('Adding: ' + value);
- * this.sum = this.sum + value;
- * },
- * error() { // We actually could just remove this method,
- * }, // since we do not really care about errors right now.
- * complete() {
- * console.log('Sum equals: ' + this.sum);
- * }
- * };
- *
- * Rx.Observable.of(1, 2, 3) // Synchronously emits 1, 2, 3 and then completes.
- * .subscribe(sumObserver);
- *
- * // Logs:
- * // "Adding: 1"
- * // "Adding: 2"
- * // "Adding: 3"
- * // "Sum equals: 6"
- *
- *
- * @example <caption>Subscribe with functions</caption>
- * let sum = 0;
- *
- * Rx.Observable.of(1, 2, 3)
- * .subscribe(
- * function(value) {
- * console.log('Adding: ' + value);
- * sum = sum + value;
- * },
- * undefined,
- * function() {
- * console.log('Sum equals: ' + sum);
- * }
- * );
- *
- * // Logs:
- * // "Adding: 1"
- * // "Adding: 2"
- * // "Adding: 3"
- * // "Sum equals: 6"
- *
- *
- * @example <caption>Cancel a subscription</caption>
- * const subscription = Rx.Observable.interval(1000).subscribe(
- * num => console.log(num),
- * undefined,
- * () => console.log('completed!') // Will not be called, even
- * ); // when cancelling subscription
- *
- *
- * setTimeout(() => {
- * subscription.unsubscribe();
- * console.log('unsubscribed!');
- * }, 2500);
- *
- * // Logs:
- * // 0 after 1s
- * // 1 after 2s
- * // "unsubscribed!" after 2.5s
- *
- *
- * @param {Observer|Function} observerOrNext (optional) Either an observer with methods to be called,
- * or the first of three possible handlers, which is the handler for each value emitted from the subscribed
- * Observable.
- * @param {Function} error (optional) A handler for a terminal event resulting from an error. If no error handler is provided,
- * the error will be thrown as unhandled.
- * @param {Function} complete (optional) A handler for a terminal event resulting from successful completion.
- * @return {ISubscription} a subscription reference to the registered handlers
- * @method subscribe
- */
- Observable.prototype.subscribe = function (observerOrNext, error, complete) {
- var operator = this.operator;
- var sink = toSubscriber_1.toSubscriber(observerOrNext, error, complete);
- if (operator) {
- operator.call(sink, this.source);
- }
- else {
- sink.add(this.source ? this._subscribe(sink) : this._trySubscribe(sink));
- }
- if (sink.syncErrorThrowable) {
- sink.syncErrorThrowable = false;
- if (sink.syncErrorThrown) {
- throw sink.syncErrorValue;
- }
- }
- return sink;
- };
- Observable.prototype._trySubscribe = function (sink) {
- try {
- return this._subscribe(sink);
- }
- catch (err) {
- sink.syncErrorThrown = true;
- sink.syncErrorValue = err;
- sink.error(err);
- }
- };
- /**
- * @method forEach
- * @param {Function} next a handler for each value emitted by the observable
- * @param {PromiseConstructor} [PromiseCtor] a constructor function used to instantiate the Promise
- * @return {Promise} a promise that either resolves on observable completion or
- * rejects with the handled error
- */
- Observable.prototype.forEach = function (next, PromiseCtor) {
- var _this = this;
- if (!PromiseCtor) {
- if (root.root.Rx && root.root.Rx.config && root.root.Rx.config.Promise) {
- PromiseCtor = root.root.Rx.config.Promise;
- }
- else if (root.root.Promise) {
- PromiseCtor = root.root.Promise;
- }
- }
- if (!PromiseCtor) {
- throw new Error('no Promise impl found');
- }
- return new PromiseCtor(function (resolve, reject) {
- // Must be declared in a separate statement to avoid a RefernceError when
- // accessing subscription below in the closure due to Temporal Dead Zone.
- var subscription;
- subscription = _this.subscribe(function (value) {
- if (subscription) {
- // if there is a subscription, then we can surmise
- // the next handling is asynchronous. Any errors thrown
- // need to be rejected explicitly and unsubscribe must be
- // called manually
- try {
- next(value);
- }
- catch (err) {
- reject(err);
- subscription.unsubscribe();
- }
- }
- else {
- // if there is NO subscription, then we're getting a nexted
- // value synchronously during subscription. We can just call it.
- // If it errors, Observable's `subscribe` will ensure the
- // unsubscription logic is called, then synchronously rethrow the error.
- // After that, Promise will trap the error and send it
- // down the rejection path.
- next(value);
- }
- }, reject, resolve);
- });
- };
- Observable.prototype._subscribe = function (subscriber) {
- return this.source.subscribe(subscriber);
- };
- /**
- * An interop point defined by the es7-observable spec https://github.com/zenparsing/es-observable
- * @method Symbol.observable
- * @return {Observable} this instance of the observable
- */
- Observable.prototype[observable.observable] = function () {
- return this;
- };
- // HACK: Since TypeScript inherits static properties too, we have to
- // fight against TypeScript here so Subject can have a different static create signature
- /**
- * Creates a new cold Observable by calling the Observable constructor
- * @static true
- * @owner Observable
- * @method create
- * @param {Function} subscribe? the subscriber function to be passed to the Observable constructor
- * @return {Observable} a new cold observable
- */
- Observable.create = function (subscribe) {
- return new Observable(subscribe);
- };
- return Observable;
- }());
- var Observable_2 = Observable;
-
- var Observable_1 = {
- Observable: Observable_2
- };
-
- var __extends$5 = (commonjsGlobal && commonjsGlobal.__extends) || function (d, b) {
- for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
-
- /**
- * We need this JSDoc comment for affecting ESDoc.
- * @extends {Ignored}
- * @hide true
- */
- var ScalarObservable = (function (_super) {
- __extends$5(ScalarObservable, _super);
- function ScalarObservable(value, scheduler) {
- _super.call(this);
- this.value = value;
- this.scheduler = scheduler;
- this._isScalar = true;
- if (scheduler) {
- this._isScalar = false;
- }
- }
- ScalarObservable.create = function (value, scheduler) {
- return new ScalarObservable(value, scheduler);
- };
- ScalarObservable.dispatch = function (state) {
- var done = state.done, value = state.value, subscriber = state.subscriber;
- if (done) {
- subscriber.complete();
- return;
- }
- subscriber.next(value);
- if (subscriber.closed) {
- return;
- }
- state.done = true;
- this.schedule(state);
- };
- ScalarObservable.prototype._subscribe = function (subscriber) {
- var value = this.value;
- var scheduler = this.scheduler;
- if (scheduler) {
- return scheduler.schedule(ScalarObservable.dispatch, 0, {
- done: false, value: value, subscriber: subscriber
- });
- }
- else {
- subscriber.next(value);
- if (!subscriber.closed) {
- subscriber.complete();
- }
- }
- };
- return ScalarObservable;
- }(Observable_1.Observable));
- var ScalarObservable_2 = ScalarObservable;
-
- var ScalarObservable_1 = {
- ScalarObservable: ScalarObservable_2
- };
-
- var __extends$6 = (commonjsGlobal && commonjsGlobal.__extends) || function (d, b) {
- for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
-
- /**
- * We need this JSDoc comment for affecting ESDoc.
- * @extends {Ignored}
- * @hide true
- */
- var EmptyObservable = (function (_super) {
- __extends$6(EmptyObservable, _super);
- function EmptyObservable(scheduler) {
- _super.call(this);
- this.scheduler = scheduler;
- }
- /**
- * Creates an Observable that emits no items to the Observer and immediately
- * emits a complete notification.
- *
- * <span class="informal">Just emits 'complete', and nothing else.
- * </span>
- *
- * <img src="./img/empty.png" width="100%">
- *
- * This static operator is useful for creating a simple Observable that only
- * emits the complete notification. It can be used for composing with other
- * Observables, such as in a {@link mergeMap}.
- *
- * @example <caption>Emit the number 7, then complete.</caption>
- * var result = Rx.Observable.empty().startWith(7);
- * result.subscribe(x => console.log(x));
- *
- * @example <caption>Map and flatten only odd numbers to the sequence 'a', 'b', 'c'</caption>
- * var interval = Rx.Observable.interval(1000);
- * var result = interval.mergeMap(x =>
- * x % 2 === 1 ? Rx.Observable.of('a', 'b', 'c') : Rx.Observable.empty()
- * );
- * result.subscribe(x => console.log(x));
- *
- * // Results in the following to the console:
- * // x is equal to the count on the interval eg(0,1,2,3,...)
- * // x will occur every 1000ms
- * // if x % 2 is equal to 1 print abc
- * // if x % 2 is not equal to 1 nothing will be output
- *
- * @see {@link create}
- * @see {@link never}
- * @see {@link of}
- * @see {@link throw}
- *
- * @param {Scheduler} [scheduler] A {@link IScheduler} to use for scheduling
- * the emission of the complete notification.
- * @return {Observable} An "empty" Observable: emits only the complete
- * notification.
- * @static true
- * @name empty
- * @owner Observable
- */
- EmptyObservable.create = function (scheduler) {
- return new EmptyObservable(scheduler);
- };
- EmptyObservable.dispatch = function (arg) {
- var subscriber = arg.subscriber;
- subscriber.complete();
- };
- EmptyObservable.prototype._subscribe = function (subscriber) {
- var scheduler = this.scheduler;
- if (scheduler) {
- return scheduler.schedule(EmptyObservable.dispatch, 0, { subscriber: subscriber });
- }
- else {
- subscriber.complete();
- }
- };
- return EmptyObservable;
- }(Observable_1.Observable));
- var EmptyObservable_2 = EmptyObservable;
-
- var EmptyObservable_1 = {
- EmptyObservable: EmptyObservable_2
- };
-
- function isScheduler(value) {
- return value && typeof value.schedule === 'function';
- }
- var isScheduler_2 = isScheduler;
-
- var isScheduler_1 = {
- isScheduler: isScheduler_2
- };
-
- var __extends$4 = (commonjsGlobal && commonjsGlobal.__extends) || function (d, b) {
- for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
-
-
-
-
- /**
- * We need this JSDoc comment for affecting ESDoc.
- * @extends {Ignored}
- * @hide true
- */
- var ArrayObservable = (function (_super) {
- __extends$4(ArrayObservable, _super);
- function ArrayObservable(array, scheduler) {
- _super.call(this);
- this.array = array;
- this.scheduler = scheduler;
- if (!scheduler && array.length === 1) {
- this._isScalar = true;
- this.value = array[0];
- }
- }
- ArrayObservable.create = function (array, scheduler) {
- return new ArrayObservable(array, scheduler);
- };
- /**
- * Creates an Observable that emits some values you specify as arguments,
- * immediately one after the other, and then emits a complete notification.
- *
- * <span class="informal">Emits the arguments you provide, then completes.
- * </span>
- *
- * <img src="./img/of.png" width="100%">
- *
- * This static operator is useful for creating a simple Observable that only
- * emits the arguments given, and the complete notification thereafter. It can
- * be used for composing with other Observables, such as with {@link concat}.
- * By default, it uses a `null` IScheduler, which means the `next`
- * notifications are sent synchronously, although with a different IScheduler
- * it is possible to determine when those notifications will be delivered.
- *
- * @example <caption>Emit 10, 20, 30, then 'a', 'b', 'c', then start ticking every second.</caption>
- * var numbers = Rx.Observable.of(10, 20, 30);
- * var letters = Rx.Observable.of('a', 'b', 'c');
- * var interval = Rx.Observable.interval(1000);
- * var result = numbers.concat(letters).concat(interval);
- * result.subscribe(x => console.log(x));
- *
- * @see {@link create}
- * @see {@link empty}
- * @see {@link never}
- * @see {@link throw}
- *
- * @param {...T} values Arguments that represent `next` values to be emitted.
- * @param {Scheduler} [scheduler] A {@link IScheduler} to use for scheduling
- * the emissions of the `next` notifications.
- * @return {Observable<T>} An Observable that emits each given input value.
- * @static true
- * @name of
- * @owner Observable
- */
- ArrayObservable.of = function () {
- var array = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- array[_i - 0] = arguments[_i];
- }
- var scheduler = array[array.length - 1];
- if (isScheduler_1.isScheduler(scheduler)) {
- array.pop();
- }
- else {
- scheduler = null;
- }
- var len = array.length;
- if (len > 1) {
- return new ArrayObservable(array, scheduler);
- }
- else if (len === 1) {
- return new ScalarObservable_1.ScalarObservable(array[0], scheduler);
- }
- else {
- return new EmptyObservable_1.EmptyObservable(scheduler);
- }
- };
- ArrayObservable.dispatch = function (state) {
- var array = state.array, index = state.index, count = state.count, subscriber = state.subscriber;
- if (index >= count) {
- subscriber.complete();
- return;
- }
- subscriber.next(array[index]);
- if (subscriber.closed) {
- return;
- }
- state.index = index + 1;
- this.schedule(state);
- };
- ArrayObservable.prototype._subscribe = function (subscriber) {
- var index = 0;
- var array = this.array;
- var count = array.length;
- var scheduler = this.scheduler;
- if (scheduler) {
- return scheduler.schedule(ArrayObservable.dispatch, 0, {
- array: array, index: index, count: count, subscriber: subscriber
- });
- }
- else {
- for (var i = 0; i < count && !subscriber.closed; i++) {
- subscriber.next(array[i]);
- }
- subscriber.complete();
- }
- };
- return ArrayObservable;
- }(Observable_1.Observable));
- var ArrayObservable_2 = ArrayObservable;
-
- var ArrayObservable_1 = {
- ArrayObservable: ArrayObservable_2
- };
-
- var __extends$8 = (commonjsGlobal && commonjsGlobal.__extends) || function (d, b) {
- for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
-
- /**
- * We need this JSDoc comment for affecting ESDoc.
- * @ignore
- * @extends {Ignored}
- */
- var OuterSubscriber = (function (_super) {
- __extends$8(OuterSubscriber, _super);
- function OuterSubscriber() {
- _super.apply(this, arguments);
- }
- OuterSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
- this.destination.next(innerValue);
- };
- OuterSubscriber.prototype.notifyError = function (error, innerSub) {
- this.destination.error(error);
- };
- OuterSubscriber.prototype.notifyComplete = function (innerSub) {
- this.destination.complete();
- };
- return OuterSubscriber;
- }(Subscriber_1.Subscriber));
- var OuterSubscriber_2 = OuterSubscriber;
-
- var OuterSubscriber_1 = {
- OuterSubscriber: OuterSubscriber_2
- };
-
- var isArrayLike_1 = (function (x) { return x && typeof x.length === 'number'; });
-
- var isArrayLike = {
- isArrayLike: isArrayLike_1
- };
-
- function isPromise$1(value) {
- return value && typeof value.subscribe !== 'function' && typeof value.then === 'function';
- }
- var isPromise_2 = isPromise$1;
-
- var isPromise_1 = {
- isPromise: isPromise_2
- };
-
- var iterator = createCommonjsModule(function (module, exports) {
- "use strict";
-
- function symbolIteratorPonyfill(root$$1) {
- var Symbol = root$$1.Symbol;
- if (typeof Symbol === 'function') {
- if (!Symbol.iterator) {
- Symbol.iterator = Symbol('iterator polyfill');
- }
- return Symbol.iterator;
- }
- else {
- // [for Mozilla Gecko 27-35:](https://mzl.la/2ewE1zC)
- var Set_1 = root$$1.Set;
- if (Set_1 && typeof new Set_1()['@@iterator'] === 'function') {
- return '@@iterator';
- }
- var Map_1 = root$$1.Map;
- // required for compatability with es6-shim
- if (Map_1) {
- var keys = Object.getOwnPropertyNames(Map_1.prototype);
- for (var i = 0; i < keys.length; ++i) {
- var key = keys[i];
- // according to spec, Map.prototype[@@iterator] and Map.orototype.entries must be equal.
- if (key !== 'entries' && key !== 'size' && Map_1.prototype[key] === Map_1.prototype['entries']) {
- return key;
- }
- }
- }
- return '@@iterator';
- }
- }
- exports.symbolIteratorPonyfill = symbolIteratorPonyfill;
- exports.iterator = symbolIteratorPonyfill(root.root);
- /**
- * @deprecated use iterator instead
- */
- exports.$$iterator = exports.iterator;
- });
-
- var __extends$9 = (commonjsGlobal && commonjsGlobal.__extends) || function (d, b) {
- for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
-
- /**
- * We need this JSDoc comment for affecting ESDoc.
- * @ignore
- * @extends {Ignored}
- */
- var InnerSubscriber = (function (_super) {
- __extends$9(InnerSubscriber, _super);
- function InnerSubscriber(parent, outerValue, outerIndex) {
- _super.call(this);
- this.parent = parent;
- this.outerValue = outerValue;
- this.outerIndex = outerIndex;
- this.index = 0;
- }
- InnerSubscriber.prototype._next = function (value) {
- this.parent.notifyNext(this.outerValue, value, this.outerIndex, this.index++, this);
- };
- InnerSubscriber.prototype._error = function (error) {
- this.parent.notifyError(error, this);
- this.unsubscribe();
- };
- InnerSubscriber.prototype._complete = function () {
- this.parent.notifyComplete(this);
- this.unsubscribe();
- };
- return InnerSubscriber;
- }(Subscriber_1.Subscriber));
- var InnerSubscriber_2 = InnerSubscriber;
-
- var InnerSubscriber_1 = {
- InnerSubscriber: InnerSubscriber_2
- };
-
- function subscribeToResult(outerSubscriber, result, outerValue, outerIndex) {
- var destination = new InnerSubscriber_1.InnerSubscriber(outerSubscriber, outerValue, outerIndex);
- if (destination.closed) {
- return null;
- }
- if (result instanceof Observable_1.Observable) {
- if (result._isScalar) {
- destination.next(result.value);
- destination.complete();
- return null;
- }
- else {
- return result.subscribe(destination);
- }
- }
- else if (isArrayLike.isArrayLike(result)) {
- for (var i = 0, len = result.length; i < len && !destination.closed; i++) {
- destination.next(result[i]);
- }
- if (!destination.closed) {
- destination.complete();
- }
- }
- else if (isPromise_1.isPromise(result)) {
- result.then(function (value) {
- if (!destination.closed) {
- destination.next(value);
- destination.complete();
- }
- }, function (err) { return destination.error(err); })
- .then(null, function (err) {
- // Escaping the Promise trap: globally throw unhandled errors
- root.root.setTimeout(function () { throw err; });
- });
- return destination;
- }
- else if (result && typeof result[iterator.iterator] === 'function') {
- var iterator$$1 = result[iterator.iterator]();
- do {
- var item = iterator$$1.next();
- if (item.done) {
- destination.complete();
- break;
- }
- destination.next(item.value);
- if (destination.closed) {
- break;
- }
- } while (true);
- }
- else if (result && typeof result[observable.observable] === 'function') {
- var obs = result[observable.observable]();
- if (typeof obs.subscribe !== 'function') {
- destination.error(new TypeError('Provided object does not correctly implement Symbol.observable'));
- }
- else {
- return obs.subscribe(new InnerSubscriber_1.InnerSubscriber(outerSubscriber, outerValue, outerIndex));
- }
- }
- else {
- var value = isObject_1.isObject(result) ? 'an invalid object' : "'" + result + "'";
- var msg = ("You provided " + value + " where a stream was expected.")
- + ' You can provide an Observable, Promise, Array, or Iterable.';
- destination.error(new TypeError(msg));
- }
- return null;
- }
- var subscribeToResult_2 = subscribeToResult;
-
- var subscribeToResult_1 = {
- subscribeToResult: subscribeToResult_2
- };
-
- var __extends$7 = (commonjsGlobal && commonjsGlobal.__extends) || function (d, b) {
- for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
-
-
- /**
- * Converts a higher-order Observable into a first-order Observable which
- * concurrently delivers all values that are emitted on the inner Observables.
- *
- * <span class="informal">Flattens an Observable-of-Observables.</span>
- *
- * <img src="./img/mergeAll.png" width="100%">
- *
- * `mergeAll` subscribes to an Observable that emits Observables, also known as
- * a higher-order Observable. Each time it observes one of these emitted inner
- * Observables, it subscribes to that and delivers all the values from the
- * inner Observable on the output Observable. The output Observable only
- * completes once all inner Observables have completed. Any error delivered by
- * a inner Observable will be immediately emitted on the output Observable.
- *
- * @example <caption>Spawn a new interval Observable for each click event, and blend their outputs as one Observable</caption>
- * var clicks = Rx.Observable.fromEvent(document, 'click');
- * var higherOrder = clicks.map((ev) => Rx.Observable.interval(1000));
- * var firstOrder = higherOrder.mergeAll();
- * firstOrder.subscribe(x => console.log(x));
- *
- * @example <caption>Count from 0 to 9 every second for each click, but only allow 2 concurrent timers</caption>
- * var clicks = Rx.Observable.fromEvent(document, 'click');
- * var higherOrder = clicks.map((ev) => Rx.Observable.interval(1000).take(10));
- * var firstOrder = higherOrder.mergeAll(2);
- * firstOrder.subscribe(x => console.log(x));
- *
- * @see {@link combineAll}
- * @see {@link concatAll}
- * @see {@link exhaust}
- * @see {@link merge}
- * @see {@link mergeMap}
- * @see {@link mergeMapTo}
- * @see {@link mergeScan}
- * @see {@link switch}
- * @see {@link zipAll}
- *
- * @param {number} [concurrent=Number.POSITIVE_INFINITY] Maximum number of inner
- * Observables being subscribed to concurrently.
- * @return {Observable} An Observable that emits values coming from all the
- * inner Observables emitted by the source Observable.
- * @method mergeAll
- * @owner Observable
- */
- function mergeAll(concurrent) {
- if (concurrent === void 0) { concurrent = Number.POSITIVE_INFINITY; }
- return this.lift(new MergeAllOperator(concurrent));
- }
- var mergeAll_2 = mergeAll;
- var MergeAllOperator = (function () {
- function MergeAllOperator(concurrent) {
- this.concurrent = concurrent;
- }
- MergeAllOperator.prototype.call = function (observer, source) {
- return source.subscribe(new MergeAllSubscriber(observer, this.concurrent));
- };
- return MergeAllOperator;
- }());
- var MergeAllOperator_1 = MergeAllOperator;
- /**
- * We need this JSDoc comment for affecting ESDoc.
- * @ignore
- * @extends {Ignored}
- */
- var MergeAllSubscriber = (function (_super) {
- __extends$7(MergeAllSubscriber, _super);
- function MergeAllSubscriber(destination, concurrent) {
- _super.call(this, destination);
- this.concurrent = concurrent;
- this.hasCompleted = false;
- this.buffer = [];
- this.active = 0;
- }
- MergeAllSubscriber.prototype._next = function (observable) {
- if (this.active < this.concurrent) {
- this.active++;
- this.add(subscribeToResult_1.subscribeToResult(this, observable));
- }
- else {
- this.buffer.push(observable);
- }
- };
- MergeAllSubscriber.prototype._complete = function () {
- this.hasCompleted = true;
- if (this.active === 0 && this.buffer.length === 0) {
- this.destination.complete();
- }
- };
- MergeAllSubscriber.prototype.notifyComplete = function (innerSub) {
- var buffer = this.buffer;
- this.remove(innerSub);
- this.active--;
- if (buffer.length > 0) {
- this._next(buffer.shift());
- }
- else if (this.active === 0 && this.hasCompleted) {
- this.destination.complete();
- }
- };
- return MergeAllSubscriber;
- }(OuterSubscriber_1.OuterSubscriber));
- var MergeAllSubscriber_1 = MergeAllSubscriber;
-
- var mergeAll_1 = {
- mergeAll: mergeAll_2,
- MergeAllOperator: MergeAllOperator_1,
- MergeAllSubscriber: MergeAllSubscriber_1
- };
-
- /* tslint:enable:max-line-length */
- /**
- * Creates an output Observable which concurrently emits all values from every
- * given input Observable.
- *
- * <span class="informal">Flattens multiple Observables together by blending
- * their values into one Observable.</span>
- *
- * <img src="./img/merge.png" width="100%">
- *
- * `merge` subscribes to each given input Observable (either the source or an
- * Observable given as argument), and simply forwards (without doing any
- * transformation) all the values from all the input Observables to the output
- * Observable. The output Observable only completes once all input Observables
- * have completed. Any error delivered by an input Observable will be immediately
- * emitted on the output Observable.
- *
- * @example <caption>Merge together two Observables: 1s interval and clicks</caption>
- * var clicks = Rx.Observable.fromEvent(document, 'click');
- * var timer = Rx.Observable.interval(1000);
- * var clicksOrTimer = clicks.merge(timer);
- * clicksOrTimer.subscribe(x => console.log(x));
- *
- * @example <caption>Merge together 3 Observables, but only 2 run concurrently</caption>
- * var timer1 = Rx.Observable.interval(1000).take(10);
- * var timer2 = Rx.Observable.interval(2000).take(6);
- * var timer3 = Rx.Observable.interval(500).take(10);
- * var concurrent = 2; // the argument
- * var merged = timer1.merge(timer2, timer3, concurrent);
- * merged.subscribe(x => console.log(x));
- *
- * @see {@link mergeAll}
- * @see {@link mergeMap}
- * @see {@link mergeMapTo}
- * @see {@link mergeScan}
- *
- * @param {ObservableInput} other An input Observable to merge with the source
- * Observable. More than one input Observables may be given as argument.
- * @param {number} [concurrent=Number.POSITIVE_INFINITY] Maximum number of input
- * Observables being subscribed to concurrently.
- * @param {Scheduler} [scheduler=null] The IScheduler to use for managing
- * concurrency of input Observables.
- * @return {Observable} An Observable that emits items that are the result of
- * every input Observable.
- * @method merge
- * @owner Observable
- */
- function merge$2() {
- var observables = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- observables[_i - 0] = arguments[_i];
- }
- return this.lift.call(mergeStatic.apply(void 0, [this].concat(observables)));
- }
- var merge_2$1 = merge$2;
- /* tslint:enable:max-line-length */
- /**
- * Creates an output Observable which concurrently emits all values from every
- * given input Observable.
- *
- * <span class="informal">Flattens multiple Observables together by blending
- * their values into one Observable.</span>
- *
- * <img src="./img/merge.png" width="100%">
- *
- * `merge` subscribes to each given input Observable (as arguments), and simply
- * forwards (without doing any transformation) all the values from all the input
- * Observables to the output Observable. The output Observable only completes
- * once all input Observables have completed. Any error delivered by an input
- * Observable will be immediately emitted on the output Observable.
- *
- * @example <caption>Merge together two Observables: 1s interval and clicks</caption>
- * var clicks = Rx.Observable.fromEvent(document, 'click');
- * var timer = Rx.Observable.interval(1000);
- * var clicksOrTimer = Rx.Observable.merge(clicks, timer);
- * clicksOrTimer.subscribe(x => console.log(x));
- *
- * // Results in the following:
- * // timer will emit ascending values, one every second(1000ms) to console
- * // clicks logs MouseEvents to console everytime the "document" is clicked
- * // Since the two streams are merged you see these happening
- * // as they occur.
- *
- * @example <caption>Merge together 3 Observables, but only 2 run concurrently</caption>
- * var timer1 = Rx.Observable.interval(1000).take(10);
- * var timer2 = Rx.Observable.interval(2000).take(6);
- * var timer3 = Rx.Observable.interval(500).take(10);
- * var concurrent = 2; // the argument
- * var merged = Rx.Observable.merge(timer1, timer2, timer3, concurrent);
- * merged.subscribe(x => console.log(x));
- *
- * // Results in the following:
- * // - First timer1 and timer2 will run concurrently
- * // - timer1 will emit a value every 1000ms for 10 iterations
- * // - timer2 will emit a value every 2000ms for 6 iterations
- * // - after timer1 hits it's max iteration, timer2 will
- * // continue, and timer3 will start to run concurrently with timer2
- * // - when timer2 hits it's max iteration it terminates, and
- * // timer3 will continue to emit a value every 500ms until it is complete
- *
- * @see {@link mergeAll}
- * @see {@link mergeMap}
- * @see {@link mergeMapTo}
- * @see {@link mergeScan}
- *
- * @param {...ObservableInput} observables Input Observables to merge together.
- * @param {number} [concurrent=Number.POSITIVE_INFINITY] Maximum number of input
- * Observables being subscribed to concurrently.
- * @param {Scheduler} [scheduler=null] The IScheduler to use for managing
- * concurrency of input Observables.
- * @return {Observable} an Observable that emits items that are the result of
- * every input Observable.
- * @static true
- * @name merge
- * @owner Observable
- */
- function mergeStatic() {
- var observables = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- observables[_i - 0] = arguments[_i];
- }
- var concurrent = Number.POSITIVE_INFINITY;
- var scheduler = null;
- var last = observables[observables.length - 1];
- if (isScheduler_1.isScheduler(last)) {
- scheduler = observables.pop();
- if (observables.length > 1 && typeof observables[observables.length - 1] === 'number') {
- concurrent = observables.pop();
- }
- }
- else if (typeof last === 'number') {
- concurrent = observables.pop();
- }
- if (scheduler === null && observables.length === 1 && observables[0] instanceof Observable_1.Observable) {
- return observables[0];
- }
- return new ArrayObservable_1.ArrayObservable(observables, scheduler).lift(new mergeAll_1.MergeAllOperator(concurrent));
- }
- var mergeStatic_1 = mergeStatic;
-
- var merge_1 = {
- merge: merge_2$1,
- mergeStatic: mergeStatic_1
- };
-
- var merge_2 = merge_1.mergeStatic;
-
- var __extends$12 = (commonjsGlobal && commonjsGlobal.__extends) || function (d, b) {
- for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- /**
- * An error thrown when an action is invalid because the object has been
- * unsubscribed.
- *
- * @see {@link Subject}
- * @see {@link BehaviorSubject}
- *
- * @class ObjectUnsubscribedError
- */
- var ObjectUnsubscribedError = (function (_super) {
- __extends$12(ObjectUnsubscribedError, _super);
- function ObjectUnsubscribedError() {
- var err = _super.call(this, 'object unsubscribed');
- this.name = err.name = 'ObjectUnsubscribedError';
- this.stack = err.stack;
- this.message = err.message;
- }
- return ObjectUnsubscribedError;
- }(Error));
- var ObjectUnsubscribedError_2 = ObjectUnsubscribedError;
-
- var ObjectUnsubscribedError_1 = {
- ObjectUnsubscribedError: ObjectUnsubscribedError_2
- };
-
- var __extends$13 = (commonjsGlobal && commonjsGlobal.__extends) || function (d, b) {
- for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
-
- /**
- * We need this JSDoc comment for affecting ESDoc.
- * @ignore
- * @extends {Ignored}
- */
- var SubjectSubscription = (function (_super) {
- __extends$13(SubjectSubscription, _super);
- function SubjectSubscription(subject, subscriber) {
- _super.call(this);
- this.subject = subject;
- this.subscriber = subscriber;
- this.closed = false;
- }
- SubjectSubscription.prototype.unsubscribe = function () {
- if (this.closed) {
- return;
- }
- this.closed = true;
- var subject = this.subject;
- var observers = subject.observers;
- this.subject = null;
- if (!observers || observers.length === 0 || subject.isStopped || subject.closed) {
- return;
- }
- var subscriberIndex = observers.indexOf(this.subscriber);
- if (subscriberIndex !== -1) {
- observers.splice(subscriberIndex, 1);
- }
- };
- return SubjectSubscription;
- }(Subscription_1.Subscription));
- var SubjectSubscription_2 = SubjectSubscription;
-
- var SubjectSubscription_1 = {
- SubjectSubscription: SubjectSubscription_2
- };
-
- var __extends$11 = (commonjsGlobal && commonjsGlobal.__extends) || function (d, b) {
- for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
-
-
-
-
-
-
- /**
- * @class SubjectSubscriber<T>
- */
- var SubjectSubscriber = (function (_super) {
- __extends$11(SubjectSubscriber, _super);
- function SubjectSubscriber(destination) {
- _super.call(this, destination);
- this.destination = destination;
- }
- return SubjectSubscriber;
- }(Subscriber_1.Subscriber));
- var SubjectSubscriber_1 = SubjectSubscriber;
- /**
- * @class Subject<T>
- */
- var Subject = (function (_super) {
- __extends$11(Subject, _super);
- function Subject() {
- _super.call(this);
- this.observers = [];
- this.closed = false;
- this.isStopped = false;
- this.hasError = false;
- this.thrownError = null;
- }
- Subject.prototype[rxSubscriber.rxSubscriber] = function () {
- return new SubjectSubscriber(this);
- };
- Subject.prototype.lift = function (operator) {
- var subject = new AnonymousSubject(this, this);
- subject.operator = operator;
- return subject;
- };
- Subject.prototype.next = function (value) {
- if (this.closed) {
- throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
- }
- if (!this.isStopped) {
- var observers = this.observers;
- var len = observers.length;
- var copy = observers.slice();
- for (var i = 0; i < len; i++) {
- copy[i].next(value);
- }
- }
- };
- Subject.prototype.error = function (err) {
- if (this.closed) {
- throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
- }
- this.hasError = true;
- this.thrownError = err;
- this.isStopped = true;
- var observers = this.observers;
- var len = observers.length;
- var copy = observers.slice();
- for (var i = 0; i < len; i++) {
- copy[i].error(err);
- }
- this.observers.length = 0;
- };
- Subject.prototype.complete = function () {
- if (this.closed) {
- throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
- }
- this.isStopped = true;
- var observers = this.observers;
- var len = observers.length;
- var copy = observers.slice();
- for (var i = 0; i < len; i++) {
- copy[i].complete();
- }
- this.observers.length = 0;
- };
- Subject.prototype.unsubscribe = function () {
- this.isStopped = true;
- this.closed = true;
- this.observers = null;
- };
- Subject.prototype._trySubscribe = function (subscriber) {
- if (this.closed) {
- throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
- }
- else {
- return _super.prototype._trySubscribe.call(this, subscriber);
- }
- };
- Subject.prototype._subscribe = function (subscriber) {
- if (this.closed) {
- throw new ObjectUnsubscribedError_1.ObjectUnsubscribedError();
- }
- else if (this.hasError) {
- subscriber.error(this.thrownError);
- return Subscription_1.Subscription.EMPTY;
- }
- else if (this.isStopped) {
- subscriber.complete();
- return Subscription_1.Subscription.EMPTY;
- }
- else {
- this.observers.push(subscriber);
- return new SubjectSubscription_1.SubjectSubscription(this, subscriber);
- }
- };
- Subject.prototype.asObservable = function () {
- var observable = new Observable_1.Observable();
- observable.source = this;
- return observable;
- };
- Subject.create = function (destination, source) {
- return new AnonymousSubject(destination, source);
- };
- return Subject;
- }(Observable_1.Observable));
- var Subject_2 = Subject;
- /**
- * @class AnonymousSubject<T>
- */
- var AnonymousSubject = (function (_super) {
- __extends$11(AnonymousSubject, _super);
- function AnonymousSubject(destination, source) {
- _super.call(this);
- this.destination = destination;
- this.source = source;
- }
- AnonymousSubject.prototype.next = function (value) {
- var destination = this.destination;
- if (destination && destination.next) {
- destination.next(value);
- }
- };
- AnonymousSubject.prototype.error = function (err) {
- var destination = this.destination;
- if (destination && destination.error) {
- this.destination.error(err);
- }
- };
- AnonymousSubject.prototype.complete = function () {
- var destination = this.destination;
- if (destination && destination.complete) {
- this.destination.complete();
- }
- };
- AnonymousSubject.prototype._subscribe = function (subscriber) {
- var source = this.source;
- if (source) {
- return this.source.subscribe(subscriber);
- }
- else {
- return Subscription_1.Subscription.EMPTY;
- }
- };
- return AnonymousSubject;
- }(Subject));
- var AnonymousSubject_1 = AnonymousSubject;
-
- var Subject_1 = {
- SubjectSubscriber: SubjectSubscriber_1,
- Subject: Subject_2,
- AnonymousSubject: AnonymousSubject_1
- };
-
- var __extends$10 = (commonjsGlobal && commonjsGlobal.__extends) || function (d, b) {
- for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
-
-
-
-
- /**
- * @class ConnectableObservable<T>
- */
- var ConnectableObservable = (function (_super) {
- __extends$10(ConnectableObservable, _super);
- function ConnectableObservable(source, subjectFactory) {
- _super.call(this);
- this.source = source;
- this.subjectFactory = subjectFactory;
- this._refCount = 0;
- this._isComplete = false;
- }
- ConnectableObservable.prototype._subscribe = function (subscriber) {
- return this.getSubject().subscribe(subscriber);
- };
- ConnectableObservable.prototype.getSubject = function () {
- var subject = this._subject;
- if (!subject || subject.isStopped) {
- this._subject = this.subjectFactory();
- }
- return this._subject;
- };
- ConnectableObservable.prototype.connect = function () {
- var connection = this._connection;
- if (!connection) {
- this._isComplete = false;
- connection = this._connection = new Subscription_1.Subscription();
- connection.add(this.source
- .subscribe(new ConnectableSubscriber(this.getSubject(), this)));
- if (connection.closed) {
- this._connection = null;
- connection = Subscription_1.Subscription.EMPTY;
- }
- else {
- this._connection = connection;
- }
- }
- return connection;
- };
- ConnectableObservable.prototype.refCount = function () {
- return this.lift(new RefCountOperator(this));
- };
- return ConnectableObservable;
- }(Observable_1.Observable));
- var ConnectableObservable_2 = ConnectableObservable;
- var connectableProto = ConnectableObservable.prototype;
- var connectableObservableDescriptor = {
- operator: { value: null },
- _refCount: { value: 0, writable: true },
- _subject: { value: null, writable: true },
- _connection: { value: null, writable: true },
- _subscribe: { value: connectableProto._subscribe },
- _isComplete: { value: connectableProto._isComplete, writable: true },
- getSubject: { value: connectableProto.getSubject },
- connect: { value: connectableProto.connect },
- refCount: { value: connectableProto.refCount }
- };
- var ConnectableSubscriber = (function (_super) {
- __extends$10(ConnectableSubscriber, _super);
- function ConnectableSubscriber(destination, connectable) {
- _super.call(this, destination);
- this.connectable = connectable;
- }
- ConnectableSubscriber.prototype._error = function (err) {
- this._unsubscribe();
- _super.prototype._error.call(this, err);
- };
- ConnectableSubscriber.prototype._complete = function () {
- this.connectable._isComplete = true;
- this._unsubscribe();
- _super.prototype._complete.call(this);
- };
- ConnectableSubscriber.prototype._unsubscribe = function () {
- var connectable = this.connectable;
- if (connectable) {
- this.connectable = null;
- var connection = connectable._connection;
- connectable._refCount = 0;
- connectable._subject = null;
- connectable._connection = null;
- if (connection) {
- connection.unsubscribe();
- }
- }
- };
- return ConnectableSubscriber;
- }(Subject_1.SubjectSubscriber));
- var RefCountOperator = (function () {
- function RefCountOperator(connectable) {
- this.connectable = connectable;
- }
- RefCountOperator.prototype.call = function (subscriber, source) {
- var connectable = this.connectable;
- connectable._refCount++;
- var refCounter = new RefCountSubscriber(subscriber, connectable);
- var subscription = source.subscribe(refCounter);
- if (!refCounter.closed) {
- refCounter.connection = connectable.connect();
- }
- return subscription;
- };
- return RefCountOperator;
- }());
- var RefCountSubscriber = (function (_super) {
- __extends$10(RefCountSubscriber, _super);
- function RefCountSubscriber(destination, connectable) {
- _super.call(this, destination);
- this.connectable = connectable;
- }
- RefCountSubscriber.prototype._unsubscribe = function () {
- var connectable = this.connectable;
- if (!connectable) {
- this.connection = null;
- return;
- }
- this.connectable = null;
- var refCount = connectable._refCount;
- if (refCount <= 0) {
- this.connection = null;
- return;
- }
- connectable._refCount = refCount - 1;
- if (refCount > 1) {
- this.connection = null;
- return;
- }
- ///
- // Compare the local RefCountSubscriber's connection Subscription to the
- // connection Subscription on the shared ConnectableObservable. In cases
- // where the ConnectableObservable source synchronously emits values, and
- // the RefCountSubscriber's downstream Observers synchronously unsubscribe,
- // execution continues to here before the RefCountOperator has a chance to
- // supply the RefCountSubscriber with the shared connection Subscription.
- // For example:
- // ```
- // Observable.range(0, 10)
- // .publish()
- // .refCount()
- // .take(5)
- // .subscribe();
- // ```
- // In order to account for this case, RefCountSubscriber should only dispose
- // the ConnectableObservable's shared connection Subscription if the
- // connection Subscription exists, *and* either:
- // a. RefCountSubscriber doesn't have a reference to the shared connection
- // Subscription yet, or,
- // b. RefCountSubscriber's connection Subscription reference is identical
- // to the shared connection Subscription
- ///
- var connection = this.connection;
- var sharedConnection = connectable._connection;
- this.connection = null;
- if (sharedConnection && (!connection || sharedConnection === connection)) {
- sharedConnection.unsubscribe();
- }
- };
- return RefCountSubscriber;
- }(Subscriber_1.Subscriber));
-
- var ConnectableObservable_1 = {
- ConnectableObservable: ConnectableObservable_2,
- connectableObservableDescriptor: connectableObservableDescriptor
- };
-
- /* tslint:enable:max-line-length */
- /**
- * Returns an Observable that emits the results of invoking a specified selector on items
- * emitted by a ConnectableObservable that shares a single subscription to the underlying stream.
- *
- * <img src="./img/multicast.png" width="100%">
- *
- * @param {Function|Subject} subjectOrSubjectFactory - Factory function to create an intermediate subject through
- * which the source sequence's elements will be multicast to the selector function
- * or Subject to push source elements into.
- * @param {Function} [selector] - Optional selector function that can use the multicasted source stream
- * as many times as needed, without causing multiple subscriptions to the source stream.
- * Subscribers to the given source will receive all notifications of the source from the
- * time of the subscription forward.
- * @return {Observable} An Observable that emits the results of invoking the selector
- * on the items emitted by a `ConnectableObservable` that shares a single subscription to
- * the underlying stream.
- * @method multicast
- * @owner Observable
- */
- function multicast(subjectOrSubjectFactory, selector) {
- var subjectFactory;
- if (typeof subjectOrSubjectFactory === 'function') {
- subjectFactory = subjectOrSubjectFactory;
- }
- else {
- subjectFactory = function subjectFactory() {
- return subjectOrSubjectFactory;
- };
- }
- if (typeof selector === 'function') {
- return this.lift(new MulticastOperator(subjectFactory, selector));
- }
- var connectable = Object.create(this, ConnectableObservable_1.connectableObservableDescriptor);
- connectable.source = this;
- connectable.subjectFactory = subjectFactory;
- return connectable;
- }
- var multicast_2 = multicast;
- var MulticastOperator = (function () {
- function MulticastOperator(subjectFactory, selector) {
- this.subjectFactory = subjectFactory;
- this.selector = selector;
- }
- MulticastOperator.prototype.call = function (subscriber, source) {
- var selector = this.selector;
- var subject = this.subjectFactory();
- var subscription = selector(subject).subscribe(subscriber);
- subscription.add(source.subscribe(subject));
- return subscription;
- };
- return MulticastOperator;
- }());
- var MulticastOperator_1 = MulticastOperator;
-
- var multicast_1 = {
- multicast: multicast_2,
- MulticastOperator: MulticastOperator_1
- };
-
- function shareSubjectFactory() {
- return new Subject_1.Subject();
- }
- /**
- * Returns a new Observable that multicasts (shares) the original Observable. As long as there is at least one
- * Subscriber this Observable will be subscribed and emitting data. When all subscribers have unsubscribed it will
- * unsubscribe from the source Observable. Because the Observable is multicasting it makes the stream `hot`.
- * This is an alias for .publish().refCount().
- *
- * <img src="./img/share.png" width="100%">
- *
- * @return {Observable<T>} An Observable that upon connection causes the source Observable to emit items to its Observers.
- * @method share
- * @owner Observable
- */
- function share() {
- return multicast_1.multicast.call(this, shareSubjectFactory).refCount();
- }
- var share_2 = share;
-
- /**
- * @license Angular v4.4.6
- * (c) 2010-2017 Google, Inc. https://angular.io/
- * License: MIT
- */
- /**
- * Creates a token that can be used in a DI Provider.
- *
- * ### Example ([live demo](http://plnkr.co/edit/Ys9ezXpj2Mnoy3Uc8KBp?p=preview))
- *
- * ```typescript
- * var t = new OpaqueToken("value");
- *
- * var injector = Injector.resolveAndCreate([
- * {provide: t, useValue: "bindingValue"}
- * ]);
- *
- * expect(injector.get(t)).toEqual("bindingValue");
- * ```
- *
- * Using an `OpaqueToken` is preferable to using strings as tokens because of possible collisions
- * caused by multiple providers using the same string as two different tokens.
- *
- * Using an `OpaqueToken` is preferable to using an `Object` as tokens because it provides better
- * error messages.
- * @deprecated since v4.0.0 because it does not support type information, use `InjectionToken<?>`
- * instead.
- */
- var OpaqueToken = (function () {
- /**
- * @param {?} _desc
- */
- function OpaqueToken(_desc) {
- this._desc = _desc;
- }
- /**
- * @return {?}
- */
- OpaqueToken.prototype.toString = function () { return "Token " + this._desc; };
- return OpaqueToken;
- }());
- /**
- * Creates a token that can be used in a DI Provider.
- *
- * Use an `InjectionToken` whenever the type you are injecting is not reified (does not have a
- * runtime representation) such as when injecting an interface, callable type, array or
- * parametrized type.
- *
- * `InjectionToken` is parameterized on `T` which is the type of object which will be returned by
- * the `Injector`. This provides additional level of type safety.
- *
- * ```
- * interface MyInterface {...}
- * var myInterface = injector.get(new InjectionToken<MyInterface>('SomeToken'));
- * // myInterface is inferred to be MyInterface.
- * ```
- *
- * ### Example
- *
- * {\@example core/di/ts/injector_spec.ts region='InjectionToken'}
- *
- * \@stable
- */
- var InjectionToken = (function (_super) {
- __extends$1(InjectionToken, _super);
- /**
- * @param {?} desc
- */
- function InjectionToken(desc) {
- return _super.call(this, desc) || this;
- }
- /**
- * @return {?}
- */
- InjectionToken.prototype.toString = function () { return "InjectionToken " + this._desc; };
- return InjectionToken;
- }(OpaqueToken));
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var __window = typeof window !== 'undefined' && window;
- var __self = typeof self !== 'undefined' && typeof WorkerGlobalScope !== 'undefined' &&
- self instanceof WorkerGlobalScope && self;
- var __global = typeof global !== 'undefined' && global;
- var _global = __window || __global || __self;
- var _symbolIterator = null;
- /**
- * @return {?}
- */
- function getSymbolIterator() {
- if (!_symbolIterator) {
- var /** @type {?} */ Symbol = _global['Symbol'];
- if (Symbol && Symbol.iterator) {
- _symbolIterator = Symbol.iterator;
- }
- else {
- // es6-shim specific logic
- var /** @type {?} */ keys = Object.getOwnPropertyNames(Map.prototype);
- for (var /** @type {?} */ i = 0; i < keys.length; ++i) {
- var /** @type {?} */ key = keys[i];
- if (key !== 'entries' && key !== 'size' &&
- ((Map)).prototype[key] === Map.prototype['entries']) {
- _symbolIterator = key;
- }
- }
- }
- }
- return _symbolIterator;
- }
- /**
- * @param {?} fn
- * @return {?}
- */
- function scheduleMicroTask(fn) {
- Zone.current.scheduleMicroTask('scheduleMicrotask', fn);
- }
- /**
- * @param {?} a
- * @param {?} b
- * @return {?}
- */
- function looseIdentical(a, b) {
- return a === b || typeof a === 'number' && typeof b === 'number' && isNaN(a) && isNaN(b);
- }
- /**
- * @param {?} token
- * @return {?}
- */
- function stringify(token) {
- if (typeof token === 'string') {
- return token;
- }
- if (token == null) {
- return '' + token;
- }
- if (token.overriddenName) {
- return "" + token.overriddenName;
- }
- if (token.name) {
- return "" + token.name;
- }
- var /** @type {?} */ res = token.toString();
- if (res == null) {
- return '' + res;
- }
- var /** @type {?} */ newLineIndex = res.indexOf('\n');
- return newLineIndex === -1 ? res : res.substring(0, newLineIndex);
- }
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var _nextClassId = 0;
- var Reflect$1 = _global['Reflect'];
- /**
- * @param {?} annotation
- * @return {?}
- */
- function extractAnnotation(annotation) {
- if (typeof annotation === 'function' && annotation.hasOwnProperty('annotation')) {
- // it is a decorator, extract annotation
- annotation = annotation.annotation;
- }
- return annotation;
- }
- /**
- * @param {?} fnOrArray
- * @param {?} key
- * @return {?}
- */
- function applyParams(fnOrArray, key) {
- if (fnOrArray === Object || fnOrArray === String || fnOrArray === Function ||
- fnOrArray === Number || fnOrArray === Array) {
- throw new Error("Can not use native " + stringify(fnOrArray) + " as constructor");
- }
- if (typeof fnOrArray === 'function') {
- return fnOrArray;
- }
- if (Array.isArray(fnOrArray)) {
- var /** @type {?} */ annotations = (fnOrArray);
- var /** @type {?} */ annoLength = annotations.length - 1;
- var /** @type {?} */ fn = fnOrArray[annoLength];
- if (typeof fn !== 'function') {
- throw new Error("Last position of Class method array must be Function in key " + key + " was '" + stringify(fn) + "'");
- }
- if (annoLength != fn.length) {
- throw new Error("Number of annotations (" + annoLength + ") does not match number of arguments (" + fn.length + ") in the function: " + stringify(fn));
- }
- var /** @type {?} */ paramsAnnotations = [];
- for (var /** @type {?} */ i = 0, /** @type {?} */ ii = annotations.length - 1; i < ii; i++) {
- var /** @type {?} */ paramAnnotations = [];
- paramsAnnotations.push(paramAnnotations);
- var /** @type {?} */ annotation = annotations[i];
- if (Array.isArray(annotation)) {
- for (var /** @type {?} */ j = 0; j < annotation.length; j++) {
- paramAnnotations.push(extractAnnotation(annotation[j]));
- }
- }
- else if (typeof annotation === 'function') {
- paramAnnotations.push(extractAnnotation(annotation));
- }
- else {
- paramAnnotations.push(annotation);
- }
- }
- Reflect$1.defineMetadata('parameters', paramsAnnotations, fn);
- return fn;
- }
- throw new Error("Only Function or Array is supported in Class definition for key '" + key + "' is '" + stringify(fnOrArray) + "'");
- }
- /**
- * Provides a way for expressing ES6 classes with parameter annotations in ES5.
- *
- * ## Basic Example
- *
- * ```
- * var Greeter = ng.Class({
- * constructor: function(name) {
- * this.name = name;
- * },
- *
- * greet: function() {
- * alert('Hello ' + this.name + '!');
- * }
- * });
- * ```
- *
- * is equivalent to ES6:
- *
- * ```
- * class Greeter {
- * constructor(name) {
- * this.name = name;
- * }
- *
- * greet() {
- * alert('Hello ' + this.name + '!');
- * }
- * }
- * ```
- *
- * or equivalent to ES5:
- *
- * ```
- * var Greeter = function (name) {
- * this.name = name;
- * }
- *
- * Greeter.prototype.greet = function () {
- * alert('Hello ' + this.name + '!');
- * }
- * ```
- *
- * ### Example with parameter annotations
- *
- * ```
- * var MyService = ng.Class({
- * constructor: [String, [new Optional(), Service], function(name, myService) {
- * ...
- * }]
- * });
- * ```
- *
- * is equivalent to ES6:
- *
- * ```
- * class MyService {
- * constructor(name: string, \@Optional() myService: Service) {
- * ...
- * }
- * }
- * ```
- *
- * ### Example with inheritance
- *
- * ```
- * var Shape = ng.Class({
- * constructor: (color) {
- * this.color = color;
- * }
- * });
- *
- * var Square = ng.Class({
- * extends: Shape,
- * constructor: function(color, size) {
- * Shape.call(this, color);
- * this.size = size;
- * }
- * });
- * ```
- * @suppress {globalThis}
- * \@stable
- * @param {?} clsDef
- * @return {?}
- */
- function Class(clsDef) {
- var /** @type {?} */ constructor = applyParams(clsDef.hasOwnProperty('constructor') ? clsDef.constructor : undefined, 'constructor');
- var /** @type {?} */ proto = constructor.prototype;
- if (clsDef.hasOwnProperty('extends')) {
- if (typeof clsDef.extends === 'function') {
- ((constructor)).prototype = proto =
- Object.create(((clsDef.extends)).prototype);
- }
- else {
- throw new Error("Class definition 'extends' property must be a constructor function was: " + stringify(clsDef.extends));
- }
- }
- for (var /** @type {?} */ key in clsDef) {
- if (key !== 'extends' && key !== 'prototype' && clsDef.hasOwnProperty(key)) {
- proto[key] = applyParams(clsDef[key], key);
- }
- }
- if (this && this.annotations instanceof Array) {
- Reflect$1.defineMetadata('annotations', this.annotations, constructor);
- }
- var /** @type {?} */ constructorName = constructor['name'];
- if (!constructorName || constructorName === 'constructor') {
- ((constructor))['overriddenName'] = "class" + _nextClassId++;
- }
- return (constructor);
- }
- /**
- * @suppress {globalThis}
- * @param {?} name
- * @param {?=} props
- * @param {?=} parentClass
- * @param {?=} chainFn
- * @return {?}
- */
- function makeDecorator(name, props, parentClass, chainFn) {
- var /** @type {?} */ metaCtor = makeMetadataCtor(props);
- /**
- * @param {?} objOrType
- * @return {?}
- */
- function DecoratorFactory(objOrType) {
- if (!(Reflect$1 && Reflect$1.getOwnMetadata)) {
- throw 'reflect-metadata shim is required when using class decorators';
- }
- if (this instanceof DecoratorFactory) {
- metaCtor.call(this, objOrType);
- return this;
- }
- var /** @type {?} */ annotationInstance = new ((DecoratorFactory))(objOrType);
- var /** @type {?} */ chainAnnotation = typeof this === 'function' && Array.isArray(this.annotations) ? this.annotations : [];
- chainAnnotation.push(annotationInstance);
- var /** @type {?} */ TypeDecorator = (function TypeDecorator(cls) {
- var /** @type {?} */ annotations = Reflect$1.getOwnMetadata('annotations', cls) || [];
- annotations.push(annotationInstance);
- Reflect$1.defineMetadata('annotations', annotations, cls);
- return cls;
- });
- TypeDecorator.annotations = chainAnnotation;
- TypeDecorator.Class = Class;
- if (chainFn)
- chainFn(TypeDecorator);
- return TypeDecorator;
- }
- if (parentClass) {
- DecoratorFactory.prototype = Object.create(parentClass.prototype);
- }
- DecoratorFactory.prototype.toString = function () { return "@" + name; };
- ((DecoratorFactory)).annotationCls = DecoratorFactory;
- return DecoratorFactory;
- }
- /**
- * @param {?=} props
- * @return {?}
- */
- function makeMetadataCtor(props) {
- return function ctor() {
- var args = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- args[_i] = arguments[_i];
- }
- if (props) {
- var /** @type {?} */ values = props.apply(void 0, args);
- for (var /** @type {?} */ propName in values) {
- this[propName] = values[propName];
- }
- }
- };
- }
- /**
- * @param {?} name
- * @param {?=} props
- * @param {?=} parentClass
- * @return {?}
- */
- function makeParamDecorator(name, props, parentClass) {
- var /** @type {?} */ metaCtor = makeMetadataCtor(props);
- /**
- * @param {...?} args
- * @return {?}
- */
- function ParamDecoratorFactory() {
- var args = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- args[_i] = arguments[_i];
- }
- if (this instanceof ParamDecoratorFactory) {
- metaCtor.apply(this, args);
- return this;
- }
- var /** @type {?} */ annotationInstance = new (((ParamDecoratorFactory)).bind.apply(((ParamDecoratorFactory)), [void 0].concat(args)))();
- ((ParamDecorator)).annotation = annotationInstance;
- return ParamDecorator;
- /**
- * @param {?} cls
- * @param {?} unusedKey
- * @param {?} index
- * @return {?}
- */
- function ParamDecorator(cls, unusedKey, index) {
- var /** @type {?} */ parameters = Reflect$1.getOwnMetadata('parameters', cls) || [];
- // there might be gaps if some in between parameters do not have annotations.
- // we pad with nulls.
- while (parameters.length <= index) {
- parameters.push(null);
- }
- parameters[index] = parameters[index] || []; /** @type {?} */
- ((parameters[index])).push(annotationInstance);
- Reflect$1.defineMetadata('parameters', parameters, cls);
- return cls;
- }
- }
- if (parentClass) {
- ParamDecoratorFactory.prototype = Object.create(parentClass.prototype);
- }
- ParamDecoratorFactory.prototype.toString = function () { return "@" + name; };
- ((ParamDecoratorFactory)).annotationCls = ParamDecoratorFactory;
- return ParamDecoratorFactory;
- }
- /**
- * @param {?} name
- * @param {?=} props
- * @param {?=} parentClass
- * @return {?}
- */
- function makePropDecorator(name, props, parentClass) {
- var /** @type {?} */ metaCtor = makeMetadataCtor(props);
- /**
- * @param {...?} args
- * @return {?}
- */
- function PropDecoratorFactory() {
- var args = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- args[_i] = arguments[_i];
- }
- if (this instanceof PropDecoratorFactory) {
- metaCtor.apply(this, args);
- return this;
- }
- var /** @type {?} */ decoratorInstance = new (((PropDecoratorFactory)).bind.apply(((PropDecoratorFactory)), [void 0].concat(args)))();
- return function PropDecorator(target, name) {
- var /** @type {?} */ meta = Reflect$1.getOwnMetadata('propMetadata', target.constructor) || {};
- meta[name] = meta.hasOwnProperty(name) && meta[name] || [];
- meta[name].unshift(decoratorInstance);
- Reflect$1.defineMetadata('propMetadata', meta, target.constructor);
- };
- }
- if (parentClass) {
- PropDecoratorFactory.prototype = Object.create(parentClass.prototype);
- }
- PropDecoratorFactory.prototype.toString = function () { return "@" + name; };
- ((PropDecoratorFactory)).annotationCls = PropDecoratorFactory;
- return PropDecoratorFactory;
- }
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * This token can be used to create a virtual provider that will populate the
- * `entryComponents` fields of components and ng modules based on its `useValue`.
- * All components that are referenced in the `useValue` value (either directly
- * or in a nested array or map) will be added to the `entryComponents` property.
- *
- * ### Example
- * The following example shows how the router can populate the `entryComponents`
- * field of an NgModule based on the router configuration which refers
- * to components.
- *
- * ```typescript
- * // helper function inside the router
- * function provideRoutes(routes) {
- * return [
- * {provide: ROUTES, useValue: routes},
- * {provide: ANALYZE_FOR_ENTRY_COMPONENTS, useValue: routes, multi: true}
- * ];
- * }
- *
- * // user code
- * let routes = [
- * {path: '/root', component: RootComp},
- * {path: '/teams', component: TeamsComp}
- * ];
- *
- * \@NgModule({
- * providers: [provideRoutes(routes)]
- * })
- * class ModuleWithRoutes {}
- * ```
- *
- * \@experimental
- */
- var ANALYZE_FOR_ENTRY_COMPONENTS = new InjectionToken('AnalyzeForEntryComponents');
- /**
- * Attribute decorator and metadata.
- *
- * \@stable
- * \@Annotation
- */
- var Attribute = makeParamDecorator('Attribute', function (attributeName) { return ({ attributeName: attributeName }); });
- /**
- * Base class for query metadata.
- *
- * See {\@link ContentChildren}, {\@link ContentChild}, {\@link ViewChildren}, {\@link ViewChild} for
- * more information.
- *
- * \@stable
- * @abstract
- */
- var Query = (function () {
- function Query() {
- }
- return Query;
- }());
- /**
- * ContentChildren decorator and metadata.
- *
- * \@stable
- * \@Annotation
- */
- var ContentChildren = makePropDecorator('ContentChildren', function (selector, data) {
- if (data === void 0) { data = {}; }
- return (Object.assign({ selector: selector, first: false, isViewQuery: false, descendants: false }, data));
- }, Query);
- /**
- * ContentChild decorator and metadata.
- *
- * \@stable
- * \@Annotation
- */
- var ContentChild = makePropDecorator('ContentChild', function (selector, data) {
- if (data === void 0) { data = {}; }
- return (Object.assign({ selector: selector, first: true, isViewQuery: false, descendants: true }, data));
- }, Query);
- /**
- * ViewChildren decorator and metadata.
- *
- * \@stable
- * \@Annotation
- */
- var ViewChildren = makePropDecorator('ViewChildren', function (selector, data) {
- if (data === void 0) { data = {}; }
- return (Object.assign({ selector: selector, first: false, isViewQuery: true, descendants: true }, data));
- }, Query);
- /**
- * ViewChild decorator and metadata.
- *
- * \@stable
- * \@Annotation
- */
- var ViewChild = makePropDecorator('ViewChild', function (selector, data) { return (Object.assign({ selector: selector, first: true, isViewQuery: true, descendants: true }, data)); }, Query);
- var ChangeDetectionStrategy = {};
- ChangeDetectionStrategy.OnPush = 0;
- ChangeDetectionStrategy.Default = 1;
- ChangeDetectionStrategy[ChangeDetectionStrategy.OnPush] = "OnPush";
- ChangeDetectionStrategy[ChangeDetectionStrategy.Default] = "Default";
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * Directive decorator and metadata.
- *
- * \@stable
- * \@Annotation
- */
- var Directive = makeDecorator('Directive', function (dir) {
- if (dir === void 0) { dir = {}; }
- return dir;
- });
- /**
- * Component decorator and metadata.
- *
- * \@stable
- * \@Annotation
- */
- var Component = makeDecorator('Component', function (c) {
- if (c === void 0) { c = {}; }
- return (Object.assign({ changeDetection: ChangeDetectionStrategy.Default }, c));
- }, Directive);
- /**
- * Pipe decorator and metadata.
- *
- * \@stable
- * \@Annotation
- */
- var Pipe = makeDecorator('Pipe', function (p) { return (Object.assign({ pure: true }, p)); });
- /**
- * Input decorator and metadata.
- *
- * \@stable
- * \@Annotation
- */
- var Input = makePropDecorator('Input', function (bindingPropertyName) { return ({ bindingPropertyName: bindingPropertyName }); });
- /**
- * Output decorator and metadata.
- *
- * \@stable
- * \@Annotation
- */
- var Output = makePropDecorator('Output', function (bindingPropertyName) { return ({ bindingPropertyName: bindingPropertyName }); });
- /**
- * HostBinding decorator and metadata.
- *
- * \@stable
- * \@Annotation
- */
- var HostBinding = makePropDecorator('HostBinding', function (hostPropertyName) { return ({ hostPropertyName: hostPropertyName }); });
- /**
- * HostListener decorator and metadata.
- *
- * \@stable
- * \@Annotation
- */
- var HostListener = makePropDecorator('HostListener', function (eventName, args) { return ({ eventName: eventName, args: args }); });
- /**
- * NgModule decorator and metadata.
- *
- * \@stable
- * \@Annotation
- */
- var NgModule = makeDecorator('NgModule', function (ngModule) { return ngModule; });
- var ViewEncapsulation = {};
- ViewEncapsulation.Emulated = 0;
- ViewEncapsulation.Native = 1;
- ViewEncapsulation.None = 2;
- ViewEncapsulation[ViewEncapsulation.Emulated] = "Emulated";
- ViewEncapsulation[ViewEncapsulation.Native] = "Native";
- ViewEncapsulation[ViewEncapsulation.None] = "None";
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * \@whatItDoes Represents the version of Angular
- *
- * \@stable
- */
- var Version = (function () {
- /**
- * @param {?} full
- */
- function Version(full) {
- this.full = full;
- }
- Object.defineProperty(Version.prototype, "major", {
- /**
- * @return {?}
- */
- get: function () { return this.full.split('.')[0]; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Version.prototype, "minor", {
- /**
- * @return {?}
- */
- get: function () { return this.full.split('.')[1]; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Version.prototype, "patch", {
- /**
- * @return {?}
- */
- get: function () { return this.full.split('.').slice(2).join('.'); },
- enumerable: true,
- configurable: true
- });
- return Version;
- }());
- /**
- * \@stable
- */
- var VERSION = new Version('4.4.6');
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * Inject decorator and metadata.
- *
- * \@stable
- * \@Annotation
- */
- var Inject = makeParamDecorator('Inject', function (token) { return ({ token: token }); });
- /**
- * Optional decorator and metadata.
- *
- * \@stable
- * \@Annotation
- */
- var Optional = makeParamDecorator('Optional');
- /**
- * Injectable decorator and metadata.
- *
- * \@stable
- * \@Annotation
- */
- var Injectable = makeDecorator('Injectable');
- /**
- * Self decorator and metadata.
- *
- * \@stable
- * \@Annotation
- */
- var Self = makeParamDecorator('Self');
- /**
- * SkipSelf decorator and metadata.
- *
- * \@stable
- * \@Annotation
- */
- var SkipSelf = makeParamDecorator('SkipSelf');
- /**
- * Host decorator and metadata.
- *
- * \@stable
- * \@Annotation
- */
- var Host = makeParamDecorator('Host');
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * Allows to refer to references which are not yet defined.
- *
- * For instance, `forwardRef` is used when the `token` which we need to refer to for the purposes of
- * DI is declared,
- * but not yet defined. It is also used when the `token` which we use when creating a query is not
- * yet defined.
- *
- * ### Example
- * {\@example core/di/ts/forward_ref/forward_ref_spec.ts region='forward_ref'}
- * \@experimental
- * @param {?} forwardRefFn
- * @return {?}
- */
- function forwardRef(forwardRefFn) {
- ((forwardRefFn)).__forward_ref__ = forwardRef;
- ((forwardRefFn)).toString = function () { return stringify(this()); };
- return (((forwardRefFn)));
- }
- /**
- * Lazily retrieves the reference value from a forwardRef.
- *
- * Acts as the identity function when given a non-forward-ref value.
- *
- * ### Example ([live demo](http://plnkr.co/edit/GU72mJrk1fiodChcmiDR?p=preview))
- *
- * {\@example core/di/ts/forward_ref/forward_ref_spec.ts region='resolve_forward_ref'}
- *
- * See: {\@link forwardRef}
- * \@experimental
- * @param {?} type
- * @return {?}
- */
- function resolveForwardRef(type) {
- if (typeof type === 'function' && type.hasOwnProperty('__forward_ref__') &&
- type.__forward_ref__ === forwardRef) {
- return ((type))();
- }
- else {
- return type;
- }
- }
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var _THROW_IF_NOT_FOUND = new Object();
- var THROW_IF_NOT_FOUND = _THROW_IF_NOT_FOUND;
- var _NullInjector = (function () {
- function _NullInjector() {
- }
- /**
- * @param {?} token
- * @param {?=} notFoundValue
- * @return {?}
- */
- _NullInjector.prototype.get = function (token, notFoundValue) {
- if (notFoundValue === void 0) { notFoundValue = _THROW_IF_NOT_FOUND; }
- if (notFoundValue === _THROW_IF_NOT_FOUND) {
- throw new Error("No provider for " + stringify(token) + "!");
- }
- return notFoundValue;
- };
- return _NullInjector;
- }());
- /**
- * \@whatItDoes Injector interface
- * \@howToUse
- * ```
- * const injector: Injector = ...;
- * injector.get(...);
- * ```
- *
- * \@description
- * For more details, see the {\@linkDocs guide/dependency-injection "Dependency Injection Guide"}.
- *
- * ### Example
- *
- * {\@example core/di/ts/injector_spec.ts region='Injector'}
- *
- * `Injector` returns itself when given `Injector` as a token:
- * {\@example core/di/ts/injector_spec.ts region='injectInjector'}
- *
- * \@stable
- * @abstract
- */
- var Injector = (function () {
- function Injector() {
- }
- /**
- * Retrieves an instance from the injector based on the provided token.
- * If not found:
- * - Throws an error if no `notFoundValue` that is not equal to
- * Injector.THROW_IF_NOT_FOUND is given
- * - Returns the `notFoundValue` otherwise
- * @abstract
- * @template T
- * @param {?} token
- * @param {?=} notFoundValue
- * @return {?}
- */
- Injector.prototype.get = function (token, notFoundValue) { };
- /**
- * @deprecated from v4.0.0 use Type<T> or InjectionToken<T>
- * @suppress {duplicate}
- * @abstract
- * @param {?} token
- * @param {?=} notFoundValue
- * @return {?}
- */
- Injector.prototype.get = function (token, notFoundValue) { };
- return Injector;
- }());
- Injector.THROW_IF_NOT_FOUND = _THROW_IF_NOT_FOUND;
- Injector.NULL = new _NullInjector();
- var ERROR_DEBUG_CONTEXT = 'ngDebugContext';
- var ERROR_ORIGINAL_ERROR = 'ngOriginalError';
- var ERROR_LOGGER = 'ngErrorLogger';
- /**
- * @param {?} error
- * @return {?}
- */
- /**
- * @param {?} error
- * @return {?}
- */
- function getDebugContext(error) {
- return ((error))[ERROR_DEBUG_CONTEXT];
- }
- /**
- * @param {?} error
- * @return {?}
- */
- function getOriginalError(error) {
- return ((error))[ERROR_ORIGINAL_ERROR];
- }
- /**
- * @param {?} error
- * @return {?}
- */
- function getErrorLogger(error) {
- return ((error))[ERROR_LOGGER] || defaultErrorLogger;
- }
- /**
- * @param {?} console
- * @param {...?} values
- * @return {?}
- */
- function defaultErrorLogger(console) {
- var values = [];
- for (var _i = 1; _i < arguments.length; _i++) {
- values[_i - 1] = arguments[_i];
- }
- console.error.apply(console, values);
- }
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * \@whatItDoes Provides a hook for centralized exception handling.
- *
- * \@description
- *
- * The default implementation of `ErrorHandler` prints error messages to the `console`. To
- * intercept error handling, write a custom exception handler that replaces this default as
- * appropriate for your app.
- *
- * ### Example
- *
- * ```
- * class MyErrorHandler implements ErrorHandler {
- * handleError(error) {
- * // do something with the exception
- * }
- * }
- *
- * \@NgModule({
- * providers: [{provide: ErrorHandler, useClass: MyErrorHandler}]
- * })
- * class MyModule {}
- * ```
- *
- * \@stable
- */
- var ErrorHandler = (function () {
- /**
- * @param {?=} deprecatedParameter
- */
- function ErrorHandler(
- /**
- * @deprecated since v4.0 parameter no longer has an effect, as ErrorHandler will never
- * rethrow.
- */
- deprecatedParameter) {
- /**
- * \@internal
- */
- this._console = console;
- }
- /**
- * @param {?} error
- * @return {?}
- */
- ErrorHandler.prototype.handleError = function (error) {
- var /** @type {?} */ originalError = this._findOriginalError(error);
- var /** @type {?} */ context = this._findContext(error);
- // Note: Browser consoles show the place from where console.error was called.
- // We can use this to give users additional information about the error.
- var /** @type {?} */ errorLogger = getErrorLogger(error);
- errorLogger(this._console, "ERROR", error);
- if (originalError) {
- errorLogger(this._console, "ORIGINAL ERROR", originalError);
- }
- if (context) {
- errorLogger(this._console, 'ERROR CONTEXT', context);
- }
- };
- /**
- * \@internal
- * @param {?} error
- * @return {?}
- */
- ErrorHandler.prototype._findContext = function (error) {
- if (error) {
- return getDebugContext(error) ? getDebugContext(error) :
- this._findContext(getOriginalError(error));
- }
- return null;
- };
- /**
- * \@internal
- * @param {?} error
- * @return {?}
- */
- ErrorHandler.prototype._findOriginalError = function (error) {
- var /** @type {?} */ e = getOriginalError(error);
- while (e && getOriginalError(e)) {
- e = getOriginalError(e);
- }
- return e;
- };
- return ErrorHandler;
- }());
- /**
- * @param {?} message
- * @param {?} originalError
- * @return {?}
- */
- function wrappedError(message, originalError) {
- var /** @type {?} */ msg = message + " caused by: " + (originalError instanceof Error ? originalError.message : originalError);
- var /** @type {?} */ error = Error(msg);
- ((error))[ERROR_ORIGINAL_ERROR] = originalError;
- return error;
- }
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * @param {?} keys
- * @return {?}
- */
- function findFirstClosedCycle(keys) {
- var /** @type {?} */ res = [];
- for (var /** @type {?} */ i = 0; i < keys.length; ++i) {
- if (res.indexOf(keys[i]) > -1) {
- res.push(keys[i]);
- return res;
- }
- res.push(keys[i]);
- }
- return res;
- }
- /**
- * @param {?} keys
- * @return {?}
- */
- function constructResolvingPath(keys) {
- if (keys.length > 1) {
- var /** @type {?} */ reversed = findFirstClosedCycle(keys.slice().reverse());
- var /** @type {?} */ tokenStrs = reversed.map(function (k) { return stringify(k.token); });
- return ' (' + tokenStrs.join(' -> ') + ')';
- }
- return '';
- }
- /**
- * @param {?} injector
- * @param {?} key
- * @param {?} constructResolvingMessage
- * @param {?=} originalError
- * @return {?}
- */
- function injectionError(injector, key, constructResolvingMessage, originalError) {
- var /** @type {?} */ keys = [key];
- var /** @type {?} */ errMsg = constructResolvingMessage(keys);
- var /** @type {?} */ error = ((originalError ? wrappedError(errMsg, originalError) : Error(errMsg)));
- error.addKey = addKey;
- error.keys = keys;
- error.injectors = [injector];
- error.constructResolvingMessage = constructResolvingMessage;
- ((error))[ERROR_ORIGINAL_ERROR] = originalError;
- return error;
- }
- /**
- * @this {?}
- * @param {?} injector
- * @param {?} key
- * @return {?}
- */
- function addKey(injector, key) {
- this.injectors.push(injector);
- this.keys.push(key);
- // Note: This updated message won't be reflected in the `.stack` property
- this.message = this.constructResolvingMessage(this.keys);
- }
- /**
- * Thrown when trying to retrieve a dependency by key from {\@link Injector}, but the
- * {\@link Injector} does not have a {\@link Provider} for the given key.
- *
- * ### Example ([live demo](http://plnkr.co/edit/vq8D3FRB9aGbnWJqtEPE?p=preview))
- *
- * ```typescript
- * class A {
- * constructor(b:B) {}
- * }
- *
- * expect(() => Injector.resolveAndCreate([A])).toThrowError();
- * ```
- * @param {?} injector
- * @param {?} key
- * @return {?}
- */
- function noProviderError(injector, key) {
- return injectionError(injector, key, function (keys) {
- var /** @type {?} */ first = stringify(keys[0].token);
- return "No provider for " + first + "!" + constructResolvingPath(keys);
- });
- }
- /**
- * Thrown when dependencies form a cycle.
- *
- * ### Example ([live demo](http://plnkr.co/edit/wYQdNos0Tzql3ei1EV9j?p=info))
- *
- * ```typescript
- * var injector = Injector.resolveAndCreate([
- * {provide: "one", useFactory: (two) => "two", deps: [[new Inject("two")]]},
- * {provide: "two", useFactory: (one) => "one", deps: [[new Inject("one")]]}
- * ]);
- *
- * expect(() => injector.get("one")).toThrowError();
- * ```
- *
- * Retrieving `A` or `B` throws a `CyclicDependencyError` as the graph above cannot be constructed.
- * @param {?} injector
- * @param {?} key
- * @return {?}
- */
- function cyclicDependencyError(injector, key) {
- return injectionError(injector, key, function (keys) {
- return "Cannot instantiate cyclic dependency!" + constructResolvingPath(keys);
- });
- }
- /**
- * Thrown when a constructing type returns with an Error.
- *
- * The `InstantiationError` class contains the original error plus the dependency graph which caused
- * this object to be instantiated.
- *
- * ### Example ([live demo](http://plnkr.co/edit/7aWYdcqTQsP0eNqEdUAf?p=preview))
- *
- * ```typescript
- * class A {
- * constructor() {
- * throw new Error('message');
- * }
- * }
- *
- * var injector = Injector.resolveAndCreate([A]);
- * try {
- * injector.get(A);
- * } catch (e) {
- * expect(e instanceof InstantiationError).toBe(true);
- * expect(e.originalException.message).toEqual("message");
- * expect(e.originalStack).toBeDefined();
- * }
- * ```
- * @param {?} injector
- * @param {?} originalException
- * @param {?} originalStack
- * @param {?} key
- * @return {?}
- */
- function instantiationError(injector, originalException, originalStack, key) {
- return injectionError(injector, key, function (keys) {
- var /** @type {?} */ first = stringify(keys[0].token);
- return originalException.message + ": Error during instantiation of " + first + "!" + constructResolvingPath(keys) + ".";
- }, originalException);
- }
- /**
- * Thrown when an object other then {\@link Provider} (or `Type`) is passed to {\@link Injector}
- * creation.
- *
- * ### Example ([live demo](http://plnkr.co/edit/YatCFbPAMCL0JSSQ4mvH?p=preview))
- *
- * ```typescript
- * expect(() => Injector.resolveAndCreate(["not a type"])).toThrowError();
- * ```
- * @param {?} provider
- * @return {?}
- */
- function invalidProviderError(provider) {
- return Error("Invalid provider - only instances of Provider and Type are allowed, got: " + provider);
- }
- /**
- * Thrown when the class has no annotation information.
- *
- * Lack of annotation information prevents the {\@link Injector} from determining which dependencies
- * need to be injected into the constructor.
- *
- * ### Example ([live demo](http://plnkr.co/edit/rHnZtlNS7vJOPQ6pcVkm?p=preview))
- *
- * ```typescript
- * class A {
- * constructor(b) {}
- * }
- *
- * expect(() => Injector.resolveAndCreate([A])).toThrowError();
- * ```
- *
- * This error is also thrown when the class not marked with {\@link Injectable} has parameter types.
- *
- * ```typescript
- * class B {}
- *
- * class A {
- * constructor(b:B) {} // no information about the parameter types of A is available at runtime.
- * }
- *
- * expect(() => Injector.resolveAndCreate([A,B])).toThrowError();
- * ```
- * \@stable
- * @param {?} typeOrFunc
- * @param {?} params
- * @return {?}
- */
- function noAnnotationError(typeOrFunc, params) {
- var /** @type {?} */ signature = [];
- for (var /** @type {?} */ i = 0, /** @type {?} */ ii = params.length; i < ii; i++) {
- var /** @type {?} */ parameter = params[i];
- if (!parameter || parameter.length == 0) {
- signature.push('?');
- }
- else {
- signature.push(parameter.map(stringify).join(' '));
- }
- }
- return Error('Cannot resolve all parameters for \'' + stringify(typeOrFunc) + '\'(' +
- signature.join(', ') + '). ' +
- 'Make sure that all the parameters are decorated with Inject or have valid type annotations and that \'' +
- stringify(typeOrFunc) + '\' is decorated with Injectable.');
- }
- /**
- * Thrown when getting an object by index.
- *
- * ### Example ([live demo](http://plnkr.co/edit/bRs0SX2OTQiJzqvjgl8P?p=preview))
- *
- * ```typescript
- * class A {}
- *
- * var injector = Injector.resolveAndCreate([A]);
- *
- * expect(() => injector.getAt(100)).toThrowError();
- * ```
- * \@stable
- * @param {?} index
- * @return {?}
- */
- function outOfBoundsError(index) {
- return Error("Index " + index + " is out-of-bounds.");
- }
- /**
- * Thrown when a multi provider and a regular provider are bound to the same token.
- *
- * ### Example
- *
- * ```typescript
- * expect(() => Injector.resolveAndCreate([
- * { provide: "Strings", useValue: "string1", multi: true},
- * { provide: "Strings", useValue: "string2", multi: false}
- * ])).toThrowError();
- * ```
- * @param {?} provider1
- * @param {?} provider2
- * @return {?}
- */
- function mixingMultiProvidersWithRegularProvidersError(provider1, provider2) {
- return Error("Cannot mix multi providers and regular providers, got: " + provider1 + " " + provider2);
- }
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * A unique object used for retrieving items from the {\@link ReflectiveInjector}.
- *
- * Keys have:
- * - a system-wide unique `id`.
- * - a `token`.
- *
- * `Key` is used internally by {\@link ReflectiveInjector} because its system-wide unique `id` allows
- * the
- * injector to store created objects in a more efficient way.
- *
- * `Key` should not be created directly. {\@link ReflectiveInjector} creates keys automatically when
- * resolving
- * providers.
- * \@experimental
- */
- var ReflectiveKey = (function () {
- /**
- * Private
- * @param {?} token
- * @param {?} id
- */
- function ReflectiveKey(token, id) {
- this.token = token;
- this.id = id;
- if (!token) {
- throw new Error('Token must be defined!');
- }
- }
- Object.defineProperty(ReflectiveKey.prototype, "displayName", {
- /**
- * Returns a stringified token.
- * @return {?}
- */
- get: function () { return stringify(this.token); },
- enumerable: true,
- configurable: true
- });
- /**
- * Retrieves a `Key` for a token.
- * @param {?} token
- * @return {?}
- */
- ReflectiveKey.get = function (token) {
- return _globalKeyRegistry.get(resolveForwardRef(token));
- };
- Object.defineProperty(ReflectiveKey, "numberOfKeys", {
- /**
- * @return {?} the number of keys registered in the system.
- */
- get: function () { return _globalKeyRegistry.numberOfKeys; },
- enumerable: true,
- configurable: true
- });
- return ReflectiveKey;
- }());
- /**
- * \@internal
- */
- var KeyRegistry = (function () {
- function KeyRegistry() {
- this._allKeys = new Map();
- }
- /**
- * @param {?} token
- * @return {?}
- */
- KeyRegistry.prototype.get = function (token) {
- if (token instanceof ReflectiveKey)
- return token;
- if (this._allKeys.has(token)) {
- return ((this._allKeys.get(token)));
- }
- var /** @type {?} */ newKey = new ReflectiveKey(token, ReflectiveKey.numberOfKeys);
- this._allKeys.set(token, newKey);
- return newKey;
- };
- Object.defineProperty(KeyRegistry.prototype, "numberOfKeys", {
- /**
- * @return {?}
- */
- get: function () { return this._allKeys.size; },
- enumerable: true,
- configurable: true
- });
- return KeyRegistry;
- }());
- var _globalKeyRegistry = new KeyRegistry();
- /**
- * \@whatItDoes Represents a type that a Component or other object is instances of.
- *
- * \@description
- *
- * An example of a `Type` is `MyCustomComponent` class, which in JavaScript is be represented by
- * the `MyCustomComponent` constructor function.
- *
- * \@stable
- */
- var Type = Function;
- /**
- * @param {?} v
- * @return {?}
- */
- function isType(v) {
- return typeof v === 'function';
- }
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * Attention: This regex has to hold even if the code is minified!
- */
- var DELEGATE_CTOR = /^function\s+\S+\(\)\s*{[\s\S]+\.apply\(this,\s*arguments\)/;
- var ReflectionCapabilities = (function () {
- /**
- * @param {?=} reflect
- */
- function ReflectionCapabilities(reflect) {
- this._reflect = reflect || _global['Reflect'];
- }
- /**
- * @return {?}
- */
- ReflectionCapabilities.prototype.isReflectionEnabled = function () { return true; };
- /**
- * @template T
- * @param {?} t
- * @return {?}
- */
- ReflectionCapabilities.prototype.factory = function (t) { return function () {
- var args = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- args[_i] = arguments[_i];
- }
- return new (t.bind.apply(t, [void 0].concat(args)))();
- }; };
- /**
- * \@internal
- * @param {?} paramTypes
- * @param {?} paramAnnotations
- * @return {?}
- */
- ReflectionCapabilities.prototype._zipTypesAndAnnotations = function (paramTypes, paramAnnotations) {
- var /** @type {?} */ result;
- if (typeof paramTypes === 'undefined') {
- result = new Array(paramAnnotations.length);
- }
- else {
- result = new Array(paramTypes.length);
- }
- for (var /** @type {?} */ i = 0; i < result.length; i++) {
- // TS outputs Object for parameters without types, while Traceur omits
- // the annotations. For now we preserve the Traceur behavior to aid
- // migration, but this can be revisited.
- if (typeof paramTypes === 'undefined') {
- result[i] = [];
- }
- else if (paramTypes[i] != Object) {
- result[i] = [paramTypes[i]];
- }
- else {
- result[i] = [];
- }
- if (paramAnnotations && paramAnnotations[i] != null) {
- result[i] = result[i].concat(paramAnnotations[i]);
- }
- }
- return result;
- };
- /**
- * @param {?} type
- * @param {?} parentCtor
- * @return {?}
- */
- ReflectionCapabilities.prototype._ownParameters = function (type, parentCtor) {
- // If we have no decorators, we only have function.length as metadata.
- // In that case, to detect whether a child class declared an own constructor or not,
- // we need to look inside of that constructor to check whether it is
- // just calling the parent.
- // This also helps to work around for https://github.com/Microsoft/TypeScript/issues/12439
- // that sets 'design:paramtypes' to []
- // if a class inherits from another class but has no ctor declared itself.
- if (DELEGATE_CTOR.exec(type.toString())) {
- return null;
- }
- // Prefer the direct API.
- if (((type)).parameters && ((type)).parameters !== parentCtor.parameters) {
- return ((type)).parameters;
- }
- // API of tsickle for lowering decorators to properties on the class.
- var /** @type {?} */ tsickleCtorParams = ((type)).ctorParameters;
- if (tsickleCtorParams && tsickleCtorParams !== parentCtor.ctorParameters) {
- // Newer tsickle uses a function closure
- // Retain the non-function case for compatibility with older tsickle
- var /** @type {?} */ ctorParameters = typeof tsickleCtorParams === 'function' ? tsickleCtorParams() : tsickleCtorParams;
- var /** @type {?} */ paramTypes = ctorParameters.map(function (ctorParam) { return ctorParam && ctorParam.type; });
- var /** @type {?} */ paramAnnotations = ctorParameters.map(function (ctorParam) { return ctorParam && convertTsickleDecoratorIntoMetadata(ctorParam.decorators); });
- return this._zipTypesAndAnnotations(paramTypes, paramAnnotations);
- }
- // API for metadata created by invoking the decorators.
- if (this._reflect != null && this._reflect.getOwnMetadata != null) {
- var /** @type {?} */ paramAnnotations = this._reflect.getOwnMetadata('parameters', type);
- var /** @type {?} */ paramTypes = this._reflect.getOwnMetadata('design:paramtypes', type);
- if (paramTypes || paramAnnotations) {
- return this._zipTypesAndAnnotations(paramTypes, paramAnnotations);
- }
- }
- // If a class has no decorators, at least create metadata
- // based on function.length.
- // Note: We know that this is a real constructor as we checked
- // the content of the constructor above.
- return new Array(((type.length))).fill(undefined);
- };
- /**
- * @param {?} type
- * @return {?}
- */
- ReflectionCapabilities.prototype.parameters = function (type) {
- // Note: only report metadata if we have at least one class decorator
- // to stay in sync with the static reflector.
- if (!isType(type)) {
- return [];
- }
- var /** @type {?} */ parentCtor = getParentCtor(type);
- var /** @type {?} */ parameters = this._ownParameters(type, parentCtor);
- if (!parameters && parentCtor !== Object) {
- parameters = this.parameters(parentCtor);
- }
- return parameters || [];
- };
- /**
- * @param {?} typeOrFunc
- * @param {?} parentCtor
- * @return {?}
- */
- ReflectionCapabilities.prototype._ownAnnotations = function (typeOrFunc, parentCtor) {
- // Prefer the direct API.
- if (((typeOrFunc)).annotations && ((typeOrFunc)).annotations !== parentCtor.annotations) {
- var /** @type {?} */ annotations = ((typeOrFunc)).annotations;
- if (typeof annotations === 'function' && annotations.annotations) {
- annotations = annotations.annotations;
- }
- return annotations;
- }
- // API of tsickle for lowering decorators to properties on the class.
- if (((typeOrFunc)).decorators && ((typeOrFunc)).decorators !== parentCtor.decorators) {
- return convertTsickleDecoratorIntoMetadata(((typeOrFunc)).decorators);
- }
- // API for metadata created by invoking the decorators.
- if (this._reflect && this._reflect.getOwnMetadata) {
- return this._reflect.getOwnMetadata('annotations', typeOrFunc);
- }
- return null;
- };
- /**
- * @param {?} typeOrFunc
- * @return {?}
- */
- ReflectionCapabilities.prototype.annotations = function (typeOrFunc) {
- if (!isType(typeOrFunc)) {
- return [];
- }
- var /** @type {?} */ parentCtor = getParentCtor(typeOrFunc);
- var /** @type {?} */ ownAnnotations = this._ownAnnotations(typeOrFunc, parentCtor) || [];
- var /** @type {?} */ parentAnnotations = parentCtor !== Object ? this.annotations(parentCtor) : [];
- return parentAnnotations.concat(ownAnnotations);
- };
- /**
- * @param {?} typeOrFunc
- * @param {?} parentCtor
- * @return {?}
- */
- ReflectionCapabilities.prototype._ownPropMetadata = function (typeOrFunc, parentCtor) {
- // Prefer the direct API.
- if (((typeOrFunc)).propMetadata &&
- ((typeOrFunc)).propMetadata !== parentCtor.propMetadata) {
- var /** @type {?} */ propMetadata = ((typeOrFunc)).propMetadata;
- if (typeof propMetadata === 'function' && propMetadata.propMetadata) {
- propMetadata = propMetadata.propMetadata;
- }
- return propMetadata;
- }
- // API of tsickle for lowering decorators to properties on the class.
- if (((typeOrFunc)).propDecorators &&
- ((typeOrFunc)).propDecorators !== parentCtor.propDecorators) {
- var /** @type {?} */ propDecorators_1 = ((typeOrFunc)).propDecorators;
- var /** @type {?} */ propMetadata_1 = ({});
- Object.keys(propDecorators_1).forEach(function (prop) {
- propMetadata_1[prop] = convertTsickleDecoratorIntoMetadata(propDecorators_1[prop]);
- });
- return propMetadata_1;
- }
- // API for metadata created by invoking the decorators.
- if (this._reflect && this._reflect.getOwnMetadata) {
- return this._reflect.getOwnMetadata('propMetadata', typeOrFunc);
- }
- return null;
- };
- /**
- * @param {?} typeOrFunc
- * @return {?}
- */
- ReflectionCapabilities.prototype.propMetadata = function (typeOrFunc) {
- if (!isType(typeOrFunc)) {
- return {};
- }
- var /** @type {?} */ parentCtor = getParentCtor(typeOrFunc);
- var /** @type {?} */ propMetadata = {};
- if (parentCtor !== Object) {
- var /** @type {?} */ parentPropMetadata_1 = this.propMetadata(parentCtor);
- Object.keys(parentPropMetadata_1).forEach(function (propName) {
- propMetadata[propName] = parentPropMetadata_1[propName];
- });
- }
- var /** @type {?} */ ownPropMetadata = this._ownPropMetadata(typeOrFunc, parentCtor);
- if (ownPropMetadata) {
- Object.keys(ownPropMetadata).forEach(function (propName) {
- var /** @type {?} */ decorators = [];
- if (propMetadata.hasOwnProperty(propName)) {
- decorators.push.apply(decorators, propMetadata[propName]);
- }
- decorators.push.apply(decorators, ownPropMetadata[propName]);
- propMetadata[propName] = decorators;
- });
- }
- return propMetadata;
- };
- /**
- * @param {?} type
- * @param {?} lcProperty
- * @return {?}
- */
- ReflectionCapabilities.prototype.hasLifecycleHook = function (type, lcProperty) {
- return type instanceof Type && lcProperty in type.prototype;
- };
- /**
- * @param {?} name
- * @return {?}
- */
- ReflectionCapabilities.prototype.getter = function (name) { return (new Function('o', 'return o.' + name + ';')); };
- /**
- * @param {?} name
- * @return {?}
- */
- ReflectionCapabilities.prototype.setter = function (name) {
- return (new Function('o', 'v', 'return o.' + name + ' = v;'));
- };
- /**
- * @param {?} name
- * @return {?}
- */
- ReflectionCapabilities.prototype.method = function (name) {
- var /** @type {?} */ functionBody = "if (!o." + name + ") throw new Error('\"" + name + "\" is undefined');\n return o." + name + ".apply(o, args);";
- return (new Function('o', 'args', functionBody));
- };
- /**
- * @param {?} type
- * @return {?}
- */
- ReflectionCapabilities.prototype.importUri = function (type) {
- // StaticSymbol
- if (typeof type === 'object' && type['filePath']) {
- return type['filePath'];
- }
- // Runtime type
- return "./" + stringify(type);
- };
- /**
- * @param {?} type
- * @return {?}
- */
- ReflectionCapabilities.prototype.resourceUri = function (type) { return "./" + stringify(type); };
- /**
- * @param {?} name
- * @param {?} moduleUrl
- * @param {?} members
- * @param {?} runtime
- * @return {?}
- */
- ReflectionCapabilities.prototype.resolveIdentifier = function (name, moduleUrl, members, runtime) {
- return runtime;
- };
- /**
- * @param {?} enumIdentifier
- * @param {?} name
- * @return {?}
- */
- ReflectionCapabilities.prototype.resolveEnum = function (enumIdentifier, name) { return enumIdentifier[name]; };
- return ReflectionCapabilities;
- }());
- /**
- * @param {?} decoratorInvocations
- * @return {?}
- */
- function convertTsickleDecoratorIntoMetadata(decoratorInvocations) {
- if (!decoratorInvocations) {
- return [];
- }
- return decoratorInvocations.map(function (decoratorInvocation) {
- var /** @type {?} */ decoratorType = decoratorInvocation.type;
- var /** @type {?} */ annotationCls = decoratorType.annotationCls;
- var /** @type {?} */ annotationArgs = decoratorInvocation.args ? decoratorInvocation.args : [];
- return new (annotationCls.bind.apply(annotationCls, [void 0].concat(annotationArgs)))();
- });
- }
- /**
- * @param {?} ctor
- * @return {?}
- */
- function getParentCtor(ctor) {
- var /** @type {?} */ parentProto = Object.getPrototypeOf(ctor.prototype);
- var /** @type {?} */ parentCtor = parentProto ? parentProto.constructor : null;
- // Note: We always use `Object` as the null value
- // to simplify checking later on.
- return parentCtor || Object;
- }
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * Provides access to reflection data about symbols. Used internally by Angular
- * to power dependency injection and compilation.
- */
- var Reflector = (function () {
- /**
- * @param {?} reflectionCapabilities
- */
- function Reflector(reflectionCapabilities) {
- this.reflectionCapabilities = reflectionCapabilities;
- }
- /**
- * @param {?} caps
- * @return {?}
- */
- Reflector.prototype.updateCapabilities = function (caps) { this.reflectionCapabilities = caps; };
- /**
- * @param {?} type
- * @return {?}
- */
- Reflector.prototype.factory = function (type) { return this.reflectionCapabilities.factory(type); };
- /**
- * @param {?} typeOrFunc
- * @return {?}
- */
- Reflector.prototype.parameters = function (typeOrFunc) {
- return this.reflectionCapabilities.parameters(typeOrFunc);
- };
- /**
- * @param {?} typeOrFunc
- * @return {?}
- */
- Reflector.prototype.annotations = function (typeOrFunc) {
- return this.reflectionCapabilities.annotations(typeOrFunc);
- };
- /**
- * @param {?} typeOrFunc
- * @return {?}
- */
- Reflector.prototype.propMetadata = function (typeOrFunc) {
- return this.reflectionCapabilities.propMetadata(typeOrFunc);
- };
- /**
- * @param {?} type
- * @param {?} lcProperty
- * @return {?}
- */
- Reflector.prototype.hasLifecycleHook = function (type, lcProperty) {
- return this.reflectionCapabilities.hasLifecycleHook(type, lcProperty);
- };
- /**
- * @param {?} name
- * @return {?}
- */
- Reflector.prototype.getter = function (name) { return this.reflectionCapabilities.getter(name); };
- /**
- * @param {?} name
- * @return {?}
- */
- Reflector.prototype.setter = function (name) { return this.reflectionCapabilities.setter(name); };
- /**
- * @param {?} name
- * @return {?}
- */
- Reflector.prototype.method = function (name) { return this.reflectionCapabilities.method(name); };
- /**
- * @param {?} type
- * @return {?}
- */
- Reflector.prototype.importUri = function (type) { return this.reflectionCapabilities.importUri(type); };
- /**
- * @param {?} type
- * @return {?}
- */
- Reflector.prototype.resourceUri = function (type) { return this.reflectionCapabilities.resourceUri(type); };
- /**
- * @param {?} name
- * @param {?} moduleUrl
- * @param {?} members
- * @param {?} runtime
- * @return {?}
- */
- Reflector.prototype.resolveIdentifier = function (name, moduleUrl, members, runtime) {
- return this.reflectionCapabilities.resolveIdentifier(name, moduleUrl, members, runtime);
- };
- /**
- * @param {?} identifier
- * @param {?} name
- * @return {?}
- */
- Reflector.prototype.resolveEnum = function (identifier, name) {
- return this.reflectionCapabilities.resolveEnum(identifier, name);
- };
- return Reflector;
- }());
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * The {\@link Reflector} used internally in Angular to access metadata
- * about symbols.
- */
- var reflector = new Reflector(new ReflectionCapabilities());
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * `Dependency` is used by the framework to extend DI.
- * This is internal to Angular and should not be used directly.
- */
- var ReflectiveDependency = (function () {
- /**
- * @param {?} key
- * @param {?} optional
- * @param {?} visibility
- */
- function ReflectiveDependency(key, optional, visibility) {
- this.key = key;
- this.optional = optional;
- this.visibility = visibility;
- }
- /**
- * @param {?} key
- * @return {?}
- */
- ReflectiveDependency.fromKey = function (key) {
- return new ReflectiveDependency(key, false, null);
- };
- return ReflectiveDependency;
- }());
- var _EMPTY_LIST = [];
- var ResolvedReflectiveProvider_ = (function () {
- /**
- * @param {?} key
- * @param {?} resolvedFactories
- * @param {?} multiProvider
- */
- function ResolvedReflectiveProvider_(key, resolvedFactories, multiProvider) {
- this.key = key;
- this.resolvedFactories = resolvedFactories;
- this.multiProvider = multiProvider;
- }
- Object.defineProperty(ResolvedReflectiveProvider_.prototype, "resolvedFactory", {
- /**
- * @return {?}
- */
- get: function () { return this.resolvedFactories[0]; },
- enumerable: true,
- configurable: true
- });
- return ResolvedReflectiveProvider_;
- }());
- /**
- * An internal resolved representation of a factory function created by resolving {\@link
- * Provider}.
- * \@experimental
- */
- var ResolvedReflectiveFactory = (function () {
- /**
- * @param {?} factory
- * @param {?} dependencies
- */
- function ResolvedReflectiveFactory(factory, dependencies) {
- this.factory = factory;
- this.dependencies = dependencies;
- }
- return ResolvedReflectiveFactory;
- }());
- /**
- * Resolve a single provider.
- * @param {?} provider
- * @return {?}
- */
- function resolveReflectiveFactory(provider) {
- var /** @type {?} */ factoryFn;
- var /** @type {?} */ resolvedDeps;
- if (provider.useClass) {
- var /** @type {?} */ useClass = resolveForwardRef(provider.useClass);
- factoryFn = reflector.factory(useClass);
- resolvedDeps = _dependenciesFor(useClass);
- }
- else if (provider.useExisting) {
- factoryFn = function (aliasInstance) { return aliasInstance; };
- resolvedDeps = [ReflectiveDependency.fromKey(ReflectiveKey.get(provider.useExisting))];
- }
- else if (provider.useFactory) {
- factoryFn = provider.useFactory;
- resolvedDeps = constructDependencies(provider.useFactory, provider.deps);
- }
- else {
- factoryFn = function () { return provider.useValue; };
- resolvedDeps = _EMPTY_LIST;
- }
- return new ResolvedReflectiveFactory(factoryFn, resolvedDeps);
- }
- /**
- * Converts the {\@link Provider} into {\@link ResolvedProvider}.
- *
- * {\@link Injector} internally only uses {\@link ResolvedProvider}, {\@link Provider} contains
- * convenience provider syntax.
- * @param {?} provider
- * @return {?}
- */
- function resolveReflectiveProvider(provider) {
- return new ResolvedReflectiveProvider_(ReflectiveKey.get(provider.provide), [resolveReflectiveFactory(provider)], provider.multi || false);
- }
- /**
- * Resolve a list of Providers.
- * @param {?} providers
- * @return {?}
- */
- function resolveReflectiveProviders(providers) {
- var /** @type {?} */ normalized = _normalizeProviders(providers, []);
- var /** @type {?} */ resolved = normalized.map(resolveReflectiveProvider);
- var /** @type {?} */ resolvedProviderMap = mergeResolvedReflectiveProviders(resolved, new Map());
- return Array.from(resolvedProviderMap.values());
- }
- /**
- * Merges a list of ResolvedProviders into a list where
- * each key is contained exactly once and multi providers
- * have been merged.
- * @param {?} providers
- * @param {?} normalizedProvidersMap
- * @return {?}
- */
- function mergeResolvedReflectiveProviders(providers, normalizedProvidersMap) {
- for (var /** @type {?} */ i = 0; i < providers.length; i++) {
- var /** @type {?} */ provider = providers[i];
- var /** @type {?} */ existing = normalizedProvidersMap.get(provider.key.id);
- if (existing) {
- if (provider.multiProvider !== existing.multiProvider) {
- throw mixingMultiProvidersWithRegularProvidersError(existing, provider);
- }
- if (provider.multiProvider) {
- for (var /** @type {?} */ j = 0; j < provider.resolvedFactories.length; j++) {
- existing.resolvedFactories.push(provider.resolvedFactories[j]);
- }
- }
- else {
- normalizedProvidersMap.set(provider.key.id, provider);
- }
- }
- else {
- var /** @type {?} */ resolvedProvider = void 0;
- if (provider.multiProvider) {
- resolvedProvider = new ResolvedReflectiveProvider_(provider.key, provider.resolvedFactories.slice(), provider.multiProvider);
- }
- else {
- resolvedProvider = provider;
- }
- normalizedProvidersMap.set(provider.key.id, resolvedProvider);
- }
- }
- return normalizedProvidersMap;
- }
- /**
- * @param {?} providers
- * @param {?} res
- * @return {?}
- */
- function _normalizeProviders(providers, res) {
- providers.forEach(function (b) {
- if (b instanceof Type) {
- res.push({ provide: b, useClass: b });
- }
- else if (b && typeof b == 'object' && ((b)).provide !== undefined) {
- res.push(/** @type {?} */ (b));
- }
- else if (b instanceof Array) {
- _normalizeProviders(b, res);
- }
- else {
- throw invalidProviderError(b);
- }
- });
- return res;
- }
- /**
- * @param {?} typeOrFunc
- * @param {?=} dependencies
- * @return {?}
- */
- function constructDependencies(typeOrFunc, dependencies) {
- if (!dependencies) {
- return _dependenciesFor(typeOrFunc);
- }
- else {
- var /** @type {?} */ params_1 = dependencies.map(function (t) { return [t]; });
- return dependencies.map(function (t) { return _extractToken(typeOrFunc, t, params_1); });
- }
- }
- /**
- * @param {?} typeOrFunc
- * @return {?}
- */
- function _dependenciesFor(typeOrFunc) {
- var /** @type {?} */ params = reflector.parameters(typeOrFunc);
- if (!params)
- return [];
- if (params.some(function (p) { return p == null; })) {
- throw noAnnotationError(typeOrFunc, params);
- }
- return params.map(function (p) { return _extractToken(typeOrFunc, p, params); });
- }
- /**
- * @param {?} typeOrFunc
- * @param {?} metadata
- * @param {?} params
- * @return {?}
- */
- function _extractToken(typeOrFunc, metadata, params) {
- var /** @type {?} */ token = null;
- var /** @type {?} */ optional = false;
- if (!Array.isArray(metadata)) {
- if (metadata instanceof Inject) {
- return _createDependency(metadata.token, optional, null);
- }
- else {
- return _createDependency(metadata, optional, null);
- }
- }
- var /** @type {?} */ visibility = null;
- for (var /** @type {?} */ i = 0; i < metadata.length; ++i) {
- var /** @type {?} */ paramMetadata = metadata[i];
- if (paramMetadata instanceof Type) {
- token = paramMetadata;
- }
- else if (paramMetadata instanceof Inject) {
- token = paramMetadata.token;
- }
- else if (paramMetadata instanceof Optional) {
- optional = true;
- }
- else if (paramMetadata instanceof Self || paramMetadata instanceof SkipSelf) {
- visibility = paramMetadata;
- }
- else if (paramMetadata instanceof InjectionToken) {
- token = paramMetadata;
- }
- }
- token = resolveForwardRef(token);
- if (token != null) {
- return _createDependency(token, optional, visibility);
- }
- else {
- throw noAnnotationError(typeOrFunc, params);
- }
- }
- /**
- * @param {?} token
- * @param {?} optional
- * @param {?} visibility
- * @return {?}
- */
- function _createDependency(token, optional, visibility) {
- return new ReflectiveDependency(ReflectiveKey.get(token), optional, visibility);
- }
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- // Threshold for the dynamic version
- var UNDEFINED = new Object();
- /**
- * A ReflectiveDependency injection container used for instantiating objects and resolving
- * dependencies.
- *
- * An `Injector` is a replacement for a `new` operator, which can automatically resolve the
- * constructor dependencies.
- *
- * In typical use, application code asks for the dependencies in the constructor and they are
- * resolved by the `Injector`.
- *
- * ### Example ([live demo](http://plnkr.co/edit/jzjec0?p=preview))
- *
- * The following example creates an `Injector` configured to create `Engine` and `Car`.
- *
- * ```typescript
- * \@Injectable()
- * class Engine {
- * }
- *
- * \@Injectable()
- * class Car {
- * constructor(public engine:Engine) {}
- * }
- *
- * var injector = ReflectiveInjector.resolveAndCreate([Car, Engine]);
- * var car = injector.get(Car);
- * expect(car instanceof Car).toBe(true);
- * expect(car.engine instanceof Engine).toBe(true);
- * ```
- *
- * Notice, we don't use the `new` operator because we explicitly want to have the `Injector`
- * resolve all of the object's dependencies automatically.
- *
- * \@stable
- * @abstract
- */
- var ReflectiveInjector = (function () {
- function ReflectiveInjector() {
- }
- /**
- * Turns an array of provider definitions into an array of resolved providers.
- *
- * A resolution is a process of flattening multiple nested arrays and converting individual
- * providers into an array of {\@link ResolvedReflectiveProvider}s.
- *
- * ### Example ([live demo](http://plnkr.co/edit/AiXTHi?p=preview))
- *
- * ```typescript
- * \@Injectable()
- * class Engine {
- * }
- *
- * \@Injectable()
- * class Car {
- * constructor(public engine:Engine) {}
- * }
- *
- * var providers = ReflectiveInjector.resolve([Car, [[Engine]]]);
- *
- * expect(providers.length).toEqual(2);
- *
- * expect(providers[0] instanceof ResolvedReflectiveProvider).toBe(true);
- * expect(providers[0].key.displayName).toBe("Car");
- * expect(providers[0].dependencies.length).toEqual(1);
- * expect(providers[0].factory).toBeDefined();
- *
- * expect(providers[1].key.displayName).toBe("Engine");
- * });
- * ```
- *
- * See {\@link ReflectiveInjector#fromResolvedProviders} for more info.
- * @param {?} providers
- * @return {?}
- */
- ReflectiveInjector.resolve = function (providers) {
- return resolveReflectiveProviders(providers);
- };
- /**
- * Resolves an array of providers and creates an injector from those providers.
- *
- * The passed-in providers can be an array of `Type`, {\@link Provider},
- * or a recursive array of more providers.
- *
- * ### Example ([live demo](http://plnkr.co/edit/ePOccA?p=preview))
- *
- * ```typescript
- * \@Injectable()
- * class Engine {
- * }
- *
- * \@Injectable()
- * class Car {
- * constructor(public engine:Engine) {}
- * }
- *
- * var injector = ReflectiveInjector.resolveAndCreate([Car, Engine]);
- * expect(injector.get(Car) instanceof Car).toBe(true);
- * ```
- *
- * This function is slower than the corresponding `fromResolvedProviders`
- * because it needs to resolve the passed-in providers first.
- * See {\@link ReflectiveInjector#resolve} and {\@link ReflectiveInjector#fromResolvedProviders}.
- * @param {?} providers
- * @param {?=} parent
- * @return {?}
- */
- ReflectiveInjector.resolveAndCreate = function (providers, parent) {
- var /** @type {?} */ ResolvedReflectiveProviders = ReflectiveInjector.resolve(providers);
- return ReflectiveInjector.fromResolvedProviders(ResolvedReflectiveProviders, parent);
- };
- /**
- * Creates an injector from previously resolved providers.
- *
- * This API is the recommended way to construct injectors in performance-sensitive parts.
- *
- * ### Example ([live demo](http://plnkr.co/edit/KrSMci?p=preview))
- *
- * ```typescript
- * \@Injectable()
- * class Engine {
- * }
- *
- * \@Injectable()
- * class Car {
- * constructor(public engine:Engine) {}
- * }
- *
- * var providers = ReflectiveInjector.resolve([Car, Engine]);
- * var injector = ReflectiveInjector.fromResolvedProviders(providers);
- * expect(injector.get(Car) instanceof Car).toBe(true);
- * ```
- * \@experimental
- * @param {?} providers
- * @param {?=} parent
- * @return {?}
- */
- ReflectiveInjector.fromResolvedProviders = function (providers, parent) {
- return new ReflectiveInjector_(providers, parent);
- };
- /**
- * Parent of this injector.
- *
- * <!-- TODO: Add a link to the section of the user guide talking about hierarchical injection.
- * -->
- *
- * ### Example ([live demo](http://plnkr.co/edit/eosMGo?p=preview))
- *
- * ```typescript
- * var parent = ReflectiveInjector.resolveAndCreate([]);
- * var child = parent.resolveAndCreateChild([]);
- * expect(child.parent).toBe(parent);
- * ```
- * @abstract
- * @return {?}
- */
- ReflectiveInjector.prototype.parent = function () { };
- /**
- * Resolves an array of providers and creates a child injector from those providers.
- *
- * <!-- TODO: Add a link to the section of the user guide talking about hierarchical injection.
- * -->
- *
- * The passed-in providers can be an array of `Type`, {\@link Provider},
- * or a recursive array of more providers.
- *
- * ### Example ([live demo](http://plnkr.co/edit/opB3T4?p=preview))
- *
- * ```typescript
- * class ParentProvider {}
- * class ChildProvider {}
- *
- * var parent = ReflectiveInjector.resolveAndCreate([ParentProvider]);
- * var child = parent.resolveAndCreateChild([ChildProvider]);
- *
- * expect(child.get(ParentProvider) instanceof ParentProvider).toBe(true);
- * expect(child.get(ChildProvider) instanceof ChildProvider).toBe(true);
- * expect(child.get(ParentProvider)).toBe(parent.get(ParentProvider));
- * ```
- *
- * This function is slower than the corresponding `createChildFromResolved`
- * because it needs to resolve the passed-in providers first.
- * See {\@link ReflectiveInjector#resolve} and {\@link ReflectiveInjector#createChildFromResolved}.
- * @abstract
- * @param {?} providers
- * @return {?}
- */
- ReflectiveInjector.prototype.resolveAndCreateChild = function (providers) { };
- /**
- * Creates a child injector from previously resolved providers.
- *
- * <!-- TODO: Add a link to the section of the user guide talking about hierarchical injection.
- * -->
- *
- * This API is the recommended way to construct injectors in performance-sensitive parts.
- *
- * ### Example ([live demo](http://plnkr.co/edit/VhyfjN?p=preview))
- *
- * ```typescript
- * class ParentProvider {}
- * class ChildProvider {}
- *
- * var parentProviders = ReflectiveInjector.resolve([ParentProvider]);
- * var childProviders = ReflectiveInjector.resolve([ChildProvider]);
- *
- * var parent = ReflectiveInjector.fromResolvedProviders(parentProviders);
- * var child = parent.createChildFromResolved(childProviders);
- *
- * expect(child.get(ParentProvider) instanceof ParentProvider).toBe(true);
- * expect(child.get(ChildProvider) instanceof ChildProvider).toBe(true);
- * expect(child.get(ParentProvider)).toBe(parent.get(ParentProvider));
- * ```
- * @abstract
- * @param {?} providers
- * @return {?}
- */
- ReflectiveInjector.prototype.createChildFromResolved = function (providers) { };
- /**
- * Resolves a provider and instantiates an object in the context of the injector.
- *
- * The created object does not get cached by the injector.
- *
- * ### Example ([live demo](http://plnkr.co/edit/yvVXoB?p=preview))
- *
- * ```typescript
- * \@Injectable()
- * class Engine {
- * }
- *
- * \@Injectable()
- * class Car {
- * constructor(public engine:Engine) {}
- * }
- *
- * var injector = ReflectiveInjector.resolveAndCreate([Engine]);
- *
- * var car = injector.resolveAndInstantiate(Car);
- * expect(car.engine).toBe(injector.get(Engine));
- * expect(car).not.toBe(injector.resolveAndInstantiate(Car));
- * ```
- * @abstract
- * @param {?} provider
- * @return {?}
- */
- ReflectiveInjector.prototype.resolveAndInstantiate = function (provider) { };
- /**
- * Instantiates an object using a resolved provider in the context of the injector.
- *
- * The created object does not get cached by the injector.
- *
- * ### Example ([live demo](http://plnkr.co/edit/ptCImQ?p=preview))
- *
- * ```typescript
- * \@Injectable()
- * class Engine {
- * }
- *
- * \@Injectable()
- * class Car {
- * constructor(public engine:Engine) {}
- * }
- *
- * var injector = ReflectiveInjector.resolveAndCreate([Engine]);
- * var carProvider = ReflectiveInjector.resolve([Car])[0];
- * var car = injector.instantiateResolved(carProvider);
- * expect(car.engine).toBe(injector.get(Engine));
- * expect(car).not.toBe(injector.instantiateResolved(carProvider));
- * ```
- * @abstract
- * @param {?} provider
- * @return {?}
- */
- ReflectiveInjector.prototype.instantiateResolved = function (provider) { };
- /**
- * @abstract
- * @param {?} token
- * @param {?=} notFoundValue
- * @return {?}
- */
- ReflectiveInjector.prototype.get = function (token, notFoundValue) { };
- return ReflectiveInjector;
- }());
- var ReflectiveInjector_ = (function () {
- /**
- * Private
- * @param {?} _providers
- * @param {?=} _parent
- */
- function ReflectiveInjector_(_providers, _parent) {
- /**
- * \@internal
- */
- this._constructionCounter = 0;
- this._providers = _providers;
- this._parent = _parent || null;
- var len = _providers.length;
- this.keyIds = new Array(len);
- this.objs = new Array(len);
- for (var i = 0; i < len; i++) {
- this.keyIds[i] = _providers[i].key.id;
- this.objs[i] = UNDEFINED;
- }
- }
- /**
- * @param {?} token
- * @param {?=} notFoundValue
- * @return {?}
- */
- ReflectiveInjector_.prototype.get = function (token, notFoundValue) {
- if (notFoundValue === void 0) { notFoundValue = THROW_IF_NOT_FOUND; }
- return this._getByKey(ReflectiveKey.get(token), null, notFoundValue);
- };
- Object.defineProperty(ReflectiveInjector_.prototype, "parent", {
- /**
- * @return {?}
- */
- get: function () { return this._parent; },
- enumerable: true,
- configurable: true
- });
- /**
- * @param {?} providers
- * @return {?}
- */
- ReflectiveInjector_.prototype.resolveAndCreateChild = function (providers) {
- var /** @type {?} */ ResolvedReflectiveProviders = ReflectiveInjector.resolve(providers);
- return this.createChildFromResolved(ResolvedReflectiveProviders);
- };
- /**
- * @param {?} providers
- * @return {?}
- */
- ReflectiveInjector_.prototype.createChildFromResolved = function (providers) {
- var /** @type {?} */ inj = new ReflectiveInjector_(providers);
- inj._parent = this;
- return inj;
- };
- /**
- * @param {?} provider
- * @return {?}
- */
- ReflectiveInjector_.prototype.resolveAndInstantiate = function (provider) {
- return this.instantiateResolved(ReflectiveInjector.resolve([provider])[0]);
- };
- /**
- * @param {?} provider
- * @return {?}
- */
- ReflectiveInjector_.prototype.instantiateResolved = function (provider) {
- return this._instantiateProvider(provider);
- };
- /**
- * @param {?} index
- * @return {?}
- */
- ReflectiveInjector_.prototype.getProviderAtIndex = function (index) {
- if (index < 0 || index >= this._providers.length) {
- throw outOfBoundsError(index);
- }
- return this._providers[index];
- };
- /**
- * \@internal
- * @param {?} provider
- * @return {?}
- */
- ReflectiveInjector_.prototype._new = function (provider) {
- if (this._constructionCounter++ > this._getMaxNumberOfObjects()) {
- throw cyclicDependencyError(this, provider.key);
- }
- return this._instantiateProvider(provider);
- };
- /**
- * @return {?}
- */
- ReflectiveInjector_.prototype._getMaxNumberOfObjects = function () { return this.objs.length; };
- /**
- * @param {?} provider
- * @return {?}
- */
- ReflectiveInjector_.prototype._instantiateProvider = function (provider) {
- if (provider.multiProvider) {
- var /** @type {?} */ res = new Array(provider.resolvedFactories.length);
- for (var /** @type {?} */ i = 0; i < provider.resolvedFactories.length; ++i) {
- res[i] = this._instantiate(provider, provider.resolvedFactories[i]);
- }
- return res;
- }
- else {
- return this._instantiate(provider, provider.resolvedFactories[0]);
- }
- };
- /**
- * @param {?} provider
- * @param {?} ResolvedReflectiveFactory
- * @return {?}
- */
- ReflectiveInjector_.prototype._instantiate = function (provider, ResolvedReflectiveFactory$$1) {
- var _this = this;
- var /** @type {?} */ factory = ResolvedReflectiveFactory$$1.factory;
- var /** @type {?} */ deps;
- try {
- deps =
- ResolvedReflectiveFactory$$1.dependencies.map(function (dep) { return _this._getByReflectiveDependency(dep); });
- }
- catch (e) {
- if (e.addKey) {
- e.addKey(this, provider.key);
- }
- throw e;
- }
- var /** @type {?} */ obj;
- try {
- obj = factory.apply(void 0, deps);
- }
- catch (e) {
- throw instantiationError(this, e, e.stack, provider.key);
- }
- return obj;
- };
- /**
- * @param {?} dep
- * @return {?}
- */
- ReflectiveInjector_.prototype._getByReflectiveDependency = function (dep) {
- return this._getByKey(dep.key, dep.visibility, dep.optional ? null : THROW_IF_NOT_FOUND);
- };
- /**
- * @param {?} key
- * @param {?} visibility
- * @param {?} notFoundValue
- * @return {?}
- */
- ReflectiveInjector_.prototype._getByKey = function (key, visibility, notFoundValue) {
- if (key === INJECTOR_KEY) {
- return this;
- }
- if (visibility instanceof Self) {
- return this._getByKeySelf(key, notFoundValue);
- }
- else {
- return this._getByKeyDefault(key, notFoundValue, visibility);
- }
- };
- /**
- * @param {?} keyId
- * @return {?}
- */
- ReflectiveInjector_.prototype._getObjByKeyId = function (keyId) {
- for (var /** @type {?} */ i = 0; i < this.keyIds.length; i++) {
- if (this.keyIds[i] === keyId) {
- if (this.objs[i] === UNDEFINED) {
- this.objs[i] = this._new(this._providers[i]);
- }
- return this.objs[i];
- }
- }
- return UNDEFINED;
- };
- /**
- * \@internal
- * @param {?} key
- * @param {?} notFoundValue
- * @return {?}
- */
- ReflectiveInjector_.prototype._throwOrNull = function (key, notFoundValue) {
- if (notFoundValue !== THROW_IF_NOT_FOUND) {
- return notFoundValue;
- }
- else {
- throw noProviderError(this, key);
- }
- };
- /**
- * \@internal
- * @param {?} key
- * @param {?} notFoundValue
- * @return {?}
- */
- ReflectiveInjector_.prototype._getByKeySelf = function (key, notFoundValue) {
- var /** @type {?} */ obj = this._getObjByKeyId(key.id);
- return (obj !== UNDEFINED) ? obj : this._throwOrNull(key, notFoundValue);
- };
- /**
- * \@internal
- * @param {?} key
- * @param {?} notFoundValue
- * @param {?} visibility
- * @return {?}
- */
- ReflectiveInjector_.prototype._getByKeyDefault = function (key, notFoundValue, visibility) {
- var /** @type {?} */ inj;
- if (visibility instanceof SkipSelf) {
- inj = this._parent;
- }
- else {
- inj = this;
- }
- while (inj instanceof ReflectiveInjector_) {
- var /** @type {?} */ inj_ = (inj);
- var /** @type {?} */ obj = inj_._getObjByKeyId(key.id);
- if (obj !== UNDEFINED)
- return obj;
- inj = inj_._parent;
- }
- if (inj !== null) {
- return inj.get(key.token, notFoundValue);
- }
- else {
- return this._throwOrNull(key, notFoundValue);
- }
- };
- Object.defineProperty(ReflectiveInjector_.prototype, "displayName", {
- /**
- * @return {?}
- */
- get: function () {
- var /** @type {?} */ providers = _mapProviders(this, function (b) { return ' "' + b.key.displayName + '" '; })
- .join(', ');
- return "ReflectiveInjector(providers: [" + providers + "])";
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @return {?}
- */
- ReflectiveInjector_.prototype.toString = function () { return this.displayName; };
- return ReflectiveInjector_;
- }());
- var INJECTOR_KEY = ReflectiveKey.get(Injector);
- /**
- * @param {?} injector
- * @param {?} fn
- * @return {?}
- */
- function _mapProviders(injector, fn) {
- var /** @type {?} */ res = new Array(injector._providers.length);
- for (var /** @type {?} */ i = 0; i < injector._providers.length; ++i) {
- res[i] = fn(injector.getProviderAtIndex(i));
- }
- return res;
- }
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * @module
- * @description
- * The `di` module provides dependency injection container services.
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * Determine if the argument is shaped like a Promise
- * @param {?} obj
- * @return {?}
- */
- function isPromise(obj) {
- // allow any Promise/A+ compliant thenable.
- // It's up to the caller to ensure that obj.then conforms to the spec
- return !!obj && typeof obj.then === 'function';
- }
- /**
- * Determine if the argument is an Observable
- * @param {?} obj
- * @return {?}
- */
- function isObservable(obj) {
- // TODO use Symbol.observable when https://github.com/ReactiveX/rxjs/issues/2415 will be resolved
- return !!obj && typeof obj.subscribe === 'function';
- }
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * A function that will be executed when an application is initialized.
- * \@experimental
- */
- var APP_INITIALIZER = new InjectionToken('Application Initializer');
- /**
- * A class that reflects the state of running {\@link APP_INITIALIZER}s.
- *
- * \@experimental
- */
- var ApplicationInitStatus = (function () {
- /**
- * @param {?} appInits
- */
- function ApplicationInitStatus(appInits) {
- var _this = this;
- this.appInits = appInits;
- this.initialized = false;
- this._done = false;
- this._donePromise = new Promise(function (res, rej) {
- _this.resolve = res;
- _this.reject = rej;
- });
- }
- /**
- * \@internal
- * @return {?}
- */
- ApplicationInitStatus.prototype.runInitializers = function () {
- var _this = this;
- if (this.initialized) {
- return;
- }
- var /** @type {?} */ asyncInitPromises = [];
- var /** @type {?} */ complete = function () {
- _this._done = true;
- _this.resolve();
- };
- if (this.appInits) {
- for (var /** @type {?} */ i = 0; i < this.appInits.length; i++) {
- var /** @type {?} */ initResult = this.appInits[i]();
- if (isPromise(initResult)) {
- asyncInitPromises.push(initResult);
- }
- }
- }
- Promise.all(asyncInitPromises).then(function () { complete(); }).catch(function (e) { _this.reject(e); });
- if (asyncInitPromises.length === 0) {
- complete();
- }
- this.initialized = true;
- };
- Object.defineProperty(ApplicationInitStatus.prototype, "done", {
- /**
- * @return {?}
- */
- get: function () { return this._done; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(ApplicationInitStatus.prototype, "donePromise", {
- /**
- * @return {?}
- */
- get: function () { return this._donePromise; },
- enumerable: true,
- configurable: true
- });
- return ApplicationInitStatus;
- }());
- ApplicationInitStatus.decorators = [
- { type: Injectable },
- ];
- /**
- * @nocollapse
- */
- ApplicationInitStatus.ctorParameters = function () { return [
- { type: Array, decorators: [{ type: Inject, args: [APP_INITIALIZER,] }, { type: Optional },] },
- ]; };
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * A DI Token representing a unique string id assigned to the application by Angular and used
- * primarily for prefixing application attributes and CSS styles when
- * {\@link ViewEncapsulation#Emulated} is being used.
- *
- * If you need to avoid randomly generated value to be used as an application id, you can provide
- * a custom value via a DI provider <!-- TODO: provider --> configuring the root {\@link Injector}
- * using this token.
- * \@experimental
- */
- var APP_ID = new InjectionToken('AppId');
- /**
- * @return {?}
- */
- function _appIdRandomProviderFactory() {
- return "" + _randomChar() + _randomChar() + _randomChar();
- }
- /**
- * Providers that will generate a random APP_ID_TOKEN.
- * \@experimental
- */
- var APP_ID_RANDOM_PROVIDER = {
- provide: APP_ID,
- useFactory: _appIdRandomProviderFactory,
- deps: [],
- };
- /**
- * @return {?}
- */
- function _randomChar() {
- return String.fromCharCode(97 + Math.floor(Math.random() * 25));
- }
- /**
- * A function that will be executed when a platform is initialized.
- * \@experimental
- */
- var PLATFORM_INITIALIZER = new InjectionToken('Platform Initializer');
- /**
- * A token that indicates an opaque platform id.
- * \@experimental
- */
- var PLATFORM_ID = new InjectionToken('Platform ID');
- /**
- * All callbacks provided via this token will be called for every component that is bootstrapped.
- * Signature of the callback:
- *
- * `(componentRef: ComponentRef) => void`.
- *
- * \@experimental
- */
- var APP_BOOTSTRAP_LISTENER = new InjectionToken('appBootstrapListener');
- /**
- * A token which indicates the root directory of the application
- * \@experimental
- */
- var PACKAGE_ROOT_URL = new InjectionToken('Application Packages Root URL');
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var Console = (function () {
- function Console() {
- }
- /**
- * @param {?} message
- * @return {?}
- */
- Console.prototype.log = function (message) {
- // tslint:disable-next-line:no-console
- console.log(message);
- };
- /**
- * @param {?} message
- * @return {?}
- */
- Console.prototype.warn = function (message) {
- // tslint:disable-next-line:no-console
- console.warn(message);
- };
- return Console;
- }());
- Console.decorators = [
- { type: Injectable },
- ];
- /**
- * @nocollapse
- */
- Console.ctorParameters = function () { return []; };
- /**
- * @return {?}
- */
- function _throwError() {
- throw new Error("Runtime compiler is not loaded");
- }
- /**
- * Low-level service for running the angular compiler during runtime
- * to create {\@link ComponentFactory}s, which
- * can later be used to create and render a Component instance.
- *
- * Each `\@NgModule` provides an own `Compiler` to its injector,
- * that will use the directives/pipes of the ng module for compilation
- * of components.
- * \@stable
- */
- var Compiler = (function () {
- function Compiler() {
- }
- /**
- * Compiles the given NgModule and all of its components. All templates of the components listed
- * in `entryComponents` have to be inlined.
- * @template T
- * @param {?} moduleType
- * @return {?}
- */
- Compiler.prototype.compileModuleSync = function (moduleType) { throw _throwError(); };
- /**
- * Compiles the given NgModule and all of its components
- * @template T
- * @param {?} moduleType
- * @return {?}
- */
- Compiler.prototype.compileModuleAsync = function (moduleType) { throw _throwError(); };
- /**
- * Same as {\@link #compileModuleSync} but also creates ComponentFactories for all components.
- * @template T
- * @param {?} moduleType
- * @return {?}
- */
- Compiler.prototype.compileModuleAndAllComponentsSync = function (moduleType) {
- throw _throwError();
- };
- /**
- * Same as {\@link #compileModuleAsync} but also creates ComponentFactories for all components.
- * @template T
- * @param {?} moduleType
- * @return {?}
- */
- Compiler.prototype.compileModuleAndAllComponentsAsync = function (moduleType) {
- throw _throwError();
- };
- /**
- * Exposes the CSS-style selectors that have been used in `ngContent` directives within
- * the template of the given component.
- * This is used by the `upgrade` library to compile the appropriate transclude content
- * in the AngularJS wrapper component.
- *
- * @deprecated since v4. Use ComponentFactory.ngContentSelectors instead.
- * @param {?} component
- * @return {?}
- */
- Compiler.prototype.getNgContentSelectors = function (component) { throw _throwError(); };
- /**
- * Clears all caches.
- * @return {?}
- */
- Compiler.prototype.clearCache = function () { };
- /**
- * Clears the cache for the given component/ngModule.
- * @param {?} type
- * @return {?}
- */
- Compiler.prototype.clearCacheFor = function (type) { };
- return Compiler;
- }());
- Compiler.decorators = [
- { type: Injectable },
- ];
- /**
- * @nocollapse
- */
- Compiler.ctorParameters = function () { return []; };
- /**
- * Token to provide CompilerOptions in the platform injector.
- *
- * \@experimental
- */
- var COMPILER_OPTIONS = new InjectionToken('compilerOptions');
- /**
- * A factory for creating a Compiler
- *
- * \@experimental
- * @abstract
- */
- var CompilerFactory = (function () {
- function CompilerFactory() {
- }
- /**
- * @abstract
- * @param {?=} options
- * @return {?}
- */
- CompilerFactory.prototype.createCompiler = function (options) { };
- return CompilerFactory;
- }());
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * Represents an instance of a Component created via a {\@link ComponentFactory}.
- *
- * `ComponentRef` provides access to the Component Instance as well other objects related to this
- * Component Instance and allows you to destroy the Component Instance via the {\@link #destroy}
- * method.
- * \@stable
- * @abstract
- */
- var ComponentRef = (function () {
- function ComponentRef() {
- }
- /**
- * Location of the Host Element of this Component Instance.
- * @abstract
- * @return {?}
- */
- ComponentRef.prototype.location = function () { };
- /**
- * The injector on which the component instance exists.
- * @abstract
- * @return {?}
- */
- ComponentRef.prototype.injector = function () { };
- /**
- * The instance of the Component.
- * @abstract
- * @return {?}
- */
- ComponentRef.prototype.instance = function () { };
- /**
- * The {\@link ViewRef} of the Host View of this Component instance.
- * @abstract
- * @return {?}
- */
- ComponentRef.prototype.hostView = function () { };
- /**
- * The {\@link ChangeDetectorRef} of the Component instance.
- * @abstract
- * @return {?}
- */
- ComponentRef.prototype.changeDetectorRef = function () { };
- /**
- * The component type.
- * @abstract
- * @return {?}
- */
- ComponentRef.prototype.componentType = function () { };
- /**
- * Destroys the component instance and all of the data structures associated with it.
- * @abstract
- * @return {?}
- */
- ComponentRef.prototype.destroy = function () { };
- /**
- * Allows to register a callback that will be called when the component is destroyed.
- * @abstract
- * @param {?} callback
- * @return {?}
- */
- ComponentRef.prototype.onDestroy = function (callback) { };
- return ComponentRef;
- }());
- /**
- * \@stable
- * @abstract
- */
- var ComponentFactory = (function () {
- function ComponentFactory() {
- }
- /**
- * @abstract
- * @return {?}
- */
- ComponentFactory.prototype.selector = function () { };
- /**
- * @abstract
- * @return {?}
- */
- ComponentFactory.prototype.componentType = function () { };
- /**
- * selector for all <ng-content> elements in the component.
- * @abstract
- * @return {?}
- */
- ComponentFactory.prototype.ngContentSelectors = function () { };
- /**
- * the inputs of the component.
- * @abstract
- * @return {?}
- */
- ComponentFactory.prototype.inputs = function () { };
- /**
- * the outputs of the component.
- * @abstract
- * @return {?}
- */
- ComponentFactory.prototype.outputs = function () { };
- /**
- * Creates a new component.
- * @abstract
- * @param {?} injector
- * @param {?=} projectableNodes
- * @param {?=} rootSelectorOrNode
- * @param {?=} ngModule
- * @return {?}
- */
- ComponentFactory.prototype.create = function (injector, projectableNodes, rootSelectorOrNode, ngModule) { };
- return ComponentFactory;
- }());
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * @param {?} component
- * @return {?}
- */
- function noComponentFactoryError(component) {
- var /** @type {?} */ error = Error("No component factory found for " + stringify(component) + ". Did you add it to @NgModule.entryComponents?");
- ((error))[ERROR_COMPONENT] = component;
- return error;
- }
- var ERROR_COMPONENT = 'ngComponent';
- /**
- * @param {?} error
- * @return {?}
- */
- var _NullComponentFactoryResolver = (function () {
- function _NullComponentFactoryResolver() {
- }
- /**
- * @template T
- * @param {?} component
- * @return {?}
- */
- _NullComponentFactoryResolver.prototype.resolveComponentFactory = function (component) {
- throw noComponentFactoryError(component);
- };
- return _NullComponentFactoryResolver;
- }());
- /**
- * \@stable
- * @abstract
- */
- var ComponentFactoryResolver = (function () {
- function ComponentFactoryResolver() {
- }
- /**
- * @abstract
- * @template T
- * @param {?} component
- * @return {?}
- */
- ComponentFactoryResolver.prototype.resolveComponentFactory = function (component) { };
- return ComponentFactoryResolver;
- }());
- ComponentFactoryResolver.NULL = new _NullComponentFactoryResolver();
- var ComponentFactoryBoundToModule = (function (_super) {
- __extends$1(ComponentFactoryBoundToModule, _super);
- /**
- * @param {?} factory
- * @param {?} ngModule
- */
- function ComponentFactoryBoundToModule(factory, ngModule) {
- var _this = _super.call(this) || this;
- _this.factory = factory;
- _this.ngModule = ngModule;
- return _this;
- }
- Object.defineProperty(ComponentFactoryBoundToModule.prototype, "selector", {
- /**
- * @return {?}
- */
- get: function () { return this.factory.selector; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(ComponentFactoryBoundToModule.prototype, "componentType", {
- /**
- * @return {?}
- */
- get: function () { return this.factory.componentType; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(ComponentFactoryBoundToModule.prototype, "ngContentSelectors", {
- /**
- * @return {?}
- */
- get: function () { return this.factory.ngContentSelectors; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(ComponentFactoryBoundToModule.prototype, "inputs", {
- /**
- * @return {?}
- */
- get: function () { return this.factory.inputs; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(ComponentFactoryBoundToModule.prototype, "outputs", {
- /**
- * @return {?}
- */
- get: function () { return this.factory.outputs; },
- enumerable: true,
- configurable: true
- });
- /**
- * @param {?} injector
- * @param {?=} projectableNodes
- * @param {?=} rootSelectorOrNode
- * @param {?=} ngModule
- * @return {?}
- */
- ComponentFactoryBoundToModule.prototype.create = function (injector, projectableNodes, rootSelectorOrNode, ngModule) {
- return this.factory.create(injector, projectableNodes, rootSelectorOrNode, ngModule || this.ngModule);
- };
- return ComponentFactoryBoundToModule;
- }(ComponentFactory));
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * Represents an instance of an NgModule created via a {\@link NgModuleFactory}.
- *
- * `NgModuleRef` provides access to the NgModule Instance as well other objects related to this
- * NgModule Instance.
- *
- * \@stable
- * @abstract
- */
- var NgModuleRef = (function () {
- function NgModuleRef() {
- }
- /**
- * The injector that contains all of the providers of the NgModule.
- * @abstract
- * @return {?}
- */
- NgModuleRef.prototype.injector = function () { };
- /**
- * The ComponentFactoryResolver to get hold of the ComponentFactories
- * declared in the `entryComponents` property of the module.
- * @abstract
- * @return {?}
- */
- NgModuleRef.prototype.componentFactoryResolver = function () { };
- /**
- * The NgModule instance.
- * @abstract
- * @return {?}
- */
- NgModuleRef.prototype.instance = function () { };
- /**
- * Destroys the module instance and all of the data structures associated with it.
- * @abstract
- * @return {?}
- */
- NgModuleRef.prototype.destroy = function () { };
- /**
- * Allows to register a callback that will be called when the module is destroyed.
- * @abstract
- * @param {?} callback
- * @return {?}
- */
- NgModuleRef.prototype.onDestroy = function (callback) { };
- return NgModuleRef;
- }());
- /**
- * \@experimental
- * @abstract
- */
- var NgModuleFactory = (function () {
- function NgModuleFactory() {
- }
- /**
- * @abstract
- * @return {?}
- */
- NgModuleFactory.prototype.moduleType = function () { };
- /**
- * @abstract
- * @param {?} parentInjector
- * @return {?}
- */
- NgModuleFactory.prototype.create = function (parentInjector) { };
- return NgModuleFactory;
- }());
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var trace;
- var events;
- /**
- * @return {?}
- */
- function detectWTF() {
- var /** @type {?} */ wtf = ((_global) /** TODO #9100 */)['wtf'];
- if (wtf) {
- trace = wtf['trace'];
- if (trace) {
- events = trace['events'];
- return true;
- }
- }
- return false;
- }
- /**
- * @param {?} signature
- * @param {?=} flags
- * @return {?}
- */
- function createScope$1(signature, flags) {
- if (flags === void 0) { flags = null; }
- return events.createScope(signature, flags);
- }
- /**
- * @template T
- * @param {?} scope
- * @param {?=} returnValue
- * @return {?}
- */
- function leave(scope, returnValue) {
- trace.leaveScope(scope, returnValue);
- return returnValue;
- }
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * True if WTF is enabled.
- */
- var wtfEnabled = detectWTF();
- /**
- * @param {?=} arg0
- * @param {?=} arg1
- * @return {?}
- */
- function noopScope(arg0, arg1) {
- return null;
- }
- /**
- * Create trace scope.
- *
- * Scopes must be strictly nested and are analogous to stack frames, but
- * do not have to follow the stack frames. Instead it is recommended that they follow logical
- * nesting. You may want to use
- * [Event
- * Signatures](http://google.github.io/tracing-framework/instrumenting-code.html#custom-events)
- * as they are defined in WTF.
- *
- * Used to mark scope entry. The return value is used to leave the scope.
- *
- * var myScope = wtfCreateScope('MyClass#myMethod(ascii someVal)');
- *
- * someMethod() {
- * var s = myScope('Foo'); // 'Foo' gets stored in tracing UI
- * // DO SOME WORK HERE
- * return wtfLeave(s, 123); // Return value 123
- * }
- *
- * Note, adding try-finally block around the work to ensure that `wtfLeave` gets called can
- * negatively impact the performance of your application. For this reason we recommend that
- * you don't add them to ensure that `wtfLeave` gets called. In production `wtfLeave` is a noop and
- * so try-finally block has no value. When debugging perf issues, skipping `wtfLeave`, do to
- * exception, will produce incorrect trace, but presence of exception signifies logic error which
- * needs to be fixed before the app should be profiled. Add try-finally only when you expect that
- * an exception is expected during normal execution while profiling.
- *
- * \@experimental
- */
- var wtfCreateScope = wtfEnabled ? createScope$1 : function (signature, flags) { return noopScope; };
- /**
- * Used to mark end of Scope.
- *
- * - `scope` to end.
- * - `returnValue` (optional) to be passed to the WTF.
- *
- * Returns the `returnValue for easy chaining.
- * \@experimental
- */
- var wtfLeave = wtfEnabled ? leave : function (s, r) { return r; };
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * Use by directives and components to emit custom Events.
- *
- * ### Examples
- *
- * In the following example, `Zippy` alternatively emits `open` and `close` events when its
- * title gets clicked:
- *
- * ```
- * \@Component({
- * selector: 'zippy',
- * template: `
- * <div class="zippy">
- * <div (click)="toggle()">Toggle</div>
- * <div [hidden]="!visible">
- * <ng-content></ng-content>
- * </div>
- * </div>`})
- * export class Zippy {
- * visible: boolean = true;
- * \@Output() open: EventEmitter<any> = new EventEmitter();
- * \@Output() close: EventEmitter<any> = new EventEmitter();
- *
- * toggle() {
- * this.visible = !this.visible;
- * if (this.visible) {
- * this.open.emit(null);
- * } else {
- * this.close.emit(null);
- * }
- * }
- * }
- * ```
- *
- * The events payload can be accessed by the parameter `$event` on the components output event
- * handler:
- *
- * ```
- * <zippy (open)="onOpen($event)" (close)="onClose($event)"></zippy>
- * ```
- *
- * Uses Rx.Observable but provides an adapter to make it work as specified here:
- * https://github.com/jhusain/observable-spec
- *
- * Once a reference implementation of the spec is available, switch to it.
- * \@stable
- */
- var EventEmitter = (function (_super) {
- __extends$1(EventEmitter, _super);
- /**
- * Creates an instance of {\@link EventEmitter}, which depending on `isAsync`,
- * delivers events synchronously or asynchronously.
- *
- * @param {?=} isAsync By default, events are delivered synchronously (default value: `false`).
- * Set to `true` for asynchronous event delivery.
- */
- function EventEmitter(isAsync) {
- if (isAsync === void 0) { isAsync = false; }
- var _this = _super.call(this) || this;
- _this.__isAsync = isAsync;
- return _this;
- }
- /**
- * @param {?=} value
- * @return {?}
- */
- EventEmitter.prototype.emit = function (value) { _super.prototype.next.call(this, value); };
- /**
- * @param {?=} generatorOrNext
- * @param {?=} error
- * @param {?=} complete
- * @return {?}
- */
- EventEmitter.prototype.subscribe = function (generatorOrNext, error, complete) {
- var /** @type {?} */ schedulerFn;
- var /** @type {?} */ errorFn = function (err) { return null; };
- var /** @type {?} */ completeFn = function () { return null; };
- if (generatorOrNext && typeof generatorOrNext === 'object') {
- schedulerFn = this.__isAsync ? function (value) {
- setTimeout(function () { return generatorOrNext.next(value); });
- } : function (value) { generatorOrNext.next(value); };
- if (generatorOrNext.error) {
- errorFn = this.__isAsync ? function (err) { setTimeout(function () { return generatorOrNext.error(err); }); } :
- function (err) { generatorOrNext.error(err); };
- }
- if (generatorOrNext.complete) {
- completeFn = this.__isAsync ? function () { setTimeout(function () { return generatorOrNext.complete(); }); } :
- function () { generatorOrNext.complete(); };
- }
- }
- else {
- schedulerFn = this.__isAsync ? function (value) { setTimeout(function () { return generatorOrNext(value); }); } :
- function (value) { generatorOrNext(value); };
- if (error) {
- errorFn =
- this.__isAsync ? function (err) { setTimeout(function () { return error(err); }); } : function (err) { error(err); };
- }
- if (complete) {
- completeFn =
- this.__isAsync ? function () { setTimeout(function () { return complete(); }); } : function () { complete(); };
- }
- }
- return _super.prototype.subscribe.call(this, schedulerFn, errorFn, completeFn);
- };
- return EventEmitter;
- }(Subject_2));
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * An injectable service for executing work inside or outside of the Angular zone.
- *
- * The most common use of this service is to optimize performance when starting a work consisting of
- * one or more asynchronous tasks that don't require UI updates or error handling to be handled by
- * Angular. Such tasks can be kicked off via {\@link #runOutsideAngular} and if needed, these tasks
- * can reenter the Angular zone via {\@link #run}.
- *
- * <!-- TODO: add/fix links to:
- * - docs explaining zones and the use of zones in Angular and change-detection
- * - link to runOutsideAngular/run (throughout this file!)
- * -->
- *
- * ### Example
- *
- * ```
- * import {Component, NgZone} from '\@angular/core';
- * import {NgIf} from '\@angular/common';
- *
- * \@Component({
- * selector: 'ng-zone-demo'.
- * template: `
- * <h2>Demo: NgZone</h2>
- *
- * <p>Progress: {{progress}}%</p>
- * <p *ngIf="progress >= 100">Done processing {{label}} of Angular zone!</p>
- *
- * <button (click)="processWithinAngularZone()">Process within Angular zone</button>
- * <button (click)="processOutsideOfAngularZone()">Process outside of Angular zone</button>
- * `,
- * })
- * export class NgZoneDemo {
- * progress: number = 0;
- * label: string;
- *
- * constructor(private _ngZone: NgZone) {}
- *
- * // Loop inside the Angular zone
- * // so the UI DOES refresh after each setTimeout cycle
- * processWithinAngularZone() {
- * this.label = 'inside';
- * this.progress = 0;
- * this._increaseProgress(() => console.log('Inside Done!'));
- * }
- *
- * // Loop outside of the Angular zone
- * // so the UI DOES NOT refresh after each setTimeout cycle
- * processOutsideOfAngularZone() {
- * this.label = 'outside';
- * this.progress = 0;
- * this._ngZone.runOutsideAngular(() => {
- * this._increaseProgress(() => {
- * // reenter the Angular zone and display done
- * this._ngZone.run(() => {console.log('Outside Done!') });
- * }}));
- * }
- *
- * _increaseProgress(doneCallback: () => void) {
- * this.progress += 1;
- * console.log(`Current progress: ${this.progress}%`);
- *
- * if (this.progress < 100) {
- * window.setTimeout(() => this._increaseProgress(doneCallback)), 10)
- * } else {
- * doneCallback();
- * }
- * }
- * }
- * ```
- *
- * \@experimental
- */
- var NgZone = (function () {
- /**
- * @param {?} __0
- */
- function NgZone(_a) {
- var _b = _a.enableLongStackTrace, enableLongStackTrace = _b === void 0 ? false : _b;
- this.hasPendingMicrotasks = false;
- this.hasPendingMacrotasks = false;
- /**
- * Whether there are no outstanding microtasks or macrotasks.
- */
- this.isStable = true;
- /**
- * Notifies when code enters Angular Zone. This gets fired first on VM Turn.
- */
- this.onUnstable = new EventEmitter(false);
- /**
- * Notifies when there is no more microtasks enqueue in the current VM Turn.
- * This is a hint for Angular to do change detection, which may enqueue more microtasks.
- * For this reason this event can fire multiple times per VM Turn.
- */
- this.onMicrotaskEmpty = new EventEmitter(false);
- /**
- * Notifies when the last `onMicrotaskEmpty` has run and there are no more microtasks, which
- * implies we are about to relinquish VM turn.
- * This event gets called just once.
- */
- this.onStable = new EventEmitter(false);
- /**
- * Notifies that an error has been delivered.
- */
- this.onError = new EventEmitter(false);
- if (typeof Zone == 'undefined') {
- throw new Error('Angular requires Zone.js prolyfill.');
- }
- Zone.assertZonePatched();
- var self = this;
- self._nesting = 0;
- self._outer = self._inner = Zone.current;
- if (Zone['wtfZoneSpec']) {
- self._inner = self._inner.fork(Zone['wtfZoneSpec']);
- }
- if (enableLongStackTrace && Zone['longStackTraceZoneSpec']) {
- self._inner = self._inner.fork(Zone['longStackTraceZoneSpec']);
- }
- forkInnerZoneWithAngularBehavior(self);
- }
- /**
- * @return {?}
- */
- NgZone.isInAngularZone = function () { return Zone.current.get('isAngularZone') === true; };
- /**
- * @return {?}
- */
- NgZone.assertInAngularZone = function () {
- if (!NgZone.isInAngularZone()) {
- throw new Error('Expected to be in Angular Zone, but it is not!');
- }
- };
- /**
- * @return {?}
- */
- NgZone.assertNotInAngularZone = function () {
- if (NgZone.isInAngularZone()) {
- throw new Error('Expected to not be in Angular Zone, but it is!');
- }
- };
- /**
- * Executes the `fn` function synchronously within the Angular zone and returns value returned by
- * the function.
- *
- * Running functions via `run` allows you to reenter Angular zone from a task that was executed
- * outside of the Angular zone (typically started via {\@link #runOutsideAngular}).
- *
- * Any future tasks or microtasks scheduled from within this function will continue executing from
- * within the Angular zone.
- *
- * If a synchronous error happens it will be rethrown and not reported via `onError`.
- * @param {?} fn
- * @return {?}
- */
- NgZone.prototype.run = function (fn) { return (((this)))._inner.run(fn); };
- /**
- * Same as `run`, except that synchronous errors are caught and forwarded via `onError` and not
- * rethrown.
- * @param {?} fn
- * @return {?}
- */
- NgZone.prototype.runGuarded = function (fn) { return (((this)))._inner.runGuarded(fn); };
- /**
- * Executes the `fn` function synchronously in Angular's parent zone and returns value returned by
- * the function.
- *
- * Running functions via {\@link #runOutsideAngular} allows you to escape Angular's zone and do
- * work that
- * doesn't trigger Angular change-detection or is subject to Angular's error handling.
- *
- * Any future tasks or microtasks scheduled from within this function will continue executing from
- * outside of the Angular zone.
- *
- * Use {\@link #run} to reenter the Angular zone and do work that updates the application model.
- * @param {?} fn
- * @return {?}
- */
- NgZone.prototype.runOutsideAngular = function (fn) { return (((this)))._outer.run(fn); };
- return NgZone;
- }());
- /**
- * @param {?} zone
- * @return {?}
- */
- function checkStable(zone) {
- if (zone._nesting == 0 && !zone.hasPendingMicrotasks && !zone.isStable) {
- try {
- zone._nesting++;
- zone.onMicrotaskEmpty.emit(null);
- }
- finally {
- zone._nesting--;
- if (!zone.hasPendingMicrotasks) {
- try {
- zone.runOutsideAngular(function () { return zone.onStable.emit(null); });
- }
- finally {
- zone.isStable = true;
- }
- }
- }
- }
- }
- /**
- * @param {?} zone
- * @return {?}
- */
- function forkInnerZoneWithAngularBehavior(zone) {
- zone._inner = zone._inner.fork({
- name: 'angular',
- properties: /** @type {?} */ ({ 'isAngularZone': true }),
- onInvokeTask: function (delegate, current, target, task, applyThis, applyArgs) {
- try {
- onEnter(zone);
- return delegate.invokeTask(target, task, applyThis, applyArgs);
- }
- finally {
- onLeave(zone);
- }
- },
- onInvoke: function (delegate, current, target, callback, applyThis, applyArgs, source) {
- try {
- onEnter(zone);
- return delegate.invoke(target, callback, applyThis, applyArgs, source);
- }
- finally {
- onLeave(zone);
- }
- },
- onHasTask: function (delegate, current, target, hasTaskState) {
- delegate.hasTask(target, hasTaskState);
- if (current === target) {
- // We are only interested in hasTask events which originate from our zone
- // (A child hasTask event is not interesting to us)
- if (hasTaskState.change == 'microTask') {
- zone.hasPendingMicrotasks = hasTaskState.microTask;
- checkStable(zone);
- }
- else if (hasTaskState.change == 'macroTask') {
- zone.hasPendingMacrotasks = hasTaskState.macroTask;
- }
- }
- },
- onHandleError: function (delegate, current, target, error) {
- delegate.handleError(target, error);
- zone.runOutsideAngular(function () { return zone.onError.emit(error); });
- return false;
- }
- });
- }
- /**
- * @param {?} zone
- * @return {?}
- */
- function onEnter(zone) {
- zone._nesting++;
- if (zone.isStable) {
- zone.isStable = false;
- zone.onUnstable.emit(null);
- }
- }
- /**
- * @param {?} zone
- * @return {?}
- */
- function onLeave(zone) {
- zone._nesting--;
- checkStable(zone);
- }
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * The Testability service provides testing hooks that can be accessed from
- * the browser and by services such as Protractor. Each bootstrapped Angular
- * application on the page will have an instance of Testability.
- * \@experimental
- */
- var Testability = (function () {
- /**
- * @param {?} _ngZone
- */
- function Testability(_ngZone) {
- this._ngZone = _ngZone;
- /**
- * \@internal
- */
- this._pendingCount = 0;
- /**
- * \@internal
- */
- this._isZoneStable = true;
- /**
- * Whether any work was done since the last 'whenStable' callback. This is
- * useful to detect if this could have potentially destabilized another
- * component while it is stabilizing.
- * \@internal
- */
- this._didWork = false;
- /**
- * \@internal
- */
- this._callbacks = [];
- this._watchAngularEvents();
- }
- /**
- * \@internal
- * @return {?}
- */
- Testability.prototype._watchAngularEvents = function () {
- var _this = this;
- this._ngZone.onUnstable.subscribe({
- next: function () {
- _this._didWork = true;
- _this._isZoneStable = false;
- }
- });
- this._ngZone.runOutsideAngular(function () {
- _this._ngZone.onStable.subscribe({
- next: function () {
- NgZone.assertNotInAngularZone();
- scheduleMicroTask(function () {
- _this._isZoneStable = true;
- _this._runCallbacksIfReady();
- });
- }
- });
- });
- };
- /**
- * @return {?}
- */
- Testability.prototype.increasePendingRequestCount = function () {
- this._pendingCount += 1;
- this._didWork = true;
- return this._pendingCount;
- };
- /**
- * @return {?}
- */
- Testability.prototype.decreasePendingRequestCount = function () {
- this._pendingCount -= 1;
- if (this._pendingCount < 0) {
- throw new Error('pending async requests below zero');
- }
- this._runCallbacksIfReady();
- return this._pendingCount;
- };
- /**
- * @return {?}
- */
- Testability.prototype.isStable = function () {
- return this._isZoneStable && this._pendingCount == 0 && !this._ngZone.hasPendingMacrotasks;
- };
- /**
- * \@internal
- * @return {?}
- */
- Testability.prototype._runCallbacksIfReady = function () {
- var _this = this;
- if (this.isStable()) {
- // Schedules the call backs in a new frame so that it is always async.
- scheduleMicroTask(function () {
- while (_this._callbacks.length !== 0) {
- (((_this._callbacks.pop())))(_this._didWork);
- }
- _this._didWork = false;
- });
- }
- else {
- // Not Ready
- this._didWork = true;
- }
- };
- /**
- * @param {?} callback
- * @return {?}
- */
- Testability.prototype.whenStable = function (callback) {
- this._callbacks.push(callback);
- this._runCallbacksIfReady();
- };
- /**
- * @return {?}
- */
- Testability.prototype.getPendingRequestCount = function () { return this._pendingCount; };
- /**
- * @deprecated use findProviders
- * @param {?} using
- * @param {?} provider
- * @param {?} exactMatch
- * @return {?}
- */
- Testability.prototype.findBindings = function (using, provider, exactMatch) {
- // TODO(juliemr): implement.
- return [];
- };
- /**
- * @param {?} using
- * @param {?} provider
- * @param {?} exactMatch
- * @return {?}
- */
- Testability.prototype.findProviders = function (using, provider, exactMatch) {
- // TODO(juliemr): implement.
- return [];
- };
- return Testability;
- }());
- Testability.decorators = [
- { type: Injectable },
- ];
- /**
- * @nocollapse
- */
- Testability.ctorParameters = function () { return [
- { type: NgZone, },
- ]; };
- /**
- * A global registry of {\@link Testability} instances for specific elements.
- * \@experimental
- */
- var TestabilityRegistry = (function () {
- function TestabilityRegistry() {
- /**
- * \@internal
- */
- this._applications = new Map();
- _testabilityGetter.addToWindow(this);
- }
- /**
- * @param {?} token
- * @param {?} testability
- * @return {?}
- */
- TestabilityRegistry.prototype.registerApplication = function (token, testability) {
- this._applications.set(token, testability);
- };
- /**
- * @param {?} elem
- * @return {?}
- */
- TestabilityRegistry.prototype.getTestability = function (elem) { return this._applications.get(elem) || null; };
- /**
- * @return {?}
- */
- TestabilityRegistry.prototype.getAllTestabilities = function () { return Array.from(this._applications.values()); };
- /**
- * @return {?}
- */
- TestabilityRegistry.prototype.getAllRootElements = function () { return Array.from(this._applications.keys()); };
- /**
- * @param {?} elem
- * @param {?=} findInAncestors
- * @return {?}
- */
- TestabilityRegistry.prototype.findTestabilityInTree = function (elem, findInAncestors) {
- if (findInAncestors === void 0) { findInAncestors = true; }
- return _testabilityGetter.findTestabilityInTree(this, elem, findInAncestors);
- };
- return TestabilityRegistry;
- }());
- TestabilityRegistry.decorators = [
- { type: Injectable },
- ];
- /**
- * @nocollapse
- */
- TestabilityRegistry.ctorParameters = function () { return []; };
- var _NoopGetTestability = (function () {
- function _NoopGetTestability() {
- }
- /**
- * @param {?} registry
- * @return {?}
- */
- _NoopGetTestability.prototype.addToWindow = function (registry) { };
- /**
- * @param {?} registry
- * @param {?} elem
- * @param {?} findInAncestors
- * @return {?}
- */
- _NoopGetTestability.prototype.findTestabilityInTree = function (registry, elem, findInAncestors) {
- return null;
- };
- return _NoopGetTestability;
- }());
- /**
- * Set the {\@link GetTestability} implementation used by the Angular testing framework.
- * \@experimental
- * @param {?} getter
- * @return {?}
- */
- function setTestabilityGetter(getter) {
- _testabilityGetter = getter;
- }
- var _testabilityGetter = new _NoopGetTestability();
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var _devMode = true;
- var _runModeLocked = false;
- var _platform;
- var ALLOW_MULTIPLE_PLATFORMS = new InjectionToken('AllowMultipleToken');
- /**
- * Returns whether Angular is in development mode. After called once,
- * the value is locked and won't change any more.
- *
- * By default, this is true, unless a user calls `enableProdMode` before calling this.
- *
- * \@experimental APIs related to application bootstrap are currently under review.
- * @return {?}
- */
- function isDevMode() {
- _runModeLocked = true;
- return _devMode;
- }
- /**
- * A token for third-party components that can register themselves with NgProbe.
- *
- * \@experimental
- */
- var NgProbeToken = (function () {
- /**
- * @param {?} name
- * @param {?} token
- */
- function NgProbeToken(name, token) {
- this.name = name;
- this.token = token;
- }
- return NgProbeToken;
- }());
- /**
- * Creates a platform.
- * Platforms have to be eagerly created via this function.
- *
- * \@experimental APIs related to application bootstrap are currently under review.
- * @param {?} injector
- * @return {?}
- */
- function createPlatform(injector) {
- if (_platform && !_platform.destroyed &&
- !_platform.injector.get(ALLOW_MULTIPLE_PLATFORMS, false)) {
- throw new Error('There can be only one platform. Destroy the previous one to create a new one.');
- }
- _platform = injector.get(PlatformRef);
- var /** @type {?} */ inits = injector.get(PLATFORM_INITIALIZER, null);
- if (inits)
- inits.forEach(function (init) { return init(); });
- return _platform;
- }
- /**
- * Creates a factory for a platform
- *
- * \@experimental APIs related to application bootstrap are currently under review.
- * @param {?} parentPlatformFactory
- * @param {?} name
- * @param {?=} providers
- * @return {?}
- */
- function createPlatformFactory(parentPlatformFactory, name, providers) {
- if (providers === void 0) { providers = []; }
- var /** @type {?} */ marker = new InjectionToken("Platform: " + name);
- return function (extraProviders) {
- if (extraProviders === void 0) { extraProviders = []; }
- var /** @type {?} */ platform = getPlatform();
- if (!platform || platform.injector.get(ALLOW_MULTIPLE_PLATFORMS, false)) {
- if (parentPlatformFactory) {
- parentPlatformFactory(providers.concat(extraProviders).concat({ provide: marker, useValue: true }));
- }
- else {
- createPlatform(ReflectiveInjector.resolveAndCreate(providers.concat(extraProviders).concat({ provide: marker, useValue: true })));
- }
- }
- return assertPlatform(marker);
- };
- }
- /**
- * Checks that there currently is a platform which contains the given token as a provider.
- *
- * \@experimental APIs related to application bootstrap are currently under review.
- * @param {?} requiredToken
- * @return {?}
- */
- function assertPlatform(requiredToken) {
- var /** @type {?} */ platform = getPlatform();
- if (!platform) {
- throw new Error('No platform exists!');
- }
- if (!platform.injector.get(requiredToken, null)) {
- throw new Error('A platform with a different configuration has been created. Please destroy it first.');
- }
- return platform;
- }
- /**
- * Returns the current platform.
- *
- * \@experimental APIs related to application bootstrap are currently under review.
- * @return {?}
- */
- function getPlatform() {
- return _platform && !_platform.destroyed ? _platform : null;
- }
- /**
- * The Angular platform is the entry point for Angular on a web page. Each page
- * has exactly one platform, and services (such as reflection) which are common
- * to every Angular application running on the page are bound in its scope.
- *
- * A page's platform is initialized implicitly when a platform is created via a platform factory
- * (e.g. {\@link platformBrowser}), or explicitly by calling the {\@link createPlatform} function.
- *
- * \@stable
- * @abstract
- */
- var PlatformRef = (function () {
- function PlatformRef() {
- }
- /**
- * Creates an instance of an `\@NgModule` for the given platform
- * for offline compilation.
- *
- * ## Simple Example
- *
- * ```typescript
- * my_module.ts:
- *
- * \@NgModule({
- * imports: [BrowserModule]
- * })
- * class MyModule {}
- *
- * main.ts:
- * import {MyModuleNgFactory} from './my_module.ngfactory';
- * import {platformBrowser} from '\@angular/platform-browser';
- *
- * let moduleRef = platformBrowser().bootstrapModuleFactory(MyModuleNgFactory);
- * ```
- *
- * \@experimental APIs related to application bootstrap are currently under review.
- * @abstract
- * @template M
- * @param {?} moduleFactory
- * @return {?}
- */
- PlatformRef.prototype.bootstrapModuleFactory = function (moduleFactory) { };
- /**
- * Creates an instance of an `\@NgModule` for a given platform using the given runtime compiler.
- *
- * ## Simple Example
- *
- * ```typescript
- * \@NgModule({
- * imports: [BrowserModule]
- * })
- * class MyModule {}
- *
- * let moduleRef = platformBrowser().bootstrapModule(MyModule);
- * ```
- * \@stable
- * @abstract
- * @template M
- * @param {?} moduleType
- * @param {?=} compilerOptions
- * @return {?}
- */
- PlatformRef.prototype.bootstrapModule = function (moduleType, compilerOptions) { };
- /**
- * Register a listener to be called when the platform is disposed.
- * @abstract
- * @param {?} callback
- * @return {?}
- */
- PlatformRef.prototype.onDestroy = function (callback) { };
- /**
- * Retrieve the platform {\@link Injector}, which is the parent injector for
- * every Angular application on the page and provides singleton providers.
- * @abstract
- * @return {?}
- */
- PlatformRef.prototype.injector = function () { };
- /**
- * Destroy the Angular platform and all Angular applications on the page.
- * @abstract
- * @return {?}
- */
- PlatformRef.prototype.destroy = function () { };
- /**
- * @abstract
- * @return {?}
- */
- PlatformRef.prototype.destroyed = function () { };
- return PlatformRef;
- }());
- /**
- * @param {?} errorHandler
- * @param {?} ngZone
- * @param {?} callback
- * @return {?}
- */
- function _callAndReportToErrorHandler(errorHandler, ngZone, callback) {
- try {
- var /** @type {?} */ result = callback();
- if (isPromise(result)) {
- return result.catch(function (e) {
- ngZone.runOutsideAngular(function () { return errorHandler.handleError(e); });
- // rethrow as the exception handler might not do it
- throw e;
- });
- }
- return result;
- }
- catch (e) {
- ngZone.runOutsideAngular(function () { return errorHandler.handleError(e); });
- // rethrow as the exception handler might not do it
- throw e;
- }
- }
- /**
- * workaround https://github.com/angular/tsickle/issues/350
- * @suppress {checkTypes}
- */
- var PlatformRef_ = (function (_super) {
- __extends$1(PlatformRef_, _super);
- /**
- * @param {?} _injector
- */
- function PlatformRef_(_injector) {
- var _this = _super.call(this) || this;
- _this._injector = _injector;
- _this._modules = [];
- _this._destroyListeners = [];
- _this._destroyed = false;
- return _this;
- }
- /**
- * @param {?} callback
- * @return {?}
- */
- PlatformRef_.prototype.onDestroy = function (callback) { this._destroyListeners.push(callback); };
- Object.defineProperty(PlatformRef_.prototype, "injector", {
- /**
- * @return {?}
- */
- get: function () { return this._injector; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(PlatformRef_.prototype, "destroyed", {
- /**
- * @return {?}
- */
- get: function () { return this._destroyed; },
- enumerable: true,
- configurable: true
- });
- /**
- * @return {?}
- */
- PlatformRef_.prototype.destroy = function () {
- if (this._destroyed) {
- throw new Error('The platform has already been destroyed!');
- }
- this._modules.slice().forEach(function (module) { return module.destroy(); });
- this._destroyListeners.forEach(function (listener) { return listener(); });
- this._destroyed = true;
- };
- /**
- * @template M
- * @param {?} moduleFactory
- * @return {?}
- */
- PlatformRef_.prototype.bootstrapModuleFactory = function (moduleFactory) {
- return this._bootstrapModuleFactoryWithZone(moduleFactory);
- };
- /**
- * @template M
- * @param {?} moduleFactory
- * @param {?=} ngZone
- * @return {?}
- */
- PlatformRef_.prototype._bootstrapModuleFactoryWithZone = function (moduleFactory, ngZone) {
- var _this = this;
- // Note: We need to create the NgZone _before_ we instantiate the module,
- // as instantiating the module creates some providers eagerly.
- // So we create a mini parent injector that just contains the new NgZone and
- // pass that as parent to the NgModuleFactory.
- if (!ngZone)
- ngZone = new NgZone({ enableLongStackTrace: isDevMode() });
- // Attention: Don't use ApplicationRef.run here,
- // as we want to be sure that all possible constructor calls are inside `ngZone.run`!
- return ngZone.run(function () {
- var /** @type {?} */ ngZoneInjector = ReflectiveInjector.resolveAndCreate([{ provide: NgZone, useValue: ngZone }], _this.injector);
- var /** @type {?} */ moduleRef = (moduleFactory.create(ngZoneInjector));
- var /** @type {?} */ exceptionHandler = moduleRef.injector.get(ErrorHandler, null);
- if (!exceptionHandler) {
- throw new Error('No ErrorHandler. Is platform module (BrowserModule) included?');
- }
- moduleRef.onDestroy(function () { return remove(_this._modules, moduleRef); }); /** @type {?} */
- ((ngZone)).runOutsideAngular(function () { return ((ngZone)).onError.subscribe({ next: function (error) { exceptionHandler.handleError(error); } }); });
- return _callAndReportToErrorHandler(exceptionHandler, /** @type {?} */ ((ngZone)), function () {
- var /** @type {?} */ initStatus = moduleRef.injector.get(ApplicationInitStatus);
- initStatus.runInitializers();
- return initStatus.donePromise.then(function () {
- _this._moduleDoBootstrap(moduleRef);
- return moduleRef;
- });
- });
- });
- };
- /**
- * @template M
- * @param {?} moduleType
- * @param {?=} compilerOptions
- * @return {?}
- */
- PlatformRef_.prototype.bootstrapModule = function (moduleType, compilerOptions) {
- if (compilerOptions === void 0) { compilerOptions = []; }
- return this._bootstrapModuleWithZone(moduleType, compilerOptions);
- };
- /**
- * @template M
- * @param {?} moduleType
- * @param {?=} compilerOptions
- * @param {?=} ngZone
- * @return {?}
- */
- PlatformRef_.prototype._bootstrapModuleWithZone = function (moduleType, compilerOptions, ngZone) {
- var _this = this;
- if (compilerOptions === void 0) { compilerOptions = []; }
- var /** @type {?} */ compilerFactory = this.injector.get(CompilerFactory);
- var /** @type {?} */ compiler = compilerFactory.createCompiler(Array.isArray(compilerOptions) ? compilerOptions : [compilerOptions]);
- return compiler.compileModuleAsync(moduleType)
- .then(function (moduleFactory) { return _this._bootstrapModuleFactoryWithZone(moduleFactory, ngZone); });
- };
- /**
- * @param {?} moduleRef
- * @return {?}
- */
- PlatformRef_.prototype._moduleDoBootstrap = function (moduleRef) {
- var /** @type {?} */ appRef = (moduleRef.injector.get(ApplicationRef));
- if (moduleRef._bootstrapComponents.length > 0) {
- moduleRef._bootstrapComponents.forEach(function (f) { return appRef.bootstrap(f); });
- }
- else if (moduleRef.instance.ngDoBootstrap) {
- moduleRef.instance.ngDoBootstrap(appRef);
- }
- else {
- throw new Error("The module " + stringify(moduleRef.instance.constructor) + " was bootstrapped, but it does not declare \"@NgModule.bootstrap\" components nor a \"ngDoBootstrap\" method. " +
- "Please define one of these.");
- }
- this._modules.push(moduleRef);
- };
- return PlatformRef_;
- }(PlatformRef));
- PlatformRef_.decorators = [
- { type: Injectable },
- ];
- /**
- * @nocollapse
- */
- PlatformRef_.ctorParameters = function () { return [
- { type: Injector, },
- ]; };
- /**
- * A reference to an Angular application running on a page.
- *
- * \@stable
- * @abstract
- */
- var ApplicationRef = (function () {
- function ApplicationRef() {
- }
- /**
- * Bootstrap a new component at the root level of the application.
- *
- * ### Bootstrap process
- *
- * When bootstrapping a new root component into an application, Angular mounts the
- * specified application component onto DOM elements identified by the [componentType]'s
- * selector and kicks off automatic change detection to finish initializing the component.
- *
- * Optionally, a component can be mounted onto a DOM element that does not match the
- * [componentType]'s selector.
- *
- * ### Example
- * {\@example core/ts/platform/platform.ts region='longform'}
- * @abstract
- * @template C
- * @param {?} componentFactory
- * @param {?=} rootSelectorOrNode
- * @return {?}
- */
- ApplicationRef.prototype.bootstrap = function (componentFactory, rootSelectorOrNode) { };
- /**
- * Invoke this method to explicitly process change detection and its side-effects.
- *
- * In development mode, `tick()` also performs a second change detection cycle to ensure that no
- * further changes are detected. If additional changes are picked up during this second cycle,
- * bindings in the app have side-effects that cannot be resolved in a single change detection
- * pass.
- * In this case, Angular throws an error, since an Angular application can only have one change
- * detection pass during which all change detection must complete.
- * @abstract
- * @return {?}
- */
- ApplicationRef.prototype.tick = function () { };
- /**
- * Get a list of component types registered to this application.
- * This list is populated even before the component is created.
- * @abstract
- * @return {?}
- */
- ApplicationRef.prototype.componentTypes = function () { };
- /**
- * Get a list of components registered to this application.
- * @abstract
- * @return {?}
- */
- ApplicationRef.prototype.components = function () { };
- /**
- * Attaches a view so that it will be dirty checked.
- * The view will be automatically detached when it is destroyed.
- * This will throw if the view is already attached to a ViewContainer.
- * @abstract
- * @param {?} view
- * @return {?}
- */
- ApplicationRef.prototype.attachView = function (view) { };
- /**
- * Detaches a view from dirty checking again.
- * @abstract
- * @param {?} view
- * @return {?}
- */
- ApplicationRef.prototype.detachView = function (view) { };
- /**
- * Returns the number of attached views.
- * @abstract
- * @return {?}
- */
- ApplicationRef.prototype.viewCount = function () { };
- /**
- * Returns an Observable that indicates when the application is stable or unstable.
- * @abstract
- * @return {?}
- */
- ApplicationRef.prototype.isStable = function () { };
- return ApplicationRef;
- }());
- /**
- * workaround https://github.com/angular/tsickle/issues/350
- * @suppress {checkTypes}
- */
- var ApplicationRef_ = (function (_super) {
- __extends$1(ApplicationRef_, _super);
- /**
- * @param {?} _zone
- * @param {?} _console
- * @param {?} _injector
- * @param {?} _exceptionHandler
- * @param {?} _componentFactoryResolver
- * @param {?} _initStatus
- */
- function ApplicationRef_(_zone, _console, _injector, _exceptionHandler, _componentFactoryResolver, _initStatus) {
- var _this = _super.call(this) || this;
- _this._zone = _zone;
- _this._console = _console;
- _this._injector = _injector;
- _this._exceptionHandler = _exceptionHandler;
- _this._componentFactoryResolver = _componentFactoryResolver;
- _this._initStatus = _initStatus;
- _this._bootstrapListeners = [];
- _this._rootComponents = [];
- _this._rootComponentTypes = [];
- _this._views = [];
- _this._runningTick = false;
- _this._enforceNoNewChanges = false;
- _this._stable = true;
- _this._enforceNoNewChanges = isDevMode();
- _this._zone.onMicrotaskEmpty.subscribe({ next: function () { _this._zone.run(function () { _this.tick(); }); } });
- var isCurrentlyStable = new Observable_2(function (observer) {
- _this._stable = _this._zone.isStable && !_this._zone.hasPendingMacrotasks &&
- !_this._zone.hasPendingMicrotasks;
- _this._zone.runOutsideAngular(function () {
- observer.next(_this._stable);
- observer.complete();
- });
- });
- var isStable = new Observable_2(function (observer) {
- // Create the subscription to onStable outside the Angular Zone so that
- // the callback is run outside the Angular Zone.
- var stableSub;
- _this._zone.runOutsideAngular(function () {
- stableSub = _this._zone.onStable.subscribe(function () {
- NgZone.assertNotInAngularZone();
- // Check whether there are no pending macro/micro tasks in the next tick
- // to allow for NgZone to update the state.
- scheduleMicroTask(function () {
- if (!_this._stable && !_this._zone.hasPendingMacrotasks &&
- !_this._zone.hasPendingMicrotasks) {
- _this._stable = true;
- observer.next(true);
- }
- });
- });
- });
- var unstableSub = _this._zone.onUnstable.subscribe(function () {
- NgZone.assertInAngularZone();
- if (_this._stable) {
- _this._stable = false;
- _this._zone.runOutsideAngular(function () { observer.next(false); });
- }
- });
- return function () {
- stableSub.unsubscribe();
- unstableSub.unsubscribe();
- };
- });
- _this._isStable = merge_2(isCurrentlyStable, share_2.call(isStable));
- return _this;
- }
- /**
- * @param {?} viewRef
- * @return {?}
- */
- ApplicationRef_.prototype.attachView = function (viewRef) {
- var /** @type {?} */ view = ((viewRef));
- this._views.push(view);
- view.attachToAppRef(this);
- };
- /**
- * @param {?} viewRef
- * @return {?}
- */
- ApplicationRef_.prototype.detachView = function (viewRef) {
- var /** @type {?} */ view = ((viewRef));
- remove(this._views, view);
- view.detachFromAppRef();
- };
- /**
- * @template C
- * @param {?} componentOrFactory
- * @param {?=} rootSelectorOrNode
- * @return {?}
- */
- ApplicationRef_.prototype.bootstrap = function (componentOrFactory, rootSelectorOrNode) {
- var _this = this;
- if (!this._initStatus.done) {
- throw new Error('Cannot bootstrap as there are still asynchronous initializers running. Bootstrap components in the `ngDoBootstrap` method of the root module.');
- }
- var /** @type {?} */ componentFactory;
- if (componentOrFactory instanceof ComponentFactory) {
- componentFactory = componentOrFactory;
- }
- else {
- componentFactory = ((this._componentFactoryResolver.resolveComponentFactory(componentOrFactory)));
- }
- this._rootComponentTypes.push(componentFactory.componentType);
- // Create a factory associated with the current module if it's not bound to some other
- var /** @type {?} */ ngModule = componentFactory instanceof ComponentFactoryBoundToModule ?
- null :
- this._injector.get(NgModuleRef);
- var /** @type {?} */ selectorOrNode = rootSelectorOrNode || componentFactory.selector;
- var /** @type {?} */ compRef = componentFactory.create(Injector.NULL, [], selectorOrNode, ngModule);
- compRef.onDestroy(function () { _this._unloadComponent(compRef); });
- var /** @type {?} */ testability = compRef.injector.get(Testability, null);
- if (testability) {
- compRef.injector.get(TestabilityRegistry)
- .registerApplication(compRef.location.nativeElement, testability);
- }
- this._loadComponent(compRef);
- if (isDevMode()) {
- this._console.log("Angular is running in the development mode. Call enableProdMode() to enable the production mode.");
- }
- return compRef;
- };
- /**
- * @param {?} componentRef
- * @return {?}
- */
- ApplicationRef_.prototype._loadComponent = function (componentRef) {
- this.attachView(componentRef.hostView);
- this.tick();
- this._rootComponents.push(componentRef);
- // Get the listeners lazily to prevent DI cycles.
- var /** @type {?} */ listeners = this._injector.get(APP_BOOTSTRAP_LISTENER, []).concat(this._bootstrapListeners);
- listeners.forEach(function (listener) { return listener(componentRef); });
- };
- /**
- * @param {?} componentRef
- * @return {?}
- */
- ApplicationRef_.prototype._unloadComponent = function (componentRef) {
- this.detachView(componentRef.hostView);
- remove(this._rootComponents, componentRef);
- };
- /**
- * @return {?}
- */
- ApplicationRef_.prototype.tick = function () {
- var _this = this;
- if (this._runningTick) {
- throw new Error('ApplicationRef.tick is called recursively');
- }
- var /** @type {?} */ scope = ApplicationRef_._tickScope();
- try {
- this._runningTick = true;
- this._views.forEach(function (view) { return view.detectChanges(); });
- if (this._enforceNoNewChanges) {
- this._views.forEach(function (view) { return view.checkNoChanges(); });
- }
- }
- catch (e) {
- // Attention: Don't rethrow as it could cancel subscriptions to Observables!
- this._zone.runOutsideAngular(function () { return _this._exceptionHandler.handleError(e); });
- }
- finally {
- this._runningTick = false;
- wtfLeave(scope);
- }
- };
- /**
- * @return {?}
- */
- ApplicationRef_.prototype.ngOnDestroy = function () {
- // TODO(alxhub): Dispose of the NgZone.
- this._views.slice().forEach(function (view) { return view.destroy(); });
- };
- Object.defineProperty(ApplicationRef_.prototype, "viewCount", {
- /**
- * @return {?}
- */
- get: function () { return this._views.length; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(ApplicationRef_.prototype, "componentTypes", {
- /**
- * @return {?}
- */
- get: function () { return this._rootComponentTypes; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(ApplicationRef_.prototype, "components", {
- /**
- * @return {?}
- */
- get: function () { return this._rootComponents; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(ApplicationRef_.prototype, "isStable", {
- /**
- * @return {?}
- */
- get: function () { return this._isStable; },
- enumerable: true,
- configurable: true
- });
- return ApplicationRef_;
- }(ApplicationRef));
- /**
- * \@internal
- */
- ApplicationRef_._tickScope = wtfCreateScope('ApplicationRef#tick()');
- ApplicationRef_.decorators = [
- { type: Injectable },
- ];
- /**
- * @nocollapse
- */
- ApplicationRef_.ctorParameters = function () { return [
- { type: NgZone, },
- { type: Console, },
- { type: Injector, },
- { type: ErrorHandler, },
- { type: ComponentFactoryResolver, },
- { type: ApplicationInitStatus, },
- ]; };
- /**
- * @template T
- * @param {?} list
- * @param {?} el
- * @return {?}
- */
- function remove(list, el) {
- var /** @type {?} */ index = list.indexOf(el);
- if (index > -1) {
- list.splice(index, 1);
- }
- }
- /**
- * @deprecated Use the `Renderer2` instead.
- * @abstract
- */
- var Renderer = (function () {
- function Renderer() {
- }
- /**
- * @abstract
- * @param {?} selectorOrNode
- * @param {?=} debugInfo
- * @return {?}
- */
- Renderer.prototype.selectRootElement = function (selectorOrNode, debugInfo) { };
- /**
- * @abstract
- * @param {?} parentElement
- * @param {?} name
- * @param {?=} debugInfo
- * @return {?}
- */
- Renderer.prototype.createElement = function (parentElement, name, debugInfo) { };
- /**
- * @abstract
- * @param {?} hostElement
- * @return {?}
- */
- Renderer.prototype.createViewRoot = function (hostElement) { };
- /**
- * @abstract
- * @param {?} parentElement
- * @param {?=} debugInfo
- * @return {?}
- */
- Renderer.prototype.createTemplateAnchor = function (parentElement, debugInfo) { };
- /**
- * @abstract
- * @param {?} parentElement
- * @param {?} value
- * @param {?=} debugInfo
- * @return {?}
- */
- Renderer.prototype.createText = function (parentElement, value, debugInfo) { };
- /**
- * @abstract
- * @param {?} parentElement
- * @param {?} nodes
- * @return {?}
- */
- Renderer.prototype.projectNodes = function (parentElement, nodes) { };
- /**
- * @abstract
- * @param {?} node
- * @param {?} viewRootNodes
- * @return {?}
- */
- Renderer.prototype.attachViewAfter = function (node, viewRootNodes) { };
- /**
- * @abstract
- * @param {?} viewRootNodes
- * @return {?}
- */
- Renderer.prototype.detachView = function (viewRootNodes) { };
- /**
- * @abstract
- * @param {?} hostElement
- * @param {?} viewAllNodes
- * @return {?}
- */
- Renderer.prototype.destroyView = function (hostElement, viewAllNodes) { };
- /**
- * @abstract
- * @param {?} renderElement
- * @param {?} name
- * @param {?} callback
- * @return {?}
- */
- Renderer.prototype.listen = function (renderElement, name, callback) { };
- /**
- * @abstract
- * @param {?} target
- * @param {?} name
- * @param {?} callback
- * @return {?}
- */
- Renderer.prototype.listenGlobal = function (target, name, callback) { };
- /**
- * @abstract
- * @param {?} renderElement
- * @param {?} propertyName
- * @param {?} propertyValue
- * @return {?}
- */
- Renderer.prototype.setElementProperty = function (renderElement, propertyName, propertyValue) { };
- /**
- * @abstract
- * @param {?} renderElement
- * @param {?} attributeName
- * @param {?} attributeValue
- * @return {?}
- */
- Renderer.prototype.setElementAttribute = function (renderElement, attributeName, attributeValue) { };
- /**
- * Used only in debug mode to serialize property changes to dom nodes as attributes.
- * @abstract
- * @param {?} renderElement
- * @param {?} propertyName
- * @param {?} propertyValue
- * @return {?}
- */
- Renderer.prototype.setBindingDebugInfo = function (renderElement, propertyName, propertyValue) { };
- /**
- * @abstract
- * @param {?} renderElement
- * @param {?} className
- * @param {?} isAdd
- * @return {?}
- */
- Renderer.prototype.setElementClass = function (renderElement, className, isAdd) { };
- /**
- * @abstract
- * @param {?} renderElement
- * @param {?} styleName
- * @param {?} styleValue
- * @return {?}
- */
- Renderer.prototype.setElementStyle = function (renderElement, styleName, styleValue) { };
- /**
- * @abstract
- * @param {?} renderElement
- * @param {?} methodName
- * @param {?=} args
- * @return {?}
- */
- Renderer.prototype.invokeElementMethod = function (renderElement, methodName, args) { };
- /**
- * @abstract
- * @param {?} renderNode
- * @param {?} text
- * @return {?}
- */
- Renderer.prototype.setText = function (renderNode, text) { };
- /**
- * @abstract
- * @param {?} element
- * @param {?} startingStyles
- * @param {?} keyframes
- * @param {?} duration
- * @param {?} delay
- * @param {?} easing
- * @param {?=} previousPlayers
- * @return {?}
- */
- Renderer.prototype.animate = function (element, startingStyles, keyframes, duration, delay, easing, previousPlayers) { };
- return Renderer;
- }());
- var Renderer2Interceptor = new InjectionToken('Renderer2Interceptor');
- /**
- * \@experimental
- * @abstract
- */
- var RendererFactory2 = (function () {
- function RendererFactory2() {
- }
- /**
- * @abstract
- * @param {?} hostElement
- * @param {?} type
- * @return {?}
- */
- RendererFactory2.prototype.createRenderer = function (hostElement, type) { };
- /**
- * @abstract
- * @return {?}
- */
- RendererFactory2.prototype.begin = function () { };
- /**
- * @abstract
- * @return {?}
- */
- RendererFactory2.prototype.end = function () { };
- /**
- * @abstract
- * @return {?}
- */
- RendererFactory2.prototype.whenRenderingDone = function () { };
- return RendererFactory2;
- }());
- var RendererStyleFlags2 = {};
- RendererStyleFlags2.Important = 1;
- RendererStyleFlags2.DashCase = 2;
- RendererStyleFlags2[RendererStyleFlags2.Important] = "Important";
- RendererStyleFlags2[RendererStyleFlags2.DashCase] = "DashCase";
- /**
- * \@experimental
- * @abstract
- */
- var Renderer2 = (function () {
- function Renderer2() {
- }
- /**
- * This field can be used to store arbitrary data on this renderer instance.
- * This is useful for renderers that delegate to other renderers.
- * @abstract
- * @return {?}
- */
- Renderer2.prototype.data = function () { };
- /**
- * @abstract
- * @return {?}
- */
- Renderer2.prototype.destroy = function () { };
- /**
- * @abstract
- * @param {?} name
- * @param {?=} namespace
- * @return {?}
- */
- Renderer2.prototype.createElement = function (name, namespace) { };
- /**
- * @abstract
- * @param {?} value
- * @return {?}
- */
- Renderer2.prototype.createComment = function (value) { };
- /**
- * @abstract
- * @param {?} value
- * @return {?}
- */
- Renderer2.prototype.createText = function (value) { };
- /**
- * @abstract
- * @param {?} parent
- * @param {?} newChild
- * @return {?}
- */
- Renderer2.prototype.appendChild = function (parent, newChild) { };
- /**
- * @abstract
- * @param {?} parent
- * @param {?} newChild
- * @param {?} refChild
- * @return {?}
- */
- Renderer2.prototype.insertBefore = function (parent, newChild, refChild) { };
- /**
- * @abstract
- * @param {?} parent
- * @param {?} oldChild
- * @return {?}
- */
- Renderer2.prototype.removeChild = function (parent, oldChild) { };
- /**
- * @abstract
- * @param {?} selectorOrNode
- * @return {?}
- */
- Renderer2.prototype.selectRootElement = function (selectorOrNode) { };
- /**
- * Attention: On WebWorkers, this will always return a value,
- * as we are asking for a result synchronously. I.e.
- * the caller can't rely on checking whether this is null or not.
- * @abstract
- * @param {?} node
- * @return {?}
- */
- Renderer2.prototype.parentNode = function (node) { };
- /**
- * Attention: On WebWorkers, this will always return a value,
- * as we are asking for a result synchronously. I.e.
- * the caller can't rely on checking whether this is null or not.
- * @abstract
- * @param {?} node
- * @return {?}
- */
- Renderer2.prototype.nextSibling = function (node) { };
- /**
- * @abstract
- * @param {?} el
- * @param {?} name
- * @param {?} value
- * @param {?=} namespace
- * @return {?}
- */
- Renderer2.prototype.setAttribute = function (el, name, value, namespace) { };
- /**
- * @abstract
- * @param {?} el
- * @param {?} name
- * @param {?=} namespace
- * @return {?}
- */
- Renderer2.prototype.removeAttribute = function (el, name, namespace) { };
- /**
- * @abstract
- * @param {?} el
- * @param {?} name
- * @return {?}
- */
- Renderer2.prototype.addClass = function (el, name) { };
- /**
- * @abstract
- * @param {?} el
- * @param {?} name
- * @return {?}
- */
- Renderer2.prototype.removeClass = function (el, name) { };
- /**
- * @abstract
- * @param {?} el
- * @param {?} style
- * @param {?} value
- * @param {?=} flags
- * @return {?}
- */
- Renderer2.prototype.setStyle = function (el, style, value, flags) { };
- /**
- * @abstract
- * @param {?} el
- * @param {?} style
- * @param {?=} flags
- * @return {?}
- */
- Renderer2.prototype.removeStyle = function (el, style, flags) { };
- /**
- * @abstract
- * @param {?} el
- * @param {?} name
- * @param {?} value
- * @return {?}
- */
- Renderer2.prototype.setProperty = function (el, name, value) { };
- /**
- * @abstract
- * @param {?} node
- * @param {?} value
- * @return {?}
- */
- Renderer2.prototype.setValue = function (node, value) { };
- /**
- * @abstract
- * @param {?} target
- * @param {?} eventName
- * @param {?} callback
- * @return {?}
- */
- Renderer2.prototype.listen = function (target, eventName, callback) { };
- return Renderer2;
- }());
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- // Public API for render
- var ElementRef = (function () {
- /**
- * @param {?} nativeElement
- */
- function ElementRef(nativeElement) {
- this.nativeElement = nativeElement;
- }
- return ElementRef;
- }());
- var moduleFactories = new Map();
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * An unmodifiable list of items that Angular keeps up to date when the state
- * of the application changes.
- *
- * The type of object that {\@link ViewChildren}, {\@link ContentChildren}, and {\@link QueryList}
- * provide.
- *
- * Implements an iterable interface, therefore it can be used in both ES6
- * javascript `for (var i of items)` loops as well as in Angular templates with
- * `*ngFor="let i of myList"`.
- *
- * Changes can be observed by subscribing to the changes `Observable`.
- *
- * NOTE: In the future this class will implement an `Observable` interface.
- *
- * ### Example ([live demo](http://plnkr.co/edit/RX8sJnQYl9FWuSCWme5z?p=preview))
- * ```typescript
- * \@Component({...})
- * class Container {
- * \@ViewChildren(Item) items:QueryList<Item>;
- * }
- * ```
- * \@stable
- */
- var QueryList = (function () {
- function QueryList() {
- this._dirty = true;
- this._results = [];
- this._emitter = new EventEmitter();
- }
- Object.defineProperty(QueryList.prototype, "changes", {
- /**
- * @return {?}
- */
- get: function () { return this._emitter; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(QueryList.prototype, "length", {
- /**
- * @return {?}
- */
- get: function () { return this._results.length; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(QueryList.prototype, "first", {
- /**
- * @return {?}
- */
- get: function () { return this._results[0]; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(QueryList.prototype, "last", {
- /**
- * @return {?}
- */
- get: function () { return this._results[this.length - 1]; },
- enumerable: true,
- configurable: true
- });
- /**
- * See
- * [Array.map](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map)
- * @template U
- * @param {?} fn
- * @return {?}
- */
- QueryList.prototype.map = function (fn) { return this._results.map(fn); };
- /**
- * See
- * [Array.filter](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter)
- * @param {?} fn
- * @return {?}
- */
- QueryList.prototype.filter = function (fn) {
- return this._results.filter(fn);
- };
- /**
- * See
- * [Array.find](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/find)
- * @param {?} fn
- * @return {?}
- */
- QueryList.prototype.find = function (fn) {
- return this._results.find(fn);
- };
- /**
- * See
- * [Array.reduce](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce)
- * @template U
- * @param {?} fn
- * @param {?} init
- * @return {?}
- */
- QueryList.prototype.reduce = function (fn, init) {
- return this._results.reduce(fn, init);
- };
- /**
- * See
- * [Array.forEach](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach)
- * @param {?} fn
- * @return {?}
- */
- QueryList.prototype.forEach = function (fn) { this._results.forEach(fn); };
- /**
- * See
- * [Array.some](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some)
- * @param {?} fn
- * @return {?}
- */
- QueryList.prototype.some = function (fn) {
- return this._results.some(fn);
- };
- /**
- * @return {?}
- */
- QueryList.prototype.toArray = function () { return this._results.slice(); };
- /**
- * @return {?}
- */
- QueryList.prototype[getSymbolIterator()] = function () { return ((this._results))[getSymbolIterator()](); };
- /**
- * @return {?}
- */
- QueryList.prototype.toString = function () { return this._results.toString(); };
- /**
- * @param {?} res
- * @return {?}
- */
- QueryList.prototype.reset = function (res) {
- this._results = flatten(res);
- this._dirty = false;
- };
- /**
- * @return {?}
- */
- QueryList.prototype.notifyOnChanges = function () { this._emitter.emit(this); };
- /**
- * internal
- * @return {?}
- */
- QueryList.prototype.setDirty = function () { this._dirty = true; };
- Object.defineProperty(QueryList.prototype, "dirty", {
- /**
- * internal
- * @return {?}
- */
- get: function () { return this._dirty; },
- enumerable: true,
- configurable: true
- });
- /**
- * internal
- * @return {?}
- */
- QueryList.prototype.destroy = function () {
- this._emitter.complete();
- this._emitter.unsubscribe();
- };
- return QueryList;
- }());
- /**
- * @template T
- * @param {?} list
- * @return {?}
- */
- function flatten(list) {
- return list.reduce(function (flat, item) {
- var /** @type {?} */ flatItem = Array.isArray(item) ? flatten(item) : item;
- return ((flat)).concat(flatItem);
- }, []);
- }
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var _SEPARATOR = '#';
- var FACTORY_CLASS_SUFFIX = 'NgFactory';
- /**
- * Configuration for SystemJsNgModuleLoader.
- * token.
- *
- * \@experimental
- * @abstract
- */
- var SystemJsNgModuleLoaderConfig = (function () {
- function SystemJsNgModuleLoaderConfig() {
- }
- return SystemJsNgModuleLoaderConfig;
- }());
- var DEFAULT_CONFIG = {
- factoryPathPrefix: '',
- factoryPathSuffix: '.ngfactory',
- };
- /**
- * NgModuleFactoryLoader that uses SystemJS to load NgModuleFactory
- * \@experimental
- */
- var SystemJsNgModuleLoader = (function () {
- /**
- * @param {?} _compiler
- * @param {?=} config
- */
- function SystemJsNgModuleLoader(_compiler, config) {
- this._compiler = _compiler;
- this._config = config || DEFAULT_CONFIG;
- }
- /**
- * @param {?} path
- * @return {?}
- */
- SystemJsNgModuleLoader.prototype.load = function (path) {
- var /** @type {?} */ offlineMode = this._compiler instanceof Compiler;
- return offlineMode ? this.loadFactory(path) : this.loadAndCompile(path);
- };
- /**
- * @param {?} path
- * @return {?}
- */
- SystemJsNgModuleLoader.prototype.loadAndCompile = function (path) {
- var _this = this;
- var _a = path.split(_SEPARATOR), module = _a[0], exportName = _a[1];
- if (exportName === undefined) {
- exportName = 'default';
- }
- return System.import(module)
- .then(function (module) { return module[exportName]; })
- .then(function (type) { return checkNotEmpty(type, module, exportName); })
- .then(function (type) { return _this._compiler.compileModuleAsync(type); });
- };
- /**
- * @param {?} path
- * @return {?}
- */
- SystemJsNgModuleLoader.prototype.loadFactory = function (path) {
- var _a = path.split(_SEPARATOR), module = _a[0], exportName = _a[1];
- var /** @type {?} */ factoryClassSuffix = FACTORY_CLASS_SUFFIX;
- if (exportName === undefined) {
- exportName = 'default';
- factoryClassSuffix = '';
- }
- return System.import(this._config.factoryPathPrefix + module + this._config.factoryPathSuffix)
- .then(function (module) { return module[exportName + factoryClassSuffix]; })
- .then(function (factory) { return checkNotEmpty(factory, module, exportName); });
- };
- return SystemJsNgModuleLoader;
- }());
- SystemJsNgModuleLoader.decorators = [
- { type: Injectable },
- ];
- /**
- * @nocollapse
- */
- SystemJsNgModuleLoader.ctorParameters = function () { return [
- { type: Compiler, },
- { type: SystemJsNgModuleLoaderConfig, decorators: [{ type: Optional },] },
- ]; };
- /**
- * @param {?} value
- * @param {?} modulePath
- * @param {?} exportName
- * @return {?}
- */
- function checkNotEmpty(value, modulePath, exportName) {
- if (!value) {
- throw new Error("Cannot find '" + exportName + "' in '" + modulePath + "'");
- }
- return value;
- }
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * Represents an Embedded Template that can be used to instantiate Embedded Views.
- *
- * You can access a `TemplateRef`, in two ways. Via a directive placed on a `<ng-template>` element
- * (or directive prefixed with `*`) and have the `TemplateRef` for this Embedded View injected into
- * the constructor of the directive using the `TemplateRef` Token. Alternatively you can query for
- * the `TemplateRef` from a Component or a Directive via {\@link Query}.
- *
- * To instantiate Embedded Views based on a Template, use
- * {\@link ViewContainerRef#createEmbeddedView}, which will create the View and attach it to the
- * View Container.
- * \@stable
- * @abstract
- */
- var TemplateRef = (function () {
- function TemplateRef() {
- }
- /**
- * @abstract
- * @return {?}
- */
- TemplateRef.prototype.elementRef = function () { };
- /**
- * @abstract
- * @param {?} context
- * @return {?}
- */
- TemplateRef.prototype.createEmbeddedView = function (context) { };
- return TemplateRef;
- }());
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * Represents a container where one or more Views can be attached.
- *
- * The container can contain two kinds of Views. Host Views, created by instantiating a
- * {\@link Component} via {\@link #createComponent}, and Embedded Views, created by instantiating an
- * {\@link TemplateRef Embedded Template} via {\@link #createEmbeddedView}.
- *
- * The location of the View Container within the containing View is specified by the Anchor
- * `element`. Each View Container can have only one Anchor Element and each Anchor Element can only
- * have a single View Container.
- *
- * Root elements of Views attached to this container become siblings of the Anchor Element in
- * the Rendered View.
- *
- * To access a `ViewContainerRef` of an Element, you can either place a {\@link Directive} injected
- * with `ViewContainerRef` on the Element, or you obtain it via a {\@link ViewChild} query.
- * \@stable
- * @abstract
- */
- var ViewContainerRef = (function () {
- function ViewContainerRef() {
- }
- /**
- * Anchor element that specifies the location of this container in the containing View.
- * <!-- TODO: rename to anchorElement -->
- * @abstract
- * @return {?}
- */
- ViewContainerRef.prototype.element = function () { };
- /**
- * @abstract
- * @return {?}
- */
- ViewContainerRef.prototype.injector = function () { };
- /**
- * @abstract
- * @return {?}
- */
- ViewContainerRef.prototype.parentInjector = function () { };
- /**
- * Destroys all Views in this container.
- * @abstract
- * @return {?}
- */
- ViewContainerRef.prototype.clear = function () { };
- /**
- * Returns the {\@link ViewRef} for the View located in this container at the specified index.
- * @abstract
- * @param {?} index
- * @return {?}
- */
- ViewContainerRef.prototype.get = function (index) { };
- /**
- * Returns the number of Views currently attached to this container.
- * @abstract
- * @return {?}
- */
- ViewContainerRef.prototype.length = function () { };
- /**
- * Instantiates an Embedded View based on the {\@link TemplateRef `templateRef`} and inserts it
- * into this container at the specified `index`.
- *
- * If `index` is not specified, the new View will be inserted as the last View in the container.
- *
- * Returns the {\@link ViewRef} for the newly created View.
- * @abstract
- * @template C
- * @param {?} templateRef
- * @param {?=} context
- * @param {?=} index
- * @return {?}
- */
- ViewContainerRef.prototype.createEmbeddedView = function (templateRef, context, index) { };
- /**
- * Instantiates a single {\@link Component} and inserts its Host View into this container at the
- * specified `index`.
- *
- * The component is instantiated using its {\@link ComponentFactory} which can be
- * obtained via {\@link ComponentFactoryResolver#resolveComponentFactory}.
- *
- * If `index` is not specified, the new View will be inserted as the last View in the container.
- *
- * You can optionally specify the {\@link Injector} that will be used as parent for the Component.
- *
- * Returns the {\@link ComponentRef} of the Host View created for the newly instantiated Component.
- * @abstract
- * @template C
- * @param {?} componentFactory
- * @param {?=} index
- * @param {?=} injector
- * @param {?=} projectableNodes
- * @param {?=} ngModule
- * @return {?}
- */
- ViewContainerRef.prototype.createComponent = function (componentFactory, index, injector, projectableNodes, ngModule) { };
- /**
- * Inserts a View identified by a {\@link ViewRef} into the container at the specified `index`.
- *
- * If `index` is not specified, the new View will be inserted as the last View in the container.
- *
- * Returns the inserted {\@link ViewRef}.
- * @abstract
- * @param {?} viewRef
- * @param {?=} index
- * @return {?}
- */
- ViewContainerRef.prototype.insert = function (viewRef, index) { };
- /**
- * Moves a View identified by a {\@link ViewRef} into the container at the specified `index`.
- *
- * Returns the inserted {\@link ViewRef}.
- * @abstract
- * @param {?} viewRef
- * @param {?} currentIndex
- * @return {?}
- */
- ViewContainerRef.prototype.move = function (viewRef, currentIndex) { };
- /**
- * Returns the index of the View, specified via {\@link ViewRef}, within the current container or
- * `-1` if this container doesn't contain the View.
- * @abstract
- * @param {?} viewRef
- * @return {?}
- */
- ViewContainerRef.prototype.indexOf = function (viewRef) { };
- /**
- * Destroys a View attached to this container at the specified `index`.
- *
- * If `index` is not specified, the last View in the container will be removed.
- * @abstract
- * @param {?=} index
- * @return {?}
- */
- ViewContainerRef.prototype.remove = function (index) { };
- /**
- * Use along with {\@link #insert} to move a View within the current container.
- *
- * If the `index` param is omitted, the last {\@link ViewRef} is detached.
- * @abstract
- * @param {?=} index
- * @return {?}
- */
- ViewContainerRef.prototype.detach = function (index) { };
- return ViewContainerRef;
- }());
- /**
- * \@stable
- * @abstract
- */
- var ChangeDetectorRef = (function () {
- function ChangeDetectorRef() {
- }
- /**
- * Marks all {\@link ChangeDetectionStrategy#OnPush} ancestors as to be checked.
- *
- * <!-- TODO: Add a link to a chapter on OnPush components -->
- *
- * ### Example ([live demo](http://plnkr.co/edit/GC512b?p=preview))
- *
- * ```typescript
- * \@Component({
- * selector: 'cmp',
- * changeDetection: ChangeDetectionStrategy.OnPush,
- * template: `Number of ticks: {{numberOfTicks}}`
- * })
- * class Cmp {
- * numberOfTicks = 0;
- *
- * constructor(private ref: ChangeDetectorRef) {
- * setInterval(() => {
- * this.numberOfTicks++;
- * // the following is required, otherwise the view will not be updated
- * this.ref.markForCheck();
- * }, 1000);
- * }
- * }
- *
- * \@Component({
- * selector: 'app',
- * changeDetection: ChangeDetectionStrategy.OnPush,
- * template: `
- * <cmp><cmp>
- * `,
- * })
- * class App {
- * }
- * ```
- * @abstract
- * @return {?}
- */
- ChangeDetectorRef.prototype.markForCheck = function () { };
- /**
- * Detaches the change detector from the change detector tree.
- *
- * The detached change detector will not be checked until it is reattached.
- *
- * This can also be used in combination with {\@link ChangeDetectorRef#detectChanges} to implement
- * local change
- * detection checks.
- *
- * <!-- TODO: Add a link to a chapter on detach/reattach/local digest -->
- * <!-- TODO: Add a live demo once ref.detectChanges is merged into master -->
- *
- * ### Example
- *
- * The following example defines a component with a large list of readonly data.
- * Imagine the data changes constantly, many times per second. For performance reasons,
- * we want to check and update the list every five seconds. We can do that by detaching
- * the component's change detector and doing a local check every five seconds.
- *
- * ```typescript
- * class DataProvider {
- * // in a real application the returned data will be different every time
- * get data() {
- * return [1,2,3,4,5];
- * }
- * }
- *
- * \@Component({
- * selector: 'giant-list',
- * template: `
- * <li *ngFor="let d of dataProvider.data">Data {{d}}</li>
- * `,
- * })
- * class GiantList {
- * constructor(private ref: ChangeDetectorRef, private dataProvider: DataProvider) {
- * ref.detach();
- * setInterval(() => {
- * this.ref.detectChanges();
- * }, 5000);
- * }
- * }
- *
- * \@Component({
- * selector: 'app',
- * providers: [DataProvider],
- * template: `
- * <giant-list><giant-list>
- * `,
- * })
- * class App {
- * }
- * ```
- * @abstract
- * @return {?}
- */
- ChangeDetectorRef.prototype.detach = function () { };
- /**
- * Checks the change detector and its children.
- *
- * This can also be used in combination with {\@link ChangeDetectorRef#detach} to implement local
- * change detection
- * checks.
- *
- * <!-- TODO: Add a link to a chapter on detach/reattach/local digest -->
- * <!-- TODO: Add a live demo once ref.detectChanges is merged into master -->
- *
- * ### Example
- *
- * The following example defines a component with a large list of readonly data.
- * Imagine, the data changes constantly, many times per second. For performance reasons,
- * we want to check and update the list every five seconds.
- *
- * We can do that by detaching the component's change detector and doing a local change detection
- * check
- * every five seconds.
- *
- * See {\@link ChangeDetectorRef#detach} for more information.
- * @abstract
- * @return {?}
- */
- ChangeDetectorRef.prototype.detectChanges = function () { };
- /**
- * Checks the change detector and its children, and throws if any changes are detected.
- *
- * This is used in development mode to verify that running change detection doesn't introduce
- * other changes.
- * @abstract
- * @return {?}
- */
- ChangeDetectorRef.prototype.checkNoChanges = function () { };
- /**
- * Reattach the change detector to the change detector tree.
- *
- * This also marks OnPush ancestors as to be checked. This reattached change detector will be
- * checked during the next change detection run.
- *
- * <!-- TODO: Add a link to a chapter on detach/reattach/local digest -->
- *
- * ### Example ([live demo](http://plnkr.co/edit/aUhZha?p=preview))
- *
- * The following example creates a component displaying `live` data. The component will detach
- * its change detector from the main change detector tree when the component's live property
- * is set to false.
- *
- * ```typescript
- * class DataProvider {
- * data = 1;
- *
- * constructor() {
- * setInterval(() => {
- * this.data = this.data * 2;
- * }, 500);
- * }
- * }
- *
- * \@Component({
- * selector: 'live-data',
- * inputs: ['live'],
- * template: 'Data: {{dataProvider.data}}'
- * })
- * class LiveData {
- * constructor(private ref: ChangeDetectorRef, private dataProvider: DataProvider) {}
- *
- * set live(value) {
- * if (value) {
- * this.ref.reattach();
- * } else {
- * this.ref.detach();
- * }
- * }
- * }
- *
- * \@Component({
- * selector: 'app',
- * providers: [DataProvider],
- * template: `
- * Live Update: <input type="checkbox" [(ngModel)]="live">
- * <live-data [live]="live"><live-data>
- * `,
- * })
- * class App {
- * live = true;
- * }
- * ```
- * @abstract
- * @return {?}
- */
- ChangeDetectorRef.prototype.reattach = function () { };
- return ChangeDetectorRef;
- }());
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * \@stable
- * @abstract
- */
- var ViewRef = (function (_super) {
- __extends$1(ViewRef, _super);
- function ViewRef() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- /**
- * Destroys the view and all of the data structures associated with it.
- * @abstract
- * @return {?}
- */
- ViewRef.prototype.destroy = function () { };
- /**
- * @abstract
- * @return {?}
- */
- ViewRef.prototype.destroyed = function () { };
- /**
- * @abstract
- * @param {?} callback
- * @return {?}
- */
- ViewRef.prototype.onDestroy = function (callback) { };
- return ViewRef;
- }(ChangeDetectorRef));
- /**
- * Represents an Angular View.
- *
- * <!-- TODO: move the next two paragraphs to the dev guide -->
- * A View is a fundamental building block of the application UI. It is the smallest grouping of
- * Elements which are created and destroyed together.
- *
- * Properties of elements in a View can change, but the structure (number and order) of elements in
- * a View cannot. Changing the structure of Elements can only be done by inserting, moving or
- * removing nested Views via a {\@link ViewContainerRef}. Each View can contain many View Containers.
- * <!-- /TODO -->
- *
- * ### Example
- *
- * Given this template...
- *
- * ```
- * Count: {{items.length}}
- * <ul>
- * <li *ngFor="let item of items">{{item}}</li>
- * </ul>
- * ```
- *
- * We have two {\@link TemplateRef}s:
- *
- * Outer {\@link TemplateRef}:
- * ```
- * Count: {{items.length}}
- * <ul>
- * <ng-template ngFor let-item [ngForOf]="items"></ng-template>
- * </ul>
- * ```
- *
- * Inner {\@link TemplateRef}:
- * ```
- * <li>{{item}}</li>
- * ```
- *
- * Notice that the original template is broken down into two separate {\@link TemplateRef}s.
- *
- * The outer/inner {\@link TemplateRef}s are then assembled into views like so:
- *
- * ```
- * <!-- ViewRef: outer-0 -->
- * Count: 2
- * <ul>
- * <ng-template view-container-ref></ng-template>
- * <!-- ViewRef: inner-1 --><li>first</li><!-- /ViewRef: inner-1 -->
- * <!-- ViewRef: inner-2 --><li>second</li><!-- /ViewRef: inner-2 -->
- * </ul>
- * <!-- /ViewRef: outer-0 -->
- * ```
- * \@experimental
- * @abstract
- */
- var EmbeddedViewRef = (function (_super) {
- __extends$1(EmbeddedViewRef, _super);
- function EmbeddedViewRef() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- /**
- * @abstract
- * @return {?}
- */
- EmbeddedViewRef.prototype.context = function () { };
- /**
- * @abstract
- * @return {?}
- */
- EmbeddedViewRef.prototype.rootNodes = function () { };
- return EmbeddedViewRef;
- }(ViewRef));
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- // Public API for compiler
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var EventListener = (function () {
- /**
- * @param {?} name
- * @param {?} callback
- */
- function EventListener(name, callback) {
- this.name = name;
- this.callback = callback;
- }
- return EventListener;
- }());
- /**
- * \@experimental All debugging apis are currently experimental.
- */
- var DebugNode = (function () {
- /**
- * @param {?} nativeNode
- * @param {?} parent
- * @param {?} _debugContext
- */
- function DebugNode(nativeNode, parent, _debugContext) {
- this._debugContext = _debugContext;
- this.nativeNode = nativeNode;
- if (parent && parent instanceof DebugElement) {
- parent.addChild(this);
- }
- else {
- this.parent = null;
- }
- this.listeners = [];
- }
- Object.defineProperty(DebugNode.prototype, "injector", {
- /**
- * @return {?}
- */
- get: function () { return this._debugContext.injector; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(DebugNode.prototype, "componentInstance", {
- /**
- * @return {?}
- */
- get: function () { return this._debugContext.component; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(DebugNode.prototype, "context", {
- /**
- * @return {?}
- */
- get: function () { return this._debugContext.context; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(DebugNode.prototype, "references", {
- /**
- * @return {?}
- */
- get: function () { return this._debugContext.references; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(DebugNode.prototype, "providerTokens", {
- /**
- * @return {?}
- */
- get: function () { return this._debugContext.providerTokens; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(DebugNode.prototype, "source", {
- /**
- * @deprecated since v4
- * @return {?}
- */
- get: function () { return 'Deprecated since v4'; },
- enumerable: true,
- configurable: true
- });
- return DebugNode;
- }());
- /**
- * \@experimental All debugging apis are currently experimental.
- */
- var DebugElement = (function (_super) {
- __extends$1(DebugElement, _super);
- /**
- * @param {?} nativeNode
- * @param {?} parent
- * @param {?} _debugContext
- */
- function DebugElement(nativeNode, parent, _debugContext) {
- var _this = _super.call(this, nativeNode, parent, _debugContext) || this;
- _this.properties = {};
- _this.attributes = {};
- _this.classes = {};
- _this.styles = {};
- _this.childNodes = [];
- _this.nativeElement = nativeNode;
- return _this;
- }
- /**
- * @param {?} child
- * @return {?}
- */
- DebugElement.prototype.addChild = function (child) {
- if (child) {
- this.childNodes.push(child);
- child.parent = this;
- }
- };
- /**
- * @param {?} child
- * @return {?}
- */
- DebugElement.prototype.removeChild = function (child) {
- var /** @type {?} */ childIndex = this.childNodes.indexOf(child);
- if (childIndex !== -1) {
- child.parent = null;
- this.childNodes.splice(childIndex, 1);
- }
- };
- /**
- * @param {?} child
- * @param {?} newChildren
- * @return {?}
- */
- DebugElement.prototype.insertChildrenAfter = function (child, newChildren) {
- var _this = this;
- var /** @type {?} */ siblingIndex = this.childNodes.indexOf(child);
- if (siblingIndex !== -1) {
- (_a = this.childNodes).splice.apply(_a, [siblingIndex + 1, 0].concat(newChildren));
- newChildren.forEach(function (c) {
- if (c.parent) {
- c.parent.removeChild(c);
- }
- c.parent = _this;
- });
- }
- var _a;
- };
- /**
- * @param {?} refChild
- * @param {?} newChild
- * @return {?}
- */
- DebugElement.prototype.insertBefore = function (refChild, newChild) {
- var /** @type {?} */ refIndex = this.childNodes.indexOf(refChild);
- if (refIndex === -1) {
- this.addChild(newChild);
- }
- else {
- if (newChild.parent) {
- newChild.parent.removeChild(newChild);
- }
- newChild.parent = this;
- this.childNodes.splice(refIndex, 0, newChild);
- }
- };
- /**
- * @param {?} predicate
- * @return {?}
- */
- DebugElement.prototype.query = function (predicate) {
- var /** @type {?} */ results = this.queryAll(predicate);
- return results[0] || null;
- };
- /**
- * @param {?} predicate
- * @return {?}
- */
- DebugElement.prototype.queryAll = function (predicate) {
- var /** @type {?} */ matches = [];
- _queryElementChildren(this, predicate, matches);
- return matches;
- };
- /**
- * @param {?} predicate
- * @return {?}
- */
- DebugElement.prototype.queryAllNodes = function (predicate) {
- var /** @type {?} */ matches = [];
- _queryNodeChildren(this, predicate, matches);
- return matches;
- };
- Object.defineProperty(DebugElement.prototype, "children", {
- /**
- * @return {?}
- */
- get: function () {
- return (this.childNodes.filter(function (node) { return node instanceof DebugElement; }));
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @param {?} eventName
- * @param {?} eventObj
- * @return {?}
- */
- DebugElement.prototype.triggerEventHandler = function (eventName, eventObj) {
- this.listeners.forEach(function (listener) {
- if (listener.name == eventName) {
- listener.callback(eventObj);
- }
- });
- };
- return DebugElement;
- }(DebugNode));
- /**
- * @param {?} element
- * @param {?} predicate
- * @param {?} matches
- * @return {?}
- */
- function _queryElementChildren(element, predicate, matches) {
- element.childNodes.forEach(function (node) {
- if (node instanceof DebugElement) {
- if (predicate(node)) {
- matches.push(node);
- }
- _queryElementChildren(node, predicate, matches);
- }
- });
- }
- /**
- * @param {?} parentNode
- * @param {?} predicate
- * @param {?} matches
- * @return {?}
- */
- function _queryNodeChildren(parentNode, predicate, matches) {
- if (parentNode instanceof DebugElement) {
- parentNode.childNodes.forEach(function (node) {
- if (predicate(node)) {
- matches.push(node);
- }
- if (node instanceof DebugElement) {
- _queryNodeChildren(node, predicate, matches);
- }
- });
- }
- }
- // Need to keep the nodes in a global Map so that multiple angular apps are supported.
- var _nativeNodeToDebugNode = new Map();
- /**
- * \@experimental
- * @param {?} nativeNode
- * @return {?}
- */
- function getDebugNode(nativeNode) {
- return _nativeNodeToDebugNode.get(nativeNode) || null;
- }
- /**
- * @return {?}
- */
- /**
- * @param {?} node
- * @return {?}
- */
- function indexDebugNode(node) {
- _nativeNodeToDebugNode.set(node.nativeNode, node);
- }
- /**
- * @param {?} node
- * @return {?}
- */
- function removeDebugNodeFromIndex(node) {
- _nativeNodeToDebugNode.delete(node.nativeNode);
- }
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * @param {?} a
- * @param {?} b
- * @return {?}
- */
- function devModeEqual(a, b) {
- var /** @type {?} */ isListLikeIterableA = isListLikeIterable(a);
- var /** @type {?} */ isListLikeIterableB = isListLikeIterable(b);
- if (isListLikeIterableA && isListLikeIterableB) {
- return areIterablesEqual(a, b, devModeEqual);
- }
- else {
- var /** @type {?} */ isAObject = a && (typeof a === 'object' || typeof a === 'function');
- var /** @type {?} */ isBObject = b && (typeof b === 'object' || typeof b === 'function');
- if (!isListLikeIterableA && isAObject && !isListLikeIterableB && isBObject) {
- return true;
- }
- else {
- return looseIdentical(a, b);
- }
- }
- }
- /**
- * Indicates that the result of a {\@link Pipe} transformation has changed even though the
- * reference
- * has not changed.
- *
- * The wrapped value will be unwrapped by change detection, and the unwrapped value will be stored.
- *
- * Example:
- *
- * ```
- * if (this._latestValue === this._latestReturnedValue) {
- * return this._latestReturnedValue;
- * } else {
- * this._latestReturnedValue = this._latestValue;
- * return WrappedValue.wrap(this._latestValue); // this will force update
- * }
- * ```
- * \@stable
- */
- var WrappedValue = (function () {
- /**
- * @param {?} wrapped
- */
- function WrappedValue(wrapped) {
- this.wrapped = wrapped;
- }
- /**
- * @param {?} value
- * @return {?}
- */
- WrappedValue.wrap = function (value) { return new WrappedValue(value); };
- return WrappedValue;
- }());
- /**
- * Represents a basic change from a previous to a new value.
- * \@stable
- */
- var SimpleChange = (function () {
- /**
- * @param {?} previousValue
- * @param {?} currentValue
- * @param {?} firstChange
- */
- function SimpleChange(previousValue, currentValue, firstChange) {
- this.previousValue = previousValue;
- this.currentValue = currentValue;
- this.firstChange = firstChange;
- }
- /**
- * Check whether the new value is the first value assigned.
- * @return {?}
- */
- SimpleChange.prototype.isFirstChange = function () { return this.firstChange; };
- return SimpleChange;
- }());
- /**
- * @param {?} obj
- * @return {?}
- */
- function isListLikeIterable(obj) {
- if (!isJsObject(obj))
- return false;
- return Array.isArray(obj) ||
- (!(obj instanceof Map) &&
- getSymbolIterator() in obj); // JS Iterable have a Symbol.iterator prop
- }
- /**
- * @param {?} a
- * @param {?} b
- * @param {?} comparator
- * @return {?}
- */
- function areIterablesEqual(a, b, comparator) {
- var /** @type {?} */ iterator1 = a[getSymbolIterator()]();
- var /** @type {?} */ iterator2 = b[getSymbolIterator()]();
- while (true) {
- var /** @type {?} */ item1 = iterator1.next();
- var /** @type {?} */ item2 = iterator2.next();
- if (item1.done && item2.done)
- return true;
- if (item1.done || item2.done)
- return false;
- if (!comparator(item1.value, item2.value))
- return false;
- }
- }
- /**
- * @param {?} obj
- * @param {?} fn
- * @return {?}
- */
- function iterateListLike(obj, fn) {
- if (Array.isArray(obj)) {
- for (var /** @type {?} */ i = 0; i < obj.length; i++) {
- fn(obj[i]);
- }
- }
- else {
- var /** @type {?} */ iterator = obj[getSymbolIterator()]();
- var /** @type {?} */ item = void 0;
- while (!((item = iterator.next()).done)) {
- fn(item.value);
- }
- }
- }
- /**
- * @param {?} o
- * @return {?}
- */
- function isJsObject(o) {
- return o !== null && (typeof o === 'function' || typeof o === 'object');
- }
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var DefaultIterableDifferFactory = (function () {
- function DefaultIterableDifferFactory() {
- }
- /**
- * @param {?} obj
- * @return {?}
- */
- DefaultIterableDifferFactory.prototype.supports = function (obj) { return isListLikeIterable(obj); };
- /**
- * @deprecated v4.0.0 - ChangeDetectorRef is not used and is no longer a parameter
- * @template V
- * @param {?=} cdRefOrTrackBy
- * @param {?=} trackByFn
- * @return {?}
- */
- DefaultIterableDifferFactory.prototype.create = function (cdRefOrTrackBy, trackByFn) {
- return new DefaultIterableDiffer(trackByFn || (cdRefOrTrackBy));
- };
- return DefaultIterableDifferFactory;
- }());
- var trackByIdentity = function (index, item) { return item; };
- /**
- * @deprecated v4.0.0 - Should not be part of public API.
- */
- var DefaultIterableDiffer = (function () {
- /**
- * @param {?=} trackByFn
- */
- function DefaultIterableDiffer(trackByFn) {
- this._length = 0;
- this._collection = null;
- this._linkedRecords = null;
- this._unlinkedRecords = null;
- this._previousItHead = null;
- this._itHead = null;
- this._itTail = null;
- this._additionsHead = null;
- this._additionsTail = null;
- this._movesHead = null;
- this._movesTail = null;
- this._removalsHead = null;
- this._removalsTail = null;
- this._identityChangesHead = null;
- this._identityChangesTail = null;
- this._trackByFn = trackByFn || trackByIdentity;
- }
- Object.defineProperty(DefaultIterableDiffer.prototype, "collection", {
- /**
- * @return {?}
- */
- get: function () { return this._collection; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(DefaultIterableDiffer.prototype, "length", {
- /**
- * @return {?}
- */
- get: function () { return this._length; },
- enumerable: true,
- configurable: true
- });
- /**
- * @param {?} fn
- * @return {?}
- */
- DefaultIterableDiffer.prototype.forEachItem = function (fn) {
- var /** @type {?} */ record;
- for (record = this._itHead; record !== null; record = record._next) {
- fn(record);
- }
- };
- /**
- * @param {?} fn
- * @return {?}
- */
- DefaultIterableDiffer.prototype.forEachOperation = function (fn) {
- var /** @type {?} */ nextIt = this._itHead;
- var /** @type {?} */ nextRemove = this._removalsHead;
- var /** @type {?} */ addRemoveOffset = 0;
- var /** @type {?} */ moveOffsets = null;
- while (nextIt || nextRemove) {
- // Figure out which is the next record to process
- // Order: remove, add, move
- var /** @type {?} */ record = !nextRemove ||
- nextIt && ((nextIt.currentIndex)) <
- getPreviousIndex(nextRemove, addRemoveOffset, moveOffsets) ? ((nextIt)) :
- nextRemove;
- var /** @type {?} */ adjPreviousIndex = getPreviousIndex(record, addRemoveOffset, moveOffsets);
- var /** @type {?} */ currentIndex = record.currentIndex;
- // consume the item, and adjust the addRemoveOffset and update moveDistance if necessary
- if (record === nextRemove) {
- addRemoveOffset--;
- nextRemove = nextRemove._nextRemoved;
- }
- else {
- nextIt = ((nextIt))._next;
- if (record.previousIndex == null) {
- addRemoveOffset++;
- }
- else {
- // INVARIANT: currentIndex < previousIndex
- if (!moveOffsets)
- moveOffsets = [];
- var /** @type {?} */ localMovePreviousIndex = adjPreviousIndex - addRemoveOffset;
- var /** @type {?} */ localCurrentIndex = ((currentIndex)) - addRemoveOffset;
- if (localMovePreviousIndex != localCurrentIndex) {
- for (var /** @type {?} */ i = 0; i < localMovePreviousIndex; i++) {
- var /** @type {?} */ offset = i < moveOffsets.length ? moveOffsets[i] : (moveOffsets[i] = 0);
- var /** @type {?} */ index = offset + i;
- if (localCurrentIndex <= index && index < localMovePreviousIndex) {
- moveOffsets[i] = offset + 1;
- }
- }
- var /** @type {?} */ previousIndex = record.previousIndex;
- moveOffsets[previousIndex] = localCurrentIndex - localMovePreviousIndex;
- }
- }
- }
- if (adjPreviousIndex !== currentIndex) {
- fn(record, adjPreviousIndex, currentIndex);
- }
- }
- };
- /**
- * @param {?} fn
- * @return {?}
- */
- DefaultIterableDiffer.prototype.forEachPreviousItem = function (fn) {
- var /** @type {?} */ record;
- for (record = this._previousItHead; record !== null; record = record._nextPrevious) {
- fn(record);
- }
- };
- /**
- * @param {?} fn
- * @return {?}
- */
- DefaultIterableDiffer.prototype.forEachAddedItem = function (fn) {
- var /** @type {?} */ record;
- for (record = this._additionsHead; record !== null; record = record._nextAdded) {
- fn(record);
- }
- };
- /**
- * @param {?} fn
- * @return {?}
- */
- DefaultIterableDiffer.prototype.forEachMovedItem = function (fn) {
- var /** @type {?} */ record;
- for (record = this._movesHead; record !== null; record = record._nextMoved) {
- fn(record);
- }
- };
- /**
- * @param {?} fn
- * @return {?}
- */
- DefaultIterableDiffer.prototype.forEachRemovedItem = function (fn) {
- var /** @type {?} */ record;
- for (record = this._removalsHead; record !== null; record = record._nextRemoved) {
- fn(record);
- }
- };
- /**
- * @param {?} fn
- * @return {?}
- */
- DefaultIterableDiffer.prototype.forEachIdentityChange = function (fn) {
- var /** @type {?} */ record;
- for (record = this._identityChangesHead; record !== null; record = record._nextIdentityChange) {
- fn(record);
- }
- };
- /**
- * @param {?} collection
- * @return {?}
- */
- DefaultIterableDiffer.prototype.diff = function (collection) {
- if (collection == null)
- collection = [];
- if (!isListLikeIterable(collection)) {
- throw new Error("Error trying to diff '" + stringify(collection) + "'. Only arrays and iterables are allowed");
- }
- if (this.check(collection)) {
- return this;
- }
- else {
- return null;
- }
- };
- /**
- * @return {?}
- */
- DefaultIterableDiffer.prototype.onDestroy = function () { };
- /**
- * @param {?} collection
- * @return {?}
- */
- DefaultIterableDiffer.prototype.check = function (collection) {
- var _this = this;
- this._reset();
- var /** @type {?} */ record = this._itHead;
- var /** @type {?} */ mayBeDirty = false;
- var /** @type {?} */ index;
- var /** @type {?} */ item;
- var /** @type {?} */ itemTrackBy;
- if (Array.isArray(collection)) {
- this._length = collection.length;
- for (var /** @type {?} */ index_1 = 0; index_1 < this._length; index_1++) {
- item = collection[index_1];
- itemTrackBy = this._trackByFn(index_1, item);
- if (record === null || !looseIdentical(record.trackById, itemTrackBy)) {
- record = this._mismatch(record, item, itemTrackBy, index_1);
- mayBeDirty = true;
- }
- else {
- if (mayBeDirty) {
- // TODO(misko): can we limit this to duplicates only?
- record = this._verifyReinsertion(record, item, itemTrackBy, index_1);
- }
- if (!looseIdentical(record.item, item))
- this._addIdentityChange(record, item);
- }
- record = record._next;
- }
- }
- else {
- index = 0;
- iterateListLike(collection, function (item) {
- itemTrackBy = _this._trackByFn(index, item);
- if (record === null || !looseIdentical(record.trackById, itemTrackBy)) {
- record = _this._mismatch(record, item, itemTrackBy, index);
- mayBeDirty = true;
- }
- else {
- if (mayBeDirty) {
- // TODO(misko): can we limit this to duplicates only?
- record = _this._verifyReinsertion(record, item, itemTrackBy, index);
- }
- if (!looseIdentical(record.item, item))
- _this._addIdentityChange(record, item);
- }
- record = record._next;
- index++;
- });
- this._length = index;
- }
- this._truncate(record);
- this._collection = collection;
- return this.isDirty;
- };
- Object.defineProperty(DefaultIterableDiffer.prototype, "isDirty", {
- /**
- * @return {?}
- */
- get: function () {
- return this._additionsHead !== null || this._movesHead !== null ||
- this._removalsHead !== null || this._identityChangesHead !== null;
- },
- enumerable: true,
- configurable: true
- });
- /**
- * Reset the state of the change objects to show no changes. This means set previousKey to
- * currentKey, and clear all of the queues (additions, moves, removals).
- * Set the previousIndexes of moved and added items to their currentIndexes
- * Reset the list of additions, moves and removals
- *
- * \@internal
- * @return {?}
- */
- DefaultIterableDiffer.prototype._reset = function () {
- if (this.isDirty) {
- var /** @type {?} */ record = void 0;
- var /** @type {?} */ nextRecord = void 0;
- for (record = this._previousItHead = this._itHead; record !== null; record = record._next) {
- record._nextPrevious = record._next;
- }
- for (record = this._additionsHead; record !== null; record = record._nextAdded) {
- record.previousIndex = record.currentIndex;
- }
- this._additionsHead = this._additionsTail = null;
- for (record = this._movesHead; record !== null; record = nextRecord) {
- record.previousIndex = record.currentIndex;
- nextRecord = record._nextMoved;
- }
- this._movesHead = this._movesTail = null;
- this._removalsHead = this._removalsTail = null;
- this._identityChangesHead = this._identityChangesTail = null;
- // todo(vicb) when assert gets supported
- // assert(!this.isDirty);
- }
- };
- /**
- * This is the core function which handles differences between collections.
- *
- * - `record` is the record which we saw at this position last time. If null then it is a new
- * item.
- * - `item` is the current item in the collection
- * - `index` is the position of the item in the collection
- *
- * \@internal
- * @param {?} record
- * @param {?} item
- * @param {?} itemTrackBy
- * @param {?} index
- * @return {?}
- */
- DefaultIterableDiffer.prototype._mismatch = function (record, item, itemTrackBy, index) {
- // The previous record after which we will append the current one.
- var /** @type {?} */ previousRecord;
- if (record === null) {
- previousRecord = this._itTail;
- }
- else {
- previousRecord = record._prev;
- // Remove the record from the collection since we know it does not match the item.
- this._remove(record);
- }
- // Attempt to see if we have seen the item before.
- record = this._linkedRecords === null ? null : this._linkedRecords.get(itemTrackBy, index);
- if (record !== null) {
- // We have seen this before, we need to move it forward in the collection.
- // But first we need to check if identity changed, so we can update in view if necessary
- if (!looseIdentical(record.item, item))
- this._addIdentityChange(record, item);
- this._moveAfter(record, previousRecord, index);
- }
- else {
- // Never seen it, check evicted list.
- record = this._unlinkedRecords === null ? null : this._unlinkedRecords.get(itemTrackBy, null);
- if (record !== null) {
- // It is an item which we have evicted earlier: reinsert it back into the list.
- // But first we need to check if identity changed, so we can update in view if necessary
- if (!looseIdentical(record.item, item))
- this._addIdentityChange(record, item);
- this._reinsertAfter(record, previousRecord, index);
- }
- else {
- // It is a new item: add it.
- record =
- this._addAfter(new IterableChangeRecord_(item, itemTrackBy), previousRecord, index);
- }
- }
- return record;
- };
- /**
- * This check is only needed if an array contains duplicates. (Short circuit of nothing dirty)
- *
- * Use case: `[a, a]` => `[b, a, a]`
- *
- * If we did not have this check then the insertion of `b` would:
- * 1) evict first `a`
- * 2) insert `b` at `0` index.
- * 3) leave `a` at index `1` as is. <-- this is wrong!
- * 3) reinsert `a` at index 2. <-- this is wrong!
- *
- * The correct behavior is:
- * 1) evict first `a`
- * 2) insert `b` at `0` index.
- * 3) reinsert `a` at index 1.
- * 3) move `a` at from `1` to `2`.
- *
- *
- * Double check that we have not evicted a duplicate item. We need to check if the item type may
- * have already been removed:
- * The insertion of b will evict the first 'a'. If we don't reinsert it now it will be reinserted
- * at the end. Which will show up as the two 'a's switching position. This is incorrect, since a
- * better way to think of it is as insert of 'b' rather then switch 'a' with 'b' and then add 'a'
- * at the end.
- *
- * \@internal
- * @param {?} record
- * @param {?} item
- * @param {?} itemTrackBy
- * @param {?} index
- * @return {?}
- */
- DefaultIterableDiffer.prototype._verifyReinsertion = function (record, item, itemTrackBy, index) {
- var /** @type {?} */ reinsertRecord = this._unlinkedRecords === null ? null : this._unlinkedRecords.get(itemTrackBy, null);
- if (reinsertRecord !== null) {
- record = this._reinsertAfter(reinsertRecord, /** @type {?} */ ((record._prev)), index);
- }
- else if (record.currentIndex != index) {
- record.currentIndex = index;
- this._addToMoves(record, index);
- }
- return record;
- };
- /**
- * Get rid of any excess {\@link IterableChangeRecord_}s from the previous collection
- *
- * - `record` The first excess {\@link IterableChangeRecord_}.
- *
- * \@internal
- * @param {?} record
- * @return {?}
- */
- DefaultIterableDiffer.prototype._truncate = function (record) {
- // Anything after that needs to be removed;
- while (record !== null) {
- var /** @type {?} */ nextRecord = record._next;
- this._addToRemovals(this._unlink(record));
- record = nextRecord;
- }
- if (this._unlinkedRecords !== null) {
- this._unlinkedRecords.clear();
- }
- if (this._additionsTail !== null) {
- this._additionsTail._nextAdded = null;
- }
- if (this._movesTail !== null) {
- this._movesTail._nextMoved = null;
- }
- if (this._itTail !== null) {
- this._itTail._next = null;
- }
- if (this._removalsTail !== null) {
- this._removalsTail._nextRemoved = null;
- }
- if (this._identityChangesTail !== null) {
- this._identityChangesTail._nextIdentityChange = null;
- }
- };
- /**
- * \@internal
- * @param {?} record
- * @param {?} prevRecord
- * @param {?} index
- * @return {?}
- */
- DefaultIterableDiffer.prototype._reinsertAfter = function (record, prevRecord, index) {
- if (this._unlinkedRecords !== null) {
- this._unlinkedRecords.remove(record);
- }
- var /** @type {?} */ prev = record._prevRemoved;
- var /** @type {?} */ next = record._nextRemoved;
- if (prev === null) {
- this._removalsHead = next;
- }
- else {
- prev._nextRemoved = next;
- }
- if (next === null) {
- this._removalsTail = prev;
- }
- else {
- next._prevRemoved = prev;
- }
- this._insertAfter(record, prevRecord, index);
- this._addToMoves(record, index);
- return record;
- };
- /**
- * \@internal
- * @param {?} record
- * @param {?} prevRecord
- * @param {?} index
- * @return {?}
- */
- DefaultIterableDiffer.prototype._moveAfter = function (record, prevRecord, index) {
- this._unlink(record);
- this._insertAfter(record, prevRecord, index);
- this._addToMoves(record, index);
- return record;
- };
- /**
- * \@internal
- * @param {?} record
- * @param {?} prevRecord
- * @param {?} index
- * @return {?}
- */
- DefaultIterableDiffer.prototype._addAfter = function (record, prevRecord, index) {
- this._insertAfter(record, prevRecord, index);
- if (this._additionsTail === null) {
- // todo(vicb)
- // assert(this._additionsHead === null);
- this._additionsTail = this._additionsHead = record;
- }
- else {
- // todo(vicb)
- // assert(_additionsTail._nextAdded === null);
- // assert(record._nextAdded === null);
- this._additionsTail = this._additionsTail._nextAdded = record;
- }
- return record;
- };
- /**
- * \@internal
- * @param {?} record
- * @param {?} prevRecord
- * @param {?} index
- * @return {?}
- */
- DefaultIterableDiffer.prototype._insertAfter = function (record, prevRecord, index) {
- // todo(vicb)
- // assert(record != prevRecord);
- // assert(record._next === null);
- // assert(record._prev === null);
- var /** @type {?} */ next = prevRecord === null ? this._itHead : prevRecord._next;
- // todo(vicb)
- // assert(next != record);
- // assert(prevRecord != record);
- record._next = next;
- record._prev = prevRecord;
- if (next === null) {
- this._itTail = record;
- }
- else {
- next._prev = record;
- }
- if (prevRecord === null) {
- this._itHead = record;
- }
- else {
- prevRecord._next = record;
- }
- if (this._linkedRecords === null) {
- this._linkedRecords = new _DuplicateMap();
- }
- this._linkedRecords.put(record);
- record.currentIndex = index;
- return record;
- };
- /**
- * \@internal
- * @param {?} record
- * @return {?}
- */
- DefaultIterableDiffer.prototype._remove = function (record) {
- return this._addToRemovals(this._unlink(record));
- };
- /**
- * \@internal
- * @param {?} record
- * @return {?}
- */
- DefaultIterableDiffer.prototype._unlink = function (record) {
- if (this._linkedRecords !== null) {
- this._linkedRecords.remove(record);
- }
- var /** @type {?} */ prev = record._prev;
- var /** @type {?} */ next = record._next;
- // todo(vicb)
- // assert((record._prev = null) === null);
- // assert((record._next = null) === null);
- if (prev === null) {
- this._itHead = next;
- }
- else {
- prev._next = next;
- }
- if (next === null) {
- this._itTail = prev;
- }
- else {
- next._prev = prev;
- }
- return record;
- };
- /**
- * \@internal
- * @param {?} record
- * @param {?} toIndex
- * @return {?}
- */
- DefaultIterableDiffer.prototype._addToMoves = function (record, toIndex) {
- // todo(vicb)
- // assert(record._nextMoved === null);
- if (record.previousIndex === toIndex) {
- return record;
- }
- if (this._movesTail === null) {
- // todo(vicb)
- // assert(_movesHead === null);
- this._movesTail = this._movesHead = record;
- }
- else {
- // todo(vicb)
- // assert(_movesTail._nextMoved === null);
- this._movesTail = this._movesTail._nextMoved = record;
- }
- return record;
- };
- /**
- * @param {?} record
- * @return {?}
- */
- DefaultIterableDiffer.prototype._addToRemovals = function (record) {
- if (this._unlinkedRecords === null) {
- this._unlinkedRecords = new _DuplicateMap();
- }
- this._unlinkedRecords.put(record);
- record.currentIndex = null;
- record._nextRemoved = null;
- if (this._removalsTail === null) {
- // todo(vicb)
- // assert(_removalsHead === null);
- this._removalsTail = this._removalsHead = record;
- record._prevRemoved = null;
- }
- else {
- // todo(vicb)
- // assert(_removalsTail._nextRemoved === null);
- // assert(record._nextRemoved === null);
- record._prevRemoved = this._removalsTail;
- this._removalsTail = this._removalsTail._nextRemoved = record;
- }
- return record;
- };
- /**
- * \@internal
- * @param {?} record
- * @param {?} item
- * @return {?}
- */
- DefaultIterableDiffer.prototype._addIdentityChange = function (record, item) {
- record.item = item;
- if (this._identityChangesTail === null) {
- this._identityChangesTail = this._identityChangesHead = record;
- }
- else {
- this._identityChangesTail = this._identityChangesTail._nextIdentityChange = record;
- }
- return record;
- };
- /**
- * @return {?}
- */
- DefaultIterableDiffer.prototype.toString = function () {
- var /** @type {?} */ list = [];
- this.forEachItem(function (record) { return list.push(record); });
- var /** @type {?} */ previous = [];
- this.forEachPreviousItem(function (record) { return previous.push(record); });
- var /** @type {?} */ additions = [];
- this.forEachAddedItem(function (record) { return additions.push(record); });
- var /** @type {?} */ moves = [];
- this.forEachMovedItem(function (record) { return moves.push(record); });
- var /** @type {?} */ removals = [];
- this.forEachRemovedItem(function (record) { return removals.push(record); });
- var /** @type {?} */ identityChanges = [];
- this.forEachIdentityChange(function (record) { return identityChanges.push(record); });
- return 'collection: ' + list.join(', ') + '\n' +
- 'previous: ' + previous.join(', ') + '\n' +
- 'additions: ' + additions.join(', ') + '\n' +
- 'moves: ' + moves.join(', ') + '\n' +
- 'removals: ' + removals.join(', ') + '\n' +
- 'identityChanges: ' + identityChanges.join(', ') + '\n';
- };
- return DefaultIterableDiffer;
- }());
- /**
- * \@stable
- */
- var IterableChangeRecord_ = (function () {
- /**
- * @param {?} item
- * @param {?} trackById
- */
- function IterableChangeRecord_(item, trackById) {
- this.item = item;
- this.trackById = trackById;
- this.currentIndex = null;
- this.previousIndex = null;
- /**
- * \@internal
- */
- this._nextPrevious = null;
- /**
- * \@internal
- */
- this._prev = null;
- /**
- * \@internal
- */
- this._next = null;
- /**
- * \@internal
- */
- this._prevDup = null;
- /**
- * \@internal
- */
- this._nextDup = null;
- /**
- * \@internal
- */
- this._prevRemoved = null;
- /**
- * \@internal
- */
- this._nextRemoved = null;
- /**
- * \@internal
- */
- this._nextAdded = null;
- /**
- * \@internal
- */
- this._nextMoved = null;
- /**
- * \@internal
- */
- this._nextIdentityChange = null;
- }
- /**
- * @return {?}
- */
- IterableChangeRecord_.prototype.toString = function () {
- return this.previousIndex === this.currentIndex ? stringify(this.item) :
- stringify(this.item) + '[' +
- stringify(this.previousIndex) + '->' + stringify(this.currentIndex) + ']';
- };
- return IterableChangeRecord_;
- }());
- var _DuplicateItemRecordList = (function () {
- function _DuplicateItemRecordList() {
- /**
- * \@internal
- */
- this._head = null;
- /**
- * \@internal
- */
- this._tail = null;
- }
- /**
- * Append the record to the list of duplicates.
- *
- * Note: by design all records in the list of duplicates hold the same value in record.item.
- * @param {?} record
- * @return {?}
- */
- _DuplicateItemRecordList.prototype.add = function (record) {
- if (this._head === null) {
- this._head = this._tail = record;
- record._nextDup = null;
- record._prevDup = null;
- }
- else {
- ((
- // todo(vicb)
- // assert(record.item == _head.item ||
- // record.item is num && record.item.isNaN && _head.item is num && _head.item.isNaN);
- this._tail))._nextDup = record;
- record._prevDup = this._tail;
- record._nextDup = null;
- this._tail = record;
- }
- };
- /**
- * @param {?} trackById
- * @param {?} atOrAfterIndex
- * @return {?}
- */
- _DuplicateItemRecordList.prototype.get = function (trackById, atOrAfterIndex) {
- var /** @type {?} */ record;
- for (record = this._head; record !== null; record = record._nextDup) {
- if ((atOrAfterIndex === null || atOrAfterIndex <= ((record.currentIndex))) &&
- looseIdentical(record.trackById, trackById)) {
- return record;
- }
- }
- return null;
- };
- /**
- * Remove one {\@link IterableChangeRecord_} from the list of duplicates.
- *
- * Returns whether the list of duplicates is empty.
- * @param {?} record
- * @return {?}
- */
- _DuplicateItemRecordList.prototype.remove = function (record) {
- // todo(vicb)
- // assert(() {
- // // verify that the record being removed is in the list.
- // for (IterableChangeRecord_ cursor = _head; cursor != null; cursor = cursor._nextDup) {
- // if (identical(cursor, record)) return true;
- // }
- // return false;
- //});
- var /** @type {?} */ prev = record._prevDup;
- var /** @type {?} */ next = record._nextDup;
- if (prev === null) {
- this._head = next;
- }
- else {
- prev._nextDup = next;
- }
- if (next === null) {
- this._tail = prev;
- }
- else {
- next._prevDup = prev;
- }
- return this._head === null;
- };
- return _DuplicateItemRecordList;
- }());
- var _DuplicateMap = (function () {
- function _DuplicateMap() {
- this.map = new Map();
- }
- /**
- * @param {?} record
- * @return {?}
- */
- _DuplicateMap.prototype.put = function (record) {
- var /** @type {?} */ key = record.trackById;
- var /** @type {?} */ duplicates = this.map.get(key);
- if (!duplicates) {
- duplicates = new _DuplicateItemRecordList();
- this.map.set(key, duplicates);
- }
- duplicates.add(record);
- };
- /**
- * Retrieve the `value` using key. Because the IterableChangeRecord_ value may be one which we
- * have already iterated over, we use the `atOrAfterIndex` to pretend it is not there.
- *
- * Use case: `[a, b, c, a, a]` if we are at index `3` which is the second `a` then asking if we
- * have any more `a`s needs to return the second `a`.
- * @param {?} trackById
- * @param {?} atOrAfterIndex
- * @return {?}
- */
- _DuplicateMap.prototype.get = function (trackById, atOrAfterIndex) {
- var /** @type {?} */ key = trackById;
- var /** @type {?} */ recordList = this.map.get(key);
- return recordList ? recordList.get(trackById, atOrAfterIndex) : null;
- };
- /**
- * Removes a {\@link IterableChangeRecord_} from the list of duplicates.
- *
- * The list of duplicates also is removed from the map if it gets empty.
- * @param {?} record
- * @return {?}
- */
- _DuplicateMap.prototype.remove = function (record) {
- var /** @type {?} */ key = record.trackById;
- var /** @type {?} */ recordList = ((this.map.get(key)));
- // Remove the list of duplicates when it gets empty
- if (recordList.remove(record)) {
- this.map.delete(key);
- }
- return record;
- };
- Object.defineProperty(_DuplicateMap.prototype, "isEmpty", {
- /**
- * @return {?}
- */
- get: function () { return this.map.size === 0; },
- enumerable: true,
- configurable: true
- });
- /**
- * @return {?}
- */
- _DuplicateMap.prototype.clear = function () { this.map.clear(); };
- /**
- * @return {?}
- */
- _DuplicateMap.prototype.toString = function () { return '_DuplicateMap(' + stringify(this.map) + ')'; };
- return _DuplicateMap;
- }());
- /**
- * @param {?} item
- * @param {?} addRemoveOffset
- * @param {?} moveOffsets
- * @return {?}
- */
- function getPreviousIndex(item, addRemoveOffset, moveOffsets) {
- var /** @type {?} */ previousIndex = item.previousIndex;
- if (previousIndex === null)
- return previousIndex;
- var /** @type {?} */ moveOffset = 0;
- if (moveOffsets && previousIndex < moveOffsets.length) {
- moveOffset = moveOffsets[previousIndex];
- }
- return previousIndex + addRemoveOffset + moveOffset;
- }
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var DefaultKeyValueDifferFactory = (function () {
- function DefaultKeyValueDifferFactory() {
- }
- /**
- * @param {?} obj
- * @return {?}
- */
- DefaultKeyValueDifferFactory.prototype.supports = function (obj) { return obj instanceof Map || isJsObject(obj); };
- /**
- * @deprecated v4.0.0 - ChangeDetectorRef is not used and is no longer a parameter
- * @template K, V
- * @param {?=} cd
- * @return {?}
- */
- DefaultKeyValueDifferFactory.prototype.create = function (cd) {
- return new DefaultKeyValueDiffer();
- };
- return DefaultKeyValueDifferFactory;
- }());
- var DefaultKeyValueDiffer = (function () {
- function DefaultKeyValueDiffer() {
- this._records = new Map();
- this._mapHead = null;
- this._appendAfter = null;
- this._previousMapHead = null;
- this._changesHead = null;
- this._changesTail = null;
- this._additionsHead = null;
- this._additionsTail = null;
- this._removalsHead = null;
- this._removalsTail = null;
- }
- Object.defineProperty(DefaultKeyValueDiffer.prototype, "isDirty", {
- /**
- * @return {?}
- */
- get: function () {
- return this._additionsHead !== null || this._changesHead !== null ||
- this._removalsHead !== null;
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @param {?} fn
- * @return {?}
- */
- DefaultKeyValueDiffer.prototype.forEachItem = function (fn) {
- var /** @type {?} */ record;
- for (record = this._mapHead; record !== null; record = record._next) {
- fn(record);
- }
- };
- /**
- * @param {?} fn
- * @return {?}
- */
- DefaultKeyValueDiffer.prototype.forEachPreviousItem = function (fn) {
- var /** @type {?} */ record;
- for (record = this._previousMapHead; record !== null; record = record._nextPrevious) {
- fn(record);
- }
- };
- /**
- * @param {?} fn
- * @return {?}
- */
- DefaultKeyValueDiffer.prototype.forEachChangedItem = function (fn) {
- var /** @type {?} */ record;
- for (record = this._changesHead; record !== null; record = record._nextChanged) {
- fn(record);
- }
- };
- /**
- * @param {?} fn
- * @return {?}
- */
- DefaultKeyValueDiffer.prototype.forEachAddedItem = function (fn) {
- var /** @type {?} */ record;
- for (record = this._additionsHead; record !== null; record = record._nextAdded) {
- fn(record);
- }
- };
- /**
- * @param {?} fn
- * @return {?}
- */
- DefaultKeyValueDiffer.prototype.forEachRemovedItem = function (fn) {
- var /** @type {?} */ record;
- for (record = this._removalsHead; record !== null; record = record._nextRemoved) {
- fn(record);
- }
- };
- /**
- * @param {?=} map
- * @return {?}
- */
- DefaultKeyValueDiffer.prototype.diff = function (map) {
- if (!map) {
- map = new Map();
- }
- else if (!(map instanceof Map || isJsObject(map))) {
- throw new Error("Error trying to diff '" + stringify(map) + "'. Only maps and objects are allowed");
- }
- return this.check(map) ? this : null;
- };
- /**
- * @return {?}
- */
- DefaultKeyValueDiffer.prototype.onDestroy = function () { };
- /**
- * Check the current state of the map vs the previous.
- * The algorithm is optimised for when the keys do no change.
- * @param {?} map
- * @return {?}
- */
- DefaultKeyValueDiffer.prototype.check = function (map) {
- var _this = this;
- this._reset();
- var /** @type {?} */ insertBefore = this._mapHead;
- this._appendAfter = null;
- this._forEach(map, function (value, key) {
- if (insertBefore && insertBefore.key === key) {
- _this._maybeAddToChanges(insertBefore, value);
- _this._appendAfter = insertBefore;
- insertBefore = insertBefore._next;
- }
- else {
- var /** @type {?} */ record = _this._getOrCreateRecordForKey(key, value);
- insertBefore = _this._insertBeforeOrAppend(insertBefore, record);
- }
- });
- // Items remaining at the end of the list have been deleted
- if (insertBefore) {
- if (insertBefore._prev) {
- insertBefore._prev._next = null;
- }
- this._removalsHead = insertBefore;
- for (var /** @type {?} */ record = insertBefore; record !== null; record = record._nextRemoved) {
- if (record === this._mapHead) {
- this._mapHead = null;
- }
- this._records.delete(record.key);
- record._nextRemoved = record._next;
- record.previousValue = record.currentValue;
- record.currentValue = null;
- record._prev = null;
- record._next = null;
- }
- }
- // Make sure tails have no next records from previous runs
- if (this._changesTail)
- this._changesTail._nextChanged = null;
- if (this._additionsTail)
- this._additionsTail._nextAdded = null;
- return this.isDirty;
- };
- /**
- * Inserts a record before `before` or append at the end of the list when `before` is null.
- *
- * Notes:
- * - This method appends at `this._appendAfter`,
- * - This method updates `this._appendAfter`,
- * - The return value is the new value for the insertion pointer.
- * @param {?} before
- * @param {?} record
- * @return {?}
- */
- DefaultKeyValueDiffer.prototype._insertBeforeOrAppend = function (before, record) {
- if (before) {
- var /** @type {?} */ prev = before._prev;
- record._next = before;
- record._prev = prev;
- before._prev = record;
- if (prev) {
- prev._next = record;
- }
- if (before === this._mapHead) {
- this._mapHead = record;
- }
- this._appendAfter = before;
- return before;
- }
- if (this._appendAfter) {
- this._appendAfter._next = record;
- record._prev = this._appendAfter;
- }
- else {
- this._mapHead = record;
- }
- this._appendAfter = record;
- return null;
- };
- /**
- * @param {?} key
- * @param {?} value
- * @return {?}
- */
- DefaultKeyValueDiffer.prototype._getOrCreateRecordForKey = function (key, value) {
- if (this._records.has(key)) {
- var /** @type {?} */ record_1 = ((this._records.get(key)));
- this._maybeAddToChanges(record_1, value);
- var /** @type {?} */ prev = record_1._prev;
- var /** @type {?} */ next = record_1._next;
- if (prev) {
- prev._next = next;
- }
- if (next) {
- next._prev = prev;
- }
- record_1._next = null;
- record_1._prev = null;
- return record_1;
- }
- var /** @type {?} */ record = new KeyValueChangeRecord_(key);
- this._records.set(key, record);
- record.currentValue = value;
- this._addToAdditions(record);
- return record;
- };
- /**
- * \@internal
- * @return {?}
- */
- DefaultKeyValueDiffer.prototype._reset = function () {
- if (this.isDirty) {
- var /** @type {?} */ record = void 0;
- // let `_previousMapHead` contain the state of the map before the changes
- this._previousMapHead = this._mapHead;
- for (record = this._previousMapHead; record !== null; record = record._next) {
- record._nextPrevious = record._next;
- }
- // Update `record.previousValue` with the value of the item before the changes
- // We need to update all changed items (that's those which have been added and changed)
- for (record = this._changesHead; record !== null; record = record._nextChanged) {
- record.previousValue = record.currentValue;
- }
- for (record = this._additionsHead; record != null; record = record._nextAdded) {
- record.previousValue = record.currentValue;
- }
- this._changesHead = this._changesTail = null;
- this._additionsHead = this._additionsTail = null;
- this._removalsHead = null;
- }
- };
- /**
- * @param {?} record
- * @param {?} newValue
- * @return {?}
- */
- DefaultKeyValueDiffer.prototype._maybeAddToChanges = function (record, newValue) {
- if (!looseIdentical(newValue, record.currentValue)) {
- record.previousValue = record.currentValue;
- record.currentValue = newValue;
- this._addToChanges(record);
- }
- };
- /**
- * @param {?} record
- * @return {?}
- */
- DefaultKeyValueDiffer.prototype._addToAdditions = function (record) {
- if (this._additionsHead === null) {
- this._additionsHead = this._additionsTail = record;
- }
- else {
- ((this._additionsTail))._nextAdded = record;
- this._additionsTail = record;
- }
- };
- /**
- * @param {?} record
- * @return {?}
- */
- DefaultKeyValueDiffer.prototype._addToChanges = function (record) {
- if (this._changesHead === null) {
- this._changesHead = this._changesTail = record;
- }
- else {
- ((this._changesTail))._nextChanged = record;
- this._changesTail = record;
- }
- };
- /**
- * \@internal
- * @template K, V
- * @param {?} obj
- * @param {?} fn
- * @return {?}
- */
- DefaultKeyValueDiffer.prototype._forEach = function (obj, fn) {
- if (obj instanceof Map) {
- obj.forEach(fn);
- }
- else {
- Object.keys(obj).forEach(function (k) { return fn(obj[k], k); });
- }
- };
- return DefaultKeyValueDiffer;
- }());
- /**
- * \@stable
- */
- var KeyValueChangeRecord_ = (function () {
- /**
- * @param {?} key
- */
- function KeyValueChangeRecord_(key) {
- this.key = key;
- this.previousValue = null;
- this.currentValue = null;
- /**
- * \@internal
- */
- this._nextPrevious = null;
- /**
- * \@internal
- */
- this._next = null;
- /**
- * \@internal
- */
- this._prev = null;
- /**
- * \@internal
- */
- this._nextAdded = null;
- /**
- * \@internal
- */
- this._nextRemoved = null;
- /**
- * \@internal
- */
- this._nextChanged = null;
- }
- return KeyValueChangeRecord_;
- }());
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * A repository of different iterable diffing strategies used by NgFor, NgClass, and others.
- * \@stable
- */
- var IterableDiffers = (function () {
- /**
- * @param {?} factories
- */
- function IterableDiffers(factories) {
- this.factories = factories;
- }
- /**
- * @param {?} factories
- * @param {?=} parent
- * @return {?}
- */
- IterableDiffers.create = function (factories, parent) {
- if (parent != null) {
- var /** @type {?} */ copied = parent.factories.slice();
- factories = factories.concat(copied);
- return new IterableDiffers(factories);
- }
- else {
- return new IterableDiffers(factories);
- }
- };
- /**
- * Takes an array of {\@link IterableDifferFactory} and returns a provider used to extend the
- * inherited {\@link IterableDiffers} instance with the provided factories and return a new
- * {\@link IterableDiffers} instance.
- *
- * The following example shows how to extend an existing list of factories,
- * which will only be applied to the injector for this component and its children.
- * This step is all that's required to make a new {\@link IterableDiffer} available.
- *
- * ### Example
- *
- * ```
- * \@Component({
- * viewProviders: [
- * IterableDiffers.extend([new ImmutableListDiffer()])
- * ]
- * })
- * ```
- * @param {?} factories
- * @return {?}
- */
- IterableDiffers.extend = function (factories) {
- return {
- provide: IterableDiffers,
- useFactory: function (parent) {
- if (!parent) {
- // Typically would occur when calling IterableDiffers.extend inside of dependencies passed
- // to
- // bootstrap(), which would override default pipes instead of extending them.
- throw new Error('Cannot extend IterableDiffers without a parent injector');
- }
- return IterableDiffers.create(factories, parent);
- },
- // Dependency technically isn't optional, but we can provide a better error message this way.
- deps: [[IterableDiffers, new SkipSelf(), new Optional()]]
- };
- };
- /**
- * @param {?} iterable
- * @return {?}
- */
- IterableDiffers.prototype.find = function (iterable) {
- var /** @type {?} */ factory = this.factories.find(function (f) { return f.supports(iterable); });
- if (factory != null) {
- return factory;
- }
- else {
- throw new Error("Cannot find a differ supporting object '" + iterable + "' of type '" + getTypeNameForDebugging(iterable) + "'");
- }
- };
- return IterableDiffers;
- }());
- /**
- * @param {?} type
- * @return {?}
- */
- function getTypeNameForDebugging(type) {
- return type['name'] || typeof type;
- }
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * A repository of different Map diffing strategies used by NgClass, NgStyle, and others.
- * \@stable
- */
- var KeyValueDiffers = (function () {
- /**
- * @param {?} factories
- */
- function KeyValueDiffers(factories) {
- this.factories = factories;
- }
- /**
- * @template S
- * @param {?} factories
- * @param {?=} parent
- * @return {?}
- */
- KeyValueDiffers.create = function (factories, parent) {
- if (parent) {
- var /** @type {?} */ copied = parent.factories.slice();
- factories = factories.concat(copied);
- }
- return new KeyValueDiffers(factories);
- };
- /**
- * Takes an array of {\@link KeyValueDifferFactory} and returns a provider used to extend the
- * inherited {\@link KeyValueDiffers} instance with the provided factories and return a new
- * {\@link KeyValueDiffers} instance.
- *
- * The following example shows how to extend an existing list of factories,
- * which will only be applied to the injector for this component and its children.
- * This step is all that's required to make a new {\@link KeyValueDiffer} available.
- *
- * ### Example
- *
- * ```
- * \@Component({
- * viewProviders: [
- * KeyValueDiffers.extend([new ImmutableMapDiffer()])
- * ]
- * })
- * ```
- * @template S
- * @param {?} factories
- * @return {?}
- */
- KeyValueDiffers.extend = function (factories) {
- return {
- provide: KeyValueDiffers,
- useFactory: function (parent) {
- if (!parent) {
- // Typically would occur when calling KeyValueDiffers.extend inside of dependencies passed
- // to bootstrap(), which would override default pipes instead of extending them.
- throw new Error('Cannot extend KeyValueDiffers without a parent injector');
- }
- return KeyValueDiffers.create(factories, parent);
- },
- // Dependency technically isn't optional, but we can provide a better error message this way.
- deps: [[KeyValueDiffers, new SkipSelf(), new Optional()]]
- };
- };
- /**
- * @param {?} kv
- * @return {?}
- */
- KeyValueDiffers.prototype.find = function (kv) {
- var /** @type {?} */ factory = this.factories.find(function (f) { return f.supports(kv); });
- if (factory) {
- return factory;
- }
- throw new Error("Cannot find a differ supporting object '" + kv + "'");
- };
- return KeyValueDiffers;
- }());
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * Structural diffing for `Object`s and `Map`s.
- */
- var keyValDiff = [new DefaultKeyValueDifferFactory()];
- /**
- * Structural diffing for `Iterable` types such as `Array`s.
- */
- var iterableDiff = [new DefaultIterableDifferFactory()];
- var defaultIterableDiffers = new IterableDiffers(iterableDiff);
- var defaultKeyValueDiffers = new KeyValueDiffers(keyValDiff);
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * @module
- * @description
- * Change detection enables data binding in Angular.
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * @return {?}
- */
- function _reflector() {
- return reflector;
- }
- var _CORE_PLATFORM_PROVIDERS = [
- // Set a default platform name for platforms that don't set it explicitly.
- { provide: PLATFORM_ID, useValue: 'unknown' },
- PlatformRef_,
- { provide: PlatformRef, useExisting: PlatformRef_ },
- { provide: Reflector, useFactory: _reflector, deps: [] },
- TestabilityRegistry,
- Console,
- ];
- /**
- * This platform has to be included in any other platform
- *
- * \@experimental
- */
- var platformCore = createPlatformFactory(null, 'core', _CORE_PLATFORM_PROVIDERS);
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * \@experimental i18n support is experimental.
- */
- var LOCALE_ID = new InjectionToken('LocaleId');
- /**
- * \@experimental i18n support is experimental.
- */
- var TRANSLATIONS = new InjectionToken('Translations');
- /**
- * \@experimental i18n support is experimental.
- */
- var TRANSLATIONS_FORMAT = new InjectionToken('TranslationsFormat');
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * @return {?}
- */
- function _iterableDiffersFactory() {
- return defaultIterableDiffers;
- }
- /**
- * @return {?}
- */
- function _keyValueDiffersFactory() {
- return defaultKeyValueDiffers;
- }
- /**
- * @param {?=} locale
- * @return {?}
- */
- function _localeFactory(locale) {
- return locale || 'en-US';
- }
- /**
- * This module includes the providers of \@angular/core that are needed
- * to bootstrap components via `ApplicationRef`.
- *
- * \@experimental
- */
- var ApplicationModule = (function () {
- /**
- * @param {?} appRef
- */
- function ApplicationModule(appRef) {
- }
- return ApplicationModule;
- }());
- ApplicationModule.decorators = [
- { type: NgModule, args: [{
- providers: [
- ApplicationRef_,
- { provide: ApplicationRef, useExisting: ApplicationRef_ },
- ApplicationInitStatus,
- Compiler,
- APP_ID_RANDOM_PROVIDER,
- { provide: IterableDiffers, useFactory: _iterableDiffersFactory },
- { provide: KeyValueDiffers, useFactory: _keyValueDiffersFactory },
- {
- provide: LOCALE_ID,
- useFactory: _localeFactory,
- deps: [[new Inject(LOCALE_ID), new Optional(), new SkipSelf()]]
- },
- ]
- },] },
- ];
- /**
- * @nocollapse
- */
- ApplicationModule.ctorParameters = function () { return [
- { type: ApplicationRef, },
- ]; };
- var SecurityContext = {};
- SecurityContext.NONE = 0;
- SecurityContext.HTML = 1;
- SecurityContext.STYLE = 2;
- SecurityContext.SCRIPT = 3;
- SecurityContext.URL = 4;
- SecurityContext.RESOURCE_URL = 5;
- SecurityContext[SecurityContext.NONE] = "NONE";
- SecurityContext[SecurityContext.HTML] = "HTML";
- SecurityContext[SecurityContext.STYLE] = "STYLE";
- SecurityContext[SecurityContext.SCRIPT] = "SCRIPT";
- SecurityContext[SecurityContext.URL] = "URL";
- SecurityContext[SecurityContext.RESOURCE_URL] = "RESOURCE_URL";
- /**
- * Sanitizer is used by the views to sanitize potentially dangerous values.
- *
- * \@stable
- * @abstract
- */
- var Sanitizer = (function () {
- function Sanitizer() {
- }
- /**
- * @abstract
- * @param {?} context
- * @param {?} value
- * @return {?}
- */
- Sanitizer.prototype.sanitize = function (context, value) { };
- return Sanitizer;
- }());
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * Node instance data.
- *
- * We have a separate type per NodeType to save memory
- * (TextData | ElementData | ProviderData | PureExpressionData | QueryList<any>)
- *
- * To keep our code monomorphic,
- * we prohibit using `NodeData` directly but enforce the use of accessors (`asElementData`, ...).
- * This way, no usage site can get a `NodeData` from view.nodes and then use it for different
- * purposes.
- */
- /**
- * Accessor for view.nodes, enforcing that every usage site stays monomorphic.
- * @param {?} view
- * @param {?} index
- * @return {?}
- */
- function asTextData(view, index) {
- return (view.nodes[index]);
- }
- /**
- * Accessor for view.nodes, enforcing that every usage site stays monomorphic.
- * @param {?} view
- * @param {?} index
- * @return {?}
- */
- function asElementData(view, index) {
- return (view.nodes[index]);
- }
- /**
- * Accessor for view.nodes, enforcing that every usage site stays monomorphic.
- * @param {?} view
- * @param {?} index
- * @return {?}
- */
- function asProviderData(view, index) {
- return (view.nodes[index]);
- }
- /**
- * Accessor for view.nodes, enforcing that every usage site stays monomorphic.
- * @param {?} view
- * @param {?} index
- * @return {?}
- */
- function asPureExpressionData(view, index) {
- return (view.nodes[index]);
- }
- /**
- * Accessor for view.nodes, enforcing that every usage site stays monomorphic.
- * @param {?} view
- * @param {?} index
- * @return {?}
- */
- function asQueryList(view, index) {
- return (view.nodes[index]);
- }
- /**
- * This object is used to prevent cycles in the source files and to have a place where
- * debug mode can hook it. It is lazily filled when `isDevMode` is known.
- */
- var Services = {
- setCurrentNode: undefined,
- createRootView: undefined,
- createEmbeddedView: undefined,
- createComponentView: undefined,
- createNgModuleRef: undefined,
- overrideProvider: undefined,
- clearProviderOverrides: undefined,
- checkAndUpdateView: undefined,
- checkNoChangesView: undefined,
- destroyView: undefined,
- resolveDep: undefined,
- createDebugContext: undefined,
- handleEvent: undefined,
- updateDirectives: undefined,
- updateRenderer: undefined,
- dirtyParentQueries: undefined,
- };
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * @param {?} context
- * @param {?} oldValue
- * @param {?} currValue
- * @param {?} isFirstCheck
- * @return {?}
- */
- function expressionChangedAfterItHasBeenCheckedError(context, oldValue, currValue, isFirstCheck) {
- var /** @type {?} */ msg = "ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. Previous value: '" + oldValue + "'. Current value: '" + currValue + "'.";
- if (isFirstCheck) {
- msg +=
- " It seems like the view has been created after its parent and its children have been dirty checked." +
- " Has it been created in a change detection hook ?";
- }
- return viewDebugError(msg, context);
- }
- /**
- * @param {?} err
- * @param {?} context
- * @return {?}
- */
- function viewWrappedDebugError(err, context) {
- if (!(err instanceof Error)) {
- // errors that are not Error instances don't have a stack,
- // so it is ok to wrap them into a new Error object...
- err = new Error(err.toString());
- }
- _addDebugContext(err, context);
- return err;
- }
- /**
- * @param {?} msg
- * @param {?} context
- * @return {?}
- */
- function viewDebugError(msg, context) {
- var /** @type {?} */ err = new Error(msg);
- _addDebugContext(err, context);
- return err;
- }
- /**
- * @param {?} err
- * @param {?} context
- * @return {?}
- */
- function _addDebugContext(err, context) {
- ((err))[ERROR_DEBUG_CONTEXT] = context;
- ((err))[ERROR_LOGGER] = context.logError.bind(context);
- }
- /**
- * @param {?} err
- * @return {?}
- */
- function isViewDebugError(err) {
- return !!getDebugContext(err);
- }
- /**
- * @param {?} action
- * @return {?}
- */
- function viewDestroyedError(action) {
- return new Error("ViewDestroyedError: Attempt to use a destroyed view: " + action);
- }
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var NOOP = function () { };
- var _tokenKeyCache = new Map();
- /**
- * @param {?} token
- * @return {?}
- */
- function tokenKey(token) {
- var /** @type {?} */ key = _tokenKeyCache.get(token);
- if (!key) {
- key = stringify(token) + '_' + _tokenKeyCache.size;
- _tokenKeyCache.set(token, key);
- }
- return key;
- }
- var UNDEFINED_RENDERER_TYPE_ID = '$$undefined';
- var EMPTY_RENDERER_TYPE_ID = '$$empty';
- var _renderCompCount = 0;
- /**
- * @param {?=} type
- * @return {?}
- */
- function resolveRendererType2(type) {
- if (type && type.id === UNDEFINED_RENDERER_TYPE_ID) {
- // first time we see this RendererType2. Initialize it...
- var /** @type {?} */ isFilled = ((type.encapsulation != null && type.encapsulation !== ViewEncapsulation.None) ||
- type.styles.length || Object.keys(type.data).length);
- if (isFilled) {
- type.id = "c" + _renderCompCount++;
- }
- else {
- type.id = EMPTY_RENDERER_TYPE_ID;
- }
- }
- if (type && type.id === EMPTY_RENDERER_TYPE_ID) {
- type = null;
- }
- return type || null;
- }
- /**
- * @param {?} view
- * @param {?} def
- * @param {?} bindingIdx
- * @param {?} value
- * @return {?}
- */
- function checkBinding(view, def, bindingIdx, value) {
- var /** @type {?} */ oldValues = view.oldValues;
- if ((view.state & 2 /* FirstCheck */) ||
- !looseIdentical(oldValues[def.bindingIndex + bindingIdx], value)) {
- return true;
- }
- return false;
- }
- /**
- * @param {?} view
- * @param {?} def
- * @param {?} bindingIdx
- * @param {?} value
- * @return {?}
- */
- function checkAndUpdateBinding(view, def, bindingIdx, value) {
- if (checkBinding(view, def, bindingIdx, value)) {
- view.oldValues[def.bindingIndex + bindingIdx] = value;
- return true;
- }
- return false;
- }
- /**
- * @param {?} view
- * @param {?} def
- * @param {?} bindingIdx
- * @param {?} value
- * @return {?}
- */
- function checkBindingNoChanges(view, def, bindingIdx, value) {
- var /** @type {?} */ oldValue = view.oldValues[def.bindingIndex + bindingIdx];
- if ((view.state & 1 /* BeforeFirstCheck */) || !devModeEqual(oldValue, value)) {
- throw expressionChangedAfterItHasBeenCheckedError(Services.createDebugContext(view, def.nodeIndex), oldValue, value, (view.state & 1 /* BeforeFirstCheck */) !== 0);
- }
- }
- /**
- * @param {?} view
- * @return {?}
- */
- function markParentViewsForCheck(view) {
- var /** @type {?} */ currView = view;
- while (currView) {
- if (currView.def.flags & 2 /* OnPush */) {
- currView.state |= 8 /* ChecksEnabled */;
- }
- currView = currView.viewContainerParent || currView.parent;
- }
- }
- /**
- * @param {?} view
- * @param {?} endView
- * @return {?}
- */
- function markParentViewsForCheckProjectedViews(view, endView) {
- var /** @type {?} */ currView = view;
- while (currView && currView !== endView) {
- currView.state |= 64 /* CheckProjectedViews */;
- currView = currView.viewContainerParent || currView.parent;
- }
- }
- /**
- * @param {?} view
- * @param {?} nodeIndex
- * @param {?} eventName
- * @param {?} event
- * @return {?}
- */
- function dispatchEvent(view, nodeIndex, eventName, event) {
- var /** @type {?} */ nodeDef = view.def.nodes[nodeIndex];
- var /** @type {?} */ startView = nodeDef.flags & 33554432 /* ComponentView */ ? asElementData(view, nodeIndex).componentView : view;
- markParentViewsForCheck(startView);
- return Services.handleEvent(view, nodeIndex, eventName, event);
- }
- /**
- * @param {?} view
- * @return {?}
- */
- function declaredViewContainer(view) {
- if (view.parent) {
- var /** @type {?} */ parentView = view.parent;
- return asElementData(parentView, /** @type {?} */ ((view.parentNodeDef)).nodeIndex);
- }
- return null;
- }
- /**
- * for component views, this is the host element.
- * for embedded views, this is the index of the parent node
- * that contains the view container.
- * @param {?} view
- * @return {?}
- */
- function viewParentEl(view) {
- var /** @type {?} */ parentView = view.parent;
- if (parentView) {
- return ((view.parentNodeDef)).parent;
- }
- else {
- return null;
- }
- }
- /**
- * @param {?} view
- * @param {?} def
- * @return {?}
- */
- function renderNode(view, def) {
- switch (def.flags & 201347067 /* Types */) {
- case 1 /* TypeElement */:
- return asElementData(view, def.nodeIndex).renderElement;
- case 2 /* TypeText */:
- return asTextData(view, def.nodeIndex).renderText;
- }
- }
- /**
- * @param {?} target
- * @param {?} name
- * @return {?}
- */
- function elementEventFullName(target, name) {
- return target ? target + ":" + name : name;
- }
- /**
- * @param {?} view
- * @return {?}
- */
- function isComponentView(view) {
- return !!view.parent && !!(((view.parentNodeDef)).flags & 32768 /* Component */);
- }
- /**
- * @param {?} view
- * @return {?}
- */
- function isEmbeddedView(view) {
- return !!view.parent && !(((view.parentNodeDef)).flags & 32768 /* Component */);
- }
- /**
- * @param {?} queryId
- * @return {?}
- */
- function filterQueryId(queryId) {
- return 1 << (queryId % 32);
- }
- /**
- * @param {?} matchedQueriesDsl
- * @return {?}
- */
- function splitMatchedQueriesDsl(matchedQueriesDsl) {
- var /** @type {?} */ matchedQueries = {};
- var /** @type {?} */ matchedQueryIds = 0;
- var /** @type {?} */ references = {};
- if (matchedQueriesDsl) {
- matchedQueriesDsl.forEach(function (_a) {
- var queryId = _a[0], valueType = _a[1];
- if (typeof queryId === 'number') {
- matchedQueries[queryId] = valueType;
- matchedQueryIds |= filterQueryId(queryId);
- }
- else {
- references[queryId] = valueType;
- }
- });
- }
- return { matchedQueries: matchedQueries, references: references, matchedQueryIds: matchedQueryIds };
- }
- /**
- * @param {?} deps
- * @return {?}
- */
- function splitDepsDsl(deps) {
- return deps.map(function (value) {
- var /** @type {?} */ token;
- var /** @type {?} */ flags;
- if (Array.isArray(value)) {
- flags = value[0], token = value[1];
- }
- else {
- flags = 0 /* None */;
- token = value;
- }
- return { flags: flags, token: token, tokenKey: tokenKey(token) };
- });
- }
- /**
- * @param {?} view
- * @param {?} renderHost
- * @param {?} def
- * @return {?}
- */
- function getParentRenderElement(view, renderHost, def) {
- var /** @type {?} */ renderParent = def.renderParent;
- if (renderParent) {
- if ((renderParent.flags & 1 /* TypeElement */) === 0 ||
- (renderParent.flags & 33554432 /* ComponentView */) === 0 ||
- (((renderParent.element)).componentRendererType && ((((renderParent.element)).componentRendererType)).encapsulation ===
- ViewEncapsulation.Native)) {
- // only children of non components, or children of components with native encapsulation should
- // be attached.
- return asElementData(view, /** @type {?} */ ((def.renderParent)).nodeIndex).renderElement;
- }
- }
- else {
- return renderHost;
- }
- }
- var DEFINITION_CACHE = new WeakMap();
- /**
- * @template D
- * @param {?} factory
- * @return {?}
- */
- function resolveDefinition(factory) {
- var /** @type {?} */ value = (((DEFINITION_CACHE.get(factory))));
- if (!value) {
- value = factory(function () { return NOOP; });
- value.factory = factory;
- DEFINITION_CACHE.set(factory, value);
- }
- return value;
- }
- /**
- * @param {?} view
- * @return {?}
- */
- function rootRenderNodes(view) {
- var /** @type {?} */ renderNodes = [];
- visitRootRenderNodes(view, 0 /* Collect */, undefined, undefined, renderNodes);
- return renderNodes;
- }
- /**
- * @param {?} view
- * @param {?} action
- * @param {?} parentNode
- * @param {?} nextSibling
- * @param {?=} target
- * @return {?}
- */
- function visitRootRenderNodes(view, action, parentNode, nextSibling, target) {
- // We need to re-compute the parent node in case the nodes have been moved around manually
- if (action === 3 /* RemoveChild */) {
- parentNode = view.renderer.parentNode(renderNode(view, /** @type {?} */ ((view.def.lastRenderRootNode))));
- }
- visitSiblingRenderNodes(view, action, 0, view.def.nodes.length - 1, parentNode, nextSibling, target);
- }
- /**
- * @param {?} view
- * @param {?} action
- * @param {?} startIndex
- * @param {?} endIndex
- * @param {?} parentNode
- * @param {?} nextSibling
- * @param {?=} target
- * @return {?}
- */
- function visitSiblingRenderNodes(view, action, startIndex, endIndex, parentNode, nextSibling, target) {
- for (var /** @type {?} */ i = startIndex; i <= endIndex; i++) {
- var /** @type {?} */ nodeDef = view.def.nodes[i];
- if (nodeDef.flags & (1 /* TypeElement */ | 2 /* TypeText */ | 8 /* TypeNgContent */)) {
- visitRenderNode(view, nodeDef, action, parentNode, nextSibling, target);
- }
- // jump to next sibling
- i += nodeDef.childCount;
- }
- }
- /**
- * @param {?} view
- * @param {?} ngContentIndex
- * @param {?} action
- * @param {?} parentNode
- * @param {?} nextSibling
- * @param {?=} target
- * @return {?}
- */
- function visitProjectedRenderNodes(view, ngContentIndex, action, parentNode, nextSibling, target) {
- var /** @type {?} */ compView = view;
- while (compView && !isComponentView(compView)) {
- compView = compView.parent;
- }
- var /** @type {?} */ hostView = ((compView)).parent;
- var /** @type {?} */ hostElDef = viewParentEl(/** @type {?} */ ((compView)));
- var /** @type {?} */ startIndex = ((hostElDef)).nodeIndex + 1;
- var /** @type {?} */ endIndex = ((hostElDef)).nodeIndex + ((hostElDef)).childCount;
- for (var /** @type {?} */ i = startIndex; i <= endIndex; i++) {
- var /** @type {?} */ nodeDef = ((hostView)).def.nodes[i];
- if (nodeDef.ngContentIndex === ngContentIndex) {
- visitRenderNode(/** @type {?} */ ((hostView)), nodeDef, action, parentNode, nextSibling, target);
- }
- // jump to next sibling
- i += nodeDef.childCount;
- }
- if (!((hostView)).parent) {
- // a root view
- var /** @type {?} */ projectedNodes = view.root.projectableNodes[ngContentIndex];
- if (projectedNodes) {
- for (var /** @type {?} */ i = 0; i < projectedNodes.length; i++) {
- execRenderNodeAction(view, projectedNodes[i], action, parentNode, nextSibling, target);
- }
- }
- }
- }
- /**
- * @param {?} view
- * @param {?} nodeDef
- * @param {?} action
- * @param {?} parentNode
- * @param {?} nextSibling
- * @param {?=} target
- * @return {?}
- */
- function visitRenderNode(view, nodeDef, action, parentNode, nextSibling, target) {
- if (nodeDef.flags & 8 /* TypeNgContent */) {
- visitProjectedRenderNodes(view, /** @type {?} */ ((nodeDef.ngContent)).index, action, parentNode, nextSibling, target);
- }
- else {
- var /** @type {?} */ rn = renderNode(view, nodeDef);
- if (action === 3 /* RemoveChild */ && (nodeDef.flags & 33554432 /* ComponentView */) &&
- (nodeDef.bindingFlags & 48 /* CatSyntheticProperty */)) {
- // Note: we might need to do both actions.
- if (nodeDef.bindingFlags & (16 /* SyntheticProperty */)) {
- execRenderNodeAction(view, rn, action, parentNode, nextSibling, target);
- }
- if (nodeDef.bindingFlags & (32 /* SyntheticHostProperty */)) {
- var /** @type {?} */ compView = asElementData(view, nodeDef.nodeIndex).componentView;
- execRenderNodeAction(compView, rn, action, parentNode, nextSibling, target);
- }
- }
- else {
- execRenderNodeAction(view, rn, action, parentNode, nextSibling, target);
- }
- if (nodeDef.flags & 16777216 /* EmbeddedViews */) {
- var /** @type {?} */ embeddedViews = ((asElementData(view, nodeDef.nodeIndex).viewContainer))._embeddedViews;
- for (var /** @type {?} */ k = 0; k < embeddedViews.length; k++) {
- visitRootRenderNodes(embeddedViews[k], action, parentNode, nextSibling, target);
- }
- }
- if (nodeDef.flags & 1 /* TypeElement */ && !((nodeDef.element)).name) {
- visitSiblingRenderNodes(view, action, nodeDef.nodeIndex + 1, nodeDef.nodeIndex + nodeDef.childCount, parentNode, nextSibling, target);
- }
- }
- }
- /**
- * @param {?} view
- * @param {?} renderNode
- * @param {?} action
- * @param {?} parentNode
- * @param {?} nextSibling
- * @param {?=} target
- * @return {?}
- */
- function execRenderNodeAction(view, renderNode, action, parentNode, nextSibling, target) {
- var /** @type {?} */ renderer = view.renderer;
- switch (action) {
- case 1 /* AppendChild */:
- renderer.appendChild(parentNode, renderNode);
- break;
- case 2 /* InsertBefore */:
- renderer.insertBefore(parentNode, renderNode, nextSibling);
- break;
- case 3 /* RemoveChild */:
- renderer.removeChild(parentNode, renderNode);
- break;
- case 0 /* Collect */:
- ((target)).push(renderNode);
- break;
- }
- }
- var NS_PREFIX_RE = /^:([^:]+):(.+)$/;
- /**
- * @param {?} name
- * @return {?}
- */
- function splitNamespace(name) {
- if (name[0] === ':') {
- var /** @type {?} */ match = ((name.match(NS_PREFIX_RE)));
- return [match[1], match[2]];
- }
- return ['', name];
- }
- /**
- * @param {?} bindings
- * @return {?}
- */
- function calcBindingFlags(bindings) {
- var /** @type {?} */ flags = 0;
- for (var /** @type {?} */ i = 0; i < bindings.length; i++) {
- flags |= bindings[i].flags;
- }
- return flags;
- }
- /**
- * @param {?} v
- * @return {?}
- */
- function _toStringWithNull(v) {
- return v != null ? v.toString() : '';
- }
- /**
- * @param {?} view
- * @param {?} renderHost
- * @param {?} def
- * @return {?}
- */
- function createElement(view, renderHost, def) {
- var /** @type {?} */ elDef = ((def.element));
- var /** @type {?} */ rootSelectorOrNode = view.root.selectorOrNode;
- var /** @type {?} */ renderer = view.renderer;
- var /** @type {?} */ el;
- if (view.parent || !rootSelectorOrNode) {
- if (elDef.name) {
- el = renderer.createElement(elDef.name, elDef.ns);
- }
- else {
- el = renderer.createComment('');
- }
- var /** @type {?} */ parentEl = getParentRenderElement(view, renderHost, def);
- if (parentEl) {
- renderer.appendChild(parentEl, el);
- }
- }
- else {
- el = renderer.selectRootElement(rootSelectorOrNode);
- }
- if (elDef.attrs) {
- for (var /** @type {?} */ i = 0; i < elDef.attrs.length; i++) {
- var _a = elDef.attrs[i], ns = _a[0], name = _a[1], value = _a[2];
- renderer.setAttribute(el, name, value, ns);
- }
- }
- return el;
- }
- /**
- * @param {?} view
- * @param {?} compView
- * @param {?} def
- * @param {?} el
- * @return {?}
- */
- function listenToElementOutputs(view, compView, def, el) {
- for (var /** @type {?} */ i = 0; i < def.outputs.length; i++) {
- var /** @type {?} */ output = def.outputs[i];
- var /** @type {?} */ handleEventClosure = renderEventHandlerClosure(view, def.nodeIndex, elementEventFullName(output.target, output.eventName));
- var /** @type {?} */ listenTarget = output.target;
- var /** @type {?} */ listenerView = view;
- if (output.target === 'component') {
- listenTarget = null;
- listenerView = compView;
- }
- var /** @type {?} */ disposable = (listenerView.renderer.listen(listenTarget || el, output.eventName, handleEventClosure)); /** @type {?} */
- ((view.disposables))[def.outputIndex + i] = disposable;
- }
- }
- /**
- * @param {?} view
- * @param {?} index
- * @param {?} eventName
- * @return {?}
- */
- function renderEventHandlerClosure(view, index, eventName) {
- return function (event) {
- try {
- return dispatchEvent(view, index, eventName, event);
- }
- catch (e) {
- // Attention: Don't rethrow, to keep in sync with directive events.
- view.root.errorHandler.handleError(e);
- }
- };
- }
- /**
- * @param {?} view
- * @param {?} def
- * @param {?} v0
- * @param {?} v1
- * @param {?} v2
- * @param {?} v3
- * @param {?} v4
- * @param {?} v5
- * @param {?} v6
- * @param {?} v7
- * @param {?} v8
- * @param {?} v9
- * @return {?}
- */
- function checkAndUpdateElementInline(view, def, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
- var /** @type {?} */ bindLen = def.bindings.length;
- var /** @type {?} */ changed = false;
- if (bindLen > 0 && checkAndUpdateElementValue(view, def, 0, v0))
- changed = true;
- if (bindLen > 1 && checkAndUpdateElementValue(view, def, 1, v1))
- changed = true;
- if (bindLen > 2 && checkAndUpdateElementValue(view, def, 2, v2))
- changed = true;
- if (bindLen > 3 && checkAndUpdateElementValue(view, def, 3, v3))
- changed = true;
- if (bindLen > 4 && checkAndUpdateElementValue(view, def, 4, v4))
- changed = true;
- if (bindLen > 5 && checkAndUpdateElementValue(view, def, 5, v5))
- changed = true;
- if (bindLen > 6 && checkAndUpdateElementValue(view, def, 6, v6))
- changed = true;
- if (bindLen > 7 && checkAndUpdateElementValue(view, def, 7, v7))
- changed = true;
- if (bindLen > 8 && checkAndUpdateElementValue(view, def, 8, v8))
- changed = true;
- if (bindLen > 9 && checkAndUpdateElementValue(view, def, 9, v9))
- changed = true;
- return changed;
- }
- /**
- * @param {?} view
- * @param {?} def
- * @param {?} values
- * @return {?}
- */
- function checkAndUpdateElementDynamic(view, def, values) {
- var /** @type {?} */ changed = false;
- for (var /** @type {?} */ i = 0; i < values.length; i++) {
- if (checkAndUpdateElementValue(view, def, i, values[i]))
- changed = true;
- }
- return changed;
- }
- /**
- * @param {?} view
- * @param {?} def
- * @param {?} bindingIdx
- * @param {?} value
- * @return {?}
- */
- function checkAndUpdateElementValue(view, def, bindingIdx, value) {
- if (!checkAndUpdateBinding(view, def, bindingIdx, value)) {
- return false;
- }
- var /** @type {?} */ binding = def.bindings[bindingIdx];
- var /** @type {?} */ elData = asElementData(view, def.nodeIndex);
- var /** @type {?} */ renderNode$$1 = elData.renderElement;
- var /** @type {?} */ name = ((binding.name));
- switch (binding.flags & 15 /* Types */) {
- case 1 /* TypeElementAttribute */:
- setElementAttribute(view, binding, renderNode$$1, binding.ns, name, value);
- break;
- case 2 /* TypeElementClass */:
- setElementClass(view, renderNode$$1, name, value);
- break;
- case 4 /* TypeElementStyle */:
- setElementStyle(view, binding, renderNode$$1, name, value);
- break;
- case 8 /* TypeProperty */:
- var /** @type {?} */ bindView = (def.flags & 33554432 /* ComponentView */ &&
- binding.flags & 32 /* SyntheticHostProperty */) ?
- elData.componentView :
- view;
- setElementProperty(bindView, binding, renderNode$$1, name, value);
- break;
- }
- return true;
- }
- /**
- * @param {?} view
- * @param {?} binding
- * @param {?} renderNode
- * @param {?} ns
- * @param {?} name
- * @param {?} value
- * @return {?}
- */
- function setElementAttribute(view, binding, renderNode$$1, ns, name, value) {
- var /** @type {?} */ securityContext = binding.securityContext;
- var /** @type {?} */ renderValue = securityContext ? view.root.sanitizer.sanitize(securityContext, value) : value;
- renderValue = renderValue != null ? renderValue.toString() : null;
- var /** @type {?} */ renderer = view.renderer;
- if (value != null) {
- renderer.setAttribute(renderNode$$1, name, renderValue, ns);
- }
- else {
- renderer.removeAttribute(renderNode$$1, name, ns);
- }
- }
- /**
- * @param {?} view
- * @param {?} renderNode
- * @param {?} name
- * @param {?} value
- * @return {?}
- */
- function setElementClass(view, renderNode$$1, name, value) {
- var /** @type {?} */ renderer = view.renderer;
- if (value) {
- renderer.addClass(renderNode$$1, name);
- }
- else {
- renderer.removeClass(renderNode$$1, name);
- }
- }
- /**
- * @param {?} view
- * @param {?} binding
- * @param {?} renderNode
- * @param {?} name
- * @param {?} value
- * @return {?}
- */
- function setElementStyle(view, binding, renderNode$$1, name, value) {
- var /** @type {?} */ renderValue = view.root.sanitizer.sanitize(SecurityContext.STYLE, /** @type {?} */ (value));
- if (renderValue != null) {
- renderValue = renderValue.toString();
- var /** @type {?} */ unit = binding.suffix;
- if (unit != null) {
- renderValue = renderValue + unit;
- }
- }
- else {
- renderValue = null;
- }
- var /** @type {?} */ renderer = view.renderer;
- if (renderValue != null) {
- renderer.setStyle(renderNode$$1, name, renderValue);
- }
- else {
- renderer.removeStyle(renderNode$$1, name);
- }
- }
- /**
- * @param {?} view
- * @param {?} binding
- * @param {?} renderNode
- * @param {?} name
- * @param {?} value
- * @return {?}
- */
- function setElementProperty(view, binding, renderNode$$1, name, value) {
- var /** @type {?} */ securityContext = binding.securityContext;
- var /** @type {?} */ renderValue = securityContext ? view.root.sanitizer.sanitize(securityContext, value) : value;
- view.renderer.setProperty(renderNode$$1, name, renderValue);
- }
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var UNDEFINED_VALUE = new Object();
- var InjectorRefTokenKey$1 = tokenKey(Injector);
- var NgModuleRefTokenKey = tokenKey(NgModuleRef);
- /**
- * @param {?} data
- * @return {?}
- */
- function initNgModule(data) {
- var /** @type {?} */ def = data._def;
- var /** @type {?} */ providers = data._providers = new Array(def.providers.length);
- for (var /** @type {?} */ i = 0; i < def.providers.length; i++) {
- var /** @type {?} */ provDef = def.providers[i];
- if (!(provDef.flags & 4096 /* LazyProvider */)) {
- providers[i] = _createProviderInstance$1(data, provDef);
- }
- }
- }
- /**
- * @param {?} data
- * @param {?} depDef
- * @param {?=} notFoundValue
- * @return {?}
- */
- function resolveNgModuleDep(data, depDef, notFoundValue) {
- if (notFoundValue === void 0) { notFoundValue = Injector.THROW_IF_NOT_FOUND; }
- if (depDef.flags & 8 /* Value */) {
- return depDef.token;
- }
- if (depDef.flags & 2 /* Optional */) {
- notFoundValue = null;
- }
- if (depDef.flags & 1 /* SkipSelf */) {
- return data._parent.get(depDef.token, notFoundValue);
- }
- var /** @type {?} */ tokenKey$$1 = depDef.tokenKey;
- switch (tokenKey$$1) {
- case InjectorRefTokenKey$1:
- case NgModuleRefTokenKey:
- return data;
- }
- var /** @type {?} */ providerDef = data._def.providersByKey[tokenKey$$1];
- if (providerDef) {
- var /** @type {?} */ providerInstance = data._providers[providerDef.index];
- if (providerInstance === undefined) {
- providerInstance = data._providers[providerDef.index] =
- _createProviderInstance$1(data, providerDef);
- }
- return providerInstance === UNDEFINED_VALUE ? undefined : providerInstance;
- }
- return data._parent.get(depDef.token, notFoundValue);
- }
- /**
- * @param {?} ngModule
- * @param {?} providerDef
- * @return {?}
- */
- function _createProviderInstance$1(ngModule, providerDef) {
- var /** @type {?} */ injectable;
- switch (providerDef.flags & 201347067 /* Types */) {
- case 512 /* TypeClassProvider */:
- injectable = _createClass(ngModule, providerDef.value, providerDef.deps);
- break;
- case 1024 /* TypeFactoryProvider */:
- injectable = _callFactory(ngModule, providerDef.value, providerDef.deps);
- break;
- case 2048 /* TypeUseExistingProvider */:
- injectable = resolveNgModuleDep(ngModule, providerDef.deps[0]);
- break;
- case 256 /* TypeValueProvider */:
- injectable = providerDef.value;
- break;
- }
- return injectable === undefined ? UNDEFINED_VALUE : injectable;
- }
- /**
- * @param {?} ngModule
- * @param {?} ctor
- * @param {?} deps
- * @return {?}
- */
- function _createClass(ngModule, ctor, deps) {
- var /** @type {?} */ len = deps.length;
- switch (len) {
- case 0:
- return new ctor();
- case 1:
- return new ctor(resolveNgModuleDep(ngModule, deps[0]));
- case 2:
- return new ctor(resolveNgModuleDep(ngModule, deps[0]), resolveNgModuleDep(ngModule, deps[1]));
- case 3:
- return new ctor(resolveNgModuleDep(ngModule, deps[0]), resolveNgModuleDep(ngModule, deps[1]), resolveNgModuleDep(ngModule, deps[2]));
- default:
- var /** @type {?} */ depValues = new Array(len);
- for (var /** @type {?} */ i = 0; i < len; i++) {
- depValues[i] = resolveNgModuleDep(ngModule, deps[i]);
- }
- return new (ctor.bind.apply(ctor, [void 0].concat(depValues)))();
- }
- }
- /**
- * @param {?} ngModule
- * @param {?} factory
- * @param {?} deps
- * @return {?}
- */
- function _callFactory(ngModule, factory, deps) {
- var /** @type {?} */ len = deps.length;
- switch (len) {
- case 0:
- return factory();
- case 1:
- return factory(resolveNgModuleDep(ngModule, deps[0]));
- case 2:
- return factory(resolveNgModuleDep(ngModule, deps[0]), resolveNgModuleDep(ngModule, deps[1]));
- case 3:
- return factory(resolveNgModuleDep(ngModule, deps[0]), resolveNgModuleDep(ngModule, deps[1]), resolveNgModuleDep(ngModule, deps[2]));
- default:
- var /** @type {?} */ depValues = Array(len);
- for (var /** @type {?} */ i = 0; i < len; i++) {
- depValues[i] = resolveNgModuleDep(ngModule, deps[i]);
- }
- return factory.apply(void 0, depValues);
- }
- }
- /**
- * @param {?} ngModule
- * @param {?} lifecycles
- * @return {?}
- */
- function callNgModuleLifecycle(ngModule, lifecycles) {
- var /** @type {?} */ def = ngModule._def;
- for (var /** @type {?} */ i = 0; i < def.providers.length; i++) {
- var /** @type {?} */ provDef = def.providers[i];
- if (provDef.flags & 131072 /* OnDestroy */) {
- var /** @type {?} */ instance = ngModule._providers[i];
- if (instance && instance !== UNDEFINED_VALUE) {
- instance.ngOnDestroy();
- }
- }
- }
- }
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * @param {?} parentView
- * @param {?} elementData
- * @param {?} viewIndex
- * @param {?} view
- * @return {?}
- */
- function attachEmbeddedView(parentView, elementData, viewIndex, view) {
- var /** @type {?} */ embeddedViews = ((elementData.viewContainer))._embeddedViews;
- if (viewIndex === null || viewIndex === undefined) {
- viewIndex = embeddedViews.length;
- }
- view.viewContainerParent = parentView;
- addToArray(embeddedViews, /** @type {?} */ ((viewIndex)), view);
- attachProjectedView(elementData, view);
- Services.dirtyParentQueries(view);
- var /** @type {?} */ prevView = ((viewIndex)) > 0 ? embeddedViews[((viewIndex)) - 1] : null;
- renderAttachEmbeddedView(elementData, prevView, view);
- }
- /**
- * @param {?} vcElementData
- * @param {?} view
- * @return {?}
- */
- function attachProjectedView(vcElementData, view) {
- var /** @type {?} */ dvcElementData = declaredViewContainer(view);
- if (!dvcElementData || dvcElementData === vcElementData ||
- view.state & 16 /* IsProjectedView */) {
- return;
- }
- // Note: For performance reasons, we
- // - add a view to template._projectedViews only 1x throughout its lifetime,
- // and remove it not until the view is destroyed.
- // (hard, as when a parent view is attached/detached we would need to attach/detach all
- // nested projected views as well, even accross component boundaries).
- // - don't track the insertion order of views in the projected views array
- // (hard, as when the views of the same template are inserted different view containers)
- view.state |= 16 /* IsProjectedView */;
- var /** @type {?} */ projectedViews = dvcElementData.template._projectedViews;
- if (!projectedViews) {
- projectedViews = dvcElementData.template._projectedViews = [];
- }
- projectedViews.push(view);
- // Note: we are changing the NodeDef here as we cannot calculate
- // the fact whether a template is used for projection during compilation.
- markNodeAsProjectedTemplate(/** @type {?} */ ((view.parent)).def, /** @type {?} */ ((view.parentNodeDef)));
- }
- /**
- * @param {?} viewDef
- * @param {?} nodeDef
- * @return {?}
- */
- function markNodeAsProjectedTemplate(viewDef, nodeDef) {
- if (nodeDef.flags & 4 /* ProjectedTemplate */) {
- return;
- }
- viewDef.nodeFlags |= 4 /* ProjectedTemplate */;
- nodeDef.flags |= 4 /* ProjectedTemplate */;
- var /** @type {?} */ parentNodeDef = nodeDef.parent;
- while (parentNodeDef) {
- parentNodeDef.childFlags |= 4 /* ProjectedTemplate */;
- parentNodeDef = parentNodeDef.parent;
- }
- }
- /**
- * @param {?} elementData
- * @param {?=} viewIndex
- * @return {?}
- */
- function detachEmbeddedView(elementData, viewIndex) {
- var /** @type {?} */ embeddedViews = ((elementData.viewContainer))._embeddedViews;
- if (viewIndex == null || viewIndex >= embeddedViews.length) {
- viewIndex = embeddedViews.length - 1;
- }
- if (viewIndex < 0) {
- return null;
- }
- var /** @type {?} */ view = embeddedViews[viewIndex];
- view.viewContainerParent = null;
- removeFromArray(embeddedViews, viewIndex);
- // See attachProjectedView for why we don't update projectedViews here.
- Services.dirtyParentQueries(view);
- renderDetachView(view);
- return view;
- }
- /**
- * @param {?} view
- * @return {?}
- */
- function detachProjectedView(view) {
- if (!(view.state & 16 /* IsProjectedView */)) {
- return;
- }
- var /** @type {?} */ dvcElementData = declaredViewContainer(view);
- if (dvcElementData) {
- var /** @type {?} */ projectedViews = dvcElementData.template._projectedViews;
- if (projectedViews) {
- removeFromArray(projectedViews, projectedViews.indexOf(view));
- Services.dirtyParentQueries(view);
- }
- }
- }
- /**
- * @param {?} elementData
- * @param {?} oldViewIndex
- * @param {?} newViewIndex
- * @return {?}
- */
- function moveEmbeddedView(elementData, oldViewIndex, newViewIndex) {
- var /** @type {?} */ embeddedViews = ((elementData.viewContainer))._embeddedViews;
- var /** @type {?} */ view = embeddedViews[oldViewIndex];
- removeFromArray(embeddedViews, oldViewIndex);
- if (newViewIndex == null) {
- newViewIndex = embeddedViews.length;
- }
- addToArray(embeddedViews, newViewIndex, view);
- // Note: Don't need to change projectedViews as the order in there
- // as always invalid...
- Services.dirtyParentQueries(view);
- renderDetachView(view);
- var /** @type {?} */ prevView = newViewIndex > 0 ? embeddedViews[newViewIndex - 1] : null;
- renderAttachEmbeddedView(elementData, prevView, view);
- return view;
- }
- /**
- * @param {?} elementData
- * @param {?} prevView
- * @param {?} view
- * @return {?}
- */
- function renderAttachEmbeddedView(elementData, prevView, view) {
- var /** @type {?} */ prevRenderNode = prevView ? renderNode(prevView, /** @type {?} */ ((prevView.def.lastRenderRootNode))) :
- elementData.renderElement;
- var /** @type {?} */ parentNode = view.renderer.parentNode(prevRenderNode);
- var /** @type {?} */ nextSibling = view.renderer.nextSibling(prevRenderNode);
- // Note: We can't check if `nextSibling` is present, as on WebWorkers it will always be!
- // However, browsers automatically do `appendChild` when there is no `nextSibling`.
- visitRootRenderNodes(view, 2 /* InsertBefore */, parentNode, nextSibling, undefined);
- }
- /**
- * @param {?} view
- * @return {?}
- */
- function renderDetachView(view) {
- visitRootRenderNodes(view, 3 /* RemoveChild */, null, null, undefined);
- }
- /**
- * @param {?} arr
- * @param {?} index
- * @param {?} value
- * @return {?}
- */
- function addToArray(arr, index, value) {
- // perf: array.push is faster than array.splice!
- if (index >= arr.length) {
- arr.push(value);
- }
- else {
- arr.splice(index, 0, value);
- }
- }
- /**
- * @param {?} arr
- * @param {?} index
- * @return {?}
- */
- function removeFromArray(arr, index) {
- // perf: array.pop is faster than array.splice!
- if (index >= arr.length - 1) {
- arr.pop();
- }
- else {
- arr.splice(index, 1);
- }
- }
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var EMPTY_CONTEXT = new Object();
- var ComponentFactory_ = (function (_super) {
- __extends$1(ComponentFactory_, _super);
- /**
- * @param {?} selector
- * @param {?} componentType
- * @param {?} viewDefFactory
- * @param {?} _inputs
- * @param {?} _outputs
- * @param {?} ngContentSelectors
- */
- function ComponentFactory_(selector, componentType, viewDefFactory, _inputs, _outputs, ngContentSelectors) {
- var _this =
- // Attention: this ctor is called as top level function.
- // Putting any logic in here will destroy closure tree shaking!
- _super.call(this) || this;
- _this.selector = selector;
- _this.componentType = componentType;
- _this._inputs = _inputs;
- _this._outputs = _outputs;
- _this.ngContentSelectors = ngContentSelectors;
- _this.viewDefFactory = viewDefFactory;
- return _this;
- }
- Object.defineProperty(ComponentFactory_.prototype, "inputs", {
- /**
- * @return {?}
- */
- get: function () {
- var /** @type {?} */ inputsArr = [];
- var /** @type {?} */ inputs = ((this._inputs));
- for (var /** @type {?} */ propName in inputs) {
- var /** @type {?} */ templateName = inputs[propName];
- inputsArr.push({ propName: propName, templateName: templateName });
- }
- return inputsArr;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(ComponentFactory_.prototype, "outputs", {
- /**
- * @return {?}
- */
- get: function () {
- var /** @type {?} */ outputsArr = [];
- for (var /** @type {?} */ propName in this._outputs) {
- var /** @type {?} */ templateName = this._outputs[propName];
- outputsArr.push({ propName: propName, templateName: templateName });
- }
- return outputsArr;
- },
- enumerable: true,
- configurable: true
- });
- /**
- * Creates a new component.
- * @param {?} injector
- * @param {?=} projectableNodes
- * @param {?=} rootSelectorOrNode
- * @param {?=} ngModule
- * @return {?}
- */
- ComponentFactory_.prototype.create = function (injector, projectableNodes, rootSelectorOrNode, ngModule) {
- if (!ngModule) {
- throw new Error('ngModule should be provided');
- }
- var /** @type {?} */ viewDef = resolveDefinition(this.viewDefFactory);
- var /** @type {?} */ componentNodeIndex = ((((viewDef.nodes[0].element)).componentProvider)).nodeIndex;
- var /** @type {?} */ view = Services.createRootView(injector, projectableNodes || [], rootSelectorOrNode, viewDef, ngModule, EMPTY_CONTEXT);
- var /** @type {?} */ component = asProviderData(view, componentNodeIndex).instance;
- if (rootSelectorOrNode) {
- view.renderer.setAttribute(asElementData(view, 0).renderElement, 'ng-version', VERSION.full);
- }
- return new ComponentRef_(view, new ViewRef_(view), component);
- };
- return ComponentFactory_;
- }(ComponentFactory));
- var ComponentRef_ = (function (_super) {
- __extends$1(ComponentRef_, _super);
- /**
- * @param {?} _view
- * @param {?} _viewRef
- * @param {?} _component
- */
- function ComponentRef_(_view, _viewRef, _component) {
- var _this = _super.call(this) || this;
- _this._view = _view;
- _this._viewRef = _viewRef;
- _this._component = _component;
- _this._elDef = _this._view.def.nodes[0];
- return _this;
- }
- Object.defineProperty(ComponentRef_.prototype, "location", {
- /**
- * @return {?}
- */
- get: function () {
- return new ElementRef(asElementData(this._view, this._elDef.nodeIndex).renderElement);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(ComponentRef_.prototype, "injector", {
- /**
- * @return {?}
- */
- get: function () { return new Injector_(this._view, this._elDef); },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(ComponentRef_.prototype, "instance", {
- /**
- * @return {?}
- */
- get: function () { return this._component; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(ComponentRef_.prototype, "hostView", {
- /**
- * @return {?}
- */
- get: function () { return this._viewRef; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(ComponentRef_.prototype, "changeDetectorRef", {
- /**
- * @return {?}
- */
- get: function () { return this._viewRef; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(ComponentRef_.prototype, "componentType", {
- /**
- * @return {?}
- */
- get: function () { return (this._component.constructor); },
- enumerable: true,
- configurable: true
- });
- /**
- * @return {?}
- */
- ComponentRef_.prototype.destroy = function () { this._viewRef.destroy(); };
- /**
- * @param {?} callback
- * @return {?}
- */
- ComponentRef_.prototype.onDestroy = function (callback) { this._viewRef.onDestroy(callback); };
- return ComponentRef_;
- }(ComponentRef));
- /**
- * @param {?} view
- * @param {?} elDef
- * @param {?} elData
- * @return {?}
- */
- function createViewContainerData(view, elDef, elData) {
- return new ViewContainerRef_(view, elDef, elData);
- }
- var ViewContainerRef_ = (function () {
- /**
- * @param {?} _view
- * @param {?} _elDef
- * @param {?} _data
- */
- function ViewContainerRef_(_view, _elDef, _data) {
- this._view = _view;
- this._elDef = _elDef;
- this._data = _data;
- /**
- * \@internal
- */
- this._embeddedViews = [];
- }
- Object.defineProperty(ViewContainerRef_.prototype, "element", {
- /**
- * @return {?}
- */
- get: function () { return new ElementRef(this._data.renderElement); },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(ViewContainerRef_.prototype, "injector", {
- /**
- * @return {?}
- */
- get: function () { return new Injector_(this._view, this._elDef); },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(ViewContainerRef_.prototype, "parentInjector", {
- /**
- * @return {?}
- */
- get: function () {
- var /** @type {?} */ view = this._view;
- var /** @type {?} */ elDef = this._elDef.parent;
- while (!elDef && view) {
- elDef = viewParentEl(view);
- view = ((view.parent));
- }
- return view ? new Injector_(view, elDef) : new Injector_(this._view, null);
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @return {?}
- */
- ViewContainerRef_.prototype.clear = function () {
- var /** @type {?} */ len = this._embeddedViews.length;
- for (var /** @type {?} */ i = len - 1; i >= 0; i--) {
- var /** @type {?} */ view = ((detachEmbeddedView(this._data, i)));
- Services.destroyView(view);
- }
- };
- /**
- * @param {?} index
- * @return {?}
- */
- ViewContainerRef_.prototype.get = function (index) {
- var /** @type {?} */ view = this._embeddedViews[index];
- if (view) {
- var /** @type {?} */ ref = new ViewRef_(view);
- ref.attachToViewContainerRef(this);
- return ref;
- }
- return null;
- };
- Object.defineProperty(ViewContainerRef_.prototype, "length", {
- /**
- * @return {?}
- */
- get: function () { return this._embeddedViews.length; },
- enumerable: true,
- configurable: true
- });
- /**
- * @template C
- * @param {?} templateRef
- * @param {?=} context
- * @param {?=} index
- * @return {?}
- */
- ViewContainerRef_.prototype.createEmbeddedView = function (templateRef, context, index) {
- var /** @type {?} */ viewRef = templateRef.createEmbeddedView(context || ({}));
- this.insert(viewRef, index);
- return viewRef;
- };
- /**
- * @template C
- * @param {?} componentFactory
- * @param {?=} index
- * @param {?=} injector
- * @param {?=} projectableNodes
- * @param {?=} ngModuleRef
- * @return {?}
- */
- ViewContainerRef_.prototype.createComponent = function (componentFactory, index, injector, projectableNodes, ngModuleRef) {
- var /** @type {?} */ contextInjector = injector || this.parentInjector;
- if (!ngModuleRef && !(componentFactory instanceof ComponentFactoryBoundToModule)) {
- ngModuleRef = contextInjector.get(NgModuleRef);
- }
- var /** @type {?} */ componentRef = componentFactory.create(contextInjector, projectableNodes, undefined, ngModuleRef);
- this.insert(componentRef.hostView, index);
- return componentRef;
- };
- /**
- * @param {?} viewRef
- * @param {?=} index
- * @return {?}
- */
- ViewContainerRef_.prototype.insert = function (viewRef, index) {
- if (viewRef.destroyed) {
- throw new Error('Cannot insert a destroyed View in a ViewContainer!');
- }
- var /** @type {?} */ viewRef_ = (viewRef);
- var /** @type {?} */ viewData = viewRef_._view;
- attachEmbeddedView(this._view, this._data, index, viewData);
- viewRef_.attachToViewContainerRef(this);
- return viewRef;
- };
- /**
- * @param {?} viewRef
- * @param {?} currentIndex
- * @return {?}
- */
- ViewContainerRef_.prototype.move = function (viewRef, currentIndex) {
- if (viewRef.destroyed) {
- throw new Error('Cannot move a destroyed View in a ViewContainer!');
- }
- var /** @type {?} */ previousIndex = this._embeddedViews.indexOf(viewRef._view);
- moveEmbeddedView(this._data, previousIndex, currentIndex);
- return viewRef;
- };
- /**
- * @param {?} viewRef
- * @return {?}
- */
- ViewContainerRef_.prototype.indexOf = function (viewRef) {
- return this._embeddedViews.indexOf(((viewRef))._view);
- };
- /**
- * @param {?=} index
- * @return {?}
- */
- ViewContainerRef_.prototype.remove = function (index) {
- var /** @type {?} */ viewData = detachEmbeddedView(this._data, index);
- if (viewData) {
- Services.destroyView(viewData);
- }
- };
- /**
- * @param {?=} index
- * @return {?}
- */
- ViewContainerRef_.prototype.detach = function (index) {
- var /** @type {?} */ view = detachEmbeddedView(this._data, index);
- return view ? new ViewRef_(view) : null;
- };
- return ViewContainerRef_;
- }());
- /**
- * @param {?} view
- * @return {?}
- */
- function createChangeDetectorRef(view) {
- return new ViewRef_(view);
- }
- var ViewRef_ = (function () {
- /**
- * @param {?} _view
- */
- function ViewRef_(_view) {
- this._view = _view;
- this._viewContainerRef = null;
- this._appRef = null;
- }
- Object.defineProperty(ViewRef_.prototype, "rootNodes", {
- /**
- * @return {?}
- */
- get: function () { return rootRenderNodes(this._view); },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(ViewRef_.prototype, "context", {
- /**
- * @return {?}
- */
- get: function () { return this._view.context; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(ViewRef_.prototype, "destroyed", {
- /**
- * @return {?}
- */
- get: function () { return (this._view.state & 128 /* Destroyed */) !== 0; },
- enumerable: true,
- configurable: true
- });
- /**
- * @return {?}
- */
- ViewRef_.prototype.markForCheck = function () { markParentViewsForCheck(this._view); };
- /**
- * @return {?}
- */
- ViewRef_.prototype.detach = function () { this._view.state &= ~4 /* Attached */; };
- /**
- * @return {?}
- */
- ViewRef_.prototype.detectChanges = function () {
- var /** @type {?} */ fs = this._view.root.rendererFactory;
- if (fs.begin) {
- fs.begin();
- }
- Services.checkAndUpdateView(this._view);
- if (fs.end) {
- fs.end();
- }
- };
- /**
- * @return {?}
- */
- ViewRef_.prototype.checkNoChanges = function () { Services.checkNoChangesView(this._view); };
- /**
- * @return {?}
- */
- ViewRef_.prototype.reattach = function () { this._view.state |= 4 /* Attached */; };
- /**
- * @param {?} callback
- * @return {?}
- */
- ViewRef_.prototype.onDestroy = function (callback) {
- if (!this._view.disposables) {
- this._view.disposables = [];
- }
- this._view.disposables.push(/** @type {?} */ (callback));
- };
- /**
- * @return {?}
- */
- ViewRef_.prototype.destroy = function () {
- if (this._appRef) {
- this._appRef.detachView(this);
- }
- else if (this._viewContainerRef) {
- this._viewContainerRef.detach(this._viewContainerRef.indexOf(this));
- }
- Services.destroyView(this._view);
- };
- /**
- * @return {?}
- */
- ViewRef_.prototype.detachFromAppRef = function () {
- this._appRef = null;
- renderDetachView(this._view);
- Services.dirtyParentQueries(this._view);
- };
- /**
- * @param {?} appRef
- * @return {?}
- */
- ViewRef_.prototype.attachToAppRef = function (appRef) {
- if (this._viewContainerRef) {
- throw new Error('This view is already attached to a ViewContainer!');
- }
- this._appRef = appRef;
- };
- /**
- * @param {?} vcRef
- * @return {?}
- */
- ViewRef_.prototype.attachToViewContainerRef = function (vcRef) {
- if (this._appRef) {
- throw new Error('This view is already attached directly to the ApplicationRef!');
- }
- this._viewContainerRef = vcRef;
- };
- return ViewRef_;
- }());
- /**
- * @param {?} view
- * @param {?} def
- * @return {?}
- */
- function createTemplateData(view, def) {
- return new TemplateRef_(view, def);
- }
- var TemplateRef_ = (function (_super) {
- __extends$1(TemplateRef_, _super);
- /**
- * @param {?} _parentView
- * @param {?} _def
- */
- function TemplateRef_(_parentView, _def) {
- var _this = _super.call(this) || this;
- _this._parentView = _parentView;
- _this._def = _def;
- return _this;
- }
- /**
- * @param {?} context
- * @return {?}
- */
- TemplateRef_.prototype.createEmbeddedView = function (context) {
- return new ViewRef_(Services.createEmbeddedView(this._parentView, this._def, /** @type {?} */ ((((this._def.element)).template)), context));
- };
- Object.defineProperty(TemplateRef_.prototype, "elementRef", {
- /**
- * @return {?}
- */
- get: function () {
- return new ElementRef(asElementData(this._parentView, this._def.nodeIndex).renderElement);
- },
- enumerable: true,
- configurable: true
- });
- return TemplateRef_;
- }(TemplateRef));
- /**
- * @param {?} view
- * @param {?} elDef
- * @return {?}
- */
- function createInjector(view, elDef) {
- return new Injector_(view, elDef);
- }
- var Injector_ = (function () {
- /**
- * @param {?} view
- * @param {?} elDef
- */
- function Injector_(view, elDef) {
- this.view = view;
- this.elDef = elDef;
- }
- /**
- * @param {?} token
- * @param {?=} notFoundValue
- * @return {?}
- */
- Injector_.prototype.get = function (token, notFoundValue) {
- if (notFoundValue === void 0) { notFoundValue = Injector.THROW_IF_NOT_FOUND; }
- var /** @type {?} */ allowPrivateServices = this.elDef ? (this.elDef.flags & 33554432 /* ComponentView */) !== 0 : false;
- return Services.resolveDep(this.view, this.elDef, allowPrivateServices, { flags: 0 /* None */, token: token, tokenKey: tokenKey(token) }, notFoundValue);
- };
- return Injector_;
- }());
- /**
- * @param {?} view
- * @return {?}
- */
- function createRendererV1(view) {
- return new RendererAdapter(view.renderer);
- }
- var RendererAdapter = (function () {
- /**
- * @param {?} delegate
- */
- function RendererAdapter(delegate) {
- this.delegate = delegate;
- }
- /**
- * @param {?} selectorOrNode
- * @return {?}
- */
- RendererAdapter.prototype.selectRootElement = function (selectorOrNode) {
- return this.delegate.selectRootElement(selectorOrNode);
- };
- /**
- * @param {?} parent
- * @param {?} namespaceAndName
- * @return {?}
- */
- RendererAdapter.prototype.createElement = function (parent, namespaceAndName) {
- var _a = splitNamespace(namespaceAndName), ns = _a[0], name = _a[1];
- var /** @type {?} */ el = this.delegate.createElement(name, ns);
- if (parent) {
- this.delegate.appendChild(parent, el);
- }
- return el;
- };
- /**
- * @param {?} hostElement
- * @return {?}
- */
- RendererAdapter.prototype.createViewRoot = function (hostElement) { return hostElement; };
- /**
- * @param {?} parentElement
- * @return {?}
- */
- RendererAdapter.prototype.createTemplateAnchor = function (parentElement) {
- var /** @type {?} */ comment = this.delegate.createComment('');
- if (parentElement) {
- this.delegate.appendChild(parentElement, comment);
- }
- return comment;
- };
- /**
- * @param {?} parentElement
- * @param {?} value
- * @return {?}
- */
- RendererAdapter.prototype.createText = function (parentElement, value) {
- var /** @type {?} */ node = this.delegate.createText(value);
- if (parentElement) {
- this.delegate.appendChild(parentElement, node);
- }
- return node;
- };
- /**
- * @param {?} parentElement
- * @param {?} nodes
- * @return {?}
- */
- RendererAdapter.prototype.projectNodes = function (parentElement, nodes) {
- for (var /** @type {?} */ i = 0; i < nodes.length; i++) {
- this.delegate.appendChild(parentElement, nodes[i]);
- }
- };
- /**
- * @param {?} node
- * @param {?} viewRootNodes
- * @return {?}
- */
- RendererAdapter.prototype.attachViewAfter = function (node, viewRootNodes) {
- var /** @type {?} */ parentElement = this.delegate.parentNode(node);
- var /** @type {?} */ nextSibling = this.delegate.nextSibling(node);
- for (var /** @type {?} */ i = 0; i < viewRootNodes.length; i++) {
- this.delegate.insertBefore(parentElement, viewRootNodes[i], nextSibling);
- }
- };
- /**
- * @param {?} viewRootNodes
- * @return {?}
- */
- RendererAdapter.prototype.detachView = function (viewRootNodes) {
- for (var /** @type {?} */ i = 0; i < viewRootNodes.length; i++) {
- var /** @type {?} */ node = viewRootNodes[i];
- var /** @type {?} */ parentElement = this.delegate.parentNode(node);
- this.delegate.removeChild(parentElement, node);
- }
- };
- /**
- * @param {?} hostElement
- * @param {?} viewAllNodes
- * @return {?}
- */
- RendererAdapter.prototype.destroyView = function (hostElement, viewAllNodes) {
- for (var /** @type {?} */ i = 0; i < viewAllNodes.length; i++) {
- ((this.delegate.destroyNode))(viewAllNodes[i]);
- }
- };
- /**
- * @param {?} renderElement
- * @param {?} name
- * @param {?} callback
- * @return {?}
- */
- RendererAdapter.prototype.listen = function (renderElement, name, callback) {
- return this.delegate.listen(renderElement, name, /** @type {?} */ (callback));
- };
- /**
- * @param {?} target
- * @param {?} name
- * @param {?} callback
- * @return {?}
- */
- RendererAdapter.prototype.listenGlobal = function (target, name, callback) {
- return this.delegate.listen(target, name, /** @type {?} */ (callback));
- };
- /**
- * @param {?} renderElement
- * @param {?} propertyName
- * @param {?} propertyValue
- * @return {?}
- */
- RendererAdapter.prototype.setElementProperty = function (renderElement, propertyName, propertyValue) {
- this.delegate.setProperty(renderElement, propertyName, propertyValue);
- };
- /**
- * @param {?} renderElement
- * @param {?} namespaceAndName
- * @param {?} attributeValue
- * @return {?}
- */
- RendererAdapter.prototype.setElementAttribute = function (renderElement, namespaceAndName, attributeValue) {
- var _a = splitNamespace(namespaceAndName), ns = _a[0], name = _a[1];
- if (attributeValue != null) {
- this.delegate.setAttribute(renderElement, name, attributeValue, ns);
- }
- else {
- this.delegate.removeAttribute(renderElement, name, ns);
- }
- };
- /**
- * @param {?} renderElement
- * @param {?} propertyName
- * @param {?} propertyValue
- * @return {?}
- */
- RendererAdapter.prototype.setBindingDebugInfo = function (renderElement, propertyName, propertyValue) { };
- /**
- * @param {?} renderElement
- * @param {?} className
- * @param {?} isAdd
- * @return {?}
- */
- RendererAdapter.prototype.setElementClass = function (renderElement, className, isAdd) {
- if (isAdd) {
- this.delegate.addClass(renderElement, className);
- }
- else {
- this.delegate.removeClass(renderElement, className);
- }
- };
- /**
- * @param {?} renderElement
- * @param {?} styleName
- * @param {?} styleValue
- * @return {?}
- */
- RendererAdapter.prototype.setElementStyle = function (renderElement, styleName, styleValue) {
- if (styleValue != null) {
- this.delegate.setStyle(renderElement, styleName, styleValue);
- }
- else {
- this.delegate.removeStyle(renderElement, styleName);
- }
- };
- /**
- * @param {?} renderElement
- * @param {?} methodName
- * @param {?} args
- * @return {?}
- */
- RendererAdapter.prototype.invokeElementMethod = function (renderElement, methodName, args) {
- ((renderElement))[methodName].apply(renderElement, args);
- };
- /**
- * @param {?} renderNode
- * @param {?} text
- * @return {?}
- */
- RendererAdapter.prototype.setText = function (renderNode$$1, text) { this.delegate.setValue(renderNode$$1, text); };
- /**
- * @return {?}
- */
- RendererAdapter.prototype.animate = function () { throw new Error('Renderer.animate is no longer supported!'); };
- return RendererAdapter;
- }());
- /**
- * @param {?} moduleType
- * @param {?} parent
- * @param {?} bootstrapComponents
- * @param {?} def
- * @return {?}
- */
- function createNgModuleRef(moduleType, parent, bootstrapComponents, def) {
- return new NgModuleRef_(moduleType, parent, bootstrapComponents, def);
- }
- var NgModuleRef_ = (function () {
- /**
- * @param {?} _moduleType
- * @param {?} _parent
- * @param {?} _bootstrapComponents
- * @param {?} _def
- */
- function NgModuleRef_(_moduleType, _parent, _bootstrapComponents, _def) {
- this._moduleType = _moduleType;
- this._parent = _parent;
- this._bootstrapComponents = _bootstrapComponents;
- this._def = _def;
- this._destroyListeners = [];
- this._destroyed = false;
- initNgModule(this);
- }
- /**
- * @param {?} token
- * @param {?=} notFoundValue
- * @return {?}
- */
- NgModuleRef_.prototype.get = function (token, notFoundValue) {
- if (notFoundValue === void 0) { notFoundValue = Injector.THROW_IF_NOT_FOUND; }
- return resolveNgModuleDep(this, { token: token, tokenKey: tokenKey(token), flags: 0 /* None */ }, notFoundValue);
- };
- Object.defineProperty(NgModuleRef_.prototype, "instance", {
- /**
- * @return {?}
- */
- get: function () { return this.get(this._moduleType); },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(NgModuleRef_.prototype, "componentFactoryResolver", {
- /**
- * @return {?}
- */
- get: function () { return this.get(ComponentFactoryResolver); },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(NgModuleRef_.prototype, "injector", {
- /**
- * @return {?}
- */
- get: function () { return this; },
- enumerable: true,
- configurable: true
- });
- /**
- * @return {?}
- */
- NgModuleRef_.prototype.destroy = function () {
- if (this._destroyed) {
- throw new Error("The ng module " + stringify(this.instance.constructor) + " has already been destroyed.");
- }
- this._destroyed = true;
- callNgModuleLifecycle(this, 131072 /* OnDestroy */);
- this._destroyListeners.forEach(function (listener) { return listener(); });
- };
- /**
- * @param {?} callback
- * @return {?}
- */
- NgModuleRef_.prototype.onDestroy = function (callback) { this._destroyListeners.push(callback); };
- return NgModuleRef_;
- }());
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var RendererV1TokenKey = tokenKey(Renderer);
- var Renderer2TokenKey = tokenKey(Renderer2);
- var ElementRefTokenKey = tokenKey(ElementRef);
- var ViewContainerRefTokenKey = tokenKey(ViewContainerRef);
- var TemplateRefTokenKey = tokenKey(TemplateRef);
- var ChangeDetectorRefTokenKey = tokenKey(ChangeDetectorRef);
- var InjectorRefTokenKey = tokenKey(Injector);
- /**
- * @param {?} checkIndex
- * @param {?} flags
- * @param {?} matchedQueriesDsl
- * @param {?} childCount
- * @param {?} token
- * @param {?} value
- * @param {?} deps
- * @param {?=} bindings
- * @param {?=} outputs
- * @return {?}
- */
- function _def(checkIndex, flags, matchedQueriesDsl, childCount, token, value, deps, bindings, outputs) {
- var _a = splitMatchedQueriesDsl(matchedQueriesDsl), matchedQueries = _a.matchedQueries, references = _a.references, matchedQueryIds = _a.matchedQueryIds;
- if (!outputs) {
- outputs = [];
- }
- if (!bindings) {
- bindings = [];
- }
- var /** @type {?} */ depDefs = splitDepsDsl(deps);
- return {
- // will bet set by the view definition
- nodeIndex: -1,
- parent: null,
- renderParent: null,
- bindingIndex: -1,
- outputIndex: -1,
- // regular values
- checkIndex: checkIndex,
- flags: flags,
- childFlags: 0,
- directChildFlags: 0,
- childMatchedQueries: 0, matchedQueries: matchedQueries, matchedQueryIds: matchedQueryIds, references: references,
- ngContentIndex: -1, childCount: childCount, bindings: bindings,
- bindingFlags: calcBindingFlags(bindings), outputs: outputs,
- element: null,
- provider: { token: token, value: value, deps: depDefs },
- text: null,
- query: null,
- ngContent: null
- };
- }
- /**
- * @param {?} view
- * @param {?} def
- * @return {?}
- */
- function createProviderInstance(view, def) {
- return _createProviderInstance(view, def);
- }
- /**
- * @param {?} view
- * @param {?} def
- * @return {?}
- */
- function createPipeInstance(view, def) {
- // deps are looked up from component.
- var /** @type {?} */ compView = view;
- while (compView.parent && !isComponentView(compView)) {
- compView = compView.parent;
- }
- // pipes can see the private services of the component
- var /** @type {?} */ allowPrivateServices = true;
- // pipes are always eager and classes!
- return createClass(/** @type {?} */ ((compView.parent)), /** @type {?} */ ((viewParentEl(compView))), allowPrivateServices, /** @type {?} */ ((def.provider)).value, /** @type {?} */ ((def.provider)).deps);
- }
- /**
- * @param {?} view
- * @param {?} def
- * @return {?}
- */
- function createDirectiveInstance(view, def) {
- // components can see other private services, other directives can't.
- var /** @type {?} */ allowPrivateServices = (def.flags & 32768 /* Component */) > 0;
- // directives are always eager and classes!
- var /** @type {?} */ instance = createClass(view, /** @type {?} */ ((def.parent)), allowPrivateServices, /** @type {?} */ ((def.provider)).value, /** @type {?} */ ((def.provider)).deps);
- if (def.outputs.length) {
- for (var /** @type {?} */ i = 0; i < def.outputs.length; i++) {
- var /** @type {?} */ output = def.outputs[i];
- var /** @type {?} */ subscription = instance[((output.propName))].subscribe(eventHandlerClosure(view, /** @type {?} */ ((def.parent)).nodeIndex, output.eventName)); /** @type {?} */
- ((view.disposables))[def.outputIndex + i] = subscription.unsubscribe.bind(subscription);
- }
- }
- return instance;
- }
- /**
- * @param {?} view
- * @param {?} index
- * @param {?} eventName
- * @return {?}
- */
- function eventHandlerClosure(view, index, eventName) {
- return function (event) {
- try {
- return dispatchEvent(view, index, eventName, event);
- }
- catch (e) {
- // Attention: Don't rethrow, as it would cancel Observable subscriptions!
- view.root.errorHandler.handleError(e);
- }
- };
- }
- /**
- * @param {?} view
- * @param {?} def
- * @param {?} v0
- * @param {?} v1
- * @param {?} v2
- * @param {?} v3
- * @param {?} v4
- * @param {?} v5
- * @param {?} v6
- * @param {?} v7
- * @param {?} v8
- * @param {?} v9
- * @return {?}
- */
- function checkAndUpdateDirectiveInline(view, def, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
- var /** @type {?} */ providerData = asProviderData(view, def.nodeIndex);
- var /** @type {?} */ directive = providerData.instance;
- var /** @type {?} */ changed = false;
- var /** @type {?} */ changes = ((undefined));
- var /** @type {?} */ bindLen = def.bindings.length;
- if (bindLen > 0 && checkBinding(view, def, 0, v0)) {
- changed = true;
- changes = updateProp(view, providerData, def, 0, v0, changes);
- }
- if (bindLen > 1 && checkBinding(view, def, 1, v1)) {
- changed = true;
- changes = updateProp(view, providerData, def, 1, v1, changes);
- }
- if (bindLen > 2 && checkBinding(view, def, 2, v2)) {
- changed = true;
- changes = updateProp(view, providerData, def, 2, v2, changes);
- }
- if (bindLen > 3 && checkBinding(view, def, 3, v3)) {
- changed = true;
- changes = updateProp(view, providerData, def, 3, v3, changes);
- }
- if (bindLen > 4 && checkBinding(view, def, 4, v4)) {
- changed = true;
- changes = updateProp(view, providerData, def, 4, v4, changes);
- }
- if (bindLen > 5 && checkBinding(view, def, 5, v5)) {
- changed = true;
- changes = updateProp(view, providerData, def, 5, v5, changes);
- }
- if (bindLen > 6 && checkBinding(view, def, 6, v6)) {
- changed = true;
- changes = updateProp(view, providerData, def, 6, v6, changes);
- }
- if (bindLen > 7 && checkBinding(view, def, 7, v7)) {
- changed = true;
- changes = updateProp(view, providerData, def, 7, v7, changes);
- }
- if (bindLen > 8 && checkBinding(view, def, 8, v8)) {
- changed = true;
- changes = updateProp(view, providerData, def, 8, v8, changes);
- }
- if (bindLen > 9 && checkBinding(view, def, 9, v9)) {
- changed = true;
- changes = updateProp(view, providerData, def, 9, v9, changes);
- }
- if (changes) {
- directive.ngOnChanges(changes);
- }
- if ((view.state & 2 /* FirstCheck */) && (def.flags & 65536 /* OnInit */)) {
- directive.ngOnInit();
- }
- if (def.flags & 262144 /* DoCheck */) {
- directive.ngDoCheck();
- }
- return changed;
- }
- /**
- * @param {?} view
- * @param {?} def
- * @param {?} values
- * @return {?}
- */
- function checkAndUpdateDirectiveDynamic(view, def, values) {
- var /** @type {?} */ providerData = asProviderData(view, def.nodeIndex);
- var /** @type {?} */ directive = providerData.instance;
- var /** @type {?} */ changed = false;
- var /** @type {?} */ changes = ((undefined));
- for (var /** @type {?} */ i = 0; i < values.length; i++) {
- if (checkBinding(view, def, i, values[i])) {
- changed = true;
- changes = updateProp(view, providerData, def, i, values[i], changes);
- }
- }
- if (changes) {
- directive.ngOnChanges(changes);
- }
- if ((view.state & 2 /* FirstCheck */) && (def.flags & 65536 /* OnInit */)) {
- directive.ngOnInit();
- }
- if (def.flags & 262144 /* DoCheck */) {
- directive.ngDoCheck();
- }
- return changed;
- }
- /**
- * @param {?} view
- * @param {?} def
- * @return {?}
- */
- function _createProviderInstance(view, def) {
- // private services can see other private services
- var /** @type {?} */ allowPrivateServices = (def.flags & 8192 /* PrivateProvider */) > 0;
- var /** @type {?} */ providerDef = def.provider;
- switch (def.flags & 201347067 /* Types */) {
- case 512 /* TypeClassProvider */:
- return createClass(view, /** @type {?} */ ((def.parent)), allowPrivateServices, /** @type {?} */ ((providerDef)).value, /** @type {?} */ ((providerDef)).deps);
- case 1024 /* TypeFactoryProvider */:
- return callFactory(view, /** @type {?} */ ((def.parent)), allowPrivateServices, /** @type {?} */ ((providerDef)).value, /** @type {?} */ ((providerDef)).deps);
- case 2048 /* TypeUseExistingProvider */:
- return resolveDep(view, /** @type {?} */ ((def.parent)), allowPrivateServices, /** @type {?} */ ((providerDef)).deps[0]);
- case 256 /* TypeValueProvider */:
- return ((providerDef)).value;
- }
- }
- /**
- * @param {?} view
- * @param {?} elDef
- * @param {?} allowPrivateServices
- * @param {?} ctor
- * @param {?} deps
- * @return {?}
- */
- function createClass(view, elDef, allowPrivateServices, ctor, deps) {
- var /** @type {?} */ len = deps.length;
- switch (len) {
- case 0:
- return new ctor();
- case 1:
- return new ctor(resolveDep(view, elDef, allowPrivateServices, deps[0]));
- case 2:
- return new ctor(resolveDep(view, elDef, allowPrivateServices, deps[0]), resolveDep(view, elDef, allowPrivateServices, deps[1]));
- case 3:
- return new ctor(resolveDep(view, elDef, allowPrivateServices, deps[0]), resolveDep(view, elDef, allowPrivateServices, deps[1]), resolveDep(view, elDef, allowPrivateServices, deps[2]));
- default:
- var /** @type {?} */ depValues = new Array(len);
- for (var /** @type {?} */ i = 0; i < len; i++) {
- depValues[i] = resolveDep(view, elDef, allowPrivateServices, deps[i]);
- }
- return new (ctor.bind.apply(ctor, [void 0].concat(depValues)))();
- }
- }
- /**
- * @param {?} view
- * @param {?} elDef
- * @param {?} allowPrivateServices
- * @param {?} factory
- * @param {?} deps
- * @return {?}
- */
- function callFactory(view, elDef, allowPrivateServices, factory, deps) {
- var /** @type {?} */ len = deps.length;
- switch (len) {
- case 0:
- return factory();
- case 1:
- return factory(resolveDep(view, elDef, allowPrivateServices, deps[0]));
- case 2:
- return factory(resolveDep(view, elDef, allowPrivateServices, deps[0]), resolveDep(view, elDef, allowPrivateServices, deps[1]));
- case 3:
- return factory(resolveDep(view, elDef, allowPrivateServices, deps[0]), resolveDep(view, elDef, allowPrivateServices, deps[1]), resolveDep(view, elDef, allowPrivateServices, deps[2]));
- default:
- var /** @type {?} */ depValues = Array(len);
- for (var /** @type {?} */ i = 0; i < len; i++) {
- depValues[i] = resolveDep(view, elDef, allowPrivateServices, deps[i]);
- }
- return factory.apply(void 0, depValues);
- }
- }
- // This default value is when checking the hierarchy for a token.
- //
- // It means both:
- // - the token is not provided by the current injector,
- // - only the element injectors should be checked (ie do not check module injectors
- //
- // mod1
- // /
- // el1 mod2
- // \ /
- // el2
- //
- // When requesting el2.injector.get(token), we should check in the following order and return the
- // first found value:
- // - el2.injector.get(token, default)
- // - el1.injector.get(token, NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR) -> do not check the module
- // - mod2.injector.get(token, default)
- var NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR = {};
- /**
- * @param {?} view
- * @param {?} elDef
- * @param {?} allowPrivateServices
- * @param {?} depDef
- * @param {?=} notFoundValue
- * @return {?}
- */
- function resolveDep(view, elDef, allowPrivateServices, depDef, notFoundValue) {
- if (notFoundValue === void 0) { notFoundValue = Injector.THROW_IF_NOT_FOUND; }
- if (depDef.flags & 8 /* Value */) {
- return depDef.token;
- }
- var /** @type {?} */ startView = view;
- if (depDef.flags & 2 /* Optional */) {
- notFoundValue = null;
- }
- var /** @type {?} */ tokenKey$$1 = depDef.tokenKey;
- if (tokenKey$$1 === ChangeDetectorRefTokenKey) {
- // directives on the same element as a component should be able to control the change detector
- // of that component as well.
- allowPrivateServices = !!(elDef && ((elDef.element)).componentView);
- }
- if (elDef && (depDef.flags & 1 /* SkipSelf */)) {
- allowPrivateServices = false;
- elDef = ((elDef.parent));
- }
- while (view) {
- if (elDef) {
- switch (tokenKey$$1) {
- case RendererV1TokenKey: {
- var /** @type {?} */ compView = findCompView(view, elDef, allowPrivateServices);
- return createRendererV1(compView);
- }
- case Renderer2TokenKey: {
- var /** @type {?} */ compView = findCompView(view, elDef, allowPrivateServices);
- return compView.renderer;
- }
- case ElementRefTokenKey:
- return new ElementRef(asElementData(view, elDef.nodeIndex).renderElement);
- case ViewContainerRefTokenKey:
- return asElementData(view, elDef.nodeIndex).viewContainer;
- case TemplateRefTokenKey: {
- if (((elDef.element)).template) {
- return asElementData(view, elDef.nodeIndex).template;
- }
- break;
- }
- case ChangeDetectorRefTokenKey: {
- var /** @type {?} */ cdView = findCompView(view, elDef, allowPrivateServices);
- return createChangeDetectorRef(cdView);
- }
- case InjectorRefTokenKey:
- return createInjector(view, elDef);
- default:
- var /** @type {?} */ providerDef_1 = (((allowPrivateServices ? ((elDef.element)).allProviders : ((elDef.element)).publicProviders)))[tokenKey$$1];
- if (providerDef_1) {
- var /** @type {?} */ providerData = asProviderData(view, providerDef_1.nodeIndex);
- if (!providerData) {
- providerData = { instance: _createProviderInstance(view, providerDef_1) };
- view.nodes[providerDef_1.nodeIndex] = (providerData);
- }
- return providerData.instance;
- }
- }
- }
- allowPrivateServices = isComponentView(view);
- elDef = ((viewParentEl(view)));
- view = ((view.parent));
- }
- var /** @type {?} */ value = startView.root.injector.get(depDef.token, NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR);
- if (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR ||
- notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR) {
- // Return the value from the root element injector when
- // - it provides it
- // (value !== NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
- // - the module injector should not be checked
- // (notFoundValue === NOT_FOUND_CHECK_ONLY_ELEMENT_INJECTOR)
- return value;
- }
- return startView.root.ngModule.injector.get(depDef.token, notFoundValue);
- }
- /**
- * @param {?} view
- * @param {?} elDef
- * @param {?} allowPrivateServices
- * @return {?}
- */
- function findCompView(view, elDef, allowPrivateServices) {
- var /** @type {?} */ compView;
- if (allowPrivateServices) {
- compView = asElementData(view, elDef.nodeIndex).componentView;
- }
- else {
- compView = view;
- while (compView.parent && !isComponentView(compView)) {
- compView = compView.parent;
- }
- }
- return compView;
- }
- /**
- * @param {?} view
- * @param {?} providerData
- * @param {?} def
- * @param {?} bindingIdx
- * @param {?} value
- * @param {?} changes
- * @return {?}
- */
- function updateProp(view, providerData, def, bindingIdx, value, changes) {
- if (def.flags & 32768 /* Component */) {
- var /** @type {?} */ compView = asElementData(view, /** @type {?} */ ((def.parent)).nodeIndex).componentView;
- if (compView.def.flags & 2 /* OnPush */) {
- compView.state |= 8 /* ChecksEnabled */;
- }
- }
- var /** @type {?} */ binding = def.bindings[bindingIdx];
- var /** @type {?} */ propName = ((binding.name));
- // Note: This is still safe with Closure Compiler as
- // the user passed in the property name as an object has to `providerDef`,
- // so Closure Compiler will have renamed the property correctly already.
- providerData.instance[propName] = value;
- if (def.flags & 524288 /* OnChanges */) {
- changes = changes || {};
- var /** @type {?} */ oldValue = view.oldValues[def.bindingIndex + bindingIdx];
- if (oldValue instanceof WrappedValue) {
- oldValue = oldValue.wrapped;
- }
- var /** @type {?} */ binding_1 = def.bindings[bindingIdx];
- changes[((binding_1.nonMinifiedName))] =
- new SimpleChange(oldValue, value, (view.state & 2 /* FirstCheck */) !== 0);
- }
- view.oldValues[def.bindingIndex + bindingIdx] = value;
- return changes;
- }
- /**
- * @param {?} view
- * @param {?} lifecycles
- * @return {?}
- */
- function callLifecycleHooksChildrenFirst(view, lifecycles) {
- if (!(view.def.nodeFlags & lifecycles)) {
- return;
- }
- var /** @type {?} */ nodes = view.def.nodes;
- for (var /** @type {?} */ i = 0; i < nodes.length; i++) {
- var /** @type {?} */ nodeDef = nodes[i];
- var /** @type {?} */ parent = nodeDef.parent;
- if (!parent && nodeDef.flags & lifecycles) {
- // matching root node (e.g. a pipe)
- callProviderLifecycles(view, i, nodeDef.flags & lifecycles);
- }
- if ((nodeDef.childFlags & lifecycles) === 0) {
- // no child matches one of the lifecycles
- i += nodeDef.childCount;
- }
- while (parent && (parent.flags & 1 /* TypeElement */) &&
- i === parent.nodeIndex + parent.childCount) {
- // last child of an element
- if (parent.directChildFlags & lifecycles) {
- callElementProvidersLifecycles(view, parent, lifecycles);
- }
- parent = parent.parent;
- }
- }
- }
- /**
- * @param {?} view
- * @param {?} elDef
- * @param {?} lifecycles
- * @return {?}
- */
- function callElementProvidersLifecycles(view, elDef, lifecycles) {
- for (var /** @type {?} */ i = elDef.nodeIndex + 1; i <= elDef.nodeIndex + elDef.childCount; i++) {
- var /** @type {?} */ nodeDef = view.def.nodes[i];
- if (nodeDef.flags & lifecycles) {
- callProviderLifecycles(view, i, nodeDef.flags & lifecycles);
- }
- // only visit direct children
- i += nodeDef.childCount;
- }
- }
- /**
- * @param {?} view
- * @param {?} index
- * @param {?} lifecycles
- * @return {?}
- */
- function callProviderLifecycles(view, index, lifecycles) {
- var /** @type {?} */ providerData = asProviderData(view, index);
- if (!providerData) {
- return;
- }
- var /** @type {?} */ provider = providerData.instance;
- if (!provider) {
- return;
- }
- Services.setCurrentNode(view, index);
- if (lifecycles & 1048576 /* AfterContentInit */) {
- provider.ngAfterContentInit();
- }
- if (lifecycles & 2097152 /* AfterContentChecked */) {
- provider.ngAfterContentChecked();
- }
- if (lifecycles & 4194304 /* AfterViewInit */) {
- provider.ngAfterViewInit();
- }
- if (lifecycles & 8388608 /* AfterViewChecked */) {
- provider.ngAfterViewChecked();
- }
- if (lifecycles & 131072 /* OnDestroy */) {
- provider.ngOnDestroy();
- }
- }
- /**
- * @return {?}
- */
- function createQuery() {
- return new QueryList();
- }
- /**
- * @param {?} view
- * @return {?}
- */
- function dirtyParentQueries(view) {
- var /** @type {?} */ queryIds = view.def.nodeMatchedQueries;
- while (view.parent && isEmbeddedView(view)) {
- var /** @type {?} */ tplDef = ((view.parentNodeDef));
- view = view.parent;
- // content queries
- var /** @type {?} */ end = tplDef.nodeIndex + tplDef.childCount;
- for (var /** @type {?} */ i = 0; i <= end; i++) {
- var /** @type {?} */ nodeDef = view.def.nodes[i];
- if ((nodeDef.flags & 67108864 /* TypeContentQuery */) &&
- (nodeDef.flags & 536870912 /* DynamicQuery */) &&
- (((nodeDef.query)).filterId & queryIds) === ((nodeDef.query)).filterId) {
- asQueryList(view, i).setDirty();
- }
- if ((nodeDef.flags & 1 /* TypeElement */ && i + nodeDef.childCount < tplDef.nodeIndex) ||
- !(nodeDef.childFlags & 67108864 /* TypeContentQuery */) ||
- !(nodeDef.childFlags & 536870912 /* DynamicQuery */)) {
- // skip elements that don't contain the template element or no query.
- i += nodeDef.childCount;
- }
- }
- }
- // view queries
- if (view.def.nodeFlags & 134217728 /* TypeViewQuery */) {
- for (var /** @type {?} */ i = 0; i < view.def.nodes.length; i++) {
- var /** @type {?} */ nodeDef = view.def.nodes[i];
- if ((nodeDef.flags & 134217728 /* TypeViewQuery */) && (nodeDef.flags & 536870912 /* DynamicQuery */)) {
- asQueryList(view, i).setDirty();
- }
- // only visit the root nodes
- i += nodeDef.childCount;
- }
- }
- }
- /**
- * @param {?} view
- * @param {?} nodeDef
- * @return {?}
- */
- function checkAndUpdateQuery(view, nodeDef) {
- var /** @type {?} */ queryList = asQueryList(view, nodeDef.nodeIndex);
- if (!queryList.dirty) {
- return;
- }
- var /** @type {?} */ directiveInstance;
- var /** @type {?} */ newValues = ((undefined));
- if (nodeDef.flags & 67108864 /* TypeContentQuery */) {
- var /** @type {?} */ elementDef_1 = ((((nodeDef.parent)).parent));
- newValues = calcQueryValues(view, elementDef_1.nodeIndex, elementDef_1.nodeIndex + elementDef_1.childCount, /** @type {?} */ ((nodeDef.query)), []);
- directiveInstance = asProviderData(view, /** @type {?} */ ((nodeDef.parent)).nodeIndex).instance;
- }
- else if (nodeDef.flags & 134217728 /* TypeViewQuery */) {
- newValues = calcQueryValues(view, 0, view.def.nodes.length - 1, /** @type {?} */ ((nodeDef.query)), []);
- directiveInstance = view.component;
- }
- queryList.reset(newValues);
- var /** @type {?} */ bindings = ((nodeDef.query)).bindings;
- var /** @type {?} */ notify = false;
- for (var /** @type {?} */ i = 0; i < bindings.length; i++) {
- var /** @type {?} */ binding = bindings[i];
- var /** @type {?} */ boundValue = void 0;
- switch (binding.bindingType) {
- case 0 /* First */:
- boundValue = queryList.first;
- break;
- case 1 /* All */:
- boundValue = queryList;
- notify = true;
- break;
- }
- directiveInstance[binding.propName] = boundValue;
- }
- if (notify) {
- queryList.notifyOnChanges();
- }
- }
- /**
- * @param {?} view
- * @param {?} startIndex
- * @param {?} endIndex
- * @param {?} queryDef
- * @param {?} values
- * @return {?}
- */
- function calcQueryValues(view, startIndex, endIndex, queryDef, values) {
- for (var /** @type {?} */ i = startIndex; i <= endIndex; i++) {
- var /** @type {?} */ nodeDef = view.def.nodes[i];
- var /** @type {?} */ valueType = nodeDef.matchedQueries[queryDef.id];
- if (valueType != null) {
- values.push(getQueryValue(view, nodeDef, valueType));
- }
- if (nodeDef.flags & 1 /* TypeElement */ && ((nodeDef.element)).template &&
- (((((nodeDef.element)).template)).nodeMatchedQueries & queryDef.filterId) ===
- queryDef.filterId) {
- var /** @type {?} */ elementData = asElementData(view, i);
- // check embedded views that were attached at the place of their template,
- // but process child nodes first if some match the query (see issue #16568)
- if ((nodeDef.childMatchedQueries & queryDef.filterId) === queryDef.filterId) {
- calcQueryValues(view, i + 1, i + nodeDef.childCount, queryDef, values);
- i += nodeDef.childCount;
- }
- if (nodeDef.flags & 16777216 /* EmbeddedViews */) {
- var /** @type {?} */ embeddedViews = ((elementData.viewContainer))._embeddedViews;
- for (var /** @type {?} */ k = 0; k < embeddedViews.length; k++) {
- var /** @type {?} */ embeddedView = embeddedViews[k];
- var /** @type {?} */ dvc = declaredViewContainer(embeddedView);
- if (dvc && dvc === elementData) {
- calcQueryValues(embeddedView, 0, embeddedView.def.nodes.length - 1, queryDef, values);
- }
- }
- }
- var /** @type {?} */ projectedViews = elementData.template._projectedViews;
- if (projectedViews) {
- for (var /** @type {?} */ k = 0; k < projectedViews.length; k++) {
- var /** @type {?} */ projectedView = projectedViews[k];
- calcQueryValues(projectedView, 0, projectedView.def.nodes.length - 1, queryDef, values);
- }
- }
- }
- if ((nodeDef.childMatchedQueries & queryDef.filterId) !== queryDef.filterId) {
- // if no child matches the query, skip the children.
- i += nodeDef.childCount;
- }
- }
- return values;
- }
- /**
- * @param {?} view
- * @param {?} nodeDef
- * @param {?} queryValueType
- * @return {?}
- */
- function getQueryValue(view, nodeDef, queryValueType) {
- if (queryValueType != null) {
- // a match
- switch (queryValueType) {
- case 1 /* RenderElement */:
- return asElementData(view, nodeDef.nodeIndex).renderElement;
- case 0 /* ElementRef */:
- return new ElementRef(asElementData(view, nodeDef.nodeIndex).renderElement);
- case 2 /* TemplateRef */:
- return asElementData(view, nodeDef.nodeIndex).template;
- case 3 /* ViewContainerRef */:
- return asElementData(view, nodeDef.nodeIndex).viewContainer;
- case 4 /* Provider */:
- return asProviderData(view, nodeDef.nodeIndex).instance;
- }
- }
- }
- /**
- * @param {?} view
- * @param {?} renderHost
- * @param {?} def
- * @return {?}
- */
- function appendNgContent(view, renderHost, def) {
- var /** @type {?} */ parentEl = getParentRenderElement(view, renderHost, def);
- if (!parentEl) {
- // Nothing to do if there is no parent element.
- return;
- }
- var /** @type {?} */ ngContentIndex = ((def.ngContent)).index;
- visitProjectedRenderNodes(view, ngContentIndex, 1 /* AppendChild */, parentEl, null, undefined);
- }
- /**
- * @param {?} flags
- * @param {?} checkIndex
- * @param {?} propertyNames
- * @return {?}
- */
- function _pureExpressionDef(flags, checkIndex, propertyNames) {
- var /** @type {?} */ bindings = new Array(propertyNames.length);
- for (var /** @type {?} */ i = 0; i < propertyNames.length; i++) {
- var /** @type {?} */ prop = propertyNames[i];
- bindings[i] = {
- flags: 8 /* TypeProperty */,
- name: prop,
- ns: null,
- nonMinifiedName: prop,
- securityContext: null,
- suffix: null
- };
- }
- return {
- // will bet set by the view definition
- nodeIndex: -1,
- parent: null,
- renderParent: null,
- bindingIndex: -1,
- outputIndex: -1,
- // regular values
- checkIndex: checkIndex,
- flags: flags,
- childFlags: 0,
- directChildFlags: 0,
- childMatchedQueries: 0,
- matchedQueries: {},
- matchedQueryIds: 0,
- references: {},
- ngContentIndex: -1,
- childCount: 0, bindings: bindings,
- bindingFlags: calcBindingFlags(bindings),
- outputs: [],
- element: null,
- provider: null,
- text: null,
- query: null,
- ngContent: null
- };
- }
- /**
- * @param {?} view
- * @param {?} def
- * @return {?}
- */
- function createPureExpression(view, def) {
- return { value: undefined };
- }
- /**
- * @param {?} view
- * @param {?} def
- * @param {?} v0
- * @param {?} v1
- * @param {?} v2
- * @param {?} v3
- * @param {?} v4
- * @param {?} v5
- * @param {?} v6
- * @param {?} v7
- * @param {?} v8
- * @param {?} v9
- * @return {?}
- */
- function checkAndUpdatePureExpressionInline(view, def, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
- var /** @type {?} */ bindings = def.bindings;
- var /** @type {?} */ changed = false;
- var /** @type {?} */ bindLen = bindings.length;
- if (bindLen > 0 && checkAndUpdateBinding(view, def, 0, v0))
- changed = true;
- if (bindLen > 1 && checkAndUpdateBinding(view, def, 1, v1))
- changed = true;
- if (bindLen > 2 && checkAndUpdateBinding(view, def, 2, v2))
- changed = true;
- if (bindLen > 3 && checkAndUpdateBinding(view, def, 3, v3))
- changed = true;
- if (bindLen > 4 && checkAndUpdateBinding(view, def, 4, v4))
- changed = true;
- if (bindLen > 5 && checkAndUpdateBinding(view, def, 5, v5))
- changed = true;
- if (bindLen > 6 && checkAndUpdateBinding(view, def, 6, v6))
- changed = true;
- if (bindLen > 7 && checkAndUpdateBinding(view, def, 7, v7))
- changed = true;
- if (bindLen > 8 && checkAndUpdateBinding(view, def, 8, v8))
- changed = true;
- if (bindLen > 9 && checkAndUpdateBinding(view, def, 9, v9))
- changed = true;
- if (changed) {
- var /** @type {?} */ data = asPureExpressionData(view, def.nodeIndex);
- var /** @type {?} */ value = void 0;
- switch (def.flags & 201347067 /* Types */) {
- case 32 /* TypePureArray */:
- value = new Array(bindings.length);
- if (bindLen > 0)
- value[0] = v0;
- if (bindLen > 1)
- value[1] = v1;
- if (bindLen > 2)
- value[2] = v2;
- if (bindLen > 3)
- value[3] = v3;
- if (bindLen > 4)
- value[4] = v4;
- if (bindLen > 5)
- value[5] = v5;
- if (bindLen > 6)
- value[6] = v6;
- if (bindLen > 7)
- value[7] = v7;
- if (bindLen > 8)
- value[8] = v8;
- if (bindLen > 9)
- value[9] = v9;
- break;
- case 64 /* TypePureObject */:
- value = {};
- if (bindLen > 0)
- value[((bindings[0].name))] = v0;
- if (bindLen > 1)
- value[((bindings[1].name))] = v1;
- if (bindLen > 2)
- value[((bindings[2].name))] = v2;
- if (bindLen > 3)
- value[((bindings[3].name))] = v3;
- if (bindLen > 4)
- value[((bindings[4].name))] = v4;
- if (bindLen > 5)
- value[((bindings[5].name))] = v5;
- if (bindLen > 6)
- value[((bindings[6].name))] = v6;
- if (bindLen > 7)
- value[((bindings[7].name))] = v7;
- if (bindLen > 8)
- value[((bindings[8].name))] = v8;
- if (bindLen > 9)
- value[((bindings[9].name))] = v9;
- break;
- case 128 /* TypePurePipe */:
- var /** @type {?} */ pipe = v0;
- switch (bindLen) {
- case 1:
- value = pipe.transform(v0);
- break;
- case 2:
- value = pipe.transform(v1);
- break;
- case 3:
- value = pipe.transform(v1, v2);
- break;
- case 4:
- value = pipe.transform(v1, v2, v3);
- break;
- case 5:
- value = pipe.transform(v1, v2, v3, v4);
- break;
- case 6:
- value = pipe.transform(v1, v2, v3, v4, v5);
- break;
- case 7:
- value = pipe.transform(v1, v2, v3, v4, v5, v6);
- break;
- case 8:
- value = pipe.transform(v1, v2, v3, v4, v5, v6, v7);
- break;
- case 9:
- value = pipe.transform(v1, v2, v3, v4, v5, v6, v7, v8);
- break;
- case 10:
- value = pipe.transform(v1, v2, v3, v4, v5, v6, v7, v8, v9);
- break;
- }
- break;
- }
- data.value = value;
- }
- return changed;
- }
- /**
- * @param {?} view
- * @param {?} def
- * @param {?} values
- * @return {?}
- */
- function checkAndUpdatePureExpressionDynamic(view, def, values) {
- var /** @type {?} */ bindings = def.bindings;
- var /** @type {?} */ changed = false;
- for (var /** @type {?} */ i = 0; i < values.length; i++) {
- // Note: We need to loop over all values, so that
- // the old values are updates as well!
- if (checkAndUpdateBinding(view, def, i, values[i])) {
- changed = true;
- }
- }
- if (changed) {
- var /** @type {?} */ data = asPureExpressionData(view, def.nodeIndex);
- var /** @type {?} */ value = void 0;
- switch (def.flags & 201347067 /* Types */) {
- case 32 /* TypePureArray */:
- value = values;
- break;
- case 64 /* TypePureObject */:
- value = {};
- for (var /** @type {?} */ i = 0; i < values.length; i++) {
- value[((bindings[i].name))] = values[i];
- }
- break;
- case 128 /* TypePurePipe */:
- var /** @type {?} */ pipe = values[0];
- var /** @type {?} */ params = values.slice(1);
- value = pipe.transform.apply(pipe, params);
- break;
- }
- data.value = value;
- }
- return changed;
- }
- /**
- * @param {?} view
- * @param {?} renderHost
- * @param {?} def
- * @return {?}
- */
- function createText(view, renderHost, def) {
- var /** @type {?} */ renderNode$$1;
- var /** @type {?} */ renderer = view.renderer;
- renderNode$$1 = renderer.createText(/** @type {?} */ ((def.text)).prefix);
- var /** @type {?} */ parentEl = getParentRenderElement(view, renderHost, def);
- if (parentEl) {
- renderer.appendChild(parentEl, renderNode$$1);
- }
- return { renderText: renderNode$$1 };
- }
- /**
- * @param {?} view
- * @param {?} def
- * @param {?} v0
- * @param {?} v1
- * @param {?} v2
- * @param {?} v3
- * @param {?} v4
- * @param {?} v5
- * @param {?} v6
- * @param {?} v7
- * @param {?} v8
- * @param {?} v9
- * @return {?}
- */
- function checkAndUpdateTextInline(view, def, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
- var /** @type {?} */ changed = false;
- var /** @type {?} */ bindings = def.bindings;
- var /** @type {?} */ bindLen = bindings.length;
- if (bindLen > 0 && checkAndUpdateBinding(view, def, 0, v0))
- changed = true;
- if (bindLen > 1 && checkAndUpdateBinding(view, def, 1, v1))
- changed = true;
- if (bindLen > 2 && checkAndUpdateBinding(view, def, 2, v2))
- changed = true;
- if (bindLen > 3 && checkAndUpdateBinding(view, def, 3, v3))
- changed = true;
- if (bindLen > 4 && checkAndUpdateBinding(view, def, 4, v4))
- changed = true;
- if (bindLen > 5 && checkAndUpdateBinding(view, def, 5, v5))
- changed = true;
- if (bindLen > 6 && checkAndUpdateBinding(view, def, 6, v6))
- changed = true;
- if (bindLen > 7 && checkAndUpdateBinding(view, def, 7, v7))
- changed = true;
- if (bindLen > 8 && checkAndUpdateBinding(view, def, 8, v8))
- changed = true;
- if (bindLen > 9 && checkAndUpdateBinding(view, def, 9, v9))
- changed = true;
- if (changed) {
- var /** @type {?} */ value = ((def.text)).prefix;
- if (bindLen > 0)
- value += _addInterpolationPart(v0, bindings[0]);
- if (bindLen > 1)
- value += _addInterpolationPart(v1, bindings[1]);
- if (bindLen > 2)
- value += _addInterpolationPart(v2, bindings[2]);
- if (bindLen > 3)
- value += _addInterpolationPart(v3, bindings[3]);
- if (bindLen > 4)
- value += _addInterpolationPart(v4, bindings[4]);
- if (bindLen > 5)
- value += _addInterpolationPart(v5, bindings[5]);
- if (bindLen > 6)
- value += _addInterpolationPart(v6, bindings[6]);
- if (bindLen > 7)
- value += _addInterpolationPart(v7, bindings[7]);
- if (bindLen > 8)
- value += _addInterpolationPart(v8, bindings[8]);
- if (bindLen > 9)
- value += _addInterpolationPart(v9, bindings[9]);
- var /** @type {?} */ renderNode$$1 = asTextData(view, def.nodeIndex).renderText;
- view.renderer.setValue(renderNode$$1, value);
- }
- return changed;
- }
- /**
- * @param {?} view
- * @param {?} def
- * @param {?} values
- * @return {?}
- */
- function checkAndUpdateTextDynamic(view, def, values) {
- var /** @type {?} */ bindings = def.bindings;
- var /** @type {?} */ changed = false;
- for (var /** @type {?} */ i = 0; i < values.length; i++) {
- // Note: We need to loop over all values, so that
- // the old values are updates as well!
- if (checkAndUpdateBinding(view, def, i, values[i])) {
- changed = true;
- }
- }
- if (changed) {
- var /** @type {?} */ value = '';
- for (var /** @type {?} */ i = 0; i < values.length; i++) {
- value = value + _addInterpolationPart(values[i], bindings[i]);
- }
- value = ((def.text)).prefix + value;
- var /** @type {?} */ renderNode$$1 = asTextData(view, def.nodeIndex).renderText;
- view.renderer.setValue(renderNode$$1, value);
- }
- return changed;
- }
- /**
- * @param {?} value
- * @param {?} binding
- * @return {?}
- */
- function _addInterpolationPart(value, binding) {
- var /** @type {?} */ valueStr = value != null ? value.toString() : '';
- return valueStr + binding.suffix;
- }
- /**
- * @param {?} node
- * @return {?}
- */
- function isNgContainer(node) {
- return (node.flags & 1 /* TypeElement */) !== 0 && ((node.element)).name === null;
- }
- /**
- * @param {?} parent
- * @param {?} node
- * @param {?} nodeCount
- * @return {?}
- */
- function validateNode(parent, node, nodeCount) {
- var /** @type {?} */ template = node.element && node.element.template;
- if (template) {
- if (!template.lastRenderRootNode) {
- throw new Error("Illegal State: Embedded templates without nodes are not allowed!");
- }
- if (template.lastRenderRootNode &&
- template.lastRenderRootNode.flags & 16777216 /* EmbeddedViews */) {
- throw new Error("Illegal State: Last root node of a template can't have embedded views, at index " + node.nodeIndex + "!");
- }
- }
- if (node.flags & 20224 /* CatProvider */) {
- var /** @type {?} */ parentFlags = parent ? parent.flags : 0;
- if ((parentFlags & 1 /* TypeElement */) === 0) {
- throw new Error("Illegal State: StaticProvider/Directive nodes need to be children of elements or anchors, at index " + node.nodeIndex + "!");
- }
- }
- if (node.query) {
- if (node.flags & 67108864 /* TypeContentQuery */ &&
- (!parent || (parent.flags & 16384 /* TypeDirective */) === 0)) {
- throw new Error("Illegal State: Content Query nodes need to be children of directives, at index " + node.nodeIndex + "!");
- }
- if (node.flags & 134217728 /* TypeViewQuery */ && parent) {
- throw new Error("Illegal State: View Query nodes have to be top level nodes, at index " + node.nodeIndex + "!");
- }
- }
- if (node.childCount) {
- var /** @type {?} */ parentEnd = parent ? parent.nodeIndex + parent.childCount : nodeCount - 1;
- if (node.nodeIndex <= parentEnd && node.nodeIndex + node.childCount > parentEnd) {
- throw new Error("Illegal State: childCount of node leads outside of parent, at index " + node.nodeIndex + "!");
- }
- }
- }
- /**
- * @param {?} parent
- * @param {?} anchorDef
- * @param {?} viewDef
- * @param {?=} context
- * @return {?}
- */
- function createEmbeddedView(parent, anchorDef$$1, viewDef, context) {
- // embedded views are seen as siblings to the anchor, so we need
- // to get the parent of the anchor and use it as parentIndex.
- var /** @type {?} */ view = createView(parent.root, parent.renderer, parent, anchorDef$$1, viewDef);
- initView(view, parent.component, context);
- createViewNodes(view);
- return view;
- }
- /**
- * @param {?} root
- * @param {?} def
- * @param {?=} context
- * @return {?}
- */
- function createRootView(root, def, context) {
- var /** @type {?} */ view = createView(root, root.renderer, null, null, def);
- initView(view, context, context);
- createViewNodes(view);
- return view;
- }
- /**
- * @param {?} parentView
- * @param {?} nodeDef
- * @param {?} viewDef
- * @param {?} hostElement
- * @return {?}
- */
- function createComponentView(parentView, nodeDef, viewDef, hostElement) {
- var /** @type {?} */ rendererType = ((nodeDef.element)).componentRendererType;
- var /** @type {?} */ compRenderer;
- if (!rendererType) {
- compRenderer = parentView.root.renderer;
- }
- else {
- compRenderer = parentView.root.rendererFactory.createRenderer(hostElement, rendererType);
- }
- return createView(parentView.root, compRenderer, parentView, /** @type {?} */ ((nodeDef.element)).componentProvider, viewDef);
- }
- /**
- * @param {?} root
- * @param {?} renderer
- * @param {?} parent
- * @param {?} parentNodeDef
- * @param {?} def
- * @return {?}
- */
- function createView(root, renderer, parent, parentNodeDef, def) {
- var /** @type {?} */ nodes = new Array(def.nodes.length);
- var /** @type {?} */ disposables = def.outputCount ? new Array(def.outputCount) : null;
- var /** @type {?} */ view = {
- def: def,
- parent: parent,
- viewContainerParent: null, parentNodeDef: parentNodeDef,
- context: null,
- component: null, nodes: nodes,
- state: 13 /* CatInit */, root: root, renderer: renderer,
- oldValues: new Array(def.bindingCount), disposables: disposables
- };
- return view;
- }
- /**
- * @param {?} view
- * @param {?} component
- * @param {?} context
- * @return {?}
- */
- function initView(view, component, context) {
- view.component = component;
- view.context = context;
- }
- /**
- * @param {?} view
- * @return {?}
- */
- function createViewNodes(view) {
- var /** @type {?} */ renderHost;
- if (isComponentView(view)) {
- var /** @type {?} */ hostDef = view.parentNodeDef;
- renderHost = asElementData(/** @type {?} */ ((view.parent)), /** @type {?} */ ((((hostDef)).parent)).nodeIndex).renderElement;
- }
- var /** @type {?} */ def = view.def;
- var /** @type {?} */ nodes = view.nodes;
- for (var /** @type {?} */ i = 0; i < def.nodes.length; i++) {
- var /** @type {?} */ nodeDef = def.nodes[i];
- Services.setCurrentNode(view, i);
- var /** @type {?} */ nodeData = void 0;
- switch (nodeDef.flags & 201347067 /* Types */) {
- case 1 /* TypeElement */:
- var /** @type {?} */ el = (createElement(view, renderHost, nodeDef));
- var /** @type {?} */ componentView = ((undefined));
- if (nodeDef.flags & 33554432 /* ComponentView */) {
- var /** @type {?} */ compViewDef = resolveDefinition(/** @type {?} */ ((((nodeDef.element)).componentView)));
- componentView = Services.createComponentView(view, nodeDef, compViewDef, el);
- }
- listenToElementOutputs(view, componentView, nodeDef, el);
- nodeData = ({
- renderElement: el,
- componentView: componentView,
- viewContainer: null,
- template: /** @type {?} */ ((nodeDef.element)).template ? createTemplateData(view, nodeDef) : undefined
- });
- if (nodeDef.flags & 16777216 /* EmbeddedViews */) {
- nodeData.viewContainer = createViewContainerData(view, nodeDef, nodeData);
- }
- break;
- case 2 /* TypeText */:
- nodeData = (createText(view, renderHost, nodeDef));
- break;
- case 512 /* TypeClassProvider */:
- case 1024 /* TypeFactoryProvider */:
- case 2048 /* TypeUseExistingProvider */:
- case 256 /* TypeValueProvider */: {
- nodeData = nodes[i];
- if (!nodeData && !(nodeDef.flags & 4096 /* LazyProvider */)) {
- var /** @type {?} */ instance = createProviderInstance(view, nodeDef);
- nodeData = ({ instance: instance });
- }
- break;
- }
- case 16 /* TypePipe */: {
- var /** @type {?} */ instance = createPipeInstance(view, nodeDef);
- nodeData = ({ instance: instance });
- break;
- }
- case 16384 /* TypeDirective */: {
- nodeData = nodes[i];
- if (!nodeData) {
- var /** @type {?} */ instance = createDirectiveInstance(view, nodeDef);
- nodeData = ({ instance: instance });
- }
- if (nodeDef.flags & 32768 /* Component */) {
- var /** @type {?} */ compView = asElementData(view, /** @type {?} */ ((nodeDef.parent)).nodeIndex).componentView;
- initView(compView, nodeData.instance, nodeData.instance);
- }
- break;
- }
- case 32 /* TypePureArray */:
- case 64 /* TypePureObject */:
- case 128 /* TypePurePipe */:
- nodeData = (createPureExpression(view, nodeDef));
- break;
- case 67108864 /* TypeContentQuery */:
- case 134217728 /* TypeViewQuery */:
- nodeData = (createQuery());
- break;
- case 8 /* TypeNgContent */:
- appendNgContent(view, renderHost, nodeDef);
- // no runtime data needed for NgContent...
- nodeData = undefined;
- break;
- }
- nodes[i] = nodeData;
- }
- // Create the ViewData.nodes of component views after we created everything else,
- // so that e.g. ng-content works
- execComponentViewsAction(view, ViewAction.CreateViewNodes);
- // fill static content and view queries
- execQueriesAction(view, 67108864 /* TypeContentQuery */ | 134217728 /* TypeViewQuery */, 268435456 /* StaticQuery */, 0 /* CheckAndUpdate */);
- }
- /**
- * @param {?} view
- * @return {?}
- */
- function checkNoChangesView(view) {
- markProjectedViewsForCheck(view);
- Services.updateDirectives(view, 1 /* CheckNoChanges */);
- execEmbeddedViewsAction(view, ViewAction.CheckNoChanges);
- Services.updateRenderer(view, 1 /* CheckNoChanges */);
- execComponentViewsAction(view, ViewAction.CheckNoChanges);
- // Note: We don't check queries for changes as we didn't do this in v2.x.
- // TODO(tbosch): investigate if we can enable the check again in v5.x with a nicer error message.
- view.state &= ~(64 /* CheckProjectedViews */ | 32 /* CheckProjectedView */);
- }
- /**
- * @param {?} view
- * @return {?}
- */
- function checkAndUpdateView(view) {
- if (view.state & 1 /* BeforeFirstCheck */) {
- view.state &= ~1 /* BeforeFirstCheck */;
- view.state |= 2 /* FirstCheck */;
- }
- else {
- view.state &= ~2 /* FirstCheck */;
- }
- markProjectedViewsForCheck(view);
- Services.updateDirectives(view, 0 /* CheckAndUpdate */);
- execEmbeddedViewsAction(view, ViewAction.CheckAndUpdate);
- execQueriesAction(view, 67108864 /* TypeContentQuery */, 536870912 /* DynamicQuery */, 0 /* CheckAndUpdate */);
- callLifecycleHooksChildrenFirst(view, 2097152 /* AfterContentChecked */ |
- (view.state & 2 /* FirstCheck */ ? 1048576 /* AfterContentInit */ : 0));
- Services.updateRenderer(view, 0 /* CheckAndUpdate */);
- execComponentViewsAction(view, ViewAction.CheckAndUpdate);
- execQueriesAction(view, 134217728 /* TypeViewQuery */, 536870912 /* DynamicQuery */, 0 /* CheckAndUpdate */);
- callLifecycleHooksChildrenFirst(view, 8388608 /* AfterViewChecked */ |
- (view.state & 2 /* FirstCheck */ ? 4194304 /* AfterViewInit */ : 0));
- if (view.def.flags & 2 /* OnPush */) {
- view.state &= ~8 /* ChecksEnabled */;
- }
- view.state &= ~(64 /* CheckProjectedViews */ | 32 /* CheckProjectedView */);
- }
- /**
- * @param {?} view
- * @param {?} nodeDef
- * @param {?} argStyle
- * @param {?=} v0
- * @param {?=} v1
- * @param {?=} v2
- * @param {?=} v3
- * @param {?=} v4
- * @param {?=} v5
- * @param {?=} v6
- * @param {?=} v7
- * @param {?=} v8
- * @param {?=} v9
- * @return {?}
- */
- function checkAndUpdateNode(view, nodeDef, argStyle, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
- if (argStyle === 0 /* Inline */) {
- return checkAndUpdateNodeInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
- }
- else {
- return checkAndUpdateNodeDynamic(view, nodeDef, v0);
- }
- }
- /**
- * @param {?} view
- * @return {?}
- */
- function markProjectedViewsForCheck(view) {
- var /** @type {?} */ def = view.def;
- if (!(def.nodeFlags & 4 /* ProjectedTemplate */)) {
- return;
- }
- for (var /** @type {?} */ i = 0; i < def.nodes.length; i++) {
- var /** @type {?} */ nodeDef = def.nodes[i];
- if (nodeDef.flags & 4 /* ProjectedTemplate */) {
- var /** @type {?} */ projectedViews = asElementData(view, i).template._projectedViews;
- if (projectedViews) {
- for (var /** @type {?} */ i_1 = 0; i_1 < projectedViews.length; i_1++) {
- var /** @type {?} */ projectedView = projectedViews[i_1];
- projectedView.state |= 32 /* CheckProjectedView */;
- markParentViewsForCheckProjectedViews(projectedView, view);
- }
- }
- }
- else if ((nodeDef.childFlags & 4 /* ProjectedTemplate */) === 0) {
- // a parent with leafs
- // no child is a component,
- // then skip the children
- i += nodeDef.childCount;
- }
- }
- }
- /**
- * @param {?} view
- * @param {?} nodeDef
- * @param {?=} v0
- * @param {?=} v1
- * @param {?=} v2
- * @param {?=} v3
- * @param {?=} v4
- * @param {?=} v5
- * @param {?=} v6
- * @param {?=} v7
- * @param {?=} v8
- * @param {?=} v9
- * @return {?}
- */
- function checkAndUpdateNodeInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
- switch (nodeDef.flags & 201347067 /* Types */) {
- case 1 /* TypeElement */:
- return checkAndUpdateElementInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
- case 2 /* TypeText */:
- return checkAndUpdateTextInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
- case 16384 /* TypeDirective */:
- return checkAndUpdateDirectiveInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
- case 32 /* TypePureArray */:
- case 64 /* TypePureObject */:
- case 128 /* TypePurePipe */:
- return checkAndUpdatePureExpressionInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
- default:
- throw 'unreachable';
- }
- }
- /**
- * @param {?} view
- * @param {?} nodeDef
- * @param {?} values
- * @return {?}
- */
- function checkAndUpdateNodeDynamic(view, nodeDef, values) {
- switch (nodeDef.flags & 201347067 /* Types */) {
- case 1 /* TypeElement */:
- return checkAndUpdateElementDynamic(view, nodeDef, values);
- case 2 /* TypeText */:
- return checkAndUpdateTextDynamic(view, nodeDef, values);
- case 16384 /* TypeDirective */:
- return checkAndUpdateDirectiveDynamic(view, nodeDef, values);
- case 32 /* TypePureArray */:
- case 64 /* TypePureObject */:
- case 128 /* TypePurePipe */:
- return checkAndUpdatePureExpressionDynamic(view, nodeDef, values);
- default:
- throw 'unreachable';
- }
- }
- /**
- * @param {?} view
- * @param {?} nodeDef
- * @param {?} argStyle
- * @param {?=} v0
- * @param {?=} v1
- * @param {?=} v2
- * @param {?=} v3
- * @param {?=} v4
- * @param {?=} v5
- * @param {?=} v6
- * @param {?=} v7
- * @param {?=} v8
- * @param {?=} v9
- * @return {?}
- */
- function checkNoChangesNode(view, nodeDef, argStyle, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
- if (argStyle === 0 /* Inline */) {
- checkNoChangesNodeInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
- }
- else {
- checkNoChangesNodeDynamic(view, nodeDef, v0);
- }
- // Returning false is ok here as we would have thrown in case of a change.
- return false;
- }
- /**
- * @param {?} view
- * @param {?} nodeDef
- * @param {?} v0
- * @param {?} v1
- * @param {?} v2
- * @param {?} v3
- * @param {?} v4
- * @param {?} v5
- * @param {?} v6
- * @param {?} v7
- * @param {?} v8
- * @param {?} v9
- * @return {?}
- */
- function checkNoChangesNodeInline(view, nodeDef, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
- var /** @type {?} */ bindLen = nodeDef.bindings.length;
- if (bindLen > 0)
- checkBindingNoChanges(view, nodeDef, 0, v0);
- if (bindLen > 1)
- checkBindingNoChanges(view, nodeDef, 1, v1);
- if (bindLen > 2)
- checkBindingNoChanges(view, nodeDef, 2, v2);
- if (bindLen > 3)
- checkBindingNoChanges(view, nodeDef, 3, v3);
- if (bindLen > 4)
- checkBindingNoChanges(view, nodeDef, 4, v4);
- if (bindLen > 5)
- checkBindingNoChanges(view, nodeDef, 5, v5);
- if (bindLen > 6)
- checkBindingNoChanges(view, nodeDef, 6, v6);
- if (bindLen > 7)
- checkBindingNoChanges(view, nodeDef, 7, v7);
- if (bindLen > 8)
- checkBindingNoChanges(view, nodeDef, 8, v8);
- if (bindLen > 9)
- checkBindingNoChanges(view, nodeDef, 9, v9);
- }
- /**
- * @param {?} view
- * @param {?} nodeDef
- * @param {?} values
- * @return {?}
- */
- function checkNoChangesNodeDynamic(view, nodeDef, values) {
- for (var /** @type {?} */ i = 0; i < values.length; i++) {
- checkBindingNoChanges(view, nodeDef, i, values[i]);
- }
- }
- /**
- * Workaround https://github.com/angular/tsickle/issues/497
- * @suppress {misplacedTypeAnnotation}
- * @param {?} view
- * @param {?} nodeDef
- * @return {?}
- */
- function checkNoChangesQuery(view, nodeDef) {
- var /** @type {?} */ queryList = asQueryList(view, nodeDef.nodeIndex);
- if (queryList.dirty) {
- throw expressionChangedAfterItHasBeenCheckedError(Services.createDebugContext(view, nodeDef.nodeIndex), "Query " + ((nodeDef.query)).id + " not dirty", "Query " + ((nodeDef.query)).id + " dirty", (view.state & 1 /* BeforeFirstCheck */) !== 0);
- }
- }
- /**
- * @param {?} view
- * @return {?}
- */
- function destroyView(view) {
- if (view.state & 128 /* Destroyed */) {
- return;
- }
- execEmbeddedViewsAction(view, ViewAction.Destroy);
- execComponentViewsAction(view, ViewAction.Destroy);
- callLifecycleHooksChildrenFirst(view, 131072 /* OnDestroy */);
- if (view.disposables) {
- for (var /** @type {?} */ i = 0; i < view.disposables.length; i++) {
- view.disposables[i]();
- }
- }
- detachProjectedView(view);
- if (view.renderer.destroyNode) {
- destroyViewNodes(view);
- }
- if (isComponentView(view)) {
- view.renderer.destroy();
- }
- view.state |= 128 /* Destroyed */;
- }
- /**
- * @param {?} view
- * @return {?}
- */
- function destroyViewNodes(view) {
- var /** @type {?} */ len = view.def.nodes.length;
- for (var /** @type {?} */ i = 0; i < len; i++) {
- var /** @type {?} */ def = view.def.nodes[i];
- if (def.flags & 1 /* TypeElement */) {
- ((view.renderer.destroyNode))(asElementData(view, i).renderElement);
- }
- else if (def.flags & 2 /* TypeText */) {
- ((view.renderer.destroyNode))(asTextData(view, i).renderText);
- }
- else if (def.flags & 67108864 /* TypeContentQuery */ || def.flags & 134217728 /* TypeViewQuery */) {
- asQueryList(view, i).destroy();
- }
- }
- }
- var ViewAction = {};
- ViewAction.CreateViewNodes = 0;
- ViewAction.CheckNoChanges = 1;
- ViewAction.CheckNoChangesProjectedViews = 2;
- ViewAction.CheckAndUpdate = 3;
- ViewAction.CheckAndUpdateProjectedViews = 4;
- ViewAction.Destroy = 5;
- ViewAction[ViewAction.CreateViewNodes] = "CreateViewNodes";
- ViewAction[ViewAction.CheckNoChanges] = "CheckNoChanges";
- ViewAction[ViewAction.CheckNoChangesProjectedViews] = "CheckNoChangesProjectedViews";
- ViewAction[ViewAction.CheckAndUpdate] = "CheckAndUpdate";
- ViewAction[ViewAction.CheckAndUpdateProjectedViews] = "CheckAndUpdateProjectedViews";
- ViewAction[ViewAction.Destroy] = "Destroy";
- /**
- * @param {?} view
- * @param {?} action
- * @return {?}
- */
- function execComponentViewsAction(view, action) {
- var /** @type {?} */ def = view.def;
- if (!(def.nodeFlags & 33554432 /* ComponentView */)) {
- return;
- }
- for (var /** @type {?} */ i = 0; i < def.nodes.length; i++) {
- var /** @type {?} */ nodeDef = def.nodes[i];
- if (nodeDef.flags & 33554432 /* ComponentView */) {
- // a leaf
- callViewAction(asElementData(view, i).componentView, action);
- }
- else if ((nodeDef.childFlags & 33554432 /* ComponentView */) === 0) {
- // a parent with leafs
- // no child is a component,
- // then skip the children
- i += nodeDef.childCount;
- }
- }
- }
- /**
- * @param {?} view
- * @param {?} action
- * @return {?}
- */
- function execEmbeddedViewsAction(view, action) {
- var /** @type {?} */ def = view.def;
- if (!(def.nodeFlags & 16777216 /* EmbeddedViews */)) {
- return;
- }
- for (var /** @type {?} */ i = 0; i < def.nodes.length; i++) {
- var /** @type {?} */ nodeDef = def.nodes[i];
- if (nodeDef.flags & 16777216 /* EmbeddedViews */) {
- // a leaf
- var /** @type {?} */ embeddedViews = ((asElementData(view, i).viewContainer))._embeddedViews;
- for (var /** @type {?} */ k = 0; k < embeddedViews.length; k++) {
- callViewAction(embeddedViews[k], action);
- }
- }
- else if ((nodeDef.childFlags & 16777216 /* EmbeddedViews */) === 0) {
- // a parent with leafs
- // no child is a component,
- // then skip the children
- i += nodeDef.childCount;
- }
- }
- }
- /**
- * @param {?} view
- * @param {?} action
- * @return {?}
- */
- function callViewAction(view, action) {
- var /** @type {?} */ viewState = view.state;
- switch (action) {
- case ViewAction.CheckNoChanges:
- if ((viewState & 128 /* Destroyed */) === 0) {
- if ((viewState & 12 /* CatDetectChanges */) === 12 /* CatDetectChanges */) {
- checkNoChangesView(view);
- }
- else if (viewState & 64 /* CheckProjectedViews */) {
- execProjectedViewsAction(view, ViewAction.CheckNoChangesProjectedViews);
- }
- }
- break;
- case ViewAction.CheckNoChangesProjectedViews:
- if ((viewState & 128 /* Destroyed */) === 0) {
- if (viewState & 32 /* CheckProjectedView */) {
- checkNoChangesView(view);
- }
- else if (viewState & 64 /* CheckProjectedViews */) {
- execProjectedViewsAction(view, action);
- }
- }
- break;
- case ViewAction.CheckAndUpdate:
- if ((viewState & 128 /* Destroyed */) === 0) {
- if ((viewState & 12 /* CatDetectChanges */) === 12 /* CatDetectChanges */) {
- checkAndUpdateView(view);
- }
- else if (viewState & 64 /* CheckProjectedViews */) {
- execProjectedViewsAction(view, ViewAction.CheckAndUpdateProjectedViews);
- }
- }
- break;
- case ViewAction.CheckAndUpdateProjectedViews:
- if ((viewState & 128 /* Destroyed */) === 0) {
- if (viewState & 32 /* CheckProjectedView */) {
- checkAndUpdateView(view);
- }
- else if (viewState & 64 /* CheckProjectedViews */) {
- execProjectedViewsAction(view, action);
- }
- }
- break;
- case ViewAction.Destroy:
- // Note: destroyView recurses over all views,
- // so we don't need to special case projected views here.
- destroyView(view);
- break;
- case ViewAction.CreateViewNodes:
- createViewNodes(view);
- break;
- }
- }
- /**
- * @param {?} view
- * @param {?} action
- * @return {?}
- */
- function execProjectedViewsAction(view, action) {
- execEmbeddedViewsAction(view, action);
- execComponentViewsAction(view, action);
- }
- /**
- * @param {?} view
- * @param {?} queryFlags
- * @param {?} staticDynamicQueryFlag
- * @param {?} checkType
- * @return {?}
- */
- function execQueriesAction(view, queryFlags, staticDynamicQueryFlag, checkType) {
- if (!(view.def.nodeFlags & queryFlags) || !(view.def.nodeFlags & staticDynamicQueryFlag)) {
- return;
- }
- var /** @type {?} */ nodeCount = view.def.nodes.length;
- for (var /** @type {?} */ i = 0; i < nodeCount; i++) {
- var /** @type {?} */ nodeDef = view.def.nodes[i];
- if ((nodeDef.flags & queryFlags) && (nodeDef.flags & staticDynamicQueryFlag)) {
- Services.setCurrentNode(view, nodeDef.nodeIndex);
- switch (checkType) {
- case 0 /* CheckAndUpdate */:
- checkAndUpdateQuery(view, nodeDef);
- break;
- case 1 /* CheckNoChanges */:
- checkNoChangesQuery(view, nodeDef);
- break;
- }
- }
- if (!(nodeDef.childFlags & queryFlags) || !(nodeDef.childFlags & staticDynamicQueryFlag)) {
- // no child has a matching query
- // then skip the children
- i += nodeDef.childCount;
- }
- }
- }
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var initialized = false;
- /**
- * @return {?}
- */
- function initServicesIfNeeded() {
- if (initialized) {
- return;
- }
- initialized = true;
- var /** @type {?} */ services = isDevMode() ? createDebugServices() : createProdServices();
- Services.setCurrentNode = services.setCurrentNode;
- Services.createRootView = services.createRootView;
- Services.createEmbeddedView = services.createEmbeddedView;
- Services.createComponentView = services.createComponentView;
- Services.createNgModuleRef = services.createNgModuleRef;
- Services.overrideProvider = services.overrideProvider;
- Services.clearProviderOverrides = services.clearProviderOverrides;
- Services.checkAndUpdateView = services.checkAndUpdateView;
- Services.checkNoChangesView = services.checkNoChangesView;
- Services.destroyView = services.destroyView;
- Services.resolveDep = resolveDep;
- Services.createDebugContext = services.createDebugContext;
- Services.handleEvent = services.handleEvent;
- Services.updateDirectives = services.updateDirectives;
- Services.updateRenderer = services.updateRenderer;
- Services.dirtyParentQueries = dirtyParentQueries;
- }
- /**
- * @return {?}
- */
- function createProdServices() {
- return {
- setCurrentNode: function () { },
- createRootView: createProdRootView,
- createEmbeddedView: createEmbeddedView,
- createComponentView: createComponentView,
- createNgModuleRef: createNgModuleRef,
- overrideProvider: NOOP,
- clearProviderOverrides: NOOP,
- checkAndUpdateView: checkAndUpdateView,
- checkNoChangesView: checkNoChangesView,
- destroyView: destroyView,
- createDebugContext: function (view, nodeIndex) { return new DebugContext_(view, nodeIndex); },
- handleEvent: function (view, nodeIndex, eventName, event) { return view.def.handleEvent(view, nodeIndex, eventName, event); },
- updateDirectives: function (view, checkType) { return view.def.updateDirectives(checkType === 0 /* CheckAndUpdate */ ? prodCheckAndUpdateNode :
- prodCheckNoChangesNode, view); },
- updateRenderer: function (view, checkType) { return view.def.updateRenderer(checkType === 0 /* CheckAndUpdate */ ? prodCheckAndUpdateNode :
- prodCheckNoChangesNode, view); },
- };
- }
- /**
- * @return {?}
- */
- function createDebugServices() {
- return {
- setCurrentNode: debugSetCurrentNode,
- createRootView: debugCreateRootView,
- createEmbeddedView: debugCreateEmbeddedView,
- createComponentView: debugCreateComponentView,
- createNgModuleRef: debugCreateNgModuleRef,
- overrideProvider: debugOverrideProvider,
- clearProviderOverrides: debugClearProviderOverrides,
- checkAndUpdateView: debugCheckAndUpdateView,
- checkNoChangesView: debugCheckNoChangesView,
- destroyView: debugDestroyView,
- createDebugContext: function (view, nodeIndex) { return new DebugContext_(view, nodeIndex); },
- handleEvent: debugHandleEvent,
- updateDirectives: debugUpdateDirectives,
- updateRenderer: debugUpdateRenderer,
- };
- }
- /**
- * @param {?} elInjector
- * @param {?} projectableNodes
- * @param {?} rootSelectorOrNode
- * @param {?} def
- * @param {?} ngModule
- * @param {?=} context
- * @return {?}
- */
- function createProdRootView(elInjector, projectableNodes, rootSelectorOrNode, def, ngModule, context) {
- var /** @type {?} */ rendererFactory = ngModule.injector.get(RendererFactory2);
- return createRootView(createRootData(elInjector, ngModule, rendererFactory, projectableNodes, rootSelectorOrNode), def, context);
- }
- /**
- * @param {?} elInjector
- * @param {?} projectableNodes
- * @param {?} rootSelectorOrNode
- * @param {?} def
- * @param {?} ngModule
- * @param {?=} context
- * @return {?}
- */
- function debugCreateRootView(elInjector, projectableNodes, rootSelectorOrNode, def, ngModule, context) {
- var /** @type {?} */ rendererFactory = ngModule.injector.get(RendererFactory2);
- var /** @type {?} */ root = createRootData(elInjector, ngModule, new DebugRendererFactory2(rendererFactory), projectableNodes, rootSelectorOrNode);
- var /** @type {?} */ defWithOverride = applyProviderOverridesToView(def);
- return callWithDebugContext(DebugAction.create, createRootView, null, [root, defWithOverride, context]);
- }
- /**
- * @param {?} elInjector
- * @param {?} ngModule
- * @param {?} rendererFactory
- * @param {?} projectableNodes
- * @param {?} rootSelectorOrNode
- * @return {?}
- */
- function createRootData(elInjector, ngModule, rendererFactory, projectableNodes, rootSelectorOrNode) {
- var /** @type {?} */ sanitizer = ngModule.injector.get(Sanitizer);
- var /** @type {?} */ errorHandler = ngModule.injector.get(ErrorHandler);
- var /** @type {?} */ renderer = rendererFactory.createRenderer(null, null);
- return {
- ngModule: ngModule,
- injector: elInjector, projectableNodes: projectableNodes,
- selectorOrNode: rootSelectorOrNode, sanitizer: sanitizer, rendererFactory: rendererFactory, renderer: renderer, errorHandler: errorHandler
- };
- }
- /**
- * @param {?} parentView
- * @param {?} anchorDef
- * @param {?} viewDef
- * @param {?=} context
- * @return {?}
- */
- function debugCreateEmbeddedView(parentView, anchorDef, viewDef$$1, context) {
- var /** @type {?} */ defWithOverride = applyProviderOverridesToView(viewDef$$1);
- return callWithDebugContext(DebugAction.create, createEmbeddedView, null, [parentView, anchorDef, defWithOverride, context]);
- }
- /**
- * @param {?} parentView
- * @param {?} nodeDef
- * @param {?} viewDef
- * @param {?} hostElement
- * @return {?}
- */
- function debugCreateComponentView(parentView, nodeDef, viewDef$$1, hostElement) {
- var /** @type {?} */ defWithOverride = applyProviderOverridesToView(viewDef$$1);
- return callWithDebugContext(DebugAction.create, createComponentView, null, [parentView, nodeDef, defWithOverride, hostElement]);
- }
- /**
- * @param {?} moduleType
- * @param {?} parentInjector
- * @param {?} bootstrapComponents
- * @param {?} def
- * @return {?}
- */
- function debugCreateNgModuleRef(moduleType, parentInjector, bootstrapComponents, def) {
- var /** @type {?} */ defWithOverride = applyProviderOverridesToNgModule(def);
- return createNgModuleRef(moduleType, parentInjector, bootstrapComponents, defWithOverride);
- }
- var providerOverrides = new Map();
- /**
- * @param {?} override
- * @return {?}
- */
- function debugOverrideProvider(override) {
- providerOverrides.set(override.token, override);
- }
- /**
- * @return {?}
- */
- function debugClearProviderOverrides() {
- providerOverrides.clear();
- }
- /**
- * @param {?} def
- * @return {?}
- */
- function applyProviderOverridesToView(def) {
- if (providerOverrides.size === 0) {
- return def;
- }
- var /** @type {?} */ elementIndicesWithOverwrittenProviders = findElementIndicesWithOverwrittenProviders(def);
- if (elementIndicesWithOverwrittenProviders.length === 0) {
- return def;
- }
- // clone the whole view definition,
- // as it maintains references between the nodes that are hard to update.
- def = ((def.factory))(function () { return NOOP; });
- for (var /** @type {?} */ i = 0; i < elementIndicesWithOverwrittenProviders.length; i++) {
- applyProviderOverridesToElement(def, elementIndicesWithOverwrittenProviders[i]);
- }
- return def;
- /**
- * @param {?} def
- * @return {?}
- */
- function findElementIndicesWithOverwrittenProviders(def) {
- var /** @type {?} */ elIndicesWithOverwrittenProviders = [];
- var /** @type {?} */ lastElementDef = null;
- for (var /** @type {?} */ i = 0; i < def.nodes.length; i++) {
- var /** @type {?} */ nodeDef = def.nodes[i];
- if (nodeDef.flags & 1 /* TypeElement */) {
- lastElementDef = nodeDef;
- }
- if (lastElementDef && nodeDef.flags & 3840 /* CatProviderNoDirective */ &&
- providerOverrides.has(/** @type {?} */ ((nodeDef.provider)).token)) {
- elIndicesWithOverwrittenProviders.push(/** @type {?} */ ((lastElementDef)).nodeIndex);
- lastElementDef = null;
- }
- }
- return elIndicesWithOverwrittenProviders;
- }
- /**
- * @param {?} viewDef
- * @param {?} elIndex
- * @return {?}
- */
- function applyProviderOverridesToElement(viewDef$$1, elIndex) {
- for (var /** @type {?} */ i = elIndex + 1; i < viewDef$$1.nodes.length; i++) {
- var /** @type {?} */ nodeDef = viewDef$$1.nodes[i];
- if (nodeDef.flags & 1 /* TypeElement */) {
- // stop at the next element
- return;
- }
- if (nodeDef.flags & 3840 /* CatProviderNoDirective */) {
- var /** @type {?} */ provider = ((nodeDef.provider));
- var /** @type {?} */ override = providerOverrides.get(provider.token);
- if (override) {
- nodeDef.flags = (nodeDef.flags & ~3840 /* CatProviderNoDirective */) | override.flags;
- provider.deps = splitDepsDsl(override.deps);
- provider.value = override.value;
- }
- }
- }
- }
- }
- /**
- * @param {?} def
- * @return {?}
- */
- function applyProviderOverridesToNgModule(def) {
- var _a = calcHasOverrides(def), hasOverrides = _a.hasOverrides, hasDeprecatedOverrides = _a.hasDeprecatedOverrides;
- if (!hasOverrides) {
- return def;
- }
- // clone the whole view definition,
- // as it maintains references between the nodes that are hard to update.
- def = ((def.factory))(function () { return NOOP; });
- applyProviderOverrides(def);
- return def;
- /**
- * @param {?} def
- * @return {?}
- */
- function calcHasOverrides(def) {
- var /** @type {?} */ hasOverrides = false;
- var /** @type {?} */ hasDeprecatedOverrides = false;
- if (providerOverrides.size === 0) {
- return { hasOverrides: hasOverrides, hasDeprecatedOverrides: hasDeprecatedOverrides };
- }
- def.providers.forEach(function (node) {
- var /** @type {?} */ override = providerOverrides.get(node.token);
- if ((node.flags & 3840 /* CatProviderNoDirective */) && override) {
- hasOverrides = true;
- hasDeprecatedOverrides = hasDeprecatedOverrides || override.deprecatedBehavior;
- }
- });
- return { hasOverrides: hasOverrides, hasDeprecatedOverrides: hasDeprecatedOverrides };
- }
- /**
- * @param {?} def
- * @return {?}
- */
- function applyProviderOverrides(def) {
- for (var /** @type {?} */ i = 0; i < def.providers.length; i++) {
- var /** @type {?} */ provider = def.providers[i];
- if (hasDeprecatedOverrides) {
- // We had a bug where me made
- // all providers lazy. Keep this logic behind a flag
- // for migrating existing users.
- provider.flags |= 4096 /* LazyProvider */;
- }
- var /** @type {?} */ override = providerOverrides.get(provider.token);
- if (override) {
- provider.flags = (provider.flags & ~3840 /* CatProviderNoDirective */) | override.flags;
- provider.deps = splitDepsDsl(override.deps);
- provider.value = override.value;
- }
- }
- }
- }
- /**
- * @param {?} view
- * @param {?} checkIndex
- * @param {?} argStyle
- * @param {?=} v0
- * @param {?=} v1
- * @param {?=} v2
- * @param {?=} v3
- * @param {?=} v4
- * @param {?=} v5
- * @param {?=} v6
- * @param {?=} v7
- * @param {?=} v8
- * @param {?=} v9
- * @return {?}
- */
- function prodCheckAndUpdateNode(view, checkIndex, argStyle, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
- var /** @type {?} */ nodeDef = view.def.nodes[checkIndex];
- checkAndUpdateNode(view, nodeDef, argStyle, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
- return (nodeDef.flags & 224 /* CatPureExpression */) ?
- asPureExpressionData(view, checkIndex).value :
- undefined;
- }
- /**
- * @param {?} view
- * @param {?} checkIndex
- * @param {?} argStyle
- * @param {?=} v0
- * @param {?=} v1
- * @param {?=} v2
- * @param {?=} v3
- * @param {?=} v4
- * @param {?=} v5
- * @param {?=} v6
- * @param {?=} v7
- * @param {?=} v8
- * @param {?=} v9
- * @return {?}
- */
- function prodCheckNoChangesNode(view, checkIndex, argStyle, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9) {
- var /** @type {?} */ nodeDef = view.def.nodes[checkIndex];
- checkNoChangesNode(view, nodeDef, argStyle, v0, v1, v2, v3, v4, v5, v6, v7, v8, v9);
- return (nodeDef.flags & 224 /* CatPureExpression */) ?
- asPureExpressionData(view, checkIndex).value :
- undefined;
- }
- /**
- * @param {?} view
- * @return {?}
- */
- function debugCheckAndUpdateView(view) {
- return callWithDebugContext(DebugAction.detectChanges, checkAndUpdateView, null, [view]);
- }
- /**
- * @param {?} view
- * @return {?}
- */
- function debugCheckNoChangesView(view) {
- return callWithDebugContext(DebugAction.checkNoChanges, checkNoChangesView, null, [view]);
- }
- /**
- * @param {?} view
- * @return {?}
- */
- function debugDestroyView(view) {
- return callWithDebugContext(DebugAction.destroy, destroyView, null, [view]);
- }
- var DebugAction = {};
- DebugAction.create = 0;
- DebugAction.detectChanges = 1;
- DebugAction.checkNoChanges = 2;
- DebugAction.destroy = 3;
- DebugAction.handleEvent = 4;
- DebugAction[DebugAction.create] = "create";
- DebugAction[DebugAction.detectChanges] = "detectChanges";
- DebugAction[DebugAction.checkNoChanges] = "checkNoChanges";
- DebugAction[DebugAction.destroy] = "destroy";
- DebugAction[DebugAction.handleEvent] = "handleEvent";
- var _currentAction;
- var _currentView;
- var _currentNodeIndex;
- /**
- * @param {?} view
- * @param {?} nodeIndex
- * @return {?}
- */
- function debugSetCurrentNode(view, nodeIndex) {
- _currentView = view;
- _currentNodeIndex = nodeIndex;
- }
- /**
- * @param {?} view
- * @param {?} nodeIndex
- * @param {?} eventName
- * @param {?} event
- * @return {?}
- */
- function debugHandleEvent(view, nodeIndex, eventName, event) {
- debugSetCurrentNode(view, nodeIndex);
- return callWithDebugContext(DebugAction.handleEvent, view.def.handleEvent, null, [view, nodeIndex, eventName, event]);
- }
- /**
- * @param {?} view
- * @param {?} checkType
- * @return {?}
- */
- function debugUpdateDirectives(view, checkType) {
- if (view.state & 128 /* Destroyed */) {
- throw viewDestroyedError(DebugAction[_currentAction]);
- }
- debugSetCurrentNode(view, nextDirectiveWithBinding(view, 0));
- return view.def.updateDirectives(debugCheckDirectivesFn, view);
- /**
- * @param {?} view
- * @param {?} nodeIndex
- * @param {?} argStyle
- * @param {...?} values
- * @return {?}
- */
- function debugCheckDirectivesFn(view, nodeIndex, argStyle) {
- var values = [];
- for (var _i = 3; _i < arguments.length; _i++) {
- values[_i - 3] = arguments[_i];
- }
- var /** @type {?} */ nodeDef = view.def.nodes[nodeIndex];
- if (checkType === 0 /* CheckAndUpdate */) {
- debugCheckAndUpdateNode(view, nodeDef, argStyle, values);
- }
- else {
- debugCheckNoChangesNode(view, nodeDef, argStyle, values);
- }
- if (nodeDef.flags & 16384 /* TypeDirective */) {
- debugSetCurrentNode(view, nextDirectiveWithBinding(view, nodeIndex));
- }
- return (nodeDef.flags & 224 /* CatPureExpression */) ?
- asPureExpressionData(view, nodeDef.nodeIndex).value :
- undefined;
- }
- }
- /**
- * @param {?} view
- * @param {?} checkType
- * @return {?}
- */
- function debugUpdateRenderer(view, checkType) {
- if (view.state & 128 /* Destroyed */) {
- throw viewDestroyedError(DebugAction[_currentAction]);
- }
- debugSetCurrentNode(view, nextRenderNodeWithBinding(view, 0));
- return view.def.updateRenderer(debugCheckRenderNodeFn, view);
- /**
- * @param {?} view
- * @param {?} nodeIndex
- * @param {?} argStyle
- * @param {...?} values
- * @return {?}
- */
- function debugCheckRenderNodeFn(view, nodeIndex, argStyle) {
- var values = [];
- for (var _i = 3; _i < arguments.length; _i++) {
- values[_i - 3] = arguments[_i];
- }
- var /** @type {?} */ nodeDef = view.def.nodes[nodeIndex];
- if (checkType === 0 /* CheckAndUpdate */) {
- debugCheckAndUpdateNode(view, nodeDef, argStyle, values);
- }
- else {
- debugCheckNoChangesNode(view, nodeDef, argStyle, values);
- }
- if (nodeDef.flags & 3 /* CatRenderNode */) {
- debugSetCurrentNode(view, nextRenderNodeWithBinding(view, nodeIndex));
- }
- return (nodeDef.flags & 224 /* CatPureExpression */) ?
- asPureExpressionData(view, nodeDef.nodeIndex).value :
- undefined;
- }
- }
- /**
- * @param {?} view
- * @param {?} nodeDef
- * @param {?} argStyle
- * @param {?} givenValues
- * @return {?}
- */
- function debugCheckAndUpdateNode(view, nodeDef, argStyle, givenValues) {
- var /** @type {?} */ changed = ((checkAndUpdateNode)).apply(void 0, [view, nodeDef, argStyle].concat(givenValues));
- if (changed) {
- var /** @type {?} */ values = argStyle === 1 /* Dynamic */ ? givenValues[0] : givenValues;
- if (nodeDef.flags & 16384 /* TypeDirective */) {
- var /** @type {?} */ bindingValues = {};
- for (var /** @type {?} */ i = 0; i < nodeDef.bindings.length; i++) {
- var /** @type {?} */ binding = nodeDef.bindings[i];
- var /** @type {?} */ value = values[i];
- if (binding.flags & 8 /* TypeProperty */) {
- bindingValues[normalizeDebugBindingName(/** @type {?} */ ((binding.nonMinifiedName)))] =
- normalizeDebugBindingValue(value);
- }
- }
- var /** @type {?} */ elDef = ((nodeDef.parent));
- var /** @type {?} */ el = asElementData(view, elDef.nodeIndex).renderElement;
- if (!((elDef.element)).name) {
- // a comment.
- view.renderer.setValue(el, "bindings=" + JSON.stringify(bindingValues, null, 2));
- }
- else {
- // a regular element.
- for (var /** @type {?} */ attr in bindingValues) {
- var /** @type {?} */ value = bindingValues[attr];
- if (value != null) {
- view.renderer.setAttribute(el, attr, value);
- }
- else {
- view.renderer.removeAttribute(el, attr);
- }
- }
- }
- }
- }
- }
- /**
- * @param {?} view
- * @param {?} nodeDef
- * @param {?} argStyle
- * @param {?} values
- * @return {?}
- */
- function debugCheckNoChangesNode(view, nodeDef, argStyle, values) {
- ((checkNoChangesNode)).apply(void 0, [view, nodeDef, argStyle].concat(values));
- }
- /**
- * @param {?} name
- * @return {?}
- */
- function normalizeDebugBindingName(name) {
- // Attribute names with `$` (eg `x-y$`) are valid per spec, but unsupported by some browsers
- name = camelCaseToDashCase(name.replace(/[$@]/g, '_'));
- return "ng-reflect-" + name;
- }
- var CAMEL_CASE_REGEXP = /([A-Z])/g;
- /**
- * @param {?} input
- * @return {?}
- */
- function camelCaseToDashCase(input) {
- return input.replace(CAMEL_CASE_REGEXP, function () {
- var m = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- m[_i] = arguments[_i];
- }
- return '-' + m[1].toLowerCase();
- });
- }
- /**
- * @param {?} value
- * @return {?}
- */
- function normalizeDebugBindingValue(value) {
- try {
- // Limit the size of the value as otherwise the DOM just gets polluted.
- return value != null ? value.toString().slice(0, 30) : value;
- }
- catch (e) {
- return '[ERROR] Exception while trying to serialize the value';
- }
- }
- /**
- * @param {?} view
- * @param {?} nodeIndex
- * @return {?}
- */
- function nextDirectiveWithBinding(view, nodeIndex) {
- for (var /** @type {?} */ i = nodeIndex; i < view.def.nodes.length; i++) {
- var /** @type {?} */ nodeDef = view.def.nodes[i];
- if (nodeDef.flags & 16384 /* TypeDirective */ && nodeDef.bindings && nodeDef.bindings.length) {
- return i;
- }
- }
- return null;
- }
- /**
- * @param {?} view
- * @param {?} nodeIndex
- * @return {?}
- */
- function nextRenderNodeWithBinding(view, nodeIndex) {
- for (var /** @type {?} */ i = nodeIndex; i < view.def.nodes.length; i++) {
- var /** @type {?} */ nodeDef = view.def.nodes[i];
- if ((nodeDef.flags & 3 /* CatRenderNode */) && nodeDef.bindings && nodeDef.bindings.length) {
- return i;
- }
- }
- return null;
- }
- var DebugContext_ = (function () {
- /**
- * @param {?} view
- * @param {?} nodeIndex
- */
- function DebugContext_(view, nodeIndex) {
- this.view = view;
- this.nodeIndex = nodeIndex;
- if (nodeIndex == null) {
- this.nodeIndex = nodeIndex = 0;
- }
- this.nodeDef = view.def.nodes[nodeIndex];
- var elDef = this.nodeDef;
- var elView = view;
- while (elDef && (elDef.flags & 1 /* TypeElement */) === 0) {
- elDef = elDef.parent;
- }
- if (!elDef) {
- while (!elDef && elView) {
- elDef = viewParentEl(elView);
- elView = elView.parent;
- }
- }
- this.elDef = elDef;
- this.elView = elView;
- }
- Object.defineProperty(DebugContext_.prototype, "elOrCompView", {
- /**
- * @return {?}
- */
- get: function () {
- // Has to be done lazily as we use the DebugContext also during creation of elements...
- return asElementData(this.elView, this.elDef.nodeIndex).componentView || this.view;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(DebugContext_.prototype, "injector", {
- /**
- * @return {?}
- */
- get: function () { return createInjector(this.elView, this.elDef); },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(DebugContext_.prototype, "component", {
- /**
- * @return {?}
- */
- get: function () { return this.elOrCompView.component; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(DebugContext_.prototype, "context", {
- /**
- * @return {?}
- */
- get: function () { return this.elOrCompView.context; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(DebugContext_.prototype, "providerTokens", {
- /**
- * @return {?}
- */
- get: function () {
- var /** @type {?} */ tokens = [];
- if (this.elDef) {
- for (var /** @type {?} */ i = this.elDef.nodeIndex + 1; i <= this.elDef.nodeIndex + this.elDef.childCount; i++) {
- var /** @type {?} */ childDef = this.elView.def.nodes[i];
- if (childDef.flags & 20224 /* CatProvider */) {
- tokens.push(/** @type {?} */ ((childDef.provider)).token);
- }
- i += childDef.childCount;
- }
- }
- return tokens;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(DebugContext_.prototype, "references", {
- /**
- * @return {?}
- */
- get: function () {
- var /** @type {?} */ references = {};
- if (this.elDef) {
- collectReferences(this.elView, this.elDef, references);
- for (var /** @type {?} */ i = this.elDef.nodeIndex + 1; i <= this.elDef.nodeIndex + this.elDef.childCount; i++) {
- var /** @type {?} */ childDef = this.elView.def.nodes[i];
- if (childDef.flags & 20224 /* CatProvider */) {
- collectReferences(this.elView, childDef, references);
- }
- i += childDef.childCount;
- }
- }
- return references;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(DebugContext_.prototype, "componentRenderElement", {
- /**
- * @return {?}
- */
- get: function () {
- var /** @type {?} */ elData = findHostElement(this.elOrCompView);
- return elData ? elData.renderElement : undefined;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(DebugContext_.prototype, "renderNode", {
- /**
- * @return {?}
- */
- get: function () {
- return this.nodeDef.flags & 2 /* TypeText */ ? renderNode(this.view, this.nodeDef) :
- renderNode(this.elView, this.elDef);
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @param {?} console
- * @param {...?} values
- * @return {?}
- */
- DebugContext_.prototype.logError = function (console) {
- var values = [];
- for (var _i = 1; _i < arguments.length; _i++) {
- values[_i - 1] = arguments[_i];
- }
- var /** @type {?} */ logViewDef;
- var /** @type {?} */ logNodeIndex;
- if (this.nodeDef.flags & 2 /* TypeText */) {
- logViewDef = this.view.def;
- logNodeIndex = this.nodeDef.nodeIndex;
- }
- else {
- logViewDef = this.elView.def;
- logNodeIndex = this.elDef.nodeIndex;
- }
- // Note: we only generate a log function for text and element nodes
- // to make the generated code as small as possible.
- var /** @type {?} */ renderNodeIndex = getRenderNodeIndex(logViewDef, logNodeIndex);
- var /** @type {?} */ currRenderNodeIndex = -1;
- var /** @type {?} */ nodeLogger = function () {
- currRenderNodeIndex++;
- if (currRenderNodeIndex === renderNodeIndex) {
- return (_a = console.error).bind.apply(_a, [console].concat(values));
- }
- else {
- return NOOP;
- }
- var _a;
- }; /** @type {?} */
- ((logViewDef.factory))(nodeLogger);
- if (currRenderNodeIndex < renderNodeIndex) {
- console.error('Illegal state: the ViewDefinitionFactory did not call the logger!');
- console.error.apply(console, values);
- }
- };
- return DebugContext_;
- }());
- /**
- * @param {?} viewDef
- * @param {?} nodeIndex
- * @return {?}
- */
- function getRenderNodeIndex(viewDef$$1, nodeIndex) {
- var /** @type {?} */ renderNodeIndex = -1;
- for (var /** @type {?} */ i = 0; i <= nodeIndex; i++) {
- var /** @type {?} */ nodeDef = viewDef$$1.nodes[i];
- if (nodeDef.flags & 3 /* CatRenderNode */) {
- renderNodeIndex++;
- }
- }
- return renderNodeIndex;
- }
- /**
- * @param {?} view
- * @return {?}
- */
- function findHostElement(view) {
- while (view && !isComponentView(view)) {
- view = ((view.parent));
- }
- if (view.parent) {
- return asElementData(view.parent, /** @type {?} */ ((viewParentEl(view))).nodeIndex);
- }
- return null;
- }
- /**
- * @param {?} view
- * @param {?} nodeDef
- * @param {?} references
- * @return {?}
- */
- function collectReferences(view, nodeDef, references) {
- for (var /** @type {?} */ refName in nodeDef.references) {
- references[refName] = getQueryValue(view, nodeDef, nodeDef.references[refName]);
- }
- }
- /**
- * @param {?} action
- * @param {?} fn
- * @param {?} self
- * @param {?} args
- * @return {?}
- */
- function callWithDebugContext(action, fn, self, args) {
- var /** @type {?} */ oldAction = _currentAction;
- var /** @type {?} */ oldView = _currentView;
- var /** @type {?} */ oldNodeIndex = _currentNodeIndex;
- try {
- _currentAction = action;
- var /** @type {?} */ result = fn.apply(self, args);
- _currentView = oldView;
- _currentNodeIndex = oldNodeIndex;
- _currentAction = oldAction;
- return result;
- }
- catch (e) {
- if (isViewDebugError(e) || !_currentView) {
- throw e;
- }
- throw viewWrappedDebugError(e, /** @type {?} */ ((getCurrentDebugContext())));
- }
- }
- /**
- * @return {?}
- */
- function getCurrentDebugContext() {
- return _currentView ? new DebugContext_(_currentView, _currentNodeIndex) : null;
- }
- var DebugRendererFactory2 = (function () {
- /**
- * @param {?} delegate
- */
- function DebugRendererFactory2(delegate) {
- this.delegate = delegate;
- }
- /**
- * @param {?} element
- * @param {?} renderData
- * @return {?}
- */
- DebugRendererFactory2.prototype.createRenderer = function (element, renderData) {
- return new DebugRenderer2(this.delegate.createRenderer(element, renderData));
- };
- /**
- * @return {?}
- */
- DebugRendererFactory2.prototype.begin = function () {
- if (this.delegate.begin) {
- this.delegate.begin();
- }
- };
- /**
- * @return {?}
- */
- DebugRendererFactory2.prototype.end = function () {
- if (this.delegate.end) {
- this.delegate.end();
- }
- };
- /**
- * @return {?}
- */
- DebugRendererFactory2.prototype.whenRenderingDone = function () {
- if (this.delegate.whenRenderingDone) {
- return this.delegate.whenRenderingDone();
- }
- return Promise.resolve(null);
- };
- return DebugRendererFactory2;
- }());
- var DebugRenderer2 = (function () {
- /**
- * @param {?} delegate
- */
- function DebugRenderer2(delegate) {
- this.delegate = delegate;
- }
- Object.defineProperty(DebugRenderer2.prototype, "data", {
- /**
- * @return {?}
- */
- get: function () { return this.delegate.data; },
- enumerable: true,
- configurable: true
- });
- /**
- * @param {?} node
- * @return {?}
- */
- DebugRenderer2.prototype.destroyNode = function (node) {
- removeDebugNodeFromIndex(/** @type {?} */ ((getDebugNode(node))));
- if (this.delegate.destroyNode) {
- this.delegate.destroyNode(node);
- }
- };
- /**
- * @return {?}
- */
- DebugRenderer2.prototype.destroy = function () { this.delegate.destroy(); };
- /**
- * @param {?} name
- * @param {?=} namespace
- * @return {?}
- */
- DebugRenderer2.prototype.createElement = function (name, namespace) {
- var /** @type {?} */ el = this.delegate.createElement(name, namespace);
- var /** @type {?} */ debugCtx = getCurrentDebugContext();
- if (debugCtx) {
- var /** @type {?} */ debugEl = new DebugElement(el, null, debugCtx);
- debugEl.name = name;
- indexDebugNode(debugEl);
- }
- return el;
- };
- /**
- * @param {?} value
- * @return {?}
- */
- DebugRenderer2.prototype.createComment = function (value) {
- var /** @type {?} */ comment = this.delegate.createComment(value);
- var /** @type {?} */ debugCtx = getCurrentDebugContext();
- if (debugCtx) {
- indexDebugNode(new DebugNode(comment, null, debugCtx));
- }
- return comment;
- };
- /**
- * @param {?} value
- * @return {?}
- */
- DebugRenderer2.prototype.createText = function (value) {
- var /** @type {?} */ text = this.delegate.createText(value);
- var /** @type {?} */ debugCtx = getCurrentDebugContext();
- if (debugCtx) {
- indexDebugNode(new DebugNode(text, null, debugCtx));
- }
- return text;
- };
- /**
- * @param {?} parent
- * @param {?} newChild
- * @return {?}
- */
- DebugRenderer2.prototype.appendChild = function (parent, newChild) {
- var /** @type {?} */ debugEl = getDebugNode(parent);
- var /** @type {?} */ debugChildEl = getDebugNode(newChild);
- if (debugEl && debugChildEl && debugEl instanceof DebugElement) {
- debugEl.addChild(debugChildEl);
- }
- this.delegate.appendChild(parent, newChild);
- };
- /**
- * @param {?} parent
- * @param {?} newChild
- * @param {?} refChild
- * @return {?}
- */
- DebugRenderer2.prototype.insertBefore = function (parent, newChild, refChild) {
- var /** @type {?} */ debugEl = getDebugNode(parent);
- var /** @type {?} */ debugChildEl = getDebugNode(newChild);
- var /** @type {?} */ debugRefEl = ((getDebugNode(refChild)));
- if (debugEl && debugChildEl && debugEl instanceof DebugElement) {
- debugEl.insertBefore(debugRefEl, debugChildEl);
- }
- this.delegate.insertBefore(parent, newChild, refChild);
- };
- /**
- * @param {?} parent
- * @param {?} oldChild
- * @return {?}
- */
- DebugRenderer2.prototype.removeChild = function (parent, oldChild) {
- var /** @type {?} */ debugEl = getDebugNode(parent);
- var /** @type {?} */ debugChildEl = getDebugNode(oldChild);
- if (debugEl && debugChildEl && debugEl instanceof DebugElement) {
- debugEl.removeChild(debugChildEl);
- }
- this.delegate.removeChild(parent, oldChild);
- };
- /**
- * @param {?} selectorOrNode
- * @return {?}
- */
- DebugRenderer2.prototype.selectRootElement = function (selectorOrNode) {
- var /** @type {?} */ el = this.delegate.selectRootElement(selectorOrNode);
- var /** @type {?} */ debugCtx = getCurrentDebugContext();
- if (debugCtx) {
- indexDebugNode(new DebugElement(el, null, debugCtx));
- }
- return el;
- };
- /**
- * @param {?} el
- * @param {?} name
- * @param {?} value
- * @param {?=} namespace
- * @return {?}
- */
- DebugRenderer2.prototype.setAttribute = function (el, name, value, namespace) {
- var /** @type {?} */ debugEl = getDebugNode(el);
- if (debugEl && debugEl instanceof DebugElement) {
- var /** @type {?} */ fullName = namespace ? namespace + ':' + name : name;
- debugEl.attributes[fullName] = value;
- }
- this.delegate.setAttribute(el, name, value, namespace);
- };
- /**
- * @param {?} el
- * @param {?} name
- * @param {?=} namespace
- * @return {?}
- */
- DebugRenderer2.prototype.removeAttribute = function (el, name, namespace) {
- var /** @type {?} */ debugEl = getDebugNode(el);
- if (debugEl && debugEl instanceof DebugElement) {
- var /** @type {?} */ fullName = namespace ? namespace + ':' + name : name;
- debugEl.attributes[fullName] = null;
- }
- this.delegate.removeAttribute(el, name, namespace);
- };
- /**
- * @param {?} el
- * @param {?} name
- * @return {?}
- */
- DebugRenderer2.prototype.addClass = function (el, name) {
- var /** @type {?} */ debugEl = getDebugNode(el);
- if (debugEl && debugEl instanceof DebugElement) {
- debugEl.classes[name] = true;
- }
- this.delegate.addClass(el, name);
- };
- /**
- * @param {?} el
- * @param {?} name
- * @return {?}
- */
- DebugRenderer2.prototype.removeClass = function (el, name) {
- var /** @type {?} */ debugEl = getDebugNode(el);
- if (debugEl && debugEl instanceof DebugElement) {
- debugEl.classes[name] = false;
- }
- this.delegate.removeClass(el, name);
- };
- /**
- * @param {?} el
- * @param {?} style
- * @param {?} value
- * @param {?} flags
- * @return {?}
- */
- DebugRenderer2.prototype.setStyle = function (el, style, value, flags) {
- var /** @type {?} */ debugEl = getDebugNode(el);
- if (debugEl && debugEl instanceof DebugElement) {
- debugEl.styles[style] = value;
- }
- this.delegate.setStyle(el, style, value, flags);
- };
- /**
- * @param {?} el
- * @param {?} style
- * @param {?} flags
- * @return {?}
- */
- DebugRenderer2.prototype.removeStyle = function (el, style, flags) {
- var /** @type {?} */ debugEl = getDebugNode(el);
- if (debugEl && debugEl instanceof DebugElement) {
- debugEl.styles[style] = null;
- }
- this.delegate.removeStyle(el, style, flags);
- };
- /**
- * @param {?} el
- * @param {?} name
- * @param {?} value
- * @return {?}
- */
- DebugRenderer2.prototype.setProperty = function (el, name, value) {
- var /** @type {?} */ debugEl = getDebugNode(el);
- if (debugEl && debugEl instanceof DebugElement) {
- debugEl.properties[name] = value;
- }
- this.delegate.setProperty(el, name, value);
- };
- /**
- * @param {?} target
- * @param {?} eventName
- * @param {?} callback
- * @return {?}
- */
- DebugRenderer2.prototype.listen = function (target, eventName, callback) {
- if (typeof target !== 'string') {
- var /** @type {?} */ debugEl = getDebugNode(target);
- if (debugEl) {
- debugEl.listeners.push(new EventListener(eventName, callback));
- }
- }
- return this.delegate.listen(target, eventName, callback);
- };
- /**
- * @param {?} node
- * @return {?}
- */
- DebugRenderer2.prototype.parentNode = function (node) { return this.delegate.parentNode(node); };
- /**
- * @param {?} node
- * @return {?}
- */
- DebugRenderer2.prototype.nextSibling = function (node) { return this.delegate.nextSibling(node); };
- /**
- * @param {?} node
- * @param {?} value
- * @return {?}
- */
- DebugRenderer2.prototype.setValue = function (node, value) { return this.delegate.setValue(node, value); };
- return DebugRenderer2;
- }());
- var NgModuleFactory_ = (function (_super) {
- __extends$1(NgModuleFactory_, _super);
- /**
- * @param {?} moduleType
- * @param {?} _bootstrapComponents
- * @param {?} _ngModuleDefFactory
- */
- function NgModuleFactory_(moduleType, _bootstrapComponents, _ngModuleDefFactory) {
- var _this =
- // Attention: this ctor is called as top level function.
- // Putting any logic in here will destroy closure tree shaking!
- _super.call(this) || this;
- _this.moduleType = moduleType;
- _this._bootstrapComponents = _bootstrapComponents;
- _this._ngModuleDefFactory = _ngModuleDefFactory;
- return _this;
- }
- /**
- * @param {?} parentInjector
- * @return {?}
- */
- NgModuleFactory_.prototype.create = function (parentInjector) {
- initServicesIfNeeded();
- var /** @type {?} */ def = resolveDefinition(this._ngModuleDefFactory);
- return Services.createNgModuleRef(this.moduleType, parentInjector || Injector.NULL, this._bootstrapComponents, def);
- };
- return NgModuleFactory_;
- }(NgModuleFactory));
- /**
- * `animate` is an animation-specific function that is designed to be used inside of Angular's
- * animation DSL language. If this information is new, please navigate to the {\@link
- * Component#animations component animations metadata page} to gain a better understanding of
- * how animations in Angular are used.
- *
- * `animate` specifies an animation step that will apply the provided `styles` data for a given
- * amount of time based on the provided `timing` expression value. Calls to `animate` are expected
- * to be used within {\@link sequence an animation sequence}, {\@link group group}, or {\@link
- * transition transition}.
- *
- * ### Usage
- *
- * The `animate` function accepts two input parameters: `timing` and `styles`:
- *
- * - `timing` is a string based value that can be a combination of a duration with optional delay
- * and easing values. The format for the expression breaks down to `duration delay easing`
- * (therefore a value such as `1s 100ms ease-out` will be parse itself into `duration=1000,
- * delay=100, easing=ease-out`. If a numeric value is provided then that will be used as the
- * `duration` value in millisecond form.
- * - `styles` is the style input data which can either be a call to {\@link style style} or {\@link
- * keyframes keyframes}. If left empty then the styles from the destination state will be collected
- * and used (this is useful when describing an animation step that will complete an animation by
- * {\@link transition#the-final-animate-call animating to the final state}).
- *
- * ```typescript
- * // various functions for specifying timing data
- * animate(500, style(...))
- * animate("1s", style(...))
- * animate("100ms 0.5s", style(...))
- * animate("5s ease", style(...))
- * animate("5s 10ms cubic-bezier(.17,.67,.88,.1)", style(...))
- *
- * // either style() of keyframes() can be used
- * animate(500, style({ background: "red" }))
- * animate(500, keyframes([
- * style({ background: "blue" })),
- * style({ background: "red" }))
- * ])
- * ```
- *
- * {\@example core/animation/ts/dsl/animation_example.ts region='Component'}
- *
- * \@experimental Animation support is experimental.
- * @param {?} timings
- * @param {?=} styles
- * @return {?}
- */
- function animate$1(timings, styles) {
- if (styles === void 0) { styles = null; }
- return { type: 4 /* Animate */, styles: styles, timings: timings };
- }
- /**
- * `group` is an animation-specific function that is designed to be used inside of Angular's
- * animation DSL language. If this information is new, please navigate to the {\@link
- * Component#animations component animations metadata page} to gain a better understanding of
- * how animations in Angular are used.
- *
- * `group` specifies a list of animation steps that are all run in parallel. Grouped animations are
- * useful when a series of styles must be animated/closed off at different starting/ending times.
- *
- * The `group` function can either be used within a {\@link sequence sequence} or a {\@link transition
- * transition} and it will only continue to the next instruction once all of the inner animation
- * steps have completed.
- *
- * ### Usage
- *
- * The `steps` data that is passed into the `group` animation function can either consist of {\@link
- * style style} or {\@link animate animate} function calls. Each call to `style()` or `animate()`
- * within a group will be executed instantly (use {\@link keyframes keyframes} or a {\@link
- * animate#usage animate() with a delay value} to offset styles to be applied at a later time).
- *
- * ```typescript
- * group([
- * animate("1s", { background: "black" }))
- * animate("2s", { color: "white" }))
- * ])
- * ```
- *
- * {\@example core/animation/ts/dsl/animation_example.ts region='Component'}
- *
- * \@experimental Animation support is experimental.
- * @param {?} steps
- * @param {?=} options
- * @return {?}
- */
- function group$1(steps, options) {
- if (options === void 0) { options = null; }
- return { type: 3 /* Group */, steps: steps, options: options };
- }
- /**
- * `sequence` is an animation-specific function that is designed to be used inside of Angular's
- * animation DSL language. If this information is new, please navigate to the {\@link
- * Component#animations component animations metadata page} to gain a better understanding of
- * how animations in Angular are used.
- *
- * `sequence` Specifies a list of animation steps that are run one by one. (`sequence` is used by
- * default when an array is passed as animation data into {\@link transition transition}.)
- *
- * The `sequence` function can either be used within a {\@link group group} or a {\@link transition
- * transition} and it will only continue to the next instruction once each of the inner animation
- * steps have completed.
- *
- * To perform animation styling in parallel with other animation steps then have a look at the
- * {\@link group group} animation function.
- *
- * ### Usage
- *
- * The `steps` data that is passed into the `sequence` animation function can either consist of
- * {\@link style style} or {\@link animate animate} function calls. A call to `style()` will apply the
- * provided styling data immediately while a call to `animate()` will apply its styling data over a
- * given time depending on its timing data.
- *
- * ```typescript
- * sequence([
- * style({ opacity: 0 })),
- * animate("1s", { opacity: 1 }))
- * ])
- * ```
- *
- * {\@example core/animation/ts/dsl/animation_example.ts region='Component'}
- *
- * \@experimental Animation support is experimental.
- * @param {?} steps
- * @param {?=} options
- * @return {?}
- */
- function sequence$1(steps, options) {
- if (options === void 0) { options = null; }
- return { type: 2 /* Sequence */, steps: steps, options: options };
- }
- /**
- * `transition` is an animation-specific function that is designed to be used inside of Angular's
- * animation DSL language. If this information is new, please navigate to the {\@link
- * Component#animations component animations metadata page} to gain a better understanding of
- * how animations in Angular are used.
- *
- * `transition` declares the {\@link sequence sequence of animation steps} that will be run when the
- * provided `stateChangeExpr` value is satisfied. The `stateChangeExpr` consists of a `state1 =>
- * state2` which consists of two known states (use an asterix (`*`) to refer to a dynamic starting
- * and/or ending state).
- *
- * A function can also be provided as the `stateChangeExpr` argument for a transition and this
- * function will be executed each time a state change occurs. If the value returned within the
- * function is true then the associated animation will be run.
- *
- * Animation transitions are placed within an {\@link trigger animation trigger}. For an transition
- * to animate to a state value and persist its styles then one or more {\@link state animation
- * states} is expected to be defined.
- *
- * ### Usage
- *
- * An animation transition is kicked off the `stateChangeExpr` predicate evaluates to true based on
- * what the previous state is and what the current state has become. In other words, if a transition
- * is defined that matches the old/current state criteria then the associated animation will be
- * triggered.
- *
- * ```typescript
- * // all transition/state changes are defined within an animation trigger
- * trigger("myAnimationTrigger", [
- * // if a state is defined then its styles will be persisted when the
- * // animation has fully completed itself
- * state("on", style({ background: "green" })),
- * state("off", style({ background: "grey" })),
- *
- * // a transition animation that will be kicked off when the state value
- * // bound to "myAnimationTrigger" changes from "on" to "off"
- * transition("on => off", animate(500)),
- *
- * // it is also possible to do run the same animation for both directions
- * transition("on <=> off", animate(500)),
- *
- * // or to define multiple states pairs separated by commas
- * transition("on => off, off => void", animate(500)),
- *
- * // this is a catch-all state change for when an element is inserted into
- * // the page and the destination state is unknown
- * transition("void => *", [
- * style({ opacity: 0 }),
- * animate(500)
- * ]),
- *
- * // this will capture a state change between any states
- * transition("* => *", animate("1s 0s")),
- *
- * // you can also go full out and include a function
- * transition((fromState, toState) => {
- * // when `true` then it will allow the animation below to be invoked
- * return fromState == "off" && toState == "on";
- * }, animate("1s 0s"))
- * ])
- * ```
- *
- * The template associated with this component will make use of the `myAnimationTrigger` animation
- * trigger by binding to an element within its template code.
- *
- * ```html
- * <!-- somewhere inside of my-component-tpl.html -->
- * <div [\@myAnimationTrigger]="myStatusExp">...</div>
- * ```
- *
- * #### The final `animate` call
- *
- * If the final step within the transition steps is a call to `animate()` that **only** uses a
- * timing value with **no style data** then it will be automatically used as the final animation arc
- * for the element to animate itself to the final state. This involves an automatic mix of
- * adding/removing CSS styles so that the element will be in the exact state it should be for the
- * applied state to be presented correctly.
- *
- * ```
- * // start off by hiding the element, but make sure that it animates properly to whatever state
- * // is currently active for "myAnimationTrigger"
- * transition("void => *", [
- * style({ opacity: 0 }),
- * animate(500)
- * ])
- * ```
- *
- * ### Transition Aliases (`:enter` and `:leave`)
- *
- * Given that enter (insertion) and leave (removal) animations are so common, the `transition`
- * function accepts both `:enter` and `:leave` values which are aliases for the `void => *` and `*
- * => void` state changes.
- *
- * ```
- * transition(":enter", [
- * style({ opacity: 0 }),
- * animate(500, style({ opacity: 1 }))
- * ])
- * transition(":leave", [
- * animate(500, style({ opacity: 0 }))
- * ])
- * ```
- *
- * ### Boolean values
- * if a trigger binding value is a boolean value then it can be matched using a transition
- * expression that compares `true` and `false` or `1` and `0`.
- *
- * ```
- * // in the template
- * <div [\@openClose]="open ? true : false">...</div>
- *
- * // in the component metadata
- * trigger('openClose', [
- * state('true', style({ height: '*' })),
- * state('false', style({ height: '0px' })),
- * transition('false <=> true', animate(500))
- * ])
- * ```
- * {\@example core/animation/ts/dsl/animation_example.ts region='Component'}
- *
- * \@experimental Animation support is experimental.
- * @param {?} stateChangeExpr
- * @param {?} steps
- * @param {?=} options
- * @return {?}
- */
- function transition$1(stateChangeExpr, steps, options) {
- if (options === void 0) { options = null; }
- return { type: 1 /* Transition */, expr: stateChangeExpr, animation: steps, options: options };
- }
-
- /**
- * @license Angular v4.4.6
- * (c) 2010-2017 Google, Inc. https://angular.io/
- * License: MIT
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * This class should not be used directly by an application developer. Instead, use
- * {\@link Location}.
- *
- * `PlatformLocation` encapsulates all calls to DOM apis, which allows the Router to be platform
- * agnostic.
- * This means that we can have different implementation of `PlatformLocation` for the different
- * platforms that angular supports. For example, `\@angular/platform-browser` provides an
- * implementation specific to the browser environment, while `\@angular/platform-webworker` provides
- * one suitable for use with web workers.
- *
- * The `PlatformLocation` class is used directly by all implementations of {\@link LocationStrategy}
- * when they need to interact with the DOM apis like pushState, popState, etc...
- *
- * {\@link LocationStrategy} in turn is used by the {\@link Location} service which is used directly
- * by the {\@link Router} in order to navigate between routes. Since all interactions between {\@link
- * Router} /
- * {\@link Location} / {\@link LocationStrategy} and DOM apis flow through the `PlatformLocation`
- * class they are all platform independent.
- *
- * \@stable
- * @abstract
- */
- var PlatformLocation = (function () {
- function PlatformLocation() {
- }
- /**
- * @abstract
- * @return {?}
- */
- PlatformLocation.prototype.getBaseHrefFromDOM = function () { };
- /**
- * @abstract
- * @param {?} fn
- * @return {?}
- */
- PlatformLocation.prototype.onPopState = function (fn) { };
- /**
- * @abstract
- * @param {?} fn
- * @return {?}
- */
- PlatformLocation.prototype.onHashChange = function (fn) { };
- /**
- * @abstract
- * @return {?}
- */
- PlatformLocation.prototype.pathname = function () { };
- /**
- * @abstract
- * @return {?}
- */
- PlatformLocation.prototype.search = function () { };
- /**
- * @abstract
- * @return {?}
- */
- PlatformLocation.prototype.hash = function () { };
- /**
- * @abstract
- * @param {?} state
- * @param {?} title
- * @param {?} url
- * @return {?}
- */
- PlatformLocation.prototype.replaceState = function (state$$1, title, url) { };
- /**
- * @abstract
- * @param {?} state
- * @param {?} title
- * @param {?} url
- * @return {?}
- */
- PlatformLocation.prototype.pushState = function (state$$1, title, url) { };
- /**
- * @abstract
- * @return {?}
- */
- PlatformLocation.prototype.forward = function () { };
- /**
- * @abstract
- * @return {?}
- */
- PlatformLocation.prototype.back = function () { };
- return PlatformLocation;
- }());
- /**
- * \@whatItDoes indicates when a location is initialized
- * \@experimental
- */
- var LOCATION_INITIALIZED = new InjectionToken('Location Initialized');
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * `LocationStrategy` is responsible for representing and reading route state
- * from the browser's URL. Angular provides two strategies:
- * {\@link HashLocationStrategy} and {\@link PathLocationStrategy}.
- *
- * This is used under the hood of the {\@link Location} service.
- *
- * Applications should use the {\@link Router} or {\@link Location} services to
- * interact with application route state.
- *
- * For instance, {\@link HashLocationStrategy} produces URLs like
- * `http://example.com#/foo`, and {\@link PathLocationStrategy} produces
- * `http://example.com/foo` as an equivalent URL.
- *
- * See these two classes for more.
- *
- * \@stable
- * @abstract
- */
- var LocationStrategy = (function () {
- function LocationStrategy() {
- }
- /**
- * @abstract
- * @param {?=} includeHash
- * @return {?}
- */
- LocationStrategy.prototype.path = function (includeHash) { };
- /**
- * @abstract
- * @param {?} internal
- * @return {?}
- */
- LocationStrategy.prototype.prepareExternalUrl = function (internal) { };
- /**
- * @abstract
- * @param {?} state
- * @param {?} title
- * @param {?} url
- * @param {?} queryParams
- * @return {?}
- */
- LocationStrategy.prototype.pushState = function (state$$1, title, url, queryParams) { };
- /**
- * @abstract
- * @param {?} state
- * @param {?} title
- * @param {?} url
- * @param {?} queryParams
- * @return {?}
- */
- LocationStrategy.prototype.replaceState = function (state$$1, title, url, queryParams) { };
- /**
- * @abstract
- * @return {?}
- */
- LocationStrategy.prototype.forward = function () { };
- /**
- * @abstract
- * @return {?}
- */
- LocationStrategy.prototype.back = function () { };
- /**
- * @abstract
- * @param {?} fn
- * @return {?}
- */
- LocationStrategy.prototype.onPopState = function (fn) { };
- /**
- * @abstract
- * @return {?}
- */
- LocationStrategy.prototype.getBaseHref = function () { };
- return LocationStrategy;
- }());
- /**
- * The `APP_BASE_HREF` token represents the base href to be used with the
- * {\@link PathLocationStrategy}.
- *
- * If you're using {\@link PathLocationStrategy}, you must provide a provider to a string
- * representing the URL prefix that should be preserved when generating and recognizing
- * URLs.
- *
- * ### Example
- *
- * ```typescript
- * import {Component, NgModule} from '\@angular/core';
- * import {APP_BASE_HREF} from '\@angular/common';
- *
- * \@NgModule({
- * providers: [{provide: APP_BASE_HREF, useValue: '/my/app'}]
- * })
- * class AppModule {}
- * ```
- *
- * \@stable
- */
- var APP_BASE_HREF = new InjectionToken('appBaseHref');
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * \@whatItDoes `Location` is a service that applications can use to interact with a browser's URL.
- * \@description
- * Depending on which {\@link LocationStrategy} is used, `Location` will either persist
- * to the URL's path or the URL's hash segment.
- *
- * Note: it's better to use {\@link Router#navigate} service to trigger route changes. Use
- * `Location` only if you need to interact with or create normalized URLs outside of
- * routing.
- *
- * `Location` is responsible for normalizing the URL against the application's base href.
- * A normalized URL is absolute from the URL host, includes the application's base href, and has no
- * trailing slash:
- * - `/my/app/user/123` is normalized
- * - `my/app/user/123` **is not** normalized
- * - `/my/app/user/123/` **is not** normalized
- *
- * ### Example
- * {\@example common/location/ts/path_location_component.ts region='LocationComponent'}
- * \@stable
- */
- var Location = (function () {
- /**
- * @param {?} platformStrategy
- */
- function Location(platformStrategy) {
- var _this = this;
- /**
- * \@internal
- */
- this._subject = new EventEmitter();
- this._platformStrategy = platformStrategy;
- var browserBaseHref = this._platformStrategy.getBaseHref();
- this._baseHref = Location.stripTrailingSlash(_stripIndexHtml(browserBaseHref));
- this._platformStrategy.onPopState(function (ev) {
- _this._subject.emit({
- 'url': _this.path(true),
- 'pop': true,
- 'type': ev.type,
- });
- });
- }
- /**
- * @param {?=} includeHash
- * @return {?}
- */
- Location.prototype.path = function (includeHash) {
- if (includeHash === void 0) { includeHash = false; }
- return this.normalize(this._platformStrategy.path(includeHash));
- };
- /**
- * Normalizes the given path and compares to the current normalized path.
- * @param {?} path
- * @param {?=} query
- * @return {?}
- */
- Location.prototype.isCurrentPathEqualTo = function (path, query) {
- if (query === void 0) { query = ''; }
- return this.path() == this.normalize(path + Location.normalizeQueryParams(query));
- };
- /**
- * Given a string representing a URL, returns the normalized URL path without leading or
- * trailing slashes.
- * @param {?} url
- * @return {?}
- */
- Location.prototype.normalize = function (url) {
- return Location.stripTrailingSlash(_stripBaseHref(this._baseHref, _stripIndexHtml(url)));
- };
- /**
- * Given a string representing a URL, returns the platform-specific external URL path.
- * If the given URL doesn't begin with a leading slash (`'/'`), this method adds one
- * before normalizing. This method will also add a hash if `HashLocationStrategy` is
- * used, or the `APP_BASE_HREF` if the `PathLocationStrategy` is in use.
- * @param {?} url
- * @return {?}
- */
- Location.prototype.prepareExternalUrl = function (url) {
- if (url && url[0] !== '/') {
- url = '/' + url;
- }
- return this._platformStrategy.prepareExternalUrl(url);
- };
- /**
- * Changes the browsers URL to the normalized version of the given URL, and pushes a
- * new item onto the platform's history.
- * @param {?} path
- * @param {?=} query
- * @return {?}
- */
- Location.prototype.go = function (path, query) {
- if (query === void 0) { query = ''; }
- this._platformStrategy.pushState(null, '', path, query);
- };
- /**
- * Changes the browsers URL to the normalized version of the given URL, and replaces
- * the top item on the platform's history stack.
- * @param {?} path
- * @param {?=} query
- * @return {?}
- */
- Location.prototype.replaceState = function (path, query) {
- if (query === void 0) { query = ''; }
- this._platformStrategy.replaceState(null, '', path, query);
- };
- /**
- * Navigates forward in the platform's history.
- * @return {?}
- */
- Location.prototype.forward = function () { this._platformStrategy.forward(); };
- /**
- * Navigates back in the platform's history.
- * @return {?}
- */
- Location.prototype.back = function () { this._platformStrategy.back(); };
- /**
- * Subscribe to the platform's `popState` events.
- * @param {?} onNext
- * @param {?=} onThrow
- * @param {?=} onReturn
- * @return {?}
- */
- Location.prototype.subscribe = function (onNext, onThrow, onReturn) {
- return this._subject.subscribe({ next: onNext, error: onThrow, complete: onReturn });
- };
- /**
- * Given a string of url parameters, prepend with '?' if needed, otherwise return parameters as
- * is.
- * @param {?} params
- * @return {?}
- */
- Location.normalizeQueryParams = function (params) {
- return params && params[0] !== '?' ? '?' + params : params;
- };
- /**
- * Given 2 parts of a url, join them with a slash if needed.
- * @param {?} start
- * @param {?} end
- * @return {?}
- */
- Location.joinWithSlash = function (start, end) {
- if (start.length == 0) {
- return end;
- }
- if (end.length == 0) {
- return start;
- }
- var /** @type {?} */ slashes = 0;
- if (start.endsWith('/')) {
- slashes++;
- }
- if (end.startsWith('/')) {
- slashes++;
- }
- if (slashes == 2) {
- return start + end.substring(1);
- }
- if (slashes == 1) {
- return start + end;
- }
- return start + '/' + end;
- };
- /**
- * If url has a trailing slash, remove it, otherwise return url as is. This
- * method looks for the first occurence of either #, ?, or the end of the
- * line as `/` characters after any of these should not be replaced.
- * @param {?} url
- * @return {?}
- */
- Location.stripTrailingSlash = function (url) {
- var /** @type {?} */ match = url.match(/#|\?|$/);
- var /** @type {?} */ pathEndIdx = match && match.index || url.length;
- var /** @type {?} */ droppedSlashIdx = pathEndIdx - (url[pathEndIdx - 1] === '/' ? 1 : 0);
- return url.slice(0, droppedSlashIdx) + url.slice(pathEndIdx);
- };
- return Location;
- }());
- Location.decorators = [
- { type: Injectable },
- ];
- /**
- * @nocollapse
- */
- Location.ctorParameters = function () { return [
- { type: LocationStrategy, },
- ]; };
- /**
- * @param {?} baseHref
- * @param {?} url
- * @return {?}
- */
- function _stripBaseHref(baseHref, url) {
- return baseHref && url.startsWith(baseHref) ? url.substring(baseHref.length) : url;
- }
- /**
- * @param {?} url
- * @return {?}
- */
- function _stripIndexHtml(url) {
- return url.replace(/\/index.html$/, '');
- }
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * \@whatItDoes Use URL hash for storing application location data.
- * \@description
- * `HashLocationStrategy` is a {\@link LocationStrategy} used to configure the
- * {\@link Location} service to represent its state in the
- * [hash fragment](https://en.wikipedia.org/wiki/Uniform_Resource_Locator#Syntax)
- * of the browser's URL.
- *
- * For instance, if you call `location.go('/foo')`, the browser's URL will become
- * `example.com#/foo`.
- *
- * ### Example
- *
- * {\@example common/location/ts/hash_location_component.ts region='LocationComponent'}
- *
- * \@stable
- */
- var HashLocationStrategy = (function (_super) {
- __extends$1(HashLocationStrategy, _super);
- /**
- * @param {?} _platformLocation
- * @param {?=} _baseHref
- */
- function HashLocationStrategy(_platformLocation, _baseHref) {
- var _this = _super.call(this) || this;
- _this._platformLocation = _platformLocation;
- _this._baseHref = '';
- if (_baseHref != null) {
- _this._baseHref = _baseHref;
- }
- return _this;
- }
- /**
- * @param {?} fn
- * @return {?}
- */
- HashLocationStrategy.prototype.onPopState = function (fn) {
- this._platformLocation.onPopState(fn);
- this._platformLocation.onHashChange(fn);
- };
- /**
- * @return {?}
- */
- HashLocationStrategy.prototype.getBaseHref = function () { return this._baseHref; };
- /**
- * @param {?=} includeHash
- * @return {?}
- */
- HashLocationStrategy.prototype.path = function (includeHash) {
- if (includeHash === void 0) { includeHash = false; }
- // the hash value is always prefixed with a `#`
- // and if it is empty then it will stay empty
- var /** @type {?} */ path = this._platformLocation.hash;
- if (path == null)
- path = '#';
- return path.length > 0 ? path.substring(1) : path;
- };
- /**
- * @param {?} internal
- * @return {?}
- */
- HashLocationStrategy.prototype.prepareExternalUrl = function (internal) {
- var /** @type {?} */ url = Location.joinWithSlash(this._baseHref, internal);
- return url.length > 0 ? ('#' + url) : url;
- };
- /**
- * @param {?} state
- * @param {?} title
- * @param {?} path
- * @param {?} queryParams
- * @return {?}
- */
- HashLocationStrategy.prototype.pushState = function (state$$1, title, path, queryParams) {
- var /** @type {?} */ url = this.prepareExternalUrl(path + Location.normalizeQueryParams(queryParams));
- if (url.length == 0) {
- url = this._platformLocation.pathname;
- }
- this._platformLocation.pushState(state$$1, title, url);
- };
- /**
- * @param {?} state
- * @param {?} title
- * @param {?} path
- * @param {?} queryParams
- * @return {?}
- */
- HashLocationStrategy.prototype.replaceState = function (state$$1, title, path, queryParams) {
- var /** @type {?} */ url = this.prepareExternalUrl(path + Location.normalizeQueryParams(queryParams));
- if (url.length == 0) {
- url = this._platformLocation.pathname;
- }
- this._platformLocation.replaceState(state$$1, title, url);
- };
- /**
- * @return {?}
- */
- HashLocationStrategy.prototype.forward = function () { this._platformLocation.forward(); };
- /**
- * @return {?}
- */
- HashLocationStrategy.prototype.back = function () { this._platformLocation.back(); };
- return HashLocationStrategy;
- }(LocationStrategy));
- HashLocationStrategy.decorators = [
- { type: Injectable },
- ];
- /**
- * @nocollapse
- */
- HashLocationStrategy.ctorParameters = function () { return [
- { type: PlatformLocation, },
- { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [APP_BASE_HREF,] },] },
- ]; };
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * \@whatItDoes Use URL for storing application location data.
- * \@description
- * `PathLocationStrategy` is a {\@link LocationStrategy} used to configure the
- * {\@link Location} service to represent its state in the
- * [path](https://en.wikipedia.org/wiki/Uniform_Resource_Locator#Syntax) of the
- * browser's URL.
- *
- * If you're using `PathLocationStrategy`, you must provide a {\@link APP_BASE_HREF}
- * or add a base element to the document. This URL prefix that will be preserved
- * when generating and recognizing URLs.
- *
- * For instance, if you provide an `APP_BASE_HREF` of `'/my/app'` and call
- * `location.go('/foo')`, the browser's URL will become
- * `example.com/my/app/foo`.
- *
- * Similarly, if you add `<base href='/my/app'/>` to the document and call
- * `location.go('/foo')`, the browser's URL will become
- * `example.com/my/app/foo`.
- *
- * ### Example
- *
- * {\@example common/location/ts/path_location_component.ts region='LocationComponent'}
- *
- * \@stable
- */
- var PathLocationStrategy = (function (_super) {
- __extends$1(PathLocationStrategy, _super);
- /**
- * @param {?} _platformLocation
- * @param {?=} href
- */
- function PathLocationStrategy(_platformLocation, href) {
- var _this = _super.call(this) || this;
- _this._platformLocation = _platformLocation;
- if (href == null) {
- href = _this._platformLocation.getBaseHrefFromDOM();
- }
- if (href == null) {
- throw new Error("No base href set. Please provide a value for the APP_BASE_HREF token or add a base element to the document.");
- }
- _this._baseHref = href;
- return _this;
- }
- /**
- * @param {?} fn
- * @return {?}
- */
- PathLocationStrategy.prototype.onPopState = function (fn) {
- this._platformLocation.onPopState(fn);
- this._platformLocation.onHashChange(fn);
- };
- /**
- * @return {?}
- */
- PathLocationStrategy.prototype.getBaseHref = function () { return this._baseHref; };
- /**
- * @param {?} internal
- * @return {?}
- */
- PathLocationStrategy.prototype.prepareExternalUrl = function (internal) {
- return Location.joinWithSlash(this._baseHref, internal);
- };
- /**
- * @param {?=} includeHash
- * @return {?}
- */
- PathLocationStrategy.prototype.path = function (includeHash) {
- if (includeHash === void 0) { includeHash = false; }
- var /** @type {?} */ pathname = this._platformLocation.pathname +
- Location.normalizeQueryParams(this._platformLocation.search);
- var /** @type {?} */ hash = this._platformLocation.hash;
- return hash && includeHash ? "" + pathname + hash : pathname;
- };
- /**
- * @param {?} state
- * @param {?} title
- * @param {?} url
- * @param {?} queryParams
- * @return {?}
- */
- PathLocationStrategy.prototype.pushState = function (state$$1, title, url, queryParams) {
- var /** @type {?} */ externalUrl = this.prepareExternalUrl(url + Location.normalizeQueryParams(queryParams));
- this._platformLocation.pushState(state$$1, title, externalUrl);
- };
- /**
- * @param {?} state
- * @param {?} title
- * @param {?} url
- * @param {?} queryParams
- * @return {?}
- */
- PathLocationStrategy.prototype.replaceState = function (state$$1, title, url, queryParams) {
- var /** @type {?} */ externalUrl = this.prepareExternalUrl(url + Location.normalizeQueryParams(queryParams));
- this._platformLocation.replaceState(state$$1, title, externalUrl);
- };
- /**
- * @return {?}
- */
- PathLocationStrategy.prototype.forward = function () { this._platformLocation.forward(); };
- /**
- * @return {?}
- */
- PathLocationStrategy.prototype.back = function () { this._platformLocation.back(); };
- return PathLocationStrategy;
- }(LocationStrategy));
- PathLocationStrategy.decorators = [
- { type: Injectable },
- ];
- /**
- * @nocollapse
- */
- PathLocationStrategy.ctorParameters = function () { return [
- { type: PlatformLocation, },
- { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [APP_BASE_HREF,] },] },
- ]; };
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * \@experimental
- * @abstract
- */
- var NgLocalization = (function () {
- function NgLocalization() {
- }
- /**
- * @abstract
- * @param {?} value
- * @return {?}
- */
- NgLocalization.prototype.getPluralCategory = function (value) { };
- return NgLocalization;
- }());
- /**
- * Returns the plural category for a given value.
- * - "=value" when the case exists,
- * - the plural category otherwise
- *
- * \@internal
- * @param {?} value
- * @param {?} cases
- * @param {?} ngLocalization
- * @return {?}
- */
- function getPluralCategory(value, cases, ngLocalization) {
- var /** @type {?} */ key = "=" + value;
- if (cases.indexOf(key) > -1) {
- return key;
- }
- key = ngLocalization.getPluralCategory(value);
- if (cases.indexOf(key) > -1) {
- return key;
- }
- if (cases.indexOf('other') > -1) {
- return 'other';
- }
- throw new Error("No plural message found for value \"" + value + "\"");
- }
- /**
- * Returns the plural case based on the locale
- *
- * \@experimental
- */
- var NgLocaleLocalization = (function (_super) {
- __extends$1(NgLocaleLocalization, _super);
- /**
- * @param {?} locale
- */
- function NgLocaleLocalization(locale) {
- var _this = _super.call(this) || this;
- _this.locale = locale;
- return _this;
- }
- /**
- * @param {?} value
- * @return {?}
- */
- NgLocaleLocalization.prototype.getPluralCategory = function (value) {
- var /** @type {?} */ plural = getPluralCase(this.locale, value);
- switch (plural) {
- case Plural.Zero:
- return 'zero';
- case Plural.One:
- return 'one';
- case Plural.Two:
- return 'two';
- case Plural.Few:
- return 'few';
- case Plural.Many:
- return 'many';
- default:
- return 'other';
- }
- };
- return NgLocaleLocalization;
- }(NgLocalization));
- NgLocaleLocalization.decorators = [
- { type: Injectable },
- ];
- /**
- * @nocollapse
- */
- NgLocaleLocalization.ctorParameters = function () { return [
- { type: undefined, decorators: [{ type: Inject, args: [LOCALE_ID,] },] },
- ]; };
- var Plural = {};
- Plural.Zero = 0;
- Plural.One = 1;
- Plural.Two = 2;
- Plural.Few = 3;
- Plural.Many = 4;
- Plural.Other = 5;
- Plural[Plural.Zero] = "Zero";
- Plural[Plural.One] = "One";
- Plural[Plural.Two] = "Two";
- Plural[Plural.Few] = "Few";
- Plural[Plural.Many] = "Many";
- Plural[Plural.Other] = "Other";
- /**
- * Returns the plural case based on the locale
- *
- * \@experimental
- * @param {?} locale
- * @param {?} nLike
- * @return {?}
- */
- function getPluralCase(locale, nLike) {
- // TODO(vicb): lazy compute
- if (typeof nLike === 'string') {
- nLike = parseInt(/** @type {?} */ (nLike), 10);
- }
- var /** @type {?} */ n = (nLike);
- var /** @type {?} */ nDecimal = n.toString().replace(/^[^.]*\.?/, '');
- var /** @type {?} */ i = Math.floor(Math.abs(n));
- var /** @type {?} */ v = nDecimal.length;
- var /** @type {?} */ f = parseInt(nDecimal, 10);
- var /** @type {?} */ t = parseInt(n.toString().replace(/^[^.]*\.?|0+$/g, ''), 10) || 0;
- var /** @type {?} */ lang = locale.split('-')[0].toLowerCase();
- switch (lang) {
- case 'af':
- case 'asa':
- case 'az':
- case 'bem':
- case 'bez':
- case 'bg':
- case 'brx':
- case 'ce':
- case 'cgg':
- case 'chr':
- case 'ckb':
- case 'ee':
- case 'el':
- case 'eo':
- case 'es':
- case 'eu':
- case 'fo':
- case 'fur':
- case 'gsw':
- case 'ha':
- case 'haw':
- case 'hu':
- case 'jgo':
- case 'jmc':
- case 'ka':
- case 'kk':
- case 'kkj':
- case 'kl':
- case 'ks':
- case 'ksb':
- case 'ky':
- case 'lb':
- case 'lg':
- case 'mas':
- case 'mgo':
- case 'ml':
- case 'mn':
- case 'nb':
- case 'nd':
- case 'ne':
- case 'nn':
- case 'nnh':
- case 'nyn':
- case 'om':
- case 'or':
- case 'os':
- case 'ps':
- case 'rm':
- case 'rof':
- case 'rwk':
- case 'saq':
- case 'seh':
- case 'sn':
- case 'so':
- case 'sq':
- case 'ta':
- case 'te':
- case 'teo':
- case 'tk':
- case 'tr':
- case 'ug':
- case 'uz':
- case 'vo':
- case 'vun':
- case 'wae':
- case 'xog':
- if (n === 1)
- return Plural.One;
- return Plural.Other;
- case 'ak':
- case 'ln':
- case 'mg':
- case 'pa':
- case 'ti':
- if (n === Math.floor(n) && n >= 0 && n <= 1)
- return Plural.One;
- return Plural.Other;
- case 'am':
- case 'as':
- case 'bn':
- case 'fa':
- case 'gu':
- case 'hi':
- case 'kn':
- case 'mr':
- case 'zu':
- if (i === 0 || n === 1)
- return Plural.One;
- return Plural.Other;
- case 'ar':
- if (n === 0)
- return Plural.Zero;
- if (n === 1)
- return Plural.One;
- if (n === 2)
- return Plural.Two;
- if (n % 100 === Math.floor(n % 100) && n % 100 >= 3 && n % 100 <= 10)
- return Plural.Few;
- if (n % 100 === Math.floor(n % 100) && n % 100 >= 11 && n % 100 <= 99)
- return Plural.Many;
- return Plural.Other;
- case 'ast':
- case 'ca':
- case 'de':
- case 'en':
- case 'et':
- case 'fi':
- case 'fy':
- case 'gl':
- case 'it':
- case 'nl':
- case 'sv':
- case 'sw':
- case 'ur':
- case 'yi':
- if (i === 1 && v === 0)
- return Plural.One;
- return Plural.Other;
- case 'be':
- if (n % 10 === 1 && !(n % 100 === 11))
- return Plural.One;
- if (n % 10 === Math.floor(n % 10) && n % 10 >= 2 && n % 10 <= 4 &&
- !(n % 100 >= 12 && n % 100 <= 14))
- return Plural.Few;
- if (n % 10 === 0 || n % 10 === Math.floor(n % 10) && n % 10 >= 5 && n % 10 <= 9 ||
- n % 100 === Math.floor(n % 100) && n % 100 >= 11 && n % 100 <= 14)
- return Plural.Many;
- return Plural.Other;
- case 'br':
- if (n % 10 === 1 && !(n % 100 === 11 || n % 100 === 71 || n % 100 === 91))
- return Plural.One;
- if (n % 10 === 2 && !(n % 100 === 12 || n % 100 === 72 || n % 100 === 92))
- return Plural.Two;
- if (n % 10 === Math.floor(n % 10) && (n % 10 >= 3 && n % 10 <= 4 || n % 10 === 9) &&
- !(n % 100 >= 10 && n % 100 <= 19 || n % 100 >= 70 && n % 100 <= 79 ||
- n % 100 >= 90 && n % 100 <= 99))
- return Plural.Few;
- if (!(n === 0) && n % 1e6 === 0)
- return Plural.Many;
- return Plural.Other;
- case 'bs':
- case 'hr':
- case 'sr':
- if (v === 0 && i % 10 === 1 && !(i % 100 === 11) || f % 10 === 1 && !(f % 100 === 11))
- return Plural.One;
- if (v === 0 && i % 10 === Math.floor(i % 10) && i % 10 >= 2 && i % 10 <= 4 &&
- !(i % 100 >= 12 && i % 100 <= 14) ||
- f % 10 === Math.floor(f % 10) && f % 10 >= 2 && f % 10 <= 4 &&
- !(f % 100 >= 12 && f % 100 <= 14))
- return Plural.Few;
- return Plural.Other;
- case 'cs':
- case 'sk':
- if (i === 1 && v === 0)
- return Plural.One;
- if (i === Math.floor(i) && i >= 2 && i <= 4 && v === 0)
- return Plural.Few;
- if (!(v === 0))
- return Plural.Many;
- return Plural.Other;
- case 'cy':
- if (n === 0)
- return Plural.Zero;
- if (n === 1)
- return Plural.One;
- if (n === 2)
- return Plural.Two;
- if (n === 3)
- return Plural.Few;
- if (n === 6)
- return Plural.Many;
- return Plural.Other;
- case 'da':
- if (n === 1 || !(t === 0) && (i === 0 || i === 1))
- return Plural.One;
- return Plural.Other;
- case 'dsb':
- case 'hsb':
- if (v === 0 && i % 100 === 1 || f % 100 === 1)
- return Plural.One;
- if (v === 0 && i % 100 === 2 || f % 100 === 2)
- return Plural.Two;
- if (v === 0 && i % 100 === Math.floor(i % 100) && i % 100 >= 3 && i % 100 <= 4 ||
- f % 100 === Math.floor(f % 100) && f % 100 >= 3 && f % 100 <= 4)
- return Plural.Few;
- return Plural.Other;
- case 'ff':
- case 'fr':
- case 'hy':
- case 'kab':
- if (i === 0 || i === 1)
- return Plural.One;
- return Plural.Other;
- case 'fil':
- if (v === 0 && (i === 1 || i === 2 || i === 3) ||
- v === 0 && !(i % 10 === 4 || i % 10 === 6 || i % 10 === 9) ||
- !(v === 0) && !(f % 10 === 4 || f % 10 === 6 || f % 10 === 9))
- return Plural.One;
- return Plural.Other;
- case 'ga':
- if (n === 1)
- return Plural.One;
- if (n === 2)
- return Plural.Two;
- if (n === Math.floor(n) && n >= 3 && n <= 6)
- return Plural.Few;
- if (n === Math.floor(n) && n >= 7 && n <= 10)
- return Plural.Many;
- return Plural.Other;
- case 'gd':
- if (n === 1 || n === 11)
- return Plural.One;
- if (n === 2 || n === 12)
- return Plural.Two;
- if (n === Math.floor(n) && (n >= 3 && n <= 10 || n >= 13 && n <= 19))
- return Plural.Few;
- return Plural.Other;
- case 'gv':
- if (v === 0 && i % 10 === 1)
- return Plural.One;
- if (v === 0 && i % 10 === 2)
- return Plural.Two;
- if (v === 0 &&
- (i % 100 === 0 || i % 100 === 20 || i % 100 === 40 || i % 100 === 60 || i % 100 === 80))
- return Plural.Few;
- if (!(v === 0))
- return Plural.Many;
- return Plural.Other;
- case 'he':
- if (i === 1 && v === 0)
- return Plural.One;
- if (i === 2 && v === 0)
- return Plural.Two;
- if (v === 0 && !(n >= 0 && n <= 10) && n % 10 === 0)
- return Plural.Many;
- return Plural.Other;
- case 'is':
- if (t === 0 && i % 10 === 1 && !(i % 100 === 11) || !(t === 0))
- return Plural.One;
- return Plural.Other;
- case 'ksh':
- if (n === 0)
- return Plural.Zero;
- if (n === 1)
- return Plural.One;
- return Plural.Other;
- case 'kw':
- case 'naq':
- case 'se':
- case 'smn':
- if (n === 1)
- return Plural.One;
- if (n === 2)
- return Plural.Two;
- return Plural.Other;
- case 'lag':
- if (n === 0)
- return Plural.Zero;
- if ((i === 0 || i === 1) && !(n === 0))
- return Plural.One;
- return Plural.Other;
- case 'lt':
- if (n % 10 === 1 && !(n % 100 >= 11 && n % 100 <= 19))
- return Plural.One;
- if (n % 10 === Math.floor(n % 10) && n % 10 >= 2 && n % 10 <= 9 &&
- !(n % 100 >= 11 && n % 100 <= 19))
- return Plural.Few;
- if (!(f === 0))
- return Plural.Many;
- return Plural.Other;
- case 'lv':
- case 'prg':
- if (n % 10 === 0 || n % 100 === Math.floor(n % 100) && n % 100 >= 11 && n % 100 <= 19 ||
- v === 2 && f % 100 === Math.floor(f % 100) && f % 100 >= 11 && f % 100 <= 19)
- return Plural.Zero;
- if (n % 10 === 1 && !(n % 100 === 11) || v === 2 && f % 10 === 1 && !(f % 100 === 11) ||
- !(v === 2) && f % 10 === 1)
- return Plural.One;
- return Plural.Other;
- case 'mk':
- if (v === 0 && i % 10 === 1 || f % 10 === 1)
- return Plural.One;
- return Plural.Other;
- case 'mt':
- if (n === 1)
- return Plural.One;
- if (n === 0 || n % 100 === Math.floor(n % 100) && n % 100 >= 2 && n % 100 <= 10)
- return Plural.Few;
- if (n % 100 === Math.floor(n % 100) && n % 100 >= 11 && n % 100 <= 19)
- return Plural.Many;
- return Plural.Other;
- case 'pl':
- if (i === 1 && v === 0)
- return Plural.One;
- if (v === 0 && i % 10 === Math.floor(i % 10) && i % 10 >= 2 && i % 10 <= 4 &&
- !(i % 100 >= 12 && i % 100 <= 14))
- return Plural.Few;
- if (v === 0 && !(i === 1) && i % 10 === Math.floor(i % 10) && i % 10 >= 0 && i % 10 <= 1 ||
- v === 0 && i % 10 === Math.floor(i % 10) && i % 10 >= 5 && i % 10 <= 9 ||
- v === 0 && i % 100 === Math.floor(i % 100) && i % 100 >= 12 && i % 100 <= 14)
- return Plural.Many;
- return Plural.Other;
- case 'pt':
- if (n === Math.floor(n) && n >= 0 && n <= 2 && !(n === 2))
- return Plural.One;
- return Plural.Other;
- case 'ro':
- if (i === 1 && v === 0)
- return Plural.One;
- if (!(v === 0) || n === 0 ||
- !(n === 1) && n % 100 === Math.floor(n % 100) && n % 100 >= 1 && n % 100 <= 19)
- return Plural.Few;
- return Plural.Other;
- case 'ru':
- case 'uk':
- if (v === 0 && i % 10 === 1 && !(i % 100 === 11))
- return Plural.One;
- if (v === 0 && i % 10 === Math.floor(i % 10) && i % 10 >= 2 && i % 10 <= 4 &&
- !(i % 100 >= 12 && i % 100 <= 14))
- return Plural.Few;
- if (v === 0 && i % 10 === 0 ||
- v === 0 && i % 10 === Math.floor(i % 10) && i % 10 >= 5 && i % 10 <= 9 ||
- v === 0 && i % 100 === Math.floor(i % 100) && i % 100 >= 11 && i % 100 <= 14)
- return Plural.Many;
- return Plural.Other;
- case 'shi':
- if (i === 0 || n === 1)
- return Plural.One;
- if (n === Math.floor(n) && n >= 2 && n <= 10)
- return Plural.Few;
- return Plural.Other;
- case 'si':
- if (n === 0 || n === 1 || i === 0 && f === 1)
- return Plural.One;
- return Plural.Other;
- case 'sl':
- if (v === 0 && i % 100 === 1)
- return Plural.One;
- if (v === 0 && i % 100 === 2)
- return Plural.Two;
- if (v === 0 && i % 100 === Math.floor(i % 100) && i % 100 >= 3 && i % 100 <= 4 || !(v === 0))
- return Plural.Few;
- return Plural.Other;
- case 'tzm':
- if (n === Math.floor(n) && n >= 0 && n <= 1 || n === Math.floor(n) && n >= 11 && n <= 99)
- return Plural.One;
- return Plural.Other;
- // When there is no specification, the default is always "other"
- // Spec: http://cldr.unicode.org/index/cldr-spec/plural-rules
- // > other (required—general plural form — also used if the language only has a single form)
- default:
- return Plural.Other;
- }
- }
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- * @param {?} cookieStr
- * @param {?} name
- * @return {?}
- */
- function parseCookieValue(cookieStr, name) {
- name = encodeURIComponent(name);
- for (var _i = 0, _a = cookieStr.split(';'); _i < _a.length; _i++) {
- var cookie = _a[_i];
- var /** @type {?} */ eqIndex = cookie.indexOf('=');
- var _b = eqIndex == -1 ? [cookie, ''] : [cookie.slice(0, eqIndex), cookie.slice(eqIndex + 1)], cookieName = _b[0], cookieValue = _b[1];
- if (cookieName.trim() === name) {
- return decodeURIComponent(cookieValue);
- }
- }
- return null;
- }
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * \@ngModule CommonModule
- *
- * \@whatItDoes Adds and removes CSS classes on an HTML element.
- *
- * \@howToUse
- * ```
- * <some-element [ngClass]="'first second'">...</some-element>
- *
- * <some-element [ngClass]="['first', 'second']">...</some-element>
- *
- * <some-element [ngClass]="{'first': true, 'second': true, 'third': false}">...</some-element>
- *
- * <some-element [ngClass]="stringExp|arrayExp|objExp">...</some-element>
- *
- * <some-element [ngClass]="{'class1 class2 class3' : true}">...</some-element>
- * ```
- *
- * \@description
- *
- * The CSS classes are updated as follows, depending on the type of the expression evaluation:
- * - `string` - the CSS classes listed in the string (space delimited) are added,
- * - `Array` - the CSS classes declared as Array elements are added,
- * - `Object` - keys are CSS classes that get added when the expression given in the value
- * evaluates to a truthy value, otherwise they are removed.
- *
- * \@stable
- */
- var NgClass = (function () {
- /**
- * @param {?} _iterableDiffers
- * @param {?} _keyValueDiffers
- * @param {?} _ngEl
- * @param {?} _renderer
- */
- function NgClass(_iterableDiffers, _keyValueDiffers, _ngEl, _renderer) {
- this._iterableDiffers = _iterableDiffers;
- this._keyValueDiffers = _keyValueDiffers;
- this._ngEl = _ngEl;
- this._renderer = _renderer;
- this._initialClasses = [];
- }
- Object.defineProperty(NgClass.prototype, "klass", {
- /**
- * @param {?} v
- * @return {?}
- */
- set: function (v) {
- this._applyInitialClasses(true);
- this._initialClasses = typeof v === 'string' ? v.split(/\s+/) : [];
- this._applyInitialClasses(false);
- this._applyClasses(this._rawClass, false);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(NgClass.prototype, "ngClass", {
- /**
- * @param {?} v
- * @return {?}
- */
- set: function (v) {
- this._cleanupClasses(this._rawClass);
- this._iterableDiffer = null;
- this._keyValueDiffer = null;
- this._rawClass = typeof v === 'string' ? v.split(/\s+/) : v;
- if (this._rawClass) {
- if (isListLikeIterable(this._rawClass)) {
- this._iterableDiffer = this._iterableDiffers.find(this._rawClass).create();
- }
- else {
- this._keyValueDiffer = this._keyValueDiffers.find(this._rawClass).create();
- }
- }
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @return {?}
- */
- NgClass.prototype.ngDoCheck = function () {
- if (this._iterableDiffer) {
- var /** @type {?} */ iterableChanges = this._iterableDiffer.diff(/** @type {?} */ (this._rawClass));
- if (iterableChanges) {
- this._applyIterableChanges(iterableChanges);
- }
- }
- else if (this._keyValueDiffer) {
- var /** @type {?} */ keyValueChanges = this._keyValueDiffer.diff(/** @type {?} */ (this._rawClass));
- if (keyValueChanges) {
- this._applyKeyValueChanges(keyValueChanges);
- }
- }
- };
- /**
- * @param {?} rawClassVal
- * @return {?}
- */
- NgClass.prototype._cleanupClasses = function (rawClassVal) {
- this._applyClasses(rawClassVal, true);
- this._applyInitialClasses(false);
- };
- /**
- * @param {?} changes
- * @return {?}
- */
- NgClass.prototype._applyKeyValueChanges = function (changes) {
- var _this = this;
- changes.forEachAddedItem(function (record) { return _this._toggleClass(record.key, record.currentValue); });
- changes.forEachChangedItem(function (record) { return _this._toggleClass(record.key, record.currentValue); });
- changes.forEachRemovedItem(function (record) {
- if (record.previousValue) {
- _this._toggleClass(record.key, false);
- }
- });
- };
- /**
- * @param {?} changes
- * @return {?}
- */
- NgClass.prototype._applyIterableChanges = function (changes) {
- var _this = this;
- changes.forEachAddedItem(function (record) {
- if (typeof record.item === 'string') {
- _this._toggleClass(record.item, true);
- }
- else {
- throw new Error("NgClass can only toggle CSS classes expressed as strings, got " + stringify(record.item));
- }
- });
- changes.forEachRemovedItem(function (record) { return _this._toggleClass(record.item, false); });
- };
- /**
- * @param {?} isCleanup
- * @return {?}
- */
- NgClass.prototype._applyInitialClasses = function (isCleanup) {
- var _this = this;
- this._initialClasses.forEach(function (klass) { return _this._toggleClass(klass, !isCleanup); });
- };
- /**
- * @param {?} rawClassVal
- * @param {?} isCleanup
- * @return {?}
- */
- NgClass.prototype._applyClasses = function (rawClassVal, isCleanup) {
- var _this = this;
- if (rawClassVal) {
- if (Array.isArray(rawClassVal) || rawClassVal instanceof Set) {
- ((rawClassVal)).forEach(function (klass) { return _this._toggleClass(klass, !isCleanup); });
- }
- else {
- Object.keys(rawClassVal).forEach(function (klass) {
- if (rawClassVal[klass] != null)
- _this._toggleClass(klass, !isCleanup);
- });
- }
- }
- };
- /**
- * @param {?} klass
- * @param {?} enabled
- * @return {?}
- */
- NgClass.prototype._toggleClass = function (klass, enabled) {
- var _this = this;
- klass = klass.trim();
- if (klass) {
- klass.split(/\s+/g).forEach(function (klass) { _this._renderer.setElementClass(_this._ngEl.nativeElement, klass, !!enabled); });
- }
- };
- return NgClass;
- }());
- NgClass.decorators = [
- { type: Directive, args: [{ selector: '[ngClass]' },] },
- ];
- /**
- * @nocollapse
- */
- NgClass.ctorParameters = function () { return [
- { type: IterableDiffers, },
- { type: KeyValueDiffers, },
- { type: ElementRef, },
- { type: Renderer, },
- ]; };
- NgClass.propDecorators = {
- 'klass': [{ type: Input, args: ['class',] },],
- 'ngClass': [{ type: Input },],
- };
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * Instantiates a single {\@link Component} type and inserts its Host View into current View.
- * `NgComponentOutlet` provides a declarative approach for dynamic component creation.
- *
- * `NgComponentOutlet` requires a component type, if a falsy value is set the view will clear and
- * any existing component will get destroyed.
- *
- * ### Fine tune control
- *
- * You can control the component creation process by using the following optional attributes:
- *
- * * `ngComponentOutletInjector`: Optional custom {\@link Injector} that will be used as parent for
- * the Component. Defaults to the injector of the current view container.
- *
- * * `ngComponentOutletContent`: Optional list of projectable nodes to insert into the content
- * section of the component, if exists.
- *
- * * `ngComponentOutletNgModuleFactory`: Optional module factory to allow dynamically loading other
- * module, then load a component from that module.
- *
- * ### Syntax
- *
- * Simple
- * ```
- * <ng-container *ngComponentOutlet="componentTypeExpression"></ng-container>
- * ```
- *
- * Customized injector/content
- * ```
- * <ng-container *ngComponentOutlet="componentTypeExpression;
- * injector: injectorExpression;
- * content: contentNodesExpression;">
- * </ng-container>
- * ```
- *
- * Customized ngModuleFactory
- * ```
- * <ng-container *ngComponentOutlet="componentTypeExpression;
- * ngModuleFactory: moduleFactory;">
- * </ng-container>
- * ```
- * ## Example
- *
- * {\@example common/ngComponentOutlet/ts/module.ts region='SimpleExample'}
- *
- * A more complete example with additional options:
- *
- * {\@example common/ngComponentOutlet/ts/module.ts region='CompleteExample'}
- * A more complete example with ngModuleFactory:
- *
- * {\@example common/ngComponentOutlet/ts/module.ts region='NgModuleFactoryExample'}
- *
- * \@experimental
- */
- var NgComponentOutlet = (function () {
- /**
- * @param {?} _viewContainerRef
- */
- function NgComponentOutlet(_viewContainerRef) {
- this._viewContainerRef = _viewContainerRef;
- this._componentRef = null;
- this._moduleRef = null;
- }
- /**
- * @param {?} changes
- * @return {?}
- */
- NgComponentOutlet.prototype.ngOnChanges = function (changes) {
- this._viewContainerRef.clear();
- this._componentRef = null;
- if (this.ngComponentOutlet) {
- var /** @type {?} */ elInjector = this.ngComponentOutletInjector || this._viewContainerRef.parentInjector;
- if (changes['ngComponentOutletNgModuleFactory']) {
- if (this._moduleRef)
- this._moduleRef.destroy();
- if (this.ngComponentOutletNgModuleFactory) {
- var /** @type {?} */ parentModule = elInjector.get(NgModuleRef);
- this._moduleRef = this.ngComponentOutletNgModuleFactory.create(parentModule.injector);
- }
- else {
- this._moduleRef = null;
- }
- }
- var /** @type {?} */ componentFactoryResolver = this._moduleRef ? this._moduleRef.componentFactoryResolver :
- elInjector.get(ComponentFactoryResolver);
- var /** @type {?} */ componentFactory = componentFactoryResolver.resolveComponentFactory(this.ngComponentOutlet);
- this._componentRef = this._viewContainerRef.createComponent(componentFactory, this._viewContainerRef.length, elInjector, this.ngComponentOutletContent);
- }
- };
- /**
- * @return {?}
- */
- NgComponentOutlet.prototype.ngOnDestroy = function () {
- if (this._moduleRef)
- this._moduleRef.destroy();
- };
- return NgComponentOutlet;
- }());
- NgComponentOutlet.decorators = [
- { type: Directive, args: [{ selector: '[ngComponentOutlet]' },] },
- ];
- /**
- * @nocollapse
- */
- NgComponentOutlet.ctorParameters = function () { return [
- { type: ViewContainerRef, },
- ]; };
- NgComponentOutlet.propDecorators = {
- 'ngComponentOutlet': [{ type: Input },],
- 'ngComponentOutletInjector': [{ type: Input },],
- 'ngComponentOutletContent': [{ type: Input },],
- 'ngComponentOutletNgModuleFactory': [{ type: Input },],
- };
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * \@stable
- */
- var NgForOfContext = (function () {
- /**
- * @param {?} $implicit
- * @param {?} ngForOf
- * @param {?} index
- * @param {?} count
- */
- function NgForOfContext($implicit, ngForOf, index, count) {
- this.$implicit = $implicit;
- this.ngForOf = ngForOf;
- this.index = index;
- this.count = count;
- }
- Object.defineProperty(NgForOfContext.prototype, "first", {
- /**
- * @return {?}
- */
- get: function () { return this.index === 0; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(NgForOfContext.prototype, "last", {
- /**
- * @return {?}
- */
- get: function () { return this.index === this.count - 1; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(NgForOfContext.prototype, "even", {
- /**
- * @return {?}
- */
- get: function () { return this.index % 2 === 0; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(NgForOfContext.prototype, "odd", {
- /**
- * @return {?}
- */
- get: function () { return !this.even; },
- enumerable: true,
- configurable: true
- });
- return NgForOfContext;
- }());
- /**
- * The `NgForOf` directive instantiates a template once per item from an iterable. The context
- * for each instantiated template inherits from the outer context with the given loop variable
- * set to the current item from the iterable.
- *
- * ### Local Variables
- *
- * `NgForOf` provides several exported values that can be aliased to local variables:
- *
- * - `$implicit: T`: The value of the individual items in the iterable (`ngForOf`).
- * - `ngForOf: NgIterable<T>`: The value of the iterable expression. Useful when the expression is
- * more complex then a property access, for example when using the async pipe (`userStreams |
- * async`).
- * - `index: number`: The index of the current item in the iterable.
- * - `first: boolean`: True when the item is the first item in the iterable.
- * - `last: boolean`: True when the item is the last item in the iterable.
- * - `even: boolean`: True when the item has an even index in the iterable.
- * - `odd: boolean`: True when the item has an odd index in the iterable.
- *
- * ```
- * <li *ngFor="let user of userObservable | async as users; index as i; first as isFirst">
- * {{i}}/{{users.length}}. {{user}} <span *ngIf="isFirst">default</span>
- * </li>
- * ```
- *
- * ### Change Propagation
- *
- * When the contents of the iterator changes, `NgForOf` makes the corresponding changes to the DOM:
- *
- * * When an item is added, a new instance of the template is added to the DOM.
- * * When an item is removed, its template instance is removed from the DOM.
- * * When items are reordered, their respective templates are reordered in the DOM.
- * * Otherwise, the DOM element for that item will remain the same.
- *
- * Angular uses object identity to track insertions and deletions within the iterator and reproduce
- * those changes in the DOM. This has important implications for animations and any stateful
- * controls (such as `<input>` elements which accept user input) that are present. Inserted rows can
- * be animated in, deleted rows can be animated out, and unchanged rows retain any unsaved state
- * such as user input.
- *
- * It is possible for the identities of elements in the iterator to change while the data does not.
- * This can happen, for example, if the iterator produced from an RPC to the server, and that
- * RPC is re-run. Even if the data hasn't changed, the second response will produce objects with
- * different identities, and Angular will tear down the entire DOM and rebuild it (as if all old
- * elements were deleted and all new elements inserted). This is an expensive operation and should
- * be avoided if possible.
- *
- * To customize the default tracking algorithm, `NgForOf` supports `trackBy` option.
- * `trackBy` takes a function which has two arguments: `index` and `item`.
- * If `trackBy` is given, Angular tracks changes by the return value of the function.
- *
- * ### Syntax
- *
- * - `<li *ngFor="let item of items; index as i; trackBy: trackByFn">...</li>`
- * - `<li template="ngFor let item of items; index as i; trackBy: trackByFn">...</li>`
- *
- * With `<ng-template>` element:
- *
- * ```
- * <ng-template ngFor let-item [ngForOf]="items" let-i="index" [ngForTrackBy]="trackByFn">
- * <li>...</li>
- * </ng-template>
- * ```
- *
- * ### Example
- *
- * See a [live demo](http://plnkr.co/edit/KVuXxDp0qinGDyo307QW?p=preview) for a more detailed
- * example.
- *
- * \@stable
- */
- var NgForOf = (function () {
- /**
- * @param {?} _viewContainer
- * @param {?} _template
- * @param {?} _differs
- */
- function NgForOf(_viewContainer, _template, _differs) {
- this._viewContainer = _viewContainer;
- this._template = _template;
- this._differs = _differs;
- this._differ = null;
- }
- Object.defineProperty(NgForOf.prototype, "ngForTrackBy", {
- /**
- * @return {?}
- */
- get: function () { return this._trackByFn; },
- /**
- * @param {?} fn
- * @return {?}
- */
- set: function (fn) {
- if (isDevMode() && fn != null && typeof fn !== 'function') {
- // TODO(vicb): use a log service once there is a public one available
- if ((console) && (console.warn)) {
- console.warn("trackBy must be a function, but received " + JSON.stringify(fn) + ". " +
- "See https://angular.io/docs/ts/latest/api/common/index/NgFor-directive.html#!#change-propagation for more information.");
- }
- }
- this._trackByFn = fn;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(NgForOf.prototype, "ngForTemplate", {
- /**
- * @param {?} value
- * @return {?}
- */
- set: function (value) {
- // TODO(TS2.1): make TemplateRef<Partial<NgForRowOf<T>>> once we move to TS v2.1
- // The current type is too restrictive; a template that just uses index, for example,
- // should be acceptable.
- if (value) {
- this._template = value;
- }
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @param {?} changes
- * @return {?}
- */
- NgForOf.prototype.ngOnChanges = function (changes) {
- if ('ngForOf' in changes) {
- // React on ngForOf changes only once all inputs have been initialized
- var /** @type {?} */ value = changes['ngForOf'].currentValue;
- if (!this._differ && value) {
- try {
- this._differ = this._differs.find(value).create(this.ngForTrackBy);
- }
- catch (e) {
- throw new Error("Cannot find a differ supporting object '" + value + "' of type '" + getTypeNameForDebugging$1(value) + "'. NgFor only supports binding to Iterables such as Arrays.");
- }
- }
- }
- };
- /**
- * @return {?}
- */
- NgForOf.prototype.ngDoCheck = function () {
- if (this._differ) {
- var /** @type {?} */ changes = this._differ.diff(this.ngForOf);
- if (changes)
- this._applyChanges(changes);
- }
- };
- /**
- * @param {?} changes
- * @return {?}
- */
- NgForOf.prototype._applyChanges = function (changes) {
- var _this = this;
- var /** @type {?} */ insertTuples = [];
- changes.forEachOperation(function (item, adjustedPreviousIndex, currentIndex) {
- if (item.previousIndex == null) {
- var /** @type {?} */ view = _this._viewContainer.createEmbeddedView(_this._template, new NgForOfContext(/** @type {?} */ ((null)), _this.ngForOf, -1, -1), currentIndex);
- var /** @type {?} */ tuple = new RecordViewTuple(item, view);
- insertTuples.push(tuple);
- }
- else if (currentIndex == null) {
- _this._viewContainer.remove(adjustedPreviousIndex);
- }
- else {
- var /** @type {?} */ view = ((_this._viewContainer.get(adjustedPreviousIndex)));
- _this._viewContainer.move(view, currentIndex);
- var /** @type {?} */ tuple = new RecordViewTuple(item, /** @type {?} */ (view));
- insertTuples.push(tuple);
- }
- });
- for (var /** @type {?} */ i = 0; i < insertTuples.length; i++) {
- this._perViewChange(insertTuples[i].view, insertTuples[i].record);
- }
- for (var /** @type {?} */ i = 0, /** @type {?} */ ilen = this._viewContainer.length; i < ilen; i++) {
- var /** @type {?} */ viewRef = (this._viewContainer.get(i));
- viewRef.context.index = i;
- viewRef.context.count = ilen;
- }
- changes.forEachIdentityChange(function (record) {
- var /** @type {?} */ viewRef = (_this._viewContainer.get(record.currentIndex));
- viewRef.context.$implicit = record.item;
- });
- };
- /**
- * @param {?} view
- * @param {?} record
- * @return {?}
- */
- NgForOf.prototype._perViewChange = function (view, record) {
- view.context.$implicit = record.item;
- };
- return NgForOf;
- }());
- NgForOf.decorators = [
- { type: Directive, args: [{ selector: '[ngFor][ngForOf]' },] },
- ];
- /**
- * @nocollapse
- */
- NgForOf.ctorParameters = function () { return [
- { type: ViewContainerRef, },
- { type: TemplateRef, },
- { type: IterableDiffers, },
- ]; };
- NgForOf.propDecorators = {
- 'ngForOf': [{ type: Input },],
- 'ngForTrackBy': [{ type: Input },],
- 'ngForTemplate': [{ type: Input },],
- };
- var RecordViewTuple = (function () {
- /**
- * @param {?} record
- * @param {?} view
- */
- function RecordViewTuple(record, view) {
- this.record = record;
- this.view = view;
- }
- return RecordViewTuple;
- }());
- /**
- * @param {?} type
- * @return {?}
- */
- function getTypeNameForDebugging$1(type) {
- return type['name'] || typeof type;
- }
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * Conditionally includes a template based on the value of an `expression`.
- *
- * `ngIf` evaluates the `expression` and then renders the `then` or `else` template in its place
- * when expression is truthy or falsy respectively. Typically the:
- * - `then` template is the inline template of `ngIf` unless bound to a different value.
- * - `else` template is blank unless it is bound.
- *
- * ## Most common usage
- *
- * The most common usage of the `ngIf` directive is to conditionally show the inline template as
- * seen in this example:
- * {\@example common/ngIf/ts/module.ts region='NgIfSimple'}
- *
- * ## Showing an alternative template using `else`
- *
- * If it is necessary to display a template when the `expression` is falsy use the `else` template
- * binding as shown. Note that the `else` binding points to a `<ng-template>` labeled `#elseBlock`.
- * The template can be defined anywhere in the component view but is typically placed right after
- * `ngIf` for readability.
- *
- * {\@example common/ngIf/ts/module.ts region='NgIfElse'}
- *
- * ## Using non-inlined `then` template
- *
- * Usually the `then` template is the inlined template of the `ngIf`, but it can be changed using
- * a binding (just like `else`). Because `then` and `else` are bindings, the template references can
- * change at runtime as shown in this example.
- *
- * {\@example common/ngIf/ts/module.ts region='NgIfThenElse'}
- *
- * ## Storing conditional result in a variable
- *
- * A common pattern is that we need to show a set of properties from the same object. If the
- * object is undefined, then we have to use the safe-traversal-operator `?.` to guard against
- * dereferencing a `null` value. This is especially the case when waiting on async data such as
- * when using the `async` pipe as shown in following example:
- *
- * ```
- * Hello {{ (userStream|async)?.last }}, {{ (userStream|async)?.first }}!
- * ```
- *
- * There are several inefficiencies in the above example:
- * - We create multiple subscriptions on `userStream`. One for each `async` pipe, or two in the
- * example above.
- * - We cannot display an alternative screen while waiting for the data to arrive asynchronously.
- * - We have to use the safe-traversal-operator `?.` to access properties, which is cumbersome.
- * - We have to place the `async` pipe in parenthesis.
- *
- * A better way to do this is to use `ngIf` and store the result of the condition in a local
- * variable as shown in the the example below:
- *
- * {\@example common/ngIf/ts/module.ts region='NgIfAs'}
- *
- * Notice that:
- * - We use only one `async` pipe and hence only one subscription gets created.
- * - `ngIf` stores the result of the `userStream|async` in the local variable `user`.
- * - The local `user` can then be bound repeatedly in a more efficient way.
- * - No need to use the safe-traversal-operator `?.` to access properties as `ngIf` will only
- * display the data if `userStream` returns a value.
- * - We can display an alternative template while waiting for the data.
- *
- * ### Syntax
- *
- * Simple form:
- * - `<div *ngIf="condition">...</div>`
- * - `<div template="ngIf condition">...</div>`
- * - `<ng-template [ngIf]="condition"><div>...</div></ng-template>`
- *
- * Form with an else block:
- * ```
- * <div *ngIf="condition; else elseBlock">...</div>
- * <ng-template #elseBlock>...</ng-template>
- * ```
- *
- * Form with a `then` and `else` block:
- * ```
- * <div *ngIf="condition; then thenBlock else elseBlock"></div>
- * <ng-template #thenBlock>...</ng-template>
- * <ng-template #elseBlock>...</ng-template>
- * ```
- *
- * Form with storing the value locally:
- * ```
- * <div *ngIf="condition as value; else elseBlock">{{value}}</div>
- * <ng-template #elseBlock>...</ng-template>
- * ```
- *
- * \@stable
- */
- var NgIf = (function () {
- /**
- * @param {?} _viewContainer
- * @param {?} templateRef
- */
- function NgIf(_viewContainer, templateRef) {
- this._viewContainer = _viewContainer;
- this._context = new NgIfContext();
- this._thenTemplateRef = null;
- this._elseTemplateRef = null;
- this._thenViewRef = null;
- this._elseViewRef = null;
- this._thenTemplateRef = templateRef;
- }
- Object.defineProperty(NgIf.prototype, "ngIf", {
- /**
- * @param {?} condition
- * @return {?}
- */
- set: function (condition) {
- this._context.$implicit = this._context.ngIf = condition;
- this._updateView();
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(NgIf.prototype, "ngIfThen", {
- /**
- * @param {?} templateRef
- * @return {?}
- */
- set: function (templateRef) {
- this._thenTemplateRef = templateRef;
- this._thenViewRef = null; // clear previous view if any.
- this._updateView();
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(NgIf.prototype, "ngIfElse", {
- /**
- * @param {?} templateRef
- * @return {?}
- */
- set: function (templateRef) {
- this._elseTemplateRef = templateRef;
- this._elseViewRef = null; // clear previous view if any.
- this._updateView();
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @return {?}
- */
- NgIf.prototype._updateView = function () {
- if (this._context.$implicit) {
- if (!this._thenViewRef) {
- this._viewContainer.clear();
- this._elseViewRef = null;
- if (this._thenTemplateRef) {
- this._thenViewRef =
- this._viewContainer.createEmbeddedView(this._thenTemplateRef, this._context);
- }
- }
- }
- else {
- if (!this._elseViewRef) {
- this._viewContainer.clear();
- this._thenViewRef = null;
- if (this._elseTemplateRef) {
- this._elseViewRef =
- this._viewContainer.createEmbeddedView(this._elseTemplateRef, this._context);
- }
- }
- }
- };
- return NgIf;
- }());
- NgIf.decorators = [
- { type: Directive, args: [{ selector: '[ngIf]' },] },
- ];
- /**
- * @nocollapse
- */
- NgIf.ctorParameters = function () { return [
- { type: ViewContainerRef, },
- { type: TemplateRef, },
- ]; };
- NgIf.propDecorators = {
- 'ngIf': [{ type: Input },],
- 'ngIfThen': [{ type: Input },],
- 'ngIfElse': [{ type: Input },],
- };
- /**
- * \@stable
- */
- var NgIfContext = (function () {
- function NgIfContext() {
- this.$implicit = null;
- this.ngIf = null;
- }
- return NgIfContext;
- }());
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var SwitchView = (function () {
- /**
- * @param {?} _viewContainerRef
- * @param {?} _templateRef
- */
- function SwitchView(_viewContainerRef, _templateRef) {
- this._viewContainerRef = _viewContainerRef;
- this._templateRef = _templateRef;
- this._created = false;
- }
- /**
- * @return {?}
- */
- SwitchView.prototype.create = function () {
- this._created = true;
- this._viewContainerRef.createEmbeddedView(this._templateRef);
- };
- /**
- * @return {?}
- */
- SwitchView.prototype.destroy = function () {
- this._created = false;
- this._viewContainerRef.clear();
- };
- /**
- * @param {?} created
- * @return {?}
- */
- SwitchView.prototype.enforceState = function (created) {
- if (created && !this._created) {
- this.create();
- }
- else if (!created && this._created) {
- this.destroy();
- }
- };
- return SwitchView;
- }());
- /**
- * \@ngModule CommonModule
- *
- * \@whatItDoes Adds / removes DOM sub-trees when the nest match expressions matches the switch
- * expression.
- *
- * \@howToUse
- * ```
- * <container-element [ngSwitch]="switch_expression">
- * <some-element *ngSwitchCase="match_expression_1">...</some-element>
- * <some-element *ngSwitchCase="match_expression_2">...</some-element>
- * <some-other-element *ngSwitchCase="match_expression_3">...</some-other-element>
- * <ng-container *ngSwitchCase="match_expression_3">
- * <!-- use a ng-container to group multiple root nodes -->
- * <inner-element></inner-element>
- * <inner-other-element></inner-other-element>
- * </ng-container>
- * <some-element *ngSwitchDefault>...</some-element>
- * </container-element>
- * ```
- * \@description
- *
- * `NgSwitch` stamps out nested views when their match expression value matches the value of the
- * switch expression.
- *
- * In other words:
- * - you define a container element (where you place the directive with a switch expression on the
- * `[ngSwitch]="..."` attribute)
- * - you define inner views inside the `NgSwitch` and place a `*ngSwitchCase` attribute on the view
- * root elements.
- *
- * Elements within `NgSwitch` but outside of a `NgSwitchCase` or `NgSwitchDefault` directives will
- * be preserved at the location.
- *
- * The `ngSwitchCase` directive informs the parent `NgSwitch` of which view to display when the
- * expression is evaluated.
- * When no matching expression is found on a `ngSwitchCase` view, the `ngSwitchDefault` view is
- * stamped out.
- *
- * \@stable
- */
- var NgSwitch = (function () {
- function NgSwitch() {
- this._defaultUsed = false;
- this._caseCount = 0;
- this._lastCaseCheckIndex = 0;
- this._lastCasesMatched = false;
- }
- Object.defineProperty(NgSwitch.prototype, "ngSwitch", {
- /**
- * @param {?} newValue
- * @return {?}
- */
- set: function (newValue) {
- this._ngSwitch = newValue;
- if (this._caseCount === 0) {
- this._updateDefaultCases(true);
- }
- },
- enumerable: true,
- configurable: true
- });
- /**
- * \@internal
- * @return {?}
- */
- NgSwitch.prototype._addCase = function () { return this._caseCount++; };
- /**
- * \@internal
- * @param {?} view
- * @return {?}
- */
- NgSwitch.prototype._addDefault = function (view) {
- if (!this._defaultViews) {
- this._defaultViews = [];
- }
- this._defaultViews.push(view);
- };
- /**
- * \@internal
- * @param {?} value
- * @return {?}
- */
- NgSwitch.prototype._matchCase = function (value) {
- var /** @type {?} */ matched = value == this._ngSwitch;
- this._lastCasesMatched = this._lastCasesMatched || matched;
- this._lastCaseCheckIndex++;
- if (this._lastCaseCheckIndex === this._caseCount) {
- this._updateDefaultCases(!this._lastCasesMatched);
- this._lastCaseCheckIndex = 0;
- this._lastCasesMatched = false;
- }
- return matched;
- };
- /**
- * @param {?} useDefault
- * @return {?}
- */
- NgSwitch.prototype._updateDefaultCases = function (useDefault) {
- if (this._defaultViews && useDefault !== this._defaultUsed) {
- this._defaultUsed = useDefault;
- for (var /** @type {?} */ i = 0; i < this._defaultViews.length; i++) {
- var /** @type {?} */ defaultView = this._defaultViews[i];
- defaultView.enforceState(useDefault);
- }
- }
- };
- return NgSwitch;
- }());
- NgSwitch.decorators = [
- { type: Directive, args: [{ selector: '[ngSwitch]' },] },
- ];
- /**
- * @nocollapse
- */
- NgSwitch.ctorParameters = function () { return []; };
- NgSwitch.propDecorators = {
- 'ngSwitch': [{ type: Input },],
- };
- /**
- * \@ngModule CommonModule
- *
- * \@whatItDoes Creates a view that will be added/removed from the parent {\@link NgSwitch} when the
- * given expression evaluate to respectively the same/different value as the switch
- * expression.
- *
- * \@howToUse
- * ```
- * <container-element [ngSwitch]="switch_expression">
- * <some-element *ngSwitchCase="match_expression_1">...</some-element>
- * </container-element>
- * ```
- * \@description
- *
- * Insert the sub-tree when the expression evaluates to the same value as the enclosing switch
- * expression.
- *
- * If multiple match expressions match the switch expression value, all of them are displayed.
- *
- * See {\@link NgSwitch} for more details and example.
- *
- * \@stable
- */
- var NgSwitchCase = (function () {
- /**
- * @param {?} viewContainer
- * @param {?} templateRef
- * @param {?} ngSwitch
- */
- function NgSwitchCase(viewContainer, templateRef, ngSwitch) {
- this.ngSwitch = ngSwitch;
- ngSwitch._addCase();
- this._view = new SwitchView(viewContainer, templateRef);
- }
- /**
- * @return {?}
- */
- NgSwitchCase.prototype.ngDoCheck = function () { this._view.enforceState(this.ngSwitch._matchCase(this.ngSwitchCase)); };
- return NgSwitchCase;
- }());
- NgSwitchCase.decorators = [
- { type: Directive, args: [{ selector: '[ngSwitchCase]' },] },
- ];
- /**
- * @nocollapse
- */
- NgSwitchCase.ctorParameters = function () { return [
- { type: ViewContainerRef, },
- { type: TemplateRef, },
- { type: NgSwitch, decorators: [{ type: Host },] },
- ]; };
- NgSwitchCase.propDecorators = {
- 'ngSwitchCase': [{ type: Input },],
- };
- /**
- * \@ngModule CommonModule
- * \@whatItDoes Creates a view that is added to the parent {\@link NgSwitch} when no case expressions
- * match the
- * switch expression.
- *
- * \@howToUse
- * ```
- * <container-element [ngSwitch]="switch_expression">
- * <some-element *ngSwitchCase="match_expression_1">...</some-element>
- * <some-other-element *ngSwitchDefault>...</some-other-element>
- * </container-element>
- * ```
- *
- * \@description
- *
- * Insert the sub-tree when no case expressions evaluate to the same value as the enclosing switch
- * expression.
- *
- * See {\@link NgSwitch} for more details and example.
- *
- * \@stable
- */
- var NgSwitchDefault = (function () {
- /**
- * @param {?} viewContainer
- * @param {?} templateRef
- * @param {?} ngSwitch
- */
- function NgSwitchDefault(viewContainer, templateRef, ngSwitch) {
- ngSwitch._addDefault(new SwitchView(viewContainer, templateRef));
- }
- return NgSwitchDefault;
- }());
- NgSwitchDefault.decorators = [
- { type: Directive, args: [{ selector: '[ngSwitchDefault]' },] },
- ];
- /**
- * @nocollapse
- */
- NgSwitchDefault.ctorParameters = function () { return [
- { type: ViewContainerRef, },
- { type: TemplateRef, },
- { type: NgSwitch, decorators: [{ type: Host },] },
- ]; };
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * \@ngModule CommonModule
- *
- * \@whatItDoes Adds / removes DOM sub-trees based on a numeric value. Tailored for pluralization.
- *
- * \@howToUse
- * ```
- * <some-element [ngPlural]="value">
- * <ng-template ngPluralCase="=0">there is nothing</ng-template>
- * <ng-template ngPluralCase="=1">there is one</ng-template>
- * <ng-template ngPluralCase="few">there are a few</ng-template>
- * </some-element>
- * ```
- *
- * \@description
- *
- * Displays DOM sub-trees that match the switch expression value, or failing that, DOM sub-trees
- * that match the switch expression's pluralization category.
- *
- * To use this directive you must provide a container element that sets the `[ngPlural]` attribute
- * to a switch expression. Inner elements with a `[ngPluralCase]` will display based on their
- * expression:
- * - if `[ngPluralCase]` is set to a value starting with `=`, it will only display if the value
- * matches the switch expression exactly,
- * - otherwise, the view will be treated as a "category match", and will only display if exact
- * value matches aren't found and the value maps to its category for the defined locale.
- *
- * See http://cldr.unicode.org/index/cldr-spec/plural-rules
- *
- * \@experimental
- */
- var NgPlural = (function () {
- /**
- * @param {?} _localization
- */
- function NgPlural(_localization) {
- this._localization = _localization;
- this._caseViews = {};
- }
- Object.defineProperty(NgPlural.prototype, "ngPlural", {
- /**
- * @param {?} value
- * @return {?}
- */
- set: function (value) {
- this._switchValue = value;
- this._updateView();
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @param {?} value
- * @param {?} switchView
- * @return {?}
- */
- NgPlural.prototype.addCase = function (value, switchView) { this._caseViews[value] = switchView; };
- /**
- * @return {?}
- */
- NgPlural.prototype._updateView = function () {
- this._clearViews();
- var /** @type {?} */ cases = Object.keys(this._caseViews);
- var /** @type {?} */ key = getPluralCategory(this._switchValue, cases, this._localization);
- this._activateView(this._caseViews[key]);
- };
- /**
- * @return {?}
- */
- NgPlural.prototype._clearViews = function () {
- if (this._activeView)
- this._activeView.destroy();
- };
- /**
- * @param {?} view
- * @return {?}
- */
- NgPlural.prototype._activateView = function (view) {
- if (view) {
- this._activeView = view;
- this._activeView.create();
- }
- };
- return NgPlural;
- }());
- NgPlural.decorators = [
- { type: Directive, args: [{ selector: '[ngPlural]' },] },
- ];
- /**
- * @nocollapse
- */
- NgPlural.ctorParameters = function () { return [
- { type: NgLocalization, },
- ]; };
- NgPlural.propDecorators = {
- 'ngPlural': [{ type: Input },],
- };
- /**
- * \@ngModule CommonModule
- *
- * \@whatItDoes Creates a view that will be added/removed from the parent {\@link NgPlural} when the
- * given expression matches the plural expression according to CLDR rules.
- *
- * \@howToUse
- * ```
- * <some-element [ngPlural]="value">
- * <ng-template ngPluralCase="=0">...</ng-template>
- * <ng-template ngPluralCase="other">...</ng-template>
- * </some-element>
- * ```
- *
- * See {\@link NgPlural} for more details and example.
- *
- * \@experimental
- */
- var NgPluralCase = (function () {
- /**
- * @param {?} value
- * @param {?} template
- * @param {?} viewContainer
- * @param {?} ngPlural
- */
- function NgPluralCase(value, template, viewContainer, ngPlural) {
- this.value = value;
- var isANumber = !isNaN(Number(value));
- ngPlural.addCase(isANumber ? "=" + value : value, new SwitchView(viewContainer, template));
- }
- return NgPluralCase;
- }());
- NgPluralCase.decorators = [
- { type: Directive, args: [{ selector: '[ngPluralCase]' },] },
- ];
- /**
- * @nocollapse
- */
- NgPluralCase.ctorParameters = function () { return [
- { type: undefined, decorators: [{ type: Attribute, args: ['ngPluralCase',] },] },
- { type: TemplateRef, },
- { type: ViewContainerRef, },
- { type: NgPlural, decorators: [{ type: Host },] },
- ]; };
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * \@ngModule CommonModule
- *
- * \@whatItDoes Update an HTML element styles.
- *
- * \@howToUse
- * ```
- * <some-element [ngStyle]="{'font-style': styleExp}">...</some-element>
- *
- * <some-element [ngStyle]="{'max-width.px': widthExp}">...</some-element>
- *
- * <some-element [ngStyle]="objExp">...</some-element>
- * ```
- *
- * \@description
- *
- * The styles are updated according to the value of the expression evaluation:
- * - keys are style names with an optional `.<unit>` suffix (ie 'top.px', 'font-style.em'),
- * - values are the values assigned to those properties (expressed in the given unit).
- *
- * \@stable
- */
- var NgStyle = (function () {
- /**
- * @param {?} _differs
- * @param {?} _ngEl
- * @param {?} _renderer
- */
- function NgStyle(_differs, _ngEl, _renderer) {
- this._differs = _differs;
- this._ngEl = _ngEl;
- this._renderer = _renderer;
- }
- Object.defineProperty(NgStyle.prototype, "ngStyle", {
- /**
- * @param {?} v
- * @return {?}
- */
- set: function (v) {
- this._ngStyle = v;
- if (!this._differ && v) {
- this._differ = this._differs.find(v).create();
- }
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @return {?}
- */
- NgStyle.prototype.ngDoCheck = function () {
- if (this._differ) {
- var /** @type {?} */ changes = this._differ.diff(this._ngStyle);
- if (changes) {
- this._applyChanges(changes);
- }
- }
- };
- /**
- * @param {?} changes
- * @return {?}
- */
- NgStyle.prototype._applyChanges = function (changes) {
- var _this = this;
- changes.forEachRemovedItem(function (record) { return _this._setStyle(record.key, null); });
- changes.forEachAddedItem(function (record) { return _this._setStyle(record.key, record.currentValue); });
- changes.forEachChangedItem(function (record) { return _this._setStyle(record.key, record.currentValue); });
- };
- /**
- * @param {?} nameAndUnit
- * @param {?} value
- * @return {?}
- */
- NgStyle.prototype._setStyle = function (nameAndUnit, value) {
- var _a = nameAndUnit.split('.'), name = _a[0], unit = _a[1];
- value = value != null && unit ? "" + value + unit : value;
- this._renderer.setElementStyle(this._ngEl.nativeElement, name, /** @type {?} */ (value));
- };
- return NgStyle;
- }());
- NgStyle.decorators = [
- { type: Directive, args: [{ selector: '[ngStyle]' },] },
- ];
- /**
- * @nocollapse
- */
- NgStyle.ctorParameters = function () { return [
- { type: KeyValueDiffers, },
- { type: ElementRef, },
- { type: Renderer, },
- ]; };
- NgStyle.propDecorators = {
- 'ngStyle': [{ type: Input },],
- };
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * \@ngModule CommonModule
- *
- * \@whatItDoes Inserts an embedded view from a prepared `TemplateRef`
- *
- * \@howToUse
- * ```
- * <ng-container *ngTemplateOutlet="templateRefExp; context: contextExp"></ng-container>
- * ```
- *
- * \@description
- *
- * You can attach a context object to the `EmbeddedViewRef` by setting `[ngTemplateOutletContext]`.
- * `[ngTemplateOutletContext]` should be an object, the object's keys will be available for binding
- * by the local template `let` declarations.
- *
- * Note: using the key `$implicit` in the context object will set it's value as default.
- *
- * ## Example
- *
- * {\@example common/ngTemplateOutlet/ts/module.ts region='NgTemplateOutlet'}
- *
- * \@experimental
- */
- var NgTemplateOutlet = (function () {
- /**
- * @param {?} _viewContainerRef
- */
- function NgTemplateOutlet(_viewContainerRef) {
- this._viewContainerRef = _viewContainerRef;
- }
- Object.defineProperty(NgTemplateOutlet.prototype, "ngOutletContext", {
- /**
- * @deprecated v4.0.0 - Renamed to ngTemplateOutletContext.
- * @param {?} context
- * @return {?}
- */
- set: function (context) { this.ngTemplateOutletContext = context; },
- enumerable: true,
- configurable: true
- });
- /**
- * @param {?} changes
- * @return {?}
- */
- NgTemplateOutlet.prototype.ngOnChanges = function (changes) {
- if (this._viewRef) {
- this._viewContainerRef.remove(this._viewContainerRef.indexOf(this._viewRef));
- }
- if (this.ngTemplateOutlet) {
- this._viewRef = this._viewContainerRef.createEmbeddedView(this.ngTemplateOutlet, this.ngTemplateOutletContext);
- }
- };
- return NgTemplateOutlet;
- }());
- NgTemplateOutlet.decorators = [
- { type: Directive, args: [{ selector: '[ngTemplateOutlet]' },] },
- ];
- /**
- * @nocollapse
- */
- NgTemplateOutlet.ctorParameters = function () { return [
- { type: ViewContainerRef, },
- ]; };
- NgTemplateOutlet.propDecorators = {
- 'ngTemplateOutletContext': [{ type: Input },],
- 'ngTemplateOutlet': [{ type: Input },],
- 'ngOutletContext': [{ type: Input },],
- };
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * A collection of Angular directives that are likely to be used in each and every Angular
- * application.
- */
- var COMMON_DIRECTIVES = [
- NgClass,
- NgComponentOutlet,
- NgForOf,
- NgIf,
- NgTemplateOutlet,
- NgStyle,
- NgSwitch,
- NgSwitchCase,
- NgSwitchDefault,
- NgPlural,
- NgPluralCase,
- ];
- /**
- * A collection of deprecated directives that are no longer part of the core module.
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * @param {?} type
- * @param {?} value
- * @return {?}
- */
- function invalidPipeArgumentError(type, value) {
- return Error("InvalidPipeArgument: '" + value + "' for pipe '" + stringify(type) + "'");
- }
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var ObservableStrategy = (function () {
- function ObservableStrategy() {
- }
- /**
- * @param {?} async
- * @param {?} updateLatestValue
- * @return {?}
- */
- ObservableStrategy.prototype.createSubscription = function (async, updateLatestValue) {
- return async.subscribe({ next: updateLatestValue, error: function (e) { throw e; } });
- };
- /**
- * @param {?} subscription
- * @return {?}
- */
- ObservableStrategy.prototype.dispose = function (subscription) { subscription.unsubscribe(); };
- /**
- * @param {?} subscription
- * @return {?}
- */
- ObservableStrategy.prototype.onDestroy = function (subscription) { subscription.unsubscribe(); };
- return ObservableStrategy;
- }());
- var PromiseStrategy = (function () {
- function PromiseStrategy() {
- }
- /**
- * @param {?} async
- * @param {?} updateLatestValue
- * @return {?}
- */
- PromiseStrategy.prototype.createSubscription = function (async, updateLatestValue) {
- return async.then(updateLatestValue, function (e) { throw e; });
- };
- /**
- * @param {?} subscription
- * @return {?}
- */
- PromiseStrategy.prototype.dispose = function (subscription) { };
- /**
- * @param {?} subscription
- * @return {?}
- */
- PromiseStrategy.prototype.onDestroy = function (subscription) { };
- return PromiseStrategy;
- }());
- var _promiseStrategy = new PromiseStrategy();
- var _observableStrategy = new ObservableStrategy();
- /**
- * \@ngModule CommonModule
- * \@whatItDoes Unwraps a value from an asynchronous primitive.
- * \@howToUse `observable_or_promise_expression | async`
- * \@description
- * The `async` pipe subscribes to an `Observable` or `Promise` and returns the latest value it has
- * emitted. When a new value is emitted, the `async` pipe marks the component to be checked for
- * changes. When the component gets destroyed, the `async` pipe unsubscribes automatically to avoid
- * potential memory leaks.
- *
- *
- * ## Examples
- *
- * This example binds a `Promise` to the view. Clicking the `Resolve` button resolves the
- * promise.
- *
- * {\@example common/pipes/ts/async_pipe.ts region='AsyncPipePromise'}
- *
- * It's also possible to use `async` with Observables. The example below binds the `time` Observable
- * to the view. The Observable continuously updates the view with the current time.
- *
- * {\@example common/pipes/ts/async_pipe.ts region='AsyncPipeObservable'}
- *
- * \@stable
- */
- var AsyncPipe = (function () {
- /**
- * @param {?} _ref
- */
- function AsyncPipe(_ref) {
- this._ref = _ref;
- this._latestValue = null;
- this._latestReturnedValue = null;
- this._subscription = null;
- this._obj = null;
- this._strategy = ((null));
- }
- /**
- * @return {?}
- */
- AsyncPipe.prototype.ngOnDestroy = function () {
- if (this._subscription) {
- this._dispose();
- }
- };
- /**
- * @param {?} obj
- * @return {?}
- */
- AsyncPipe.prototype.transform = function (obj) {
- if (!this._obj) {
- if (obj) {
- this._subscribe(obj);
- }
- this._latestReturnedValue = this._latestValue;
- return this._latestValue;
- }
- if (obj !== this._obj) {
- this._dispose();
- return this.transform(/** @type {?} */ (obj));
- }
- if (this._latestValue === this._latestReturnedValue) {
- return this._latestReturnedValue;
- }
- this._latestReturnedValue = this._latestValue;
- return WrappedValue.wrap(this._latestValue);
- };
- /**
- * @param {?} obj
- * @return {?}
- */
- AsyncPipe.prototype._subscribe = function (obj) {
- var _this = this;
- this._obj = obj;
- this._strategy = this._selectStrategy(obj);
- this._subscription = this._strategy.createSubscription(obj, function (value) { return _this._updateLatestValue(obj, value); });
- };
- /**
- * @param {?} obj
- * @return {?}
- */
- AsyncPipe.prototype._selectStrategy = function (obj) {
- if (isPromise(obj)) {
- return _promiseStrategy;
- }
- if (isObservable(obj)) {
- return _observableStrategy;
- }
- throw invalidPipeArgumentError(AsyncPipe, obj);
- };
- /**
- * @return {?}
- */
- AsyncPipe.prototype._dispose = function () {
- this._strategy.dispose(/** @type {?} */ ((this._subscription)));
- this._latestValue = null;
- this._latestReturnedValue = null;
- this._subscription = null;
- this._obj = null;
- };
- /**
- * @param {?} async
- * @param {?} value
- * @return {?}
- */
- AsyncPipe.prototype._updateLatestValue = function (async, value) {
- if (async === this._obj) {
- this._latestValue = value;
- this._ref.markForCheck();
- }
- };
- return AsyncPipe;
- }());
- AsyncPipe.decorators = [
- { type: Pipe, args: [{ name: 'async', pure: false },] },
- ];
- /**
- * @nocollapse
- */
- AsyncPipe.ctorParameters = function () { return [
- { type: ChangeDetectorRef, },
- ]; };
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * Transforms text to lowercase.
- *
- * {\@example common/pipes/ts/lowerupper_pipe.ts region='LowerUpperPipe' }
- *
- * \@stable
- */
- var LowerCasePipe = (function () {
- function LowerCasePipe() {
- }
- /**
- * @param {?} value
- * @return {?}
- */
- LowerCasePipe.prototype.transform = function (value) {
- if (!value)
- return value;
- if (typeof value !== 'string') {
- throw invalidPipeArgumentError(LowerCasePipe, value);
- }
- return value.toLowerCase();
- };
- return LowerCasePipe;
- }());
- LowerCasePipe.decorators = [
- { type: Pipe, args: [{ name: 'lowercase' },] },
- ];
- /**
- * @nocollapse
- */
- LowerCasePipe.ctorParameters = function () { return []; };
- /**
- * Helper method to transform a single word to titlecase.
- *
- * \@stable
- * @param {?} word
- * @return {?}
- */
- function titleCaseWord(word) {
- if (!word)
- return word;
- return word[0].toUpperCase() + word.substr(1).toLowerCase();
- }
- /**
- * Transforms text to titlecase.
- *
- * \@stable
- */
- var TitleCasePipe = (function () {
- function TitleCasePipe() {
- }
- /**
- * @param {?} value
- * @return {?}
- */
- TitleCasePipe.prototype.transform = function (value) {
- if (!value)
- return value;
- if (typeof value !== 'string') {
- throw invalidPipeArgumentError(TitleCasePipe, value);
- }
- return value.split(/\b/g).map(function (word) { return titleCaseWord(word); }).join('');
- };
- return TitleCasePipe;
- }());
- TitleCasePipe.decorators = [
- { type: Pipe, args: [{ name: 'titlecase' },] },
- ];
- /**
- * @nocollapse
- */
- TitleCasePipe.ctorParameters = function () { return []; };
- /**
- * Transforms text to uppercase.
- *
- * \@stable
- */
- var UpperCasePipe = (function () {
- function UpperCasePipe() {
- }
- /**
- * @param {?} value
- * @return {?}
- */
- UpperCasePipe.prototype.transform = function (value) {
- if (!value)
- return value;
- if (typeof value !== 'string') {
- throw invalidPipeArgumentError(UpperCasePipe, value);
- }
- return value.toUpperCase();
- };
- return UpperCasePipe;
- }());
- UpperCasePipe.decorators = [
- { type: Pipe, args: [{ name: 'uppercase' },] },
- ];
- /**
- * @nocollapse
- */
- UpperCasePipe.ctorParameters = function () { return []; };
- var NumberFormatStyle = {};
- NumberFormatStyle.Decimal = 0;
- NumberFormatStyle.Percent = 1;
- NumberFormatStyle.Currency = 2;
- NumberFormatStyle[NumberFormatStyle.Decimal] = "Decimal";
- NumberFormatStyle[NumberFormatStyle.Percent] = "Percent";
- NumberFormatStyle[NumberFormatStyle.Currency] = "Currency";
- var NumberFormatter = (function () {
- function NumberFormatter() {
- }
- /**
- * @param {?} num
- * @param {?} locale
- * @param {?} style
- * @param {?=} opts
- * @return {?}
- */
- NumberFormatter.format = function (num, locale, style$$1, opts) {
- if (opts === void 0) { opts = {}; }
- var minimumIntegerDigits = opts.minimumIntegerDigits, minimumFractionDigits = opts.minimumFractionDigits, maximumFractionDigits = opts.maximumFractionDigits, currency = opts.currency, _a = opts.currencyAsSymbol, currencyAsSymbol = _a === void 0 ? false : _a;
- var /** @type {?} */ options = {
- minimumIntegerDigits: minimumIntegerDigits,
- minimumFractionDigits: minimumFractionDigits,
- maximumFractionDigits: maximumFractionDigits,
- style: NumberFormatStyle[style$$1].toLowerCase()
- };
- if (style$$1 == NumberFormatStyle.Currency) {
- options.currency = typeof currency == 'string' ? currency : undefined;
- options.currencyDisplay = currencyAsSymbol ? 'symbol' : 'code';
- }
- return new Intl.NumberFormat(locale, options).format(num);
- };
- return NumberFormatter;
- }());
- var DATE_FORMATS_SPLIT = /((?:[^yMLdHhmsazZEwGjJ']+)|(?:'(?:[^']|'')*')|(?:E+|y+|M+|L+|d+|H+|h+|J+|j+|m+|s+|a|z|Z|G+|w+))(.*)/;
- var PATTERN_ALIASES = {
- // Keys are quoted so they do not get renamed during closure compilation.
- 'yMMMdjms': datePartGetterFactory(combine([
- digitCondition('year', 1),
- nameCondition('month', 3),
- digitCondition('day', 1),
- digitCondition('hour', 1),
- digitCondition('minute', 1),
- digitCondition('second', 1),
- ])),
- 'yMdjm': datePartGetterFactory(combine([
- digitCondition('year', 1), digitCondition('month', 1), digitCondition('day', 1),
- digitCondition('hour', 1), digitCondition('minute', 1)
- ])),
- 'yMMMMEEEEd': datePartGetterFactory(combine([
- digitCondition('year', 1), nameCondition('month', 4), nameCondition('weekday', 4),
- digitCondition('day', 1)
- ])),
- 'yMMMMd': datePartGetterFactory(combine([digitCondition('year', 1), nameCondition('month', 4), digitCondition('day', 1)])),
- 'yMMMd': datePartGetterFactory(combine([digitCondition('year', 1), nameCondition('month', 3), digitCondition('day', 1)])),
- 'yMd': datePartGetterFactory(combine([digitCondition('year', 1), digitCondition('month', 1), digitCondition('day', 1)])),
- 'jms': datePartGetterFactory(combine([digitCondition('hour', 1), digitCondition('second', 1), digitCondition('minute', 1)])),
- 'jm': datePartGetterFactory(combine([digitCondition('hour', 1), digitCondition('minute', 1)]))
- };
- var DATE_FORMATS = {
- // Keys are quoted so they do not get renamed.
- 'yyyy': datePartGetterFactory(digitCondition('year', 4)),
- 'yy': datePartGetterFactory(digitCondition('year', 2)),
- 'y': datePartGetterFactory(digitCondition('year', 1)),
- 'MMMM': datePartGetterFactory(nameCondition('month', 4)),
- 'MMM': datePartGetterFactory(nameCondition('month', 3)),
- 'MM': datePartGetterFactory(digitCondition('month', 2)),
- 'M': datePartGetterFactory(digitCondition('month', 1)),
- 'LLLL': datePartGetterFactory(nameCondition('month', 4)),
- 'L': datePartGetterFactory(nameCondition('month', 1)),
- 'dd': datePartGetterFactory(digitCondition('day', 2)),
- 'd': datePartGetterFactory(digitCondition('day', 1)),
- 'HH': digitModifier(hourExtractor(datePartGetterFactory(hour12Modify(digitCondition('hour', 2), false)))),
- 'H': hourExtractor(datePartGetterFactory(hour12Modify(digitCondition('hour', 1), false))),
- 'hh': digitModifier(hourExtractor(datePartGetterFactory(hour12Modify(digitCondition('hour', 2), true)))),
- 'h': hourExtractor(datePartGetterFactory(hour12Modify(digitCondition('hour', 1), true))),
- 'jj': datePartGetterFactory(digitCondition('hour', 2)),
- 'j': datePartGetterFactory(digitCondition('hour', 1)),
- 'mm': digitModifier(datePartGetterFactory(digitCondition('minute', 2))),
- 'm': datePartGetterFactory(digitCondition('minute', 1)),
- 'ss': digitModifier(datePartGetterFactory(digitCondition('second', 2))),
- 's': datePartGetterFactory(digitCondition('second', 1)),
- // while ISO 8601 requires fractions to be prefixed with `.` or `,`
- // we can be just safely rely on using `sss` since we currently don't support single or two digit
- // fractions
- 'sss': datePartGetterFactory(digitCondition('second', 3)),
- 'EEEE': datePartGetterFactory(nameCondition('weekday', 4)),
- 'EEE': datePartGetterFactory(nameCondition('weekday', 3)),
- 'EE': datePartGetterFactory(nameCondition('weekday', 2)),
- 'E': datePartGetterFactory(nameCondition('weekday', 1)),
- 'a': hourClockExtractor(datePartGetterFactory(hour12Modify(digitCondition('hour', 1), true))),
- 'Z': timeZoneGetter('short'),
- 'z': timeZoneGetter('long'),
- 'ww': datePartGetterFactory({}),
- // first Thursday of the year. not support ?
- 'w': datePartGetterFactory({}),
- // of the year not support ?
- 'G': datePartGetterFactory(nameCondition('era', 1)),
- 'GG': datePartGetterFactory(nameCondition('era', 2)),
- 'GGG': datePartGetterFactory(nameCondition('era', 3)),
- 'GGGG': datePartGetterFactory(nameCondition('era', 4))
- };
- /**
- * @param {?} inner
- * @return {?}
- */
- function digitModifier(inner) {
- return function (date, locale) {
- var /** @type {?} */ result = inner(date, locale);
- return result.length == 1 ? '0' + result : result;
- };
- }
- /**
- * @param {?} inner
- * @return {?}
- */
- function hourClockExtractor(inner) {
- return function (date, locale) { return inner(date, locale).split(' ')[1]; };
- }
- /**
- * @param {?} inner
- * @return {?}
- */
- function hourExtractor(inner) {
- return function (date, locale) { return inner(date, locale).split(' ')[0]; };
- }
- /**
- * @param {?} date
- * @param {?} locale
- * @param {?} options
- * @return {?}
- */
- function intlDateFormat(date, locale, options) {
- return new Intl.DateTimeFormat(locale, options).format(date).replace(/[\u200e\u200f]/g, '');
- }
- /**
- * @param {?} timezone
- * @return {?}
- */
- function timeZoneGetter(timezone) {
- // To workaround `Intl` API restriction for single timezone let format with 24 hours
- var /** @type {?} */ options = { hour: '2-digit', hour12: false, timeZoneName: timezone };
- return function (date, locale) {
- var /** @type {?} */ result = intlDateFormat(date, locale, options);
- // Then extract first 3 letters that related to hours
- return result ? result.substring(3) : '';
- };
- }
- /**
- * @param {?} options
- * @param {?} value
- * @return {?}
- */
- function hour12Modify(options, value) {
- options.hour12 = value;
- return options;
- }
- /**
- * @param {?} prop
- * @param {?} len
- * @return {?}
- */
- function digitCondition(prop, len) {
- var /** @type {?} */ result = {};
- result[prop] = len === 2 ? '2-digit' : 'numeric';
- return result;
- }
- /**
- * @param {?} prop
- * @param {?} len
- * @return {?}
- */
- function nameCondition(prop, len) {
- var /** @type {?} */ result = {};
- if (len < 4) {
- result[prop] = len > 1 ? 'short' : 'narrow';
- }
- else {
- result[prop] = 'long';
- }
- return result;
- }
- /**
- * @param {?} options
- * @return {?}
- */
- function combine(options) {
- return options.reduce(function (merged, opt) { return (Object.assign({}, merged, opt)); }, {});
- }
- /**
- * @param {?} ret
- * @return {?}
- */
- function datePartGetterFactory(ret) {
- return function (date, locale) { return intlDateFormat(date, locale, ret); };
- }
- var DATE_FORMATTER_CACHE = new Map();
- /**
- * @param {?} format
- * @param {?} date
- * @param {?} locale
- * @return {?}
- */
- function dateFormatter(format, date, locale) {
- var /** @type {?} */ fn = PATTERN_ALIASES[format];
- if (fn)
- return fn(date, locale);
- var /** @type {?} */ cacheKey = format;
- var /** @type {?} */ parts = DATE_FORMATTER_CACHE.get(cacheKey);
- if (!parts) {
- parts = [];
- var /** @type {?} */ match = void 0;
- DATE_FORMATS_SPLIT.exec(format);
- var /** @type {?} */ _format = format;
- while (_format) {
- match = DATE_FORMATS_SPLIT.exec(_format);
- if (match) {
- parts = parts.concat(match.slice(1));
- _format = ((parts.pop()));
- }
- else {
- parts.push(_format);
- _format = null;
- }
- }
- DATE_FORMATTER_CACHE.set(cacheKey, parts);
- }
- return parts.reduce(function (text, part) {
- var /** @type {?} */ fn = DATE_FORMATS[part];
- return text + (fn ? fn(date, locale) : partToTime(part));
- }, '');
- }
- /**
- * @param {?} part
- * @return {?}
- */
- function partToTime(part) {
- return part === '\'\'' ? '\'' : part.replace(/(^'|'$)/g, '').replace(/''/g, '\'');
- }
- var DateFormatter = (function () {
- function DateFormatter() {
- }
- /**
- * @param {?} date
- * @param {?} locale
- * @param {?} pattern
- * @return {?}
- */
- DateFormatter.format = function (date, locale, pattern) {
- return dateFormatter(pattern, date, locale);
- };
- return DateFormatter;
- }());
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var _NUMBER_FORMAT_REGEXP = /^(\d+)?\.((\d+)(-(\d+))?)?$/;
- /**
- * @param {?} pipe
- * @param {?} locale
- * @param {?} value
- * @param {?} style
- * @param {?=} digits
- * @param {?=} currency
- * @param {?=} currencyAsSymbol
- * @return {?}
- */
- function formatNumber(pipe, locale, value, style$$1, digits, currency, currencyAsSymbol) {
- if (currency === void 0) { currency = null; }
- if (currencyAsSymbol === void 0) { currencyAsSymbol = false; }
- if (value == null)
- return null;
- // Convert strings to numbers
- value = typeof value === 'string' && isNumeric(value) ? +value : value;
- if (typeof value !== 'number') {
- throw invalidPipeArgumentError(pipe, value);
- }
- var /** @type {?} */ minInt = undefined;
- var /** @type {?} */ minFraction = undefined;
- var /** @type {?} */ maxFraction = undefined;
- if (style$$1 !== NumberFormatStyle.Currency) {
- // rely on Intl default for currency
- minInt = 1;
- minFraction = 0;
- maxFraction = 3;
- }
- if (digits) {
- var /** @type {?} */ parts = digits.match(_NUMBER_FORMAT_REGEXP);
- if (parts === null) {
- throw new Error(digits + " is not a valid digit info for number pipes");
- }
- if (parts[1] != null) {
- minInt = parseIntAutoRadix(parts[1]);
- }
- if (parts[3] != null) {
- minFraction = parseIntAutoRadix(parts[3]);
- }
- if (parts[5] != null) {
- maxFraction = parseIntAutoRadix(parts[5]);
- }
- }
- return NumberFormatter.format(/** @type {?} */ (value), locale, style$$1, {
- minimumIntegerDigits: minInt,
- minimumFractionDigits: minFraction,
- maximumFractionDigits: maxFraction,
- currency: currency,
- currencyAsSymbol: currencyAsSymbol,
- });
- }
- /**
- * \@ngModule CommonModule
- * \@whatItDoes Formats a number according to locale rules.
- * \@howToUse `number_expression | number[:digitInfo]`
- *
- * Formats a number as text. Group sizing and separator and other locale-specific
- * configurations are based on the active locale.
- *
- * where `expression` is a number:
- * - `digitInfo` is a `string` which has a following format: <br>
- * <code>{minIntegerDigits}.{minFractionDigits}-{maxFractionDigits}</code>
- * - `minIntegerDigits` is the minimum number of integer digits to use. Defaults to `1`.
- * - `minFractionDigits` is the minimum number of digits after fraction. Defaults to `0`.
- * - `maxFractionDigits` is the maximum number of digits after fraction. Defaults to `3`.
- *
- * For more information on the acceptable range for each of these numbers and other
- * details see your native internationalization library.
- *
- * WARNING: this pipe uses the Internationalization API which is not yet available in all browsers
- * and may require a polyfill. See [Browser Support](guide/browser-support) for details.
- *
- * ### Example
- *
- * {\@example common/pipes/ts/number_pipe.ts region='NumberPipe'}
- *
- * \@stable
- */
- var DecimalPipe = (function () {
- /**
- * @param {?} _locale
- */
- function DecimalPipe(_locale) {
- this._locale = _locale;
- }
- /**
- * @param {?} value
- * @param {?=} digits
- * @return {?}
- */
- DecimalPipe.prototype.transform = function (value, digits) {
- return formatNumber(DecimalPipe, this._locale, value, NumberFormatStyle.Decimal, digits);
- };
- return DecimalPipe;
- }());
- DecimalPipe.decorators = [
- { type: Pipe, args: [{ name: 'number' },] },
- ];
- /**
- * @nocollapse
- */
- DecimalPipe.ctorParameters = function () { return [
- { type: undefined, decorators: [{ type: Inject, args: [LOCALE_ID,] },] },
- ]; };
- /**
- * \@ngModule CommonModule
- * \@whatItDoes Formats a number as a percentage according to locale rules.
- * \@howToUse `number_expression | percent[:digitInfo]`
- *
- * \@description
- *
- * Formats a number as percentage.
- *
- * - `digitInfo` See {\@link DecimalPipe} for detailed description.
- *
- * WARNING: this pipe uses the Internationalization API which is not yet available in all browsers
- * and may require a polyfill. See [Browser Support](guide/browser-support) for details.
- *
- * ### Example
- *
- * {\@example common/pipes/ts/number_pipe.ts region='PercentPipe'}
- *
- * \@stable
- */
- var PercentPipe = (function () {
- /**
- * @param {?} _locale
- */
- function PercentPipe(_locale) {
- this._locale = _locale;
- }
- /**
- * @param {?} value
- * @param {?=} digits
- * @return {?}
- */
- PercentPipe.prototype.transform = function (value, digits) {
- return formatNumber(PercentPipe, this._locale, value, NumberFormatStyle.Percent, digits);
- };
- return PercentPipe;
- }());
- PercentPipe.decorators = [
- { type: Pipe, args: [{ name: 'percent' },] },
- ];
- /**
- * @nocollapse
- */
- PercentPipe.ctorParameters = function () { return [
- { type: undefined, decorators: [{ type: Inject, args: [LOCALE_ID,] },] },
- ]; };
- /**
- * \@ngModule CommonModule
- * \@whatItDoes Formats a number as currency using locale rules.
- * \@howToUse `number_expression | currency[:currencyCode[:symbolDisplay[:digitInfo]]]`
- * \@description
- *
- * Use `currency` to format a number as currency.
- *
- * - `currencyCode` is the [ISO 4217](https://en.wikipedia.org/wiki/ISO_4217) currency code, such
- * as `USD` for the US dollar and `EUR` for the euro.
- * - `symbolDisplay` is a boolean indicating whether to use the currency symbol or code.
- * - `true`: use symbol (e.g. `$`).
- * - `false`(default): use code (e.g. `USD`).
- * - `digitInfo` See {\@link DecimalPipe} for detailed description.
- *
- * WARNING: this pipe uses the Internationalization API which is not yet available in all browsers
- * and may require a polyfill. See [Browser Support](guide/browser-support) for details.
- *
- * ### Example
- *
- * {\@example common/pipes/ts/number_pipe.ts region='CurrencyPipe'}
- *
- * \@stable
- */
- var CurrencyPipe = (function () {
- /**
- * @param {?} _locale
- */
- function CurrencyPipe(_locale) {
- this._locale = _locale;
- }
- /**
- * @param {?} value
- * @param {?=} currencyCode
- * @param {?=} symbolDisplay
- * @param {?=} digits
- * @return {?}
- */
- CurrencyPipe.prototype.transform = function (value, currencyCode, symbolDisplay, digits) {
- if (currencyCode === void 0) { currencyCode = 'USD'; }
- if (symbolDisplay === void 0) { symbolDisplay = false; }
- return formatNumber(CurrencyPipe, this._locale, value, NumberFormatStyle.Currency, digits, currencyCode, symbolDisplay);
- };
- return CurrencyPipe;
- }());
- CurrencyPipe.decorators = [
- { type: Pipe, args: [{ name: 'currency' },] },
- ];
- /**
- * @nocollapse
- */
- CurrencyPipe.ctorParameters = function () { return [
- { type: undefined, decorators: [{ type: Inject, args: [LOCALE_ID,] },] },
- ]; };
- /**
- * @param {?} text
- * @return {?}
- */
- function parseIntAutoRadix(text) {
- var /** @type {?} */ result = parseInt(text);
- if (isNaN(result)) {
- throw new Error('Invalid integer literal when parsing ' + text);
- }
- return result;
- }
- /**
- * @param {?} value
- * @return {?}
- */
- function isNumeric(value) {
- return !isNaN(value - parseFloat(value));
- }
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var ISO8601_DATE_REGEX = /^(\d{4})-?(\d\d)-?(\d\d)(?:T(\d\d)(?::?(\d\d)(?::?(\d\d)(?:\.(\d+))?)?)?(Z|([+-])(\d\d):?(\d\d))?)?$/;
- /**
- * \@ngModule CommonModule
- * \@whatItDoes Formats a date according to locale rules.
- * \@howToUse `date_expression | date[:format]`
- * \@description
- *
- * Where:
- * - `expression` is a date object or a number (milliseconds since UTC epoch) or an ISO string
- * (https://www.w3.org/TR/NOTE-datetime).
- * - `format` indicates which date/time components to include. The format can be predefined as
- * shown below or custom as shown in the table.
- * - `'medium'`: equivalent to `'yMMMdjms'` (e.g. `Sep 3, 2010, 12:05:08 PM` for `en-US`)
- * - `'short'`: equivalent to `'yMdjm'` (e.g. `9/3/2010, 12:05 PM` for `en-US`)
- * - `'fullDate'`: equivalent to `'yMMMMEEEEd'` (e.g. `Friday, September 3, 2010` for `en-US`)
- * - `'longDate'`: equivalent to `'yMMMMd'` (e.g. `September 3, 2010` for `en-US`)
- * - `'mediumDate'`: equivalent to `'yMMMd'` (e.g. `Sep 3, 2010` for `en-US`)
- * - `'shortDate'`: equivalent to `'yMd'` (e.g. `9/3/2010` for `en-US`)
- * - `'mediumTime'`: equivalent to `'jms'` (e.g. `12:05:08 PM` for `en-US`)
- * - `'shortTime'`: equivalent to `'jm'` (e.g. `12:05 PM` for `en-US`)
- *
- *
- * | Component | Symbol | Narrow | Short Form | Long Form | Numeric | 2-digit |
- * |-----------|:------:|--------|--------------|-------------------|-----------|-----------|
- * | era | G | G (A) | GGG (AD) | GGGG (Anno Domini)| - | - |
- * | year | y | - | - | - | y (2015) | yy (15) |
- * | month | M | L (S) | MMM (Sep) | MMMM (September) | M (9) | MM (09) |
- * | day | d | - | - | - | d (3) | dd (03) |
- * | weekday | E | E (S) | EEE (Sun) | EEEE (Sunday) | - | - |
- * | hour | j | - | - | - | j (1 PM) | jj (1 PM) |
- * | hour12 | h | - | - | - | h (1) | hh (01) |
- * | hour24 | H | - | - | - | H (13) | HH (13) |
- * | minute | m | - | - | - | m (5) | mm (05) |
- * | second | s | - | - | - | s (9) | ss (09) |
- * | timezone | z | - | - | z (Pacific Standard Time)| - | - |
- * | timezone | Z | - | Z (GMT-8:00) | - | - | - |
- * | timezone | a | - | a (PM) | - | - | - |
- *
- * In javascript, only the components specified will be respected (not the ordering,
- * punctuations, ...) and details of the formatting will be dependent on the locale.
- *
- * Timezone of the formatted text will be the local system timezone of the end-user's machine.
- *
- * When the expression is a ISO string without time (e.g. 2016-09-19) the time zone offset is not
- * applied and the formatted text will have the same day, month and year of the expression.
- *
- * WARNINGS:
- * - this pipe is marked as pure hence it will not be re-evaluated when the input is mutated.
- * Instead users should treat the date as an immutable object and change the reference when the
- * pipe needs to re-run (this is to avoid reformatting the date on every change detection run
- * which would be an expensive operation).
- * - this pipe uses the Internationalization API. Therefore it is only reliable in Chrome and Opera
- * browsers.
- *
- * ### Examples
- *
- * Assuming `dateObj` is (year: 2015, month: 6, day: 15, hour: 21, minute: 43, second: 11)
- * in the _local_ time and locale is 'en-US':
- *
- * ```
- * {{ dateObj | date }} // output is 'Jun 15, 2015'
- * {{ dateObj | date:'medium' }} // output is 'Jun 15, 2015, 9:43:11 PM'
- * {{ dateObj | date:'shortTime' }} // output is '9:43 PM'
- * {{ dateObj | date:'mmss' }} // output is '43:11'
- * ```
- *
- * {\@example common/pipes/ts/date_pipe.ts region='DatePipe'}
- *
- * \@stable
- */
- var DatePipe = (function () {
- /**
- * @param {?} _locale
- */
- function DatePipe(_locale) {
- this._locale = _locale;
- }
- /**
- * @param {?} value
- * @param {?=} pattern
- * @return {?}
- */
- DatePipe.prototype.transform = function (value, pattern) {
- if (pattern === void 0) { pattern = 'mediumDate'; }
- var /** @type {?} */ date;
- if (isBlank(value) || value !== value)
- return null;
- if (typeof value === 'string') {
- value = value.trim();
- }
- if (isDate(value)) {
- date = value;
- }
- else if (isNumeric(value)) {
- date = new Date(parseFloat(value));
- }
- else if (typeof value === 'string' && /^(\d{4}-\d{1,2}-\d{1,2})$/.test(value)) {
- /**
- * For ISO Strings without time the day, month and year must be extracted from the ISO String
- * before Date creation to avoid time offset and errors in the new Date.
- * If we only replace '-' with ',' in the ISO String ("2015,01,01"), and try to create a new
- * date, some browsers (e.g. IE 9) will throw an invalid Date error
- * If we leave the '-' ("2015-01-01") and try to create a new Date("2015-01-01") the timeoffset
- * is applied
- * Note: ISO months are 0 for January, 1 for February, ...
- */
- var _a = value.split('-').map(function (val) { return parseInt(val, 10); }), y = _a[0], m = _a[1], d = _a[2];
- date = new Date(y, m - 1, d);
- }
- else {
- date = new Date(value);
- }
- if (!isDate(date)) {
- var /** @type {?} */ match = void 0;
- if ((typeof value === 'string') && (match = value.match(ISO8601_DATE_REGEX))) {
- date = isoStringToDate(match);
- }
- else {
- throw invalidPipeArgumentError(DatePipe, value);
- }
- }
- return DateFormatter.format(date, this._locale, DatePipe._ALIASES[pattern] || pattern);
- };
- return DatePipe;
- }());
- /**
- * \@internal
- */
- DatePipe._ALIASES = {
- 'medium': 'yMMMdjms',
- 'short': 'yMdjm',
- 'fullDate': 'yMMMMEEEEd',
- 'longDate': 'yMMMMd',
- 'mediumDate': 'yMMMd',
- 'shortDate': 'yMd',
- 'mediumTime': 'jms',
- 'shortTime': 'jm'
- };
- DatePipe.decorators = [
- { type: Pipe, args: [{ name: 'date', pure: true },] },
- ];
- /**
- * @nocollapse
- */
- DatePipe.ctorParameters = function () { return [
- { type: undefined, decorators: [{ type: Inject, args: [LOCALE_ID,] },] },
- ]; };
- /**
- * @param {?} obj
- * @return {?}
- */
- function isBlank(obj) {
- return obj == null || obj === '';
- }
- /**
- * @param {?} obj
- * @return {?}
- */
- function isDate(obj) {
- return obj instanceof Date && !isNaN(obj.valueOf());
- }
- /**
- * @param {?} match
- * @return {?}
- */
- function isoStringToDate(match) {
- var /** @type {?} */ date = new Date(0);
- var /** @type {?} */ tzHour = 0;
- var /** @type {?} */ tzMin = 0;
- var /** @type {?} */ dateSetter = match[8] ? date.setUTCFullYear : date.setFullYear;
- var /** @type {?} */ timeSetter = match[8] ? date.setUTCHours : date.setHours;
- if (match[9]) {
- tzHour = toInt(match[9] + match[10]);
- tzMin = toInt(match[9] + match[11]);
- }
- dateSetter.call(date, toInt(match[1]), toInt(match[2]) - 1, toInt(match[3]));
- var /** @type {?} */ h = toInt(match[4] || '0') - tzHour;
- var /** @type {?} */ m = toInt(match[5] || '0') - tzMin;
- var /** @type {?} */ s = toInt(match[6] || '0');
- var /** @type {?} */ ms = Math.round(parseFloat('0.' + (match[7] || 0)) * 1000);
- timeSetter.call(date, h, m, s, ms);
- return date;
- }
- /**
- * @param {?} str
- * @return {?}
- */
- function toInt(str) {
- return parseInt(str, 10);
- }
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var _INTERPOLATION_REGEXP = /#/g;
- /**
- * \@ngModule CommonModule
- * \@whatItDoes Maps a value to a string that pluralizes the value according to locale rules.
- * \@howToUse `expression | i18nPlural:mapping`
- * \@description
- *
- * Where:
- * - `expression` is a number.
- * - `mapping` is an object that mimics the ICU format, see
- * http://userguide.icu-project.org/formatparse/messages
- *
- * ## Example
- *
- * {\@example common/pipes/ts/i18n_pipe.ts region='I18nPluralPipeComponent'}
- *
- * \@experimental
- */
- var I18nPluralPipe = (function () {
- /**
- * @param {?} _localization
- */
- function I18nPluralPipe(_localization) {
- this._localization = _localization;
- }
- /**
- * @param {?} value
- * @param {?} pluralMap
- * @return {?}
- */
- I18nPluralPipe.prototype.transform = function (value, pluralMap) {
- if (value == null)
- return '';
- if (typeof pluralMap !== 'object' || pluralMap === null) {
- throw invalidPipeArgumentError(I18nPluralPipe, pluralMap);
- }
- var /** @type {?} */ key = getPluralCategory(value, Object.keys(pluralMap), this._localization);
- return pluralMap[key].replace(_INTERPOLATION_REGEXP, value.toString());
- };
- return I18nPluralPipe;
- }());
- I18nPluralPipe.decorators = [
- { type: Pipe, args: [{ name: 'i18nPlural', pure: true },] },
- ];
- /**
- * @nocollapse
- */
- I18nPluralPipe.ctorParameters = function () { return [
- { type: NgLocalization, },
- ]; };
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * \@ngModule CommonModule
- * \@whatItDoes Generic selector that displays the string that matches the current value.
- * \@howToUse `expression | i18nSelect:mapping`
- * \@description
- *
- * Where `mapping` is an object that indicates the text that should be displayed
- * for different values of the provided `expression`.
- * If none of the keys of the mapping match the value of the `expression`, then the content
- * of the `other` key is returned when present, otherwise an empty string is returned.
- *
- * ## Example
- *
- * {\@example common/pipes/ts/i18n_pipe.ts region='I18nSelectPipeComponent'}
- *
- * \@experimental
- */
- var I18nSelectPipe = (function () {
- function I18nSelectPipe() {
- }
- /**
- * @param {?} value
- * @param {?} mapping
- * @return {?}
- */
- I18nSelectPipe.prototype.transform = function (value, mapping) {
- if (value == null)
- return '';
- if (typeof mapping !== 'object' || typeof value !== 'string') {
- throw invalidPipeArgumentError(I18nSelectPipe, mapping);
- }
- if (mapping.hasOwnProperty(value)) {
- return mapping[value];
- }
- if (mapping.hasOwnProperty('other')) {
- return mapping['other'];
- }
- return '';
- };
- return I18nSelectPipe;
- }());
- I18nSelectPipe.decorators = [
- { type: Pipe, args: [{ name: 'i18nSelect', pure: true },] },
- ];
- /**
- * @nocollapse
- */
- I18nSelectPipe.ctorParameters = function () { return []; };
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * \@ngModule CommonModule
- * \@whatItDoes Converts value into JSON string.
- * \@howToUse `expression | json`
- * \@description
- *
- * Converts value into string using `JSON.stringify`. Useful for debugging.
- *
- * ### Example
- * {\@example common/pipes/ts/json_pipe.ts region='JsonPipe'}
- *
- * \@stable
- */
- var JsonPipe = (function () {
- function JsonPipe() {
- }
- /**
- * @param {?} value
- * @return {?}
- */
- JsonPipe.prototype.transform = function (value) { return JSON.stringify(value, null, 2); };
- return JsonPipe;
- }());
- JsonPipe.decorators = [
- { type: Pipe, args: [{ name: 'json', pure: false },] },
- ];
- /**
- * @nocollapse
- */
- JsonPipe.ctorParameters = function () { return []; };
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * \@ngModule CommonModule
- * \@whatItDoes Creates a new List or String containing a subset (slice) of the elements.
- * \@howToUse `array_or_string_expression | slice:start[:end]`
- * \@description
- *
- * Where the input expression is a `List` or `String`, and:
- * - `start`: The starting index of the subset to return.
- * - **a positive integer**: return the item at `start` index and all items after
- * in the list or string expression.
- * - **a negative integer**: return the item at `start` index from the end and all items after
- * in the list or string expression.
- * - **if positive and greater than the size of the expression**: return an empty list or string.
- * - **if negative and greater than the size of the expression**: return entire list or string.
- * - `end`: The ending index of the subset to return.
- * - **omitted**: return all items until the end.
- * - **if positive**: return all items before `end` index of the list or string.
- * - **if negative**: return all items before `end` index from the end of the list or string.
- *
- * All behavior is based on the expected behavior of the JavaScript API `Array.prototype.slice()`
- * and `String.prototype.slice()`.
- *
- * When operating on a [List], the returned list is always a copy even when all
- * the elements are being returned.
- *
- * When operating on a blank value, the pipe returns the blank value.
- *
- * ## List Example
- *
- * This `ngFor` example:
- *
- * {\@example common/pipes/ts/slice_pipe.ts region='SlicePipe_list'}
- *
- * produces the following:
- *
- * <li>b</li>
- * <li>c</li>
- *
- * ## String Examples
- *
- * {\@example common/pipes/ts/slice_pipe.ts region='SlicePipe_string'}
- *
- * \@stable
- */
- var SlicePipe = (function () {
- function SlicePipe() {
- }
- /**
- * @param {?} value
- * @param {?} start
- * @param {?=} end
- * @return {?}
- */
- SlicePipe.prototype.transform = function (value, start, end) {
- if (value == null)
- return value;
- if (!this.supports(value)) {
- throw invalidPipeArgumentError(SlicePipe, value);
- }
- return value.slice(start, end);
- };
- /**
- * @param {?} obj
- * @return {?}
- */
- SlicePipe.prototype.supports = function (obj) { return typeof obj === 'string' || Array.isArray(obj); };
- return SlicePipe;
- }());
- SlicePipe.decorators = [
- { type: Pipe, args: [{ name: 'slice', pure: false },] },
- ];
- /**
- * @nocollapse
- */
- SlicePipe.ctorParameters = function () { return []; };
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * @module
- * @description
- * This module provides a set of common Pipes.
- */
- /**
- * A collection of Angular pipes that are likely to be used in each and every application.
- */
- var COMMON_PIPES = [
- AsyncPipe,
- UpperCasePipe,
- LowerCasePipe,
- JsonPipe,
- SlicePipe,
- DecimalPipe,
- PercentPipe,
- TitleCasePipe,
- CurrencyPipe,
- DatePipe,
- I18nPluralPipe,
- I18nSelectPipe,
- ];
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * The module that includes all the basic Angular directives like {\@link NgIf}, {\@link NgForOf}, ...
- *
- * \@stable
- */
- var CommonModule = (function () {
- function CommonModule() {
- }
- return CommonModule;
- }());
- CommonModule.decorators = [
- { type: NgModule, args: [{
- declarations: [COMMON_DIRECTIVES, COMMON_PIPES],
- exports: [COMMON_DIRECTIVES, COMMON_PIPES],
- providers: [
- { provide: NgLocalization, useClass: NgLocaleLocalization },
- ],
- },] },
- ];
- /**
- * @nocollapse
- */
- CommonModule.ctorParameters = function () { return []; };
- /**
- * I18N pipes are being changed to move away from using the JS Intl API.
- *
- * The former pipes relying on the Intl API will be moved to this module while the `CommonModule`
- * will contain the new pipes that do not rely on Intl.
- *
- * As a first step this module is created empty to ease the migration.
- *
- * see https://github.com/angular/angular/pull/18284
- *
- * @deprecated from v5
- */
- var DeprecatedI18NPipesModule = (function () {
- function DeprecatedI18NPipesModule() {
- }
- return DeprecatedI18NPipesModule;
- }());
- DeprecatedI18NPipesModule.decorators = [
- { type: NgModule, args: [{ declarations: [], exports: [] },] },
- ];
- /**
- * @nocollapse
- */
- DeprecatedI18NPipesModule.ctorParameters = function () { return []; };
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * A DI Token representing the main rendering context. In a browser this is the DOM Document.
- *
- * Note: Document might not be available in the Application Context when Application and Rendering
- * Contexts are not the same (e.g. when running the application into a Web Worker).
- *
- * \@stable
- */
- var DOCUMENT = new InjectionToken('DocumentToken');
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var PLATFORM_BROWSER_ID = 'browser';
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * @module
- * @description
- * Entry point for all public APIs of the common package.
- */
- /**
- * \@stable
- */
- var VERSION$2 = new Version('4.4.6');
-
- /**
- * @license Angular v4.4.6
- * (c) 2010-2017 Google, Inc. https://angular.io/
- * License: MIT
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var _DOM = ((null));
- /**
- * @return {?}
- */
- function getDOM() {
- return _DOM;
- }
- /**
- * @param {?} adapter
- * @return {?}
- */
- /**
- * @param {?} adapter
- * @return {?}
- */
- function setRootDomAdapter(adapter) {
- if (!_DOM) {
- _DOM = adapter;
- }
- }
- /**
- * Provides DOM operations in an environment-agnostic way.
- *
- * \@security Tread carefully! Interacting with the DOM directly is dangerous and
- * can introduce XSS risks.
- * @abstract
- */
- var DomAdapter = (function () {
- function DomAdapter() {
- this.resourceLoaderType = ((null));
- }
- /**
- * @abstract
- * @param {?} element
- * @param {?} name
- * @return {?}
- */
- DomAdapter.prototype.hasProperty = function (element, name) { };
- /**
- * @abstract
- * @param {?} el
- * @param {?} name
- * @param {?} value
- * @return {?}
- */
- DomAdapter.prototype.setProperty = function (el, name, value) { };
- /**
- * @abstract
- * @param {?} el
- * @param {?} name
- * @return {?}
- */
- DomAdapter.prototype.getProperty = function (el, name) { };
- /**
- * @abstract
- * @param {?} el
- * @param {?} methodName
- * @param {?} args
- * @return {?}
- */
- DomAdapter.prototype.invoke = function (el, methodName, args) { };
- /**
- * @abstract
- * @param {?} error
- * @return {?}
- */
- DomAdapter.prototype.logError = function (error) { };
- /**
- * @abstract
- * @param {?} error
- * @return {?}
- */
- DomAdapter.prototype.log = function (error) { };
- /**
- * @abstract
- * @param {?} error
- * @return {?}
- */
- DomAdapter.prototype.logGroup = function (error) { };
- /**
- * @abstract
- * @return {?}
- */
- DomAdapter.prototype.logGroupEnd = function () { };
- Object.defineProperty(DomAdapter.prototype, "attrToPropMap", {
- /**
- * Maps attribute names to their corresponding property names for cases
- * where attribute name doesn't match property name.
- * @return {?}
- */
- get: function () { return this._attrToPropMap; },
- /**
- * @param {?} value
- * @return {?}
- */
- set: function (value) { this._attrToPropMap = value; },
- enumerable: true,
- configurable: true
- });
- /**
- * @abstract
- * @param {?} nodeA
- * @param {?} nodeB
- * @return {?}
- */
- DomAdapter.prototype.contains = function (nodeA, nodeB) { };
- /**
- * @abstract
- * @param {?} templateHtml
- * @return {?}
- */
- DomAdapter.prototype.parse = function (templateHtml) { };
- /**
- * @abstract
- * @param {?} el
- * @param {?} selector
- * @return {?}
- */
- DomAdapter.prototype.querySelector = function (el, selector) { };
- /**
- * @abstract
- * @param {?} el
- * @param {?} selector
- * @return {?}
- */
- DomAdapter.prototype.querySelectorAll = function (el, selector) { };
- /**
- * @abstract
- * @param {?} el
- * @param {?} evt
- * @param {?} listener
- * @return {?}
- */
- DomAdapter.prototype.on = function (el, evt, listener) { };
- /**
- * @abstract
- * @param {?} el
- * @param {?} evt
- * @param {?} listener
- * @return {?}
- */
- DomAdapter.prototype.onAndCancel = function (el, evt, listener) { };
- /**
- * @abstract
- * @param {?} el
- * @param {?} evt
- * @return {?}
- */
- DomAdapter.prototype.dispatchEvent = function (el, evt) { };
- /**
- * @abstract
- * @param {?} eventType
- * @return {?}
- */
- DomAdapter.prototype.createMouseEvent = function (eventType) { };
- /**
- * @abstract
- * @param {?} eventType
- * @return {?}
- */
- DomAdapter.prototype.createEvent = function (eventType) { };
- /**
- * @abstract
- * @param {?} evt
- * @return {?}
- */
- DomAdapter.prototype.preventDefault = function (evt) { };
- /**
- * @abstract
- * @param {?} evt
- * @return {?}
- */
- DomAdapter.prototype.isPrevented = function (evt) { };
- /**
- * @abstract
- * @param {?} el
- * @return {?}
- */
- DomAdapter.prototype.getInnerHTML = function (el) { };
- /**
- * Returns content if el is a <template> element, null otherwise.
- * @abstract
- * @param {?} el
- * @return {?}
- */
- DomAdapter.prototype.getTemplateContent = function (el) { };
- /**
- * @abstract
- * @param {?} el
- * @return {?}
- */
- DomAdapter.prototype.getOuterHTML = function (el) { };
- /**
- * @abstract
- * @param {?} node
- * @return {?}
- */
- DomAdapter.prototype.nodeName = function (node) { };
- /**
- * @abstract
- * @param {?} node
- * @return {?}
- */
- DomAdapter.prototype.nodeValue = function (node) { };
- /**
- * @abstract
- * @param {?} node
- * @return {?}
- */
- DomAdapter.prototype.type = function (node) { };
- /**
- * @abstract
- * @param {?} node
- * @return {?}
- */
- DomAdapter.prototype.content = function (node) { };
- /**
- * @abstract
- * @param {?} el
- * @return {?}
- */
- DomAdapter.prototype.firstChild = function (el) { };
- /**
- * @abstract
- * @param {?} el
- * @return {?}
- */
- DomAdapter.prototype.nextSibling = function (el) { };
- /**
- * @abstract
- * @param {?} el
- * @return {?}
- */
- DomAdapter.prototype.parentElement = function (el) { };
- /**
- * @abstract
- * @param {?} el
- * @return {?}
- */
- DomAdapter.prototype.childNodes = function (el) { };
- /**
- * @abstract
- * @param {?} el
- * @return {?}
- */
- DomAdapter.prototype.childNodesAsList = function (el) { };
- /**
- * @abstract
- * @param {?} el
- * @return {?}
- */
- DomAdapter.prototype.clearNodes = function (el) { };
- /**
- * @abstract
- * @param {?} el
- * @param {?} node
- * @return {?}
- */
- DomAdapter.prototype.appendChild = function (el, node) { };
- /**
- * @abstract
- * @param {?} el
- * @param {?} node
- * @return {?}
- */
- DomAdapter.prototype.removeChild = function (el, node) { };
- /**
- * @abstract
- * @param {?} el
- * @param {?} newNode
- * @param {?} oldNode
- * @return {?}
- */
- DomAdapter.prototype.replaceChild = function (el, newNode, oldNode) { };
- /**
- * @abstract
- * @param {?} el
- * @return {?}
- */
- DomAdapter.prototype.remove = function (el) { };
- /**
- * @abstract
- * @param {?} parent
- * @param {?} ref
- * @param {?} node
- * @return {?}
- */
- DomAdapter.prototype.insertBefore = function (parent, ref, node) { };
- /**
- * @abstract
- * @param {?} parent
- * @param {?} ref
- * @param {?} nodes
- * @return {?}
- */
- DomAdapter.prototype.insertAllBefore = function (parent, ref, nodes) { };
- /**
- * @abstract
- * @param {?} parent
- * @param {?} el
- * @param {?} node
- * @return {?}
- */
- DomAdapter.prototype.insertAfter = function (parent, el, node) { };
- /**
- * @abstract
- * @param {?} el
- * @param {?} value
- * @return {?}
- */
- DomAdapter.prototype.setInnerHTML = function (el, value) { };
- /**
- * @abstract
- * @param {?} el
- * @return {?}
- */
- DomAdapter.prototype.getText = function (el) { };
- /**
- * @abstract
- * @param {?} el
- * @param {?} value
- * @return {?}
- */
- DomAdapter.prototype.setText = function (el, value) { };
- /**
- * @abstract
- * @param {?} el
- * @return {?}
- */
- DomAdapter.prototype.getValue = function (el) { };
- /**
- * @abstract
- * @param {?} el
- * @param {?} value
- * @return {?}
- */
- DomAdapter.prototype.setValue = function (el, value) { };
- /**
- * @abstract
- * @param {?} el
- * @return {?}
- */
- DomAdapter.prototype.getChecked = function (el) { };
- /**
- * @abstract
- * @param {?} el
- * @param {?} value
- * @return {?}
- */
- DomAdapter.prototype.setChecked = function (el, value) { };
- /**
- * @abstract
- * @param {?} text
- * @return {?}
- */
- DomAdapter.prototype.createComment = function (text) { };
- /**
- * @abstract
- * @param {?} html
- * @return {?}
- */
- DomAdapter.prototype.createTemplate = function (html) { };
- /**
- * @abstract
- * @param {?} tagName
- * @param {?=} doc
- * @return {?}
- */
- DomAdapter.prototype.createElement = function (tagName, doc) { };
- /**
- * @abstract
- * @param {?} ns
- * @param {?} tagName
- * @param {?=} doc
- * @return {?}
- */
- DomAdapter.prototype.createElementNS = function (ns, tagName, doc) { };
- /**
- * @abstract
- * @param {?} text
- * @param {?=} doc
- * @return {?}
- */
- DomAdapter.prototype.createTextNode = function (text, doc) { };
- /**
- * @abstract
- * @param {?} attrName
- * @param {?} attrValue
- * @param {?=} doc
- * @return {?}
- */
- DomAdapter.prototype.createScriptTag = function (attrName, attrValue, doc) { };
- /**
- * @abstract
- * @param {?} css
- * @param {?=} doc
- * @return {?}
- */
- DomAdapter.prototype.createStyleElement = function (css, doc) { };
- /**
- * @abstract
- * @param {?} el
- * @return {?}
- */
- DomAdapter.prototype.createShadowRoot = function (el) { };
- /**
- * @abstract
- * @param {?} el
- * @return {?}
- */
- DomAdapter.prototype.getShadowRoot = function (el) { };
- /**
- * @abstract
- * @param {?} el
- * @return {?}
- */
- DomAdapter.prototype.getHost = function (el) { };
- /**
- * @abstract
- * @param {?} el
- * @return {?}
- */
- DomAdapter.prototype.getDistributedNodes = function (el) { };
- /**
- * @abstract
- * @param {?} node
- * @return {?}
- */
- DomAdapter.prototype.clone /*<T extends Node>*/ = function (node) { };
- /**
- * @abstract
- * @param {?} element
- * @param {?} name
- * @return {?}
- */
- DomAdapter.prototype.getElementsByClassName = function (element, name) { };
- /**
- * @abstract
- * @param {?} element
- * @param {?} name
- * @return {?}
- */
- DomAdapter.prototype.getElementsByTagName = function (element, name) { };
- /**
- * @abstract
- * @param {?} element
- * @return {?}
- */
- DomAdapter.prototype.classList = function (element) { };
- /**
- * @abstract
- * @param {?} element
- * @param {?} className
- * @return {?}
- */
- DomAdapter.prototype.addClass = function (element, className) { };
- /**
- * @abstract
- * @param {?} element
- * @param {?} className
- * @return {?}
- */
- DomAdapter.prototype.removeClass = function (element, className) { };
- /**
- * @abstract
- * @param {?} element
- * @param {?} className
- * @return {?}
- */
- DomAdapter.prototype.hasClass = function (element, className) { };
- /**
- * @abstract
- * @param {?} element
- * @param {?} styleName
- * @param {?} styleValue
- * @return {?}
- */
- DomAdapter.prototype.setStyle = function (element, styleName, styleValue) { };
- /**
- * @abstract
- * @param {?} element
- * @param {?} styleName
- * @return {?}
- */
- DomAdapter.prototype.removeStyle = function (element, styleName) { };
- /**
- * @abstract
- * @param {?} element
- * @param {?} styleName
- * @return {?}
- */
- DomAdapter.prototype.getStyle = function (element, styleName) { };
- /**
- * @abstract
- * @param {?} element
- * @param {?} styleName
- * @param {?=} styleValue
- * @return {?}
- */
- DomAdapter.prototype.hasStyle = function (element, styleName, styleValue) { };
- /**
- * @abstract
- * @param {?} element
- * @return {?}
- */
- DomAdapter.prototype.tagName = function (element) { };
- /**
- * @abstract
- * @param {?} element
- * @return {?}
- */
- DomAdapter.prototype.attributeMap = function (element) { };
- /**
- * @abstract
- * @param {?} element
- * @param {?} attribute
- * @return {?}
- */
- DomAdapter.prototype.hasAttribute = function (element, attribute) { };
- /**
- * @abstract
- * @param {?} element
- * @param {?} ns
- * @param {?} attribute
- * @return {?}
- */
- DomAdapter.prototype.hasAttributeNS = function (element, ns, attribute) { };
- /**
- * @abstract
- * @param {?} element
- * @param {?} attribute
- * @return {?}
- */
- DomAdapter.prototype.getAttribute = function (element, attribute) { };
- /**
- * @abstract
- * @param {?} element
- * @param {?} ns
- * @param {?} attribute
- * @return {?}
- */
- DomAdapter.prototype.getAttributeNS = function (element, ns, attribute) { };
- /**
- * @abstract
- * @param {?} element
- * @param {?} name
- * @param {?} value
- * @return {?}
- */
- DomAdapter.prototype.setAttribute = function (element, name, value) { };
- /**
- * @abstract
- * @param {?} element
- * @param {?} ns
- * @param {?} name
- * @param {?} value
- * @return {?}
- */
- DomAdapter.prototype.setAttributeNS = function (element, ns, name, value) { };
- /**
- * @abstract
- * @param {?} element
- * @param {?} attribute
- * @return {?}
- */
- DomAdapter.prototype.removeAttribute = function (element, attribute) { };
- /**
- * @abstract
- * @param {?} element
- * @param {?} ns
- * @param {?} attribute
- * @return {?}
- */
- DomAdapter.prototype.removeAttributeNS = function (element, ns, attribute) { };
- /**
- * @abstract
- * @param {?} el
- * @return {?}
- */
- DomAdapter.prototype.templateAwareRoot = function (el) { };
- /**
- * @abstract
- * @return {?}
- */
- DomAdapter.prototype.createHtmlDocument = function () { };
- /**
- * @abstract
- * @param {?} el
- * @return {?}
- */
- DomAdapter.prototype.getBoundingClientRect = function (el) { };
- /**
- * @abstract
- * @param {?} doc
- * @return {?}
- */
- DomAdapter.prototype.getTitle = function (doc) { };
- /**
- * @abstract
- * @param {?} doc
- * @param {?} newTitle
- * @return {?}
- */
- DomAdapter.prototype.setTitle = function (doc, newTitle) { };
- /**
- * @abstract
- * @param {?} n
- * @param {?} selector
- * @return {?}
- */
- DomAdapter.prototype.elementMatches = function (n, selector) { };
- /**
- * @abstract
- * @param {?} el
- * @return {?}
- */
- DomAdapter.prototype.isTemplateElement = function (el) { };
- /**
- * @abstract
- * @param {?} node
- * @return {?}
- */
- DomAdapter.prototype.isTextNode = function (node) { };
- /**
- * @abstract
- * @param {?} node
- * @return {?}
- */
- DomAdapter.prototype.isCommentNode = function (node) { };
- /**
- * @abstract
- * @param {?} node
- * @return {?}
- */
- DomAdapter.prototype.isElementNode = function (node) { };
- /**
- * @abstract
- * @param {?} node
- * @return {?}
- */
- DomAdapter.prototype.hasShadowRoot = function (node) { };
- /**
- * @abstract
- * @param {?} node
- * @return {?}
- */
- DomAdapter.prototype.isShadowRoot = function (node) { };
- /**
- * @abstract
- * @param {?} node
- * @return {?}
- */
- DomAdapter.prototype.importIntoDoc /*<T extends Node>*/ = function (node) { };
- /**
- * @abstract
- * @param {?} node
- * @return {?}
- */
- DomAdapter.prototype.adoptNode /*<T extends Node>*/ = function (node) { };
- /**
- * @abstract
- * @param {?} element
- * @return {?}
- */
- DomAdapter.prototype.getHref = function (element) { };
- /**
- * @abstract
- * @param {?} event
- * @return {?}
- */
- DomAdapter.prototype.getEventKey = function (event) { };
- /**
- * @abstract
- * @param {?} element
- * @param {?} baseUrl
- * @param {?} href
- * @return {?}
- */
- DomAdapter.prototype.resolveAndSetHref = function (element, baseUrl, href) { };
- /**
- * @abstract
- * @return {?}
- */
- DomAdapter.prototype.supportsDOMEvents = function () { };
- /**
- * @abstract
- * @return {?}
- */
- DomAdapter.prototype.supportsNativeShadowDOM = function () { };
- /**
- * @abstract
- * @param {?} doc
- * @param {?} target
- * @return {?}
- */
- DomAdapter.prototype.getGlobalEventTarget = function (doc, target) { };
- /**
- * @abstract
- * @return {?}
- */
- DomAdapter.prototype.getHistory = function () { };
- /**
- * @abstract
- * @return {?}
- */
- DomAdapter.prototype.getLocation = function () { };
- /**
- * @abstract
- * @param {?} doc
- * @return {?}
- */
- DomAdapter.prototype.getBaseHref = function (doc) { };
- /**
- * @abstract
- * @return {?}
- */
- DomAdapter.prototype.resetBaseElement = function () { };
- /**
- * @abstract
- * @return {?}
- */
- DomAdapter.prototype.getUserAgent = function () { };
- /**
- * @abstract
- * @param {?} element
- * @param {?} name
- * @param {?} value
- * @return {?}
- */
- DomAdapter.prototype.setData = function (element, name, value) { };
- /**
- * @abstract
- * @param {?} element
- * @return {?}
- */
- DomAdapter.prototype.getComputedStyle = function (element) { };
- /**
- * @abstract
- * @param {?} element
- * @param {?} name
- * @return {?}
- */
- DomAdapter.prototype.getData = function (element, name) { };
- /**
- * @abstract
- * @return {?}
- */
- DomAdapter.prototype.supportsWebAnimation = function () { };
- /**
- * @abstract
- * @return {?}
- */
- DomAdapter.prototype.performanceNow = function () { };
- /**
- * @abstract
- * @return {?}
- */
- DomAdapter.prototype.getAnimationPrefix = function () { };
- /**
- * @abstract
- * @return {?}
- */
- DomAdapter.prototype.getTransitionEnd = function () { };
- /**
- * @abstract
- * @return {?}
- */
- DomAdapter.prototype.supportsAnimation = function () { };
- /**
- * @abstract
- * @return {?}
- */
- DomAdapter.prototype.supportsCookies = function () { };
- /**
- * @abstract
- * @param {?} name
- * @return {?}
- */
- DomAdapter.prototype.getCookie = function (name) { };
- /**
- * @abstract
- * @param {?} name
- * @param {?} value
- * @return {?}
- */
- DomAdapter.prototype.setCookie = function (name, value) { };
- return DomAdapter;
- }());
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * Provides DOM operations in any browser environment.
- *
- * \@security Tread carefully! Interacting with the DOM directly is dangerous and
- * can introduce XSS risks.
- * @abstract
- */
- var GenericBrowserDomAdapter = (function (_super) {
- __extends$1(GenericBrowserDomAdapter, _super);
- function GenericBrowserDomAdapter() {
- var _this = _super.call(this) || this;
- _this._animationPrefix = null;
- _this._transitionEnd = null;
- try {
- var element_1 = _this.createElement('div', document);
- if (_this.getStyle(element_1, 'animationName') != null) {
- _this._animationPrefix = '';
- }
- else {
- var domPrefixes = ['Webkit', 'Moz', 'O', 'ms'];
- for (var i = 0; i < domPrefixes.length; i++) {
- if (_this.getStyle(element_1, domPrefixes[i] + 'AnimationName') != null) {
- _this._animationPrefix = '-' + domPrefixes[i].toLowerCase() + '-';
- break;
- }
- }
- }
- var transEndEventNames_1 = {
- WebkitTransition: 'webkitTransitionEnd',
- MozTransition: 'transitionend',
- OTransition: 'oTransitionEnd otransitionend',
- transition: 'transitionend'
- };
- Object.keys(transEndEventNames_1).forEach(function (key) {
- if (_this.getStyle(element_1, key) != null) {
- _this._transitionEnd = transEndEventNames_1[key];
- }
- });
- }
- catch (e) {
- _this._animationPrefix = null;
- _this._transitionEnd = null;
- }
- return _this;
- }
- /**
- * @param {?} el
- * @return {?}
- */
- GenericBrowserDomAdapter.prototype.getDistributedNodes = function (el) { return ((el)).getDistributedNodes(); };
- /**
- * @param {?} el
- * @param {?} baseUrl
- * @param {?} href
- * @return {?}
- */
- GenericBrowserDomAdapter.prototype.resolveAndSetHref = function (el, baseUrl, href) {
- el.href = href == null ? baseUrl : baseUrl + '/../' + href;
- };
- /**
- * @return {?}
- */
- GenericBrowserDomAdapter.prototype.supportsDOMEvents = function () { return true; };
- /**
- * @return {?}
- */
- GenericBrowserDomAdapter.prototype.supportsNativeShadowDOM = function () {
- return typeof ((document.body)).createShadowRoot === 'function';
- };
- /**
- * @return {?}
- */
- GenericBrowserDomAdapter.prototype.getAnimationPrefix = function () { return this._animationPrefix ? this._animationPrefix : ''; };
- /**
- * @return {?}
- */
- GenericBrowserDomAdapter.prototype.getTransitionEnd = function () { return this._transitionEnd ? this._transitionEnd : ''; };
- /**
- * @return {?}
- */
- GenericBrowserDomAdapter.prototype.supportsAnimation = function () {
- return this._animationPrefix != null && this._transitionEnd != null;
- };
- return GenericBrowserDomAdapter;
- }(DomAdapter));
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var _attrToPropMap = {
- 'class': 'className',
- 'innerHtml': 'innerHTML',
- 'readonly': 'readOnly',
- 'tabindex': 'tabIndex',
- };
- var DOM_KEY_LOCATION_NUMPAD = 3;
- // Map to convert some key or keyIdentifier values to what will be returned by getEventKey
- var _keyMap = {
- // The following values are here for cross-browser compatibility and to match the W3C standard
- // cf http://www.w3.org/TR/DOM-Level-3-Events-key/
- '\b': 'Backspace',
- '\t': 'Tab',
- '\x7F': 'Delete',
- '\x1B': 'Escape',
- 'Del': 'Delete',
- 'Esc': 'Escape',
- 'Left': 'ArrowLeft',
- 'Right': 'ArrowRight',
- 'Up': 'ArrowUp',
- 'Down': 'ArrowDown',
- 'Menu': 'ContextMenu',
- 'Scroll': 'ScrollLock',
- 'Win': 'OS'
- };
- // There is a bug in Chrome for numeric keypad keys:
- // https://code.google.com/p/chromium/issues/detail?id=155654
- // 1, 2, 3 ... are reported as A, B, C ...
- var _chromeNumKeyPadMap = {
- 'A': '1',
- 'B': '2',
- 'C': '3',
- 'D': '4',
- 'E': '5',
- 'F': '6',
- 'G': '7',
- 'H': '8',
- 'I': '9',
- 'J': '*',
- 'K': '+',
- 'M': '-',
- 'N': '.',
- 'O': '/',
- '\x60': '0',
- '\x90': 'NumLock'
- };
- var nodeContains;
- if (_global['Node']) {
- nodeContains = _global['Node'].prototype.contains || function (node) {
- return !!(this.compareDocumentPosition(node) & 16);
- };
- }
- var BrowserDomAdapter = (function (_super) {
- __extends$1(BrowserDomAdapter, _super);
- function BrowserDomAdapter() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- /**
- * @param {?} templateHtml
- * @return {?}
- */
- BrowserDomAdapter.prototype.parse = function (templateHtml) { throw new Error('parse not implemented'); };
- /**
- * @return {?}
- */
- BrowserDomAdapter.makeCurrent = function () { setRootDomAdapter(new BrowserDomAdapter()); };
- /**
- * @param {?} element
- * @param {?} name
- * @return {?}
- */
- BrowserDomAdapter.prototype.hasProperty = function (element, name) { return name in element; };
- /**
- * @param {?} el
- * @param {?} name
- * @param {?} value
- * @return {?}
- */
- BrowserDomAdapter.prototype.setProperty = function (el, name, value) { ((el))[name] = value; };
- /**
- * @param {?} el
- * @param {?} name
- * @return {?}
- */
- BrowserDomAdapter.prototype.getProperty = function (el, name) { return ((el))[name]; };
- /**
- * @param {?} el
- * @param {?} methodName
- * @param {?} args
- * @return {?}
- */
- BrowserDomAdapter.prototype.invoke = function (el, methodName, args) { ((el))[methodName].apply(((el)), args); };
- /**
- * @param {?} error
- * @return {?}
- */
- BrowserDomAdapter.prototype.logError = function (error) {
- if (window.console) {
- if (console.error) {
- console.error(error);
- }
- else {
- console.log(error);
- }
- }
- };
- /**
- * @param {?} error
- * @return {?}
- */
- BrowserDomAdapter.prototype.log = function (error) {
- if (window.console) {
- window.console.log && window.console.log(error);
- }
- };
- /**
- * @param {?} error
- * @return {?}
- */
- BrowserDomAdapter.prototype.logGroup = function (error) {
- if (window.console) {
- window.console.group && window.console.group(error);
- }
- };
- /**
- * @return {?}
- */
- BrowserDomAdapter.prototype.logGroupEnd = function () {
- if (window.console) {
- window.console.groupEnd && window.console.groupEnd();
- }
- };
- Object.defineProperty(BrowserDomAdapter.prototype, "attrToPropMap", {
- /**
- * @return {?}
- */
- get: function () { return _attrToPropMap; },
- enumerable: true,
- configurable: true
- });
- /**
- * @param {?} nodeA
- * @param {?} nodeB
- * @return {?}
- */
- BrowserDomAdapter.prototype.contains = function (nodeA, nodeB) { return nodeContains.call(nodeA, nodeB); };
- /**
- * @param {?} el
- * @param {?} selector
- * @return {?}
- */
- BrowserDomAdapter.prototype.querySelector = function (el, selector) { return el.querySelector(selector); };
- /**
- * @param {?} el
- * @param {?} selector
- * @return {?}
- */
- BrowserDomAdapter.prototype.querySelectorAll = function (el, selector) { return el.querySelectorAll(selector); };
- /**
- * @param {?} el
- * @param {?} evt
- * @param {?} listener
- * @return {?}
- */
- BrowserDomAdapter.prototype.on = function (el, evt, listener) { el.addEventListener(evt, listener, false); };
- /**
- * @param {?} el
- * @param {?} evt
- * @param {?} listener
- * @return {?}
- */
- BrowserDomAdapter.prototype.onAndCancel = function (el, evt, listener) {
- el.addEventListener(evt, listener, false);
- // Needed to follow Dart's subscription semantic, until fix of
- // https://code.google.com/p/dart/issues/detail?id=17406
- return function () { el.removeEventListener(evt, listener, false); };
- };
- /**
- * @param {?} el
- * @param {?} evt
- * @return {?}
- */
- BrowserDomAdapter.prototype.dispatchEvent = function (el, evt) { el.dispatchEvent(evt); };
- /**
- * @param {?} eventType
- * @return {?}
- */
- BrowserDomAdapter.prototype.createMouseEvent = function (eventType) {
- var /** @type {?} */ evt = document.createEvent('MouseEvent');
- evt.initEvent(eventType, true, true);
- return evt;
- };
- /**
- * @param {?} eventType
- * @return {?}
- */
- BrowserDomAdapter.prototype.createEvent = function (eventType) {
- var /** @type {?} */ evt = document.createEvent('Event');
- evt.initEvent(eventType, true, true);
- return evt;
- };
- /**
- * @param {?} evt
- * @return {?}
- */
- BrowserDomAdapter.prototype.preventDefault = function (evt) {
- evt.preventDefault();
- evt.returnValue = false;
- };
- /**
- * @param {?} evt
- * @return {?}
- */
- BrowserDomAdapter.prototype.isPrevented = function (evt) {
- return evt.defaultPrevented || evt.returnValue != null && !evt.returnValue;
- };
- /**
- * @param {?} el
- * @return {?}
- */
- BrowserDomAdapter.prototype.getInnerHTML = function (el) { return el.innerHTML; };
- /**
- * @param {?} el
- * @return {?}
- */
- BrowserDomAdapter.prototype.getTemplateContent = function (el) {
- return 'content' in el && el instanceof HTMLTemplateElement ? el.content : null;
- };
- /**
- * @param {?} el
- * @return {?}
- */
- BrowserDomAdapter.prototype.getOuterHTML = function (el) { return el.outerHTML; };
- /**
- * @param {?} node
- * @return {?}
- */
- BrowserDomAdapter.prototype.nodeName = function (node) { return node.nodeName; };
- /**
- * @param {?} node
- * @return {?}
- */
- BrowserDomAdapter.prototype.nodeValue = function (node) { return node.nodeValue; };
- /**
- * @param {?} node
- * @return {?}
- */
- BrowserDomAdapter.prototype.type = function (node) { return node.type; };
- /**
- * @param {?} node
- * @return {?}
- */
- BrowserDomAdapter.prototype.content = function (node) {
- if (this.hasProperty(node, 'content')) {
- return ((node)).content;
- }
- else {
- return node;
- }
- };
- /**
- * @param {?} el
- * @return {?}
- */
- BrowserDomAdapter.prototype.firstChild = function (el) { return el.firstChild; };
- /**
- * @param {?} el
- * @return {?}
- */
- BrowserDomAdapter.prototype.nextSibling = function (el) { return el.nextSibling; };
- /**
- * @param {?} el
- * @return {?}
- */
- BrowserDomAdapter.prototype.parentElement = function (el) { return el.parentNode; };
- /**
- * @param {?} el
- * @return {?}
- */
- BrowserDomAdapter.prototype.childNodes = function (el) { return el.childNodes; };
- /**
- * @param {?} el
- * @return {?}
- */
- BrowserDomAdapter.prototype.childNodesAsList = function (el) {
- var /** @type {?} */ childNodes = el.childNodes;
- var /** @type {?} */ res = new Array(childNodes.length);
- for (var /** @type {?} */ i = 0; i < childNodes.length; i++) {
- res[i] = childNodes[i];
- }
- return res;
- };
- /**
- * @param {?} el
- * @return {?}
- */
- BrowserDomAdapter.prototype.clearNodes = function (el) {
- while (el.firstChild) {
- el.removeChild(el.firstChild);
- }
- };
- /**
- * @param {?} el
- * @param {?} node
- * @return {?}
- */
- BrowserDomAdapter.prototype.appendChild = function (el, node) { el.appendChild(node); };
- /**
- * @param {?} el
- * @param {?} node
- * @return {?}
- */
- BrowserDomAdapter.prototype.removeChild = function (el, node) { el.removeChild(node); };
- /**
- * @param {?} el
- * @param {?} newChild
- * @param {?} oldChild
- * @return {?}
- */
- BrowserDomAdapter.prototype.replaceChild = function (el, newChild, oldChild) { el.replaceChild(newChild, oldChild); };
- /**
- * @param {?} node
- * @return {?}
- */
- BrowserDomAdapter.prototype.remove = function (node) {
- if (node.parentNode) {
- node.parentNode.removeChild(node);
- }
- return node;
- };
- /**
- * @param {?} parent
- * @param {?} ref
- * @param {?} node
- * @return {?}
- */
- BrowserDomAdapter.prototype.insertBefore = function (parent, ref, node) { parent.insertBefore(node, ref); };
- /**
- * @param {?} parent
- * @param {?} ref
- * @param {?} nodes
- * @return {?}
- */
- BrowserDomAdapter.prototype.insertAllBefore = function (parent, ref, nodes) {
- nodes.forEach(function (n) { return parent.insertBefore(n, ref); });
- };
- /**
- * @param {?} parent
- * @param {?} ref
- * @param {?} node
- * @return {?}
- */
- BrowserDomAdapter.prototype.insertAfter = function (parent, ref, node) { parent.insertBefore(node, ref.nextSibling); };
- /**
- * @param {?} el
- * @param {?} value
- * @return {?}
- */
- BrowserDomAdapter.prototype.setInnerHTML = function (el, value) { el.innerHTML = value; };
- /**
- * @param {?} el
- * @return {?}
- */
- BrowserDomAdapter.prototype.getText = function (el) { return el.textContent; };
- /**
- * @param {?} el
- * @param {?} value
- * @return {?}
- */
- BrowserDomAdapter.prototype.setText = function (el, value) { el.textContent = value; };
- /**
- * @param {?} el
- * @return {?}
- */
- BrowserDomAdapter.prototype.getValue = function (el) { return el.value; };
- /**
- * @param {?} el
- * @param {?} value
- * @return {?}
- */
- BrowserDomAdapter.prototype.setValue = function (el, value) { el.value = value; };
- /**
- * @param {?} el
- * @return {?}
- */
- BrowserDomAdapter.prototype.getChecked = function (el) { return el.checked; };
- /**
- * @param {?} el
- * @param {?} value
- * @return {?}
- */
- BrowserDomAdapter.prototype.setChecked = function (el, value) { el.checked = value; };
- /**
- * @param {?} text
- * @return {?}
- */
- BrowserDomAdapter.prototype.createComment = function (text) { return document.createComment(text); };
- /**
- * @param {?} html
- * @return {?}
- */
- BrowserDomAdapter.prototype.createTemplate = function (html) {
- var /** @type {?} */ t = document.createElement('template');
- t.innerHTML = html;
- return t;
- };
- /**
- * @param {?} tagName
- * @param {?=} doc
- * @return {?}
- */
- BrowserDomAdapter.prototype.createElement = function (tagName, doc) {
- if (doc === void 0) { doc = document; }
- return doc.createElement(tagName);
- };
- /**
- * @param {?} ns
- * @param {?} tagName
- * @param {?=} doc
- * @return {?}
- */
- BrowserDomAdapter.prototype.createElementNS = function (ns, tagName, doc) {
- if (doc === void 0) { doc = document; }
- return doc.createElementNS(ns, tagName);
- };
- /**
- * @param {?} text
- * @param {?=} doc
- * @return {?}
- */
- BrowserDomAdapter.prototype.createTextNode = function (text, doc) {
- if (doc === void 0) { doc = document; }
- return doc.createTextNode(text);
- };
- /**
- * @param {?} attrName
- * @param {?} attrValue
- * @param {?=} doc
- * @return {?}
- */
- BrowserDomAdapter.prototype.createScriptTag = function (attrName, attrValue, doc) {
- if (doc === void 0) { doc = document; }
- var /** @type {?} */ el = (doc.createElement('SCRIPT'));
- el.setAttribute(attrName, attrValue);
- return el;
- };
- /**
- * @param {?} css
- * @param {?=} doc
- * @return {?}
- */
- BrowserDomAdapter.prototype.createStyleElement = function (css, doc) {
- if (doc === void 0) { doc = document; }
- var /** @type {?} */ style$$1 = (doc.createElement('style'));
- this.appendChild(style$$1, this.createTextNode(css));
- return style$$1;
- };
- /**
- * @param {?} el
- * @return {?}
- */
- BrowserDomAdapter.prototype.createShadowRoot = function (el) { return ((el)).createShadowRoot(); };
- /**
- * @param {?} el
- * @return {?}
- */
- BrowserDomAdapter.prototype.getShadowRoot = function (el) { return ((el)).shadowRoot; };
- /**
- * @param {?} el
- * @return {?}
- */
- BrowserDomAdapter.prototype.getHost = function (el) { return ((el)).host; };
- /**
- * @param {?} node
- * @return {?}
- */
- BrowserDomAdapter.prototype.clone = function (node) { return node.cloneNode(true); };
- /**
- * @param {?} element
- * @param {?} name
- * @return {?}
- */
- BrowserDomAdapter.prototype.getElementsByClassName = function (element, name) {
- return element.getElementsByClassName(name);
- };
- /**
- * @param {?} element
- * @param {?} name
- * @return {?}
- */
- BrowserDomAdapter.prototype.getElementsByTagName = function (element, name) {
- return element.getElementsByTagName(name);
- };
- /**
- * @param {?} element
- * @return {?}
- */
- BrowserDomAdapter.prototype.classList = function (element) { return Array.prototype.slice.call(element.classList, 0); };
- /**
- * @param {?} element
- * @param {?} className
- * @return {?}
- */
- BrowserDomAdapter.prototype.addClass = function (element, className) { element.classList.add(className); };
- /**
- * @param {?} element
- * @param {?} className
- * @return {?}
- */
- BrowserDomAdapter.prototype.removeClass = function (element, className) { element.classList.remove(className); };
- /**
- * @param {?} element
- * @param {?} className
- * @return {?}
- */
- BrowserDomAdapter.prototype.hasClass = function (element, className) {
- return element.classList.contains(className);
- };
- /**
- * @param {?} element
- * @param {?} styleName
- * @param {?} styleValue
- * @return {?}
- */
- BrowserDomAdapter.prototype.setStyle = function (element, styleName, styleValue) {
- element.style[styleName] = styleValue;
- };
- /**
- * @param {?} element
- * @param {?} stylename
- * @return {?}
- */
- BrowserDomAdapter.prototype.removeStyle = function (element, stylename) {
- // IE requires '' instead of null
- // see https://github.com/angular/angular/issues/7916
- element.style[stylename] = '';
- };
- /**
- * @param {?} element
- * @param {?} stylename
- * @return {?}
- */
- BrowserDomAdapter.prototype.getStyle = function (element, stylename) { return element.style[stylename]; };
- /**
- * @param {?} element
- * @param {?} styleName
- * @param {?=} styleValue
- * @return {?}
- */
- BrowserDomAdapter.prototype.hasStyle = function (element, styleName, styleValue) {
- var /** @type {?} */ value = this.getStyle(element, styleName) || '';
- return styleValue ? value == styleValue : value.length > 0;
- };
- /**
- * @param {?} element
- * @return {?}
- */
- BrowserDomAdapter.prototype.tagName = function (element) { return element.tagName; };
- /**
- * @param {?} element
- * @return {?}
- */
- BrowserDomAdapter.prototype.attributeMap = function (element) {
- var /** @type {?} */ res = new Map();
- var /** @type {?} */ elAttrs = element.attributes;
- for (var /** @type {?} */ i = 0; i < elAttrs.length; i++) {
- var /** @type {?} */ attrib = elAttrs[i];
- res.set(attrib.name, attrib.value);
- }
- return res;
- };
- /**
- * @param {?} element
- * @param {?} attribute
- * @return {?}
- */
- BrowserDomAdapter.prototype.hasAttribute = function (element, attribute) {
- return element.hasAttribute(attribute);
- };
- /**
- * @param {?} element
- * @param {?} ns
- * @param {?} attribute
- * @return {?}
- */
- BrowserDomAdapter.prototype.hasAttributeNS = function (element, ns, attribute) {
- return element.hasAttributeNS(ns, attribute);
- };
- /**
- * @param {?} element
- * @param {?} attribute
- * @return {?}
- */
- BrowserDomAdapter.prototype.getAttribute = function (element, attribute) {
- return element.getAttribute(attribute);
- };
- /**
- * @param {?} element
- * @param {?} ns
- * @param {?} name
- * @return {?}
- */
- BrowserDomAdapter.prototype.getAttributeNS = function (element, ns, name) {
- return element.getAttributeNS(ns, name);
- };
- /**
- * @param {?} element
- * @param {?} name
- * @param {?} value
- * @return {?}
- */
- BrowserDomAdapter.prototype.setAttribute = function (element, name, value) { element.setAttribute(name, value); };
- /**
- * @param {?} element
- * @param {?} ns
- * @param {?} name
- * @param {?} value
- * @return {?}
- */
- BrowserDomAdapter.prototype.setAttributeNS = function (element, ns, name, value) {
- element.setAttributeNS(ns, name, value);
- };
- /**
- * @param {?} element
- * @param {?} attribute
- * @return {?}
- */
- BrowserDomAdapter.prototype.removeAttribute = function (element, attribute) { element.removeAttribute(attribute); };
- /**
- * @param {?} element
- * @param {?} ns
- * @param {?} name
- * @return {?}
- */
- BrowserDomAdapter.prototype.removeAttributeNS = function (element, ns, name) {
- element.removeAttributeNS(ns, name);
- };
- /**
- * @param {?} el
- * @return {?}
- */
- BrowserDomAdapter.prototype.templateAwareRoot = function (el) { return this.isTemplateElement(el) ? this.content(el) : el; };
- /**
- * @return {?}
- */
- BrowserDomAdapter.prototype.createHtmlDocument = function () {
- return document.implementation.createHTMLDocument('fakeTitle');
- };
- /**
- * @param {?} el
- * @return {?}
- */
- BrowserDomAdapter.prototype.getBoundingClientRect = function (el) {
- try {
- return el.getBoundingClientRect();
- }
- catch (e) {
- return { top: 0, bottom: 0, left: 0, right: 0, width: 0, height: 0 };
- }
- };
- /**
- * @param {?} doc
- * @return {?}
- */
- BrowserDomAdapter.prototype.getTitle = function (doc) { return document.title; };
- /**
- * @param {?} doc
- * @param {?} newTitle
- * @return {?}
- */
- BrowserDomAdapter.prototype.setTitle = function (doc, newTitle) { document.title = newTitle || ''; };
- /**
- * @param {?} n
- * @param {?} selector
- * @return {?}
- */
- BrowserDomAdapter.prototype.elementMatches = function (n, selector) {
- if (n instanceof HTMLElement) {
- return n.matches && n.matches(selector) ||
- n.msMatchesSelector && n.msMatchesSelector(selector) ||
- n.webkitMatchesSelector && n.webkitMatchesSelector(selector);
- }
- return false;
- };
- /**
- * @param {?} el
- * @return {?}
- */
- BrowserDomAdapter.prototype.isTemplateElement = function (el) {
- return el instanceof HTMLElement && el.nodeName == 'TEMPLATE';
- };
- /**
- * @param {?} node
- * @return {?}
- */
- BrowserDomAdapter.prototype.isTextNode = function (node) { return node.nodeType === Node.TEXT_NODE; };
- /**
- * @param {?} node
- * @return {?}
- */
- BrowserDomAdapter.prototype.isCommentNode = function (node) { return node.nodeType === Node.COMMENT_NODE; };
- /**
- * @param {?} node
- * @return {?}
- */
- BrowserDomAdapter.prototype.isElementNode = function (node) { return node.nodeType === Node.ELEMENT_NODE; };
- /**
- * @param {?} node
- * @return {?}
- */
- BrowserDomAdapter.prototype.hasShadowRoot = function (node) {
- return node.shadowRoot != null && node instanceof HTMLElement;
- };
- /**
- * @param {?} node
- * @return {?}
- */
- BrowserDomAdapter.prototype.isShadowRoot = function (node) { return node instanceof DocumentFragment; };
- /**
- * @param {?} node
- * @return {?}
- */
- BrowserDomAdapter.prototype.importIntoDoc = function (node) { return document.importNode(this.templateAwareRoot(node), true); };
- /**
- * @param {?} node
- * @return {?}
- */
- BrowserDomAdapter.prototype.adoptNode = function (node) { return document.adoptNode(node); };
- /**
- * @param {?} el
- * @return {?}
- */
- BrowserDomAdapter.prototype.getHref = function (el) { return ((el)).href; };
- /**
- * @param {?} event
- * @return {?}
- */
- BrowserDomAdapter.prototype.getEventKey = function (event) {
- var /** @type {?} */ key = event.key;
- if (key == null) {
- key = event.keyIdentifier;
- // keyIdentifier is defined in the old draft of DOM Level 3 Events implemented by Chrome and
- // Safari cf
- // http://www.w3.org/TR/2007/WD-DOM-Level-3-Events-20071221/events.html#Events-KeyboardEvents-Interfaces
- if (key == null) {
- return 'Unidentified';
- }
- if (key.startsWith('U+')) {
- key = String.fromCharCode(parseInt(key.substring(2), 16));
- if (event.location === DOM_KEY_LOCATION_NUMPAD && _chromeNumKeyPadMap.hasOwnProperty(key)) {
- // There is a bug in Chrome for numeric keypad keys:
- // https://code.google.com/p/chromium/issues/detail?id=155654
- // 1, 2, 3 ... are reported as A, B, C ...
- key = ((_chromeNumKeyPadMap))[key];
- }
- }
- }
- return _keyMap[key] || key;
- };
- /**
- * @param {?} doc
- * @param {?} target
- * @return {?}
- */
- BrowserDomAdapter.prototype.getGlobalEventTarget = function (doc, target) {
- if (target === 'window') {
- return window;
- }
- if (target === 'document') {
- return document;
- }
- if (target === 'body') {
- return document.body;
- }
- return null;
- };
- /**
- * @return {?}
- */
- BrowserDomAdapter.prototype.getHistory = function () { return window.history; };
- /**
- * @return {?}
- */
- BrowserDomAdapter.prototype.getLocation = function () { return window.location; };
- /**
- * @param {?} doc
- * @return {?}
- */
- BrowserDomAdapter.prototype.getBaseHref = function (doc) {
- var /** @type {?} */ href = getBaseElementHref();
- return href == null ? null : relativePath(href);
- };
- /**
- * @return {?}
- */
- BrowserDomAdapter.prototype.resetBaseElement = function () { baseElement = null; };
- /**
- * @return {?}
- */
- BrowserDomAdapter.prototype.getUserAgent = function () { return window.navigator.userAgent; };
- /**
- * @param {?} element
- * @param {?} name
- * @param {?} value
- * @return {?}
- */
- BrowserDomAdapter.prototype.setData = function (element, name, value) {
- this.setAttribute(element, 'data-' + name, value);
- };
- /**
- * @param {?} element
- * @param {?} name
- * @return {?}
- */
- BrowserDomAdapter.prototype.getData = function (element, name) {
- return this.getAttribute(element, 'data-' + name);
- };
- /**
- * @param {?} element
- * @return {?}
- */
- BrowserDomAdapter.prototype.getComputedStyle = function (element) { return getComputedStyle(element); };
- /**
- * @return {?}
- */
- BrowserDomAdapter.prototype.supportsWebAnimation = function () {
- return typeof ((Element)).prototype['animate'] === 'function';
- };
- /**
- * @return {?}
- */
- BrowserDomAdapter.prototype.performanceNow = function () {
- // performance.now() is not available in all browsers, see
- // http://caniuse.com/#search=performance.now
- return window.performance && window.performance.now ? window.performance.now() :
- new Date().getTime();
- };
- /**
- * @return {?}
- */
- BrowserDomAdapter.prototype.supportsCookies = function () { return true; };
- /**
- * @param {?} name
- * @return {?}
- */
- BrowserDomAdapter.prototype.getCookie = function (name) { return parseCookieValue(document.cookie, name); };
- /**
- * @param {?} name
- * @param {?} value
- * @return {?}
- */
- BrowserDomAdapter.prototype.setCookie = function (name, value) {
- // document.cookie is magical, assigning into it assigns/overrides one cookie value, but does
- // not clear other cookies.
- document.cookie = encodeURIComponent(name) + '=' + encodeURIComponent(value);
- };
- return BrowserDomAdapter;
- }(GenericBrowserDomAdapter));
- var baseElement = null;
- /**
- * @return {?}
- */
- function getBaseElementHref() {
- if (!baseElement) {
- baseElement = ((document.querySelector('base')));
- if (!baseElement) {
- return null;
- }
- }
- return baseElement.getAttribute('href');
- }
- // based on urlUtils.js in AngularJS 1
- var urlParsingNode;
- /**
- * @param {?} url
- * @return {?}
- */
- function relativePath(url) {
- if (!urlParsingNode) {
- urlParsingNode = document.createElement('a');
- }
- urlParsingNode.setAttribute('href', url);
- return (urlParsingNode.pathname.charAt(0) === '/') ? urlParsingNode.pathname :
- '/' + urlParsingNode.pathname;
- }
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * A DI Token representing the main rendering context. In a browser this is the DOM Document.
- *
- * Note: Document might not be available in the Application Context when Application and Rendering
- * Contexts are not the same (e.g. when running the application into a Web Worker).
- *
- * @deprecated import from `\@angular/common` instead.
- */
- var DOCUMENT$1 = DOCUMENT;
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- * @return {?}
- */
- function supportsState() {
- return !!window.history.pushState;
- }
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * `PlatformLocation` encapsulates all of the direct calls to platform APIs.
- * This class should not be used directly by an application developer. Instead, use
- * {\@link Location}.
- */
- var BrowserPlatformLocation = (function (_super) {
- __extends$1(BrowserPlatformLocation, _super);
- /**
- * @param {?} _doc
- */
- function BrowserPlatformLocation(_doc) {
- var _this = _super.call(this) || this;
- _this._doc = _doc;
- _this._init();
- return _this;
- }
- /**
- * \@internal
- * @return {?}
- */
- BrowserPlatformLocation.prototype._init = function () {
- this._location = getDOM().getLocation();
- this._history = getDOM().getHistory();
- };
- Object.defineProperty(BrowserPlatformLocation.prototype, "location", {
- /**
- * @return {?}
- */
- get: function () { return this._location; },
- enumerable: true,
- configurable: true
- });
- /**
- * @return {?}
- */
- BrowserPlatformLocation.prototype.getBaseHrefFromDOM = function () { return ((getDOM().getBaseHref(this._doc))); };
- /**
- * @param {?} fn
- * @return {?}
- */
- BrowserPlatformLocation.prototype.onPopState = function (fn) {
- getDOM().getGlobalEventTarget(this._doc, 'window').addEventListener('popstate', fn, false);
- };
- /**
- * @param {?} fn
- * @return {?}
- */
- BrowserPlatformLocation.prototype.onHashChange = function (fn) {
- getDOM().getGlobalEventTarget(this._doc, 'window').addEventListener('hashchange', fn, false);
- };
- Object.defineProperty(BrowserPlatformLocation.prototype, "pathname", {
- /**
- * @return {?}
- */
- get: function () { return this._location.pathname; },
- /**
- * @param {?} newPath
- * @return {?}
- */
- set: function (newPath) { this._location.pathname = newPath; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(BrowserPlatformLocation.prototype, "search", {
- /**
- * @return {?}
- */
- get: function () { return this._location.search; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(BrowserPlatformLocation.prototype, "hash", {
- /**
- * @return {?}
- */
- get: function () { return this._location.hash; },
- enumerable: true,
- configurable: true
- });
- /**
- * @param {?} state
- * @param {?} title
- * @param {?} url
- * @return {?}
- */
- BrowserPlatformLocation.prototype.pushState = function (state$$1, title, url) {
- if (supportsState()) {
- this._history.pushState(state$$1, title, url);
- }
- else {
- this._location.hash = url;
- }
- };
- /**
- * @param {?} state
- * @param {?} title
- * @param {?} url
- * @return {?}
- */
- BrowserPlatformLocation.prototype.replaceState = function (state$$1, title, url) {
- if (supportsState()) {
- this._history.replaceState(state$$1, title, url);
- }
- else {
- this._location.hash = url;
- }
- };
- /**
- * @return {?}
- */
- BrowserPlatformLocation.prototype.forward = function () { this._history.forward(); };
- /**
- * @return {?}
- */
- BrowserPlatformLocation.prototype.back = function () { this._history.back(); };
- return BrowserPlatformLocation;
- }(PlatformLocation));
- BrowserPlatformLocation.decorators = [
- { type: Injectable },
- ];
- /**
- * @nocollapse
- */
- BrowserPlatformLocation.ctorParameters = function () { return [
- { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT$1,] },] },
- ]; };
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * A service that can be used to get and add meta tags.
- *
- * \@experimental
- */
- var Meta = (function () {
- /**
- * @param {?} _doc
- */
- function Meta(_doc) {
- this._doc = _doc;
- this._dom = getDOM();
- }
- /**
- * @param {?} tag
- * @param {?=} forceCreation
- * @return {?}
- */
- Meta.prototype.addTag = function (tag, forceCreation) {
- if (forceCreation === void 0) { forceCreation = false; }
- if (!tag)
- return null;
- return this._getOrCreateElement(tag, forceCreation);
- };
- /**
- * @param {?} tags
- * @param {?=} forceCreation
- * @return {?}
- */
- Meta.prototype.addTags = function (tags, forceCreation) {
- var _this = this;
- if (forceCreation === void 0) { forceCreation = false; }
- if (!tags)
- return [];
- return tags.reduce(function (result, tag) {
- if (tag) {
- result.push(_this._getOrCreateElement(tag, forceCreation));
- }
- return result;
- }, []);
- };
- /**
- * @param {?} attrSelector
- * @return {?}
- */
- Meta.prototype.getTag = function (attrSelector) {
- if (!attrSelector)
- return null;
- return this._dom.querySelector(this._doc, "meta[" + attrSelector + "]");
- };
- /**
- * @param {?} attrSelector
- * @return {?}
- */
- Meta.prototype.getTags = function (attrSelector) {
- if (!attrSelector)
- return [];
- var /** @type {?} */ list /*NodeList*/ = this._dom.querySelectorAll(this._doc, "meta[" + attrSelector + "]");
- return list ? [].slice.call(list) : [];
- };
- /**
- * @param {?} tag
- * @param {?=} selector
- * @return {?}
- */
- Meta.prototype.updateTag = function (tag, selector) {
- if (!tag)
- return null;
- selector = selector || this._parseSelector(tag);
- var /** @type {?} */ meta = ((this.getTag(selector)));
- if (meta) {
- return this._setMetaElementAttributes(tag, meta);
- }
- return this._getOrCreateElement(tag, true);
- };
- /**
- * @param {?} attrSelector
- * @return {?}
- */
- Meta.prototype.removeTag = function (attrSelector) { this.removeTagElement(/** @type {?} */ ((this.getTag(attrSelector)))); };
- /**
- * @param {?} meta
- * @return {?}
- */
- Meta.prototype.removeTagElement = function (meta) {
- if (meta) {
- this._dom.remove(meta);
- }
- };
- /**
- * @param {?} meta
- * @param {?=} forceCreation
- * @return {?}
- */
- Meta.prototype._getOrCreateElement = function (meta, forceCreation) {
- if (forceCreation === void 0) { forceCreation = false; }
- if (!forceCreation) {
- var /** @type {?} */ selector = this._parseSelector(meta);
- var /** @type {?} */ elem = ((this.getTag(selector)));
- // It's allowed to have multiple elements with the same name so it's not enough to
- // just check that element with the same name already present on the page. We also need to
- // check if element has tag attributes
- if (elem && this._containsAttributes(meta, elem))
- return elem;
- }
- var /** @type {?} */ element = (this._dom.createElement('meta'));
- this._setMetaElementAttributes(meta, element);
- var /** @type {?} */ head = this._dom.getElementsByTagName(this._doc, 'head')[0];
- this._dom.appendChild(head, element);
- return element;
- };
- /**
- * @param {?} tag
- * @param {?} el
- * @return {?}
- */
- Meta.prototype._setMetaElementAttributes = function (tag, el) {
- var _this = this;
- Object.keys(tag).forEach(function (prop) { return _this._dom.setAttribute(el, prop, tag[prop]); });
- return el;
- };
- /**
- * @param {?} tag
- * @return {?}
- */
- Meta.prototype._parseSelector = function (tag) {
- var /** @type {?} */ attr = tag.name ? 'name' : 'property';
- return attr + "=\"" + tag[attr] + "\"";
- };
- /**
- * @param {?} tag
- * @param {?} elem
- * @return {?}
- */
- Meta.prototype._containsAttributes = function (tag, elem) {
- var _this = this;
- return Object.keys(tag).every(function (key) { return _this._dom.getAttribute(elem, key) === tag[key]; });
- };
- return Meta;
- }());
- Meta.decorators = [
- { type: Injectable },
- ];
- /**
- * @nocollapse
- */
- Meta.ctorParameters = function () { return [
- { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT$1,] },] },
- ]; };
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * An id that identifies a particular application being bootstrapped, that should
- * match across the client/server boundary.
- */
- var TRANSITION_ID = new InjectionToken('TRANSITION_ID');
- /**
- * @param {?} transitionId
- * @param {?} document
- * @param {?} injector
- * @return {?}
- */
- function appInitializerFactory(transitionId, document, injector) {
- return function () {
- // Wait for all application initializers to be completed before removing the styles set by
- // the server.
- injector.get(ApplicationInitStatus).donePromise.then(function () {
- var /** @type {?} */ dom = getDOM();
- var /** @type {?} */ styles = Array.prototype.slice.apply(dom.querySelectorAll(document, "style[ng-transition]"));
- styles.filter(function (el) { return dom.getAttribute(el, 'ng-transition') === transitionId; })
- .forEach(function (el) { return dom.remove(el); });
- });
- };
- }
- var SERVER_TRANSITION_PROVIDERS = [
- {
- provide: APP_INITIALIZER,
- useFactory: appInitializerFactory,
- deps: [TRANSITION_ID, DOCUMENT$1, Injector],
- multi: true
- },
- ];
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var BrowserGetTestability = (function () {
- function BrowserGetTestability() {
- }
- /**
- * @return {?}
- */
- BrowserGetTestability.init = function () { setTestabilityGetter(new BrowserGetTestability()); };
- /**
- * @param {?} registry
- * @return {?}
- */
- BrowserGetTestability.prototype.addToWindow = function (registry) {
- _global['getAngularTestability'] = function (elem, findInAncestors) {
- if (findInAncestors === void 0) { findInAncestors = true; }
- var /** @type {?} */ testability = registry.findTestabilityInTree(elem, findInAncestors);
- if (testability == null) {
- throw new Error('Could not find testability for element.');
- }
- return testability;
- };
- _global['getAllAngularTestabilities'] = function () { return registry.getAllTestabilities(); };
- _global['getAllAngularRootElements'] = function () { return registry.getAllRootElements(); };
- var /** @type {?} */ whenAllStable = function (callback /** TODO #9100 */) {
- var /** @type {?} */ testabilities = _global['getAllAngularTestabilities']();
- var /** @type {?} */ count = testabilities.length;
- var /** @type {?} */ didWork = false;
- var /** @type {?} */ decrement = function (didWork_ /** TODO #9100 */) {
- didWork = didWork || didWork_;
- count--;
- if (count == 0) {
- callback(didWork);
- }
- };
- testabilities.forEach(function (testability /** TODO #9100 */) {
- testability.whenStable(decrement);
- });
- };
- if (!_global['frameworkStabilizers']) {
- _global['frameworkStabilizers'] = [];
- }
- _global['frameworkStabilizers'].push(whenAllStable);
- };
- /**
- * @param {?} registry
- * @param {?} elem
- * @param {?} findInAncestors
- * @return {?}
- */
- BrowserGetTestability.prototype.findTestabilityInTree = function (registry, elem, findInAncestors) {
- if (elem == null) {
- return null;
- }
- var /** @type {?} */ t = registry.getTestability(elem);
- if (t != null) {
- return t;
- }
- else if (!findInAncestors) {
- return null;
- }
- if (getDOM().isShadowRoot(elem)) {
- return this.findTestabilityInTree(registry, getDOM().getHost(elem), true);
- }
- return this.findTestabilityInTree(registry, getDOM().parentElement(elem), true);
- };
- return BrowserGetTestability;
- }());
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * A service that can be used to get and set the title of a current HTML document.
- *
- * Since an Angular application can't be bootstrapped on the entire HTML document (`<html>` tag)
- * it is not possible to bind to the `text` property of the `HTMLTitleElement` elements
- * (representing the `<title>` tag). Instead, this service can be used to set and get the current
- * title value.
- *
- * \@experimental
- */
- var Title = (function () {
- /**
- * @param {?} _doc
- */
- function Title(_doc) {
- this._doc = _doc;
- }
- /**
- * Get the title of the current HTML document.
- * @return {?}
- */
- Title.prototype.getTitle = function () { return getDOM().getTitle(this._doc); };
- /**
- * Set the title of the current HTML document.
- * @param {?} newTitle
- * @return {?}
- */
- Title.prototype.setTitle = function (newTitle) { getDOM().setTitle(this._doc, newTitle); };
- return Title;
- }());
- Title.decorators = [
- { type: Injectable },
- ];
- /**
- * @nocollapse
- */
- Title.ctorParameters = function () { return [
- { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT$1,] },] },
- ]; };
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * @param {?} input
- * @return {?}
- */
- /**
- * @param {?} input
- * @return {?}
- */
- /**
- * Exports the value under a given `name` in the global property `ng`. For example `ng.probe` if
- * `name` is `'probe'`.
- * @param {?} name Name under which it will be exported. Keep in mind this will be a property of the
- * global `ng` object.
- * @param {?} value The value to export.
- * @return {?}
- */
- function exportNgVar(name, value) {
- if (!ng) {
- _global['ng'] = ng = ((_global['ng'])) || {};
- }
- ng[name] = value;
- }
- var ng;
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var CORE_TOKENS = {
- 'ApplicationRef': ApplicationRef,
- 'NgZone': NgZone,
- };
- var INSPECT_GLOBAL_NAME = 'probe';
- var CORE_TOKENS_GLOBAL_NAME = 'coreTokens';
- /**
- * Returns a {\@link DebugElement} for the given native DOM element, or
- * null if the given native element does not have an Angular view associated
- * with it.
- * @param {?} element
- * @return {?}
- */
- function inspectNativeElement(element) {
- return getDebugNode(element);
- }
- /**
- * Deprecated. Use the one from '\@angular/core'.
- * @deprecated
- */
- var NgProbeToken$1 = (function () {
- /**
- * @param {?} name
- * @param {?} token
- */
- function NgProbeToken$1(name, token) {
- this.name = name;
- this.token = token;
- }
- return NgProbeToken$1;
- }());
- /**
- * @param {?} extraTokens
- * @param {?} coreTokens
- * @return {?}
- */
- function _createNgProbe(extraTokens, coreTokens) {
- var /** @type {?} */ tokens = (extraTokens || []).concat(coreTokens || []);
- exportNgVar(INSPECT_GLOBAL_NAME, inspectNativeElement);
- exportNgVar(CORE_TOKENS_GLOBAL_NAME, Object.assign({}, CORE_TOKENS, _ngProbeTokensToMap(tokens || [])));
- return function () { return inspectNativeElement; };
- }
- /**
- * @param {?} tokens
- * @return {?}
- */
- function _ngProbeTokensToMap(tokens) {
- return tokens.reduce(function (prev, t) { return (prev[t.name] = t.token, prev); }, {});
- }
- /**
- * Providers which support debugging Angular applications (e.g. via `ng.probe`).
- */
- var ELEMENT_PROBE_PROVIDERS = [
- {
- provide: APP_INITIALIZER,
- useFactory: _createNgProbe,
- deps: [
- [NgProbeToken$1, new Optional()],
- [NgProbeToken, new Optional()],
- ],
- multi: true,
- },
- ];
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * \@stable
- */
- var EVENT_MANAGER_PLUGINS = new InjectionToken('EventManagerPlugins');
- /**
- * \@stable
- */
- var EventManager = (function () {
- /**
- * @param {?} plugins
- * @param {?} _zone
- */
- function EventManager(plugins, _zone) {
- var _this = this;
- this._zone = _zone;
- this._eventNameToPlugin = new Map();
- plugins.forEach(function (p) { return p.manager = _this; });
- this._plugins = plugins.slice().reverse();
- }
- /**
- * @param {?} element
- * @param {?} eventName
- * @param {?} handler
- * @return {?}
- */
- EventManager.prototype.addEventListener = function (element, eventName, handler) {
- var /** @type {?} */ plugin = this._findPluginFor(eventName);
- return plugin.addEventListener(element, eventName, handler);
- };
- /**
- * @param {?} target
- * @param {?} eventName
- * @param {?} handler
- * @return {?}
- */
- EventManager.prototype.addGlobalEventListener = function (target, eventName, handler) {
- var /** @type {?} */ plugin = this._findPluginFor(eventName);
- return plugin.addGlobalEventListener(target, eventName, handler);
- };
- /**
- * @return {?}
- */
- EventManager.prototype.getZone = function () { return this._zone; };
- /**
- * \@internal
- * @param {?} eventName
- * @return {?}
- */
- EventManager.prototype._findPluginFor = function (eventName) {
- var /** @type {?} */ plugin = this._eventNameToPlugin.get(eventName);
- if (plugin) {
- return plugin;
- }
- var /** @type {?} */ plugins = this._plugins;
- for (var /** @type {?} */ i = 0; i < plugins.length; i++) {
- var /** @type {?} */ plugin_1 = plugins[i];
- if (plugin_1.supports(eventName)) {
- this._eventNameToPlugin.set(eventName, plugin_1);
- return plugin_1;
- }
- }
- throw new Error("No event manager plugin found for event " + eventName);
- };
- return EventManager;
- }());
- EventManager.decorators = [
- { type: Injectable },
- ];
- /**
- * @nocollapse
- */
- EventManager.ctorParameters = function () { return [
- { type: Array, decorators: [{ type: Inject, args: [EVENT_MANAGER_PLUGINS,] },] },
- { type: NgZone, },
- ]; };
- /**
- * @abstract
- */
- var EventManagerPlugin = (function () {
- /**
- * @param {?} _doc
- */
- function EventManagerPlugin(_doc) {
- this._doc = _doc;
- }
- /**
- * @abstract
- * @param {?} eventName
- * @return {?}
- */
- EventManagerPlugin.prototype.supports = function (eventName) { };
- /**
- * @abstract
- * @param {?} element
- * @param {?} eventName
- * @param {?} handler
- * @return {?}
- */
- EventManagerPlugin.prototype.addEventListener = function (element, eventName, handler) { };
- /**
- * @param {?} element
- * @param {?} eventName
- * @param {?} handler
- * @return {?}
- */
- EventManagerPlugin.prototype.addGlobalEventListener = function (element, eventName, handler) {
- var /** @type {?} */ target = getDOM().getGlobalEventTarget(this._doc, element);
- if (!target) {
- throw new Error("Unsupported event target " + target + " for event " + eventName);
- }
- return this.addEventListener(target, eventName, handler);
- };
- return EventManagerPlugin;
- }());
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var SharedStylesHost = (function () {
- function SharedStylesHost() {
- /**
- * \@internal
- */
- this._stylesSet = new Set();
- }
- /**
- * @param {?} styles
- * @return {?}
- */
- SharedStylesHost.prototype.addStyles = function (styles) {
- var _this = this;
- var /** @type {?} */ additions = new Set();
- styles.forEach(function (style$$1) {
- if (!_this._stylesSet.has(style$$1)) {
- _this._stylesSet.add(style$$1);
- additions.add(style$$1);
- }
- });
- this.onStylesAdded(additions);
- };
- /**
- * @param {?} additions
- * @return {?}
- */
- SharedStylesHost.prototype.onStylesAdded = function (additions) { };
- /**
- * @return {?}
- */
- SharedStylesHost.prototype.getAllStyles = function () { return Array.from(this._stylesSet); };
- return SharedStylesHost;
- }());
- SharedStylesHost.decorators = [
- { type: Injectable },
- ];
- /**
- * @nocollapse
- */
- SharedStylesHost.ctorParameters = function () { return []; };
- var DomSharedStylesHost = (function (_super) {
- __extends$1(DomSharedStylesHost, _super);
- /**
- * @param {?} _doc
- */
- function DomSharedStylesHost(_doc) {
- var _this = _super.call(this) || this;
- _this._doc = _doc;
- _this._hostNodes = new Set();
- _this._styleNodes = new Set();
- _this._hostNodes.add(_doc.head);
- return _this;
- }
- /**
- * @param {?} styles
- * @param {?} host
- * @return {?}
- */
- DomSharedStylesHost.prototype._addStylesToHost = function (styles, host) {
- var _this = this;
- styles.forEach(function (style$$1) {
- var /** @type {?} */ styleEl = _this._doc.createElement('style');
- styleEl.textContent = style$$1;
- _this._styleNodes.add(host.appendChild(styleEl));
- });
- };
- /**
- * @param {?} hostNode
- * @return {?}
- */
- DomSharedStylesHost.prototype.addHost = function (hostNode) {
- this._addStylesToHost(this._stylesSet, hostNode);
- this._hostNodes.add(hostNode);
- };
- /**
- * @param {?} hostNode
- * @return {?}
- */
- DomSharedStylesHost.prototype.removeHost = function (hostNode) { this._hostNodes.delete(hostNode); };
- /**
- * @param {?} additions
- * @return {?}
- */
- DomSharedStylesHost.prototype.onStylesAdded = function (additions) {
- var _this = this;
- this._hostNodes.forEach(function (hostNode) { return _this._addStylesToHost(additions, hostNode); });
- };
- /**
- * @return {?}
- */
- DomSharedStylesHost.prototype.ngOnDestroy = function () { this._styleNodes.forEach(function (styleNode) { return getDOM().remove(styleNode); }); };
- return DomSharedStylesHost;
- }(SharedStylesHost));
- DomSharedStylesHost.decorators = [
- { type: Injectable },
- ];
- /**
- * @nocollapse
- */
- DomSharedStylesHost.ctorParameters = function () { return [
- { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT$1,] },] },
- ]; };
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var NAMESPACE_URIS = {
- 'svg': 'http://www.w3.org/2000/svg',
- 'xhtml': 'http://www.w3.org/1999/xhtml',
- 'xlink': 'http://www.w3.org/1999/xlink',
- 'xml': 'http://www.w3.org/XML/1998/namespace',
- 'xmlns': 'http://www.w3.org/2000/xmlns/',
- };
- var COMPONENT_REGEX = /%COMP%/g;
- var COMPONENT_VARIABLE = '%COMP%';
- var HOST_ATTR = "_nghost-" + COMPONENT_VARIABLE;
- var CONTENT_ATTR = "_ngcontent-" + COMPONENT_VARIABLE;
- /**
- * @param {?} componentShortId
- * @return {?}
- */
- function shimContentAttribute(componentShortId) {
- return CONTENT_ATTR.replace(COMPONENT_REGEX, componentShortId);
- }
- /**
- * @param {?} componentShortId
- * @return {?}
- */
- function shimHostAttribute(componentShortId) {
- return HOST_ATTR.replace(COMPONENT_REGEX, componentShortId);
- }
- /**
- * @param {?} compId
- * @param {?} styles
- * @param {?} target
- * @return {?}
- */
- function flattenStyles(compId, styles, target) {
- for (var /** @type {?} */ i = 0; i < styles.length; i++) {
- var /** @type {?} */ style$$1 = styles[i];
- if (Array.isArray(style$$1)) {
- flattenStyles(compId, style$$1, target);
- }
- else {
- style$$1 = style$$1.replace(COMPONENT_REGEX, compId);
- target.push(style$$1);
- }
- }
- return target;
- }
- /**
- * @param {?} eventHandler
- * @return {?}
- */
- function decoratePreventDefault(eventHandler) {
- return function (event) {
- var /** @type {?} */ allowDefaultBehavior = eventHandler(event);
- if (allowDefaultBehavior === false) {
- // TODO(tbosch): move preventDefault into event plugins...
- event.preventDefault();
- event.returnValue = false;
- }
- };
- }
- var DomRendererFactory2 = (function () {
- /**
- * @param {?} eventManager
- * @param {?} sharedStylesHost
- */
- function DomRendererFactory2(eventManager, sharedStylesHost) {
- this.eventManager = eventManager;
- this.sharedStylesHost = sharedStylesHost;
- this.rendererByCompId = new Map();
- this.defaultRenderer = new DefaultDomRenderer2(eventManager);
- }
- /**
- * @param {?} element
- * @param {?} type
- * @return {?}
- */
- DomRendererFactory2.prototype.createRenderer = function (element, type) {
- if (!element || !type) {
- return this.defaultRenderer;
- }
- switch (type.encapsulation) {
- case ViewEncapsulation.Emulated: {
- var /** @type {?} */ renderer = this.rendererByCompId.get(type.id);
- if (!renderer) {
- renderer =
- new EmulatedEncapsulationDomRenderer2(this.eventManager, this.sharedStylesHost, type);
- this.rendererByCompId.set(type.id, renderer);
- }
- ((renderer)).applyToHost(element);
- return renderer;
- }
- case ViewEncapsulation.Native:
- return new ShadowDomRenderer(this.eventManager, this.sharedStylesHost, element, type);
- default: {
- if (!this.rendererByCompId.has(type.id)) {
- var /** @type {?} */ styles = flattenStyles(type.id, type.styles, []);
- this.sharedStylesHost.addStyles(styles);
- this.rendererByCompId.set(type.id, this.defaultRenderer);
- }
- return this.defaultRenderer;
- }
- }
- };
- /**
- * @return {?}
- */
- DomRendererFactory2.prototype.begin = function () { };
- /**
- * @return {?}
- */
- DomRendererFactory2.prototype.end = function () { };
- return DomRendererFactory2;
- }());
- DomRendererFactory2.decorators = [
- { type: Injectable },
- ];
- /**
- * @nocollapse
- */
- DomRendererFactory2.ctorParameters = function () { return [
- { type: EventManager, },
- { type: DomSharedStylesHost, },
- ]; };
- var DefaultDomRenderer2 = (function () {
- /**
- * @param {?} eventManager
- */
- function DefaultDomRenderer2(eventManager) {
- this.eventManager = eventManager;
- this.data = Object.create(null);
- }
- /**
- * @return {?}
- */
- DefaultDomRenderer2.prototype.destroy = function () { };
- /**
- * @param {?} name
- * @param {?=} namespace
- * @return {?}
- */
- DefaultDomRenderer2.prototype.createElement = function (name, namespace) {
- if (namespace) {
- return document.createElementNS(NAMESPACE_URIS[namespace], name);
- }
- return document.createElement(name);
- };
- /**
- * @param {?} value
- * @return {?}
- */
- DefaultDomRenderer2.prototype.createComment = function (value) { return document.createComment(value); };
- /**
- * @param {?} value
- * @return {?}
- */
- DefaultDomRenderer2.prototype.createText = function (value) { return document.createTextNode(value); };
- /**
- * @param {?} parent
- * @param {?} newChild
- * @return {?}
- */
- DefaultDomRenderer2.prototype.appendChild = function (parent, newChild) { parent.appendChild(newChild); };
- /**
- * @param {?} parent
- * @param {?} newChild
- * @param {?} refChild
- * @return {?}
- */
- DefaultDomRenderer2.prototype.insertBefore = function (parent, newChild, refChild) {
- if (parent) {
- parent.insertBefore(newChild, refChild);
- }
- };
- /**
- * @param {?} parent
- * @param {?} oldChild
- * @return {?}
- */
- DefaultDomRenderer2.prototype.removeChild = function (parent, oldChild) {
- if (parent) {
- parent.removeChild(oldChild);
- }
- };
- /**
- * @param {?} selectorOrNode
- * @return {?}
- */
- DefaultDomRenderer2.prototype.selectRootElement = function (selectorOrNode) {
- var /** @type {?} */ el = typeof selectorOrNode === 'string' ? document.querySelector(selectorOrNode) :
- selectorOrNode;
- if (!el) {
- throw new Error("The selector \"" + selectorOrNode + "\" did not match any elements");
- }
- el.textContent = '';
- return el;
- };
- /**
- * @param {?} node
- * @return {?}
- */
- DefaultDomRenderer2.prototype.parentNode = function (node) { return node.parentNode; };
- /**
- * @param {?} node
- * @return {?}
- */
- DefaultDomRenderer2.prototype.nextSibling = function (node) { return node.nextSibling; };
- /**
- * @param {?} el
- * @param {?} name
- * @param {?} value
- * @param {?=} namespace
- * @return {?}
- */
- DefaultDomRenderer2.prototype.setAttribute = function (el, name, value, namespace) {
- if (namespace) {
- name = namespace + ":" + name;
- var /** @type {?} */ namespaceUri = NAMESPACE_URIS[namespace];
- if (namespaceUri) {
- el.setAttributeNS(namespaceUri, name, value);
- }
- else {
- el.setAttribute(name, value);
- }
- }
- else {
- el.setAttribute(name, value);
- }
- };
- /**
- * @param {?} el
- * @param {?} name
- * @param {?=} namespace
- * @return {?}
- */
- DefaultDomRenderer2.prototype.removeAttribute = function (el, name, namespace) {
- if (namespace) {
- var /** @type {?} */ namespaceUri = NAMESPACE_URIS[namespace];
- if (namespaceUri) {
- el.removeAttributeNS(namespaceUri, name);
- }
- else {
- el.removeAttribute(namespace + ":" + name);
- }
- }
- else {
- el.removeAttribute(name);
- }
- };
- /**
- * @param {?} el
- * @param {?} name
- * @return {?}
- */
- DefaultDomRenderer2.prototype.addClass = function (el, name) { el.classList.add(name); };
- /**
- * @param {?} el
- * @param {?} name
- * @return {?}
- */
- DefaultDomRenderer2.prototype.removeClass = function (el, name) { el.classList.remove(name); };
- /**
- * @param {?} el
- * @param {?} style
- * @param {?} value
- * @param {?} flags
- * @return {?}
- */
- DefaultDomRenderer2.prototype.setStyle = function (el, style$$1, value, flags) {
- if (flags & RendererStyleFlags2.DashCase) {
- el.style.setProperty(style$$1, value, !!(flags & RendererStyleFlags2.Important) ? 'important' : '');
- }
- else {
- el.style[style$$1] = value;
- }
- };
- /**
- * @param {?} el
- * @param {?} style
- * @param {?} flags
- * @return {?}
- */
- DefaultDomRenderer2.prototype.removeStyle = function (el, style$$1, flags) {
- if (flags & RendererStyleFlags2.DashCase) {
- el.style.removeProperty(style$$1);
- }
- else {
- // IE requires '' instead of null
- // see https://github.com/angular/angular/issues/7916
- el.style[style$$1] = '';
- }
- };
- /**
- * @param {?} el
- * @param {?} name
- * @param {?} value
- * @return {?}
- */
- DefaultDomRenderer2.prototype.setProperty = function (el, name, value) {
- checkNoSyntheticProp(name, 'property');
- el[name] = value;
- };
- /**
- * @param {?} node
- * @param {?} value
- * @return {?}
- */
- DefaultDomRenderer2.prototype.setValue = function (node, value) { node.nodeValue = value; };
- /**
- * @param {?} target
- * @param {?} event
- * @param {?} callback
- * @return {?}
- */
- DefaultDomRenderer2.prototype.listen = function (target, event, callback) {
- checkNoSyntheticProp(event, 'listener');
- if (typeof target === 'string') {
- return (this.eventManager.addGlobalEventListener(target, event, decoratePreventDefault(callback)));
- }
- return ((this.eventManager.addEventListener(target, event, decoratePreventDefault(callback))));
- };
- return DefaultDomRenderer2;
- }());
- var AT_CHARCODE = '@'.charCodeAt(0);
- /**
- * @param {?} name
- * @param {?} nameKind
- * @return {?}
- */
- function checkNoSyntheticProp(name, nameKind) {
- if (name.charCodeAt(0) === AT_CHARCODE) {
- throw new Error("Found the synthetic " + nameKind + " " + name + ". Please include either \"BrowserAnimationsModule\" or \"NoopAnimationsModule\" in your application.");
- }
- }
- var EmulatedEncapsulationDomRenderer2 = (function (_super) {
- __extends$1(EmulatedEncapsulationDomRenderer2, _super);
- /**
- * @param {?} eventManager
- * @param {?} sharedStylesHost
- * @param {?} component
- */
- function EmulatedEncapsulationDomRenderer2(eventManager, sharedStylesHost, component) {
- var _this = _super.call(this, eventManager) || this;
- _this.component = component;
- var styles = flattenStyles(component.id, component.styles, []);
- sharedStylesHost.addStyles(styles);
- _this.contentAttr = shimContentAttribute(component.id);
- _this.hostAttr = shimHostAttribute(component.id);
- return _this;
- }
- /**
- * @param {?} element
- * @return {?}
- */
- EmulatedEncapsulationDomRenderer2.prototype.applyToHost = function (element) { _super.prototype.setAttribute.call(this, element, this.hostAttr, ''); };
- /**
- * @param {?} parent
- * @param {?} name
- * @return {?}
- */
- EmulatedEncapsulationDomRenderer2.prototype.createElement = function (parent, name) {
- var /** @type {?} */ el = _super.prototype.createElement.call(this, parent, name);
- _super.prototype.setAttribute.call(this, el, this.contentAttr, '');
- return el;
- };
- return EmulatedEncapsulationDomRenderer2;
- }(DefaultDomRenderer2));
- var ShadowDomRenderer = (function (_super) {
- __extends$1(ShadowDomRenderer, _super);
- /**
- * @param {?} eventManager
- * @param {?} sharedStylesHost
- * @param {?} hostEl
- * @param {?} component
- */
- function ShadowDomRenderer(eventManager, sharedStylesHost, hostEl, component) {
- var _this = _super.call(this, eventManager) || this;
- _this.sharedStylesHost = sharedStylesHost;
- _this.hostEl = hostEl;
- _this.component = component;
- _this.shadowRoot = hostEl.createShadowRoot();
- _this.sharedStylesHost.addHost(_this.shadowRoot);
- var styles = flattenStyles(component.id, component.styles, []);
- for (var i = 0; i < styles.length; i++) {
- var styleEl = document.createElement('style');
- styleEl.textContent = styles[i];
- _this.shadowRoot.appendChild(styleEl);
- }
- return _this;
- }
- /**
- * @param {?} node
- * @return {?}
- */
- ShadowDomRenderer.prototype.nodeOrShadowRoot = function (node) { return node === this.hostEl ? this.shadowRoot : node; };
- /**
- * @return {?}
- */
- ShadowDomRenderer.prototype.destroy = function () { this.sharedStylesHost.removeHost(this.shadowRoot); };
- /**
- * @param {?} parent
- * @param {?} newChild
- * @return {?}
- */
- ShadowDomRenderer.prototype.appendChild = function (parent, newChild) {
- return _super.prototype.appendChild.call(this, this.nodeOrShadowRoot(parent), newChild);
- };
- /**
- * @param {?} parent
- * @param {?} newChild
- * @param {?} refChild
- * @return {?}
- */
- ShadowDomRenderer.prototype.insertBefore = function (parent, newChild, refChild) {
- return _super.prototype.insertBefore.call(this, this.nodeOrShadowRoot(parent), newChild, refChild);
- };
- /**
- * @param {?} parent
- * @param {?} oldChild
- * @return {?}
- */
- ShadowDomRenderer.prototype.removeChild = function (parent, oldChild) {
- return _super.prototype.removeChild.call(this, this.nodeOrShadowRoot(parent), oldChild);
- };
- /**
- * @param {?} node
- * @return {?}
- */
- ShadowDomRenderer.prototype.parentNode = function (node) {
- return this.nodeOrShadowRoot(_super.prototype.parentNode.call(this, this.nodeOrShadowRoot(node)));
- };
- return ShadowDomRenderer;
- }(DefaultDomRenderer2));
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var DomEventsPlugin = (function (_super) {
- __extends$1(DomEventsPlugin, _super);
- /**
- * @param {?} doc
- */
- function DomEventsPlugin(doc) {
- return _super.call(this, doc) || this;
- }
- /**
- * @param {?} eventName
- * @return {?}
- */
- DomEventsPlugin.prototype.supports = function (eventName) { return true; };
- /**
- * @param {?} element
- * @param {?} eventName
- * @param {?} handler
- * @return {?}
- */
- DomEventsPlugin.prototype.addEventListener = function (element, eventName, handler) {
- element.addEventListener(eventName, /** @type {?} */ (handler), false);
- return function () { return element.removeEventListener(eventName, /** @type {?} */ (handler), false); };
- };
- return DomEventsPlugin;
- }(EventManagerPlugin));
- DomEventsPlugin.decorators = [
- { type: Injectable },
- ];
- /**
- * @nocollapse
- */
- DomEventsPlugin.ctorParameters = function () { return [
- { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT$1,] },] },
- ]; };
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var EVENT_NAMES = {
- // pan
- 'pan': true,
- 'panstart': true,
- 'panmove': true,
- 'panend': true,
- 'pancancel': true,
- 'panleft': true,
- 'panright': true,
- 'panup': true,
- 'pandown': true,
- // pinch
- 'pinch': true,
- 'pinchstart': true,
- 'pinchmove': true,
- 'pinchend': true,
- 'pinchcancel': true,
- 'pinchin': true,
- 'pinchout': true,
- // press
- 'press': true,
- 'pressup': true,
- // rotate
- 'rotate': true,
- 'rotatestart': true,
- 'rotatemove': true,
- 'rotateend': true,
- 'rotatecancel': true,
- // swipe
- 'swipe': true,
- 'swipeleft': true,
- 'swiperight': true,
- 'swipeup': true,
- 'swipedown': true,
- // tap
- 'tap': true,
- };
- /**
- * A DI token that you can use to provide{\@link HammerGestureConfig} to Angular. Use it to configure
- * Hammer gestures.
- *
- * \@experimental
- */
- var HAMMER_GESTURE_CONFIG = new InjectionToken('HammerGestureConfig');
- /**
- * \@experimental
- */
- var HammerGestureConfig = (function () {
- function HammerGestureConfig() {
- this.events = [];
- this.overrides = {};
- }
- /**
- * @param {?} element
- * @return {?}
- */
- HammerGestureConfig.prototype.buildHammer = function (element) {
- var /** @type {?} */ mc = new Hammer(element);
- mc.get('pinch').set({ enable: true });
- mc.get('rotate').set({ enable: true });
- for (var /** @type {?} */ eventName in this.overrides) {
- mc.get(eventName).set(this.overrides[eventName]);
- }
- return mc;
- };
- return HammerGestureConfig;
- }());
- HammerGestureConfig.decorators = [
- { type: Injectable },
- ];
- /**
- * @nocollapse
- */
- HammerGestureConfig.ctorParameters = function () { return []; };
- var HammerGesturesPlugin = (function (_super) {
- __extends$1(HammerGesturesPlugin, _super);
- /**
- * @param {?} doc
- * @param {?} _config
- */
- function HammerGesturesPlugin(doc, _config) {
- var _this = _super.call(this, doc) || this;
- _this._config = _config;
- return _this;
- }
- /**
- * @param {?} eventName
- * @return {?}
- */
- HammerGesturesPlugin.prototype.supports = function (eventName) {
- if (!EVENT_NAMES.hasOwnProperty(eventName.toLowerCase()) && !this.isCustomEvent(eventName)) {
- return false;
- }
- if (!((window)).Hammer) {
- throw new Error("Hammer.js is not loaded, can not bind " + eventName + " event");
- }
- return true;
- };
- /**
- * @param {?} element
- * @param {?} eventName
- * @param {?} handler
- * @return {?}
- */
- HammerGesturesPlugin.prototype.addEventListener = function (element, eventName, handler) {
- var _this = this;
- var /** @type {?} */ zone = this.manager.getZone();
- eventName = eventName.toLowerCase();
- return zone.runOutsideAngular(function () {
- // Creating the manager bind events, must be done outside of angular
- var /** @type {?} */ mc = _this._config.buildHammer(element);
- var /** @type {?} */ callback = function (eventObj) {
- zone.runGuarded(function () { handler(eventObj); });
- };
- mc.on(eventName, callback);
- return function () { return mc.off(eventName, callback); };
- });
- };
- /**
- * @param {?} eventName
- * @return {?}
- */
- HammerGesturesPlugin.prototype.isCustomEvent = function (eventName) { return this._config.events.indexOf(eventName) > -1; };
- return HammerGesturesPlugin;
- }(EventManagerPlugin));
- HammerGesturesPlugin.decorators = [
- { type: Injectable },
- ];
- /**
- * @nocollapse
- */
- HammerGesturesPlugin.ctorParameters = function () { return [
- { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT$1,] },] },
- { type: HammerGestureConfig, decorators: [{ type: Inject, args: [HAMMER_GESTURE_CONFIG,] },] },
- ]; };
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var MODIFIER_KEYS = ['alt', 'control', 'meta', 'shift'];
- var MODIFIER_KEY_GETTERS = {
- 'alt': function (event) { return event.altKey; },
- 'control': function (event) { return event.ctrlKey; },
- 'meta': function (event) { return event.metaKey; },
- 'shift': function (event) { return event.shiftKey; }
- };
- /**
- * \@experimental
- */
- var KeyEventsPlugin = (function (_super) {
- __extends$1(KeyEventsPlugin, _super);
- /**
- * @param {?} doc
- */
- function KeyEventsPlugin(doc) {
- return _super.call(this, doc) || this;
- }
- /**
- * @param {?} eventName
- * @return {?}
- */
- KeyEventsPlugin.prototype.supports = function (eventName) { return KeyEventsPlugin.parseEventName(eventName) != null; };
- /**
- * @param {?} element
- * @param {?} eventName
- * @param {?} handler
- * @return {?}
- */
- KeyEventsPlugin.prototype.addEventListener = function (element, eventName, handler) {
- var /** @type {?} */ parsedEvent = ((KeyEventsPlugin.parseEventName(eventName)));
- var /** @type {?} */ outsideHandler = KeyEventsPlugin.eventCallback(parsedEvent['fullKey'], handler, this.manager.getZone());
- return this.manager.getZone().runOutsideAngular(function () {
- return getDOM().onAndCancel(element, parsedEvent['domEventName'], outsideHandler);
- });
- };
- /**
- * @param {?} eventName
- * @return {?}
- */
- KeyEventsPlugin.parseEventName = function (eventName) {
- var /** @type {?} */ parts = eventName.toLowerCase().split('.');
- var /** @type {?} */ domEventName = parts.shift();
- if ((parts.length === 0) || !(domEventName === 'keydown' || domEventName === 'keyup')) {
- return null;
- }
- var /** @type {?} */ key = KeyEventsPlugin._normalizeKey(/** @type {?} */ ((parts.pop())));
- var /** @type {?} */ fullKey = '';
- MODIFIER_KEYS.forEach(function (modifierName) {
- var /** @type {?} */ index = parts.indexOf(modifierName);
- if (index > -1) {
- parts.splice(index, 1);
- fullKey += modifierName + '.';
- }
- });
- fullKey += key;
- if (parts.length != 0 || key.length === 0) {
- // returning null instead of throwing to let another plugin process the event
- return null;
- }
- var /** @type {?} */ result = {};
- result['domEventName'] = domEventName;
- result['fullKey'] = fullKey;
- return result;
- };
- /**
- * @param {?} event
- * @return {?}
- */
- KeyEventsPlugin.getEventFullKey = function (event) {
- var /** @type {?} */ fullKey = '';
- var /** @type {?} */ key = getDOM().getEventKey(event);
- key = key.toLowerCase();
- if (key === ' ') {
- key = 'space'; // for readability
- }
- else if (key === '.') {
- key = 'dot'; // because '.' is used as a separator in event names
- }
- MODIFIER_KEYS.forEach(function (modifierName) {
- if (modifierName != key) {
- var /** @type {?} */ modifierGetter = MODIFIER_KEY_GETTERS[modifierName];
- if (modifierGetter(event)) {
- fullKey += modifierName + '.';
- }
- }
- });
- fullKey += key;
- return fullKey;
- };
- /**
- * @param {?} fullKey
- * @param {?} handler
- * @param {?} zone
- * @return {?}
- */
- KeyEventsPlugin.eventCallback = function (fullKey, handler, zone) {
- return function (event /** TODO #9100 */) {
- if (KeyEventsPlugin.getEventFullKey(event) === fullKey) {
- zone.runGuarded(function () { return handler(event); });
- }
- };
- };
- /**
- * \@internal
- * @param {?} keyName
- * @return {?}
- */
- KeyEventsPlugin._normalizeKey = function (keyName) {
- // TODO: switch to a Map if the mapping grows too much
- switch (keyName) {
- case 'esc':
- return 'escape';
- default:
- return keyName;
- }
- };
- return KeyEventsPlugin;
- }(EventManagerPlugin));
- KeyEventsPlugin.decorators = [
- { type: Injectable },
- ];
- /**
- * @nocollapse
- */
- KeyEventsPlugin.ctorParameters = function () { return [
- { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT$1,] },] },
- ]; };
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * A pattern that recognizes a commonly useful subset of URLs that are safe.
- *
- * This regular expression matches a subset of URLs that will not cause script
- * execution if used in URL context within a HTML document. Specifically, this
- * regular expression matches if (comment from here on and regex copied from
- * Soy's EscapingConventions):
- * (1) Either a protocol in a whitelist (http, https, mailto or ftp).
- * (2) or no protocol. A protocol must be followed by a colon. The below
- * allows that by allowing colons only after one of the characters [/?#].
- * A colon after a hash (#) must be in the fragment.
- * Otherwise, a colon after a (?) must be in a query.
- * Otherwise, a colon after a single solidus (/) must be in a path.
- * Otherwise, a colon after a double solidus (//) must be in the authority
- * (before port).
- *
- * The pattern disallows &, used in HTML entity declarations before
- * one of the characters in [/?#]. This disallows HTML entities used in the
- * protocol name, which should never happen, e.g. "http" for "http".
- * It also disallows HTML entities in the first path part of a relative path,
- * e.g. "foo<bar/baz". Our existing escaping functions should not produce
- * that. More importantly, it disallows masking of a colon,
- * e.g. "javascript:...".
- *
- * This regular expression was taken from the Closure sanitization library.
- */
- var SAFE_URL_PATTERN = /^(?:(?:https?|mailto|ftp|tel|file):|[^&:/?#]*(?:[/?#]|$))/gi;
- /**
- * A pattern that matches safe data URLs. Only matches image, video and audio types.
- */
- var DATA_URL_PATTERN = /^data:(?:image\/(?:bmp|gif|jpeg|jpg|png|tiff|webp)|video\/(?:mpeg|mp4|ogg|webm)|audio\/(?:mp3|oga|ogg|opus));base64,[a-z0-9+\/]+=*$/i;
- /**
- * @param {?} url
- * @return {?}
- */
- function sanitizeUrl(url) {
- url = String(url);
- if (url.match(SAFE_URL_PATTERN) || url.match(DATA_URL_PATTERN))
- return url;
- if (isDevMode()) {
- getDOM().log("WARNING: sanitizing unsafe URL value " + url + " (see http://g.co/ng/security#xss)");
- }
- return 'unsafe:' + url;
- }
- /**
- * @param {?} srcset
- * @return {?}
- */
- function sanitizeSrcset(srcset) {
- srcset = String(srcset);
- return srcset.split(',').map(function (srcset) { return sanitizeUrl(srcset.trim()); }).join(', ');
- }
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * A <body> element that can be safely used to parse untrusted HTML. Lazily initialized below.
- */
- var inertElement = null;
- /**
- * Lazily initialized to make sure the DOM adapter gets set before use.
- */
- var DOM = null;
- /**
- * Returns an HTML element that is guaranteed to not execute code when creating elements in it.
- * @return {?}
- */
- function getInertElement() {
- if (inertElement)
- return inertElement;
- DOM = getDOM();
- // Prefer using <template> element if supported.
- var /** @type {?} */ templateEl = DOM.createElement('template');
- if ('content' in templateEl)
- return templateEl;
- var /** @type {?} */ doc = DOM.createHtmlDocument();
- inertElement = DOM.querySelector(doc, 'body');
- if (inertElement == null) {
- // usually there should be only one body element in the document, but IE doesn't have any, so we
- // need to create one.
- var /** @type {?} */ html = DOM.createElement('html', doc);
- inertElement = DOM.createElement('body', doc);
- DOM.appendChild(html, inertElement);
- DOM.appendChild(doc, html);
- }
- return inertElement;
- }
- /**
- * @param {?} tags
- * @return {?}
- */
- function tagSet(tags) {
- var /** @type {?} */ res = {};
- for (var _i = 0, _a = tags.split(','); _i < _a.length; _i++) {
- var t = _a[_i];
- res[t] = true;
- }
- return res;
- }
- /**
- * @param {...?} sets
- * @return {?}
- */
- function merge$3() {
- var sets = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- sets[_i] = arguments[_i];
- }
- var /** @type {?} */ res = {};
- for (var _a = 0, sets_1 = sets; _a < sets_1.length; _a++) {
- var s = sets_1[_a];
- for (var /** @type {?} */ v in s) {
- if (s.hasOwnProperty(v))
- res[v] = true;
- }
- }
- return res;
- }
- // Good source of info about elements and attributes
- // http://dev.w3.org/html5/spec/Overview.html#semantics
- // http://simon.html5.org/html-elements
- // Safe Void Elements - HTML5
- // http://dev.w3.org/html5/spec/Overview.html#void-elements
- var VOID_ELEMENTS = tagSet('area,br,col,hr,img,wbr');
- // Elements that you can, intentionally, leave open (and which close themselves)
- // http://dev.w3.org/html5/spec/Overview.html#optional-tags
- var OPTIONAL_END_TAG_BLOCK_ELEMENTS = tagSet('colgroup,dd,dt,li,p,tbody,td,tfoot,th,thead,tr');
- var OPTIONAL_END_TAG_INLINE_ELEMENTS = tagSet('rp,rt');
- var OPTIONAL_END_TAG_ELEMENTS = merge$3(OPTIONAL_END_TAG_INLINE_ELEMENTS, OPTIONAL_END_TAG_BLOCK_ELEMENTS);
- // Safe Block Elements - HTML5
- var BLOCK_ELEMENTS = merge$3(OPTIONAL_END_TAG_BLOCK_ELEMENTS, tagSet('address,article,' +
- 'aside,blockquote,caption,center,del,details,dialog,dir,div,dl,figure,figcaption,footer,h1,h2,h3,h4,h5,' +
- 'h6,header,hgroup,hr,ins,main,map,menu,nav,ol,pre,section,summary,table,ul'));
- // Inline Elements - HTML5
- var INLINE_ELEMENTS = merge$3(OPTIONAL_END_TAG_INLINE_ELEMENTS, tagSet('a,abbr,acronym,audio,b,' +
- 'bdi,bdo,big,br,cite,code,del,dfn,em,font,i,img,ins,kbd,label,map,mark,picture,q,ruby,rp,rt,s,' +
- 'samp,small,source,span,strike,strong,sub,sup,time,track,tt,u,var,video'));
- var VALID_ELEMENTS = merge$3(VOID_ELEMENTS, BLOCK_ELEMENTS, INLINE_ELEMENTS, OPTIONAL_END_TAG_ELEMENTS);
- // Attributes that have href and hence need to be sanitized
- var URI_ATTRS = tagSet('background,cite,href,itemtype,longdesc,poster,src,xlink:href');
- // Attributes that have special href set hence need to be sanitized
- var SRCSET_ATTRS = tagSet('srcset');
- var HTML_ATTRS = tagSet('abbr,accesskey,align,alt,autoplay,axis,bgcolor,border,cellpadding,cellspacing,class,clear,color,cols,colspan,' +
- 'compact,controls,coords,datetime,default,dir,download,face,headers,height,hidden,hreflang,hspace,' +
- 'ismap,itemscope,itemprop,kind,label,lang,language,loop,media,muted,nohref,nowrap,open,preload,rel,rev,role,rows,rowspan,rules,' +
- 'scope,scrolling,shape,size,sizes,span,srclang,start,summary,tabindex,target,title,translate,type,usemap,' +
- 'valign,value,vspace,width');
- // NB: This currently consciously doesn't support SVG. SVG sanitization has had several security
- // issues in the past, so it seems safer to leave it out if possible. If support for binding SVG via
- // innerHTML is required, SVG attributes should be added here.
- // NB: Sanitization does not allow <form> elements or other active elements (<button> etc). Those
- // can be sanitized, but they increase security surface area without a legitimate use case, so they
- // are left out here.
- var VALID_ATTRS = merge$3(URI_ATTRS, SRCSET_ATTRS, HTML_ATTRS);
- /**
- * SanitizingHtmlSerializer serializes a DOM fragment, stripping out any unsafe elements and unsafe
- * attributes.
- */
- var SanitizingHtmlSerializer = (function () {
- function SanitizingHtmlSerializer() {
- this.sanitizedSomething = false;
- this.buf = [];
- }
- /**
- * @param {?} el
- * @return {?}
- */
- SanitizingHtmlSerializer.prototype.sanitizeChildren = function (el) {
- // This cannot use a TreeWalker, as it has to run on Angular's various DOM adapters.
- // However this code never accesses properties off of `document` before deleting its contents
- // again, so it shouldn't be vulnerable to DOM clobbering.
- var /** @type {?} */ current = ((el.firstChild));
- while (current) {
- if (DOM.isElementNode(current)) {
- this.startElement(/** @type {?} */ (current));
- }
- else if (DOM.isTextNode(current)) {
- this.chars(/** @type {?} */ ((DOM.nodeValue(current))));
- }
- else {
- // Strip non-element, non-text nodes.
- this.sanitizedSomething = true;
- }
- if (DOM.firstChild(current)) {
- current = ((DOM.firstChild(current)));
- continue;
- }
- while (current) {
- // Leaving the element. Walk up and to the right, closing tags as we go.
- if (DOM.isElementNode(current)) {
- this.endElement(/** @type {?} */ (current));
- }
- var /** @type {?} */ next = checkClobberedElement(current, /** @type {?} */ ((DOM.nextSibling(current))));
- if (next) {
- current = next;
- break;
- }
- current = checkClobberedElement(current, /** @type {?} */ ((DOM.parentElement(current))));
- }
- }
- return this.buf.join('');
- };
- /**
- * @param {?} element
- * @return {?}
- */
- SanitizingHtmlSerializer.prototype.startElement = function (element) {
- var _this = this;
- var /** @type {?} */ tagName = DOM.nodeName(element).toLowerCase();
- if (!VALID_ELEMENTS.hasOwnProperty(tagName)) {
- this.sanitizedSomething = true;
- return;
- }
- this.buf.push('<');
- this.buf.push(tagName);
- DOM.attributeMap(element).forEach(function (value, attrName) {
- var /** @type {?} */ lower = attrName.toLowerCase();
- if (!VALID_ATTRS.hasOwnProperty(lower)) {
- _this.sanitizedSomething = true;
- return;
- }
- // TODO(martinprobst): Special case image URIs for data:image/...
- if (URI_ATTRS[lower])
- value = sanitizeUrl(value);
- if (SRCSET_ATTRS[lower])
- value = sanitizeSrcset(value);
- _this.buf.push(' ');
- _this.buf.push(attrName);
- _this.buf.push('="');
- _this.buf.push(encodeEntities(value));
- _this.buf.push('"');
- });
- this.buf.push('>');
- };
- /**
- * @param {?} current
- * @return {?}
- */
- SanitizingHtmlSerializer.prototype.endElement = function (current) {
- var /** @type {?} */ tagName = DOM.nodeName(current).toLowerCase();
- if (VALID_ELEMENTS.hasOwnProperty(tagName) && !VOID_ELEMENTS.hasOwnProperty(tagName)) {
- this.buf.push('</');
- this.buf.push(tagName);
- this.buf.push('>');
- }
- };
- /**
- * @param {?} chars
- * @return {?}
- */
- SanitizingHtmlSerializer.prototype.chars = function (chars) { this.buf.push(encodeEntities(chars)); };
- return SanitizingHtmlSerializer;
- }());
- /**
- * @param {?} node
- * @param {?} nextNode
- * @return {?}
- */
- function checkClobberedElement(node, nextNode) {
- if (nextNode && DOM.contains(node, nextNode)) {
- throw new Error("Failed to sanitize html because the element is clobbered: " + DOM.getOuterHTML(node));
- }
- return nextNode;
- }
- // Regular Expressions for parsing tags and attributes
- var SURROGATE_PAIR_REGEXP = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
- // ! to ~ is the ASCII range.
- var NON_ALPHANUMERIC_REGEXP = /([^\#-~ |!])/g;
- /**
- * Escapes all potentially dangerous characters, so that the
- * resulting string can be safely inserted into attribute or
- * element text.
- * @param {?} value
- * @return {?}
- */
- function encodeEntities(value) {
- return value.replace(/&/g, '&')
- .replace(SURROGATE_PAIR_REGEXP, function (match) {
- var /** @type {?} */ hi = match.charCodeAt(0);
- var /** @type {?} */ low = match.charCodeAt(1);
- return '&#' + (((hi - 0xD800) * 0x400) + (low - 0xDC00) + 0x10000) + ';';
- })
- .replace(NON_ALPHANUMERIC_REGEXP, function (match) { return '&#' + match.charCodeAt(0) + ';'; })
- .replace(/</g, '<')
- .replace(/>/g, '>');
- }
- /**
- * When IE9-11 comes across an unknown namespaced attribute e.g. 'xlink:foo' it adds 'xmlns:ns1'
- * attribute to declare ns1 namespace and prefixes the attribute with 'ns1' (e.g. 'ns1:xlink:foo').
- *
- * This is undesirable since we don't want to allow any of these custom attributes. This method
- * strips them all.
- * @param {?} el
- * @return {?}
- */
- function stripCustomNsAttrs(el) {
- DOM.attributeMap(el).forEach(function (_, attrName) {
- if (attrName === 'xmlns:ns1' || attrName.indexOf('ns1:') === 0) {
- DOM.removeAttribute(el, attrName);
- }
- });
- for (var _i = 0, _a = DOM.childNodesAsList(el); _i < _a.length; _i++) {
- var n = _a[_i];
- if (DOM.isElementNode(n))
- stripCustomNsAttrs(/** @type {?} */ (n));
- }
- }
- /**
- * Sanitizes the given unsafe, untrusted HTML fragment, and returns HTML text that is safe to add to
- * the DOM in a browser environment.
- * @param {?} defaultDoc
- * @param {?} unsafeHtmlInput
- * @return {?}
- */
- function sanitizeHtml(defaultDoc, unsafeHtmlInput) {
- try {
- var /** @type {?} */ containerEl = getInertElement();
- // Make sure unsafeHtml is actually a string (TypeScript types are not enforced at runtime).
- var /** @type {?} */ unsafeHtml = unsafeHtmlInput ? String(unsafeHtmlInput) : '';
- // mXSS protection. Repeatedly parse the document to make sure it stabilizes, so that a browser
- // trying to auto-correct incorrect HTML cannot cause formerly inert HTML to become dangerous.
- var /** @type {?} */ mXSSAttempts = 5;
- var /** @type {?} */ parsedHtml = unsafeHtml;
- do {
- if (mXSSAttempts === 0) {
- throw new Error('Failed to sanitize html because the input is unstable');
- }
- mXSSAttempts--;
- unsafeHtml = parsedHtml;
- DOM.setInnerHTML(containerEl, unsafeHtml);
- if (defaultDoc.documentMode) {
- // strip custom-namespaced attributes on IE<=11
- stripCustomNsAttrs(containerEl);
- }
- parsedHtml = DOM.getInnerHTML(containerEl);
- } while (unsafeHtml !== parsedHtml);
- var /** @type {?} */ sanitizer = new SanitizingHtmlSerializer();
- var /** @type {?} */ safeHtml = sanitizer.sanitizeChildren(DOM.getTemplateContent(containerEl) || containerEl);
- // Clear out the body element.
- var /** @type {?} */ parent = DOM.getTemplateContent(containerEl) || containerEl;
- for (var _i = 0, _a = DOM.childNodesAsList(parent); _i < _a.length; _i++) {
- var child = _a[_i];
- DOM.removeChild(parent, child);
- }
- if (isDevMode() && sanitizer.sanitizedSomething) {
- DOM.log('WARNING: sanitizing HTML stripped some content (see http://g.co/ng/security#xss).');
- }
- return safeHtml;
- }
- catch (e) {
- // In case anything goes wrong, clear out inertElement to reset the entire DOM structure.
- inertElement = null;
- throw e;
- }
- }
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * Regular expression for safe style values.
- *
- * Quotes (" and ') are allowed, but a check must be done elsewhere to ensure they're balanced.
- *
- * ',' allows multiple values to be assigned to the same property (e.g. background-attachment or
- * font-family) and hence could allow multiple values to get injected, but that should pose no risk
- * of XSS.
- *
- * The function expression checks only for XSS safety, not for CSS validity.
- *
- * This regular expression was taken from the Closure sanitization library, and augmented for
- * transformation values.
- */
- var VALUES = '[-,."\'%_!# a-zA-Z0-9]+';
- var TRANSFORMATION_FNS = '(?:matrix|translate|scale|rotate|skew|perspective)(?:X|Y|3d)?';
- var COLOR_FNS = '(?:rgb|hsl)a?';
- var GRADIENTS = '(?:repeating-)?(?:linear|radial)-gradient';
- var CSS3_FNS = '(?:calc|attr)';
- var FN_ARGS = '\\([-0-9.%, #a-zA-Z]+\\)';
- var SAFE_STYLE_VALUE = new RegExp("^(" + VALUES + "|" +
- ("(?:" + TRANSFORMATION_FNS + "|" + COLOR_FNS + "|" + GRADIENTS + "|" + CSS3_FNS + ")") +
- (FN_ARGS + ")$"), 'g');
- /**
- * Matches a `url(...)` value with an arbitrary argument as long as it does
- * not contain parentheses.
- *
- * The URL value still needs to be sanitized separately.
- *
- * `url(...)` values are a very common use case, e.g. for `background-image`. With carefully crafted
- * CSS style rules, it is possible to construct an information leak with `url` values in CSS, e.g.
- * by observing whether scroll bars are displayed, or character ranges used by a font face
- * definition.
- *
- * Angular only allows binding CSS values (as opposed to entire CSS rules), so it is unlikely that
- * binding a URL value without further cooperation from the page will cause an information leak, and
- * if so, it is just a leak, not a full blown XSS vulnerability.
- *
- * Given the common use case, low likelihood of attack vector, and low impact of an attack, this
- * code is permissive and allows URLs that sanitize otherwise.
- */
- var URL_RE = /^url\(([^)]+)\)$/;
- /**
- * Checks that quotes (" and ') are properly balanced inside a string. Assumes
- * that neither escape (\) nor any other character that could result in
- * breaking out of a string parsing context are allowed;
- * see http://www.w3.org/TR/css3-syntax/#string-token-diagram.
- *
- * This code was taken from the Closure sanitization library.
- * @param {?} value
- * @return {?}
- */
- function hasBalancedQuotes(value) {
- var /** @type {?} */ outsideSingle = true;
- var /** @type {?} */ outsideDouble = true;
- for (var /** @type {?} */ i = 0; i < value.length; i++) {
- var /** @type {?} */ c = value.charAt(i);
- if (c === '\'' && outsideDouble) {
- outsideSingle = !outsideSingle;
- }
- else if (c === '"' && outsideSingle) {
- outsideDouble = !outsideDouble;
- }
- }
- return outsideSingle && outsideDouble;
- }
- /**
- * Sanitizes the given untrusted CSS style property value (i.e. not an entire object, just a single
- * value) and returns a value that is safe to use in a browser environment.
- * @param {?} value
- * @return {?}
- */
- function sanitizeStyle(value) {
- value = String(value).trim(); // Make sure it's actually a string.
- if (!value)
- return '';
- // Single url(...) values are supported, but only for URLs that sanitize cleanly. See above for
- // reasoning behind this.
- var /** @type {?} */ urlMatch = value.match(URL_RE);
- if ((urlMatch && sanitizeUrl(urlMatch[1]) === urlMatch[1]) ||
- value.match(SAFE_STYLE_VALUE) && hasBalancedQuotes(value)) {
- return value; // Safe style values.
- }
- if (isDevMode()) {
- getDOM().log("WARNING: sanitizing unsafe style value " + value + " (see http://g.co/ng/security#xss).");
- }
- return 'unsafe';
- }
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * DomSanitizer helps preventing Cross Site Scripting Security bugs (XSS) by sanitizing
- * values to be safe to use in the different DOM contexts.
- *
- * For example, when binding a URL in an `<a [href]="someValue">` hyperlink, `someValue` will be
- * sanitized so that an attacker cannot inject e.g. a `javascript:` URL that would execute code on
- * the website.
- *
- * In specific situations, it might be necessary to disable sanitization, for example if the
- * application genuinely needs to produce a `javascript:` style link with a dynamic value in it.
- * Users can bypass security by constructing a value with one of the `bypassSecurityTrust...`
- * methods, and then binding to that value from the template.
- *
- * These situations should be very rare, and extraordinary care must be taken to avoid creating a
- * Cross Site Scripting (XSS) security bug!
- *
- * When using `bypassSecurityTrust...`, make sure to call the method as early as possible and as
- * close as possible to the source of the value, to make it easy to verify no security bug is
- * created by its use.
- *
- * It is not required (and not recommended) to bypass security if the value is safe, e.g. a URL that
- * does not start with a suspicious protocol, or an HTML snippet that does not contain dangerous
- * code. The sanitizer leaves safe values intact.
- *
- * \@security Calling any of the `bypassSecurityTrust...` APIs disables Angular's built-in
- * sanitization for the value passed in. Carefully check and audit all values and code paths going
- * into this call. Make sure any user data is appropriately escaped for this security context.
- * For more detail, see the [Security Guide](http://g.co/ng/security).
- *
- * \@stable
- * @abstract
- */
- var DomSanitizer = (function () {
- function DomSanitizer() {
- }
- /**
- * Sanitizes a value for use in the given SecurityContext.
- *
- * If value is trusted for the context, this method will unwrap the contained safe value and use
- * it directly. Otherwise, value will be sanitized to be safe in the given context, for example
- * by replacing URLs that have an unsafe protocol part (such as `javascript:`). The implementation
- * is responsible to make sure that the value can definitely be safely used in the given context.
- * @abstract
- * @param {?} context
- * @param {?} value
- * @return {?}
- */
- DomSanitizer.prototype.sanitize = function (context, value) { };
- /**
- * Bypass security and trust the given value to be safe HTML. Only use this when the bound HTML
- * is unsafe (e.g. contains `<script>` tags) and the code should be executed. The sanitizer will
- * leave safe HTML intact, so in most situations this method should not be used.
- *
- * **WARNING:** calling this method with untrusted user data exposes your application to XSS
- * security risks!
- * @abstract
- * @param {?} value
- * @return {?}
- */
- DomSanitizer.prototype.bypassSecurityTrustHtml = function (value) { };
- /**
- * Bypass security and trust the given value to be safe style value (CSS).
- *
- * **WARNING:** calling this method with untrusted user data exposes your application to XSS
- * security risks!
- * @abstract
- * @param {?} value
- * @return {?}
- */
- DomSanitizer.prototype.bypassSecurityTrustStyle = function (value) { };
- /**
- * Bypass security and trust the given value to be safe JavaScript.
- *
- * **WARNING:** calling this method with untrusted user data exposes your application to XSS
- * security risks!
- * @abstract
- * @param {?} value
- * @return {?}
- */
- DomSanitizer.prototype.bypassSecurityTrustScript = function (value) { };
- /**
- * Bypass security and trust the given value to be a safe style URL, i.e. a value that can be used
- * in hyperlinks or `<img src>`.
- *
- * **WARNING:** calling this method with untrusted user data exposes your application to XSS
- * security risks!
- * @abstract
- * @param {?} value
- * @return {?}
- */
- DomSanitizer.prototype.bypassSecurityTrustUrl = function (value) { };
- /**
- * Bypass security and trust the given value to be a safe resource URL, i.e. a location that may
- * be used to load executable code from, like `<script src>`, or `<iframe src>`.
- *
- * **WARNING:** calling this method with untrusted user data exposes your application to XSS
- * security risks!
- * @abstract
- * @param {?} value
- * @return {?}
- */
- DomSanitizer.prototype.bypassSecurityTrustResourceUrl = function (value) { };
- return DomSanitizer;
- }());
- var DomSanitizerImpl = (function (_super) {
- __extends$1(DomSanitizerImpl, _super);
- /**
- * @param {?} _doc
- */
- function DomSanitizerImpl(_doc) {
- var _this = _super.call(this) || this;
- _this._doc = _doc;
- return _this;
- }
- /**
- * @param {?} ctx
- * @param {?} value
- * @return {?}
- */
- DomSanitizerImpl.prototype.sanitize = function (ctx, value) {
- if (value == null)
- return null;
- switch (ctx) {
- case SecurityContext.NONE:
- return (value);
- case SecurityContext.HTML:
- if (value instanceof SafeHtmlImpl)
- return value.changingThisBreaksApplicationSecurity;
- this.checkNotSafeValue(value, 'HTML');
- return sanitizeHtml(this._doc, String(value));
- case SecurityContext.STYLE:
- if (value instanceof SafeStyleImpl)
- return value.changingThisBreaksApplicationSecurity;
- this.checkNotSafeValue(value, 'Style');
- return sanitizeStyle(/** @type {?} */ (value));
- case SecurityContext.SCRIPT:
- if (value instanceof SafeScriptImpl)
- return value.changingThisBreaksApplicationSecurity;
- this.checkNotSafeValue(value, 'Script');
- throw new Error('unsafe value used in a script context');
- case SecurityContext.URL:
- if (value instanceof SafeResourceUrlImpl || value instanceof SafeUrlImpl) {
- // Allow resource URLs in URL contexts, they are strictly more trusted.
- return value.changingThisBreaksApplicationSecurity;
- }
- this.checkNotSafeValue(value, 'URL');
- return sanitizeUrl(String(value));
- case SecurityContext.RESOURCE_URL:
- if (value instanceof SafeResourceUrlImpl) {
- return value.changingThisBreaksApplicationSecurity;
- }
- this.checkNotSafeValue(value, 'ResourceURL');
- throw new Error('unsafe value used in a resource URL context (see http://g.co/ng/security#xss)');
- default:
- throw new Error("Unexpected SecurityContext " + ctx + " (see http://g.co/ng/security#xss)");
- }
- };
- /**
- * @param {?} value
- * @param {?} expectedType
- * @return {?}
- */
- DomSanitizerImpl.prototype.checkNotSafeValue = function (value, expectedType) {
- if (value instanceof SafeValueImpl) {
- throw new Error("Required a safe " + expectedType + ", got a " + value.getTypeName() + " " +
- "(see http://g.co/ng/security#xss)");
- }
- };
- /**
- * @param {?} value
- * @return {?}
- */
- DomSanitizerImpl.prototype.bypassSecurityTrustHtml = function (value) { return new SafeHtmlImpl(value); };
- /**
- * @param {?} value
- * @return {?}
- */
- DomSanitizerImpl.prototype.bypassSecurityTrustStyle = function (value) { return new SafeStyleImpl(value); };
- /**
- * @param {?} value
- * @return {?}
- */
- DomSanitizerImpl.prototype.bypassSecurityTrustScript = function (value) { return new SafeScriptImpl(value); };
- /**
- * @param {?} value
- * @return {?}
- */
- DomSanitizerImpl.prototype.bypassSecurityTrustUrl = function (value) { return new SafeUrlImpl(value); };
- /**
- * @param {?} value
- * @return {?}
- */
- DomSanitizerImpl.prototype.bypassSecurityTrustResourceUrl = function (value) {
- return new SafeResourceUrlImpl(value);
- };
- return DomSanitizerImpl;
- }(DomSanitizer));
- DomSanitizerImpl.decorators = [
- { type: Injectable },
- ];
- /**
- * @nocollapse
- */
- DomSanitizerImpl.ctorParameters = function () { return [
- { type: undefined, decorators: [{ type: Inject, args: [DOCUMENT$1,] },] },
- ]; };
- /**
- * @abstract
- */
- var SafeValueImpl = (function () {
- /**
- * @param {?} changingThisBreaksApplicationSecurity
- */
- function SafeValueImpl(changingThisBreaksApplicationSecurity) {
- this.changingThisBreaksApplicationSecurity = changingThisBreaksApplicationSecurity;
- // empty
- }
- /**
- * @abstract
- * @return {?}
- */
- SafeValueImpl.prototype.getTypeName = function () { };
- /**
- * @return {?}
- */
- SafeValueImpl.prototype.toString = function () {
- return "SafeValue must use [property]=binding: " + this.changingThisBreaksApplicationSecurity +
- " (see http://g.co/ng/security#xss)";
- };
- return SafeValueImpl;
- }());
- var SafeHtmlImpl = (function (_super) {
- __extends$1(SafeHtmlImpl, _super);
- function SafeHtmlImpl() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- /**
- * @return {?}
- */
- SafeHtmlImpl.prototype.getTypeName = function () { return 'HTML'; };
- return SafeHtmlImpl;
- }(SafeValueImpl));
- var SafeStyleImpl = (function (_super) {
- __extends$1(SafeStyleImpl, _super);
- function SafeStyleImpl() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- /**
- * @return {?}
- */
- SafeStyleImpl.prototype.getTypeName = function () { return 'Style'; };
- return SafeStyleImpl;
- }(SafeValueImpl));
- var SafeScriptImpl = (function (_super) {
- __extends$1(SafeScriptImpl, _super);
- function SafeScriptImpl() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- /**
- * @return {?}
- */
- SafeScriptImpl.prototype.getTypeName = function () { return 'Script'; };
- return SafeScriptImpl;
- }(SafeValueImpl));
- var SafeUrlImpl = (function (_super) {
- __extends$1(SafeUrlImpl, _super);
- function SafeUrlImpl() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- /**
- * @return {?}
- */
- SafeUrlImpl.prototype.getTypeName = function () { return 'URL'; };
- return SafeUrlImpl;
- }(SafeValueImpl));
- var SafeResourceUrlImpl = (function (_super) {
- __extends$1(SafeResourceUrlImpl, _super);
- function SafeResourceUrlImpl() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- /**
- * @return {?}
- */
- SafeResourceUrlImpl.prototype.getTypeName = function () { return 'ResourceURL'; };
- return SafeResourceUrlImpl;
- }(SafeValueImpl));
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var INTERNAL_BROWSER_PLATFORM_PROVIDERS = [
- { provide: PLATFORM_ID, useValue: PLATFORM_BROWSER_ID },
- { provide: PLATFORM_INITIALIZER, useValue: initDomAdapter, multi: true },
- { provide: PlatformLocation, useClass: BrowserPlatformLocation },
- { provide: DOCUMENT$1, useFactory: _document, deps: [] },
- ];
- /**
- * \@security Replacing built-in sanitization providers exposes the application to XSS risks.
- * Attacker-controlled data introduced by an unsanitized provider could expose your
- * application to XSS risks. For more detail, see the [Security Guide](http://g.co/ng/security).
- * \@experimental
- */
- var BROWSER_SANITIZATION_PROVIDERS = [
- { provide: Sanitizer, useExisting: DomSanitizer },
- { provide: DomSanitizer, useClass: DomSanitizerImpl },
- ];
- /**
- * \@stable
- */
- var platformBrowser = createPlatformFactory(platformCore, 'browser', INTERNAL_BROWSER_PLATFORM_PROVIDERS);
- /**
- * @return {?}
- */
- function initDomAdapter() {
- BrowserDomAdapter.makeCurrent();
- BrowserGetTestability.init();
- }
- /**
- * @return {?}
- */
- function errorHandler() {
- return new ErrorHandler();
- }
- /**
- * @return {?}
- */
- function _document() {
- return document;
- }
- /**
- * The ng module for the browser.
- *
- * \@stable
- */
- var BrowserModule = (function () {
- /**
- * @param {?} parentModule
- */
- function BrowserModule(parentModule) {
- if (parentModule) {
- throw new Error("BrowserModule has already been loaded. If you need access to common directives such as NgIf and NgFor from a lazy loaded module, import CommonModule instead.");
- }
- }
- /**
- * Configures a browser-based application to transition from a server-rendered app, if
- * one is present on the page. The specified parameters must include an application id,
- * which must match between the client and server applications.
- *
- * \@experimental
- * @param {?} params
- * @return {?}
- */
- BrowserModule.withServerTransition = function (params) {
- return {
- ngModule: BrowserModule,
- providers: [
- { provide: APP_ID, useValue: params.appId },
- { provide: TRANSITION_ID, useExisting: APP_ID },
- SERVER_TRANSITION_PROVIDERS,
- ],
- };
- };
- return BrowserModule;
- }());
- BrowserModule.decorators = [
- { type: NgModule, args: [{
- providers: [
- BROWSER_SANITIZATION_PROVIDERS,
- { provide: ErrorHandler, useFactory: errorHandler, deps: [] },
- { provide: EVENT_MANAGER_PLUGINS, useClass: DomEventsPlugin, multi: true },
- { provide: EVENT_MANAGER_PLUGINS, useClass: KeyEventsPlugin, multi: true },
- { provide: EVENT_MANAGER_PLUGINS, useClass: HammerGesturesPlugin, multi: true },
- { provide: HAMMER_GESTURE_CONFIG, useClass: HammerGestureConfig },
- DomRendererFactory2,
- { provide: RendererFactory2, useExisting: DomRendererFactory2 },
- { provide: SharedStylesHost, useExisting: DomSharedStylesHost },
- DomSharedStylesHost,
- Testability,
- EventManager,
- ELEMENT_PROBE_PROVIDERS,
- Meta,
- Title,
- ],
- exports: [CommonModule, ApplicationModule]
- },] },
- ];
- /**
- * @nocollapse
- */
- BrowserModule.ctorParameters = function () { return [
- { type: BrowserModule, decorators: [{ type: Optional }, { type: SkipSelf },] },
- ]; };
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var win = typeof window !== 'undefined' && window || {};
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var ChangeDetectionPerfRecord = (function () {
- /**
- * @param {?} msPerTick
- * @param {?} numTicks
- */
- function ChangeDetectionPerfRecord(msPerTick, numTicks) {
- this.msPerTick = msPerTick;
- this.numTicks = numTicks;
- }
- return ChangeDetectionPerfRecord;
- }());
- /**
- * Entry point for all Angular profiling-related debug tools. This object
- * corresponds to the `ng.profiler` in the dev console.
- */
- var AngularProfiler = (function () {
- /**
- * @param {?} ref
- */
- function AngularProfiler(ref) {
- this.appRef = ref.injector.get(ApplicationRef);
- }
- /**
- * Exercises change detection in a loop and then prints the average amount of
- * time in milliseconds how long a single round of change detection takes for
- * the current state of the UI. It runs a minimum of 5 rounds for a minimum
- * of 500 milliseconds.
- *
- * Optionally, a user may pass a `config` parameter containing a map of
- * options. Supported options are:
- *
- * `record` (boolean) - causes the profiler to record a CPU profile while
- * it exercises the change detector. Example:
- *
- * ```
- * ng.profiler.timeChangeDetection({record: true})
- * ```
- * @param {?} config
- * @return {?}
- */
- AngularProfiler.prototype.timeChangeDetection = function (config) {
- var /** @type {?} */ record = config && config['record'];
- var /** @type {?} */ profileName = 'Change Detection';
- // Profiler is not available in Android browsers, nor in IE 9 without dev tools opened
- var /** @type {?} */ isProfilerAvailable = win.console.profile != null;
- if (record && isProfilerAvailable) {
- win.console.profile(profileName);
- }
- var /** @type {?} */ start = getDOM().performanceNow();
- var /** @type {?} */ numTicks = 0;
- while (numTicks < 5 || (getDOM().performanceNow() - start) < 500) {
- this.appRef.tick();
- numTicks++;
- }
- var /** @type {?} */ end = getDOM().performanceNow();
- if (record && isProfilerAvailable) {
- // need to cast to <any> because type checker thinks there's no argument
- // while in fact there is:
- //
- // https://developer.mozilla.org/en-US/docs/Web/API/Console/profileEnd
- ((win.console.profileEnd))(profileName);
- }
- var /** @type {?} */ msPerTick = (end - start) / numTicks;
- win.console.log("ran " + numTicks + " change detection cycles");
- win.console.log(msPerTick.toFixed(2) + " ms per check");
- return new ChangeDetectionPerfRecord(msPerTick, numTicks);
- };
- return AngularProfiler;
- }());
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var PROFILER_GLOBAL_NAME = 'profiler';
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * @module
- * @description
- * Entry point for all public APIs of the common package.
- */
- /**
- * \@stable
- */
- var VERSION$1 = new Version('4.4.6');
-
- var PORTAL_DEFAULT = 1;
- var PORTAL_MODAL = 2;
- var PORTAL_LOADING = 3;
- var PORTAL_TOAST = 4;
-
- /**
- * @hidden
- * Given a min and max, restrict the given number
- * to the range.
- * @param min the minimum
- * @param n the value
- * @param max the maximum
- */
- function clamp(min, n, max) {
- return Math.max(min, Math.min(n, max));
- }
- /** @hidden */
- function deepCopy(obj) {
- return JSON.parse(JSON.stringify(obj));
- }
- /** @hidden */
- function deepEqual(a, b) {
- if (a === b) {
- return true;
- }
- return JSON.stringify(a) === JSON.stringify(b);
- }
- /** @hidden */
-
- /**
- * @hidden
- * Rewrites an absolute URL so it works across file and http based engines
- */
- function normalizeURL(url) {
- var ionic = window['Ionic'];
- if (ionic && ionic.normalizeURL) {
- return ionic.normalizeURL(url);
- }
- return url;
- }
- /**
- * @hidden
- * Apply default arguments if they don't exist in
- * the first object.
- * @param {any} dest the destination to apply defaults to.
- */
- function defaults(dest) {
- var _args = [];
- for (var _i = 1; _i < arguments.length; _i++) {
- _args[_i - 1] = arguments[_i];
- }
- for (var i = arguments.length - 1; i >= 1; i--) {
- var source = arguments[i];
- if (source) {
- for (var key in source) {
- if (source.hasOwnProperty(key) && !dest.hasOwnProperty(key)) {
- dest[key] = source[key];
- }
- }
- }
- }
- return dest;
- }
- /** @hidden */
-
- /** @hidden */
- function isString(val) { return typeof val === 'string'; }
- /** @hidden */
- function isNumber(val) { return typeof val === 'number'; }
- /** @hidden */
- function isFunction$1(val) { return typeof val === 'function'; }
- /** @hidden */
- function isDefined(val) { return typeof val !== 'undefined'; }
- /** @hidden */
- function isUndefined(val) { return typeof val === 'undefined'; }
- /** @hidden */
- function isPresent(val) { return val !== undefined && val !== null; }
- /** @hidden */
- function isBlank$1(val) { return val === undefined || val === null; }
- /** @hidden */
- function isObject$1(val) { return typeof val === 'object'; }
- /** @hidden */
- function isArray$2(val) { return Array.isArray(val); }
- /** @hidden */
-
- /** @hidden */
- function isTrueProperty(val) {
- if (typeof val === 'string') {
- val = val.toLowerCase().trim();
- return (val === 'true' || val === 'on' || val === '');
- }
- return !!val;
- }
- /** @hidden */
- function isCheckedProperty(a, b) {
- if (a === undefined || a === null || a === '') {
- return (b === undefined || b === null || b === '');
- }
- else if (a === true || a === 'true') {
- return (b === true || b === 'true');
- }
- else if (a === false || a === 'false') {
- return (b === false || b === 'false');
- }
- else if (a === 0 || a === '0') {
- return (b === 0 || b === '0');
- }
- // not using strict comparison on purpose
- return (a == b); // tslint:disable-line
- }
- /**
- * @hidden
- * Given a side, return if it should be on the right
- * based on the value of dir
- * @param side the side
- * @param isRTL whether the application dir is rtl
- * @param defaultRight whether the default side is right
- */
- function isRightSide(side, isRTL, defaultRight) {
- if (defaultRight === void 0) { defaultRight = false; }
- switch (side) {
- case 'right': return true;
- case 'left': return false;
- case 'end': return !isRTL;
- case 'start': return isRTL;
- default: return defaultRight ? !isRTL : isRTL;
- }
- }
- /** @hidden */
- function reorderArray(array, indexes) {
- var element = array[indexes.from];
- array.splice(indexes.from, 1);
- array.splice(indexes.to, 0, element);
- return array;
- }
- /** @hidden */
- function removeArrayItem(array, item) {
- var index = array.indexOf(item);
- return !!~index && !!array.splice(index, 1);
- }
- /** @hidden */
- function swipeShouldReset(isResetDirection, isMovingFast, isOnResetZone) {
- // The logic required to know when the sliding item should close (openAmount=0)
- // depends on three booleans (isCloseDirection, isMovingFast, isOnCloseZone)
- // and it ended up being too complicated to be written manually without errors
- // so the truth table is attached below: (0=false, 1=true)
- // isCloseDirection | isMovingFast | isOnCloseZone || shouldClose
- // 0 | 0 | 0 || 0
- // 0 | 0 | 1 || 1
- // 0 | 1 | 0 || 0
- // 0 | 1 | 1 || 0
- // 1 | 0 | 0 || 0
- // 1 | 0 | 1 || 1
- // 1 | 1 | 0 || 1
- // 1 | 1 | 1 || 1
- // The resulting expression was generated by resolving the K-map (Karnaugh map):
- var shouldClose = (!isMovingFast && isOnResetZone) || (isResetDirection && isMovingFast);
- return shouldClose;
- }
- /** @hidden */
- var ASSERT_ENABLED = true;
- /** @hidden */
- function requestIonicCallback(functionToLazy) {
- if ('requestIdleCallback' in window) {
- return window.requestIdleCallback(functionToLazy);
- }
- else {
- return setTimeout(functionToLazy, 500);
- }
- }
-
- /**
- * @name Config
- * @demo /docs/demos/src/config/
- * @description
- * The Config lets you configure your entire app or specific platforms.
- * You can set the tab placement, icon mode, animations, and more here.
- *
- * ```ts
- * import { IonicApp, IonicModule } from 'ionic-angular';
- *
- * @NgModule({
- * declarations: [ MyApp ],
- * imports: [
- * BrowserModule,
- * IonicModule.forRoot(MyApp, {
- * backButtonText: 'Go Back',
- * iconMode: 'ios',
- * modalEnter: 'modal-slide-in',
- * modalLeave: 'modal-slide-out',
- * tabsPlacement: 'bottom',
- * pageTransition: 'ios-transition'
- * }, {}
- * )],
- * bootstrap: [IonicApp],
- * entryComponents: [ MyApp ],
- * providers: []
- * })
- * ```
- *
- *
- * Config can be overwritten at multiple levels allowing for more granular configuration.
- * Below is an example where an app can override any setting we want based on a platform.
- *
- * ```ts
- * import { IonicModule } from 'ionic-angular';
- *
- * @NgModule({
- * ...
- * imports: [
- * BrowserModule,
- * IonicModule.forRoot(MyApp, {
- * tabsPlacement: 'bottom',
- * platforms: {
- * ios: {
- * tabsPlacement: 'top',
- * }
- * }
- * }, {}
- * )],
- * ...
- * })
- * ```
- *
- * We could also configure these values at a component level. Take `tabsPlacement`,
- * we can configure this as a property on our `ion-tabs`.
- *
- * ```html
- * <ion-tabs tabsPlacement="top">
- * <ion-tab tabTitle="Dash" tabIcon="pulse" [root]="tabRoot"></ion-tab>
- * </ion-tabs>
- * ```
- *
- * The last way we could configure is through URL query strings. This is useful for testing
- * while in the browser. Simply add `?ionic<PROPERTYNAME>=<value>` to the url.
- *
- * ```bash
- * http://localhost:8100/?ionicTabsPlacement=bottom
- * ```
- *
- * Any value can be added to config, and looked up at a later in any component.
- *
- * ```js
- * config.set('ios', 'favoriteColor', 'green');
- *
- * // from any page in your app:
- * config.get('favoriteColor'); // 'green' when iOS
- * ```
- *
- *
- * A config value can come from anywhere and be anything, but there are default
- * values for each mode. The [theming](../../../theming/platform-specific-styles/)
- * documentation has a chart of the default mode configuration. The following
- * chart displays each property with a description of what it controls.
- *
- *
- * | Config Property | Type | Details |
- * |--------------------------|---------------------|--------------------------------------------------------------------------------------------------------------------------------------------------|
- * | `activator` | `string` | Used for buttons, changes the effect of pressing on a button. Available options: `"ripple"`, `"highlight"`. |
- * | `actionSheetEnter` | `string` | The name of the transition to use while an action sheet is presented. |
- * | `actionSheetLeave` | `string` | The name of the transition to use while an action sheet is dismissed. |
- * | `alertEnter` | `string` | The name of the transition to use while an alert is presented. |
- * | `alertLeave` | `string` | The name of the transition to use while an alert is dismissed. |
- * | `backButtonText` | `string` | The text to display by the back button icon in the navbar. |
- * | `backButtonIcon` | `string` | The icon to use as the back button icon. |
- * | `iconMode` | `string` | The mode to use for all icons throughout the application. Available options: `"ios"`, `"md"` |
- * | `locationStrategy` | `string` | Set to 'path' to remove hashbangs when using Deeplinking. |
- * | `loadingEnter` | `string` | The name of the transition to use while a loading indicator is presented. |
- * | `loadingLeave` | `string` | The name of the transition to use while a loading indicator is dismissed. |
- * | `menuType` | `string` | Type of menu to display. Available options: `"overlay"`, `"reveal"`, `"push"`. |
- * | `modalEnter` | `string` | The name of the transition to use while a modal is presented. |
- * | `modalLeave` | `string` | The name of the transition to use while a modal is dismiss. |
- * | `mode` | `string` | The mode to use throughout the application. |
- * | `pageTransition` | `string` | The name of the transition to use while changing pages. Available options: `"ios-transition"`, `"md-transition"`, `"wp-transition"`. |
- * | `pickerEnter` | `string` | The name of the transition to use while a picker is presented. |
- * | `pickerLeave` | `string` | The name of the transition to use while a picker is dismissed. |
- * | `popoverEnter` | `string` | The name of the transition to use while a popover is presented. |
- * | `popoverLeave` | `string` | The name of the transition to use while a popover is dismissed.
- * | `scrollAssist` | `boolean` | Used to avoid the input to be hidden by the keyboard if it's near the bottom of the page.
- * | `scrollPadding` | `boolean` | Used to remove the extra padding on ion-content when keyboard is displayed.
- * | `spinner` | `string` | The default spinner to use when a name is not defined. |
- * | `statusbarPadding` | `boolean` | Whether to hide extra padding for statusbar. |
- * | `swipeBackEnabled` | `boolean` | Whether native iOS swipe to go back functionality is enabled. |
- * | `tabsHighlight` | `boolean` | Whether to show a highlight line under the tab when it is selected. |
- * | `tabsLayout` | `string` | The layout to use for all tabs. Available options: `"icon-top"`, `"icon-start"`, `"icon-end"`, `"icon-bottom"`, `"icon-hide"`, `"title-hide"`. |
- * | `tabsPlacement` | `string` | The position of the tabs relative to the content. Available options: `"top"`, `"bottom"` |
- * | `tabsHideOnSubPages` | `boolean` | Whether to hide the tabs on child pages or not. If `true` it will not show the tabs on child pages. |
- * | `toastEnter` | `string` | The name of the transition to use while a toast is presented. |
- * | `toastLeave` | `string` | The name of the transition to use while a toast is dismissed. |
- *
- **/
- var Config = (function () {
- function Config() {
- this._c = {};
- this._s = {};
- this._modes = {};
- this._trns = {};
- }
- /**
- * @hidden
- */
- Config.prototype.init = function (config, plt) {
- this._s = config && isObject$1(config) && !isArray$2(config) ? config : {};
- this.plt = plt;
- };
- /**
- * @name get
- * @description
- * Returns a single config value, given a key.
- *
- * @param {string} [key] - the key for the config value
- * @param {any} [fallbackValue] - a fallback value to use when the config
- * value was not found, or is config value is `null`. Fallback value
- * defaults to `null`.
- */
- Config.prototype.get = function (key, fallbackValue) {
- if (fallbackValue === void 0) { fallbackValue = null; }
- var platform = this.plt;
- if (!isDefined(this._c[key])) {
- if (!isDefined(key)) {
- throw 'config key is not defined';
- }
- // if the value was already set this will all be skipped
- // if there was no user config then it'll check each of
- // the user config's platforms, which already contains
- // settings from default platform configs
- var userPlatformValue = undefined;
- var userDefaultValue = this._s[key];
- var userPlatformModeValue = undefined;
- var userDefaultModeValue = undefined;
- var platformValue = undefined;
- var platformModeValue = undefined;
- var configObj = null;
- if (platform) {
- var queryStringValue = platform.getQueryParam('ionic' + key);
- if (isDefined(queryStringValue)) {
- return this._c[key] = (queryStringValue === 'true' ? true : queryStringValue === 'false' ? false : queryStringValue);
- }
- // check the platform settings object for this value
- // loop though each of the active platforms
- // array of active platforms, which also knows the hierarchy,
- // with the last one the most important
- var activePlatformKeys = platform.platforms();
- // loop through all of the active platforms we're on
- for (var i = 0, ilen = activePlatformKeys.length; i < ilen; i++) {
- // get user defined platform values
- if (this._s.platforms) {
- configObj = this._s.platforms[activePlatformKeys[i]];
- if (configObj) {
- if (isDefined(configObj[key])) {
- userPlatformValue = configObj[key];
- }
- configObj = this.getModeConfig(configObj.mode);
- if (configObj && isDefined(configObj[key])) {
- userPlatformModeValue = configObj[key];
- }
- }
- }
- // get default platform's setting
- configObj = platform.getPlatformConfig(activePlatformKeys[i]);
- if (configObj && configObj.settings) {
- if (isDefined(configObj.settings[key])) {
- // found a setting for this platform
- platformValue = configObj.settings[key];
- }
- configObj = this.getModeConfig(configObj.settings.mode);
- if (configObj && isDefined(configObj[key])) {
- // found setting for this platform's mode
- platformModeValue = configObj[key];
- }
- }
- }
- }
- configObj = this.getModeConfig(this._s.mode);
- if (configObj && isDefined(configObj[key])) {
- userDefaultModeValue = configObj[key];
- }
- // cache the value
- this._c[key] = isDefined(userPlatformValue) ? userPlatformValue :
- isDefined(userDefaultValue) ? userDefaultValue :
- isDefined(userPlatformModeValue) ? userPlatformModeValue :
- isDefined(userDefaultModeValue) ? userDefaultModeValue :
- isDefined(platformValue) ? platformValue :
- isDefined(platformModeValue) ? platformModeValue :
- null;
- }
- // return key's value
- // either it came directly from the user config
- // or it was from the users platform configs
- // or it was from the default platform configs
- // in that order
- var rtnVal = this._c[key];
- if (isFunction$1(rtnVal)) {
- rtnVal = rtnVal(platform);
- }
- return (rtnVal !== null ? rtnVal : fallbackValue);
- };
- /**
- * @name getBoolean
- * @description
- * Same as `get()`, however always returns a boolean value. If the
- * value from `get()` is `null`, then it'll return the `fallbackValue`
- * which defaults to `false`. Otherwise, `getBoolean()` will return
- * if the config value is truthy or not. It also returns `true` if
- * the config value was the string value `"true"`.
- * @param {string} [key] - the key for the config value
- * @param {boolean} [fallbackValue] - a fallback value to use when the config
- * value was `null`. Fallback value defaults to `false`.
- */
- Config.prototype.getBoolean = function (key, fallbackValue) {
- if (fallbackValue === void 0) { fallbackValue = false; }
- var val = this.get(key);
- if (val === null) {
- return fallbackValue;
- }
- if (typeof val === 'string') {
- return val === 'true';
- }
- return !!val;
- };
- /**
- * @name getNumber
- * @description
- * Same as `get()`, however always returns a number value. Uses `parseFloat()`
- * on the value received from `get()`. If the result from the parse is `NaN`,
- * then it will return the value passed to `fallbackValue`. If no fallback
- * value was provided then it'll default to returning `NaN` when the result
- * is not a valid number.
- * @param {string} [key] - the key for the config value
- * @param {number} [fallbackValue] - a fallback value to use when the config
- * value turned out to be `NaN`. Fallback value defaults to `NaN`.
- */
- Config.prototype.getNumber = function (key, fallbackValue) {
- if (fallbackValue === void 0) { fallbackValue = NaN; }
- var val = parseFloat(this.get(key));
- return isNaN(val) ? fallbackValue : val;
- };
- /**
- * @name set
- * @description
- * Sets a single config value.
- *
- * @param {string} [platform] - The platform (either 'ios' or 'android') that the config value should apply to. Leaving this blank will apply the config value to all platforms.
- * @param {string} [key] - The key used to look up the value at a later point in time.
- * @param {string} [value] - The config value being stored.
- */
- Config.prototype.set = function () {
- var args = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- args[_i] = arguments[_i];
- }
- var arg0 = args[0];
- var arg1 = args[1];
- switch (args.length) {
- case 2:
- // set('key', 'value') = set key/value pair
- // arg1 = value
- this._s[arg0] = arg1;
- delete this._c[arg0]; // clear cache
- break;
- case 3:
- // setting('ios', 'key', 'value') = set key/value pair for platform
- // arg0 = platform
- // arg1 = key
- // arg2 = value
- this._s.platforms = this._s.platforms || {};
- this._s.platforms[arg0] = this._s.platforms[arg0] || {};
- this._s.platforms[arg0][arg1] = args[2];
- delete this._c[arg1]; // clear cache
- break;
- }
- return this;
- };
- /**
- * @hidden
- * @name settings()
- * @description
- */
- Config.prototype.settings = function (arg0, arg1) {
- switch (arguments.length) {
- case 0:
- return this._s;
- case 1:
- // settings({...})
- this._s = arg0;
- this._c = {}; // clear cache
- break;
- case 2:
- // settings('ios', {...})
- this._s.platforms = this._s.platforms || {};
- this._s.platforms[arg0] = arg1;
- this._c = {}; // clear cache
- break;
- }
- return this;
- };
- /**
- * @hidden
- */
- Config.prototype.setModeConfig = function (modeName, modeConfig) {
- this._modes[modeName] = modeConfig;
- };
- /**
- * @hidden
- */
- Config.prototype.getModeConfig = function (modeName) {
- return this._modes[modeName] || null;
- };
- /**
- * @hidden
- */
- Config.prototype.setTransition = function (trnsName, trnsClass) {
- this._trns[trnsName] = trnsClass;
- };
- /**
- * @hidden
- */
- Config.prototype.getTransition = function (trnsName) {
- return this._trns[trnsName] || null;
- };
- return Config;
- }());
- /**
- * @hidden
- */
- function setupConfig(userConfig, plt) {
- var config = new Config();
- config.init(userConfig, plt);
- // add the config obj to the window
- var win = plt.win();
- win['Ionic'] = win['Ionic'] || {};
- win['Ionic']['config'] = config;
- return config;
- }
- /**
- * @hidden
- */
- var ConfigToken = new InjectionToken('USERCONFIG');
-
- /**
- * @name NavParams
- * @description
- * NavParams are an object that exists on a page and can contain data for that particular view.
- * Similar to how data was pass to a view in V1 with `$stateParams`, NavParams offer a much more flexible
- * option with a simple `get` method.
- *
- * @usage
- * ```ts
- * import { NavParams } from 'ionic-angular';
- *
- * export class MyClass{
- *
- * constructor(navParams: NavParams){
- * // userParams is an object we have in our nav-parameters
- * navParams.get('userParams');
- * }
- *
- * }
- * ```
- * @demo /docs/demos/src/nav-params/
- * @see {@link /docs/components#navigation Navigation Component Docs}
- * @see {@link ../NavController/ NavController API Docs}
- * @see {@link /docs/api/components/nav/Nav/ Nav API Docs}
- * @see {@link /docs/api/components/nav/NavPush/ NavPush API Docs}
- */
- var NavParams = (function () {
- /**
- * @hidden
- * @param {TODO} data TODO
- */
- function NavParams(data) {
- if (data === void 0) { data = {}; }
- this.data = data;
- }
- /**
- * Get the value of a nav-parameter for the current view
- *
- * ```ts
- * import { NavParams } from 'ionic-angular';
- *
- * export class MyClass{
- * constructor(public navParams: NavParams){
- * // userParams is an object we have in our nav-parameters
- * this.navParams.get('userParams');
- * }
- * }
- * ```
- *
- *
- * @param {string} param Which param you want to look up
- */
- NavParams.prototype.get = function (param) {
- return this.data[param];
- };
- return NavParams;
- }());
-
- /**
- * @name ViewController
- * @description
- * Access various features and information about the current view.
- * @usage
- * ```ts
- * import { Component } from '@angular/core';
- * import { ViewController } from 'ionic-angular';
- *
- * @Component({...})
- * export class MyPage{
- *
- * constructor(public viewCtrl: ViewController) {}
- *
- * }
- * ```
- */
- var ViewController = (function () {
- function ViewController(component, data, rootCssClass) {
- if (rootCssClass === void 0) { rootCssClass = DEFAULT_CSS_CLASS; }
- this.component = component;
- this._isHidden = false;
- this._state = STATE_NEW;
- /**
- * Observable to be subscribed to when the current component will become active
- * @returns {Observable} Returns an observable
- */
- this.willEnter = new EventEmitter();
- /**
- * Observable to be subscribed to when the current component has become active
- * @returns {Observable} Returns an observable
- */
- this.didEnter = new EventEmitter();
- /**
- * Observable to be subscribed to when the current component will no longer be active
- * @returns {Observable} Returns an observable
- */
- this.willLeave = new EventEmitter();
- /**
- * Observable to be subscribed to when the current component is no long active
- * @returns {Observable} Returns an observable
- */
- this.didLeave = new EventEmitter();
- /**
- * Observable to be subscribed to when the current component has been destroyed
- * @returns {Observable} Returns an observable
- */
- this.willUnload = new EventEmitter();
- /**
- * @hidden
- */
- this.readReady = new EventEmitter();
- /**
- * @hidden
- */
- this.writeReady = new EventEmitter();
- /** @hidden */
- this.isOverlay = false;
- /** @hidden */
- this._emitter = new EventEmitter();
- // passed in data could be NavParams, but all we care about is its data object
- this.data = (data instanceof NavParams ? data.data : (isPresent(data) ? data : {}));
- this._cssClass = rootCssClass;
- this._ts = Date.now();
- window.addEventListener('orientationchange', this.handleOrientationChange.bind(this));
- }
- ViewController.prototype.handleOrientationChange = function () {
- if (this.getContent()) {
- this.getContent().resize();
- }
- };
- /**
- * @hidden
- */
- ViewController.prototype.init = function (componentRef) {
- (void 0) /* assert */;
- this._ts = Date.now();
- this._cmp = componentRef;
- this.instance = this.instance || componentRef.instance;
- this._detached = false;
- };
- ViewController.prototype._setNav = function (navCtrl) {
- this._nav = navCtrl;
- };
- ViewController.prototype._setInstance = function (instance) {
- this.instance = instance;
- };
- /**
- * @hidden
- */
- ViewController.prototype.subscribe = function (generatorOrNext) {
- return this._emitter.subscribe(generatorOrNext);
- };
- /**
- * @hidden
- */
- ViewController.prototype.emit = function (data) {
- this._emitter.emit(data);
- };
- /**
- * Called when the current viewController has be successfully dismissed
- */
- ViewController.prototype.onDidDismiss = function (callback) {
- this._onDidDismiss = callback;
- };
- /**
- * Called when the current viewController will be dismissed
- */
- ViewController.prototype.onWillDismiss = function (callback) {
- this._onWillDismiss = callback;
- };
- /**
- * Dismiss the current viewController
- * @param {any} [data] Data that you want to return when the viewController is dismissed.
- * @param {any} [role ]
- * @param {NavOptions} navOptions Options for the dismiss navigation.
- * @returns {any} data Returns the data passed in, if any.
- */
- ViewController.prototype.dismiss = function (data, role, navOptions) {
- if (navOptions === void 0) { navOptions = {}; }
- if (!this._nav) {
- (void 0) /* assert */;
- return Promise.resolve(false);
- }
- if (this.isOverlay && !navOptions.minClickBlockDuration) {
- // This is a Modal being dismissed so we need
- // to add the minClickBlockDuration option
- // for UIWebView
- navOptions.minClickBlockDuration = 400;
- }
- this._dismissData = data;
- this._dismissRole = role;
- var options = Object.assign({}, this._leavingOpts, navOptions);
- return this._nav.removeView(this, options).then(function () { return data; });
- };
- /**
- * @hidden
- */
- ViewController.prototype.getNav = function () {
- return this._nav;
- };
- /**
- * @hidden
- */
- ViewController.prototype.getTransitionName = function (_direction) {
- return this._nav && this._nav.config.get('pageTransition');
- };
- /**
- * @hidden
- */
- ViewController.prototype.getNavParams = function () {
- return new NavParams(this.data);
- };
- /**
- * @hidden
- */
- ViewController.prototype.setLeavingOpts = function (opts) {
- this._leavingOpts = opts;
- };
- /**
- * Check to see if you can go back in the navigation stack.
- * @returns {boolean} Returns if it's possible to go back from this Page.
- */
- ViewController.prototype.enableBack = function () {
- // update if it's possible to go back from this nav item
- if (!this._nav) {
- return false;
- }
- // the previous view may exist, but if it's about to be destroyed
- // it shouldn't be able to go back to
- var previousItem = this._nav.getPrevious(this);
- return !!(previousItem);
- };
- Object.defineProperty(ViewController.prototype, "name", {
- /**
- * @hidden
- */
- get: function () {
- return (this.component ? this.component.name : '');
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(ViewController.prototype, "index", {
- /**
- * Get the index of the current component in the current navigation stack.
- * @returns {number} Returns the index of this page within its `NavController`.
- */
- get: function () {
- return (this._nav ? this._nav.indexOf(this) : -1);
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @returns {boolean} Returns if this Page is the first in the stack of pages within its NavController.
- */
- ViewController.prototype.isFirst = function () {
- return (this._nav ? this._nav.first() === this : false);
- };
- /**
- * @returns {boolean} Returns if this Page is the last in the stack of pages within its NavController.
- */
- ViewController.prototype.isLast = function () {
- return (this._nav ? this._nav.last() === this : false);
- };
- /**
- * @hidden
- * DOM WRITE
- */
- ViewController.prototype._domShow = function (shouldShow, renderer) {
- // using hidden element attribute to display:none and not render views
- // _hidden value of '' means the hidden attribute will be added
- // _hidden value of null means the hidden attribute will be removed
- // doing checks to make sure we only update the DOM when actually needed
- // if it should render, then the hidden attribute should not be on the element
- if (this._cmp && shouldShow === this._isHidden) {
- this._isHidden = !shouldShow;
- var value = (shouldShow ? null : '');
- // ******** DOM WRITE ****************
- renderer.setElementAttribute(this.pageRef().nativeElement, 'hidden', value);
- }
- };
- /**
- * @hidden
- */
- ViewController.prototype.getZIndex = function () {
- return this._zIndex;
- };
- /**
- * @hidden
- * DOM WRITE
- */
- ViewController.prototype._setZIndex = function (zIndex, renderer) {
- if (zIndex !== this._zIndex) {
- this._zIndex = zIndex;
- var pageRef = this.pageRef();
- if (pageRef) {
- // ******** DOM WRITE ****************
- renderer.setElementStyle(pageRef.nativeElement, 'z-index', zIndex);
- }
- }
- };
- /**
- * @returns {ElementRef} Returns the Page's ElementRef.
- */
- ViewController.prototype.pageRef = function () {
- return this._cmp && this._cmp.location;
- };
- ViewController.prototype._setContent = function (directive) {
- this._cntDir = directive;
- };
- /**
- * @returns {component} Returns the Page's Content component reference.
- */
- ViewController.prototype.getContent = function () {
- return this._cntDir;
- };
- ViewController.prototype._setContentRef = function (elementRef) {
- this._cntRef = elementRef;
- };
- /**
- * @returns {ElementRef} Returns the Content's ElementRef.
- */
- ViewController.prototype.contentRef = function () {
- return this._cntRef;
- };
- ViewController.prototype._setIONContent = function (content) {
- this._setContent(content);
- this._ionCntDir = content;
- };
- /**
- * @hidden
- */
- ViewController.prototype.getIONContent = function () {
- return this._ionCntDir;
- };
- ViewController.prototype._setIONContentRef = function (elementRef) {
- this._setContentRef(elementRef);
- this._ionCntRef = elementRef;
- };
- /**
- * @hidden
- */
- ViewController.prototype.getIONContentRef = function () {
- return this._ionCntRef;
- };
- ViewController.prototype._setHeader = function (directive) {
- this._hdrDir = directive;
- };
- /**
- * @hidden
- */
- ViewController.prototype.getHeader = function () {
- return this._hdrDir;
- };
- ViewController.prototype._setFooter = function (directive) {
- this._ftrDir = directive;
- };
- /**
- * @hidden
- */
- ViewController.prototype.getFooter = function () {
- return this._ftrDir;
- };
- ViewController.prototype._setNavbar = function (directive) {
- this._nb = directive;
- };
- /**
- * @hidden
- */
- ViewController.prototype.getNavbar = function () {
- return this._nb;
- };
- /**
- * Find out if the current component has a NavBar or not. Be sure
- * to wrap this in an `ionViewWillEnter` method in order to make sure
- * the view has rendered fully.
- * @returns {boolean} Returns a boolean if this Page has a navbar or not.
- */
- ViewController.prototype.hasNavbar = function () {
- return !!this._nb;
- };
- /**
- * Change the title of the back-button. Be sure to call this
- * after `ionViewWillEnter` to make sure the DOM has been rendered.
- * @param {string} val Set the back button text.
- */
- ViewController.prototype.setBackButtonText = function (val) {
- this._nb && this._nb.setBackButtonText(val);
- };
- /**
- * Set if the back button for the current view is visible or not. Be sure to call this
- * after `ionViewWillEnter` to make sure the DOM has been rendered.
- * @param {boolean} Set if this Page's back button should show or not.
- */
- ViewController.prototype.showBackButton = function (shouldShow) {
- if (this._nb) {
- this._nb.hideBackButton = !shouldShow;
- }
- };
- ViewController.prototype._preLoad = function () {
- (void 0) /* assert */;
- this._lifecycle('PreLoad');
- };
- /**
- * @hidden
- * The view has loaded. This event only happens once per view will be created.
- * This event is fired before the component and his children have been initialized.
- */
- ViewController.prototype._willLoad = function () {
- (void 0) /* assert */;
- this._lifecycle('WillLoad');
- };
- /**
- * @hidden
- * The view has loaded. This event only happens once per view being
- * created. If a view leaves but is cached, then this will not
- * fire again on a subsequent viewing. This method is a good place
- * to put your setup code for the view; however, it is not the
- * recommended method to use when a view becomes active.
- */
- ViewController.prototype._didLoad = function () {
- (void 0) /* assert */;
- this._lifecycle('DidLoad');
- };
- /**
- * @hidden
- * The view is about to enter and become the active view.
- */
- ViewController.prototype._willEnter = function () {
- this.handleOrientationChange();
- (void 0) /* assert */;
- if (this._detached && this._cmp) {
- // ensure this has been re-attached to the change detector
- this._cmp.changeDetectorRef.reattach();
- this._detached = false;
- }
- this.willEnter.emit(null);
- this._lifecycle('WillEnter');
- };
- /**
- * @hidden
- * The view has fully entered and is now the active view. This
- * will fire, whether it was the first load or loaded from the cache.
- */
- ViewController.prototype._didEnter = function () {
- (void 0) /* assert */;
- this._nb && this._nb.didEnter();
- this.didEnter.emit(null);
- this._lifecycle('DidEnter');
- };
- /**
- * @hidden
- * The view is about to leave and no longer be the active view.
- */
- ViewController.prototype._willLeave = function (willUnload) {
- this.willLeave.emit(null);
- this._lifecycle('WillLeave');
- if (willUnload && this._onWillDismiss) {
- this._onWillDismiss(this._dismissData, this._dismissRole);
- this._onWillDismiss = null;
- }
- };
- /**
- * @hidden
- * The view has finished leaving and is no longer the active view. This
- * will fire, whether it is cached or unloaded.
- */
- ViewController.prototype._didLeave = function () {
- this.didLeave.emit(null);
- this._lifecycle('DidLeave');
- // when this is not the active page
- // we no longer need to detect changes
- if (!this._detached && this._cmp) {
- this._cmp.changeDetectorRef.detach();
- this._detached = true;
- }
- };
- /**
- * @hidden
- */
- ViewController.prototype._willUnload = function () {
- this.willUnload.emit(null);
- this._lifecycle('WillUnload');
- this._onDidDismiss && this._onDidDismiss(this._dismissData, this._dismissRole);
- this._onDidDismiss = null;
- this._dismissData = null;
- this._dismissRole = null;
- };
- /**
- * @hidden
- * DOM WRITE
- */
- ViewController.prototype._destroy = function (renderer) {
- (void 0) /* assert */;
- if (this._cmp) {
- if (renderer) {
- // ensure the element is cleaned up for when the view pool reuses this element
- // ******** DOM WRITE ****************
- var cmpEle = this._cmp.location.nativeElement;
- renderer.setElementAttribute(cmpEle, 'class', null);
- renderer.setElementAttribute(cmpEle, 'style', null);
- }
- window.removeEventListener('orientationchange', this.handleOrientationChange.bind(this));
- // completely destroy this component. boom.
- this._cmp.destroy();
- }
- this._nav = this._cmp = this.instance = this._cntDir = this._cntRef = this._leavingOpts = this._hdrDir = this._ftrDir = this._nb = this._onDidDismiss = this._onWillDismiss = null;
- this._state = STATE_DESTROYED;
- };
- /**
- * @hidden
- */
- ViewController.prototype._lifecycleTest = function (lifecycle) {
- var instance = this.instance;
- var methodName = 'ionViewCan' + lifecycle;
- if (instance && instance[methodName]) {
- try {
- var result = instance[methodName]();
- if (result instanceof Promise) {
- return result;
- }
- else {
- // Any value but explitic false, should be true
- return Promise.resolve(result !== false);
- }
- }
- catch (e) {
- return Promise.reject(this.name + " " + methodName + " error: " + e.message);
- }
- }
- return Promise.resolve(true);
- };
- /**
- * @hidden
- */
- ViewController.prototype._lifecycle = function (lifecycle) {
- var instance = this.instance;
- var methodName = 'ionView' + lifecycle;
- if (instance && instance[methodName]) {
- instance[methodName]();
- }
- };
- ViewController.propDecorators = {
- '_emitter': [{ type: Output },],
- };
- return ViewController;
- }());
- function isViewController(viewCtrl) {
- return !!(viewCtrl && viewCtrl._didLoad && viewCtrl._willUnload);
- }
- var DEFAULT_CSS_CLASS = 'ion-page';
-
- function getComponent(linker, nameOrPageOrView, params) {
- if (typeof nameOrPageOrView === 'function') {
- return Promise.resolve(new ViewController(nameOrPageOrView, params));
- }
- if (typeof nameOrPageOrView === 'string') {
- return linker.getComponentFromName(nameOrPageOrView).then(function (component) {
- var vc = new ViewController(component, params);
- vc.id = nameOrPageOrView;
- return vc;
- });
- }
- return Promise.resolve(null);
- }
- function convertToView(linker, nameOrPageOrView, params) {
- if (nameOrPageOrView) {
- if (isViewController(nameOrPageOrView)) {
- // is already a ViewController
- return Promise.resolve(nameOrPageOrView);
- }
- return getComponent(linker, nameOrPageOrView, params);
- }
- return Promise.resolve(null);
- }
- function convertToViews(linker, pages) {
- var views = [];
- if (isArray$2(pages)) {
- for (var i = 0; i < pages.length; i++) {
- var page = pages[i];
- if (page) {
- if (isViewController(page)) {
- views.push(page);
- }
- else if (page.page) {
- views.push(convertToView(linker, page.page, page.params));
- }
- else {
- views.push(convertToView(linker, page, null));
- }
- }
- }
- }
- return Promise.all(views);
- }
- var portalZindex = 9999;
- function setZIndex(nav, enteringView, leavingView, direction, renderer) {
- if (enteringView) {
- if (nav._isPortal) {
- if (direction === DIRECTION_FORWARD) {
- enteringView._setZIndex(nav._zIndexOffset + portalZindex, renderer);
- }
- portalZindex++;
- return;
- }
- leavingView = leavingView || nav.getPrevious(enteringView);
- if (leavingView && isPresent(leavingView._zIndex)) {
- if (direction === DIRECTION_BACK) {
- enteringView._setZIndex(leavingView._zIndex - 1, renderer);
- }
- else {
- enteringView._setZIndex(leavingView._zIndex + 1, renderer);
- }
- }
- else {
- enteringView._setZIndex(INIT_ZINDEX + nav._zIndexOffset, renderer);
- }
- }
- }
- function isTabs(nav) {
- // Tabs (ion-tabs)
- return !!nav && !!nav.getSelected;
- }
- function isTab(nav) {
- // Tab (ion-tab)
- return !!nav && isPresent(nav._tabId);
- }
- function isNav(nav) {
- // Nav (ion-nav), Tab (ion-tab), Portal (ion-portal)
- return !!nav && !!nav.push && nav.getType() === 'nav';
- }
-
- /**
- * @hidden
- */
- var DeepLinkMetadata = (function () {
- function DeepLinkMetadata() {
- }
- return DeepLinkMetadata;
- }());
- /**
- * @hidden
- */
- var DeepLinkMetadataFactory;
- var STATE_NEW = 1;
- var STATE_INITIALIZED = 2;
- var STATE_ATTACHED = 3;
- var STATE_DESTROYED = 4;
- var INIT_ZINDEX = 100;
- var DIRECTION_BACK = 'back';
- var DIRECTION_FORWARD = 'forward';
- var DIRECTION_SWITCH = 'switch';
-
- /**
- * @name MenuController
- * @description
- * The MenuController is a provider which makes it easy to control a [Menu](../../Menu/Menu/).
- * Its methods can be used to display the menu, enable the menu, toggle the menu, and more.
- * The controller will grab a reference to the menu by the `side`, `id`, or, if neither
- * of these are passed to it, it will grab the first menu it finds.
- *
- *
- * @usage
- *
- * Add a basic menu component to start with. See the [Menu](../../Menu/Menu/) API docs
- * for more information on adding menu components.
- *
- * ```html
- * <ion-menu [content]="mycontent">
- * <ion-content>
- * <ion-list>
- * ...
- * </ion-list>
- * </ion-content>
- * </ion-menu>
- *
- * <ion-nav #mycontent [root]="rootPage"></ion-nav>
- * ```
- *
- * To call the controller methods, inject the `MenuController` provider
- * into the page. Then, create some methods for opening, closing, and
- * toggling the menu.
- *
- * ```ts
- * import { Component } from '@angular/core';
- * import { MenuController } from 'ionic-angular';
- *
- * @Component({...})
- * export class MyPage {
- *
- * constructor(public menuCtrl: MenuController) {
- *
- * }
- *
- * openMenu() {
- * this.menuCtrl.open();
- * }
- *
- * closeMenu() {
- * this.menuCtrl.close();
- * }
- *
- * toggleMenu() {
- * this.menuCtrl.toggle();
- * }
- *
- * }
- * ```
- *
- * Since only one menu exists, the `MenuController` will grab the
- * correct menu and call the correct method for each.
- *
- *
- * ### Multiple Menus on Different Sides
- *
- * For applications with both a left and right menu, the desired menu can be
- * grabbed by passing the `side` of the menu. If nothing is passed, it will
- * default to the `"left"` menu.
- *
- * ```html
- * <ion-menu side="left" [content]="mycontent">...</ion-menu>
- * <ion-menu side="right" [content]="mycontent">...</ion-menu>
- * <ion-nav #mycontent [root]="rootPage"></ion-nav>
- * ```
- *
- * ```ts
- * toggleLeftMenu() {
- * this.menuCtrl.toggle();
- * }
- *
- * toggleRightMenu() {
- * this.menuCtrl.toggle('right');
- * }
- * ```
- *
- *
- * ### Multiple Menus on the Same Side
- *
- * An application can have multiple menus on the same side. In order to determine
- * the menu to control, an `id` should be passed. In the example below, the menu
- * with the `authenticated` id will be enabled, and the menu with the `unauthenticated`
- * id will be disabled.
- *
- * ```html
- * <ion-menu id="authenticated" side="left" [content]="mycontent">...</ion-menu>
- * <ion-menu id="unauthenticated" side="left" [content]="mycontent">...</ion-menu>
- * <ion-nav #mycontent [root]="rootPage"></ion-nav>
- * ```
- *
- * ```ts
- * enableAuthenticatedMenu() {
- * this.menuCtrl.enable(true, 'authenticated');
- * this.menuCtrl.enable(false, 'unauthenticated');
- * }
- * ```
- *
- * Note: if an app only has one menu, there is no reason to pass an `id`.
- *
- *
- * @demo /docs/demos/src/menu/
- *
- * @see {@link /docs/components#menus Menu Component Docs}
- * @see {@link ../Menu Menu API Docs}
- *
- */
- var MenuController = (function () {
- function MenuController() {
- this._menus = [];
- }
- /**
- * Programatically open the Menu.
- * @param {string} [menuId] Optionally get the menu by its id, or side.
- * @return {Promise} returns a promise when the menu is fully opened
- */
- MenuController.prototype.open = function (menuId) {
- var menu = this.get(menuId);
- if (menu && !this.isAnimating()) {
- var openedMenu = this.getOpen();
- if (openedMenu && menu !== openedMenu) {
- openedMenu.setOpen(false, false);
- }
- return menu.open();
- }
- return Promise.resolve(false);
- };
- /**
- * Programatically close the Menu. If no `menuId` is given as the first
- * argument then it'll close any menu which is open. If a `menuId`
- * is given then it'll close that exact menu.
- * @param {string} [menuId] Optionally get the menu by its id, or side.
- * @return {Promise} returns a promise when the menu is fully closed
- */
- MenuController.prototype.close = function (menuId) {
- var menu;
- if (menuId) {
- // find the menu by its id
- menu = this.get(menuId);
- }
- else {
- // find the menu that is open
- menu = this.getOpen();
- }
- if (menu) {
- // close the menu
- return menu.close();
- }
- return Promise.resolve(false);
- };
- /**
- * Toggle the menu. If it's closed, it will open, and if opened, it
- * will close.
- * @param {string} [menuId] Optionally get the menu by its id, or side.
- * @return {Promise} returns a promise when the menu has been toggled
- */
- MenuController.prototype.toggle = function (menuId) {
- var menu = this.get(menuId);
- if (menu && !this.isAnimating()) {
- var openedMenu = this.getOpen();
- if (openedMenu && menu !== openedMenu) {
- openedMenu.setOpen(false, false);
- }
- return menu.toggle();
- }
- return Promise.resolve(false);
- };
- /**
- * Used to enable or disable a menu. For example, there could be multiple
- * left menus, but only one of them should be able to be opened at the same
- * time. If there are multiple menus on the same side, then enabling one menu
- * will also automatically disable all the others that are on the same side.
- * @param {string} [menuId] Optionally get the menu by its id, or side.
- * @return {Menu} Returns the instance of the menu, which is useful for chaining.
- */
- MenuController.prototype.enable = function (shouldEnable, menuId) {
- var menu = this.get(menuId);
- if (menu) {
- return menu.enable(shouldEnable);
- }
- };
- /**
- * Used to enable or disable the ability to swipe open the menu.
- * @param {boolean} shouldEnable True if it should be swipe-able, false if not.
- * @param {string} [menuId] Optionally get the menu by its id, or side.
- * @return {Menu} Returns the instance of the menu, which is useful for chaining.
- */
- MenuController.prototype.swipeEnable = function (shouldEnable, menuId) {
- var menu = this.get(menuId);
- if (menu) {
- return menu.swipeEnable(shouldEnable);
- }
- };
- /**
- * @param {string} [menuId] Optionally get the menu by its id, or side.
- * @return {boolean} Returns true if the specified menu is currently open, otherwise false.
- * If the menuId is not specified, it returns true if ANY menu is currenly open.
- */
- MenuController.prototype.isOpen = function (menuId) {
- if (menuId) {
- var menu = this.get(menuId);
- return menu && menu.isOpen || false;
- }
- else {
- return !!this.getOpen();
- }
- };
- /**
- * @param {string} [menuId] Optionally get the menu by its id, or side.
- * @return {boolean} Returns true if the menu is currently enabled, otherwise false.
- */
- MenuController.prototype.isEnabled = function (menuId) {
- var menu = this.get(menuId);
- return menu && menu.enabled || false;
- };
- /**
- * Used to get a menu instance. If a `menuId` is not provided then it'll
- * return the first menu found. If a `menuId` is `left` or `right`, then
- * it'll return the enabled menu on that side. Otherwise, if a `menuId` is
- * provided, then it'll try to find the menu using the menu's `id`
- * property. If a menu is not found then it'll return `null`.
- * @param {string} [menuId] Optionally get the menu by its id, or side.
- * @return {Menu} Returns the instance of the menu if found, otherwise `null`.
- */
- MenuController.prototype.get = function (menuId) {
- var menu;
- if (menuId === 'left' || menuId === 'right') {
- // there could be more than one menu on the same side
- // so first try to get the enabled one
- menu = this._menus.find(function (m) { return m.side === menuId && m.enabled; });
- if (menu) {
- return menu;
- }
- // didn't find a menu side that is enabled
- // so try to get the first menu side found
- return this._menus.find(function (m) { return m.side === menuId; }) || null;
- }
- else if (menuId) {
- // the menuId was not left or right
- // so try to get the menu by its "id"
- return this._menus.find(function (m) { return m.id === menuId; }) || null;
- }
- // return the first enabled menu
- menu = this._menus.find(function (m) { return m.enabled; });
- if (menu) {
- return menu;
- }
- // get the first menu in the array, if one exists
- return (this._menus.length ? this._menus[0] : null);
- };
- /**
- * @return {Menu} Returns the instance of the menu already opened, otherwise `null`.
- */
- MenuController.prototype.getOpen = function () {
- return this._menus.find(function (m) { return m.isOpen; });
- };
- /**
- * @return {Array<Menu>} Returns an array of all menu instances.
- */
- MenuController.prototype.getMenus = function () {
- return this._menus;
- };
- /**
- * @hidden
- * @return {boolean} if any menu is currently animating
- */
- MenuController.prototype.isAnimating = function () {
- return this._menus.some(function (menu) { return menu.isAnimating(); });
- };
- /**
- * @hidden
- */
- MenuController.prototype._register = function (menu) {
- (void 0) /* assert */;
- this._menus.push(menu);
- };
- /**
- * @hidden
- */
- MenuController.prototype._unregister = function (menu) {
- (void 0) /* assert */;
- removeArrayItem(this._menus, menu);
- };
- /**
- * @hidden
- */
- MenuController.prototype._setActiveMenu = function (menu) {
- (void 0) /* assert */;
- (void 0) /* assert */;
- // if this menu should be enabled
- // then find all the other menus on this same side
- // and automatically disable other same side menus
- var side = menu.side;
- this._menus
- .filter(function (m) { return m.side === side && m !== menu; })
- .map(function (m) { return m.enable(false); });
- };
- /**
- * @hidden
- */
- MenuController.registerType = function (name, cls) {
- menuTypes[name] = cls;
- };
- /**
- * @hidden
- */
- MenuController.create = function (type, menuCmp, plt) {
- return new menuTypes[type](menuCmp, plt);
- };
- return MenuController;
- }());
- var menuTypes = {};
-
- function getCss(docEle) {
- var css = {};
- // transform
- var i;
- var keys = ['webkitTransform', '-webkit-transform', 'webkit-transform', 'transform'];
- for (i = 0; i < keys.length; i++) {
- if (docEle.style[keys[i]] !== undefined) {
- css.transform = keys[i];
- break;
- }
- }
- // transition
- keys = ['webkitTransition', 'transition'];
- for (i = 0; i < keys.length; i++) {
- if (docEle.style[keys[i]] !== undefined) {
- css.transition = keys[i];
- break;
- }
- }
- // The only prefix we care about is webkit for transitions.
- var isWebkit = css.transition.indexOf('webkit') > -1;
- // transition duration
- css.transitionDuration = (isWebkit ? '-webkit-' : '') + 'transition-duration';
- // transition timing function
- css.transitionTimingFn = (isWebkit ? '-webkit-' : '') + 'transition-timing-function';
- // transition delay
- css.transitionDelay = (isWebkit ? '-webkit-' : '') + 'transition-delay';
- // To be sure transitionend works everywhere, include *both* the webkit and non-webkit events
- css.transitionEnd = (isWebkit ? 'webkitTransitionEnd ' : '') + 'transitionend';
- // transform origin
- css.transformOrigin = (isWebkit ? '-webkit-' : '') + 'transform-origin';
- // animation delay
- css.animationDelay = (isWebkit ? 'webkitAnimationDelay' : 'animationDelay');
- return css;
- }
- function pointerCoord(ev) {
- // get coordinates for either a mouse click
- // or a touch depending on the given event
- if (ev) {
- var changedTouches = ev.changedTouches;
- if (changedTouches && changedTouches.length > 0) {
- var touch = changedTouches[0];
- return { x: touch.clientX, y: touch.clientY };
- }
- var pageX = ev.pageX;
- if (pageX !== undefined) {
- return { x: pageX, y: ev.pageY };
- }
- }
- return { x: 0, y: 0 };
- }
- function hasPointerMoved(threshold, startCoord, endCoord) {
- if (startCoord && endCoord) {
- var deltaX = (startCoord.x - endCoord.x);
- var deltaY = (startCoord.y - endCoord.y);
- var distance = deltaX * deltaX + deltaY * deltaY;
- return distance > (threshold * threshold);
- }
- return false;
- }
- function isTextInput(ele) {
- return !!ele &&
- (ele.tagName === 'TEXTAREA' ||
- ele.contentEditable === 'true' ||
- (ele.tagName === 'INPUT' && !(NON_TEXT_INPUT_REGEX.test(ele.type))));
- }
- var NON_TEXT_INPUT_REGEX = /^(radio|checkbox|range|file|submit|reset|color|image|button)$/i;
- var SKIP_INPUT_ATTR = ['value', 'checked', 'disabled', 'readonly', 'placeholder', 'type', 'class', 'style', 'id', 'autofocus', 'autocomplete', 'autocorrect'];
- function copyInputAttributes(srcElement, destElement) {
- // copy attributes from one element to another
- // however, skip over a few of them as they're already
- // handled in the angular world
- var attrs = srcElement.attributes;
- for (var i = 0; i < attrs.length; i++) {
- var attr = attrs[i];
- if (SKIP_INPUT_ATTR.indexOf(attr.name) === -1) {
- destElement.setAttribute(attr.name, attr.value);
- }
- }
- }
-
- /**
- * @hidden
- */
- var QueryParams = (function () {
- function QueryParams() {
- this.data = {};
- }
- QueryParams.prototype.parseUrl = function (url) {
- if (url) {
- var startIndex = url.indexOf('?');
- if (startIndex > -1) {
- var queries = url.slice(startIndex + 1).split('&');
- for (var i = 0; i < queries.length; i++) {
- if (queries[i].indexOf('=') > 0) {
- var split = queries[i].split('=');
- if (split.length > 1) {
- this.data[split[0].toLowerCase()] = split[1].split('#')[0];
- }
- }
- }
- }
- }
- };
- QueryParams.prototype.get = function (key) {
- return this.data[key.toLowerCase()];
- };
- return QueryParams;
- }());
-
- /**
- * @name Platform
- * @description
- * The Platform service can be used to get information about your current device.
- * You can get all of the platforms associated with the device using the [platforms](#platforms)
- * method, including whether the app is being viewed from a tablet, if it's
- * on a mobile device or browser, and the exact platform (iOS, Android, etc).
- * You can also get the orientation of the device, if it uses right-to-left
- * language direction, and much much more. With this information you can completely
- * customize your app to fit any device.
- *
- * @usage
- * ```ts
- * import { Platform } from 'ionic-angular';
- *
- * @Component({...})
- * export MyPage {
- * constructor(public platform: Platform) {
- *
- * }
- * }
- * ```
- * @demo /docs/demos/src/platform/
- */
- var Platform = (function () {
- function Platform() {
- var _this = this;
- this._versions = {};
- this._qp = new QueryParams();
- this._bbActions = [];
- this._pW = 0;
- this._pH = 0;
- this._lW = 0;
- this._lH = 0;
- this._isPortrait = null;
- this._uiEvtOpts = false;
- /** @internal */
- this._platforms = [];
- // Events meant to be triggered by the engine
- // **********************************************
- /**
- * @hidden
- */
- this.backButton = new EventEmitter();
- /**
- * The pause event emits when the native platform puts the application
- * into the background, typically when the user switches to a different
- * application. This event would emit when a Cordova app is put into
- * the background, however, it would not fire on a standard web browser.
- */
- this.pause = new EventEmitter();
- /**
- * The resume event emits when the native platform pulls the application
- * out from the background. This event would emit when a Cordova app comes
- * out from the background, however, it would not fire on a standard web browser.
- */
- this.resume = new EventEmitter();
- /**
- * The resize event emits when the browser window has changed dimensions. This
- * could be from a browser window being physically resized, or from a device
- * changing orientation.
- */
- this.resize = new EventEmitter();
- this._readyPromise = new Promise(function (res) { _this._readyResolve = res; });
- this.backButton.subscribe(function () {
- // the hardware back button event has been fired
- (void 0) /* console.debug */;
- // decide which backbutton action should run
- _this.runBackButtonAction();
- });
- }
- /**
- * @hidden
- */
- Platform.prototype.setWindow = function (win) {
- this._win = win;
- };
- /**
- * @hidden
- */
- Platform.prototype.win = function () {
- return this._win;
- };
- /**
- * @hidden
- */
- Platform.prototype.setDocument = function (doc) {
- this._doc = doc;
- };
- /**
- * @hidden
- */
- Platform.prototype.doc = function () {
- return this._doc;
- };
- /**
- * @hidden
- */
- Platform.prototype.setZone = function (zone) {
- this.zone = zone;
- };
- /**
- * @hidden
- */
- Platform.prototype.setCssProps = function (docElement) {
- this.Css = getCss(docElement);
- };
- // Methods
- // **********************************************
- /**
- * @returns {boolean} returns true/false based on platform.
- * @description
- * Depending on the platform the user is on, `is(platformName)` will
- * return `true` or `false`. Note that the same app can return `true`
- * for more than one platform name. For example, an app running from
- * an iPad would return `true` for the platform names: `mobile`,
- * `ios`, `ipad`, and `tablet`. Additionally, if the app was running
- * from Cordova then `cordova` would be true, and if it was running
- * from a web browser on the iPad then `mobileweb` would be `true`.
- *
- * ```
- * import { Platform } from 'ionic-angular';
- *
- * @Component({...})
- * export MyPage {
- * constructor(public platform: Platform) {
- * if (this.platform.is('ios')) {
- * // This will only print when on iOS
- * console.log('I am an iOS device!');
- * }
- * }
- * }
- * ```
- *
- * | Platform Name | Description |
- * |-----------------|------------------------------------|
- * | android | on a device running Android. |
- * | cordova | on a device running Cordova. |
- * | core | on a desktop device. |
- * | ios | on a device running iOS. |
- * | ipad | on an iPad device. |
- * | iphone | on an iPhone device. |
- * | mobile | on a mobile device. |
- * | mobileweb | in a browser on a mobile device. |
- * | phablet | on a phablet device. |
- * | tablet | on a tablet device. |
- * | windows | on a device running Windows. |
- *
- * @param {string} platformName
- */
- Platform.prototype.is = function (platformName) {
- return (this._platforms.indexOf(platformName) > -1);
- };
- /**
- * @returns {array} the array of platforms
- * @description
- * Depending on what device you are on, `platforms` can return multiple values.
- * Each possible value is a hierarchy of platforms. For example, on an iPhone,
- * it would return `mobile`, `ios`, and `iphone`.
- *
- * ```
- * import { Platform } from 'ionic-angular';
- *
- * @Component({...})
- * export MyPage {
- * constructor(public platform: Platform) {
- * // This will print an array of the current platforms
- * console.log(this.platform.platforms());
- * }
- * }
- * ```
- */
- Platform.prototype.platforms = function () {
- // get the array of active platforms, which also knows the hierarchy,
- // with the last one the most important
- return this._platforms;
- };
- /**
- * Returns an object containing version information about all of the platforms.
- *
- * ```
- * import { Platform } from 'ionic-angular';
- *
- * @Component({...})
- * export MyPage {
- * constructor(public platform: Platform) {
- * // This will print an object containing
- * // all of the platforms and their versions
- * console.log(platform.versions());
- * }
- * }
- * ```
- *
- * @returns {object} An object containing all of the platforms and their versions.
- */
- Platform.prototype.versions = function () {
- // get all the platforms that have a valid parsed version
- return this._versions;
- };
- /**
- * @hidden
- */
- Platform.prototype.version = function () {
- for (var platformName in this._versions) {
- if (this._versions[platformName]) {
- return this._versions[platformName];
- }
- }
- return {};
- };
- /**
- * Returns a promise when the platform is ready and native functionality
- * can be called. If the app is running from within a web browser, then
- * the promise will resolve when the DOM is ready. When the app is running
- * from an application engine such as Cordova, then the promise will
- * resolve when Cordova triggers the `deviceready` event.
- *
- * The resolved value is the `readySource`, which states which platform
- * ready was used. For example, when Cordova is ready, the resolved ready
- * source is `cordova`. The default ready source value will be `dom`. The
- * `readySource` is useful if different logic should run depending on the
- * platform the app is running from. For example, only Cordova can execute
- * the status bar plugin, so the web should not run status bar plugin logic.
- *
- * ```
- * import { Component } from '@angular/core';
- * import { Platform } from 'ionic-angular';
- *
- * @Component({...})
- * export MyApp {
- * constructor(public platform: Platform) {
- * this.platform.ready().then((readySource) => {
- * console.log('Platform ready from', readySource);
- * // Platform now ready, execute any required native code
- * });
- * }
- * }
- * ```
- * @returns {promise}
- */
- Platform.prototype.ready = function () {
- return this._readyPromise;
- };
- /**
- * @hidden
- * This should be triggered by the engine when the platform is
- * ready. If there was no custom prepareReady method from the engine,
- * such as Cordova or Electron, then it uses the default DOM ready.
- */
- Platform.prototype.triggerReady = function (readySource) {
- var _this = this;
- this.zone.run(function () {
- _this._readyResolve(readySource);
- });
- };
- /**
- * @hidden
- * This is the default prepareReady if it's not replaced by an engine,
- * such as Cordova or Electron. If there was no custom prepareReady
- * method from an engine then it uses the method below, which triggers
- * the platform ready on the DOM ready event, and the default resolved
- * value is `dom`.
- */
- Platform.prototype.prepareReady = function () {
- var self = this;
- if (self._doc.readyState === 'complete' || self._doc.readyState === 'interactive') {
- self.triggerReady('dom');
- }
- else {
- self._doc.addEventListener('DOMContentLoaded', completed, false);
- self._win.addEventListener('load', completed, false);
- }
- function completed() {
- self._doc.removeEventListener('DOMContentLoaded', completed, false);
- self._win.removeEventListener('load', completed, false);
- self.triggerReady('dom');
- }
- };
- /**
- * Set the app's language direction, which will update the `dir` attribute
- * on the app's root `<html>` element. We recommend the app's `index.html`
- * file already has the correct `dir` attribute value set, such as
- * `<html dir="ltr">` or `<html dir="rtl">`. This method is useful if the
- * direction needs to be dynamically changed per user/session.
- * [W3C: Structural markup and right-to-left text in HTML](http://www.w3.org/International/questions/qa-html-dir)
- * @param {DocumentDirection} dir Examples: `rtl`, `ltr`
- * @param {boolean} updateDocument
- */
- Platform.prototype.setDir = function (dir, updateDocument) {
- this._dir = dir;
- this.isRTL = (dir === 'rtl');
- if (updateDocument !== false) {
- this._doc['documentElement'].setAttribute('dir', dir);
- }
- };
- /**
- * Returns app's language direction.
- * We recommend the app's `index.html` file already has the correct `dir`
- * attribute value set, such as `<html dir="ltr">` or `<html dir="rtl">`.
- * [W3C: Structural markup and right-to-left text in HTML](http://www.w3.org/International/questions/qa-html-dir)
- * @returns {DocumentDirection}
- */
- Platform.prototype.dir = function () {
- return this._dir;
- };
- /**
- * Set the app's language and optionally the country code, which will update
- * the `lang` attribute on the app's root `<html>` element.
- * We recommend the app's `index.html` file already has the correct `lang`
- * attribute value set, such as `<html lang="en">`. This method is useful if
- * the language needs to be dynamically changed per user/session.
- * [W3C: Declaring language in HTML](http://www.w3.org/International/questions/qa-html-language-declarations)
- * @param {string} language Examples: `en-US`, `en-GB`, `ar`, `de`, `zh`, `es-MX`
- * @param {boolean} updateDocument Specifies whether the `lang` attribute of `<html>` should be updated
- */
- Platform.prototype.setLang = function (language, updateDocument) {
- this._lang = language;
- if (updateDocument !== false) {
- this._doc['documentElement'].setAttribute('lang', language);
- }
- };
- /**
- * Returns app's language and optional country code.
- * We recommend the app's `index.html` file already has the correct `lang`
- * attribute value set, such as `<html lang="en">`.
- * [W3C: Declaring language in HTML](http://www.w3.org/International/questions/qa-html-language-declarations)
- * @returns {string}
- */
- Platform.prototype.lang = function () {
- return this._lang;
- };
- // Methods meant to be overridden by the engine
- // **********************************************
- // Provided NOOP methods so they do not error when
- // called by engines (the browser)that do not provide them
- /**
- * @hidden
- */
- Platform.prototype.exitApp = function () { };
- /**
- * The back button event is triggered when the user presses the native
- * platform's back button, also referred to as the "hardware" back button.
- * This event is only used within Cordova apps running on Android and
- * Windows platforms. This event is not fired on iOS since iOS doesn't come
- * with a hardware back button in the same sense an Android or Windows device
- * does.
- *
- * Registering a hardware back button action and setting a priority allows
- * apps to control which action should be called when the hardware back
- * button is pressed. This method decides which of the registered back button
- * actions has the highest priority and should be called.
- *
- * @param {Function} fn Called when the back button is pressed,
- * if this registered action has the highest priority.
- * @param {number} priority Set the priority for this action. Only the highest priority will execute. Defaults to `0`.
- * @returns {Function} A function that, when called, will unregister
- * the back button action.
- */
- Platform.prototype.registerBackButtonAction = function (fn, priority) {
- var _this = this;
- if (priority === void 0) { priority = 0; }
- var action = { fn: fn, priority: priority };
- this._bbActions.push(action);
- // return a function to unregister this back button action
- return function () {
- removeArrayItem(_this._bbActions, action);
- };
- };
- /**
- * @hidden
- */
- Platform.prototype.runBackButtonAction = function () {
- // decide which one back button action should run
- var winner = null;
- this._bbActions.forEach(function (action) {
- if (!winner || action.priority >= winner.priority) {
- winner = action;
- }
- });
- // run the winning action if there is one
- winner && winner.fn && winner.fn();
- };
- // Getter/Setter Methods
- // **********************************************
- /**
- * @hidden
- */
- Platform.prototype.setUserAgent = function (userAgent) {
- this._ua = userAgent;
- };
- /**
- * @hidden
- */
- Platform.prototype.setQueryParams = function (url) {
- this._qp.parseUrl(url);
- };
- /**
- * Get the query string parameter
- */
- Platform.prototype.getQueryParam = function (key) {
- return this._qp.get(key);
- };
- /**
- * Get the current url.
- */
- Platform.prototype.url = function () {
- return this._win['location']['href'];
- };
- /**
- * @hidden
- */
- Platform.prototype.userAgent = function () {
- return this._ua || '';
- };
- /**
- * @hidden
- */
- Platform.prototype.setNavigatorPlatform = function (navigatorPlt) {
- this._nPlt = navigatorPlt;
- };
- /**
- * @hidden
- */
- Platform.prototype.navigatorPlatform = function () {
- return this._nPlt || '';
- };
- /**
- * Gets the width of the platform's viewport using `window.innerWidth`.
- * Using this method is preferred since the dimension is a cached value,
- * which reduces the chance of multiple and expensive DOM reads.
- */
- Platform.prototype.width = function () {
- this._calcDim();
- return this._isPortrait ? this._pW : this._lW;
- };
- /**
- * Gets the height of the platform's viewport using `window.innerHeight`.
- * Using this method is preferred since the dimension is a cached value,
- * which reduces the chance of multiple and expensive DOM reads.
- */
- Platform.prototype.height = function () {
- this._calcDim();
- return this._isPortrait ? this._pH : this._lH;
- };
- /**
- * @hidden
- */
- Platform.prototype.getElementComputedStyle = function (ele, pseudoEle) {
- return this._win['getComputedStyle'](ele, pseudoEle);
- };
- /**
- * @hidden
- */
- Platform.prototype.getElementFromPoint = function (x, y) {
- return this._doc['elementFromPoint'](x, y);
- };
- /**
- * @hidden
- */
- Platform.prototype.getElementBoundingClientRect = function (ele) {
- return ele['getBoundingClientRect']();
- };
- /**
- * Returns `true` if the app is in portait mode.
- */
- Platform.prototype.isPortrait = function () {
- this._calcDim();
- return this._isPortrait;
- };
- /**
- * Returns `true` if the app is in landscape mode.
- */
- Platform.prototype.isLandscape = function () {
- return !this.isPortrait();
- };
- Platform.prototype._calcDim = function () {
- // we're caching window dimensions so that
- // we're not forcing many layouts
- // if _isPortrait is null then that means
- // the dimensions needs to be looked up again
- // this also has to cover an edge case that only
- // happens on iOS 10 (not other versions of iOS)
- // where window.innerWidth is always bigger than
- // window.innerHeight when it is first measured,
- // even when the device is in portrait but
- // the second time it is measured it is correct.
- // Hopefully this check will not be needed in the future
- if (this._isPortrait === null || this._isPortrait === false && this._win['innerWidth'] < this._win['innerHeight']) {
- var win = this._win;
- var innerWidth = win['innerWidth'];
- var innerHeight = win['innerHeight'];
- // we're keeping track of portrait and landscape dimensions
- // separately because the virtual keyboard can really mess
- // up accurate values when the keyboard is up
- if (win.screen.width > 0 && win.screen.height > 0) {
- if (innerWidth < innerHeight) {
- // the device is in portrait
- // we have to do fancier checking here
- // because of the virtual keyboard resizing
- // the window
- if (this._pW <= innerWidth) {
- (void 0) /* console.debug */;
- this._isPortrait = true;
- this._pW = innerWidth;
- }
- if (this._pH <= innerHeight) {
- (void 0) /* console.debug */;
- this._isPortrait = true;
- this._pH = innerHeight;
- }
- }
- else {
- // the device is in landscape
- if (this._lW !== innerWidth) {
- (void 0) /* console.debug */;
- this._isPortrait = false;
- this._lW = innerWidth;
- }
- if (this._lH !== innerHeight) {
- (void 0) /* console.debug */;
- this._isPortrait = false;
- this._lH = innerHeight;
- }
- }
- }
- }
- };
- /**
- * @hidden
- * This requestAnimationFrame will NOT be wrapped by zone.
- */
- Platform.prototype.raf = function (callback) {
- var win = this._win;
- return win['__zone_symbol__requestAnimationFrame'](callback);
- };
- /**
- * @hidden
- */
- Platform.prototype.cancelRaf = function (rafId) {
- var win = this._win;
- return win['__zone_symbol__cancelAnimationFrame'](rafId);
- };
- /**
- * @hidden
- * This setTimeout will NOT be wrapped by zone.
- */
- Platform.prototype.timeout = function (callback, timeout) {
- var win = this._win;
- return win['__zone_symbol__setTimeout'](callback, timeout);
- };
- /**
- * @hidden
- * This setTimeout will NOT be wrapped by zone.
- */
- Platform.prototype.cancelTimeout = function (timeoutId) {
- var win = this._win;
- win['__zone_symbol__clearTimeout'](timeoutId);
- };
- /**
- * @hidden
- * Built to use modern event listener options, like "passive".
- * If options are not supported, then just return a boolean which
- * represents "capture". Returns a method to remove the listener.
- */
- Platform.prototype.registerListener = function (ele, eventName, callback, opts, unregisterListenersCollection) {
- // use event listener options when supported
- // otherwise it's just a boolean for the "capture" arg
- var listenerOpts = this._uiEvtOpts ? {
- 'capture': !!opts.capture,
- 'passive': !!opts.passive,
- } : !!opts.capture;
- var unReg;
- if (!opts.zone && ele['__zone_symbol__addEventListener']) {
- // do not wrap this event in zone and we've verified we can use the raw addEventListener
- ele['__zone_symbol__addEventListener'](eventName, callback, listenerOpts);
- unReg = function unregisterListener() {
- ele['__zone_symbol__removeEventListener'](eventName, callback, listenerOpts);
- };
- }
- else {
- // use the native addEventListener, which is wrapped with zone
- ele['addEventListener'](eventName, callback, listenerOpts);
- unReg = function unregisterListener() {
- ele['removeEventListener'](eventName, callback, listenerOpts);
- };
- }
- if (unregisterListenersCollection) {
- unregisterListenersCollection.push(unReg);
- }
- return unReg;
- };
- /**
- * @hidden
- */
- Platform.prototype.transitionEnd = function (el, callback, zone) {
- if (zone === void 0) { zone = true; }
- var unRegs = [];
- function unregister() {
- unRegs.forEach(function (unReg) {
- unReg();
- });
- }
- function onTransitionEnd(ev) {
- if (el === ev.target) {
- unregister();
- callback(ev);
- }
- }
- if (el) {
- this.registerListener(el, 'webkitTransitionEnd', onTransitionEnd, { zone: zone }, unRegs);
- this.registerListener(el, 'transitionend', onTransitionEnd, { zone: zone }, unRegs);
- }
- return unregister;
- };
- /**
- * @hidden
- */
- Platform.prototype.windowLoad = function (callback) {
- var win = this._win;
- var doc = this._doc;
- var unreg;
- if (doc.readyState === 'complete') {
- callback(win, doc);
- }
- else {
- unreg = this.registerListener(win, 'load', function () {
- unreg && unreg();
- callback(win, doc);
- }, { zone: false });
- }
- };
- /**
- * @hidden
- */
- Platform.prototype.isActiveElement = function (ele) {
- return !!(ele && (this.getActiveElement() === ele));
- };
- /**
- * @hidden
- */
- Platform.prototype.getActiveElement = function () {
- return this._doc['activeElement'];
- };
- /**
- * @hidden
- */
- Platform.prototype.hasFocus = function (ele) {
- return !!((ele && (this.getActiveElement() === ele)) && (ele.parentElement.querySelector(':focus') === ele));
- };
- /**
- * @hidden
- */
- Platform.prototype.hasFocusedTextInput = function () {
- var ele = this.getActiveElement();
- if (isTextInput(ele)) {
- return (ele.parentElement.querySelector(':focus') === ele);
- }
- return false;
- };
- /**
- * @hidden
- */
- Platform.prototype.focusOutActiveElement = function () {
- var activeElement = this.getActiveElement();
- activeElement && activeElement.blur && activeElement.blur();
- };
- Platform.prototype._initEvents = function () {
- var _this = this;
- // Test via a getter in the options object to see if the passive property is accessed
- try {
- var opts = Object.defineProperty({}, 'passive', {
- get: function () {
- _this._uiEvtOpts = true;
- }
- });
- this._win.addEventListener('optsTest', null, opts);
- }
- catch (e) { }
- // add the window resize event listener XXms after
- this.timeout(function () {
- var timerId;
- _this.registerListener(_this._win, 'resize', function () {
- clearTimeout(timerId);
- timerId = setTimeout(function () {
- // setting _isPortrait to null means the
- // dimensions will need to be looked up again
- if (_this.hasFocusedTextInput() === false) {
- _this._isPortrait = null;
- }
- _this.zone.run(function () { return _this.resize.emit(); });
- }, 200);
- }, { passive: true, zone: false });
- }, 2000);
- };
- // Platform Registry
- // **********************************************
- /**
- * @hidden
- */
- Platform.prototype.setPlatformConfigs = function (platformConfigs) {
- this._registry = platformConfigs || {};
- };
- /**
- * @hidden
- */
- Platform.prototype.getPlatformConfig = function (platformName) {
- return this._registry[platformName] || {};
- };
- /**
- * @hidden
- */
- Platform.prototype.registry = function () {
- return this._registry;
- };
- /**
- * @hidden
- */
- Platform.prototype.setDefault = function (platformName) {
- this._default = platformName;
- };
- /**
- * @hidden
- */
- Platform.prototype.testQuery = function (queryValue, queryTestValue) {
- var valueSplit = queryValue.toLowerCase().split(';');
- return valueSplit.indexOf(queryTestValue) > -1;
- };
- /**
- * @hidden
- */
- Platform.prototype.testNavigatorPlatform = function (navigatorPlatformExpression) {
- var rgx = new RegExp(navigatorPlatformExpression, 'i');
- return rgx.test(this._nPlt);
- };
- /**
- * @hidden
- */
- Platform.prototype.matchUserAgentVersion = function (userAgentExpression) {
- if (this._ua && userAgentExpression) {
- var val = this._ua.match(userAgentExpression);
- if (val) {
- return {
- major: val[1],
- minor: val[2]
- };
- }
- }
- };
- Platform.prototype.testUserAgent = function (expression) {
- if (this._ua) {
- return this._ua.indexOf(expression) >= 0;
- }
- return false;
- };
- /**
- * @hidden
- */
- Platform.prototype.isPlatformMatch = function (queryStringName, userAgentAtLeastHas, userAgentMustNotHave) {
- if (userAgentMustNotHave === void 0) { userAgentMustNotHave = []; }
- var queryValue = this._qp.get('ionicplatform');
- if (queryValue) {
- return this.testQuery(queryValue, queryStringName);
- }
- userAgentAtLeastHas = userAgentAtLeastHas || [queryStringName];
- var userAgent = this._ua.toLowerCase();
- for (var i = 0; i < userAgentAtLeastHas.length; i++) {
- if (userAgent.indexOf(userAgentAtLeastHas[i]) > -1) {
- for (var j = 0; j < userAgentMustNotHave.length; j++) {
- if (userAgent.indexOf(userAgentMustNotHave[j]) > -1) {
- return false;
- }
- }
- return true;
- }
- }
- return false;
- };
- /** @hidden */
- Platform.prototype.init = function () {
- this._initEvents();
- var rootPlatformNode;
- var enginePlatformNode;
- // figure out the most specific platform and active engine
- var tmpPlt;
- for (var platformName in this._registry) {
- tmpPlt = this.matchPlatform(platformName);
- if (tmpPlt) {
- // we found a platform match!
- // check if its more specific than the one we already have
- if (tmpPlt.isEngine) {
- // because it matched then this should be the active engine
- // you cannot have more than one active engine
- enginePlatformNode = tmpPlt;
- }
- else if (!rootPlatformNode || tmpPlt.depth > rootPlatformNode.depth) {
- // only find the root node for platforms that are not engines
- // set this node as the root since we either don't already
- // have one, or this one is more specific that the current one
- rootPlatformNode = tmpPlt;
- }
- }
- }
- if (!rootPlatformNode) {
- rootPlatformNode = new PlatformNode(this._registry, this._default);
- }
- // build a Platform instance filled with the
- // hierarchy of active platforms and settings
- if (rootPlatformNode) {
- // check if we found an engine node (cordova/node-webkit/etc)
- if (enginePlatformNode) {
- // add the engine to the first in the platform hierarchy
- // the original rootPlatformNode now becomes a child
- // of the engineNode, which is not the new root
- enginePlatformNode.child = rootPlatformNode;
- rootPlatformNode.parent = enginePlatformNode;
- rootPlatformNode = enginePlatformNode;
- }
- var platformNode = rootPlatformNode;
- while (platformNode) {
- insertSuperset(this._registry, platformNode);
- platformNode = platformNode.child;
- }
- // make sure the root noot is actually the root
- // incase a node was inserted before the root
- platformNode = rootPlatformNode.parent;
- while (platformNode) {
- rootPlatformNode = platformNode;
- platformNode = platformNode.parent;
- }
- platformNode = rootPlatformNode;
- while (platformNode) {
- platformNode.initialize(this);
- // extra check for ipad pro issue
- // https://forums.developer.apple.com/thread/25948
- if (platformNode.name === 'iphone' && this.navigatorPlatform() === 'iPad') {
- // this is an ipad pro so push ipad and tablet to platforms
- // and then return as we are done
- this._platforms.push('tablet');
- this._platforms.push('ipad');
- return;
- }
- // set the array of active platforms with
- // the last one in the array the most important
- this._platforms.push(platformNode.name);
- // get the platforms version if a version parser was provided
- this._versions[platformNode.name] = platformNode.version(this);
- // go to the next platform child
- platformNode = platformNode.child;
- }
- }
- if (this._platforms.indexOf('mobile') > -1 && this._platforms.indexOf('cordova') === -1) {
- this._platforms.push('mobileweb');
- }
- };
- /**
- * @hidden
- */
- Platform.prototype.matchPlatform = function (platformName) {
- // build a PlatformNode and assign config data to it
- // use it's getRoot method to build up its hierarchy
- // depending on which platforms match
- var platformNode = new PlatformNode(this._registry, platformName);
- var rootNode = platformNode.getRoot(this);
- if (rootNode) {
- rootNode.depth = 0;
- var childPlatform = rootNode.child;
- while (childPlatform) {
- rootNode.depth++;
- childPlatform = childPlatform.child;
- }
- }
- return rootNode;
- };
- return Platform;
- }());
- function insertSuperset(registry, platformNode) {
- var supersetPlaformName = platformNode.superset();
- if (supersetPlaformName) {
- // add a platform in between two exist platforms
- // so we can build the correct hierarchy of active platforms
- var supersetPlatform = new PlatformNode(registry, supersetPlaformName);
- supersetPlatform.parent = platformNode.parent;
- supersetPlatform.child = platformNode;
- if (supersetPlatform.parent) {
- supersetPlatform.parent.child = supersetPlatform;
- }
- platformNode.parent = supersetPlatform;
- }
- }
- /**
- * @hidden
- */
- var PlatformNode = (function () {
- function PlatformNode(registry, platformName) {
- this.registry = registry;
- this.c = registry[platformName];
- this.name = platformName;
- this.isEngine = this.c.isEngine;
- }
- PlatformNode.prototype.settings = function () {
- return this.c.settings || {};
- };
- PlatformNode.prototype.superset = function () {
- return this.c.superset;
- };
- PlatformNode.prototype.isMatch = function (p) {
- return this.c.isMatch && this.c.isMatch(p) || false;
- };
- PlatformNode.prototype.initialize = function (plt) {
- this.c.initialize && this.c.initialize(plt);
- };
- PlatformNode.prototype.version = function (plt) {
- if (this.c.versionParser) {
- var v = this.c.versionParser(plt);
- if (v) {
- var str = v.major + '.' + v.minor;
- return {
- str: str,
- num: parseFloat(str),
- major: parseInt(v.major, 10),
- minor: parseInt(v.minor, 10)
- };
- }
- }
- };
- PlatformNode.prototype.getRoot = function (plt) {
- if (this.isMatch(plt)) {
- var parents = this.getSubsetParents(this.name);
- if (!parents.length) {
- return this;
- }
- var platformNode = null;
- var rootPlatformNode = null;
- for (var i = 0; i < parents.length; i++) {
- platformNode = new PlatformNode(this.registry, parents[i]);
- platformNode.child = this;
- rootPlatformNode = platformNode.getRoot(plt);
- if (rootPlatformNode) {
- this.parent = platformNode;
- return rootPlatformNode;
- }
- }
- }
- return null;
- };
- PlatformNode.prototype.getSubsetParents = function (subsetPlatformName) {
- var parentPlatformNames = [];
- var pltConfig = null;
- for (var platformName in this.registry) {
- pltConfig = this.registry[platformName];
- if (pltConfig.subsets && pltConfig.subsets.indexOf(subsetPlatformName) > -1) {
- parentPlatformNames.push(platformName);
- }
- }
- return parentPlatformNames;
- };
- return PlatformNode;
- }());
- /**
- * @hidden
- */
- function setupPlatform(doc, platformConfigs, zone) {
- var plt = new Platform();
- plt.setDefault('core');
- plt.setPlatformConfigs(platformConfigs);
- plt.setZone(zone);
- // set values from "document"
- var docElement = doc.documentElement;
- plt.setDocument(doc);
- var dir = docElement.dir;
- plt.setDir(dir === 'rtl' ? 'rtl' : 'ltr', !dir);
- plt.setLang(docElement.lang, false);
- // set css properties
- plt.setCssProps(docElement);
- // set values from "window"
- var win = doc.defaultView;
- plt.setWindow(win);
- plt.setNavigatorPlatform(win.navigator.platform);
- plt.setUserAgent(win.navigator.userAgent);
- // set location values
- plt.setQueryParams(win.location.href);
- plt.init();
- // add the platform obj to the window
- win['Ionic'] = win['Ionic'] || {};
- win['Ionic']['platform'] = plt;
- return plt;
- }
-
- /**
- * @hidden
- */
- var Animation = (function () {
- function Animation(plt, ele, opts) {
- this._dur = null;
- this._es = null;
- this._rvEs = null;
- this.hasChildren = false;
- this.isPlaying = false;
- this.hasCompleted = false;
- this.plt = plt;
- this.element(ele);
- this.opts = opts;
- }
- Animation.prototype.element = function (ele) {
- if (ele) {
- if (typeof ele === 'string') {
- ele = this.plt.doc().querySelectorAll(ele);
- for (var i = 0; i < ele.length; i++) {
- this._addEle(ele[i]);
- }
- }
- else if (ele.length) {
- for (var i = 0; i < ele.length; i++) {
- this._addEle(ele[i]);
- }
- }
- else {
- this._addEle(ele);
- }
- }
- return this;
- };
- /**
- * NO DOM
- */
- Animation.prototype._addEle = function (ele) {
- if (ele.nativeElement) {
- ele = ele.nativeElement;
- }
- if (ele.nodeType === 1) {
- this._eL = (this._e = this._e || []).push(ele);
- }
- };
- /**
- * Add a child animation to this animation.
- */
- Animation.prototype.add = function (childAnimation) {
- childAnimation.parent = this;
- this.hasChildren = true;
- this._cL = (this._c = this._c || []).push(childAnimation);
- return this;
- };
- /**
- * Get the duration of this animation. If this animation does
- * not have a duration, then it'll get the duration from its parent.
- */
- Animation.prototype.getDuration = function (opts) {
- if (opts && isDefined(opts.duration)) {
- return opts.duration;
- }
- else if (this._dur !== null) {
- return this._dur;
- }
- else if (this.parent) {
- return this.parent.getDuration();
- }
- return 0;
- };
- /**
- * Returns if the animation is a root one.
- */
- Animation.prototype.isRoot = function () {
- return !this.parent;
- };
- /**
- * Set the duration for this animation.
- */
- Animation.prototype.duration = function (milliseconds) {
- this._dur = milliseconds;
- return this;
- };
- /**
- * Get the easing of this animation. If this animation does
- * not have an easing, then it'll get the easing from its parent.
- */
- Animation.prototype.getEasing = function () {
- if (this._rv && this._rvEs) {
- return this._rvEs;
- }
- return this._es !== null ? this._es : (this.parent && this.parent.getEasing()) || null;
- };
- /**
- * Set the easing for this animation.
- */
- Animation.prototype.easing = function (name) {
- this._es = name;
- return this;
- };
- /**
- * Set the easing for this reversed animation.
- */
- Animation.prototype.easingReverse = function (name) {
- this._rvEs = name;
- return this;
- };
- /**
- * Add the "from" value for a specific property.
- */
- Animation.prototype.from = function (prop, val) {
- this._addProp('from', prop, val);
- return this;
- };
- /**
- * Add the "to" value for a specific property.
- */
- Animation.prototype.to = function (prop, val, clearProperyAfterTransition) {
- var fx = this._addProp('to', prop, val);
- if (clearProperyAfterTransition) {
- // if this effect is a transform then clear the transform effect
- // otherwise just clear the actual property
- this.afterClearStyles([fx.trans ? this.plt.Css.transform : prop]);
- }
- return this;
- };
- /**
- * Shortcut to add both the "from" and "to" for the same property.
- */
- Animation.prototype.fromTo = function (prop, fromVal, toVal, clearProperyAfterTransition) {
- return this.from(prop, fromVal).to(prop, toVal, clearProperyAfterTransition);
- };
- /**
- * @hidden
- * NO DOM
- */
- Animation.prototype._getProp = function (name) {
- if (this._fx) {
- return this._fx.find(function (prop) { return prop.name === name; });
- }
- else {
- this._fx = [];
- }
- return null;
- };
- Animation.prototype._addProp = function (state, prop, val) {
- var fxProp = this._getProp(prop);
- if (!fxProp) {
- // first time we've see this EffectProperty
- var shouldTrans = (ANIMATION_TRANSFORMS[prop] === 1);
- fxProp = {
- name: prop,
- trans: shouldTrans,
- // add the will-change property for transforms or opacity
- wc: (shouldTrans ? this.plt.Css.transform : prop)
- };
- this._fx.push(fxProp);
- }
- // add from/to EffectState to the EffectProperty
- var fxState = {
- val: val,
- num: null,
- unit: '',
- };
- fxProp[state] = fxState;
- if (typeof val === 'string' && val.indexOf(' ') < 0) {
- var r = val.match(ANIMATION_CSS_VALUE_REGEX);
- var num = parseFloat(r[1]);
- if (!isNaN(num)) {
- fxState.num = num;
- }
- fxState.unit = (r[0] !== r[2] ? r[2] : '');
- }
- else if (typeof val === 'number') {
- fxState.num = val;
- }
- return fxProp;
- };
- /**
- * Add CSS class to this animation's elements
- * before the animation begins.
- */
- Animation.prototype.beforeAddClass = function (className) {
- (this._bfAdd = this._bfAdd || []).push(className);
- return this;
- };
- /**
- * Remove CSS class from this animation's elements
- * before the animation begins.
- */
- Animation.prototype.beforeRemoveClass = function (className) {
- (this._bfRm = this._bfRm || []).push(className);
- return this;
- };
- /**
- * Set CSS inline styles to this animation's elements
- * before the animation begins.
- */
- Animation.prototype.beforeStyles = function (styles) {
- this._bfSty = styles;
- return this;
- };
- /**
- * Clear CSS inline styles from this animation's elements
- * before the animation begins.
- */
- Animation.prototype.beforeClearStyles = function (propertyNames) {
- this._bfSty = this._bfSty || {};
- for (var i = 0; i < propertyNames.length; i++) {
- this._bfSty[propertyNames[i]] = '';
- }
- return this;
- };
- /**
- * Add a function which contains DOM reads, which will run
- * before the animation begins.
- */
- Animation.prototype.beforeAddRead = function (domReadFn) {
- (this._rdFn = this._rdFn || []).push(domReadFn);
- return this;
- };
- /**
- * Add a function which contains DOM writes, which will run
- * before the animation begins.
- */
- Animation.prototype.beforeAddWrite = function (domWriteFn) {
- (this._wrFn = this._wrFn || []).push(domWriteFn);
- return this;
- };
- /**
- * Add CSS class to this animation's elements
- * after the animation finishes.
- */
- Animation.prototype.afterAddClass = function (className) {
- (this._afAdd = this._afAdd || []).push(className);
- return this;
- };
- /**
- * Remove CSS class from this animation's elements
- * after the animation finishes.
- */
- Animation.prototype.afterRemoveClass = function (className) {
- (this._afRm = this._afRm || []).push(className);
- return this;
- };
- /**
- * Set CSS inline styles to this animation's elements
- * after the animation finishes.
- */
- Animation.prototype.afterStyles = function (styles) {
- this._afSty = styles;
- return this;
- };
- /**
- * Clear CSS inline styles from this animation's elements
- * after the animation finishes.
- */
- Animation.prototype.afterClearStyles = function (propertyNames) {
- this._afSty = this._afSty || {};
- for (var i = 0; i < propertyNames.length; i++) {
- this._afSty[propertyNames[i]] = '';
- }
- return this;
- };
- /**
- * Play the animation.
- */
- Animation.prototype.play = function (opts) {
- var _this = this;
- // If the animation was already invalidated (it did finish), do nothing
- if (!this.plt) {
- return;
- }
- // this is the top level animation and is in full control
- // of when the async play() should actually kick off
- // if there is no duration then it'll set the TO property immediately
- // if there is a duration, then it'll stage all animations at the
- // FROM property and transition duration, wait a few frames, then
- // kick off the animation by setting the TO property for each animation
- this._isAsync = this._hasDuration(opts);
- // ensure all past transition end events have been cleared
- this._clearAsync();
- // recursively kicks off the correct progress step for each child animation
- // ******** DOM WRITE ****************
- this._playInit(opts);
- // doubling up RAFs since this animation was probably triggered
- // from an input event, and just having one RAF would have this code
- // run within the same frame as the triggering input event, and the
- // input event probably already did way too much work for one frame
- this.plt.raf(function () {
- _this.plt.raf(_this._playDomInspect.bind(_this, opts));
- });
- };
- Animation.prototype.syncPlay = function () {
- // If the animation was already invalidated (it did finish), do nothing
- if (!this.plt) {
- return;
- }
- var opts = { duration: 0 };
- this._isAsync = false;
- this._clearAsync();
- this._playInit(opts);
- this._playDomInspect(opts);
- };
- /**
- * @hidden
- * DOM WRITE
- * RECURSION
- */
- Animation.prototype._playInit = function (opts) {
- // always default that an animation does not tween
- // a tween requires that an Animation class has an element
- // and that it has at least one FROM/TO effect
- // and that the FROM/TO effect can tween numeric values
- this._twn = false;
- this.isPlaying = true;
- this.hasCompleted = false;
- this._hasDur = (this.getDuration(opts) > ANIMATION_DURATION_MIN);
- var children = this._c;
- for (var i = 0; i < this._cL; i++) {
- // ******** DOM WRITE ****************
- children[i]._playInit(opts);
- }
- if (this._hasDur) {
- // if there is a duration then we want to start at step 0
- // ******** DOM WRITE ****************
- this._progress(0);
- // add the will-change properties
- // ******** DOM WRITE ****************
- this._willChg(true);
- }
- };
- /**
- * @hidden
- * DOM WRITE
- * NO RECURSION
- * ROOT ANIMATION
- */
- Animation.prototype._playDomInspect = function (opts) {
- // fire off all the "before" function that have DOM READS in them
- // elements will be in the DOM, however visibily hidden
- // so we can read their dimensions if need be
- // ******** DOM READ ****************
- // ******** DOM WRITE ****************
- this._beforeAnimation();
- // for the root animation only
- // set the async TRANSITION END event
- // and run onFinishes when the transition ends
- var dur = this.getDuration(opts);
- if (this._isAsync) {
- this._asyncEnd(dur, true);
- }
- // ******** DOM WRITE ****************
- this._playProgress(opts);
- if (this._isAsync && this.plt) {
- // this animation has a duration so we need another RAF
- // for the CSS TRANSITION properties to kick in
- this.plt.raf(this._playToStep.bind(this, 1));
- }
- };
- /**
- * @hidden
- * DOM WRITE
- * RECURSION
- */
- Animation.prototype._playProgress = function (opts) {
- var children = this._c;
- for (var i = 0; i < this._cL; i++) {
- // ******** DOM WRITE ****************
- children[i]._playProgress(opts);
- }
- if (this._hasDur) {
- // set the CSS TRANSITION duration/easing
- // ******** DOM WRITE ****************
- this._setTrans(this.getDuration(opts), false);
- }
- else {
- // this animation does not have a duration, so it should not animate
- // just go straight to the TO properties and call it done
- // ******** DOM WRITE ****************
- this._progress(1);
- // since there was no animation, immediately run the after
- // ******** DOM WRITE ****************
- this._setAfterStyles();
- // this animation has no duration, so it has finished
- // other animations could still be running
- this._didFinish(true);
- }
- };
- /**
- * @hidden
- * DOM WRITE
- * RECURSION
- */
- Animation.prototype._playToStep = function (stepValue) {
- var children = this._c;
- for (var i = 0; i < this._cL; i++) {
- // ******** DOM WRITE ****************
- children[i]._playToStep(stepValue);
- }
- if (this._hasDur) {
- // browser had some time to render everything in place
- // and the transition duration/easing is set
- // now set the TO properties which will trigger the transition to begin
- // ******** DOM WRITE ****************
- this._progress(stepValue);
- }
- };
- /**
- * @hidden
- * DOM WRITE
- * NO RECURSION
- * ROOT ANIMATION
- */
- Animation.prototype._asyncEnd = function (dur, shouldComplete) {
- (void 0) /* assert */;
- (void 0) /* assert */;
- (void 0) /* assert */;
- var self = this;
- function onTransitionEnd() {
- // congrats! a successful transition completed!
- // ensure transition end events and timeouts have been cleared
- self._clearAsync();
- // ******** DOM WRITE ****************
- self._playEnd();
- // transition finished
- self._didFinishAll(shouldComplete, true, false);
- }
- function onTransitionFallback() {
- (void 0) /* console.debug */;
- // oh noz! the transition end event didn't fire in time!
- // instead the fallback timer when first
- // if all goes well this fallback should never fire
- // clear the other async end events from firing
- self._tm = undefined;
- self._clearAsync();
- // set the after styles
- // ******** DOM WRITE ****************
- self._playEnd(shouldComplete ? 1 : 0);
- // transition finished
- self._didFinishAll(shouldComplete, true, false);
- }
- // set the TRANSITION END event on one of the transition elements
- self._unrgTrns = this.plt.transitionEnd(self._transEl(), onTransitionEnd, false);
- // set a fallback timeout if the transition end event never fires, or is too slow
- // transition end fallback: (animation duration + XXms)
- self._tm = self.plt.timeout(onTransitionFallback, (dur + ANIMATION_TRANSITION_END_FALLBACK_PADDING_MS));
- };
- /**
- * @hidden
- * DOM WRITE
- * RECURSION
- */
- Animation.prototype._playEnd = function (stepValue) {
- var children = this._c;
- for (var i = 0; i < this._cL; i++) {
- // ******** DOM WRITE ****************
- children[i]._playEnd(stepValue);
- }
- if (this._hasDur) {
- if (isDefined(stepValue)) {
- // too late to have a smooth animation, just finish it
- // ******** DOM WRITE ****************
- this._setTrans(0, true);
- // ensure the ending progress step gets rendered
- // ******** DOM WRITE ****************
- this._progress(stepValue);
- }
- // set the after styles
- // ******** DOM WRITE ****************
- this._setAfterStyles();
- // remove the will-change properties
- // ******** DOM WRITE ****************
- this._willChg(false);
- }
- };
- /**
- * @hidden
- * NO DOM
- * RECURSION
- */
- Animation.prototype._hasDuration = function (opts) {
- if (this.getDuration(opts) > ANIMATION_DURATION_MIN) {
- return true;
- }
- var children = this._c;
- for (var i = 0; i < this._cL; i++) {
- if (children[i]._hasDuration(opts)) {
- return true;
- }
- }
- return false;
- };
- /**
- * @hidden
- * NO DOM
- * RECURSION
- */
- Animation.prototype._hasDomReads = function () {
- if (this._rdFn && this._rdFn.length) {
- return true;
- }
- var children = this._c;
- for (var i = 0; i < this._cL; i++) {
- if (children[i]._hasDomReads()) {
- return true;
- }
- }
- return false;
- };
- /**
- * Immediately stop at the end of the animation.
- */
- Animation.prototype.stop = function (stepValue) {
- if (stepValue === void 0) { stepValue = 1; }
- // ensure all past transition end events have been cleared
- this._clearAsync();
- this._hasDur = true;
- this._playEnd(stepValue);
- };
- /**
- * @hidden
- * NO DOM
- * NO RECURSION
- */
- Animation.prototype._clearAsync = function () {
- this._unrgTrns && this._unrgTrns();
- this._tm && clearTimeout(this._tm);
- this._tm = this._unrgTrns = undefined;
- };
- /**
- * @hidden
- * DOM WRITE
- * NO RECURSION
- */
- Animation.prototype._progress = function (stepValue) {
- // bread 'n butter
- var val;
- var effects = this._fx;
- var nuElements = this._eL;
- if (!effects || !nuElements) {
- return;
- }
- // flip the number if we're going in reverse
- if (this._rv) {
- stepValue = ((stepValue * -1) + 1);
- }
- var i, j;
- var finalTransform = '';
- var elements = this._e;
- for (i = 0; i < effects.length; i++) {
- var fx = effects[i];
- if (fx.from && fx.to) {
- var fromNum = fx.from.num;
- var toNum = fx.to.num;
- var tweenEffect = (fromNum !== toNum);
- (void 0) /* assert */;
- if (tweenEffect) {
- this._twn = true;
- }
- if (stepValue === 0) {
- // FROM
- val = fx.from.val;
- }
- else if (stepValue === 1) {
- // TO
- val = fx.to.val;
- }
- else if (tweenEffect) {
- // EVERYTHING IN BETWEEN
- var valNum = (((toNum - fromNum) * stepValue) + fromNum);
- var unit = fx.to.unit;
- if (unit === 'px') {
- valNum = Math.round(valNum);
- }
- val = valNum + unit;
- }
- if (val !== null) {
- var prop = fx.name;
- if (fx.trans) {
- finalTransform += prop + '(' + val + ') ';
- }
- else {
- for (j = 0; j < nuElements; j++) {
- // ******** DOM WRITE ****************
- elements[j].style[prop] = val;
- }
- }
- }
- }
- }
- // place all transforms on the same property
- if (finalTransform.length) {
- if (!this._rv && stepValue !== 1 || this._rv && stepValue !== 0) {
- finalTransform += 'translateZ(0px)';
- }
- var cssTransform = this.plt.Css.transform;
- for (i = 0; i < elements.length; i++) {
- // ******** DOM WRITE ****************
- elements[i].style[cssTransform] = finalTransform;
- }
- }
- };
- /**
- * @hidden
- * DOM WRITE
- * NO RECURSION
- */
- Animation.prototype._setTrans = function (dur, forcedLinearEasing) {
- // Transition is not enabled if there are not effects
- if (!this._fx) {
- return;
- }
- // set the TRANSITION properties inline on the element
- var elements = this._e;
- var easing = (forcedLinearEasing ? 'linear' : this.getEasing());
- var durString = dur + 'ms';
- var Css = this.plt.Css;
- var cssTransform = Css.transition;
- var cssTransitionDuration = Css.transitionDuration;
- var cssTransitionTimingFn = Css.transitionTimingFn;
- var eleStyle;
- for (var i = 0; i < this._eL; i++) {
- eleStyle = elements[i].style;
- if (dur > 0) {
- // ******** DOM WRITE ****************
- eleStyle[cssTransform] = '';
- eleStyle[cssTransitionDuration] = durString;
- // each animation can have a different easing
- if (easing) {
- // ******** DOM WRITE ****************
- eleStyle[cssTransitionTimingFn] = easing;
- }
- }
- else {
- eleStyle[cssTransform] = 'none';
- }
- }
- };
- /**
- * @hidden
- * DOM READ
- * DOM WRITE
- * RECURSION
- */
- Animation.prototype._beforeAnimation = function () {
- // fire off all the "before" function that have DOM READS in them
- // elements will be in the DOM, however visibily hidden
- // so we can read their dimensions if need be
- // ******** DOM READ ****************
- this._fireBeforeReadFunc();
- // ******** DOM READS ABOVE / DOM WRITES BELOW ****************
- // fire off all the "before" function that have DOM WRITES in them
- // ******** DOM WRITE ****************
- this._fireBeforeWriteFunc();
- // stage all of the before css classes and inline styles
- // ******** DOM WRITE ****************
- this._setBeforeStyles();
- };
- /**
- * @hidden
- * DOM WRITE
- * RECURSION
- */
- Animation.prototype._setBeforeStyles = function () {
- var i, j;
- var children = this._c;
- for (i = 0; i < this._cL; i++) {
- children[i]._setBeforeStyles();
- }
- // before the animations have started
- // only set before styles if animation is not reversed
- if (this._rv) {
- return;
- }
- var addClasses = this._bfAdd;
- var removeClasses = this._bfRm;
- var ele;
- var eleClassList;
- var prop;
- for (i = 0; i < this._eL; i++) {
- ele = this._e[i];
- eleClassList = ele.classList;
- // css classes to add before the animation
- if (addClasses) {
- for (j = 0; j < addClasses.length; j++) {
- // ******** DOM WRITE ****************
- eleClassList.add(addClasses[j]);
- }
- }
- // css classes to remove before the animation
- if (removeClasses) {
- for (j = 0; j < removeClasses.length; j++) {
- // ******** DOM WRITE ****************
- eleClassList.remove(removeClasses[j]);
- }
- }
- // inline styles to add before the animation
- if (this._bfSty) {
- for (prop in this._bfSty) {
- // ******** DOM WRITE ****************
- ele.style[prop] = this._bfSty[prop];
- }
- }
- }
- };
- /**
- * @hidden
- * DOM READ
- * RECURSION
- */
- Animation.prototype._fireBeforeReadFunc = function () {
- var children = this._c;
- for (var i = 0; i < this._cL; i++) {
- // ******** DOM READ ****************
- children[i]._fireBeforeReadFunc();
- }
- var readFunctions = this._rdFn;
- if (readFunctions) {
- for (var i = 0; i < readFunctions.length; i++) {
- // ******** DOM READ ****************
- readFunctions[i]();
- }
- }
- };
- /**
- * @hidden
- * DOM WRITE
- * RECURSION
- */
- Animation.prototype._fireBeforeWriteFunc = function () {
- var children = this._c;
- for (var i = 0; i < this._cL; i++) {
- // ******** DOM WRITE ****************
- children[i]._fireBeforeWriteFunc();
- }
- var writeFunctions = this._wrFn;
- if (this._wrFn) {
- for (var i = 0; i < writeFunctions.length; i++) {
- // ******** DOM WRITE ****************
- writeFunctions[i]();
- }
- }
- };
- /**
- * @hidden
- * DOM WRITE
- */
- Animation.prototype._setAfterStyles = function () {
- var i, j;
- var ele;
- var eleClassList;
- var elements = this._e;
- for (i = 0; i < this._eL; i++) {
- ele = elements[i];
- eleClassList = ele.classList;
- // remove the transition duration/easing
- // ******** DOM WRITE ****************
- ele.style[this.plt.Css.transitionDuration] = ele.style[this.plt.Css.transitionTimingFn] = '';
- if (this._rv) {
- // finished in reverse direction
- // css classes that were added before the animation should be removed
- if (this._bfAdd) {
- for (j = 0; j < this._bfAdd.length; j++) {
- // ******** DOM WRITE ****************
- eleClassList.remove(this._bfAdd[j]);
- }
- }
- // css classes that were removed before the animation should be added
- if (this._bfRm) {
- for (j = 0; j < this._bfRm.length; j++) {
- // ******** DOM WRITE ****************
- eleClassList.add(this._bfRm[j]);
- }
- }
- // inline styles that were added before the animation should be removed
- if (this._bfSty) {
- for (var prop in this._bfSty) {
- // ******** DOM WRITE ****************
- ele.style[prop] = '';
- }
- }
- }
- else {
- // finished in forward direction
- // css classes to add after the animation
- if (this._afAdd) {
- for (j = 0; j < this._afAdd.length; j++) {
- // ******** DOM WRITE ****************
- eleClassList.add(this._afAdd[j]);
- }
- }
- // css classes to remove after the animation
- if (this._afRm) {
- for (j = 0; j < this._afRm.length; j++) {
- // ******** DOM WRITE ****************
- eleClassList.remove(this._afRm[j]);
- }
- }
- // inline styles to add after the animation
- if (this._afSty) {
- for (var prop in this._afSty) {
- // ******** DOM WRITE ****************
- ele.style[prop] = this._afSty[prop];
- }
- }
- }
- }
- };
- /**
- * @hidden
- * DOM WRITE
- * NO RECURSION
- */
- Animation.prototype._willChg = function (addWillChange) {
- var wc;
- var effects = this._fx;
- var willChange;
- if (addWillChange && effects) {
- wc = [];
- for (var i = 0; i < effects.length; i++) {
- var propWC = effects[i].wc;
- if (propWC === 'webkitTransform') {
- wc.push('transform', '-webkit-transform');
- }
- else {
- wc.push(propWC);
- }
- }
- willChange = wc.join(',');
- }
- else {
- willChange = '';
- }
- for (var i = 0; i < this._eL; i++) {
- // ******** DOM WRITE ****************
- this._e[i].style.willChange = willChange;
- }
- };
- /**
- * Start the animation with a user controlled progress.
- */
- Animation.prototype.progressStart = function () {
- // ensure all past transition end events have been cleared
- this._clearAsync();
- // ******** DOM READ/WRITE ****************
- this._beforeAnimation();
- // ******** DOM WRITE ****************
- this._progressStart();
- };
- /**
- * @hidden
- * DOM WRITE
- * RECURSION
- */
- Animation.prototype._progressStart = function () {
- var children = this._c;
- for (var i = 0; i < this._cL; i++) {
- // ******** DOM WRITE ****************
- children[i]._progressStart();
- }
- // force no duration, linear easing
- // ******** DOM WRITE ****************
- this._setTrans(0, true);
- // ******** DOM WRITE ****************
- this._willChg(true);
- };
- /**
- * Set the progress step for this animation.
- * progressStep() is not debounced, so it should not be called faster than 60FPS.
- */
- Animation.prototype.progressStep = function (stepValue) {
- // only update if the last update was more than 16ms ago
- stepValue = Math.min(1, Math.max(0, stepValue));
- var children = this._c;
- for (var i = 0; i < this._cL; i++) {
- // ******** DOM WRITE ****************
- children[i].progressStep(stepValue);
- }
- if (this._rv) {
- // if the animation is going in reverse then
- // flip the step value: 0 becomes 1, 1 becomes 0
- stepValue = ((stepValue * -1) + 1);
- }
- // ******** DOM WRITE ****************
- this._progress(stepValue);
- };
- /**
- * End the progress animation.
- */
- Animation.prototype.progressEnd = function (shouldComplete, currentStepValue, dur) {
- if (dur === void 0) { dur = -1; }
- (void 0) /* console.debug */;
- if (this._rv) {
- // if the animation is going in reverse then
- // flip the step value: 0 becomes 1, 1 becomes 0
- currentStepValue = ((currentStepValue * -1) + 1);
- }
- var stepValue = shouldComplete ? 1 : 0;
- var diff = Math.abs(currentStepValue - stepValue);
- if (diff < 0.05) {
- dur = 0;
- }
- else if (dur < 0) {
- dur = this._dur;
- }
- this._isAsync = (dur > 30);
- this._progressEnd(shouldComplete, stepValue, dur, this._isAsync);
- if (this._isAsync) {
- // for the root animation only
- // set the async TRANSITION END event
- // and run onFinishes when the transition ends
- // ******** DOM WRITE ****************
- this._asyncEnd(dur, shouldComplete);
- // this animation has a duration so we need another RAF
- // for the CSS TRANSITION properties to kick in
- this.plt && this.plt.raf(this._playToStep.bind(this, stepValue));
- }
- };
- /**
- * @hidden
- * DOM WRITE
- * RECURSION
- */
- Animation.prototype._progressEnd = function (shouldComplete, stepValue, dur, isAsync) {
- var children = this._c;
- for (var i = 0; i < this._cL; i++) {
- // ******** DOM WRITE ****************
- children[i]._progressEnd(shouldComplete, stepValue, dur, isAsync);
- }
- if (!isAsync) {
- // stop immediately
- // set all the animations to their final position
- // ******** DOM WRITE ****************
- this._progress(stepValue);
- this._willChg(false);
- this._setAfterStyles();
- this._didFinish(shouldComplete);
- }
- else {
- // animate it back to it's ending position
- this.isPlaying = true;
- this.hasCompleted = false;
- this._hasDur = true;
- // ******** DOM WRITE ****************
- this._willChg(true);
- this._setTrans(dur, false);
- }
- };
- /**
- * Add a callback to fire when the animation has finished.
- */
- Animation.prototype.onFinish = function (callback, onceTimeCallback, clearOnFinishCallacks) {
- if (onceTimeCallback === void 0) { onceTimeCallback = false; }
- if (clearOnFinishCallacks === void 0) { clearOnFinishCallacks = false; }
- if (clearOnFinishCallacks) {
- this._fFn = this._fOneFn = undefined;
- }
- if (onceTimeCallback) {
- this._fOneFn = this._fOneFn || [];
- this._fOneFn.push(callback);
- }
- else {
- this._fFn = this._fFn || [];
- this._fFn.push(callback);
- }
- return this;
- };
- /**
- * @hidden
- * NO DOM
- * RECURSION
- */
- Animation.prototype._didFinishAll = function (hasCompleted, finishAsyncAnimations, finishNoDurationAnimations) {
- var children = this._c;
- for (var i = 0; i < this._cL; i++) {
- children[i]._didFinishAll(hasCompleted, finishAsyncAnimations, finishNoDurationAnimations);
- }
- if (finishAsyncAnimations && this._isAsync || finishNoDurationAnimations && !this._isAsync) {
- this._didFinish(hasCompleted);
- }
- };
- /**
- * @hidden
- * NO RECURSION
- */
- Animation.prototype._didFinish = function (hasCompleted) {
- this.isPlaying = false;
- this.hasCompleted = hasCompleted;
- if (this._fFn) {
- // run all finish callbacks
- for (var i = 0; i < this._fFn.length; i++) {
- this._fFn[i](this);
- }
- }
- if (this._fOneFn) {
- // run all "onetime" finish callbacks
- for (var i = 0; i < this._fOneFn.length; i++) {
- this._fOneFn[i](this);
- }
- this._fOneFn.length = 0;
- }
- };
- /**
- * Reverse the animation.
- */
- Animation.prototype.reverse = function (shouldReverse) {
- if (shouldReverse === void 0) { shouldReverse = true; }
- var children = this._c;
- for (var i = 0; i < this._cL; i++) {
- children[i].reverse(shouldReverse);
- }
- this._rv = shouldReverse;
- return this;
- };
- /**
- * Recursively destroy this animation and all child animations.
- */
- Animation.prototype.destroy = function () {
- var children = this._c;
- for (var i = 0; i < this._cL; i++) {
- children[i].destroy();
- }
- this._clearAsync();
- this.parent = this.plt = this._e = this._rdFn = this._wrFn = null;
- if (this._c) {
- this._c.length = this._cL = 0;
- }
- if (this._fFn) {
- this._fFn.length = 0;
- }
- if (this._fOneFn) {
- this._fOneFn.length = 0;
- }
- };
- /**
- * @hidden
- * NO DOM
- */
- Animation.prototype._transEl = function () {
- // get the lowest level element that has an Animation
- var targetEl;
- for (var i = 0; i < this._cL; i++) {
- targetEl = this._c[i]._transEl();
- if (targetEl) {
- return targetEl;
- }
- }
- return (this._twn && this._hasDur && this._eL ? this._e[0] : null);
- };
- return Animation;
- }());
- var ANIMATION_TRANSFORMS = {
- 'translateX': 1,
- 'translateY': 1,
- 'translateZ': 1,
- 'scale': 1,
- 'scaleX': 1,
- 'scaleY': 1,
- 'scaleZ': 1,
- 'rotate': 1,
- 'rotateX': 1,
- 'rotateY': 1,
- 'rotateZ': 1,
- 'skewX': 1,
- 'skewY': 1,
- 'perspective': 1
- };
- var ANIMATION_CSS_VALUE_REGEX = /(^-?\d*\.?\d*)(.*)/;
- var ANIMATION_DURATION_MIN = 32;
- var ANIMATION_TRANSITION_END_FALLBACK_PADDING_MS = 400;
-
- var __extends$16 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @hidden
- *
- * - play
- * - Add before classes - DOM WRITE
- * - Remove before classes - DOM WRITE
- * - Add before inline styles - DOM WRITE
- * - set inline FROM styles - DOM WRITE
- * - RAF
- * - read toolbar dimensions - DOM READ
- * - write content top/bottom padding - DOM WRITE
- * - set css transition duration/easing - DOM WRITE
- * - RAF
- * - set inline TO styles - DOM WRITE
- */
- var Transition = (function (_super) {
- __extends$16(Transition, _super);
- function Transition(plt, enteringView, leavingView, opts) {
- var _this = _super.call(this, plt, null, opts) || this;
- _this.enteringView = enteringView;
- _this.leavingView = leavingView;
- return _this;
- }
- Transition.prototype.init = function () { };
- Transition.prototype.registerStart = function (trnsStart) {
- this._trnsStart = trnsStart;
- };
- Transition.prototype.start = function () {
- this._trnsStart && this._trnsStart();
- this._trnsStart = null;
- // bubble up start
- this.parent && this.parent.start();
- };
- Transition.prototype.destroy = function () {
- _super.prototype.destroy.call(this);
- this.parent = this.enteringView = this.leavingView = this._trnsStart = null;
- };
- return Transition;
- }(Animation));
-
- var __extends$15 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @hidden
- */
- var PageTransition = (function (_super) {
- __extends$15(PageTransition, _super);
- function PageTransition() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- PageTransition.prototype.init = function () {
- var _this = this;
- if (this.enteringView) {
- this.enteringPage = new Animation(this.plt, this.enteringView.pageRef());
- this.add(this.enteringPage.beforeAddClass('show-page'));
- // Resize content before transition starts
- this.beforeAddRead(function () {
- _this.enteringView.readReady.emit();
- });
- this.beforeAddWrite(function () {
- _this.enteringView.writeReady.emit();
- });
- }
- };
- PageTransition.prototype.destroy = function () {
- _super.prototype.destroy.call(this);
- this.enteringPage && this.enteringPage.destroy();
- this.enteringPage = null;
- };
- return PageTransition;
- }(Transition));
-
- var __extends$14 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- var DURATION = 500;
- var EASING = 'cubic-bezier(0.36,0.66,0.04,1)';
- var OPACITY = 'opacity';
- var TRANSFORM = 'transform';
- var TRANSLATEX = 'translateX';
- var CENTER = '0%';
- var OFF_OPACITY = 0.8;
- var SHOW_BACK_BTN_CSS = 'show-back-button';
- var IOSTransition = (function (_super) {
- __extends$14(IOSTransition, _super);
- function IOSTransition() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- IOSTransition.prototype.init = function () {
- _super.prototype.init.call(this);
- var plt = this.plt;
- var OFF_RIGHT = plt.isRTL ? '-99.5%' : '99.5%';
- var OFF_LEFT = plt.isRTL ? '33%' : '-33%';
- var enteringView = this.enteringView;
- var leavingView = this.leavingView;
- var opts = this.opts;
- this.duration(isPresent(opts.duration) ? opts.duration : DURATION);
- this.easing(isPresent(opts.easing) ? opts.easing : EASING);
- var backDirection = (opts.direction === 'back');
- var enteringHasNavbar = (enteringView && enteringView.hasNavbar());
- var leavingHasNavbar = (leavingView && leavingView.hasNavbar());
- if (enteringView) {
- // get the native element for the entering page
- var enteringPageEle = enteringView.pageRef().nativeElement;
- // entering content
- var enteringContent = new Animation(plt, enteringView.contentRef());
- enteringContent.element(enteringPageEle.querySelectorAll('ion-header > *:not(ion-navbar),ion-footer > *'));
- this.add(enteringContent);
- if (backDirection) {
- // entering content, back direction
- enteringContent
- .fromTo(TRANSLATEX, OFF_LEFT, CENTER, true)
- .fromTo(OPACITY, OFF_OPACITY, 1, true);
- }
- else {
- // entering content, forward direction
- enteringContent
- .beforeClearStyles([OPACITY])
- .fromTo(TRANSLATEX, OFF_RIGHT, CENTER, true);
- }
- if (enteringHasNavbar) {
- // entering page has a navbar
- var enteringNavbarEle = enteringPageEle.querySelector('ion-navbar');
- var enteringNavBar = new Animation(plt, enteringNavbarEle);
- this.add(enteringNavBar);
- var enteringTitle = new Animation(plt, enteringNavbarEle.querySelector('ion-title'));
- var enteringNavbarItems = new Animation(plt, enteringNavbarEle.querySelectorAll('ion-buttons,[menuToggle]'));
- var enteringNavbarBg = new Animation(plt, enteringNavbarEle.querySelector('.toolbar-background'));
- var enteringBackButton = new Animation(plt, enteringNavbarEle.querySelector('.back-button'));
- enteringNavBar
- .add(enteringTitle)
- .add(enteringNavbarItems)
- .add(enteringNavbarBg)
- .add(enteringBackButton);
- enteringTitle.fromTo(OPACITY, 0.01, 1, true);
- enteringNavbarItems.fromTo(OPACITY, 0.01, 1, true);
- // set properties depending on direction
- if (backDirection) {
- // entering navbar, back direction
- enteringTitle.fromTo(TRANSLATEX, OFF_LEFT, CENTER, true);
- if (enteringView.enableBack()) {
- // back direction, entering page has a back button
- enteringBackButton
- .beforeAddClass(SHOW_BACK_BTN_CSS)
- .fromTo(OPACITY, 0.01, 1, true);
- }
- }
- else {
- // entering navbar, forward direction
- enteringTitle.fromTo(TRANSLATEX, OFF_RIGHT, CENTER, true);
- enteringNavbarBg
- .beforeClearStyles([OPACITY])
- .fromTo(TRANSLATEX, OFF_RIGHT, CENTER, true);
- if (enteringView.enableBack()) {
- // forward direction, entering page has a back button
- enteringBackButton
- .beforeAddClass(SHOW_BACK_BTN_CSS)
- .fromTo(OPACITY, 0.01, 1, true);
- var enteringBackBtnText = new Animation(plt, enteringNavbarEle.querySelector('.back-button-text'));
- enteringBackBtnText.fromTo(TRANSLATEX, (plt.isRTL ? '-100px' : '100px'), '0px');
- enteringNavBar.add(enteringBackBtnText);
- }
- else {
- enteringBackButton.beforeRemoveClass(SHOW_BACK_BTN_CSS);
- }
- }
- }
- }
- // setup leaving view
- if (leavingView && leavingView.pageRef()) {
- // leaving content
- var leavingPageEle = leavingView.pageRef().nativeElement;
- var leavingContent = new Animation(plt, leavingView.contentRef());
- leavingContent.element(leavingPageEle.querySelectorAll('ion-header > *:not(ion-navbar),ion-footer > *'));
- this.add(leavingContent);
- if (backDirection) {
- // leaving content, back direction
- leavingContent
- .beforeClearStyles([OPACITY])
- .fromTo(TRANSLATEX, CENTER, (plt.isRTL ? '-100%' : '100%'));
- }
- else {
- // leaving content, forward direction
- leavingContent
- .fromTo(TRANSLATEX, CENTER, OFF_LEFT)
- .fromTo(OPACITY, 1, OFF_OPACITY)
- .afterClearStyles([TRANSFORM, OPACITY]);
- }
- if (leavingHasNavbar) {
- // leaving page has a navbar
- var leavingNavbarEle = leavingPageEle.querySelector('ion-navbar');
- var leavingNavBar = new Animation(plt, leavingNavbarEle);
- var leavingTitle = new Animation(plt, leavingNavbarEle.querySelector('ion-title'));
- var leavingNavbarItems = new Animation(plt, leavingNavbarEle.querySelectorAll('ion-buttons,[menuToggle]'));
- var leavingNavbarBg = new Animation(plt, leavingNavbarEle.querySelector('.toolbar-background'));
- var leavingBackButton = new Animation(plt, leavingNavbarEle.querySelector('.back-button'));
- leavingNavBar
- .add(leavingTitle)
- .add(leavingNavbarItems)
- .add(leavingBackButton)
- .add(leavingNavbarBg);
- this.add(leavingNavBar);
- // fade out leaving navbar items
- leavingBackButton.fromTo(OPACITY, 0.99, 0);
- leavingTitle.fromTo(OPACITY, 0.99, 0);
- leavingNavbarItems.fromTo(OPACITY, 0.99, 0);
- if (backDirection) {
- // leaving navbar, back direction
- leavingTitle.fromTo(TRANSLATEX, CENTER, (plt.isRTL ? '-100%' : '100%'));
- // leaving navbar, back direction, and there's no entering navbar
- // should just slide out, no fading out
- leavingNavbarBg
- .beforeClearStyles([OPACITY])
- .fromTo(TRANSLATEX, CENTER, (plt.isRTL ? '-100%' : '100%'));
- var leavingBackBtnText = new Animation(plt, leavingNavbarEle.querySelector('.back-button-text'));
- leavingBackBtnText.fromTo(TRANSLATEX, CENTER, (plt.isRTL ? -300 : 300) + 'px');
- leavingNavBar.add(leavingBackBtnText);
- }
- else {
- // leaving navbar, forward direction
- leavingTitle
- .fromTo(TRANSLATEX, CENTER, OFF_LEFT)
- .afterClearStyles([TRANSFORM]);
- leavingBackButton.afterClearStyles([OPACITY]);
- leavingTitle.afterClearStyles([OPACITY]);
- leavingNavbarItems.afterClearStyles([OPACITY]);
- }
- }
- }
- };
- return IOSTransition;
- }(PageTransition));
-
- var __extends$17 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- var TRANSLATEY = 'translateY';
- var OFF_BOTTOM = '40px';
- var CENTER$1 = '0px';
- var SHOW_BACK_BTN_CSS$1 = 'show-back-button';
- var MDTransition = (function (_super) {
- __extends$17(MDTransition, _super);
- function MDTransition() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- MDTransition.prototype.init = function () {
- _super.prototype.init.call(this);
- var plt = this.plt;
- var enteringView = this.enteringView;
- var leavingView = this.leavingView;
- var opts = this.opts;
- // what direction is the transition going
- var backDirection = (opts.direction === 'back');
- if (enteringView) {
- if (backDirection) {
- this.duration(isPresent(opts.duration) ? opts.duration : 200).easing('cubic-bezier(0.47,0,0.745,0.715)');
- }
- else {
- this.duration(isPresent(opts.duration) ? opts.duration : 280).easing('cubic-bezier(0.36,0.66,0.04,1)');
- this.enteringPage
- .fromTo(TRANSLATEY, OFF_BOTTOM, CENTER$1, true)
- .fromTo('opacity', 0.01, 1, true);
- }
- if (enteringView.hasNavbar()) {
- var enteringPageEle = enteringView.pageRef().nativeElement;
- var enteringNavbarEle = enteringPageEle.querySelector('ion-navbar');
- var enteringNavBar = new Animation(plt, enteringNavbarEle);
- this.add(enteringNavBar);
- var enteringBackButton = new Animation(plt, enteringNavbarEle.querySelector('.back-button'));
- this.add(enteringBackButton);
- if (enteringView.enableBack()) {
- enteringBackButton.beforeAddClass(SHOW_BACK_BTN_CSS$1);
- }
- else {
- enteringBackButton.beforeRemoveClass(SHOW_BACK_BTN_CSS$1);
- }
- }
- }
- // setup leaving view
- if (leavingView && backDirection) {
- // leaving content
- this.duration(opts.duration || 200).easing('cubic-bezier(0.47,0,0.745,0.715)');
- var leavingPage = new Animation(plt, leavingView.pageRef());
- this.add(leavingPage.fromTo(TRANSLATEY, CENTER$1, OFF_BOTTOM).fromTo('opacity', 1, 0));
- }
- };
- return MDTransition;
- }(PageTransition));
-
- var __extends$18 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- var SHOW_BACK_BTN_CSS$2 = 'show-back-button';
- var SCALE_SMALL = .95;
- var WPTransition = (function (_super) {
- __extends$18(WPTransition, _super);
- function WPTransition() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- WPTransition.prototype.init = function () {
- _super.prototype.init.call(this);
- var plt = this.plt;
- var enteringView = this.enteringView;
- var leavingView = this.leavingView;
- var opts = this.opts;
- // what direction is the transition going
- var backDirection = (opts.direction === 'back');
- if (enteringView) {
- if (backDirection) {
- this.duration(isPresent(opts.duration) ? opts.duration : 120).easing('cubic-bezier(0.47,0,0.745,0.715)');
- this.enteringPage.beforeClearStyles(['scale']);
- }
- else {
- this.duration(isPresent(opts.duration) ? opts.duration : 280).easing('cubic-bezier(0,0,0.05,1)');
- this.enteringPage
- .fromTo('scale', SCALE_SMALL, 1, true)
- .fromTo('opacity', 0.01, 1, true);
- }
- if (enteringView.hasNavbar()) {
- var enteringPageEle = enteringView.pageRef().nativeElement;
- var enteringNavbarEle = enteringPageEle.querySelector('ion-navbar');
- var enteringNavBar = new Animation(plt, enteringNavbarEle);
- this.add(enteringNavBar);
- var enteringBackButton = new Animation(plt, enteringNavbarEle.querySelector('.back-button'));
- this.add(enteringBackButton);
- if (enteringView.enableBack()) {
- enteringBackButton.beforeAddClass(SHOW_BACK_BTN_CSS$2);
- }
- else {
- enteringBackButton.beforeRemoveClass(SHOW_BACK_BTN_CSS$2);
- }
- }
- }
- // setup leaving view
- if (leavingView && backDirection) {
- // leaving content
- this.duration(opts.duration || 200).easing('cubic-bezier(0.47,0,0.745,0.715)');
- var leavingPage = new Animation(plt, leavingView.pageRef());
- this.add(leavingPage.fromTo('scale', 1, SCALE_SMALL).fromTo('opacity', 0.99, 0));
- }
- };
- return WPTransition;
- }(PageTransition));
-
- /**
- * @name App
- * @description
- * App is a utility class used in Ionic to get information about various aspects of an app
- */
- var App = (function () {
- function App(_config, _plt, _menuCtrl) {
- this._config = _config;
- this._plt = _plt;
- this._menuCtrl = _menuCtrl;
- this._disTime = 0;
- this._scrollTime = 0;
- this._title = '';
- this._titleSrv = new Title(DOCUMENT$1);
- this._rootNavs = new Map();
- this._didScroll = false;
- /**
- * Observable that emits whenever a view loads in the app.
- * @returns {Observable} Returns an observable
- */
- this.viewDidLoad = new EventEmitter();
- /**
- * Observable that emits before any view is entered in the app.
- * @returns {Observable} Returns an observable
- */
- this.viewWillEnter = new EventEmitter();
- /**
- * Observable that emits after any view is entered in the app.
- * @returns {Observable} Returns an observable
- */
- this.viewDidEnter = new EventEmitter();
- /**
- * Observable that emits before any view is exited in the app.
- * @returns {Observable} Returns an observable
- */
- this.viewWillLeave = new EventEmitter();
- /**
- * Observable that emits after any view is exited in the app.
- * @returns {Observable} Returns an observable
- */
- this.viewDidLeave = new EventEmitter();
- /**
- * Observable that emits before any view unloads in the app.
- * @returns {Observable} Returns an observable
- */
- this.viewWillUnload = new EventEmitter();
- // listen for hardware back button events
- // register this back button action with a default priority
- _plt.registerBackButtonAction(this.goBack.bind(this));
- this._disableScrollAssist = _config.getBoolean('disableScrollAssist', false);
- var blurring = _config.getBoolean('inputBlurring', false);
- if (blurring) {
- this._enableInputBlurring();
- }
- (void 0) /* runInDev */;
- _config.setTransition('ios-transition', IOSTransition);
- _config.setTransition('md-transition', MDTransition);
- _config.setTransition('wp-transition', WPTransition);
- }
- /**
- * Sets the document title.
- * @param {string} val Value to set the document title to.
- */
- App.prototype.setTitle = function (val) {
- if (val !== this._title) {
- this._title = val;
- this._titleSrv.setTitle(val);
- }
- };
- /**
- * @hidden
- */
- App.prototype.setElementClass = function (className, isAdd) {
- this._appRoot.setElementClass(className, isAdd);
- };
- /**
- * @hidden
- * Sets if the app is currently enabled or not, meaning if it's
- * available to accept new user commands. For example, this is set to `false`
- * while views transition, a modal slides up, an action-sheet
- * slides up, etc. After the transition completes it is set back to `true`.
- * @param {boolean} isEnabled `true` for enabled, `false` for disabled
- * @param {number} duration When `isEnabled` is set to `false`, this argument
- * is used to set the maximum number of milliseconds that app will wait until
- * it will automatically enable the app again. It's basically a fallback incase
- * something goes wrong during a transition and the app wasn't re-enabled correctly.
- */
- App.prototype.setEnabled = function (isEnabled, duration, minDuration) {
- if (duration === void 0) { duration = 700; }
- if (minDuration === void 0) { minDuration = 0; }
- this._disTime = (isEnabled ? 0 : Date.now() + duration);
- if (this._clickBlock) {
- if (isEnabled) {
- // disable the click block if it's enabled, or the duration is tiny
- this._clickBlock.activate(false, CLICK_BLOCK_BUFFER_IN_MILLIS, minDuration);
- }
- else {
- // show the click block for duration + some number
- this._clickBlock.activate(true, duration + CLICK_BLOCK_BUFFER_IN_MILLIS, minDuration);
- }
- }
- };
- /**
- * @hidden
- * Toggles whether an application can be scrolled
- * @param {boolean} disableScroll when set to `false`, the application's
- * scrolling is enabled. When set to `true`, scrolling is disabled.
- */
- App.prototype._setDisableScroll = function (disableScroll) {
- if (this._disableScrollAssist) {
- this._appRoot._disableScroll(disableScroll);
- }
- };
- /**
- * @hidden
- * Boolean if the app is actively enabled or not.
- * @return {boolean}
- */
- App.prototype.isEnabled = function () {
- var disTime = this._disTime;
- if (disTime === 0) {
- return true;
- }
- return (disTime < Date.now());
- };
- /**
- * @hidden
- */
- App.prototype.setScrolling = function () {
- this._scrollTime = Date.now() + ACTIVE_SCROLLING_TIME;
- this._didScroll = true;
- };
- /**
- * Boolean if the app is actively scrolling or not.
- * @return {boolean} returns true or false
- */
- App.prototype.isScrolling = function () {
- var scrollTime = this._scrollTime;
- if (scrollTime === 0) {
- return false;
- }
- if (scrollTime < Date.now()) {
- this._scrollTime = 0;
- return false;
- }
- return true;
- };
- /**
- * @return {NavController} Returns the first Active Nav Controller from the list. This method is deprecated
- */
- App.prototype.getActiveNav = function () {
- console.warn('(getActiveNav) is deprecated and will be removed in the next major release. Use getActiveNavs instead.');
- var navs = this.getActiveNavs();
- if (navs && navs.length) {
- return navs[0];
- }
- return null;
- };
- /**
- * @return {NavController[]} Returns the active NavControllers. Using this method is preferred when we need access to the top-level navigation controller while on the outside views and handlers like `registerBackButtonAction()`
- */
- App.prototype.getActiveNavs = function (rootNavId) {
- var portal = this._appRoot._getPortal(PORTAL_MODAL);
- if (portal.length() > 0) {
- return findTopNavs(portal);
- }
- if (!this._rootNavs || !this._rootNavs.size) {
- return [];
- }
- if (this._rootNavs.size === 1) {
- return findTopNavs(this._rootNavs.values().next().value);
- }
- if (rootNavId) {
- return findTopNavs(this._rootNavs.get(rootNavId));
- }
- // fallback to just using all root names
- var activeNavs = [];
- this._rootNavs.forEach(function (nav) {
- var topNavs = findTopNavs(nav);
- activeNavs = activeNavs.concat(topNavs);
- });
- return activeNavs;
- };
- App.prototype.getRootNav = function () {
- console.warn('(getRootNav) is deprecated and will be removed in the next major release. Use getRootNavById instead.');
- var rootNavs = this.getRootNavs();
- if (rootNavs.length === 0) {
- return null;
- }
- else if (rootNavs.length > 1) {
- console.warn('(getRootNav) there are multiple root navs, use getRootNavs instead');
- }
- return rootNavs[0];
- };
- App.prototype.getRootNavs = function () {
- var navs = [];
- this._rootNavs.forEach(function (nav) { return navs.push(nav); });
- return navs;
- };
- /**
- * @return {NavController} Returns the root NavController
- */
- App.prototype.getRootNavById = function (navId) {
- return this._rootNavs.get(navId);
- };
- /**
- * @hidden
- */
- App.prototype.registerRootNav = function (nav) {
- this._rootNavs.set(nav.id, nav);
- };
- /**
- * @hidden
- */
- App.prototype.unregisterRootNav = function (nav) {
- this._rootNavs.delete(nav.id);
- };
- App.prototype.getActiveNavContainers = function () {
- // for each root nav container, get it's active nav
- var list = [];
- this._rootNavs.forEach(function (container) {
- list = list.concat(findTopNavs(container));
- });
- return list;
- };
- /**
- * @hidden
- */
- App.prototype.present = function (enteringView, opts, appPortal) {
- (void 0) /* assert */;
- var portal = this._appRoot._getPortal(appPortal);
- // Set Nav must be set here in order to dimiss() work synchnously.
- // TODO: move _setNav() to the earlier stages of NavController. _queueTrns()
- enteringView._setNav(portal);
- opts.direction = DIRECTION_FORWARD;
- if (!opts.animation) {
- opts.animation = enteringView.getTransitionName(DIRECTION_FORWARD);
- }
- enteringView.setLeavingOpts({
- keyboardClose: opts.keyboardClose,
- direction: DIRECTION_BACK,
- animation: enteringView.getTransitionName(DIRECTION_BACK),
- ev: opts.ev
- });
- return portal.insertPages(-1, [enteringView], opts);
- };
- /**
- * @hidden
- */
- App.prototype.goBack = function () {
- if (this._menuCtrl && this._menuCtrl.isOpen()) {
- return this._menuCtrl.close();
- }
- var navPromise = this.navPop();
- if (!navPromise) {
- // no views to go back to
- // let's exit the app
- if (this._config.getBoolean('navExitApp', true)) {
- (void 0) /* console.debug */;
- this._plt.exitApp();
- }
- }
- return navPromise;
- };
- /**
- * @hidden
- */
- App.prototype.navPop = function () {
- var _this = this;
- if (!this._rootNavs || this._rootNavs.size === 0 || !this.isEnabled()) {
- return Promise.resolve();
- }
- // If there are any alert/actionsheet open, let's do nothing
- var portal = this._appRoot._getPortal(PORTAL_DEFAULT);
- if (portal.length() > 0) {
- return Promise.resolve();
- }
- var navToPop = null;
- var mostRecentVC = null;
- this._rootNavs.forEach(function (navContainer) {
- var activeNavs = _this.getActiveNavs(navContainer.id);
- var poppableNavs = activeNavs.map(function (activeNav) { return getPoppableNav(activeNav); }).filter(function (nav) { return !!nav; });
- poppableNavs.forEach(function (poppable) {
- var topViewController = poppable.last();
- if (poppable._isPortal || (topViewController && poppable.length() > 1 && (!mostRecentVC || topViewController._ts >= mostRecentVC._ts))) {
- mostRecentVC = topViewController;
- navToPop = poppable;
- }
- });
- });
- if (navToPop) {
- return navToPop.pop();
- }
- };
- /**
- * @hidden
- */
- App.prototype._enableInputBlurring = function () {
- (void 0) /* console.debug */;
- var focused = true;
- var self = this;
- var platform = this._plt;
- platform.registerListener(platform.doc(), 'focusin', onFocusin, { capture: true, zone: false, passive: true });
- platform.registerListener(platform.doc(), 'touchend', onTouchend, { capture: false, zone: false, passive: true });
- function onFocusin() {
- focused = true;
- }
- function onTouchend(ev) {
- // if app did scroll return early
- if (self._didScroll) {
- self._didScroll = false;
- return;
- }
- var active = self._plt.getActiveElement();
- if (!active) {
- return;
- }
- // only blur if the active element is a text-input or a textarea
- if (SKIP_BLURRING.indexOf(active.tagName) === -1) {
- return;
- }
- // if the selected target is the active element, do not blur
- var tapped = ev.target;
- if (tapped === active) {
- return;
- }
- if (SKIP_BLURRING.indexOf(tapped.tagName) >= 0) {
- return;
- }
- // skip if div is a cover
- if (tapped.classList.contains('input-cover')) {
- return;
- }
- focused = false;
- // TODO: find a better way, why 50ms?
- platform.timeout(function () {
- if (!focused) {
- active.blur();
- }
- }, 50);
- }
- };
- App.prototype.getNavByIdOrName = function (id) {
- var navs = Array.from(this._rootNavs.values());
- for (var _i = 0, navs_1 = navs; _i < navs_1.length; _i++) {
- var navContainer = navs_1[_i];
- var match = getNavByIdOrName(navContainer, id);
- if (match) {
- return match;
- }
- }
- return null;
- };
- App.decorators = [
- { type: Injectable },
- ];
- /** @nocollapse */
- App.ctorParameters = function () { return [
- { type: Config, },
- { type: Platform, },
- { type: MenuController, decorators: [{ type: Optional },] },
- ]; };
- return App;
- }());
- function getNavByIdOrName(nav, id) {
- if (nav.id === id || nav.name === id) {
- return nav;
- }
- for (var _i = 0, _a = nav.getAllChildNavs(); _i < _a.length; _i++) {
- var child = _a[_i];
- var tmp = getNavByIdOrName(child, id);
- if (tmp) {
- return tmp;
- }
- }
- return null;
- }
- function getPoppableNav(nav) {
- if (!nav) {
- return null;
- }
- if (isTabs(nav)) {
- // tabs aren't a nav, so just call this function again immediately on the parent on tabs
- return getPoppableNav(nav.parent);
- }
- var len = nav.length();
- if (len > 1 || (nav._isPortal && len > 0)) {
- // this nav controller has more than one view
- // use this nav!
- return nav;
- }
- // try again using the parent nav (if there is one)
- return getPoppableNav(nav.parent);
- }
- function findTopNavs(nav) {
- var containers = [];
- var childNavs = nav.getActiveChildNavs();
- if (!childNavs || !childNavs.length) {
- containers.push(nav);
- }
- else {
- childNavs.forEach(function (childNav) {
- var topNavs = findTopNavs(childNav);
- containers = containers.concat(topNavs);
- });
- }
- return containers;
- }
- var SKIP_BLURRING = ['INPUT', 'TEXTAREA', 'ION-INPUT', 'ION-TEXTAREA'];
- var ACTIVE_SCROLLING_TIME = 100;
- var CLICK_BLOCK_BUFFER_IN_MILLIS = 64;
-
- /**
- * Base class for all Ionic components. Exposes some common functionality
- * that all Ionic components need, such as accessing underlying native elements and
- * sending/receiving app-level events.
- */
- /** @hidden */
- var Ion = (function () {
- function Ion(config, elementRef, renderer, componentName) {
- this._config = config;
- this._elementRef = elementRef;
- this._renderer = renderer;
- this._componentName = componentName;
- if (componentName) {
- this._setComponentName();
- this._setMode(config.get('mode'));
- }
- }
- Object.defineProperty(Ion.prototype, "color", {
- get: function () {
- return this._color;
- },
- /**
- * @input {string} The color to use from your Sass `$colors` map.
- * Default options are: `"primary"`, `"secondary"`, `"danger"`, `"light"`, and `"dark"`.
- * For more information, see [Theming your App](/docs/theming/theming-your-app).
- */
- set: function (val) {
- this._setColor(val);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Ion.prototype, "mode", {
- get: function () {
- return this._mode;
- },
- /**
- * @input {string} The mode determines which platform styles to use.
- * Possible values are: `"ios"`, `"md"`, or `"wp"`.
- * For more information, see [Platform Styles](/docs/theming/platform-specific-styles).
- */
- set: function (val) {
- this._setMode(val);
- },
- enumerable: true,
- configurable: true
- });
- /** @hidden */
- Ion.prototype.setElementClass = function (className, isAdd) {
- this._renderer.setElementClass(this._elementRef.nativeElement, className, isAdd);
- };
- /** @hidden */
- Ion.prototype.setElementAttribute = function (attributeName, attributeValue) {
- this._renderer.setElementAttribute(this._elementRef.nativeElement, attributeName, attributeValue);
- };
- /** @hidden */
- Ion.prototype.setElementStyle = function (property, value) {
- this._renderer.setElementStyle(this._elementRef.nativeElement, property, value);
- };
- /** @hidden */
- Ion.prototype._setColor = function (newColor, componentName) {
- if (componentName) {
- // This is needed for the item-radio
- this._componentName = componentName;
- }
- if (this._color) {
- this.setElementClass(this._componentName + "-" + this._mode + "-" + this._color, false);
- }
- if (newColor) {
- this.setElementClass(this._componentName + "-" + this._mode + "-" + newColor, true);
- this._color = newColor;
- }
- };
- /** @hidden */
- Ion.prototype._setMode = function (newMode) {
- if (this._mode) {
- this.setElementClass(this._componentName + "-" + this._mode, false);
- }
- if (newMode) {
- this.setElementClass(this._componentName + "-" + newMode, true);
- // Remove the color class associated with the previous mode,
- // change the mode, then add the new color class
- this._setColor(null);
- this._mode = newMode;
- this._setColor(this._color);
- }
- };
- /** @hidden */
- Ion.prototype._setComponentName = function () {
- this.setElementClass(this._componentName, true);
- };
- /** @hidden */
- Ion.prototype.getElementRef = function () {
- return this._elementRef;
- };
- /** @hidden */
- Ion.prototype.getNativeElement = function () {
- return this._elementRef.nativeElement;
- };
- Ion.propDecorators = {
- 'color': [{ type: Input },],
- 'mode': [{ type: Input },],
- };
- return Ion;
- }());
-
- /**
- * @hidden
- */
- var UrlSerializer = (function () {
- function UrlSerializer(_app, config) {
- this._app = _app;
- if (config && isArray$2(config.links)) {
- this.links = normalizeLinks(config.links);
- }
- else {
- this.links = [];
- }
- }
- /**
- * Parse the URL into a Path, which is made up of multiple NavSegments.
- * Match which components belong to each segment.
- */
- UrlSerializer.prototype.parse = function (browserUrl) {
- if (browserUrl.charAt(0) === '/') {
- browserUrl = browserUrl.substr(1);
- }
- // trim off data after ? and #
- browserUrl = browserUrl.split('?')[0].split('#')[0];
- return convertUrlToSegments(this._app, browserUrl, this.links);
- };
- UrlSerializer.prototype.createSegmentFromName = function (navContainer, nameOrComponent) {
- var configLink = this.getLinkFromName(nameOrComponent);
- if (configLink) {
- return this._createSegment(this._app, navContainer, configLink, null);
- }
- return null;
- };
- UrlSerializer.prototype.getLinkFromName = function (nameOrComponent) {
- return this.links.find(function (link) {
- return (link.component === nameOrComponent) ||
- (link.name === nameOrComponent);
- });
- };
- /**
- * Serialize a path, which is made up of multiple NavSegments,
- * into a URL string. Turn each segment into a string and concat them to a URL.
- */
- UrlSerializer.prototype.serialize = function (segments) {
- if (!segments || !segments.length) {
- return '/';
- }
- var sections = segments.map(function (segment) {
- if (segment.type === 'tabs') {
- if (segment.requiresExplicitNavPrefix) {
- return "/" + segment.type + "/" + segment.navId + "/" + segment.secondaryId + "/" + segment.id;
- }
- return "/" + segment.secondaryId + "/" + segment.id;
- }
- // it's a nav
- if (segment.requiresExplicitNavPrefix) {
- return "/" + segment.type + "/" + segment.navId + "/" + segment.id;
- }
- return "/" + segment.id;
- });
- return sections.join('');
- };
- /**
- * Serializes a component and its data into a NavSegment.
- */
- UrlSerializer.prototype.serializeComponent = function (navContainer, component, data) {
- if (component) {
- var link = findLinkByComponentData(this.links, component, data);
- if (link) {
- return this._createSegment(this._app, navContainer, link, data);
- }
- }
- return null;
- };
- /**
- * @internal
- */
- UrlSerializer.prototype._createSegment = function (app, navContainer, configLink, data) {
- var urlParts = configLink.segmentParts;
- if (isPresent(data)) {
- // create a copy of the original parts in the link config
- urlParts = urlParts.slice();
- // loop through all the data and convert it to a string
- var keys = Object.keys(data);
- var keysLength = keys.length;
- if (keysLength) {
- for (var i = 0; i < urlParts.length; i++) {
- if (urlParts[i].charAt(0) === ':') {
- for (var j = 0; j < keysLength; j++) {
- if (urlParts[i] === ":" + keys[j]) {
- // this data goes into the URL part (between slashes)
- urlParts[i] = encodeURIComponent(data[keys[j]]);
- break;
- }
- }
- }
- }
- }
- }
- var requiresExplicitPrefix = true;
- if (navContainer.parent) {
- requiresExplicitPrefix = navContainer.parent && navContainer.parent.getAllChildNavs().length > 1;
- }
- else {
- // if it's a root nav, and there are multiple root navs, we need an explicit prefix
- requiresExplicitPrefix = app.getRootNavById(navContainer.id) && app.getRootNavs().length > 1;
- }
- return {
- id: urlParts.join('/'),
- name: configLink.name,
- component: configLink.component,
- loadChildren: configLink.loadChildren,
- data: data,
- defaultHistory: configLink.defaultHistory,
- navId: navContainer.name || navContainer.id,
- type: navContainer.getType(),
- secondaryId: navContainer.getSecondaryIdentifier(),
- requiresExplicitNavPrefix: requiresExplicitPrefix
- };
- };
- return UrlSerializer;
- }());
- function formatUrlPart(name) {
- name = name.replace(URL_REPLACE_REG, '-');
- name = name.charAt(0).toLowerCase() + name.substring(1).replace(/[A-Z]/g, function (match) {
- return '-' + match.toLowerCase();
- });
- while (name.indexOf('--') > -1) {
- name = name.replace('--', '-');
- }
- if (name.charAt(0) === '-') {
- name = name.substring(1);
- }
- if (name.substring(name.length - 1) === '-') {
- name = name.substring(0, name.length - 1);
- }
- return encodeURIComponent(name);
- }
- var isPartMatch = function (urlPart, configLinkPart) {
- if (isPresent(urlPart) && isPresent(configLinkPart)) {
- if (configLinkPart.charAt(0) === ':') {
- return true;
- }
- return (urlPart === configLinkPart);
- }
- return false;
- };
- var createMatchedData = function (matchedUrlParts, link) {
- var data = null;
- for (var i = 0; i < link.segmentPartsLen; i++) {
- if (link.segmentParts[i].charAt(0) === ':') {
- data = data || {};
- data[link.segmentParts[i].substring(1)] = decodeURIComponent(matchedUrlParts[i]);
- }
- }
- return data;
- };
- var findLinkByComponentData = function (links, component, instanceData) {
- var foundLink = null;
- var foundLinkDataMatches = -1;
- for (var i = 0; i < links.length; i++) {
- var link = links[i];
- if (link.component === component) {
- // ok, so the component matched, but multiple links can point
- // to the same component, so let's make sure this is the right link
- var dataMatches = 0;
- if (instanceData) {
- var instanceDataKeys = Object.keys(instanceData);
- // this link has data
- for (var j = 0; j < instanceDataKeys.length; j++) {
- if (isPresent(link.dataKeys[instanceDataKeys[j]])) {
- dataMatches++;
- }
- }
- }
- else if (link.dataLen) {
- // this component does not have data but the link does
- continue;
- }
- if (dataMatches >= foundLinkDataMatches) {
- foundLink = link;
- foundLinkDataMatches = dataMatches;
- }
- }
- }
- return foundLink;
- };
- var normalizeLinks = function (links) {
- for (var i = 0, ilen = links.length; i < ilen; i++) {
- var link = links[i];
- if (isBlank$1(link.segment)) {
- link.segment = link.name;
- }
- link.dataKeys = {};
- link.segmentParts = link.segment.split('/');
- link.segmentPartsLen = link.segmentParts.length;
- // used for sorting
- link.staticLen = link.dataLen = 0;
- var stillCountingStatic = true;
- for (var j = 0; j < link.segmentPartsLen; j++) {
- if (link.segmentParts[j].charAt(0) === ':') {
- link.dataLen++;
- stillCountingStatic = false;
- link.dataKeys[link.segmentParts[j].substring(1)] = true;
- }
- else if (stillCountingStatic) {
- link.staticLen++;
- }
- }
- }
- // sort by the number of parts, with the links
- // with the most parts first
- return links.sort(sortConfigLinks);
- };
- function sortConfigLinks(a, b) {
- // sort by the number of parts
- if (a.segmentPartsLen > b.segmentPartsLen) {
- return -1;
- }
- if (a.segmentPartsLen < b.segmentPartsLen) {
- return 1;
- }
- // sort by the number of static parts in a row
- if (a.staticLen > b.staticLen) {
- return -1;
- }
- if (a.staticLen < b.staticLen) {
- return 1;
- }
- // sort by the number of total data parts
- if (a.dataLen < b.dataLen) {
- return -1;
- }
- if (a.dataLen > b.dataLen) {
- return 1;
- }
- return 0;
- }
- var URL_REPLACE_REG = /\s+|\?|\!|\$|\,|\.|\+|\"|\'|\*|\^|\||\/|\\|\[|\]|#|%|`|>|<|;|:|@|&|=/g;
- /**
- * @hidden
- */
- var DeepLinkConfigToken = new InjectionToken('USERLINKS');
- function setupUrlSerializer(app, userDeepLinkConfig) {
- return new UrlSerializer(app, userDeepLinkConfig);
- }
- function navGroupStringtoObjects(navGroupStrings) {
- // each string has a known format-ish, convert it to it
- return navGroupStrings.map(function (navGroupString) {
- var sections = navGroupString.split('/');
- if (sections[0] === 'nav') {
- return {
- type: 'nav',
- navId: sections[1],
- niceId: sections[1],
- secondaryId: null,
- segmentPieces: sections.splice(2)
- };
- }
- else if (sections[0] === 'tabs') {
- return {
- type: 'tabs',
- navId: sections[1],
- niceId: sections[1],
- secondaryId: sections[2],
- segmentPieces: sections.splice(3)
- };
- }
- return {
- type: null,
- navId: null,
- niceId: null,
- secondaryId: null,
- segmentPieces: sections
- };
- });
- }
- function urlToNavGroupStrings(url) {
- var tokens = url.split('/');
- var keywordIndexes = [];
- for (var i = 0; i < tokens.length; i++) {
- if (i !== 0 && (tokens[i] === 'nav' || tokens[i] === 'tabs')) {
- keywordIndexes.push(i);
- }
- }
- // append the last index + 1 to the list no matter what
- keywordIndexes.push(tokens.length);
- var groupings = [];
- var activeKeywordIndex = 0;
- var tmpArray = [];
- for (var i = 0; i < tokens.length; i++) {
- if (i >= keywordIndexes[activeKeywordIndex]) {
- groupings.push(tmpArray.join('/'));
- tmpArray = [];
- activeKeywordIndex++;
- }
- tmpArray.push(tokens[i]);
- }
- // okay, after the loop we've gotta push one more time just to be safe
- groupings.push(tmpArray.join('/'));
- return groupings;
- }
- function convertUrlToSegments(app, url, navLinks) {
- var pairs = convertUrlToDehydratedSegments(url, navLinks);
- return hydrateSegmentsWithNav(app, pairs);
- }
- function convertUrlToDehydratedSegments(url, navLinks) {
- var navGroupStrings = urlToNavGroupStrings(url);
- var navGroups = navGroupStringtoObjects(navGroupStrings);
- return getSegmentsFromNavGroups(navGroups, navLinks);
- }
- function hydrateSegmentsWithNav(app, dehydratedSegmentPairs) {
- var segments = [];
- for (var i = 0; i < dehydratedSegmentPairs.length; i++) {
- var navs = getNavFromNavGroup(dehydratedSegmentPairs[i].navGroup, app);
- // okay, cool, let's walk through the segments and hydrate them
- for (var _i = 0, _a = dehydratedSegmentPairs[i].segments; _i < _a.length; _i++) {
- var dehydratedSegment = _a[_i];
- if (navs.length === 1) {
- segments.push(hydrateSegment(dehydratedSegment, navs[0]));
- navs = navs[0].getActiveChildNavs();
- }
- else if (navs.length > 1) {
- // this is almost certainly an async race condition bug in userland
- // if you're in this state, it would be nice to just bail here
- // but alas we must perservere and handle the issue
- // the simple solution is to just use the last child
- // because that is probably what the user wants anyway
- // remember, do not harm, even if it makes our shizzle ugly
- segments.push(hydrateSegment(dehydratedSegment, navs[navs.length - 1]));
- navs = navs[navs.length - 1].getActiveChildNavs();
- }
- else {
- break;
- }
- }
- }
- return segments;
- }
- function getNavFromNavGroup(navGroup, app) {
- if (navGroup.navId) {
- var rootNav = app.getNavByIdOrName(navGroup.navId);
- if (rootNav) {
- return [rootNav];
- }
- return [];
- }
- // we don't know what nav to use, so just use the root nav.
- // if there is more than one root nav, throw an error
- return app.getRootNavs();
- }
- /*
- * Let's face the facts: Getting a dehydrated segment from the url is really hard
- * because we need to do a ton of crazy looping
- * the are chunks of a url that are totally irrelevant at this stage, such as the secondary identifier
- * stating which tab is selected, etc.
- * but is necessary.
- * We look at segment pieces in reverse order to try to build segments
- * as in, if you had an array like this
- * ['my', 'super', 'cool', 'url']
- * we want to look at the pieces in reverse order:
- * url
- * cool url
- * super cool url
- * my super cool url
- * cool
- * super cool
- * my super cool
- * super
- * my super
- * my
- **/
- function getSegmentsFromNavGroups(navGroups, navLinks) {
- var pairs = [];
- var usedNavLinks = new Set();
- for (var _i = 0, navGroups_1 = navGroups; _i < navGroups_1.length; _i++) {
- var navGroup = navGroups_1[_i];
- var segments = [];
- var segmentPieces = navGroup.segmentPieces.concat([]);
- for (var i = segmentPieces.length; i >= 0; i--) {
- var created = false;
- for (var j = 0; j < i; j++) {
- var startIndex = i - j - 1;
- var endIndex = i;
- var subsetOfUrl = segmentPieces.slice(startIndex, endIndex);
- for (var _a = 0, navLinks_1 = navLinks; _a < navLinks_1.length; _a++) {
- var navLink = navLinks_1[_a];
- if (!usedNavLinks.has(navLink.name)) {
- var segment = getSegmentsFromUrlPieces(subsetOfUrl, navLink);
- if (segment) {
- i = startIndex + 1;
- usedNavLinks.add(navLink.name);
- created = true;
- // sweet, we found a segment
- segments.push(segment);
- // now we want to null out the url subsection in the segmentPieces
- for (var k = startIndex; k < endIndex; k++) {
- segmentPieces[k] = null;
- }
- break;
- }
- }
- }
- if (created) {
- break;
- }
- }
- if (!created && segmentPieces[i - 1]) {
- // this is very likely a tab's secondary identifier
- segments.push({
- id: null,
- name: null,
- secondaryId: segmentPieces[i - 1],
- component: null,
- loadChildren: null,
- data: null,
- defaultHistory: null
- });
- }
- }
- // since we're getting segments in from right-to-left in the url, reverse them
- // so they're in the correct order. Also filter out and bogus segments
- var orderedSegments = segments.reverse();
- // okay, this is the lazy persons approach here.
- // so here's the deal! Right now if section of the url is not a part of a segment
- // it is almost certainly the secondaryId for a tabs component
- // basically, knowing the segment for the `tab` itself is good, but we also need to know
- // which tab is selected, so we have an identifer in the url that is associated with the tabs component
- // telling us which tab is selected. With that in mind, we are going to go through and find the segments with only secondary identifiers,
- // and simply add the secondaryId to the next segment, and then remove the empty segment from the list
- for (var i = 0; i < orderedSegments.length; i++) {
- if (orderedSegments[i].secondaryId && !orderedSegments[i].id && ((i + 1) <= orderedSegments.length - 1)) {
- orderedSegments[i + 1].secondaryId = orderedSegments[i].secondaryId;
- orderedSegments[i] = null;
- }
- }
- var cleanedSegments = segments.filter(function (segment) { return !!segment; });
- // if the nav group has a secondary id, make sure the first segment also has it set
- if (navGroup.secondaryId && segments.length) {
- cleanedSegments[0].secondaryId = navGroup.secondaryId;
- }
- pairs.push({
- navGroup: navGroup,
- segments: cleanedSegments
- });
- }
- return pairs;
- }
- function getSegmentsFromUrlPieces(urlSections, navLink) {
- if (navLink.segmentPartsLen !== urlSections.length) {
- return null;
- }
- for (var i = 0; i < urlSections.length; i++) {
- if (!isPartMatch(urlSections[i], navLink.segmentParts[i])) {
- // just return an empty array if the part doesn't match
- return null;
- }
- }
- return {
- id: urlSections.join('/'),
- name: navLink.name,
- component: navLink.component,
- loadChildren: navLink.loadChildren,
- data: createMatchedData(urlSections, navLink),
- defaultHistory: navLink.defaultHistory
- };
- }
- function hydrateSegment(segment, nav) {
- var hydratedSegment = Object.assign({}, segment);
- hydratedSegment.type = nav.getType();
- hydratedSegment.navId = nav.name || nav.id;
- // secondaryId is set on an empty dehydrated segment in the case of tabs to identify which tab is selected
- hydratedSegment.secondaryId = segment.secondaryId;
- return hydratedSegment;
- }
-
- /**
- * @hidden
- */
- var DeepLinker = (function () {
- function DeepLinker(_app, _serializer, _location, _moduleLoader, _baseCfr) {
- this._app = _app;
- this._serializer = _serializer;
- this._location = _location;
- this._moduleLoader = _moduleLoader;
- this._baseCfr = _baseCfr;
- /** @internal */
- this._history = [];
- }
- /**
- * @internal
- */
- DeepLinker.prototype.init = function () {
- var _this = this;
- // scenario 1: Initial load of all navs from the initial browser URL
- var browserUrl = normalizeUrl(this._location.path());
- (void 0) /* console.debug */;
- // remember this URL in our internal history stack
- this._historyPush(browserUrl);
- // listen for browser URL changes
- this._location.subscribe(function (locationChg) {
- _this._urlChange(normalizeUrl(locationChg.url));
- });
- };
- /**
- * The browser's location has been updated somehow.
- * @internal
- */
- DeepLinker.prototype._urlChange = function (browserUrl) {
- var _this = this;
- // do nothing if this url is the same as the current one
- if (!this._isCurrentUrl(browserUrl)) {
- var isGoingBack = true;
- if (this._isBackUrl(browserUrl)) {
- // scenario 2: user clicked the browser back button
- // scenario 4: user changed the browser URL to what was the back url was
- // scenario 5: user clicked a link href that was the back url
- (void 0) /* console.debug */;
- this._historyPop();
- }
- else {
- // scenario 3: user click forward button
- // scenario 4: user changed browser URL that wasn't the back url
- // scenario 5: user clicked a link href that wasn't the back url
- isGoingBack = false;
- (void 0) /* console.debug */;
- this._historyPush(browserUrl);
- }
- // get the app's root nav container
- var activeNavContainers_1 = this._app.getActiveNavContainers();
- if (activeNavContainers_1 && activeNavContainers_1.length) {
- if (browserUrl === '/') {
- // a url change to the index url
- if (isPresent(this._indexAliasUrl)) {
- // we already know the indexAliasUrl
- // update the url to use the know alias
- browserUrl = this._indexAliasUrl;
- }
- else {
- // the url change is to the root but we don't
- // already know the url used. So let's just
- // reset the root nav to its root page
- activeNavContainers_1.forEach(function (navContainer) {
- navContainer.goToRoot({
- updateUrl: false,
- isNavRoot: true
- });
- });
- return;
- }
- }
- // normal url
- var segments = this.getCurrentSegments(browserUrl);
- segments
- .map(function (segment) {
- // find the matching nav container
- for (var _i = 0, activeNavContainers_2 = activeNavContainers_1; _i < activeNavContainers_2.length; _i++) {
- var navContainer = activeNavContainers_2[_i];
- var nav = getNavFromTree(navContainer, segment.navId);
- if (nav) {
- return {
- segment: segment,
- navContainer: nav
- };
- }
- }
- })
- .filter(function (pair) { return !!pair; })
- .forEach(function (pair) {
- _this._loadViewForSegment(pair.navContainer, pair.segment, function () { });
- });
- }
- }
- };
- DeepLinker.prototype.getCurrentSegments = function (browserUrl) {
- if (!browserUrl) {
- browserUrl = normalizeUrl(this._location.path());
- }
- return this._serializer.parse(browserUrl);
- };
- /**
- * Update the deep linker using the NavController's current active view.
- * @internal
- */
- DeepLinker.prototype.navChange = function (direction) {
- if (direction) {
- var activeNavContainers = this._app.getActiveNavContainers();
- // the only time you'll ever get a TABS here is when loading directly from a URL
- // this method will be called again when the TAB is loaded
- // so just don't worry about the TABS for now
- // if you encounter a TABS, just return
- for (var _i = 0, activeNavContainers_3 = activeNavContainers; _i < activeNavContainers_3.length; _i++) {
- var activeNavContainer = activeNavContainers_3[_i];
- if (isTabs(activeNavContainer) || activeNavContainer.isTransitioning()) {
- return;
- }
- }
- // okay, get the root navs and build the segments up
- var segments = [];
- var navContainers = this._app.getRootNavs();
- for (var _a = 0, navContainers_1 = navContainers; _a < navContainers_1.length; _a++) {
- var navContainer = navContainers_1[_a];
- var segmentsForNav = this.getSegmentsFromNav(navContainer);
- segments = segments.concat(segmentsForNav);
- }
- segments = segments.filter(function (segment) { return !!segment; });
- if (segments.length) {
- var browserUrl = this._serializer.serialize(segments);
- this._updateLocation(browserUrl, direction);
- }
- }
- };
- DeepLinker.prototype.getSegmentsFromNav = function (nav) {
- var _this = this;
- var segments = [];
- if (isNav(nav)) {
- segments.push(this.getSegmentFromNav(nav));
- }
- else if (isTab(nav)) {
- segments.push(this.getSegmentFromTab(nav));
- }
- nav.getActiveChildNavs().forEach(function (child) {
- segments = segments.concat(_this.getSegmentsFromNav(child));
- });
- return segments;
- };
- DeepLinker.prototype.getSegmentFromNav = function (nav, component, data) {
- if (!component) {
- var viewController = nav.getActive(true);
- if (viewController) {
- component = viewController.component;
- data = viewController.data;
- }
- }
- return this._serializer.serializeComponent(nav, component, data);
- };
- DeepLinker.prototype.getSegmentFromTab = function (navContainer, component, data) {
- if (navContainer && navContainer.parent) {
- var tabsNavContainer = navContainer.parent;
- var activeChildNavs = tabsNavContainer.getActiveChildNavs();
- if (activeChildNavs && activeChildNavs.length) {
- var activeChildNav = activeChildNavs[0];
- var viewController = activeChildNav.getActive(true);
- if (viewController) {
- component = viewController.component;
- data = viewController.data;
- }
- return this._serializer.serializeComponent(tabsNavContainer, component, data);
- }
- }
- };
- /**
- * @internal
- */
- DeepLinker.prototype._updateLocation = function (browserUrl, direction) {
- if (this._indexAliasUrl === browserUrl) {
- browserUrl = '/';
- }
- if (direction === DIRECTION_BACK && this._isBackUrl(browserUrl)) {
- // this URL is exactly the same as the back URL
- // it's safe to use the browser's location.back()
- (void 0) /* console.debug */;
- this._historyPop();
- this._location.back();
- }
- else if (!this._isCurrentUrl(browserUrl)) {
- // probably navigating forward
- (void 0) /* console.debug */;
- this._historyPush(browserUrl);
- this._location.go(browserUrl);
- }
- };
- DeepLinker.prototype.getComponentFromName = function (componentName) {
- var link = this._serializer.getLinkFromName(componentName);
- if (link) {
- // cool, we found the right link for this component name
- return this.getNavLinkComponent(link);
- }
- // umm, idk
- return Promise.reject("invalid link: " + componentName);
- };
- DeepLinker.prototype.getNavLinkComponent = function (link) {
- if (link.component) {
- // sweet, we're already got a component loaded for this link
- return Promise.resolve(link.component);
- }
- if (link.loadChildren) {
- // awesome, looks like we'll lazy load this component
- // using loadChildren as the URL to request
- return this._moduleLoader.load(link.loadChildren).then(function (response) {
- link.component = response.component;
- return response.component;
- });
- }
- return Promise.reject("invalid link component: " + link.name);
- };
- /**
- * @internal
- */
- DeepLinker.prototype.resolveComponent = function (component) {
- var cfr = this._moduleLoader.getComponentFactoryResolver(component);
- if (!cfr) {
- cfr = this._baseCfr;
- }
- return cfr.resolveComponentFactory(component);
- };
- /**
- * @internal
- */
- DeepLinker.prototype.createUrl = function (navContainer, nameOrComponent, _data, prepareExternalUrl) {
- if (prepareExternalUrl === void 0) { prepareExternalUrl = true; }
- // create a segment out of just the passed in name
- var segment = this._serializer.createSegmentFromName(navContainer, nameOrComponent);
- var allSegments = this.getCurrentSegments();
- if (segment) {
- for (var i = 0; i < allSegments.length; i++) {
- if (allSegments[i].navId === navContainer.name || allSegments[i].navId === navContainer.id) {
- allSegments[i] = segment;
- var url = this._serializer.serialize(allSegments);
- return prepareExternalUrl ? this._location.prepareExternalUrl(url) : url;
- }
- }
- }
- return '';
- };
- /**
- * Each NavController will call this method when it initializes for
- * the first time. This allows each NavController to figure out
- * where it lives in the path and load up the correct component.
- * @internal
- */
- DeepLinker.prototype.getSegmentByNavIdOrName = function (navId, name) {
- var browserUrl = normalizeUrl(this._location.path());
- var segments = this._serializer.parse(browserUrl);
- for (var _i = 0, segments_1 = segments; _i < segments_1.length; _i++) {
- var segment = segments_1[_i];
- if (segment.navId === navId || segment.navId === name) {
- return segment;
- }
- }
- return null;
- };
- /**
- * @internal
- */
- DeepLinker.prototype.initViews = function (segment) {
- var _this = this;
- var link = this._serializer.getLinkFromName(segment.name);
- return this.getNavLinkComponent(link).then(function (component) {
- segment.component = component;
- var view = new ViewController(component, segment.data);
- view.id = segment.id;
- if (isArray$2(segment.defaultHistory)) {
- return convertToViews(_this, segment.defaultHistory).then(function (views) {
- views.push(view);
- return views;
- });
- }
- return [view];
- });
- };
- /**
- * @internal
- */
- DeepLinker.prototype._isBackUrl = function (browserUrl) {
- return (browserUrl === this._history[this._history.length - 2]);
- };
- /**
- * @internal
- */
- DeepLinker.prototype._isCurrentUrl = function (browserUrl) {
- return (browserUrl === this._history[this._history.length - 1]);
- };
- /**
- * @internal
- */
- DeepLinker.prototype._historyPush = function (browserUrl) {
- if (!this._isCurrentUrl(browserUrl)) {
- this._history.push(browserUrl);
- if (this._history.length > 30) {
- this._history.shift();
- }
- }
- };
- /**
- * @internal
- */
- DeepLinker.prototype._historyPop = function () {
- this._history.pop();
- if (!this._history.length) {
- this._historyPush(this._location.path());
- }
- };
- /**
- * @internal
- */
- DeepLinker.prototype._getTabSelector = function (tab) {
- if (isPresent(tab.tabUrlPath)) {
- return tab.tabUrlPath;
- }
- if (isPresent(tab.tabTitle)) {
- return formatUrlPart(tab.tabTitle);
- }
- return "tab-" + tab.index;
- };
- /**
- * Using the known Path of Segments, walk down all descendents
- * from the root NavController and load each NavController according
- * to each Segment. This is usually called after a browser URL and
- * Path changes and needs to update all NavControllers to match
- * the new browser URL. Because the URL is already known, it will
- * not update the browser's URL when transitions have completed.
- *
- * @internal
- */
- DeepLinker.prototype._loadViewForSegment = function (navContainer, segment, done) {
- if (!segment) {
- return done(false, false);
- }
- if (isTabs(navContainer) || (isTab(navContainer) && navContainer.parent)) {
- var tabs = (isTabs(navContainer) ? navContainer : navContainer.parent);
- var selectedIndex = tabs._getSelectedTabIndex(segment.secondaryId);
- var tab = tabs.getByIndex(selectedIndex);
- tab._segment = segment;
- tabs.select(tab, {
- updateUrl: false,
- animate: false
- }, true);
- return done(false, false);
- }
- var navController = navContainer;
- var numViews = navController.length() - 1;
- // walk backwards to see if the exact view we want to show here
- // is already in the stack that we can just pop back to
- for (var i = numViews; i >= 0; i--) {
- var viewController = navController.getByIndex(i);
- if (viewController && (viewController.id === segment.id || viewController.id === segment.name)) {
- // hooray! we've already got a view loaded in the stack
- // matching the view they wanted to show
- if (i === numViews) {
- // this is the last view in the stack and it's the same
- // as the segment so there's no change needed
- return done(false, false);
- }
- else {
- // it's not the exact view as the end
- // let's have this nav go back to this exact view
- return navController.popTo(viewController, {
- animate: false,
- updateUrl: false,
- }, done);
- }
- }
- }
- // ok, so we don't know about a view that they're navigating to
- // so we might as well just call setRoot and make tthe view the first view
- // this seems like the least bad option
- return navController.setRoot(segment.component || segment.name, segment.data, {
- id: segment.id, animate: false, updateUrl: false
- }, done);
- };
- return DeepLinker;
- }());
- function setupDeepLinker(app, serializer, location, moduleLoader, cfr) {
- var deepLinker = new DeepLinker(app, serializer, location, moduleLoader, cfr);
- deepLinker.init();
- return deepLinker;
- }
- function normalizeUrl(browserUrl) {
- browserUrl = browserUrl.trim();
- if (browserUrl.charAt(0) !== '/') {
- // ensure first char is a /
- browserUrl = '/' + browserUrl;
- }
- if (browserUrl.length > 1 && browserUrl.charAt(browserUrl.length - 1) === '/') {
- // ensure last char is not a /
- browserUrl = browserUrl.substr(0, browserUrl.length - 1);
- }
- return browserUrl;
- }
- function getNavFromTree(nav, id) {
- while (nav) {
- if (nav.id === id || nav.name === id) {
- return nav;
- }
- nav = nav.parent;
- }
- return null;
- }
-
- /**
- * Adopted from FastDom
- * https://github.com/wilsonpage/fastdom
- * MIT License
- */
- /**
- * @hidden
- */
- var DomDebouncer = (function () {
- function DomDebouncer(dom) {
- this.dom = dom;
- this.writeTask = null;
- this.readTask = null;
- }
- DomDebouncer.prototype.read = function (fn) {
- var _this = this;
- if (this.readTask) {
- return;
- }
- return this.readTask = this.dom.read(function (t) {
- _this.readTask = null;
- fn(t);
- });
- };
- DomDebouncer.prototype.write = function (fn) {
- var _this = this;
- if (this.writeTask) {
- return;
- }
- return this.writeTask = this.dom.write(function (t) {
- _this.writeTask = null;
- fn(t);
- });
- };
- DomDebouncer.prototype.cancel = function () {
- var writeTask = this.writeTask;
- writeTask && this.dom.cancel(writeTask);
- var readTask = this.readTask;
- readTask && this.dom.cancel(readTask);
- this.readTask = this.writeTask = null;
- };
- return DomDebouncer;
- }());
- /**
- * @hidden
- */
- var DomController = (function () {
- function DomController(plt) {
- this.plt = plt;
- this.r = [];
- this.w = [];
- }
- DomController.prototype.debouncer = function () {
- return new DomDebouncer(this);
- };
- DomController.prototype.read = function (fn, timeout) {
- var _this = this;
- if (timeout) {
- fn.timeoutId = this.plt.timeout(function () {
- _this.r.push(fn);
- _this._queue();
- }, timeout);
- }
- else {
- this.r.push(fn);
- this._queue();
- }
- return fn;
- };
- DomController.prototype.write = function (fn, timeout) {
- var _this = this;
- if (timeout) {
- fn.timeoutId = this.plt.timeout(function () {
- _this.w.push(fn);
- _this._queue();
- }, timeout);
- }
- else {
- this.w.push(fn);
- this._queue();
- }
- return fn;
- };
- DomController.prototype.cancel = function (fn) {
- if (fn) {
- if (fn.timeoutId) {
- this.plt.cancelTimeout(fn.timeoutId);
- }
- removeArrayItem(this.r, fn) || removeArrayItem(this.w, fn);
- }
- };
- DomController.prototype._queue = function () {
- var self = this;
- if (!self.q) {
- self.q = true;
- self.plt.raf(function rafCallback(timeStamp) {
- self._flush(timeStamp);
- });
- }
- };
- DomController.prototype._flush = function (timeStamp) {
- var err;
- try {
- dispatch(timeStamp, this.r, this.w);
- }
- catch (e) {
- err = e;
- }
- this.q = false;
- if (this.r.length || this.w.length) {
- this._queue();
- }
- if (err) {
- throw err;
- }
- };
- DomController.decorators = [
- { type: Injectable },
- ];
- /** @nocollapse */
- DomController.ctorParameters = function () { return [
- { type: Platform, },
- ]; };
- return DomController;
- }());
- function dispatch(timeStamp, r, w) {
- var fn;
- // ******** DOM READS ****************
- while (fn = r.shift()) {
- fn(timeStamp);
- }
- // ******** DOM WRITES ****************
- while (fn = w.shift()) {
- fn(timeStamp);
- }
- }
-
- /** @hidden */
- var GESTURE_GO_BACK_SWIPE = 'goback-swipe';
- /** @hidden */
- var GESTURE_MENU_SWIPE = 'menu-swipe';
- /** @hidden */
- var GESTURE_ITEM_SWIPE = 'item-swipe';
- /** @hidden */
- var GESTURE_REFRESHER = 'refresher';
- /** @hidden */
- var GESTURE_TOGGLE = 'toggle';
- /** @hidden */
- var GESTURE_PRIORITY_SLIDING_ITEM = -10;
- /** @hidden */
- var GESTURE_PRIORITY_REFRESHER = 0;
- /** @hidden */
- var GESTURE_PRIORITY_MENU_SWIPE = 10;
- /** @hidden */
- var GESTURE_PRIORITY_GO_BACK_SWIPE = 20;
- /** @hidden */
- var GESTURE_PRIORITY_TOGGLE = 30;
- /**
- * @hidden
- */
- var BLOCK_ALL = {
- disable: [GESTURE_MENU_SWIPE, GESTURE_GO_BACK_SWIPE],
- disableScroll: true
- };
- /**
- * @hidden
- */
- var GestureController = (function () {
- function GestureController(_app) {
- this._app = _app;
- this.id = 1;
- this.requestedStart = {};
- this.disabledGestures = {};
- this.disabledScroll = new Set();
- this.capturedID = null;
- }
- GestureController.prototype.createGesture = function (opts) {
- if (!opts.name) {
- throw new Error('name is undefined');
- }
- return new GestureDelegate(opts.name, this.newID(), this, opts.priority || 0, !!opts.disableScroll);
- };
- GestureController.prototype.createBlocker = function (opts) {
- if (opts === void 0) { opts = {}; }
- return new BlockerDelegate(this.newID(), this, opts.disable, !!opts.disableScroll);
- };
- GestureController.prototype.newID = function () {
- var id = this.id;
- this.id++;
- return id;
- };
- GestureController.prototype.start = function (gestureName, id, priority) {
- if (!this.canStart(gestureName)) {
- delete this.requestedStart[id];
- return false;
- }
- this.requestedStart[id] = priority;
- return true;
- };
- GestureController.prototype.capture = function (gestureName, id, priority) {
- if (!this.start(gestureName, id, priority)) {
- return false;
- }
- var requestedStart = this.requestedStart;
- var maxPriority = -10000;
- for (var gestureID in requestedStart) {
- maxPriority = Math.max(maxPriority, requestedStart[gestureID]);
- }
- if (maxPriority === priority) {
- this.capturedID = id;
- this.requestedStart = {};
- (void 0) /* console.debug */;
- return true;
- }
- delete requestedStart[id];
- (void 0) /* console.debug */;
- return false;
- };
- GestureController.prototype.release = function (id) {
- delete this.requestedStart[id];
- if (this.capturedID && id === this.capturedID) {
- this.capturedID = null;
- }
- };
- GestureController.prototype.disableGesture = function (gestureName, id) {
- var set = this.disabledGestures[gestureName];
- if (!set) {
- set = new Set();
- this.disabledGestures[gestureName] = set;
- }
- set.add(id);
- };
- GestureController.prototype.enableGesture = function (gestureName, id) {
- var set = this.disabledGestures[gestureName];
- if (set) {
- set.delete(id);
- }
- };
- GestureController.prototype.disableScroll = function (id) {
- var isEnabled = !this.isScrollDisabled();
- this.disabledScroll.add(id);
- if (this._app && isEnabled && this.isScrollDisabled()) {
- (void 0) /* console.debug */;
- this._app._setDisableScroll(true);
- }
- };
- GestureController.prototype.enableScroll = function (id) {
- var isDisabled = this.isScrollDisabled();
- this.disabledScroll.delete(id);
- if (this._app && isDisabled && !this.isScrollDisabled()) {
- (void 0) /* console.debug */;
- this._app._setDisableScroll(false);
- }
- };
- GestureController.prototype.canStart = function (gestureName) {
- if (this.capturedID) {
- (void 0) /* console.debug */;
- // a gesture already captured
- return false;
- }
- if (this.isDisabled(gestureName)) {
- (void 0) /* console.debug */;
- return false;
- }
- return true;
- };
- GestureController.prototype.isCaptured = function () {
- return !!this.capturedID;
- };
- GestureController.prototype.isScrollDisabled = function () {
- return this.disabledScroll.size > 0;
- };
- GestureController.prototype.isDisabled = function (gestureName) {
- var disabled = this.disabledGestures[gestureName];
- return !!(disabled && disabled.size > 0);
- };
- GestureController.decorators = [
- { type: Injectable },
- ];
- /** @nocollapse */
- GestureController.ctorParameters = function () { return [
- { type: App, decorators: [{ type: Inject, args: [forwardRef(function () { return App; }),] },] },
- ]; };
- return GestureController;
- }());
- /**
- * @hidden
- */
- var GestureDelegate = (function () {
- function GestureDelegate(name, id, controller, priority, disableScroll) {
- this.name = name;
- this.id = id;
- this.controller = controller;
- this.priority = priority;
- this.disableScroll = disableScroll;
- }
- GestureDelegate.prototype.canStart = function () {
- if (!this.controller) {
- (void 0) /* assert */;
- return false;
- }
- return this.controller.canStart(this.name);
- };
- GestureDelegate.prototype.start = function () {
- if (!this.controller) {
- (void 0) /* assert */;
- return false;
- }
- return this.controller.start(this.name, this.id, this.priority);
- };
- GestureDelegate.prototype.capture = function () {
- if (!this.controller) {
- (void 0) /* assert */;
- return false;
- }
- var captured = this.controller.capture(this.name, this.id, this.priority);
- if (captured && this.disableScroll) {
- this.controller.disableScroll(this.id);
- }
- return captured;
- };
- GestureDelegate.prototype.release = function () {
- if (!this.controller) {
- (void 0) /* assert */;
- return;
- }
- this.controller.release(this.id);
- if (this.disableScroll) {
- this.controller.enableScroll(this.id);
- }
- };
- GestureDelegate.prototype.destroy = function () {
- this.release();
- this.controller = null;
- };
- return GestureDelegate;
- }());
- /**
- * @hidden
- */
- var BlockerDelegate = (function () {
- function BlockerDelegate(id, controller, disable, disableScroll) {
- this.id = id;
- this.controller = controller;
- this.disable = disable;
- this.disableScroll = disableScroll;
- this.blocked = false;
- }
- BlockerDelegate.prototype.block = function () {
- var _this = this;
- if (!this.controller) {
- (void 0) /* assert */;
- return;
- }
- if (this.disable) {
- this.disable.forEach(function (gesture) {
- _this.controller.disableGesture(gesture, _this.id);
- });
- }
- if (this.disableScroll) {
- this.controller.disableScroll(this.id);
- }
- this.blocked = true;
- };
- BlockerDelegate.prototype.unblock = function () {
- var _this = this;
- if (!this.controller) {
- (void 0) /* assert */;
- return;
- }
- if (this.disable) {
- this.disable.forEach(function (gesture) {
- _this.controller.enableGesture(gesture, _this.id);
- });
- }
- if (this.disableScroll) {
- this.controller.enableScroll(this.id);
- }
- this.blocked = false;
- };
- BlockerDelegate.prototype.destroy = function () {
- this.unblock();
- this.controller = null;
- };
- return BlockerDelegate;
- }());
-
- /**
- * @name NavController
- * @description
- *
- * NavController is the base class for navigation controller components like
- * [`Nav`](../../components/nav/Nav/) and [`Tab`](../../components/tabs/Tab/). You use navigation controllers
- * to navigate to [pages](#view-creation) in your app. At a basic level, a
- * navigation controller is an array of pages representing a particular history
- * (of a Tab for example). This array can be manipulated to navigate throughout
- * an app by pushing and popping pages or inserting and removing them at
- * arbitrary locations in history.
- *
- * The current page is the last one in the array, or the top of the stack if we
- * think of it that way. [Pushing](#push) a new page onto the top of the
- * navigation stack causes the new page to be animated in, while [popping](#pop)
- * the current page will navigate to the previous page in the stack.
- *
- * Unless you are using a directive like [NavPush](../../components/nav/NavPush/), or need a
- * specific NavController, most times you will inject and use a reference to the
- * nearest NavController to manipulate the navigation stack.
- *
- * ## Basic usage
- * The simplest way to navigate through an app is to create and initialize a new
- * nav controller using the `<ion-nav>` component. `ion-nav` extends the `NavController`
- * class.
- *
- * ```typescript
- * import { Component } from `@angular/core`;
- * import { StartPage } from './start-page';
- *
- * @Component(
- * template: `<ion-nav [root]="rootPage"></ion-nav>`
- * })
- * class MyApp {
- * // set the rootPage to the first page we want displayed
- * public rootPage: any = StartPage;
- *
- * constructor(){
- * }
- * }
- *
- * ```
- *
- * ### Injecting NavController
- * Injecting NavController will always get you an instance of the nearest
- * NavController, regardless of whether it is a Tab or a Nav.
- *
- * Behind the scenes, when Ionic instantiates a new NavController, it creates an
- * injector with NavController bound to that instance (usually either a Nav or
- * Tab) and adds the injector to its own providers. For more information on
- * providers and dependency injection, see [Dependency Injection](https://angular.io/docs/ts/latest/guide/dependency-injection.html).
- *
- * Instead, you can inject NavController and know that it is the correct
- * navigation controller for most situations (for more advanced situations, see
- * [Menu](../../menu/Menu/) and [Tab](../../tab/Tab/)).
- *
- * ```ts
- * import { NavController } from 'ionic-angular';
- *
- * class MyComponent {
- * constructor(public navCtrl: NavController) {
- *
- * }
- * }
- * ```
- *
- * ### Navigating from the Root component
- * What if you want to control navigation from your root app component?
- * You can't inject `NavController` because any components that are navigation
- * controllers are _children_ of the root component so they aren't available
- * to be injected.
- *
- * By adding a reference variable to the `ion-nav`, you can use `@ViewChild` to
- * get an instance of the `Nav` component, which is a navigation controller
- * (it extends `NavController`):
- *
- * ```typescript
- *
- * import { Component, ViewChild } from '@angular/core';
- * import { NavController } from 'ionic-angular';
- *
- * @Component({
- * template: '<ion-nav #myNav [root]="rootPage"></ion-nav>'
- * })
- * export class MyApp {
- * @ViewChild('myNav') nav: NavController
- * public rootPage: any = TabsPage;
- *
- * // Wait for the components in MyApp's template to be initialized
- * // In this case, we are waiting for the Nav with reference variable of "#myNav"
- * ngOnInit() {
- * // Let's navigate from TabsPage to Page1
- * this.nav.push(Page1);
- * }
- * }
- * ```
- *
- * ### Navigating from an Overlay Component
- * What if you wanted to navigate from an overlay component (popover, modal, alert, etc)?
- * In this example, we've displayed a popover in our app. From the popover, we'll get a
- * reference of the root `NavController` in our app, using the `getRootNav()` method.
- *
- *
- * ```typescript
- * import { Component } from '@angular/core';
- * import { App, ViewController } from 'ionic-angular';
- *
- * @Component({
- * template: `
- * <ion-content>
- * <h1>My PopoverPage</h1>
- * <button ion-button (click)="pushPage()">Call pushPage</button>
- * </ion-content>
- * `
- * })
- * class PopoverPage {
- * constructor(
- * public viewCtrl: ViewController
- * public appCtrl: App
- * ) {}
- *
- * pushPage() {
- * this.viewCtrl.dismiss();
- * this.appCtrl.getRootNav().push(SecondPage);
- * }
- * }
- *```
- *
- *
- * ## View creation
- * Views are created when they are added to the navigation stack. For methods
- * like [push()](#push), the NavController takes any component class that is
- * decorated with `@Component` as its first argument. The NavController then
- * compiles that component, adds it to the app and animates it into view.
- *
- * By default, pages are cached and left in the DOM if they are navigated away
- * from but still in the navigation stack (the exiting page on a `push()` for
- * example). They are destroyed when removed from the navigation stack (on
- * [pop()](#pop) or [setRoot()](#setRoot)).
- *
- * ## Pushing a View
- * To push a new view onto the navigation stack, use the `push` method.
- * If the page has an [`<ion-navbar>`](../../navbar/Navbar/),
- * a back button will automatically be added to the pushed view.
- *
- * Data can also be passed to a view by passing an object to the `push` method.
- * The pushed view can then receive the data by accessing it via the `NavParams`
- * class.
- *
- * ```typescript
- * import { Component } from '@angular/core';
- * import { NavController } from 'ionic-angular';
- * import { OtherPage } from './other-page';
- * @Component({
- * template: `
- * <ion-header>
- * <ion-navbar>
- * <ion-title>Login</ion-title>
- * </ion-navbar>
- * </ion-header>
- *
- * <ion-content>
- * <button ion-button (click)="pushPage()">
- * Go to OtherPage
- * </button>
- * </ion-content>
- * `
- * })
- * export class StartPage {
- * constructor(public navCtrl: NavController) {
- * }
- *
- * pushPage(){
- * // push another page onto the navigation stack
- * // causing the nav controller to transition to the new page
- * // optional data can also be passed to the pushed page.
- * this.navCtrl.push(OtherPage, {
- * id: "123",
- * name: "Carl"
- * });
- * }
- * }
- *
- * import { NavParams } from 'ionic-angular';
- *
- * @Component({
- * template: `
- * <ion-header>
- * <ion-navbar>
- * <ion-title>Other Page</ion-title>
- * </ion-navbar>
- * </ion-header>
- * <ion-content>I'm the other page!</ion-content>`
- * })
- * class OtherPage {
- * constructor(private navParams: NavParams) {
- * let id = navParams.get('id');
- * let name = navParams.get('name');
- * }
- * }
- * ```
- *
- * ## Removing a view
- * To remove a view from the stack, use the `pop` method.
- * Popping a view will transition to the previous view.
- *
- * ```ts
- * import { Component } from '@angular/core';
- * import { NavController } from 'ionic-angular';
- *
- * @Component({
- * template: `
- * <ion-header>
- * <ion-navbar>
- * <ion-title>Other Page</ion-title>
- * </ion-navbar>
- * </ion-header>
- * <ion-content>I'm the other page!</ion-content>`
- * })
- * class OtherPage {
- * constructor(public navCtrl: NavController ){
- * }
- *
- * popView(){
- * this.navCtrl.pop();
- * }
- * }
- * ```
- *
- * ## Lifecycle events
- * Lifecycle events are fired during various stages of navigation. They can be
- * defined in any component type which is pushed/popped from a `NavController`.
- *
- * ```ts
- * import { Component } from '@angular/core';
- *
- * @Component({
- * template: 'Hello World'
- * })
- * class HelloWorld {
- * ionViewDidLoad() {
- * console.log("I'm alive!");
- * }
- * ionViewWillLeave() {
- * console.log("Looks like I'm about to leave :(");
- * }
- * }
- * ```
- *
- * | Page Event | Returns | Description |
- * |---------------------|-----------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
- * | `ionViewDidLoad` | void | Runs when the page has loaded. This event only happens once per page being created. If a page leaves but is cached, then this event will not fire again on a subsequent viewing. The `ionViewDidLoad` event is good place to put your setup code for the page. |
- * | `ionViewWillEnter` | void | Runs when the page is about to enter and become the active page. |
- * | `ionViewDidEnter` | void | Runs when the page has fully entered and is now the active page. This event will fire, whether it was the first load or a cached page. |
- * | `ionViewWillLeave` | void | Runs when the page is about to leave and no longer be the active page. |
- * | `ionViewDidLeave` | void | Runs when the page has finished leaving and is no longer the active page. |
- * | `ionViewWillUnload` | void | Runs when the page is about to be destroyed and have its elements removed. |
- * | `ionViewCanEnter` | boolean/Promise<void> | Runs before the view can enter. This can be used as a sort of "guard" in authenticated views where you need to check permissions before the view can enter |
- * | `ionViewCanLeave` | boolean/Promise<void> | Runs before the view can leave. This can be used as a sort of "guard" in authenticated views where you need to check permissions before the view can leave |
- *
- *
- * ## Nav Guards
- *
- * In some cases, a developer should be able to control views leaving and entering. To allow for this, NavController has the `ionViewCanEnter` and `ionViewCanLeave` methods.
- * Similar to Angular route guards, but are more integrated with NavController. For example, if you wanted to prevent a user from leaving a view:
- *
- * ```ts
- * export class MyClass{
- * constructor(
- * public navCtrl: NavController
- * ){}
- *
- * pushPage(){
- * this.navCtrl.push(DetailPage);
- * }
- *
- * ionViewCanLeave(): boolean{
- * // here we can either return true or false
- * // depending on if we want to leave this view
- * if(isValid(randomValue)){
- * return true;
- * } else {
- * return false;
- * }
- * }
- * }
- * ```
- *
- * We need to make sure that our `navCtrl.push` has a catch in order to catch the and handle the error.
- * If you need to prevent a view from entering, you can do the same thing
- *
- * ```ts
- * export class MyClass{
- * constructor(
- * public navCtrl: NavController
- * ){}
- *
- * pushPage(){
- * this.navCtrl.push(DetailPage);
- * }
- *
- * }
- *
- * export class DetailPage(){
- * constructor(
- * public navCtrl: NavController
- * ){}
- * ionViewCanEnter(): boolean{
- * // here we can either return true or false
- * // depending on if we want to enter this view
- * if(isValid(randomValue)){
- * return true;
- * } else {
- * return false;
- * }
- * }
- * }
- * ```
- *
- * Similar to `ionViewCanLeave` we still need a catch on the original `navCtrl.push` in order to handle it properly.
- * When handling the back button in the `ion-navbar`, the catch is already taken care of for you by the framework.
- *
- * ## NavOptions
- *
- * Some methods on `NavController` allow for customizing the current transition.
- * To do this, we can pass an object with the modified properites.
- *
- *
- * | Property | Value | Description |
- * |-----------|-----------|------------------------------------------------------------------------------------------------------------|
- * | animate | `boolean` | Whether or not the transition should animate. |
- * | animation | `string` | What kind of animation should be used. |
- * | direction | `string` | The conceptual direction the user is navigating. For example, is the user navigating `forward`, or `back`? |
- * | duration | `number` | The length in milliseconds the animation should take. |
- * | easing | `string` | The easing for the animation. |
- *
- * The property 'animation' understands the following values: `md-transition`, `ios-transition` and `wp-transition`.
- *
- * @see {@link /docs/components#navigation Navigation Component Docs}
- */
- var NavController = (function () {
- function NavController() {
- }
- return NavController;
- }());
-
- var PanRecognizer = (function () {
- function PanRecognizer(direction, threshold, maxAngle) {
- this.direction = direction;
- this.dirty = false;
- this._angle = 0;
- this._isPan = 0;
- var radians = maxAngle * (Math.PI / 180);
- this.maxCosine = Math.cos(radians);
- this.threshold = threshold * threshold;
- }
- PanRecognizer.prototype.start = function (coord) {
- this.startCoord = coord;
- this._angle = 0;
- this._isPan = 0;
- this.dirty = true;
- };
- PanRecognizer.prototype.detect = function (coord) {
- if (!this.dirty) {
- return false;
- }
- var deltaX = (coord.x - this.startCoord.x);
- var deltaY = (coord.y - this.startCoord.y);
- var distance = deltaX * deltaX + deltaY * deltaY;
- if (distance >= this.threshold) {
- var angle = Math.atan2(deltaY, deltaX);
- var cosine = (this.direction === 'y')
- ? Math.sin(angle)
- : Math.cos(angle);
- this._angle = angle;
- if (cosine > this.maxCosine) {
- this._isPan = 1;
- }
- else if (cosine < -this.maxCosine) {
- this._isPan = -1;
- }
- else {
- this._isPan = 0;
- }
- this.dirty = false;
- return true;
- }
- return false;
- };
- PanRecognizer.prototype.angle = function () {
- return this._angle;
- };
- PanRecognizer.prototype.pan = function () {
- return this._isPan;
- };
- return PanRecognizer;
- }());
-
- /**
- * @hidden
- */
- var PointerEvents = (function () {
- function PointerEvents(plt, ele, pointerDown, pointerMove, pointerUp, option) {
- this.plt = plt;
- this.ele = ele;
- this.pointerDown = pointerDown;
- this.pointerMove = pointerMove;
- this.pointerUp = pointerUp;
- this.option = option;
- this.rmTouchStart = null;
- this.rmTouchMove = null;
- this.rmTouchEnd = null;
- this.rmTouchCancel = null;
- this.rmMouseStart = null;
- this.rmMouseMove = null;
- this.rmMouseUp = null;
- this.lastTouchEvent = 0;
- this.mouseWait = 2 * 1000;
- (void 0) /* assert */;
- (void 0) /* assert */;
- this.bindTouchEnd = this.handleTouchEnd.bind(this);
- this.bindMouseUp = this.handleMouseUp.bind(this);
- this.rmTouchStart = this.plt.registerListener(ele, 'touchstart', this.handleTouchStart.bind(this), option);
- this.rmMouseStart = this.plt.registerListener(ele, 'mousedown', this.handleMouseDown.bind(this), option);
- }
- PointerEvents.prototype.handleTouchStart = function (ev) {
- (void 0) /* assert */;
- (void 0) /* assert */;
- this.lastTouchEvent = Date.now() + this.mouseWait;
- this.lastEventType = POINTER_EVENT_TYPE_TOUCH;
- if (!this.pointerDown(ev, POINTER_EVENT_TYPE_TOUCH)) {
- return;
- }
- if (!this.rmTouchMove && this.pointerMove) {
- this.rmTouchMove = this.plt.registerListener(this.ele, 'touchmove', this.pointerMove, this.option);
- }
- if (!this.rmTouchEnd) {
- this.rmTouchEnd = this.plt.registerListener(this.ele, 'touchend', this.bindTouchEnd, this.option);
- }
- if (!this.rmTouchCancel) {
- this.rmTouchCancel = this.plt.registerListener(this.ele, 'touchcancel', this.bindTouchEnd, this.option);
- }
- };
- PointerEvents.prototype.handleMouseDown = function (ev) {
- (void 0) /* assert */;
- (void 0) /* assert */;
- if (this.lastTouchEvent > Date.now()) {
- (void 0) /* console.debug */;
- return;
- }
- this.lastEventType = POINTER_EVENT_TYPE_MOUSE;
- if (!this.pointerDown(ev, POINTER_EVENT_TYPE_MOUSE)) {
- return;
- }
- if (!this.rmMouseMove && this.pointerMove) {
- this.rmMouseMove = this.plt.registerListener(this.plt.doc(), 'mousemove', this.pointerMove, this.option);
- }
- if (!this.rmMouseUp) {
- this.rmMouseUp = this.plt.registerListener(this.plt.doc(), 'mouseup', this.bindMouseUp, this.option);
- }
- };
- PointerEvents.prototype.handleTouchEnd = function (ev) {
- this.stopTouch();
- this.pointerUp && this.pointerUp(ev, POINTER_EVENT_TYPE_TOUCH);
- };
- PointerEvents.prototype.handleMouseUp = function (ev) {
- this.stopMouse();
- this.pointerUp && this.pointerUp(ev, POINTER_EVENT_TYPE_MOUSE);
- };
- PointerEvents.prototype.stopTouch = function () {
- this.rmTouchMove && this.rmTouchMove();
- this.rmTouchEnd && this.rmTouchEnd();
- this.rmTouchCancel && this.rmTouchCancel();
- this.rmTouchMove = this.rmTouchEnd = this.rmTouchCancel = null;
- };
- PointerEvents.prototype.stopMouse = function () {
- this.rmMouseMove && this.rmMouseMove();
- this.rmMouseUp && this.rmMouseUp();
- this.rmMouseMove = this.rmMouseUp = null;
- };
- PointerEvents.prototype.stop = function () {
- this.stopTouch();
- this.stopMouse();
- };
- PointerEvents.prototype.destroy = function () {
- this.rmTouchStart && this.rmTouchStart();
- this.rmMouseStart && this.rmMouseStart();
- this.stop();
- this.ele = this.pointerUp = this.pointerMove = this.pointerDown = this.rmTouchStart = this.rmMouseStart = null;
- };
- return PointerEvents;
- }());
- var POINTER_EVENT_TYPE_MOUSE = 1;
- var POINTER_EVENT_TYPE_TOUCH = 2;
-
- /**
- * @hidden
- */
- var UIEventManager = (function () {
- function UIEventManager(plt) {
- this.plt = plt;
- this.evts = [];
- }
- UIEventManager.prototype.pointerEvents = function (config) {
- if (!config.element || !config.pointerDown) {
- console.error('PointerEvents config is invalid');
- return;
- }
- var eventListnerOpts = {
- capture: config.capture,
- passive: config.passive,
- zone: config.zone
- };
- var pointerEvents = new PointerEvents(this.plt, config.element, config.pointerDown, config.pointerMove, config.pointerUp, eventListnerOpts);
- var removeFunc = function () { return pointerEvents.destroy(); };
- this.evts.push(removeFunc);
- return pointerEvents;
- };
- UIEventManager.prototype.listen = function (ele, eventName, callback, opts) {
- if (ele) {
- var removeFunc = this.plt.registerListener(ele, eventName, callback, opts);
- this.evts.push(removeFunc);
- return removeFunc;
- }
- };
- UIEventManager.prototype.unlistenAll = function () {
- this.evts.forEach(function (unRegEvent) {
- unRegEvent();
- });
- this.evts.length = 0;
- };
- UIEventManager.prototype.destroy = function () {
- this.unlistenAll();
- this.evts = null;
- };
- return UIEventManager;
- }());
-
- /**
- * @hidden
- */
- var PanGesture = (function () {
- function PanGesture(plt, element, opts) {
- if (opts === void 0) { opts = {}; }
- this.plt = plt;
- this.element = element;
- defaults(opts, {
- threshold: 20,
- maxAngle: 40,
- direction: 'x',
- zone: true,
- capture: false,
- passive: false,
- });
- this.events = new UIEventManager(plt);
- if (opts.domController) {
- this.debouncer = opts.domController.debouncer();
- }
- this.gestute = opts.gesture;
- this.direction = opts.direction;
- this.eventsConfig = {
- element: this.element,
- pointerDown: this.pointerDown.bind(this),
- pointerMove: this.pointerMove.bind(this),
- pointerUp: this.pointerUp.bind(this),
- zone: opts.zone,
- capture: opts.capture,
- passive: opts.passive
- };
- if (opts.threshold > 0) {
- this.detector = new PanRecognizer(opts.direction, opts.threshold, opts.maxAngle);
- }
- }
- PanGesture.prototype.listen = function () {
- if (!this.isListening) {
- this.pointerEvents = this.events.pointerEvents(this.eventsConfig);
- this.isListening = true;
- }
- };
- PanGesture.prototype.unlisten = function () {
- if (this.isListening) {
- this.gestute && this.gestute.release();
- this.events.unlistenAll();
- this.isListening = false;
- }
- };
- PanGesture.prototype.destroy = function () {
- this.gestute && this.gestute.destroy();
- this.gestute = null;
- this.unlisten();
- this.events.destroy();
- this.events = this.element = this.gestute = null;
- };
- PanGesture.prototype.pointerDown = function (ev) {
- if (this.started) {
- return;
- }
- if (!this.canStart(ev)) {
- return false;
- }
- if (this.gestute) {
- // Release fallback
- this.gestute.release();
- // Start gesture
- if (!this.gestute.start()) {
- return false;
- }
- }
- this.started = true;
- this.captured = false;
- var coord = pointerCoord(ev);
- if (this.detector) {
- this.detector.start(coord);
- }
- else {
- if (!this.tryToCapture(ev)) {
- this.started = false;
- this.captured = false;
- this.gestute.release();
- return false;
- }
- }
- return true;
- };
- PanGesture.prototype.pointerMove = function (ev) {
- var _this = this;
- (void 0) /* assert */;
- if (this.captured) {
- this.debouncer.write(function () {
- _this.onDragMove(ev);
- });
- return;
- }
- (void 0) /* assert */;
- var coord = pointerCoord(ev);
- if (this.detector.detect(coord)) {
- if (this.detector.pan() !== 0) {
- if (!this.tryToCapture(ev)) {
- this.abort(ev);
- }
- }
- }
- };
- PanGesture.prototype.pointerUp = function (ev) {
- (void 0) /* assert */;
- this.debouncer.cancel();
- this.gestute && this.gestute.release();
- if (this.captured) {
- this.onDragEnd(ev);
- }
- else {
- this.notCaptured(ev);
- }
- this.captured = false;
- this.started = false;
- };
- PanGesture.prototype.tryToCapture = function (ev) {
- (void 0) /* assert */;
- (void 0) /* assert */;
- if (this.gestute && !this.gestute.capture()) {
- return false;
- }
- this.onDragStart(ev);
- this.captured = true;
- return true;
- };
- PanGesture.prototype.abort = function (ev) {
- this.started = false;
- this.captured = false;
- this.gestute.release();
- this.pointerEvents.stop();
- this.notCaptured(ev);
- };
- PanGesture.prototype.getNativeElement = function () {
- return this.element;
- };
- // Implemented in a subclass
- PanGesture.prototype.canStart = function (_ev) { return true; };
- PanGesture.prototype.onDragStart = function (_ev) { };
- PanGesture.prototype.onDragMove = function (_ev) { };
- PanGesture.prototype.onDragEnd = function (_ev) { };
- PanGesture.prototype.notCaptured = function (_ev) { };
- return PanGesture;
- }());
-
- var __extends$23 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @hidden
- */
- var SlideGesture = (function (_super) {
- __extends$23(SlideGesture, _super);
- function SlideGesture(plt, element, opts) {
- if (opts === void 0) { opts = {}; }
- var _this = _super.call(this, plt, element, opts) || this;
- _this.slide = null;
- return _this;
- }
- /*
- * Get the min and max for the slide. pageX/pageY.
- * Only called on dragstart.
- */
- SlideGesture.prototype.getSlideBoundaries = function (_slide, _ev) {
- return {
- min: 0,
- max: this.getNativeElement().offsetWidth
- };
- };
- /*
- * Get the element's pos when the drag starts.
- * For example, an open side menu starts at 100% and a closed
- * sidemenu starts at 0%.
- */
- SlideGesture.prototype.getElementStartPos = function (_slide, _ev) {
- return 0;
- };
- SlideGesture.prototype.onDragStart = function (ev) {
- this.onSlideBeforeStart(ev);
- var coord = pointerCoord(ev);
- var pos = coord[this.direction];
- this.slide = {
- min: 0,
- max: 0,
- pointerStartPos: pos,
- pos: pos,
- timestamp: Date.now(),
- elementStartPos: 0,
- started: true,
- delta: 0,
- distance: 0,
- velocity: 0,
- };
- // TODO: we should run this in the next frame
- var _a = this.getSlideBoundaries(this.slide, ev), min = _a.min, max = _a.max;
- this.slide.min = min;
- this.slide.max = max;
- this.slide.elementStartPos = this.getElementStartPos(this.slide, ev);
- this.onSlideStart(this.slide, ev);
- };
- SlideGesture.prototype.onDragMove = function (ev) {
- var slide = this.slide;
- (void 0) /* assert */;
- var coord = pointerCoord(ev);
- var newPos = coord[this.direction];
- var newTimestamp = Date.now();
- var velocity = (this.plt.isRTL ? (slide.pos - newPos) : (newPos - slide.pos)) / (newTimestamp - slide.timestamp);
- slide.pos = newPos;
- slide.timestamp = newTimestamp;
- slide.distance = clamp(slide.min, (this.plt.isRTL ? slide.pointerStartPos - newPos : newPos - slide.pointerStartPos) + slide.elementStartPos, slide.max);
- slide.velocity = velocity;
- slide.delta = (this.plt.isRTL ? slide.pointerStartPos - newPos : newPos - slide.pointerStartPos);
- this.onSlide(slide, ev);
- };
- SlideGesture.prototype.onDragEnd = function (ev) {
- this.onSlideEnd(this.slide, ev);
- this.slide = null;
- };
- SlideGesture.prototype.onSlideBeforeStart = function (_ev) { };
- SlideGesture.prototype.onSlideStart = function (_slide, _ev) { };
- SlideGesture.prototype.onSlide = function (_slide, _ev) { };
- SlideGesture.prototype.onSlideEnd = function (_slide, _ev) { };
- return SlideGesture;
- }(PanGesture));
-
- var __extends$22 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @hidden
- */
- var SlideEdgeGesture = (function (_super) {
- __extends$22(SlideEdgeGesture, _super);
- function SlideEdgeGesture(plt, element, opts) {
- if (opts === void 0) { opts = {}; }
- var _this = this;
- defaults(opts, {
- edge: 'start',
- maxEdgeStart: 50
- });
- _this = _super.call(this, plt, element, opts) || this;
- // Can check corners through use of eg 'left top'
- _this.setEdges(opts.edge);
- _this.maxEdgeStart = opts.maxEdgeStart;
- return _this;
- }
- SlideEdgeGesture.prototype.setEdges = function (edges) {
- var isRTL = this.plt.isRTL;
- this.edges = edges.split(' ').map(function (value) {
- switch (value) {
- case 'start': return isRTL ? 'right' : 'left';
- case 'end': return isRTL ? 'left' : 'right';
- default: return value;
- }
- });
- };
- SlideEdgeGesture.prototype.canStart = function (ev) {
- var _this = this;
- var coord = pointerCoord(ev);
- this._d = this.getContainerDimensions();
- return this.edges.every(function (edge) { return _this._checkEdge(edge, coord); });
- };
- SlideEdgeGesture.prototype.getContainerDimensions = function () {
- var plt = this.plt;
- return {
- left: 0,
- top: 0,
- width: plt.width(),
- height: plt.height()
- };
- };
- SlideEdgeGesture.prototype._checkEdge = function (edge, pos) {
- var data = this._d;
- var maxEdgeStart = this.maxEdgeStart;
- switch (edge) {
- case 'left': return pos.x <= data.left + maxEdgeStart;
- case 'right': return pos.x >= data.width - maxEdgeStart;
- case 'top': return pos.y <= data.top + maxEdgeStart;
- case 'bottom': return pos.y >= data.height - maxEdgeStart;
- }
- return false;
- };
- return SlideEdgeGesture;
- }(SlideGesture));
-
- var __extends$21 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @hidden
- */
- var SwipeBackGesture = (function (_super) {
- __extends$21(SwipeBackGesture, _super);
- function SwipeBackGesture(plt, _nav, gestureCtlr, domCtrl) {
- var _this = _super.call(this, plt, plt.doc().body, {
- direction: 'x',
- edge: 'start',
- maxEdgeStart: 75,
- threshold: 5,
- zone: false,
- domController: domCtrl,
- gesture: gestureCtlr.createGesture({
- name: GESTURE_GO_BACK_SWIPE,
- priority: GESTURE_PRIORITY_GO_BACK_SWIPE,
- disableScroll: true
- })
- }) || this;
- _this._nav = _nav;
- return _this;
- }
- SwipeBackGesture.prototype.canStart = function (ev) {
- // the gesture swipe angle must be mainly horizontal and the
- // gesture distance would be relatively short for a swipe back
- // and swipe back must be possible on this nav controller
- return (this._nav.canSwipeBack() &&
- _super.prototype.canStart.call(this, ev));
- };
- SwipeBackGesture.prototype.onSlideBeforeStart = function (_ev) {
- this._nav.swipeBackStart();
- };
- SwipeBackGesture.prototype.onSlide = function (slide, ev) {
- ev.preventDefault();
- ev.stopPropagation();
- var stepValue = (slide.distance / slide.max);
- this._nav.swipeBackProgress(stepValue);
- };
- SwipeBackGesture.prototype.onSlideEnd = function (slide, _ev) {
- var velocity = slide.velocity;
- var currentStepValue = (slide.distance / slide.max);
- var isResetDirecction = velocity < 0;
- var isMovingFast = Math.abs(slide.velocity) > 0.4;
- var isInResetZone = Math.abs(slide.delta) < Math.abs(slide.max) * 0.5;
- var shouldComplete = !swipeShouldReset(isResetDirecction, isMovingFast, isInResetZone);
- this._nav.swipeBackEnd(shouldComplete, currentStepValue, velocity);
- };
- return SwipeBackGesture;
- }(SlideEdgeGesture));
-
- var __extends$20 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @hidden
- * This class is for internal use only. It is not exported publicly.
- */
- var NavControllerBase = (function (_super) {
- __extends$20(NavControllerBase, _super);
- function NavControllerBase(parent, _app, config, plt, elementRef, _zone, renderer, _cfr, _gestureCtrl, _trnsCtrl, _linker, _domCtrl, _errHandler) {
- var _this = _super.call(this, config, elementRef, renderer) || this;
- _this.parent = parent;
- _this._app = _app;
- _this.config = config;
- _this.plt = plt;
- _this._zone = _zone;
- _this._cfr = _cfr;
- _this._gestureCtrl = _gestureCtrl;
- _this._trnsCtrl = _trnsCtrl;
- _this._linker = _linker;
- _this._domCtrl = _domCtrl;
- _this._errHandler = _errHandler;
- _this._ids = -1;
- _this._init = false;
- _this._queue = [];
- _this._trnsId = null;
- _this._trnsTm = false;
- _this._views = [];
- _this._zIndexOffset = 0;
- _this.viewDidLoad = new EventEmitter();
- _this.viewWillEnter = new EventEmitter();
- _this.viewDidEnter = new EventEmitter();
- _this.viewWillLeave = new EventEmitter();
- _this.viewDidLeave = new EventEmitter();
- _this.viewWillUnload = new EventEmitter();
- _this._sbEnabled = config.getBoolean('swipeBackEnabled');
- _this._children = [];
- _this.id = 'n' + (++ctrlIds);
- _this._destroyed = false;
- return _this;
- }
- Object.defineProperty(NavControllerBase.prototype, "swipeBackEnabled", {
- get: function () {
- return this._sbEnabled;
- },
- set: function (val) {
- this._sbEnabled = isTrueProperty(val);
- this._swipeBackCheck();
- },
- enumerable: true,
- configurable: true
- });
- NavControllerBase.prototype.push = function (page, params, opts, done) {
- return this._queueTrns({
- insertStart: -1,
- insertViews: [{ page: page, params: params }],
- opts: opts,
- }, done);
- };
- NavControllerBase.prototype.insert = function (insertIndex, page, params, opts, done) {
- return this._queueTrns({
- insertStart: insertIndex,
- insertViews: [{ page: page, params: params }],
- opts: opts,
- }, done);
- };
- NavControllerBase.prototype.insertPages = function (insertIndex, insertPages, opts, done) {
- return this._queueTrns({
- insertStart: insertIndex,
- insertViews: insertPages,
- opts: opts,
- }, done);
- };
- NavControllerBase.prototype.pop = function (opts, done) {
- return this._queueTrns({
- removeStart: -1,
- removeCount: 1,
- opts: opts,
- }, done);
- };
- NavControllerBase.prototype.popTo = function (indexOrViewCtrl, opts, done) {
- var config = {
- removeStart: -1,
- removeCount: -1,
- opts: opts
- };
- if (isViewController(indexOrViewCtrl)) {
- config.removeView = indexOrViewCtrl;
- config.removeStart = 1;
- }
- else if (isNumber(indexOrViewCtrl)) {
- config.removeStart = indexOrViewCtrl + 1;
- }
- return this._queueTrns(config, done);
- };
- NavControllerBase.prototype.popToRoot = function (opts, done) {
- return this._queueTrns({
- removeStart: 1,
- removeCount: -1,
- opts: opts,
- }, done);
- };
- NavControllerBase.prototype.popAll = function () {
- var promises = [];
- for (var i = this._views.length - 1; i >= 0; i--) {
- promises.push(this.pop(null));
- }
- return Promise.all(promises);
- };
- NavControllerBase.prototype.remove = function (startIndex, removeCount, opts, done) {
- if (removeCount === void 0) { removeCount = 1; }
- return this._queueTrns({
- removeStart: startIndex,
- removeCount: removeCount,
- opts: opts,
- }, done);
- };
- NavControllerBase.prototype.removeView = function (viewController, opts, done) {
- return this._queueTrns({
- removeView: viewController,
- removeStart: 0,
- removeCount: 1,
- opts: opts,
- }, done);
- };
- NavControllerBase.prototype.setRoot = function (pageOrViewCtrl, params, opts, done) {
- return this.setPages([{ page: pageOrViewCtrl, params: params }], opts, done);
- };
- NavControllerBase.prototype.setPages = function (viewControllers, opts, done) {
- if (isBlank$1(opts)) {
- opts = {};
- }
- // if animation wasn't set to true then default it to NOT animate
- if (opts.animate !== true) {
- opts.animate = false;
- }
- return this._queueTrns({
- insertStart: 0,
- insertViews: viewControllers,
- removeStart: 0,
- removeCount: -1,
- opts: opts
- }, done);
- };
- // _queueTrns() adds a navigation stack change to the queue and schedules it to run:
- // 1. _nextTrns(): consumes the next transition in the queue
- // 2. _viewInit(): initializes enteringView if required
- // 3. _viewTest(): ensures canLeave/canEnter returns true, so the operation can continue
- // 4. _postViewInit(): add/remove the views from the navigation stack
- // 5. _transitionInit(): initializes the visual transition if required and schedules it to run
- // 6. _viewAttachToDOM(): attaches the enteringView to the DOM
- // 7. _transitionStart(): called once the transition actually starts, it initializes the Animation underneath.
- // 8. _transitionFinish(): called once the transition finishes
- // 9. _cleanup(): syncs the navigation internal state with the DOM. For example it removes the pages from the DOM or hides/show them.
- NavControllerBase.prototype._queueTrns = function (ti, done) {
- var promise = new Promise(function (resolve, reject) {
- ti.resolve = resolve;
- ti.reject = reject;
- });
- ti.done = done;
- // Normalize empty
- if (ti.insertViews && ti.insertViews.length === 0) {
- ti.insertViews = undefined;
- }
- // Enqueue transition instruction
- this._queue.push(ti);
- // if there isn't a transition already happening
- // then this will kick off this transition
- this._nextTrns();
- return promise;
- };
- NavControllerBase.prototype._success = function (result, ti) {
- if (this._queue === null) {
- this._fireError('nav controller was destroyed', ti);
- return;
- }
- this._init = true;
- this._trnsId = null;
- // ensure we're not transitioning here
- this.setTransitioning(false);
- this._swipeBackCheck();
- // let's see if there's another to kick off
- this._nextTrns();
- if (ti.done) {
- ti.done(result.hasCompleted, result.requiresTransition, result.enteringName, result.leavingName, result.direction);
- }
- ti.resolve(result.hasCompleted);
- };
- NavControllerBase.prototype._failed = function (rejectReason, ti) {
- if (this._queue === null) {
- this._fireError('nav controller was destroyed', ti);
- return;
- }
- this._trnsId = null;
- this._queue.length = 0;
- // let's see if there's another to kick off
- this.setTransitioning(false);
- this._swipeBackCheck();
- this._nextTrns();
- this._fireError(rejectReason, ti);
- };
- NavControllerBase.prototype._fireError = function (rejectReason, ti) {
- if (ti.done) {
- ti.done(false, false, rejectReason);
- }
- if (ti.reject && !this._destroyed) {
- ti.reject(rejectReason);
- }
- else {
- ti.resolve(false);
- }
- };
- NavControllerBase.prototype._nextTrns = function () {
- var _this = this;
- // this is the framework's bread 'n butta function
- // only one transition is allowed at any given time
- if (this.isTransitioning()) {
- return false;
- }
- // there is no transition happening right now
- // get the next instruction
- var ti = this._queue.shift();
- if (!ti) {
- return false;
- }
- // set that this nav is actively transitioning
- var enteringView;
- var leavingView;
- this._startTI(ti)
- .then(function () { return _this._loadLazyLoading(ti); })
- .then(function () {
- leavingView = _this.getActive();
- enteringView = _this._getEnteringView(ti, leavingView);
- if (!leavingView && !enteringView) {
- throw 'no views in the stack to be removed';
- }
- if (enteringView && enteringView._state === STATE_NEW) {
- _this._viewInit(enteringView);
- }
- // Needs transition?
- ti.requiresTransition = (ti.enteringRequiresTransition || ti.leavingRequiresTransition) && enteringView !== leavingView;
- })
- .then(function () { return _this._viewTest(enteringView, leavingView, ti); })
- .then(function () { return _this._postViewInit(enteringView, leavingView, ti); })
- .then(function () { return _this._transition(enteringView, leavingView, ti); })
- .then(function (result) { return _this._success(result, ti); })
- .catch(function (rejectReason) { return _this._failed(rejectReason, ti); });
- return true;
- };
- NavControllerBase.prototype._startTI = function (ti) {
- var viewsLength = this._views.length;
- if (isPresent(ti.removeView)) {
- (void 0) /* assert */;
- (void 0) /* assert */;
- var index = this.indexOf(ti.removeView);
- if (index < 0) {
- return Promise.reject('removeView was not found');
- }
- ti.removeStart += index;
- }
- if (isPresent(ti.removeStart)) {
- if (ti.removeStart < 0) {
- ti.removeStart = (viewsLength - 1);
- }
- if (ti.removeCount < 0) {
- ti.removeCount = (viewsLength - ti.removeStart);
- }
- ti.leavingRequiresTransition = (ti.removeCount > 0) && ((ti.removeStart + ti.removeCount) === viewsLength);
- }
- if (ti.insertViews) {
- // allow -1 to be passed in to auto push it on the end
- // and clean up the index if it's larger then the size of the stack
- if (ti.insertStart < 0 || ti.insertStart > viewsLength) {
- ti.insertStart = viewsLength;
- }
- ti.enteringRequiresTransition = (ti.insertStart === viewsLength);
- }
- this.setTransitioning(true);
- return Promise.resolve();
- };
- NavControllerBase.prototype._loadLazyLoading = function (ti) {
- var _this = this;
- var insertViews = ti.insertViews;
- if (insertViews) {
- (void 0) /* assert */;
- return convertToViews(this._linker, insertViews).then(function (viewControllers) {
- (void 0) /* assert */;
- viewControllers = viewControllers.filter(function (v) { return v !== null; });
- if (viewControllers.length === 0) {
- throw 'invalid views to insert';
- }
- // Check all the inserted view are correct
- for (var i = 0; i < viewControllers.length; i++) {
- var view = viewControllers[i];
- var nav = view._nav;
- if (nav && nav !== _this) {
- throw 'inserted view was already inserted';
- }
- if (view._state === STATE_DESTROYED) {
- throw 'inserted view was already destroyed';
- }
- }
- ti.insertViews = viewControllers;
- });
- }
- return Promise.resolve();
- };
- NavControllerBase.prototype._getEnteringView = function (ti, leavingView) {
- var insertViews = ti.insertViews;
- if (insertViews) {
- // grab the very last view of the views to be inserted
- // and initialize it as the new entering view
- return insertViews[insertViews.length - 1];
- }
- var removeStart = ti.removeStart;
- if (isPresent(removeStart)) {
- var views = this._views;
- var removeEnd = removeStart + ti.removeCount;
- var i;
- var view;
- for (i = views.length - 1; i >= 0; i--) {
- view = views[i];
- if ((i < removeStart || i >= removeEnd) && view !== leavingView) {
- return view;
- }
- }
- }
- return null;
- };
- NavControllerBase.prototype._postViewInit = function (enteringView, leavingView, ti) {
- var _this = this;
- (void 0) /* assert */;
- (void 0) /* assert */;
- (void 0) /* assert */;
- var opts = ti.opts || {};
- var insertViews = ti.insertViews;
- var removeStart = ti.removeStart;
- var removeCount = ti.removeCount;
- var view;
- var i;
- var destroyQueue;
- // there are views to remove
- if (isPresent(removeStart)) {
- (void 0) /* assert */;
- (void 0) /* assert */;
- destroyQueue = [];
- for (i = 0; i < removeCount; i++) {
- view = this._views[i + removeStart];
- if (view && view !== enteringView && view !== leavingView) {
- destroyQueue.push(view);
- }
- }
- // default the direction to "back"
- opts.direction = opts.direction || DIRECTION_BACK;
- }
- var finalBalance = this._views.length + (insertViews ? insertViews.length : 0) - (removeCount ? removeCount : 0);
- (void 0) /* assert */;
- if (finalBalance === 0 && !this._isPortal) {
- console.warn("You can't remove all the pages in the navigation stack. nav.pop() is probably called too many times.", this, this.getNativeElement());
- throw 'navigation stack needs at least one root page';
- }
- // At this point the transition can not be rejected, any throw should be an error
- // there are views to insert
- if (insertViews) {
- // manually set the new view's id if an id was passed in the options
- if (isPresent(opts.id)) {
- enteringView.id = opts.id;
- }
- // add the views to the
- for (i = 0; i < insertViews.length; i++) {
- view = insertViews[i];
- this._insertViewAt(view, ti.insertStart + i);
- }
- if (ti.enteringRequiresTransition) {
- // default to forward if not already set
- opts.direction = opts.direction || DIRECTION_FORWARD;
- }
- }
- // if the views to be removed are in the beginning or middle
- // and there is not a view that needs to visually transition out
- // then just destroy them and don't transition anything
- // batch all of lifecycles together
- // let's make sure, callbacks are zoned
- if (destroyQueue && destroyQueue.length > 0) {
- this._zone.run(function () {
- for (i = 0; i < destroyQueue.length; i++) {
- view = destroyQueue[i];
- _this._willLeave(view, true);
- _this._didLeave(view);
- _this._willUnload(view);
- }
- });
- // once all lifecycle events has been delivered, we can safely detroy the views
- for (i = 0; i < destroyQueue.length; i++) {
- this._destroyView(destroyQueue[i]);
- }
- }
- // set which animation it should use if it wasn't set yet
- if (ti.requiresTransition && !opts.animation) {
- if (isPresent(ti.removeStart)) {
- opts.animation = (leavingView || enteringView).getTransitionName(opts.direction);
- }
- else {
- opts.animation = (enteringView || leavingView).getTransitionName(opts.direction);
- }
- }
- ti.opts = opts;
- };
- /**
- * DOM WRITE
- */
- NavControllerBase.prototype._viewInit = function (enteringView) {
- (void 0) /* assert */;
- (void 0) /* assert */;
- // render the entering view, and all child navs and views
- // entering view has not been initialized yet
- var componentProviders = ReflectiveInjector.resolve([
- { provide: NavController, useValue: this },
- { provide: ViewController, useValue: enteringView },
- { provide: NavParams, useValue: enteringView.getNavParams() }
- ]);
- var componentFactory = this._linker.resolveComponent(enteringView.component);
- var childInjector = ReflectiveInjector.fromResolvedProviders(componentProviders, this._viewport.parentInjector);
- // create ComponentRef and set it to the entering view
- enteringView.init(componentFactory.create(childInjector, []));
- enteringView._state = STATE_INITIALIZED;
- this._preLoad(enteringView);
- };
- NavControllerBase.prototype._viewAttachToDOM = function (view, componentRef, viewport) {
- (void 0) /* assert */;
- (void 0) /* assert */;
- // fire willLoad before change detection runs
- this._willLoad(view);
- // render the component ref instance to the DOM
- // ******** DOM WRITE ****************
- viewport.insert(componentRef.hostView, viewport.length);
- view._state = STATE_ATTACHED;
- if (view._cssClass) {
- // the ElementRef of the actual ion-page created
- var pageElement = componentRef.location.nativeElement;
- // ******** DOM WRITE ****************
- this._renderer.setElementClass(pageElement, view._cssClass, true);
- }
- componentRef.changeDetectorRef.detectChanges();
- // successfully finished loading the entering view
- // fire off the "didLoad" lifecycle events
- this._zone.run(this._didLoad.bind(this, view));
- };
- NavControllerBase.prototype._viewTest = function (enteringView, leavingView, ti) {
- // Only test canLeave/canEnter if there is transition
- if (!ti.requiresTransition) {
- return Promise.resolve();
- }
- var promises = [];
- if (leavingView) {
- promises.push(leavingView._lifecycleTest('Leave'));
- }
- if (enteringView) {
- promises.push(enteringView._lifecycleTest('Enter'));
- }
- if (promises.length === 0) {
- return Promise.resolve();
- }
- // darn, async promises, gotta wait for them to resolve
- return Promise.all(promises).then(function (values) {
- if (values.some(function (result) { return result === false; })) {
- throw 'canEnter/Leave returned false';
- }
- }).catch(function (reason) {
- // Do not
- ti.reject = null;
- throw reason;
- });
- };
- NavControllerBase.prototype._transition = function (enteringView, leavingView, ti) {
- var _this = this;
- if (!ti.requiresTransition) {
- // transition is not required, so we are already done!
- // they're inserting/removing the views somewhere in the middle or
- // beginning, so visually nothing needs to animate/transition
- // resolve immediately because there's no animation that's happening
- return Promise.resolve({
- hasCompleted: true,
- requiresTransition: false
- });
- }
- var opts = ti.opts;
- // figure out if this transition is the root one or a
- // child of a parent nav that has the root transition
- this._trnsId = this._trnsCtrl.getRootTrnsId(this);
- if (this._trnsId === null) {
- // this is the root transition, meaning all child navs and their views
- // should be added as a child transition to this one
- this._trnsId = this._trnsCtrl.nextId();
- }
- // create the transition options
- var animationOpts = {
- animation: opts.animation,
- direction: opts.direction,
- duration: (opts.animate === false ? 0 : opts.duration),
- easing: opts.easing,
- isRTL: this._config.plt.isRTL,
- ev: opts.ev,
- };
- // create the transition animation from the TransitionController
- // this will either create the root transition, or add it as a child transition
- var transition$$1 = this._trnsCtrl.get(this._trnsId, enteringView, leavingView, animationOpts);
- // ensure any swipeback transitions are cleared out
- this._sbTrns && this._sbTrns.destroy();
- this._sbTrns = null;
- // swipe to go back root transition
- if (transition$$1.isRoot() && opts.progressAnimation) {
- this._sbTrns = transition$$1;
- }
- // transition start has to be registered before attaching the view to the DOM!
- var promise = new Promise(function (resolve) { return transition$$1.registerStart(resolve); }).then(function () {
- return _this._transitionStart(transition$$1, enteringView, leavingView, opts);
- });
- if (enteringView && (enteringView._state === STATE_INITIALIZED)) {
- // render the entering component in the DOM
- // this would also render new child navs/views
- // which may have their very own async canEnter/Leave tests
- // ******** DOM WRITE ****************
- this._viewAttachToDOM(enteringView, enteringView._cmp, this._viewport);
- }
- if (!transition$$1.hasChildren) {
- // lowest level transition, so kick it off and let it bubble up to start all of them
- transition$$1.start();
- }
- return promise;
- };
- NavControllerBase.prototype._transitionStart = function (transition$$1, enteringView, leavingView, opts) {
- var _this = this;
- (void 0) /* assert */;
- this._trnsId = null;
- // set the correct zIndex for the entering and leaving views
- // ******** DOM WRITE ****************
- setZIndex(this, enteringView, leavingView, opts.direction, this._renderer);
- // always ensure the entering view is viewable
- // ******** DOM WRITE ****************
- enteringView && enteringView._domShow(true, this._renderer);
- // always ensure the leaving view is viewable
- // ******** DOM WRITE ****************
- leavingView && leavingView._domShow(true, this._renderer);
- // initialize the transition
- transition$$1.init();
- // we should animate (duration > 0) if the pushed page is not the first one (startup)
- // or if it is a portal (modal, actionsheet, etc.)
- var isFirstPage = !this._init && this._views.length === 1;
- var shouldNotAnimate = isFirstPage && !this._isPortal;
- var canNotAnimate = this._config.get('animate') === false;
- if (shouldNotAnimate || canNotAnimate) {
- opts.animate = false;
- }
- if (opts.animate === false) {
- // if it was somehow set to not animation, then make the duration zero
- transition$$1.duration(0);
- }
- // create a callback that needs to run within zone
- // that will fire off the willEnter/Leave lifecycle events at the right time
- transition$$1.beforeAddRead(this._viewsWillLifecycles.bind(this, enteringView, leavingView));
- // get the set duration of this transition
- var duration = transition$$1.getDuration();
- // create a callback for when the animation is done
- var promise = new Promise(function (resolve) {
- transition$$1.onFinish(resolve);
- });
- if (transition$$1.isRoot()) {
- // this is the top most, or only active transition, so disable the app
- // add XXms to the duration the app is disabled when the keyboard is open
- if (duration > DISABLE_APP_MINIMUM_DURATION && opts.disableApp !== false) {
- // if this transition has a duration and this is the root transition
- // then set that the app is actively disabled
- this._app.setEnabled(false, duration + ACTIVE_TRANSITION_OFFSET, opts.minClickBlockDuration);
- }
- else {
- (void 0) /* console.debug */;
- }
- // cool, let's do this, start the transition
- if (opts.progressAnimation) {
- // this is a swipe to go back, just get the transition progress ready
- // kick off the swipe animation start
- transition$$1.progressStart();
- }
- else {
- // only the top level transition should actually start "play"
- // kick it off and let it play through
- // ******** DOM WRITE ****************
- transition$$1.play();
- }
- }
- return promise.then(function () { return _this._zone.run(function () {
- return _this._transitionFinish(transition$$1, opts);
- }); });
- };
- NavControllerBase.prototype._transitionFinish = function (transition$$1, opts) {
- var hasCompleted = transition$$1.hasCompleted;
- var enteringView = transition$$1.enteringView;
- var leavingView = transition$$1.leavingView;
- // mainly for testing
- var enteringName;
- var leavingName;
- if (hasCompleted) {
- // transition has completed (went from 0 to 1)
- if (enteringView) {
- enteringName = enteringView.name;
- this._didEnter(enteringView);
- }
- if (leavingView) {
- leavingName = leavingView.name;
- this._didLeave(leavingView);
- }
- this._cleanup(enteringView);
- }
- else {
- // If transition does not complete, we have to cleanup anyway, because
- // previous pages in the stack are not hidden probably.
- this._cleanup(leavingView);
- }
- if (transition$$1.isRoot()) {
- // this is the root transition
- // it's safe to destroy this transition
- this._trnsCtrl.destroy(transition$$1.trnsId);
- // it's safe to enable the app again
- this._app.setEnabled(true);
- // mark ourselves as not transitioning - `deepLinker navchange` requires this
- // TODO - probably could be resolved in a better way
- this.setTransitioning(false);
- if (!this.hasChildren() && opts.updateUrl !== false) {
- // notify deep linker of the nav change
- // if a direction was provided and should update url
- this._linker.navChange(opts.direction);
- }
- if (opts.keyboardClose !== false) {
- // the keyboard is still open!
- // no problem, let's just close for them
- this.plt.focusOutActiveElement();
- }
- }
- return {
- hasCompleted: hasCompleted,
- requiresTransition: true,
- enteringName: enteringName,
- leavingName: leavingName,
- direction: opts.direction
- };
- };
- NavControllerBase.prototype._viewsWillLifecycles = function (enteringView, leavingView) {
- var _this = this;
- if (enteringView || leavingView) {
- this._zone.run(function () {
- // Here, the order is important. WillLeave must be called before WillEnter.
- if (leavingView) {
- var willUnload = enteringView ? leavingView.index > enteringView.index : true;
- _this._willLeave(leavingView, willUnload);
- }
- enteringView && _this._willEnter(enteringView);
- });
- }
- };
- NavControllerBase.prototype._insertViewAt = function (view, index) {
- var existingIndex = this._views.indexOf(view);
- if (existingIndex > -1) {
- // this view is already in the stack!!
- // move it to its new location
- (void 0) /* assert */;
- this._views.splice(index, 0, this._views.splice(existingIndex, 1)[0]);
- }
- else {
- (void 0) /* assert */;
- // this is a new view to add to the stack
- // create the new entering view
- view._setNav(this);
- // give this inserted view an ID
- this._ids++;
- if (!view.id) {
- view.id = this.id + "-" + this._ids;
- }
- // insert the entering view into the correct index in the stack
- this._views.splice(index, 0, view);
- }
- };
- NavControllerBase.prototype._removeView = function (view) {
- (void 0) /* assert */;
- var views = this._views;
- var index = views.indexOf(view);
- (void 0) /* assert */;
- if (index >= 0) {
- views.splice(index, 1);
- }
- };
- NavControllerBase.prototype._destroyView = function (view) {
- view._destroy(this._renderer);
- this._removeView(view);
- };
- /**
- * DOM WRITE
- */
- NavControllerBase.prototype._cleanup = function (activeView) {
- // ok, cleanup time!! Destroy all of the views that are
- // INACTIVE and come after the active view
- // only do this if the views exist, though
- if (!this._destroyed) {
- var activeViewIndex = this._views.indexOf(activeView);
- var views = this._views;
- var reorderZIndexes = false;
- var view = void 0;
- var i = void 0;
- for (i = views.length - 1; i >= 0; i--) {
- view = views[i];
- if (i > activeViewIndex) {
- // this view comes after the active view
- // let's unload it
- this._willUnload(view);
- this._destroyView(view);
- }
- else if (i < activeViewIndex && !this._isPortal) {
- // this view comes before the active view
- // and it is not a portal then ensure it is hidden
- view._domShow(false, this._renderer);
- }
- if (view._zIndex <= 0) {
- reorderZIndexes = true;
- }
- }
- if (!this._isPortal && reorderZIndexes) {
- for (i = 0; i < views.length; i++) {
- view = views[i];
- // ******** DOM WRITE ****************
- view._setZIndex(view._zIndex + INIT_ZINDEX + 1, this._renderer);
- }
- }
- }
- };
- NavControllerBase.prototype._preLoad = function (view) {
- (void 0) /* assert */;
- view._preLoad();
- };
- NavControllerBase.prototype._willLoad = function (view) {
- (void 0) /* assert */;
- try {
- view._willLoad();
- }
- catch (e) {
- this._errHandler && this._errHandler.handleError(e);
- }
- };
- NavControllerBase.prototype._didLoad = function (view) {
- (void 0) /* assert */;
- (void 0) /* assert */;
- try {
- view._didLoad();
- this.viewDidLoad.emit(view);
- this._app.viewDidLoad.emit(view);
- }
- catch (e) {
- this._errHandler && this._errHandler.handleError(e);
- }
- };
- NavControllerBase.prototype._willEnter = function (view) {
- (void 0) /* assert */;
- (void 0) /* assert */;
- try {
- view._willEnter();
- this.viewWillEnter.emit(view);
- this._app.viewWillEnter.emit(view);
- }
- catch (e) {
- this._errHandler && this._errHandler.handleError(e);
- }
- };
- NavControllerBase.prototype._didEnter = function (view) {
- (void 0) /* assert */;
- (void 0) /* assert */;
- try {
- view._didEnter();
- this.viewDidEnter.emit(view);
- this._app.viewDidEnter.emit(view);
- }
- catch (e) {
- this._errHandler && this._errHandler.handleError(e);
- }
- };
- NavControllerBase.prototype._willLeave = function (view, willUnload) {
- (void 0) /* assert */;
- (void 0) /* assert */;
- try {
- view._willLeave(willUnload);
- this.viewWillLeave.emit(view);
- this._app.viewWillLeave.emit(view);
- }
- catch (e) {
- this._errHandler && this._errHandler.handleError(e);
- }
- };
- NavControllerBase.prototype._didLeave = function (view) {
- (void 0) /* assert */;
- (void 0) /* assert */;
- try {
- view._didLeave();
- this.viewDidLeave.emit(view);
- this._app.viewDidLeave.emit(view);
- }
- catch (e) {
- this._errHandler && this._errHandler.handleError(e);
- }
- };
- NavControllerBase.prototype._willUnload = function (view) {
- (void 0) /* assert */;
- (void 0) /* assert */;
- try {
- view._willUnload();
- this.viewWillUnload.emit(view);
- this._app.viewWillUnload.emit(view);
- }
- catch (e) {
- this._errHandler && this._errHandler.handleError(e);
- }
- };
- NavControllerBase.prototype.hasChildren = function () {
- return this._children && this._children.length > 0;
- };
- NavControllerBase.prototype.getActiveChildNavs = function () {
- return this._children;
- };
- NavControllerBase.prototype.getAllChildNavs = function () {
- return this._children;
- };
- NavControllerBase.prototype.registerChildNav = function (container) {
- this._children.push(container);
- };
- NavControllerBase.prototype.unregisterChildNav = function (nav) {
- this._children = this._children.filter(function (child) { return child !== nav; });
- };
- NavControllerBase.prototype.destroy = function () {
- var views = this._views;
- var view;
- for (var i = 0; i < views.length; i++) {
- view = views[i];
- view._willUnload();
- view._destroy(this._renderer);
- }
- // release swipe back gesture and transition
- this._sbGesture && this._sbGesture.destroy();
- this._sbTrns && this._sbTrns.destroy();
- this._queue = this._views = this._sbGesture = this._sbTrns = null;
- // Unregister navcontroller
- if (this.parent && this.parent.unregisterChildNav) {
- this.parent.unregisterChildNav(this);
- }
- else if (this._app) {
- this._app.unregisterRootNav(this);
- }
- this._destroyed = true;
- };
- NavControllerBase.prototype.swipeBackStart = function () {
- if (this.isTransitioning() || this._queue.length > 0) {
- return;
- }
- // default the direction to "back";
- var opts = {
- direction: DIRECTION_BACK,
- progressAnimation: true
- };
- this._queueTrns({
- removeStart: -1,
- removeCount: 1,
- opts: opts,
- }, null);
- };
- NavControllerBase.prototype.swipeBackProgress = function (stepValue) {
- if (this._sbTrns && this._sbGesture) {
- // continue to disable the app while actively dragging
- this._app.setEnabled(false, ACTIVE_TRANSITION_DEFAULT);
- this.setTransitioning(true);
- // set the transition animation's progress
- this._sbTrns.progressStep(stepValue);
- }
- };
- NavControllerBase.prototype.swipeBackEnd = function (shouldComplete, currentStepValue, velocity) {
- if (this._sbTrns && this._sbGesture) {
- // the swipe back gesture has ended
- var dur = this._sbTrns.getDuration() / (Math.abs(velocity) + 1);
- this._sbTrns.progressEnd(shouldComplete, currentStepValue, dur);
- }
- };
- NavControllerBase.prototype._swipeBackCheck = function () {
- if (this.canSwipeBack()) {
- if (!this._sbGesture) {
- this._sbGesture = new SwipeBackGesture(this.plt, this, this._gestureCtrl, this._domCtrl);
- }
- this._sbGesture.listen();
- }
- else if (this._sbGesture) {
- this._sbGesture.unlisten();
- }
- };
- NavControllerBase.prototype.canSwipeBack = function () {
- return (this._sbEnabled &&
- !this._isPortal &&
- !this._children.length &&
- !this.isTransitioning() &&
- this._app.isEnabled() &&
- this.canGoBack());
- };
- NavControllerBase.prototype.canGoBack = function () {
- var activeView = this.getActive();
- return !!(activeView && activeView.enableBack());
- };
- NavControllerBase.prototype.isTransitioning = function () {
- return this._trnsTm;
- };
- NavControllerBase.prototype.setTransitioning = function (isTransitioning) {
- this._trnsTm = isTransitioning;
- };
- NavControllerBase.prototype.getActive = function () {
- return this._views[this._views.length - 1];
- };
- NavControllerBase.prototype.isActive = function (view) {
- return (view === this.getActive());
- };
- NavControllerBase.prototype.getByIndex = function (index) {
- return this._views[index];
- };
- NavControllerBase.prototype.getPrevious = function (view) {
- // returns the view controller which is before the given view controller.
- if (!view) {
- view = this.getActive();
- }
- var views = this._views;
- var index = views.indexOf(view);
- return (index > 0) ? views[index - 1] : null;
- };
- NavControllerBase.prototype.first = function () {
- // returns the first view controller in this nav controller's stack.
- return this._views[0];
- };
- NavControllerBase.prototype.last = function () {
- // returns the last page in this nav controller's stack.
- var views = this._views;
- return views[views.length - 1];
- };
- NavControllerBase.prototype.indexOf = function (view) {
- // returns the index number of the given view controller.
- return this._views.indexOf(view);
- };
- NavControllerBase.prototype.length = function () {
- return this._views.length;
- };
- NavControllerBase.prototype.getViews = function () {
- return this._views;
- };
- /**
- * Return a view controller
- */
- NavControllerBase.prototype.getViewById = function (id) {
- for (var _i = 0, _a = this._views; _i < _a.length; _i++) {
- var vc = _a[_i];
- if (vc && vc.id === id) {
- return vc;
- }
- }
- return null;
- };
- NavControllerBase.prototype.isSwipeBackEnabled = function () {
- return this._sbEnabled;
- };
- NavControllerBase.prototype.dismissPageChangeViews = function () {
- for (var _i = 0, _a = this._views; _i < _a.length; _i++) {
- var view = _a[_i];
- if (view.data && view.data.dismissOnPageChange) {
- view.dismiss().catch(function () { });
- }
- }
- };
- NavControllerBase.prototype.setViewport = function (val) {
- this._viewport = val;
- };
- NavControllerBase.prototype.resize = function () {
- var active = this.getActive();
- if (!active) {
- return;
- }
- var content = active.getIONContent();
- content && content.resize();
- };
- NavControllerBase.prototype.goToRoot = function (_opts) {
- return Promise.reject(new Error('goToRoot needs to be implemented by child class'));
- };
- /*
- * @private
- */
- NavControllerBase.prototype.getType = function () {
- return 'nav';
- };
- /*
- * @private
- */
- NavControllerBase.prototype.getSecondaryIdentifier = function () {
- return null;
- };
- /**
- * Returns the active child navigation.
- */
- NavControllerBase.prototype.getActiveChildNav = function () {
- console.warn('(getActiveChildNav) is deprecated and will be removed in the next major release. Use getActiveChildNavs instead.');
- return this._children[this._children.length - 1];
- };
- NavControllerBase.propDecorators = {
- 'swipeBackEnabled': [{ type: Input },],
- };
- return NavControllerBase;
- }(Ion));
- var ctrlIds = -1;
- var DISABLE_APP_MINIMUM_DURATION = 64;
- var ACTIVE_TRANSITION_DEFAULT = 5000;
- var ACTIVE_TRANSITION_OFFSET = 2000;
-
- /**
- * @hidden
- */
- var TransitionController = (function () {
- function TransitionController(plt, _config) {
- this.plt = plt;
- this._config = _config;
- this._ids = 0;
- this._trns = {};
- }
- TransitionController.prototype.getRootTrnsId = function (nav) {
- nav = nav.parent;
- while (nav) {
- if (isPresent(nav._trnsId)) {
- return nav._trnsId;
- }
- nav = nav.parent;
- }
- return null;
- };
- TransitionController.prototype.nextId = function () {
- return this._ids++;
- };
- TransitionController.prototype.get = function (trnsId, enteringView, leavingView, opts) {
- var TransitionClass = this._config.getTransition(opts.animation);
- if (!TransitionClass) {
- // didn't find a transition animation, default to ios-transition
- TransitionClass = this._config.getTransition('ios-transition');
- }
- var trns = new TransitionClass(this.plt, enteringView, leavingView, opts);
- trns.trnsId = trnsId;
- if (!this._trns[trnsId]) {
- // we haven't created the root transition yet
- this._trns[trnsId] = trns;
- }
- else {
- // we already have a root transition created
- // add this new transition as a child to the root
- this._trns[trnsId].add(trns);
- }
- return trns;
- };
- TransitionController.prototype.destroy = function (trnsId) {
- var trans = this._trns[trnsId];
- if (trans) {
- trans.destroy();
- delete this._trns[trnsId];
- }
- };
- TransitionController.decorators = [
- { type: Injectable },
- ];
- /** @nocollapse */
- TransitionController.ctorParameters = function () { return [
- { type: Platform, },
- { type: Config, },
- ]; };
- return TransitionController;
- }());
-
- var __extends$19 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @hidden
- */
- var OverlayPortal = (function (_super) {
- __extends$19(OverlayPortal, _super);
- function OverlayPortal(app, config, plt, elementRef, zone, renderer, cfr, gestureCtrl, transCtrl, linker, viewPort, domCtrl, errHandler) {
- var _this = _super.call(this, null, app, config, plt, elementRef, zone, renderer, cfr, gestureCtrl, transCtrl, linker, domCtrl, errHandler) || this;
- _this._isPortal = true;
- _this._init = true;
- _this.setViewport(viewPort);
- // on every page change make sure the portal has
- // dismissed any views that should be auto dismissed on page change
- app.viewDidLeave.subscribe(function (view) {
- if (!view.isOverlay) {
- _this.dismissPageChangeViews();
- }
- });
- return _this;
- }
- Object.defineProperty(OverlayPortal.prototype, "_overlayPortal", {
- set: function (val) {
- this._zIndexOffset = (val || 0);
- },
- enumerable: true,
- configurable: true
- });
- OverlayPortal.prototype.ngOnDestroy = function () {
- this.destroy();
- };
- /*
- * @private
- */
- OverlayPortal.prototype.getType = function () {
- return 'portal';
- };
- /*
- * @private
- */
- OverlayPortal.prototype.getSecondaryIdentifier = function () {
- return null;
- };
- OverlayPortal.decorators = [
- { type: Directive, args: [{
- selector: '[overlay-portal]',
- },] },
- ];
- /** @nocollapse */
- OverlayPortal.ctorParameters = function () { return [
- { type: App, decorators: [{ type: Inject, args: [forwardRef(function () { return App; }),] },] },
- { type: Config, },
- { type: Platform, },
- { type: ElementRef, },
- { type: NgZone, },
- { type: Renderer, },
- { type: ComponentFactoryResolver, },
- { type: GestureController, },
- { type: TransitionController, },
- { type: DeepLinker, decorators: [{ type: Optional },] },
- { type: ViewContainerRef, },
- { type: DomController, },
- { type: ErrorHandler, },
- ]; };
- OverlayPortal.propDecorators = {
- '_overlayPortal': [{ type: Input, args: ['overlay-portal',] },],
- };
- return OverlayPortal;
- }(NavControllerBase));
-
- var __extends = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- var AppRootToken = new InjectionToken('USERROOT');
- /**
- * @hidden
- */
- var IonicApp = (function (_super) {
- __extends(IonicApp, _super);
- function IonicApp(_userCmp, _cfr, elementRef, renderer, config, _plt, app) {
- var _this = _super.call(this, config, elementRef, renderer, 'app-root') || this;
- _this._userCmp = _userCmp;
- _this._cfr = _cfr;
- _this._plt = _plt;
- // register with App that this is Ionic's appRoot component. tada!
- app._appRoot = _this;
- _this._stopScrollPlugin = window['IonicStopScroll'];
- return _this;
- }
- IonicApp.prototype.ngOnInit = function () {
- var _this = this;
- // load the user root component
- // into Ionic's root component
- var factory = this._cfr.resolveComponentFactory(this._userCmp);
- var componentRef = this._viewport.createComponent(factory);
- this._renderer.setElementClass(componentRef.location.nativeElement, 'app-root', true);
- componentRef.changeDetectorRef.detectChanges();
- // set the mode class name
- // ios/md/wp
- this.setElementClass(this._config.get('mode'), true);
- var versions = this._plt.versions();
- this._plt.platforms().forEach(function (platformName) {
- // platform-ios
- var platformClass = 'platform-' + platformName;
- _this.setElementClass(platformClass, true);
- var platformVersion = versions[platformName];
- if (platformVersion) {
- // platform-ios9
- platformClass += platformVersion.major;
- _this.setElementClass(platformClass, true);
- // platform-ios9_3
- _this.setElementClass(platformClass + '_' + platformVersion.minor, true);
- }
- });
- // touch devices should not use :hover CSS pseudo
- // enable :hover CSS when the "hoverCSS" setting is not false
- if (this._config.getBoolean('hoverCSS', true)) {
- this.setElementClass('enable-hover', true);
- }
- // sweet, the app root has loaded!
- // which means angular and ionic has fully loaded!
- // fire off the platform prepare ready, which could
- // have been switched out by any of the platform engines
- this._plt.prepareReady();
- };
- /**
- * @hidden
- */
- IonicApp.prototype._getPortal = function (portal) {
- if (portal === PORTAL_LOADING) {
- return this._loadingPortal;
- }
- if (portal === PORTAL_TOAST) {
- return this._toastPortal;
- }
- // Modals need their own overlay becuase we don't want an ActionSheet
- // or Alert to trigger lifecycle events inside a modal
- if (portal === PORTAL_MODAL) {
- return this._modalPortal;
- }
- return this._overlayPortal;
- };
- IonicApp.prototype._getActivePortal = function () {
- var defaultPortal = this._overlayPortal;
- var modalPortal = this._modalPortal;
- var hasModal = modalPortal.length() > 0;
- var hasDefault = defaultPortal.length() > 0;
- if (!hasModal && !hasDefault) {
- return null;
- }
- else if (hasModal && hasDefault) {
- var defaultIndex = defaultPortal.getActive().getZIndex();
- var modalIndex = modalPortal.getActive().getZIndex();
- if (defaultIndex > modalIndex) {
- return defaultPortal;
- }
- else {
- (void 0) /* assert */;
- return modalPortal;
- }
- }
- if (hasModal) {
- return modalPortal;
- }
- else if (hasDefault) {
- return defaultPortal;
- }
- };
- IonicApp.prototype._disableScroll = function (shouldDisableScroll) {
- var _this = this;
- if (shouldDisableScroll) {
- this.stopScroll().then(function () {
- _this._tmr = _this._plt.timeout(function () {
- (void 0) /* console.debug */;
- _this.setElementClass('disable-scroll', true);
- }, 32);
- });
- }
- else {
- var plugin = this._stopScrollPlugin;
- if (plugin && plugin.cancel) {
- plugin.cancel();
- }
- clearTimeout(this._tmr);
- (void 0) /* console.debug */;
- this.setElementClass('disable-scroll', false);
- }
- };
- IonicApp.prototype.stopScroll = function () {
- var _this = this;
- if (this._stopScrollPlugin) {
- return new Promise(function (resolve) {
- _this._stopScrollPlugin.stop(function () { return resolve(true); });
- });
- }
- else {
- return Promise.resolve(false);
- }
- };
- IonicApp.decorators = [
- { type: Component, args: [{
- selector: 'ion-app',
- template: '<div #viewport app-viewport></div>' +
- '<div #modalPortal overlay-portal></div>' +
- '<div #overlayPortal overlay-portal></div>' +
- '<div #loadingPortal class="loading-portal" overlay-portal></div>' +
- '<div #toastPortal class="toast-portal" [overlay-portal]="10000"></div>' +
- '<div class="click-block"></div>'
- },] },
- ];
- /** @nocollapse */
- IonicApp.ctorParameters = function () { return [
- { type: undefined, decorators: [{ type: Inject, args: [AppRootToken,] },] },
- { type: ComponentFactoryResolver, },
- { type: ElementRef, },
- { type: Renderer, },
- { type: Config, },
- { type: Platform, },
- { type: App, },
- ]; };
- IonicApp.propDecorators = {
- '_viewport': [{ type: ViewChild, args: ['viewport', { read: ViewContainerRef },] },],
- '_modalPortal': [{ type: ViewChild, args: ['modalPortal', { read: OverlayPortal },] },],
- '_overlayPortal': [{ type: ViewChild, args: ['overlayPortal', { read: OverlayPortal },] },],
- '_loadingPortal': [{ type: ViewChild, args: ['loadingPortal', { read: OverlayPortal },] },],
- '_toastPortal': [{ type: ViewChild, args: ['toastPortal', { read: OverlayPortal },] },],
- };
- return IonicApp;
- }(Ion));
-
- var KEY_LEFT = 37;
- var KEY_UP = 38;
- var KEY_RIGHT = 39;
- var KEY_DOWN = 40;
- var KEY_ENTER = 13;
- var KEY_ESCAPE = 27;
- var KEY_SPACE = 32;
- var KEY_TAB = 9;
-
- /**
- * @hidden
- */
- var ActionSheetCmp = (function () {
- function ActionSheetCmp(_viewCtrl, config, _elementRef, gestureCtrl, params, renderer) {
- this._viewCtrl = _viewCtrl;
- this._elementRef = _elementRef;
- this.gestureBlocker = gestureCtrl.createBlocker(BLOCK_ALL);
- this.d = params.data;
- this.mode = config.get('mode');
- renderer.setElementClass(_elementRef.nativeElement, "action-sheet-" + this.mode, true);
- if (this.d.cssClass) {
- this.d.cssClass.split(' ').forEach(function (cssClass) {
- // Make sure the class isn't whitespace, otherwise it throws exceptions
- if (cssClass.trim() !== '')
- renderer.setElementClass(_elementRef.nativeElement, cssClass, true);
- });
- }
- this.id = (++actionSheetIds);
- if (this.d.title) {
- this.hdrId = 'acst-hdr-' + this.id;
- }
- if (this.d.subTitle) {
- this.descId = 'acst-subhdr-' + this.id;
- }
- }
- ActionSheetCmp.prototype.ionViewDidLoad = function () {
- var _this = this;
- // normalize the data
- this.d.buttons = this.d.buttons.map(function (button) {
- if (typeof button === 'string') {
- button = { text: button };
- }
- if (!button.cssClass) {
- button.cssClass = '';
- }
- switch (button.role) {
- case 'cancel':
- _this.cancelButton = button;
- return null;
- case 'destructive':
- button.cssClass = (button.cssClass + ' ' || '') + 'action-sheet-destructive';
- break;
- case 'selected':
- button.cssClass = (button.cssClass + ' ' || '') + 'action-sheet-selected';
- break;
- }
- return button;
- }).filter(function (button) { return button !== null; });
- };
- ActionSheetCmp.prototype.ionViewWillEnter = function () {
- this.gestureBlocker.block();
- };
- ActionSheetCmp.prototype.ionViewDidLeave = function () {
- this.gestureBlocker.unblock();
- };
- ActionSheetCmp.prototype.ionViewDidEnter = function () {
- var focusableEle = this._elementRef.nativeElement.querySelector('button');
- if (focusableEle) {
- focusableEle.focus();
- }
- this.enabled = true;
- };
- ActionSheetCmp.prototype.keyUp = function (ev) {
- if (this.enabled && ev.keyCode === KEY_ESCAPE && this._viewCtrl.isLast()) {
- (void 0) /* console.debug */;
- this.bdClick();
- }
- };
- ActionSheetCmp.prototype.click = function (button) {
- if (!this.enabled) {
- return;
- }
- var shouldDismiss = true;
- if (button.handler) {
- // a handler has been provided, execute it
- if (button.handler() === false) {
- // if the return value of the handler is false then do not dismiss
- shouldDismiss = false;
- }
- }
- if (shouldDismiss) {
- this.dismiss(button.role);
- }
- };
- ActionSheetCmp.prototype.bdClick = function () {
- if (this.enabled && this.d.enableBackdropDismiss) {
- if (this.cancelButton) {
- this.click(this.cancelButton);
- }
- else {
- this.dismiss('backdrop');
- }
- }
- };
- ActionSheetCmp.prototype.dismiss = function (role) {
- var opts = {
- minClickBlockDuration: 400
- };
- return this._viewCtrl.dismiss(null, role, opts);
- };
- ActionSheetCmp.prototype.ngOnDestroy = function () {
- (void 0) /* assert */;
- this.d = this.cancelButton = null;
- this.gestureBlocker.destroy();
- };
- ActionSheetCmp.decorators = [
- { type: Component, args: [{
- selector: 'ion-action-sheet',
- template: '<ion-backdrop (click)="bdClick()" [class.backdrop-no-tappable]="!d.enableBackdropDismiss"></ion-backdrop>' +
- '<div class="action-sheet-wrapper">' +
- '<div class="action-sheet-container">' +
- '<div class="action-sheet-group">' +
- '<div class="action-sheet-title" id="{{hdrId}}" *ngIf="d.title">{{d.title}}</div>' +
- '<div class="action-sheet-sub-title" id="{{descId}}" *ngIf="d.subTitle">{{d.subTitle}}</div>' +
- '<button ion-button="action-sheet-button" (click)="click(b)" *ngFor="let b of d.buttons" class="disable-hover" [attr.icon-start]="b.icon ? \'\' : null" [ngClass]="b.cssClass">' +
- '<ion-icon [name]="b.icon" *ngIf="b.icon" class="action-sheet-icon"></ion-icon>' +
- '{{b.text}}' +
- '</button>' +
- '</div>' +
- '<div class="action-sheet-group action-sheet-group-cancel" *ngIf="cancelButton">' +
- '<button ion-button="action-sheet-button" (click)="click(cancelButton)" class="action-sheet-cancel disable-hover" [attr.icon-start]="cancelButton.icon ? \'\' : null" [ngClass]="cancelButton.cssClass">' +
- '<ion-icon [name]="cancelButton.icon" *ngIf="cancelButton.icon" class="action-sheet-icon"></ion-icon>' +
- '{{cancelButton.text}}' +
- '</button>' +
- '</div>' +
- '</div>' +
- '</div>',
- host: {
- 'role': 'dialog',
- '[attr.aria-labelledby]': 'hdrId',
- '[attr.aria-describedby]': 'descId'
- },
- encapsulation: ViewEncapsulation.None,
- },] },
- ];
- /** @nocollapse */
- ActionSheetCmp.ctorParameters = function () { return [
- { type: ViewController, },
- { type: Config, },
- { type: ElementRef, },
- { type: GestureController, },
- { type: NavParams, },
- { type: Renderer, },
- ]; };
- ActionSheetCmp.propDecorators = {
- 'keyUp': [{ type: HostListener, args: ['body:keyup', ['$event'],] },],
- };
- return ActionSheetCmp;
- }());
- var actionSheetIds = -1;
-
- var __extends$25 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- var ActionSheetSlideIn = (function (_super) {
- __extends$25(ActionSheetSlideIn, _super);
- function ActionSheetSlideIn() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- ActionSheetSlideIn.prototype.init = function () {
- var ele = this.enteringView.pageRef().nativeElement;
- var backdrop = new Animation(this.plt, ele.querySelector('ion-backdrop'));
- var wrapper = new Animation(this.plt, ele.querySelector('.action-sheet-wrapper'));
- backdrop.fromTo('opacity', 0.01, 0.4);
- wrapper.fromTo('translateY', '100%', '0%');
- this.easing('cubic-bezier(.36,.66,.04,1)').duration(400).add(backdrop).add(wrapper);
- };
- return ActionSheetSlideIn;
- }(Transition));
- var ActionSheetSlideOut = (function (_super) {
- __extends$25(ActionSheetSlideOut, _super);
- function ActionSheetSlideOut() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- ActionSheetSlideOut.prototype.init = function () {
- var ele = this.leavingView.pageRef().nativeElement;
- var backdrop = new Animation(this.plt, ele.querySelector('ion-backdrop'));
- var wrapper = new Animation(this.plt, ele.querySelector('.action-sheet-wrapper'));
- backdrop.fromTo('opacity', 0.4, 0);
- wrapper.fromTo('translateY', '0%', '100%');
- this.easing('cubic-bezier(.36,.66,.04,1)').duration(300).add(backdrop).add(wrapper);
- };
- return ActionSheetSlideOut;
- }(Transition));
- var ActionSheetMdSlideIn = (function (_super) {
- __extends$25(ActionSheetMdSlideIn, _super);
- function ActionSheetMdSlideIn() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- ActionSheetMdSlideIn.prototype.init = function () {
- var ele = this.enteringView.pageRef().nativeElement;
- var backdrop = new Animation(this.plt, ele.querySelector('ion-backdrop'));
- var wrapper = new Animation(this.plt, ele.querySelector('.action-sheet-wrapper'));
- backdrop.fromTo('opacity', 0.01, 0.26);
- wrapper.fromTo('translateY', '100%', '0%');
- this.easing('cubic-bezier(.36,.66,.04,1)').duration(400).add(backdrop).add(wrapper);
- };
- return ActionSheetMdSlideIn;
- }(Transition));
- var ActionSheetMdSlideOut = (function (_super) {
- __extends$25(ActionSheetMdSlideOut, _super);
- function ActionSheetMdSlideOut() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- ActionSheetMdSlideOut.prototype.init = function () {
- var ele = this.leavingView.pageRef().nativeElement;
- var backdrop = new Animation(this.plt, ele.querySelector('ion-backdrop'));
- var wrapper = new Animation(this.plt, ele.querySelector('.action-sheet-wrapper'));
- backdrop.fromTo('opacity', 0.26, 0);
- wrapper.fromTo('translateY', '0%', '100%');
- this.easing('cubic-bezier(.36,.66,.04,1)').duration(450).add(backdrop).add(wrapper);
- };
- return ActionSheetMdSlideOut;
- }(Transition));
- var ActionSheetWpSlideIn = (function (_super) {
- __extends$25(ActionSheetWpSlideIn, _super);
- function ActionSheetWpSlideIn() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- ActionSheetWpSlideIn.prototype.init = function () {
- var ele = this.enteringView.pageRef().nativeElement;
- var backdrop = new Animation(this.plt, ele.querySelector('ion-backdrop'));
- var wrapper = new Animation(this.plt, ele.querySelector('.action-sheet-wrapper'));
- backdrop.fromTo('opacity', 0.01, 0.16);
- wrapper.fromTo('translateY', '100%', '0%');
- this.easing('cubic-bezier(.36,.66,.04,1)').duration(400).add(backdrop).add(wrapper);
- };
- return ActionSheetWpSlideIn;
- }(Transition));
- var ActionSheetWpSlideOut = (function (_super) {
- __extends$25(ActionSheetWpSlideOut, _super);
- function ActionSheetWpSlideOut() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- ActionSheetWpSlideOut.prototype.init = function () {
- var ele = this.leavingView.pageRef().nativeElement;
- var backdrop = new Animation(this.plt, ele.querySelector('ion-backdrop'));
- var wrapper = new Animation(this.plt, ele.querySelector('.action-sheet-wrapper'));
- backdrop.fromTo('opacity', 0.1, 0);
- wrapper.fromTo('translateY', '0%', '100%');
- this.easing('cubic-bezier(.36,.66,.04,1)').duration(450).add(backdrop).add(wrapper);
- };
- return ActionSheetWpSlideOut;
- }(Transition));
-
- var __extends$24 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @hidden
- */
- var ActionSheet = (function (_super) {
- __extends$24(ActionSheet, _super);
- function ActionSheet(app, opts, config) {
- var _this = this;
- opts.buttons = opts.buttons || [];
- opts.enableBackdropDismiss = isPresent(opts.enableBackdropDismiss) ? !!opts.enableBackdropDismiss : true;
- _this = _super.call(this, ActionSheetCmp, opts, null) || this;
- _this._app = app;
- _this.isOverlay = true;
- config.setTransition('action-sheet-slide-in', ActionSheetSlideIn);
- config.setTransition('action-sheet-slide-out', ActionSheetSlideOut);
- config.setTransition('action-sheet-md-slide-in', ActionSheetMdSlideIn);
- config.setTransition('action-sheet-md-slide-out', ActionSheetMdSlideOut);
- config.setTransition('action-sheet-wp-slide-in', ActionSheetWpSlideIn);
- config.setTransition('action-sheet-wp-slide-out', ActionSheetWpSlideOut);
- return _this;
- }
- /**
- * @hidden
- */
- ActionSheet.prototype.getTransitionName = function (direction) {
- var key = 'actionSheet' + (direction === 'back' ? 'Leave' : 'Enter');
- return this._nav && this._nav.config.get(key);
- };
- /**
- * @param {string} title Action sheet title
- */
- ActionSheet.prototype.setTitle = function (title) {
- this.data.title = title;
- return this;
- };
- /**
- * @param {string} subTitle Action sheet subtitle
- */
- ActionSheet.prototype.setSubTitle = function (subTitle) {
- this.data.subTitle = subTitle;
- return this;
- };
- /**
- * @param {object} button Action sheet button
- */
- ActionSheet.prototype.addButton = function (button) {
- this.data.buttons.push(button);
- return this;
- };
- /**
- * Present the action sheet instance.
- *
- * @param {NavOptions} [navOptions={}] Nav options to go with this transition.
- * @returns {Promise} Returns a promise which is resolved when the transition has completed.
- */
- ActionSheet.prototype.present = function (navOptions) {
- if (navOptions === void 0) { navOptions = {}; }
- navOptions.minClickBlockDuration = navOptions.minClickBlockDuration || 400;
- return this._app.present(this, navOptions);
- };
- return ActionSheet;
- }(ViewController));
-
- /**
- * @name ActionSheetController
- * @description
- * An Action Sheet is a dialog that lets the user choose from a set of
- * options. It appears on top of the app's content, and must be manually
- * dismissed by the user before they can resume interaction with the app.
- * Dangerous (destructive) options are made obvious in `ios` mode. There are easy
- * ways to cancel out of the action sheet, such as tapping the backdrop or
- * hitting the escape key on desktop.
- *
- * An action sheet is created from an array of `buttons`, with each button
- * including properties for its `text`, and optionally a `handler` and `role`.
- * If a handler returns `false` then the action sheet will not be dismissed. An
- * action sheet can also optionally have a `title`, `subTitle` and an `icon`.
- *
- * A button's `role` property can either be `destructive` or `cancel`. Buttons
- * without a role property will have the default look for the platform. Buttons
- * with the `cancel` role will always load as the bottom button, no matter where
- * they are in the array. All other buttons will be displayed in the order they
- * have been added to the `buttons` array. Note: We recommend that `destructive`
- * buttons are always the first button in the array, making them the top button.
- * Additionally, if the action sheet is dismissed by tapping the backdrop, then
- * it will fire the handler from the button with the cancel role.
- *
- * You can pass all of the action sheet's options in the first argument of
- * the create method: `ActionSheet.create(opts)`. Otherwise the action sheet's
- * instance has methods to add options, like `setTitle()` or `addButton()`.
- *
- * @usage
- * ```ts
- * import { ActionSheetController } from 'ionic-angular'
- *
- * export class MyClass{
- *
- * constructor(public actionSheetCtrl: ActionSheetController) { }
- *
- * presentActionSheet() {
- * const actionSheet = this.actionSheetCtrl.create({
- * title: 'Modify your album',
- * buttons: [
- * {
- * text: 'Destructive',
- * role: 'destructive',
- * handler: () => {
- * console.log('Destructive clicked');
- * }
- * },
- * {
- * text: 'Archive',
- * handler: () => {
- * console.log('Archive clicked');
- * }
- * },
- * {
- * text: 'Cancel',
- * role: 'cancel',
- * handler: () => {
- * console.log('Cancel clicked');
- * }
- * }
- * ]
- * });
- *
- * actionSheet.present();
- * }
- * }
- * ```
- *
- * @advanced
- *
- * ActionSheet create options
- *
- * | Option | Type | Description |
- * |-----------------------|------------|--------------------------------------------------------------------|
- * | title |`string` | The title for the Action Sheet. |
- * | subTitle |`string` | The sub-title for the Action Sheet. |
- * | cssClass |`string` | Additional classes for custom styles, separated by spaces. |
- * | enableBackdropDismiss |`boolean` | If the Action Sheet should close when the user taps the backdrop. |
- * | buttons |`array<any>`| An array of buttons to display. |
- *
- * ActionSheet button options
- *
- * | Option | Type | Description |
- * |----------|----------|--------------------------------------------------------------------------------------------------------------------------------------------------|
- * | text | `string` | The buttons text. |
- * | icon | `icon` | The buttons icons. |
- * | handler | `any` | An express the button should evaluate. |
- * | cssClass | `string` | Additional classes for custom styles, separated by spaces. |
- * | role | `string` | How the button should be displayed, `destructive` or `cancel`. If not role is provided, it will display the button without any additional styles.|
- *
- *
- * ### Dismissing And Async Navigation
- *
- * After an action sheet has been dismissed, the app may need to also transition
- * to another page depending on the handler's logic. However, because multiple
- * transitions were fired at roughly the same time, it's difficult for the
- * nav controller to cleanly animate multiple transitions that may
- * have been kicked off asynchronously. This is further described in the
- * [`Nav Transition Promises`](../../nav/NavController/#nav-transition-promises) section. For action sheets,
- * this means it's best to wait for the action sheet to finish its transition
- * out before starting a new transition on the same nav controller.
- *
- * In the example below, after the button has been clicked, its handler
- * waits on async operation to complete, *then* it uses `pop` to navigate
- * back a page in the same stack. The potential problem is that the async operation
- * may have been completed before the action sheet has even finished its transition
- * out. In this case, it's best to ensure the action sheet has finished its transition
- * out first, *then* start the next transition.
- *
- * ```ts
- * const actionSheet = this.actionSheetCtrl.create({
- * title: 'Hello',
- * buttons: [{
- * text: 'Ok',
- * handler: () => {
- * // user has clicked the action sheet button
- * // begin the action sheet's dimiss transition
- * let navTransition = actionSheet.dismiss();
- *
- * // start some async method
- * someAsyncOperation().then(() => {
- * // once the async operation has completed
- * // then run the next nav transition after the
- * // first transition has finished animating out
- *
- * navTransition.then(() => {
- * this.nav.pop();
- * });
- * });
- * return false;
- * }
- * }]
- * });
- *
- * actionSheet.present();
- * ```
- *
- * It's important to note that the handler returns `false`. A feature of
- * button handlers is that they automatically dismiss the action sheet when their button
- * was clicked, however, we'll need more control regarding the transition. Because
- * the handler returns `false`, then the action sheet does not automatically dismiss
- * itself. Instead, you now have complete control of when the action sheet has finished
- * transitioning, and the ability to wait for the action sheet to finish transitioning
- * out before starting a new transition.
- *
- *
- * @demo /docs/demos/src/action-sheet/
- * @see {@link /docs/components#action-sheets ActionSheet Component Docs}
- */
- var ActionSheetController = (function () {
- function ActionSheetController(_app, config) {
- this._app = _app;
- this.config = config;
- }
- /**
- * Open an action sheet with a title, subTitle, and an array of buttons
- * @param {ActionSheetOptions} opts Action sheet options
- */
- ActionSheetController.prototype.create = function (opts) {
- if (opts === void 0) { opts = {}; }
- return new ActionSheet(this._app, opts, this.config);
- };
- ActionSheetController.decorators = [
- { type: Injectable },
- ];
- /** @nocollapse */
- ActionSheetController.ctorParameters = function () { return [
- { type: App, },
- { type: Config, },
- ]; };
- return ActionSheetController;
- }());
-
- /**
- * @hidden
- */
- var AlertCmp = (function () {
- function AlertCmp(_viewCtrl, _elementRef, config, gestureCtrl, params, _renderer, _plt) {
- this._viewCtrl = _viewCtrl;
- this._elementRef = _elementRef;
- this._renderer = _renderer;
- this._plt = _plt;
- // gesture blocker is used to disable gestures dynamically
- this.gestureBlocker = gestureCtrl.createBlocker(BLOCK_ALL);
- this.d = params.data;
- this.mode = this.d.mode || config.get('mode');
- this.keyboardResizes = config.getBoolean('keyboardResizes', false);
- _renderer.setElementClass(_elementRef.nativeElement, "alert-" + this.mode, true);
- if (this.d.cssClass) {
- this.d.cssClass.split(' ').forEach(function (cssClass) {
- // Make sure the class isn't whitespace, otherwise it throws exceptions
- if (cssClass.trim() !== '')
- _renderer.setElementClass(_elementRef.nativeElement, cssClass, true);
- });
- }
- this.id = (++alertIds);
- this.descId = '';
- this.hdrId = 'alert-hdr-' + this.id;
- this.subHdrId = 'alert-subhdr-' + this.id;
- this.msgId = 'alert-msg-' + this.id;
- this.activeId = '';
- this.lastClick = 0;
- if (this.d.message) {
- this.descId = this.msgId;
- }
- else if (this.d.subTitle) {
- this.descId = this.subHdrId;
- }
- if (!this.d.message) {
- this.d.message = '';
- }
- }
- AlertCmp.prototype.ionViewDidLoad = function () {
- var _this = this;
- // normalize the data
- var data = this.d;
- data.buttons = data.buttons.map(function (button) {
- if (typeof button === 'string') {
- return { text: button };
- }
- return button;
- });
- data.inputs = data.inputs.map(function (input, index) {
- var r = {
- type: input.type || 'text',
- name: isPresent(input.name) ? input.name : index + '',
- placeholder: isPresent(input.placeholder) ? input.placeholder : '',
- value: isPresent(input.value) ? input.value : '',
- label: input.label,
- checked: !!input.checked,
- disabled: !!input.disabled,
- id: isPresent(input.id) ? input.id : "alert-input-" + _this.id + "-" + index,
- handler: isPresent(input.handler) ? input.handler : null,
- min: isPresent(input.min) ? input.min : null,
- max: isPresent(input.max) ? input.max : null
- };
- return r;
- });
- // An alert can be created with several different inputs. Radios,
- // checkboxes and inputs are all accepted, but they cannot be mixed.
- var inputTypes = [];
- data.inputs.forEach(function (input) {
- if (inputTypes.indexOf(input.type) < 0) {
- inputTypes.push(input.type);
- }
- });
- if (inputTypes.length > 1 && (inputTypes.indexOf('checkbox') > -1 || inputTypes.indexOf('radio') > -1)) {
- console.warn("Alert cannot mix input types: " + (inputTypes.join('/')) + ". Please see alert docs for more info.");
- }
- this.inputType = inputTypes.length ? inputTypes[0] : null;
- var checkedInput = this.d.inputs.find(function (input) { return input.checked; });
- if (checkedInput) {
- this.activeId = checkedInput.id;
- }
- var hasTextInput = (this.d.inputs.length && this.d.inputs.some(function (i) { return !(NON_TEXT_INPUT_REGEX.test(i.type)); }));
- if (!this.keyboardResizes && hasTextInput && this._plt.is('mobile')) {
- // this alert has a text input and it's on a mobile device so we should align
- // the alert up high because we need to leave space for the virtual keboard
- // this also helps prevent the layout getting all messed up from
- // the browser trying to scroll the input into a safe area
- this._renderer.setElementClass(this._elementRef.nativeElement, 'alert-top', true);
- }
- };
- AlertCmp.prototype.ionViewWillEnter = function () {
- this.gestureBlocker.block();
- };
- AlertCmp.prototype.ionViewDidLeave = function () {
- this.gestureBlocker.unblock();
- };
- AlertCmp.prototype.ionViewDidEnter = function () {
- // set focus on the first input or button in the alert
- // note that this does not always work and bring up the keyboard on
- // devices since the focus command must come from the user's touch event
- // and ionViewDidEnter is not in the same callstack as the touch event :(
- var focusableEle = this._elementRef.nativeElement.querySelector('input,button');
- if (focusableEle) {
- setTimeout(function () { return focusableEle.focus(); });
- }
- this.enabled = true;
- };
- AlertCmp.prototype.keyUp = function (ev) {
- if (this.enabled && this._viewCtrl.isLast()) {
- if (ev.keyCode === KEY_ENTER) {
- if (this.lastClick + 1000 < Date.now()) {
- // do not fire this click if there recently was already a click
- // this can happen when the button has focus and used the enter
- // key to click the button. However, both the click handler and
- // this keyup event will fire, so only allow one of them to go.
- (void 0) /* console.debug */;
- var button = this.d.buttons[this.d.buttons.length - 1];
- this.btnClick(button);
- }
- }
- else if (ev.keyCode === KEY_ESCAPE) {
- (void 0) /* console.debug */;
- this.bdClick();
- }
- }
- };
- AlertCmp.prototype.btnClick = function (button) {
- if (!this.enabled) {
- return;
- }
- // keep the time of the most recent button click
- this.lastClick = Date.now();
- var shouldDismiss = true;
- if (button.handler) {
- // a handler has been provided, execute it
- // pass the handler the values from the inputs
- if (button.handler(this.getValues()) === false) {
- // if the return value of the handler is false then do not dismiss
- shouldDismiss = false;
- }
- }
- if (shouldDismiss) {
- this.dismiss(button.role);
- }
- };
- AlertCmp.prototype.rbClick = function (checkedInput) {
- if (this.enabled) {
- this.d.inputs.forEach(function (input) {
- input.checked = (checkedInput === input);
- });
- this.activeId = checkedInput.id;
- if (checkedInput.handler) {
- checkedInput.handler(checkedInput);
- }
- }
- };
- AlertCmp.prototype.cbClick = function (checkedInput) {
- if (this.enabled) {
- checkedInput.checked = !checkedInput.checked;
- if (checkedInput.handler) {
- checkedInput.handler(checkedInput);
- }
- }
- };
- AlertCmp.prototype.bdClick = function () {
- if (this.enabled && this.d.enableBackdropDismiss) {
- var cancelBtn = this.d.buttons.find(function (b) { return b.role === 'cancel'; });
- if (cancelBtn) {
- this.btnClick(cancelBtn);
- }
- else {
- this.dismiss('backdrop');
- }
- }
- };
- AlertCmp.prototype.dismiss = function (role) {
- var opts = {
- minClickBlockDuration: 400
- };
- return this._viewCtrl.dismiss(this.getValues(), role, opts);
- };
- AlertCmp.prototype.getValues = function () {
- if (this.inputType === 'radio') {
- // this is an alert with radio buttons (single value select)
- // return the one value which is checked, otherwise undefined
- var checkedInput = this.d.inputs.find(function (i) { return i.checked; });
- return checkedInput ? checkedInput.value : undefined;
- }
- if (this.inputType === 'checkbox') {
- // this is an alert with checkboxes (multiple value select)
- // return an array of all the checked values
- return this.d.inputs.filter(function (i) { return i.checked; }).map(function (i) { return i.value; });
- }
- if (this.d.inputs.length === 0) {
- // this is an alert without any options/inputs at all
- return undefined;
- }
- // this is an alert with text inputs
- // return an object of all the values with the input name as the key
- var values = {};
- this.d.inputs.forEach(function (i) {
- values[i.name] = i.value;
- });
- return values;
- };
- AlertCmp.prototype.ngOnDestroy = function () {
- (void 0) /* assert */;
- this.gestureBlocker.destroy();
- };
- AlertCmp.decorators = [
- { type: Component, args: [{
- selector: 'ion-alert',
- template: '<ion-backdrop (click)="bdClick()" [class.backdrop-no-tappable]="!d.enableBackdropDismiss"></ion-backdrop>' +
- '<div class="alert-wrapper">' +
- '<div class="alert-head">' +
- '<h2 id="{{hdrId}}" class="alert-title" *ngIf="d.title" [innerHTML]="d.title"></h2>' +
- '<h3 id="{{subHdrId}}" class="alert-sub-title" *ngIf="d.subTitle" [innerHTML]="d.subTitle"></h3>' +
- '</div>' +
- '<div id="{{msgId}}" class="alert-message" [innerHTML]="d.message"></div>' +
- '<div *ngIf="d.inputs.length" [ngSwitch]="inputType">' +
- '<ng-template ngSwitchCase="radio">' +
- '<div class="alert-radio-group" role="radiogroup" [attr.aria-labelledby]="hdrId" [attr.aria-activedescendant]="activeId">' +
- '<button ion-button="alert-radio-button" *ngFor="let i of d.inputs" (click)="rbClick(i)" [attr.aria-checked]="i.checked" [disabled]="i.disabled" [attr.id]="i.id" class="alert-tappable alert-radio" role="radio">' +
- '<div class="alert-radio-icon"><div class="alert-radio-inner"></div></div>' +
- '<div class="alert-radio-label">' +
- '{{i.label}}' +
- '</div>' +
- '</button>' +
- '</div>' +
- '</ng-template>' +
- '<ng-template ngSwitchCase="checkbox">' +
- '<div class="alert-checkbox-group">' +
- '<button ion-button="alert-checkbox-button" *ngFor="let i of d.inputs" (click)="cbClick(i)" [attr.aria-checked]="i.checked" [attr.id]="i.id" [disabled]="i.disabled" class="alert-tappable alert-checkbox" role="checkbox">' +
- '<div class="alert-checkbox-icon"><div class="alert-checkbox-inner"></div></div>' +
- '<div class="alert-checkbox-label">' +
- '{{i.label}}' +
- '</div>' +
- '</button>' +
- '</div>' +
- '</ng-template>' +
- '<ng-template ngSwitchDefault>' +
- '<div class="alert-input-group">' +
- '<div *ngFor="let i of d.inputs" class="alert-input-wrapper">' +
- '<input [placeholder]="i.placeholder" [(ngModel)]="i.value" [type]="i.type" dir="auto" [min]="i.min" [max]="i.max" [attr.id]="i.id" class="alert-input">' +
- '</div>' +
- '</div>' +
- '</ng-template>' +
- '</div>' +
- '<div class="alert-button-group" [ngClass]="{\'alert-button-group-vertical\':d.buttons.length>2}">' +
- '<button ion-button="alert-button" *ngFor="let b of d.buttons" (click)="btnClick(b)" [ngClass]="b.cssClass">' +
- '{{b.text}}' +
- '</button>' +
- '</div>' +
- '</div>',
- host: {
- 'role': 'dialog',
- '[attr.aria-labelledby]': 'hdrId',
- '[attr.aria-describedby]': 'descId'
- },
- encapsulation: ViewEncapsulation.None,
- },] },
- ];
- /** @nocollapse */
- AlertCmp.ctorParameters = function () { return [
- { type: ViewController, },
- { type: ElementRef, },
- { type: Config, },
- { type: GestureController, },
- { type: NavParams, },
- { type: Renderer, },
- { type: Platform, },
- ]; };
- AlertCmp.propDecorators = {
- 'keyUp': [{ type: HostListener, args: ['body:keyup', ['$event'],] },],
- };
- return AlertCmp;
- }());
- var alertIds = -1;
-
- var __extends$27 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * Animations for alerts
- */
- var AlertPopIn = (function (_super) {
- __extends$27(AlertPopIn, _super);
- function AlertPopIn() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- AlertPopIn.prototype.init = function () {
- var ele = this.enteringView.pageRef().nativeElement;
- var backdrop = new Animation(this.plt, ele.querySelector('ion-backdrop'));
- var wrapper = new Animation(this.plt, ele.querySelector('.alert-wrapper'));
- wrapper.fromTo('opacity', 0.01, 1).fromTo('scale', 1.1, 1);
- backdrop.fromTo('opacity', 0.01, 0.3);
- this
- .easing('ease-in-out')
- .duration(200)
- .add(backdrop)
- .add(wrapper);
- };
- return AlertPopIn;
- }(Transition));
- var AlertPopOut = (function (_super) {
- __extends$27(AlertPopOut, _super);
- function AlertPopOut() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- AlertPopOut.prototype.init = function () {
- var ele = this.leavingView.pageRef().nativeElement;
- var backdrop = new Animation(this.plt, ele.querySelector('ion-backdrop'));
- var wrapper = new Animation(this.plt, ele.querySelector('.alert-wrapper'));
- wrapper.fromTo('opacity', 0.99, 0).fromTo('scale', 1, 0.9);
- backdrop.fromTo('opacity', 0.3, 0);
- this
- .easing('ease-in-out')
- .duration(200)
- .add(backdrop)
- .add(wrapper);
- };
- return AlertPopOut;
- }(Transition));
- var AlertMdPopIn = (function (_super) {
- __extends$27(AlertMdPopIn, _super);
- function AlertMdPopIn() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- AlertMdPopIn.prototype.init = function () {
- var ele = this.enteringView.pageRef().nativeElement;
- var backdrop = new Animation(this.plt, ele.querySelector('ion-backdrop'));
- var wrapper = new Animation(this.plt, ele.querySelector('.alert-wrapper'));
- wrapper.fromTo('opacity', 0.01, 1).fromTo('scale', 1.1, 1);
- backdrop.fromTo('opacity', 0.01, 0.5);
- this
- .easing('ease-in-out')
- .duration(200)
- .add(backdrop)
- .add(wrapper);
- };
- return AlertMdPopIn;
- }(Transition));
- var AlertMdPopOut = (function (_super) {
- __extends$27(AlertMdPopOut, _super);
- function AlertMdPopOut() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- AlertMdPopOut.prototype.init = function () {
- var ele = this.leavingView.pageRef().nativeElement;
- var backdrop = new Animation(this.plt, ele.querySelector('ion-backdrop'));
- var wrapper = new Animation(this.plt, ele.querySelector('.alert-wrapper'));
- wrapper.fromTo('opacity', 0.99, 0).fromTo('scale', 1, 0.9);
- backdrop.fromTo('opacity', 0.5, 0);
- this
- .easing('ease-in-out')
- .duration(200)
- .add(backdrop)
- .add(wrapper);
- };
- return AlertMdPopOut;
- }(Transition));
- var AlertWpPopIn = (function (_super) {
- __extends$27(AlertWpPopIn, _super);
- function AlertWpPopIn() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- AlertWpPopIn.prototype.init = function () {
- var ele = this.enteringView.pageRef().nativeElement;
- var backdrop = new Animation(this.plt, ele.querySelector('ion-backdrop'));
- var wrapper = new Animation(this.plt, ele.querySelector('.alert-wrapper'));
- wrapper.fromTo('opacity', 0.01, 1).fromTo('scale', 1.3, 1);
- backdrop.fromTo('opacity', 0.01, 0.5);
- this
- .easing('cubic-bezier(0,0,0.05,1)')
- .duration(200)
- .add(backdrop)
- .add(wrapper);
- };
- return AlertWpPopIn;
- }(Transition));
- var AlertWpPopOut = (function (_super) {
- __extends$27(AlertWpPopOut, _super);
- function AlertWpPopOut() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- AlertWpPopOut.prototype.init = function () {
- var ele = this.leavingView.pageRef().nativeElement;
- var backdrop = new Animation(this.plt, ele.querySelector('ion-backdrop'));
- var wrapper = new Animation(this.plt, ele.querySelector('.alert-wrapper'));
- wrapper.fromTo('opacity', 0.99, 0).fromTo('scale', 1, 1.3);
- backdrop.fromTo('opacity', 0.5, 0);
- this
- .easing('ease-out')
- .duration(150)
- .add(backdrop)
- .add(wrapper);
- };
- return AlertWpPopOut;
- }(Transition));
-
- var __extends$26 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @hidden
- */
- var Alert = (function (_super) {
- __extends$26(Alert, _super);
- function Alert(app, opts, config) {
- if (opts === void 0) { opts = {}; }
- var _this = this;
- opts.inputs = opts.inputs || [];
- opts.buttons = opts.buttons || [];
- opts.enableBackdropDismiss = isPresent(opts.enableBackdropDismiss) ? !!opts.enableBackdropDismiss : true;
- _this = _super.call(this, AlertCmp, opts, null) || this;
- _this._app = app;
- _this.isOverlay = true;
- config.setTransition('alert-pop-in', AlertPopIn);
- config.setTransition('alert-pop-out', AlertPopOut);
- config.setTransition('alert-md-pop-in', AlertMdPopIn);
- config.setTransition('alert-md-pop-out', AlertMdPopOut);
- config.setTransition('alert-wp-pop-in', AlertWpPopIn);
- config.setTransition('alert-wp-pop-out', AlertWpPopOut);
- return _this;
- }
- /**
- * @hidden
- */
- Alert.prototype.getTransitionName = function (direction) {
- var key = (direction === 'back' ? 'alertLeave' : 'alertEnter');
- return this._nav && this._nav.config.get(key);
- };
- /**
- * @param {string} title Alert title
- */
- Alert.prototype.setTitle = function (title) {
- this.data.title = title;
- return this;
- };
- /**
- * @param {string} subTitle Alert subtitle
- */
- Alert.prototype.setSubTitle = function (subTitle) {
- this.data.subTitle = subTitle;
- return this;
- };
- /**
- * @param {string} message Alert message content
- */
- Alert.prototype.setMessage = function (message) {
- this.data.message = message;
- return this;
- };
- /**
- * @param {object} input Alert input
- */
- Alert.prototype.addInput = function (input) {
- this.data.inputs.push(input);
- return this;
- };
- /**
- * @param {any} button Alert button
- */
- Alert.prototype.addButton = function (button) {
- this.data.buttons.push(button);
- return this;
- };
- /**
- * @param {string} cssClass Set the CSS class names on the alert's outer wrapper.
- */
- Alert.prototype.setCssClass = function (cssClass) {
- this.data.cssClass = cssClass;
- return this;
- };
- /**
- * @param {string} mode Set the mode of the alert (ios, md, wp).
- */
- Alert.prototype.setMode = function (mode) {
- this.data.mode = mode;
- };
- /**
- * Present the alert instance.
- *
- * @param {NavOptions} [navOptions={}] Nav options to go with this transition.
- * @returns {Promise} Returns a promise which is resolved when the transition has completed.
- */
- Alert.prototype.present = function (navOptions) {
- if (navOptions === void 0) { navOptions = {}; }
- navOptions.minClickBlockDuration = navOptions.minClickBlockDuration || 400;
- return this._app.present(this, navOptions);
- };
- return Alert;
- }(ViewController));
-
- /**
- * @name AlertController
- * @description
- * An Alert is a dialog that presents users with information or collects
- * information from the user using inputs. An alert appears on top
- * of the app's content, and must be manually dismissed by the user before
- * they can resume interaction with the app. It can also optionally have a
- * `title`, `subTitle` and `message`.
- *
- * You can pass all of the alert's options in the first argument of
- * the create method: `create(opts)`. Otherwise the alert's instance
- * has methods to add options, such as `setTitle()` or `addButton()`.
- *
- *
- * ### Alert Buttons
- *
- * In the array of `buttons`, each button includes properties for its `text`,
- * and optionally a `handler`. If a handler returns `false` then the alert
- * will not automatically be dismissed when the button is clicked. All
- * buttons will show up in the order they have been added to the `buttons`
- * array, from left to right. Note: The right most button (the last one in
- * the array) is the main button.
- *
- * Optionally, a `role` property can be added to a button, such as `cancel`.
- * If a `cancel` role is on one of the buttons, then if the alert is
- * dismissed by tapping the backdrop, then it will fire the handler from
- * the button with a cancel role.
- *
- *
- * ### Alert Inputs
- *
- * Alerts can also include several different inputs whose data can be passed
- * back to the app. Inputs can be used as a simple way to prompt users for
- * information. Radios, checkboxes and text inputs are all accepted, but they
- * cannot be mixed. For example, an alert could have all radio button inputs,
- * or all checkbox inputs, but the same alert cannot mix radio and checkbox
- * inputs. Do note however, different types of "text"" inputs can be mixed,
- * such as `url`, `email`, `text`, etc. If you require a complex form UI
- * which doesn't fit within the guidelines of an alert then we recommend
- * building the form within a modal instead.
- *
- *
- * @usage
- * ```ts
- * import { AlertController } from 'ionic-angular';
- *
- * constructor(public alertCtrl: AlertController) { }
- *
- * presentAlert() {
- * const alert = this.alertCtrl.create({
- * title: 'Low battery',
- * subTitle: '10% of battery remaining',
- * buttons: ['Dismiss']
- * });
- * alert.present();
- * }
- *
- * presentConfirm() {
- * const alert = this.alertCtrl.create({
- * title: 'Confirm purchase',
- * message: 'Do you want to buy this book?',
- * buttons: [
- * {
- * text: 'Cancel',
- * role: 'cancel',
- * handler: () => {
- * console.log('Cancel clicked');
- * }
- * },
- * {
- * text: 'Buy',
- * handler: () => {
- * console.log('Buy clicked');
- * }
- * }
- * ]
- * });
- * alert.present();
- * }
- *
- * presentPrompt() {
- * const alert = this.alertCtrl.create({
- * title: 'Login',
- * inputs: [
- * {
- * name: 'username',
- * placeholder: 'Username'
- * },
- * {
- * name: 'password',
- * placeholder: 'Password',
- * type: 'password'
- * }
- * ],
- * buttons: [
- * {
- * text: 'Cancel',
- * role: 'cancel',
- * handler: data => {
- * console.log('Cancel clicked');
- * }
- * },
- * {
- * text: 'Login',
- * handler: data => {
- * if (User.isValid(data.username, data.password)) {
- * // logged in!
- * } else {
- * // invalid login
- * return false;
- * }
- * }
- * }
- * ]
- * });
- * alert.present();
- * }
- * ```
- * @advanced
- *
- *
- * Alert options
- *
- * | Property | Type | Description |
- * |-----------------------|-----------|------------------------------------------------------------------------------|
- * | title | `string` | The title for the alert. |
- * | subTitle | `string` | The subtitle for the alert. |
- * | message | `string` | The message for the alert. |
- * | cssClass | `string` | Additional classes for custom styles, separated by spaces. |
- * | inputs | `array` | An array of inputs for the alert. See input options. |
- * | buttons | `array` | An array of buttons for the alert. See buttons options. |
- * | enableBackdropDismiss | `boolean` | Whether the alert should be dismissed by tapping the backdrop. Default true. |
- *
- *
- * Input options
- *
- * | Property | Type | Description |
- * |-------------|-----------|-----------------------------------------------------------------|
- * | type | `string` | The type the input should be: text, tel, number, etc. |
- * | name | `string` | The name for the input. |
- * | placeholder | `string` | The input's placeholder (for textual/numeric inputs) |
- * | value | `string` | The input's value. |
- * | label | `string` | The input's label (only for radio/checkbox inputs) |
- * | checked | `boolean` | Whether or not the input is checked. |
- * | id | `string` | The input's id. |
- *
- * Button options
- *
- * | Property | Type | Description |
- * |----------|----------|-----------------------------------------------------------------|
- * | text | `string` | The buttons displayed text. |
- * | handler | `any` | Emitted when the button is pressed. |
- * | cssClass | `string` | An additional CSS class for the button. |
- * | role | `string` | The buttons role, null or `cancel`. |
- *
- * ### Dismissing And Async Navigation
- *
- * After an alert has been dismissed, the app may need to also transition
- * to another page depending on the handler's logic. However, because multiple
- * transitions were fired at roughly the same time, it's difficult for the
- * nav controller to cleanly animate multiple transitions that may
- * have been kicked off asynchronously. This is further described in the
- * [`Nav Transition Promises`](../../nav/NavController) section. For alerts,
- * this means it's best to wait for the alert to finish its transition
- * out before starting a new transition on the same nav controller.
- *
- * In the example below, after the alert button has been clicked, its handler
- * waits on async operation to complete, *then* it uses `pop` to navigate
- * back a page in the same stack. The potential problem is that the async operation
- * may have been completed before the alert has even finished its transition
- * out. In this case, it's best to ensure the alert has finished its transition
- * out first, *then* start the next transition.
- *
- * ```ts
- * const alert = this.alertCtrl.create({
- * title: 'Hello',
- * buttons: [{
- * text: 'Ok',
- * handler: () => {
- * // user has clicked the alert button
- * // begin the alert's dismiss transition
- * const navTransition = alert.dismiss();
- *
- * // start some async method
- * someAsyncOperation().then(() => {
- * // once the async operation has completed
- * // then run the next nav transition after the
- * // first transition has finished animating out
- *
- * navTransition.then(() => {
- * this.nav.pop();
- * });
- * });
- * return false;
- * }
- * }]
- * });
- *
- * alert.present();
- * ```
- *
- * It's important to note that the handler returns `false`. A feature of
- * button handlers is that they automatically dismiss the alert when their button
- * was clicked, however, we'll need more control regarding the transition. Because
- * the handler returns `false`, then the alert does not automatically dismiss
- * itself. Instead, you now have complete control of when the alert has finished
- * transitioning, and the ability to wait for the alert to finish transitioning
- * out before starting a new transition.
- *
- *
- * @demo /docs/demos/src/alert/
- */
- var AlertController = (function () {
- function AlertController(_app, config) {
- this._app = _app;
- this.config = config;
- }
- /**
- * Display an alert with a title, inputs, and buttons
- * @param {AlertOptions} opts Alert. See the table below
- */
- AlertController.prototype.create = function (opts) {
- if (opts === void 0) { opts = {}; }
- return new Alert(this._app, opts, this.config);
- };
- AlertController.decorators = [
- { type: Injectable },
- ];
- /** @nocollapse */
- AlertController.ctorParameters = function () { return [
- { type: App, },
- { type: Config, },
- ]; };
- return AlertController;
- }());
-
- /**
- * @name Avatar
- * @module ionic
- * @description
- * An Avatar is a component that creates a circular image for an item.
- * Avatars can be placed on the left or right side of an item with the `item-start` or `item-end` directive.
- * @see {@link /docs/components/#avatar-list Avatar Component Docs}
- */
- var Avatar = (function () {
- function Avatar() {
- }
- Avatar.decorators = [
- { type: Directive, args: [{
- selector: 'ion-avatar'
- },] },
- ];
- /** @nocollapse */
- Avatar.ctorParameters = function () { return []; };
- return Avatar;
- }());
-
- /**
- * @hidden
- */
- var Backdrop = (function () {
- function Backdrop(_elementRef, _renderer) {
- this._elementRef = _elementRef;
- this._renderer = _renderer;
- }
- Backdrop.prototype.getNativeElement = function () {
- return this._elementRef.nativeElement;
- };
- Backdrop.prototype.setElementClass = function (className, add) {
- this._renderer.setElementClass(this._elementRef.nativeElement, className, add);
- };
- Backdrop.decorators = [
- { type: Directive, args: [{
- selector: 'ion-backdrop',
- host: {
- 'role': 'presentation',
- 'tappable': '',
- 'disable-activated': ''
- },
- },] },
- ];
- /** @nocollapse */
- Backdrop.ctorParameters = function () { return [
- { type: ElementRef, },
- { type: Renderer, },
- ]; };
- return Backdrop;
- }());
-
- var __extends$28 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @name Badge
- * @module ionic
- * @description
- * Badges are simple components in Ionic containing numbers or text. You can display a badge to indicate that there is new information associated with the item it is on.
- * @see {@link /docs/components/#badges Badges Component Docs}
- */
- var Badge = (function (_super) {
- __extends$28(Badge, _super);
- function Badge(config, elementRef, renderer) {
- return _super.call(this, config, elementRef, renderer, 'badge') || this;
- }
- Badge.decorators = [
- { type: Directive, args: [{
- selector: 'ion-badge'
- },] },
- ];
- /** @nocollapse */
- Badge.ctorParameters = function () { return [
- { type: Config, },
- { type: ElementRef, },
- { type: Renderer, },
- ]; };
- return Badge;
- }(Ion));
-
- var __extends$29 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @name Button
- * @module ionic
- * @description
- * Buttons are simple components in Ionic. They can consist of text and icons
- * and be enhanced by a wide range of attributes.
- *
- * @usage
- *
- * ```html
- *
- * <!-- Colors -->
- * <button ion-button>Default</button>
- *
- * <button ion-button color="secondary">Secondary</button>
- *
- * <button ion-button color="danger">Danger</button>
- *
- * <button ion-button color="light">Light</button>
- *
- * <button ion-button color="dark">Dark</button>
- *
- * <!-- Shapes -->
- * <button ion-button full>Full Button</button>
- *
- * <button ion-button block>Block Button</button>
- *
- * <button ion-button round>Round Button</button>
- *
- * <!-- Outline -->
- * <button ion-button full outline>Outline + Full</button>
- *
- * <button ion-button block outline>Outline + Block</button>
- *
- * <button ion-button round outline>Outline + Round</button>
- *
- * <!-- Icons -->
- * <button ion-button icon-start>
- * <ion-icon name="star"></ion-icon>
- * Left Icon
- * </button>
- *
- * <button ion-button icon-end>
- * Right Icon
- * <ion-icon name="star"></ion-icon>
- * </button>
- *
- * <button ion-button icon-only>
- * <ion-icon name="star"></ion-icon>
- * </button>
- *
- * <!-- Sizes -->
- * <button ion-button large>Large</button>
- *
- * <button ion-button>Default</button>
- *
- * <button ion-button small>Small</button>
- * ```
- *
- * @advanced
- *
- * ```html
- *
- * <!-- Bind the color and outline inputs to an expression -->
- * <button ion-button [color]="isDanger ? 'danger' : 'primary'" [outline]="isOutline">
- * Danger (Solid)
- * </button>
- *
- * <!-- Bind the color and round inputs to an expression -->
- * <button ion-button [color]="myColor" [round]="isRound">
- * Secondary (Round)
- * </button>
- *
- * <!-- Bind the color and clear inputs to an expression -->
- * <button ion-button [color]="isSecondary ? 'secondary' : 'primary'" [clear]="isClear">
- * Primary (Clear)
- * </button>
- *
- * <!-- Bind the color, outline and round inputs to an expression -->
- * <button ion-button [color]="myColor2" [outline]="isOutline" [round]="isRound">
- * Dark (Solid + Round)
- * </button>
- *
- * <!-- Bind the click event to a method -->
- * <button ion-button (click)="logEvent($event)">
- * Click me!
- * </button>
- * ```
- *
- * ```ts
- * @Component({
- * templateUrl: 'main.html'
- * })
- * class E2EPage {
- * isDanger: boolean = true;
- * isSecondary: boolean = false;
- * isRound: boolean = true;
- * isOutline: boolean = false;
- * isClear: boolean = true;
- * myColor: string = 'secondary';
- * myColor2: string = 'dark';
- *
- * logEvent(event) {
- * console.log(event)
- * }
- * }
- *
- * ```
- *
- * @demo /docs/demos/src/button/
- * @see {@link /docs/components#buttons Button Component Docs}
- * @see {@link /docs/components#fabs FabButton Docs}
- * @see {@link ../../fab/FabButton FabButton API Docs}
- * @see {@link ../../fab/FabContainer FabContainer API Docs}
- */
- var Button = (function (_super) {
- __extends$29(Button, _super);
- function Button(ionButton, config, elementRef, renderer) {
- var _this = _super.call(this, config, elementRef, renderer) || this;
- /** @hidden */
- _this._role = 'button'; // bar-button
- /** @hidden */
- _this._style = 'default'; // outline/clear/solid
- _this._mode = config.get('mode');
- if (config.get('hoverCSS') === false) {
- _this.setElementClass('disable-hover', true);
- }
- if (ionButton.trim().length > 0) {
- _this.setRole(ionButton);
- }
- return _this;
- }
- Object.defineProperty(Button.prototype, "large", {
- /**
- * @input {boolean} If true, activates the large button size.
- */
- set: function (val) {
- this._attr('_size', 'large', val);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Button.prototype, "small", {
- /**
- * @input {boolean} If true, activates the small button size.
- */
- set: function (val) {
- this._attr('_size', 'small', val);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Button.prototype, "default", {
- /**
- * @input {boolean} If true, activates the default button size. Normally the default, useful for buttons in an item.
- */
- set: function (val) {
- this._attr('_size', 'default', val);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Button.prototype, "outline", {
- /**
- * @input {boolean} If true, activates a transparent button style with a border.
- */
- set: function (val) {
- this._attr('_style', 'outline', val);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Button.prototype, "clear", {
- /**
- * @input {boolean} If true, activates a transparent button style without a border.
- */
- set: function (val) {
- this._attr('_style', 'clear', val);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Button.prototype, "solid", {
- /**
- * @input {boolean} If true, activates a solid button style. Normally the default, useful for buttons in a toolbar.
- */
- set: function (val) {
- this._attr('_style', 'solid', val);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Button.prototype, "round", {
- /**
- * @input {boolean} If true, activates a button with rounded corners.
- */
- set: function (val) {
- this._attr('_shape', 'round', val);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Button.prototype, "block", {
- /**
- * @input {boolean} If true, activates a button style that fills the available width.
- */
- set: function (val) {
- this._attr('_display', 'block', val);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Button.prototype, "full", {
- /**
- * @input {boolean} If true, activates a button style that fills the available width without
- * a left and right border.
- */
- set: function (val) {
- this._attr('_display', 'full', val);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Button.prototype, "strong", {
- /**
- * @input {boolean} If true, activates a button with a heavier font weight.
- */
- set: function (val) {
- this._attr('_decorator', 'strong', val);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Button.prototype, "mode", {
- /**
- * @input {string} The mode determines which platform styles to use.
- * Possible values are: `"ios"`, `"md"`, or `"wp"`.
- * For more information, see [Platform Styles](/docs/theming/platform-specific-styles).
- */
- set: function (val) {
- this._assignCss(false);
- this._mode = val;
- this._assignCss(true);
- },
- enumerable: true,
- configurable: true
- });
- /** @hidden */
- Button.prototype._attr = function (type, attrName, attrValue) {
- if (type === '_style') {
- this._updateColor(this._color, false);
- }
- this._setClass(this[type], false);
- if (isTrueProperty(attrValue)) {
- this[type] = attrName;
- this._setClass(attrName, true);
- }
- else {
- // Special handling for '_style' which defaults to 'default'.
- this[type] = (type === '_style' ? 'default' : null);
- this._setClass(this[type], true);
- }
- if (type === '_style') {
- this._updateColor(this._color, true);
- }
- };
- Object.defineProperty(Button.prototype, "color", {
- /**
- * @input {string} The color to use from your Sass `$colors` map.
- * Default options are: `"primary"`, `"secondary"`, `"danger"`, `"light"`, and `"dark"`.
- * For more information, see [Theming your App](/docs/theming/theming-your-app).
- */
- set: function (val) {
- this._updateColor(this._color, false);
- this._updateColor(val, true);
- this._color = val;
- },
- enumerable: true,
- configurable: true
- });
- /** @hidden */
- Button.prototype.ngAfterContentInit = function () {
- this._init = true;
- this._assignCss(true);
- };
- /**
- * @hidden
- */
- Button.prototype.setRole = function (val) {
- this._assignCss(false);
- this._role = val;
- this._assignCss(true);
- };
- /**
- * @hidden
- */
- Button.prototype._assignCss = function (assignCssClass) {
- var role = this._role;
- if (role) {
- this.setElementClass(role, assignCssClass); // button
- this.setElementClass(role + "-" + this._mode, assignCssClass); // button
- this._setClass(this._style, assignCssClass); // button-clear
- this._setClass(this._shape, assignCssClass); // button-round
- this._setClass(this._display, assignCssClass); // button-full
- this._setClass(this._size, assignCssClass); // button-small
- this._setClass(this._decorator, assignCssClass); // button-strong
- this._updateColor(this._color, assignCssClass); // button-secondary, bar-button-secondary
- }
- };
- /**
- * @hidden
- */
- Button.prototype._setClass = function (type, assignCssClass) {
- if (type && this._init) {
- type = type.toLocaleLowerCase();
- this.setElementClass(this._role + "-" + type, assignCssClass);
- this.setElementClass(this._role + "-" + type + "-" + this._mode, assignCssClass);
- }
- };
- /**
- * @hidden
- */
- Button.prototype._updateColor = function (color, isAdd) {
- if (color && this._init) {
- // The class should begin with the button role
- // button, bar-button
- var className = this._role;
- // If the role is not a bar-button, don't apply the solid style
- var style$$1 = this._style;
- style$$1 = (this._role !== 'bar-button' && style$$1 === 'solid' ? 'default' : style$$1);
- className += (style$$1 !== null && style$$1 !== '' && style$$1 !== 'default' ? '-' + style$$1.toLowerCase() : '');
- if (color !== null && color !== '') {
- this.setElementClass(className + "-" + this._mode + "-" + color, isAdd);
- }
- }
- };
- Button.decorators = [
- { type: Component, args: [{
- selector: '[ion-button]',
- template: '<span class="button-inner">' +
- '<ng-content></ng-content>' +
- '</span>' +
- '<div class="button-effect"></div>',
- changeDetection: ChangeDetectionStrategy.OnPush,
- encapsulation: ViewEncapsulation.None,
- },] },
- ];
- /** @nocollapse */
- Button.ctorParameters = function () { return [
- { type: undefined, decorators: [{ type: Attribute, args: ['ion-button',] },] },
- { type: Config, },
- { type: ElementRef, },
- { type: Renderer, },
- ]; };
- Button.propDecorators = {
- 'large': [{ type: Input },],
- 'small': [{ type: Input },],
- 'default': [{ type: Input },],
- 'outline': [{ type: Input },],
- 'clear': [{ type: Input },],
- 'solid': [{ type: Input },],
- 'round': [{ type: Input },],
- 'block': [{ type: Input },],
- 'full': [{ type: Input },],
- 'strong': [{ type: Input },],
- 'mode': [{ type: Input },],
- 'color': [{ type: Input },],
- };
- return Button;
- }(Ion));
-
- var __extends$30 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @hidden
- */
- var Card = (function (_super) {
- __extends$30(Card, _super);
- function Card(config, elementRef, renderer) {
- return _super.call(this, config, elementRef, renderer, 'card') || this;
- }
- Card.decorators = [
- { type: Directive, args: [{
- selector: 'ion-card'
- },] },
- ];
- /** @nocollapse */
- Card.ctorParameters = function () { return [
- { type: Config, },
- { type: ElementRef, },
- { type: Renderer, },
- ]; };
- return Card;
- }(Ion));
-
- var __extends$31 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @hidden
- */
- var CardContent = (function (_super) {
- __extends$31(CardContent, _super);
- function CardContent(config, elementRef, renderer) {
- return _super.call(this, config, elementRef, renderer, 'card-content') || this;
- }
- CardContent.decorators = [
- { type: Directive, args: [{
- selector: 'ion-card-content'
- },] },
- ];
- /** @nocollapse */
- CardContent.ctorParameters = function () { return [
- { type: Config, },
- { type: ElementRef, },
- { type: Renderer, },
- ]; };
- return CardContent;
- }(Ion));
-
- var __extends$32 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @hidden
- */
- var CardHeader = (function (_super) {
- __extends$32(CardHeader, _super);
- function CardHeader(config, elementRef, renderer) {
- return _super.call(this, config, elementRef, renderer, 'card-header') || this;
- }
- CardHeader.decorators = [
- { type: Directive, args: [{
- selector: 'ion-card-header'
- },] },
- ];
- /** @nocollapse */
- CardHeader.ctorParameters = function () { return [
- { type: Config, },
- { type: ElementRef, },
- { type: Renderer, },
- ]; };
- return CardHeader;
- }(Ion));
-
- var __extends$33 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @hidden
- */
- var CardTitle = (function (_super) {
- __extends$33(CardTitle, _super);
- function CardTitle(config, elementRef, renderer) {
- return _super.call(this, config, elementRef, renderer, 'card-title') || this;
- }
- CardTitle.decorators = [
- { type: Directive, args: [{
- selector: 'ion-card-title'
- },] },
- ];
- /** @nocollapse */
- CardTitle.ctorParameters = function () { return [
- { type: Config, },
- { type: ElementRef, },
- { type: Renderer, },
- ]; };
- return CardTitle;
- }(Ion));
-
- var __extends$35 = (commonjsGlobal && commonjsGlobal.__extends) || function (d, b) {
- for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
-
-
-
-
-
- /**
- * We need this JSDoc comment for affecting ESDoc.
- * @extends {Ignored}
- * @hide true
- */
- var ForkJoinObservable = (function (_super) {
- __extends$35(ForkJoinObservable, _super);
- function ForkJoinObservable(sources, resultSelector) {
- _super.call(this);
- this.sources = sources;
- this.resultSelector = resultSelector;
- }
- /* tslint:enable:max-line-length */
- /**
- * @param sources
- * @return {any}
- * @static true
- * @name forkJoin
- * @owner Observable
- */
- ForkJoinObservable.create = function () {
- var sources = [];
- for (var _i = 0; _i < arguments.length; _i++) {
- sources[_i - 0] = arguments[_i];
- }
- if (sources === null || arguments.length === 0) {
- return new EmptyObservable_1.EmptyObservable();
- }
- var resultSelector = null;
- if (typeof sources[sources.length - 1] === 'function') {
- resultSelector = sources.pop();
- }
- // if the first and only other argument besides the resultSelector is an array
- // assume it's been called with `forkJoin([obs1, obs2, obs3], resultSelector)`
- if (sources.length === 1 && isArray.isArray(sources[0])) {
- sources = sources[0];
- }
- if (sources.length === 0) {
- return new EmptyObservable_1.EmptyObservable();
- }
- return new ForkJoinObservable(sources, resultSelector);
- };
- ForkJoinObservable.prototype._subscribe = function (subscriber) {
- return new ForkJoinSubscriber(subscriber, this.sources, this.resultSelector);
- };
- return ForkJoinObservable;
- }(Observable_1.Observable));
- var ForkJoinObservable_2 = ForkJoinObservable;
- /**
- * We need this JSDoc comment for affecting ESDoc.
- * @ignore
- * @extends {Ignored}
- */
- var ForkJoinSubscriber = (function (_super) {
- __extends$35(ForkJoinSubscriber, _super);
- function ForkJoinSubscriber(destination, sources, resultSelector) {
- _super.call(this, destination);
- this.sources = sources;
- this.resultSelector = resultSelector;
- this.completed = 0;
- this.haveValues = 0;
- var len = sources.length;
- this.total = len;
- this.values = new Array(len);
- for (var i = 0; i < len; i++) {
- var source = sources[i];
- var innerSubscription = subscribeToResult_1.subscribeToResult(this, source, null, i);
- if (innerSubscription) {
- innerSubscription.outerIndex = i;
- this.add(innerSubscription);
- }
- }
- }
- ForkJoinSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
- this.values[outerIndex] = innerValue;
- if (!innerSub._hasValue) {
- innerSub._hasValue = true;
- this.haveValues++;
- }
- };
- ForkJoinSubscriber.prototype.notifyComplete = function (innerSub) {
- var destination = this.destination;
- var _a = this, haveValues = _a.haveValues, resultSelector = _a.resultSelector, values = _a.values;
- var len = values.length;
- if (!innerSub._hasValue) {
- destination.complete();
- return;
- }
- this.completed++;
- if (this.completed !== len) {
- return;
- }
- if (haveValues === len) {
- var value = resultSelector ? resultSelector.apply(this, values) : values;
- destination.next(value);
- }
- destination.complete();
- };
- return ForkJoinSubscriber;
- }(OuterSubscriber_1.OuterSubscriber));
-
- var ForkJoinObservable_1 = {
- ForkJoinObservable: ForkJoinObservable_2
- };
-
- var forkJoin_1 = ForkJoinObservable_1.ForkJoinObservable.create;
-
- var __extends$36 = (commonjsGlobal && commonjsGlobal.__extends) || function (d, b) {
- for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
-
-
- /**
- * We need this JSDoc comment for affecting ESDoc.
- * @extends {Ignored}
- * @hide true
- */
- var PromiseObservable = (function (_super) {
- __extends$36(PromiseObservable, _super);
- function PromiseObservable(promise, scheduler) {
- _super.call(this);
- this.promise = promise;
- this.scheduler = scheduler;
- }
- /**
- * Converts a Promise to an Observable.
- *
- * <span class="informal">Returns an Observable that just emits the Promise's
- * resolved value, then completes.</span>
- *
- * Converts an ES2015 Promise or a Promises/A+ spec compliant Promise to an
- * Observable. If the Promise resolves with a value, the output Observable
- * emits that resolved value as a `next`, and then completes. If the Promise
- * is rejected, then the output Observable emits the corresponding Error.
- *
- * @example <caption>Convert the Promise returned by Fetch to an Observable</caption>
- * var result = Rx.Observable.fromPromise(fetch('http://myserver.com/'));
- * result.subscribe(x => console.log(x), e => console.error(e));
- *
- * @see {@link bindCallback}
- * @see {@link from}
- *
- * @param {PromiseLike<T>} promise The promise to be converted.
- * @param {Scheduler} [scheduler] An optional IScheduler to use for scheduling
- * the delivery of the resolved value (or the rejection).
- * @return {Observable<T>} An Observable which wraps the Promise.
- * @static true
- * @name fromPromise
- * @owner Observable
- */
- PromiseObservable.create = function (promise, scheduler) {
- return new PromiseObservable(promise, scheduler);
- };
- PromiseObservable.prototype._subscribe = function (subscriber) {
- var _this = this;
- var promise = this.promise;
- var scheduler = this.scheduler;
- if (scheduler == null) {
- if (this._isScalar) {
- if (!subscriber.closed) {
- subscriber.next(this.value);
- subscriber.complete();
- }
- }
- else {
- promise.then(function (value) {
- _this.value = value;
- _this._isScalar = true;
- if (!subscriber.closed) {
- subscriber.next(value);
- subscriber.complete();
- }
- }, function (err) {
- if (!subscriber.closed) {
- subscriber.error(err);
- }
- })
- .then(null, function (err) {
- // escape the promise trap, throw unhandled errors
- root.root.setTimeout(function () { throw err; });
- });
- }
- }
- else {
- if (this._isScalar) {
- if (!subscriber.closed) {
- return scheduler.schedule(dispatchNext, 0, { value: this.value, subscriber: subscriber });
- }
- }
- else {
- promise.then(function (value) {
- _this.value = value;
- _this._isScalar = true;
- if (!subscriber.closed) {
- subscriber.add(scheduler.schedule(dispatchNext, 0, { value: value, subscriber: subscriber }));
- }
- }, function (err) {
- if (!subscriber.closed) {
- subscriber.add(scheduler.schedule(dispatchError, 0, { err: err, subscriber: subscriber }));
- }
- })
- .then(null, function (err) {
- // escape the promise trap, throw unhandled errors
- root.root.setTimeout(function () { throw err; });
- });
- }
- }
- };
- return PromiseObservable;
- }(Observable_1.Observable));
- var PromiseObservable_2 = PromiseObservable;
- function dispatchNext(arg) {
- var value = arg.value, subscriber = arg.subscriber;
- if (!subscriber.closed) {
- subscriber.next(value);
- subscriber.complete();
- }
- }
- function dispatchError(arg) {
- var err = arg.err, subscriber = arg.subscriber;
- if (!subscriber.closed) {
- subscriber.error(err);
- }
- }
-
- var PromiseObservable_1 = {
- PromiseObservable: PromiseObservable_2
- };
-
- var fromPromise_1 = PromiseObservable_1.PromiseObservable.create;
-
- var __extends$37 = (commonjsGlobal && commonjsGlobal.__extends) || function (d, b) {
- for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
-
- /**
- * Applies a given `project` function to each value emitted by the source
- * Observable, and emits the resulting values as an Observable.
- *
- * <span class="informal">Like [Array.prototype.map()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map),
- * it passes each source value through a transformation function to get
- * corresponding output values.</span>
- *
- * <img src="./img/map.png" width="100%">
- *
- * Similar to the well known `Array.prototype.map` function, this operator
- * applies a projection to each value and emits that projection in the output
- * Observable.
- *
- * @example <caption>Map every click to the clientX position of that click</caption>
- * var clicks = Rx.Observable.fromEvent(document, 'click');
- * var positions = clicks.map(ev => ev.clientX);
- * positions.subscribe(x => console.log(x));
- *
- * @see {@link mapTo}
- * @see {@link pluck}
- *
- * @param {function(value: T, index: number): R} project The function to apply
- * to each `value` emitted by the source Observable. The `index` parameter is
- * the number `i` for the i-th emission that has happened since the
- * subscription, starting from the number `0`.
- * @param {any} [thisArg] An optional argument to define what `this` is in the
- * `project` function.
- * @return {Observable<R>} An Observable that emits the values from the source
- * Observable transformed by the given `project` function.
- * @method map
- * @owner Observable
- */
- function map(project, thisArg) {
- if (typeof project !== 'function') {
- throw new TypeError('argument is not a function. Are you looking for `mapTo()`?');
- }
- return this.lift(new MapOperator(project, thisArg));
- }
- var map_2 = map;
- var MapOperator = (function () {
- function MapOperator(project, thisArg) {
- this.project = project;
- this.thisArg = thisArg;
- }
- MapOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new MapSubscriber(subscriber, this.project, this.thisArg));
- };
- return MapOperator;
- }());
- /**
- * We need this JSDoc comment for affecting ESDoc.
- * @ignore
- * @extends {Ignored}
- */
- var MapSubscriber = (function (_super) {
- __extends$37(MapSubscriber, _super);
- function MapSubscriber(destination, project, thisArg) {
- _super.call(this, destination);
- this.project = project;
- this.count = 0;
- this.thisArg = thisArg || this;
- }
- // NOTE: This looks unoptimized, but it's actually purposefully NOT
- // using try/catch optimizations.
- MapSubscriber.prototype._next = function (value) {
- var result;
- try {
- result = this.project.call(this.thisArg, value, this.count++);
- }
- catch (err) {
- this.destination.error(err);
- return;
- }
- this.destination.next(result);
- };
- return MapSubscriber;
- }(Subscriber_1.Subscriber));
-
- /**
- * @license Angular v4.4.6
- * (c) 2010-2017 Google, Inc. https://angular.io/
- * License: MIT
- */
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * Base class for control directives.
- *
- * Only used internally in the forms module.
- *
- * \@stable
- * @abstract
- */
- var AbstractControlDirective = (function () {
- function AbstractControlDirective() {
- }
- /**
- * The {\@link FormControl}, {\@link FormGroup}, or {\@link FormArray}
- * that backs this directive. Most properties fall through to that
- * instance.
- * @abstract
- * @return {?}
- */
- AbstractControlDirective.prototype.control = function () { };
- Object.defineProperty(AbstractControlDirective.prototype, "value", {
- /**
- * The value of the control.
- * @return {?}
- */
- get: function () { return this.control ? this.control.value : null; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(AbstractControlDirective.prototype, "valid", {
- /**
- * A control is `valid` when its `status === VALID`.
- *
- * In order to have this status, the control must have passed all its
- * validation checks.
- * @return {?}
- */
- get: function () { return this.control ? this.control.valid : null; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(AbstractControlDirective.prototype, "invalid", {
- /**
- * A control is `invalid` when its `status === INVALID`.
- *
- * In order to have this status, the control must have failed
- * at least one of its validation checks.
- * @return {?}
- */
- get: function () { return this.control ? this.control.invalid : null; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(AbstractControlDirective.prototype, "pending", {
- /**
- * A control is `pending` when its `status === PENDING`.
- *
- * In order to have this status, the control must be in the
- * middle of conducting a validation check.
- * @return {?}
- */
- get: function () { return this.control ? this.control.pending : null; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(AbstractControlDirective.prototype, "disabled", {
- /**
- * A control is `disabled` when its `status === DISABLED`.
- *
- * Disabled controls are exempt from validation checks and
- * are not included in the aggregate value of their ancestor
- * controls.
- * @return {?}
- */
- get: function () { return this.control ? this.control.disabled : null; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(AbstractControlDirective.prototype, "enabled", {
- /**
- * A control is `enabled` as long as its `status !== DISABLED`.
- *
- * In other words, it has a status of `VALID`, `INVALID`, or
- * `PENDING`.
- * @return {?}
- */
- get: function () { return this.control ? this.control.enabled : null; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(AbstractControlDirective.prototype, "errors", {
- /**
- * Returns any errors generated by failing validation. If there
- * are no errors, it will return null.
- * @return {?}
- */
- get: function () { return this.control ? this.control.errors : null; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(AbstractControlDirective.prototype, "pristine", {
- /**
- * A control is `pristine` if the user has not yet changed
- * the value in the UI.
- *
- * Note that programmatic changes to a control's value will
- * *not* mark it dirty.
- * @return {?}
- */
- get: function () { return this.control ? this.control.pristine : null; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(AbstractControlDirective.prototype, "dirty", {
- /**
- * A control is `dirty` if the user has changed the value
- * in the UI.
- *
- * Note that programmatic changes to a control's value will
- * *not* mark it dirty.
- * @return {?}
- */
- get: function () { return this.control ? this.control.dirty : null; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(AbstractControlDirective.prototype, "touched", {
- /**
- * A control is marked `touched` once the user has triggered
- * a `blur` event on it.
- * @return {?}
- */
- get: function () { return this.control ? this.control.touched : null; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(AbstractControlDirective.prototype, "untouched", {
- /**
- * A control is `untouched` if the user has not yet triggered
- * a `blur` event on it.
- * @return {?}
- */
- get: function () { return this.control ? this.control.untouched : null; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(AbstractControlDirective.prototype, "statusChanges", {
- /**
- * Emits an event every time the validation status of the control
- * is re-calculated.
- * @return {?}
- */
- get: function () {
- return this.control ? this.control.statusChanges : null;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(AbstractControlDirective.prototype, "valueChanges", {
- /**
- * Emits an event every time the value of the control changes, in
- * the UI or programmatically.
- * @return {?}
- */
- get: function () {
- return this.control ? this.control.valueChanges : null;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(AbstractControlDirective.prototype, "path", {
- /**
- * Returns an array that represents the path from the top-level form
- * to this control. Each index is the string name of the control on
- * that level.
- * @return {?}
- */
- get: function () { return null; },
- enumerable: true,
- configurable: true
- });
- /**
- * Resets the form control. This means by default:
- *
- * * it is marked as `pristine`
- * * it is marked as `untouched`
- * * value is set to null
- *
- * For more information, see {\@link AbstractControl}.
- * @param {?=} value
- * @return {?}
- */
- AbstractControlDirective.prototype.reset = function (value) {
- if (value === void 0) { value = undefined; }
- if (this.control)
- this.control.reset(value);
- };
- /**
- * Returns true if the control with the given path has the error specified. Otherwise
- * returns false.
- *
- * If no path is given, it checks for the error on the present control.
- * @param {?} errorCode
- * @param {?=} path
- * @return {?}
- */
- AbstractControlDirective.prototype.hasError = function (errorCode, path) {
- return this.control ? this.control.hasError(errorCode, path) : false;
- };
- /**
- * Returns error data if the control with the given path has the error specified. Otherwise
- * returns null or undefined.
- *
- * If no path is given, it checks for the error on the present control.
- * @param {?} errorCode
- * @param {?=} path
- * @return {?}
- */
- AbstractControlDirective.prototype.getError = function (errorCode, path) {
- return this.control ? this.control.getError(errorCode, path) : null;
- };
- return AbstractControlDirective;
- }());
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * A directive that contains multiple {\@link NgControl}s.
- *
- * Only used by the forms module.
- *
- * \@stable
- * @abstract
- */
- var ControlContainer = (function (_super) {
- __extends$1(ControlContainer, _super);
- function ControlContainer() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- Object.defineProperty(ControlContainer.prototype, "formDirective", {
- /**
- * Get the form to which this container belongs.
- * @return {?}
- */
- get: function () { return null; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(ControlContainer.prototype, "path", {
- /**
- * Get the path to this container.
- * @return {?}
- */
- get: function () { return null; },
- enumerable: true,
- configurable: true
- });
- return ControlContainer;
- }(AbstractControlDirective));
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * @param {?} value
- * @return {?}
- */
- function isEmptyInputValue(value) {
- // we don't check for string here so it also works with arrays
- return value == null || value.length === 0;
- }
- /**
- * Providers for validators to be used for {\@link FormControl}s in a form.
- *
- * Provide this using `multi: true` to add validators.
- *
- * \@stable
- */
- var NG_VALIDATORS = new InjectionToken('NgValidators');
- /**
- * Providers for asynchronous validators to be used for {\@link FormControl}s
- * in a form.
- *
- * Provide this using `multi: true` to add validators.
- *
- * See {\@link NG_VALIDATORS} for more details.
- *
- * \@stable
- */
- var NG_ASYNC_VALIDATORS = new InjectionToken('NgAsyncValidators');
- var EMAIL_REGEXP = /^(?=.{1,254}$)(?=.{1,64}@)[-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+(\.[-!#$%&'*+/0-9=?A-Z^_`a-z{|}~]+)*@[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?(\.[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*$/;
- /**
- * Provides a set of validators used by form controls.
- *
- * A validator is a function that processes a {\@link FormControl} or collection of
- * controls and returns a map of errors. A null map means that validation has passed.
- *
- * ### Example
- *
- * ```typescript
- * var loginControl = new FormControl("", Validators.required)
- * ```
- *
- * \@stable
- */
- var Validators = (function () {
- function Validators() {
- }
- /**
- * Validator that requires controls to have a value greater than a number.
- * @param {?} min
- * @return {?}
- */
- Validators.min = function (min) {
- return function (control) {
- if (isEmptyInputValue(control.value) || isEmptyInputValue(min)) {
- return null; // don't validate empty values to allow optional controls
- }
- var /** @type {?} */ value = parseFloat(control.value);
- // Controls with NaN values after parsing should be treated as not having a
- // minimum, per the HTML forms spec: https://www.w3.org/TR/html5/forms.html#attr-input-min
- return !isNaN(value) && value < min ? { 'min': { 'min': min, 'actual': control.value } } : null;
- };
- };
- /**
- * Validator that requires controls to have a value less than a number.
- * @param {?} max
- * @return {?}
- */
- Validators.max = function (max) {
- return function (control) {
- if (isEmptyInputValue(control.value) || isEmptyInputValue(max)) {
- return null; // don't validate empty values to allow optional controls
- }
- var /** @type {?} */ value = parseFloat(control.value);
- // Controls with NaN values after parsing should be treated as not having a
- // maximum, per the HTML forms spec: https://www.w3.org/TR/html5/forms.html#attr-input-max
- return !isNaN(value) && value > max ? { 'max': { 'max': max, 'actual': control.value } } : null;
- };
- };
- /**
- * Validator that requires controls to have a non-empty value.
- * @param {?} control
- * @return {?}
- */
- Validators.required = function (control) {
- return isEmptyInputValue(control.value) ? { 'required': true } : null;
- };
- /**
- * Validator that requires control value to be true.
- * @param {?} control
- * @return {?}
- */
- Validators.requiredTrue = function (control) {
- return control.value === true ? null : { 'required': true };
- };
- /**
- * Validator that performs email validation.
- * @param {?} control
- * @return {?}
- */
- Validators.email = function (control) {
- return EMAIL_REGEXP.test(control.value) ? null : { 'email': true };
- };
- /**
- * Validator that requires controls to have a value of a minimum length.
- * @param {?} minLength
- * @return {?}
- */
- Validators.minLength = function (minLength) {
- return function (control) {
- if (isEmptyInputValue(control.value)) {
- return null; // don't validate empty values to allow optional controls
- }
- var /** @type {?} */ length = control.value ? control.value.length : 0;
- return length < minLength ?
- { 'minlength': { 'requiredLength': minLength, 'actualLength': length } } :
- null;
- };
- };
- /**
- * Validator that requires controls to have a value of a maximum length.
- * @param {?} maxLength
- * @return {?}
- */
- Validators.maxLength = function (maxLength) {
- return function (control) {
- var /** @type {?} */ length = control.value ? control.value.length : 0;
- return length > maxLength ?
- { 'maxlength': { 'requiredLength': maxLength, 'actualLength': length } } :
- null;
- };
- };
- /**
- * Validator that requires a control to match a regex to its value.
- * @param {?} pattern
- * @return {?}
- */
- Validators.pattern = function (pattern) {
- if (!pattern)
- return Validators.nullValidator;
- var /** @type {?} */ regex;
- var /** @type {?} */ regexStr;
- if (typeof pattern === 'string') {
- regexStr = "^" + pattern + "$";
- regex = new RegExp(regexStr);
- }
- else {
- regexStr = pattern.toString();
- regex = pattern;
- }
- return function (control) {
- if (isEmptyInputValue(control.value)) {
- return null; // don't validate empty values to allow optional controls
- }
- var /** @type {?} */ value = control.value;
- return regex.test(value) ? null :
- { 'pattern': { 'requiredPattern': regexStr, 'actualValue': value } };
- };
- };
- /**
- * No-op validator.
- * @param {?} c
- * @return {?}
- */
- Validators.nullValidator = function (c) { return null; };
- /**
- * @param {?} validators
- * @return {?}
- */
- Validators.compose = function (validators) {
- if (!validators)
- return null;
- var /** @type {?} */ presentValidators = (validators.filter(isPresent$1));
- if (presentValidators.length == 0)
- return null;
- return function (control) {
- return _mergeErrors(_executeValidators(control, presentValidators));
- };
- };
- /**
- * @param {?} validators
- * @return {?}
- */
- Validators.composeAsync = function (validators) {
- if (!validators)
- return null;
- var /** @type {?} */ presentValidators = (validators.filter(isPresent$1));
- if (presentValidators.length == 0)
- return null;
- return function (control) {
- var /** @type {?} */ observables = _executeAsyncValidators(control, presentValidators).map(toObservable);
- return map_2.call(forkJoin_1(observables), _mergeErrors);
- };
- };
- return Validators;
- }());
- /**
- * @param {?} o
- * @return {?}
- */
- function isPresent$1(o) {
- return o != null;
- }
- /**
- * @param {?} r
- * @return {?}
- */
- function toObservable(r) {
- var /** @type {?} */ obs = isPromise(r) ? fromPromise_1(r) : r;
- if (!(isObservable(obs))) {
- throw new Error("Expected validator to return Promise or Observable.");
- }
- return obs;
- }
- /**
- * @param {?} control
- * @param {?} validators
- * @return {?}
- */
- function _executeValidators(control, validators) {
- return validators.map(function (v) { return v(control); });
- }
- /**
- * @param {?} control
- * @param {?} validators
- * @return {?}
- */
- function _executeAsyncValidators(control, validators) {
- return validators.map(function (v) { return v(control); });
- }
- /**
- * @param {?} arrayOfErrors
- * @return {?}
- */
- function _mergeErrors(arrayOfErrors) {
- var /** @type {?} */ res = arrayOfErrors.reduce(function (res, errors) {
- return errors != null ? Object.assign({}, /** @type {?} */ ((res)), errors) : ((res));
- }, {});
- return Object.keys(res).length === 0 ? null : res;
- }
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * Used to provide a {\@link ControlValueAccessor} for form controls.
- *
- * See {\@link DefaultValueAccessor} for how to implement one.
- * \@stable
- */
- var NG_VALUE_ACCESSOR = new InjectionToken('NgValueAccessor');
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var CHECKBOX_VALUE_ACCESSOR = {
- provide: NG_VALUE_ACCESSOR,
- useExisting: forwardRef(function () { return CheckboxControlValueAccessor; }),
- multi: true,
- };
- /**
- * The accessor for writing a value and listening to changes on a checkbox input element.
- *
- * ### Example
- * ```
- * <input type="checkbox" name="rememberLogin" ngModel>
- * ```
- *
- * \@stable
- */
- var CheckboxControlValueAccessor = (function () {
- /**
- * @param {?} _renderer
- * @param {?} _elementRef
- */
- function CheckboxControlValueAccessor(_renderer, _elementRef) {
- this._renderer = _renderer;
- this._elementRef = _elementRef;
- this.onChange = function (_) { };
- this.onTouched = function () { };
- }
- /**
- * @param {?} value
- * @return {?}
- */
- CheckboxControlValueAccessor.prototype.writeValue = function (value) {
- this._renderer.setProperty(this._elementRef.nativeElement, 'checked', value);
- };
- /**
- * @param {?} fn
- * @return {?}
- */
- CheckboxControlValueAccessor.prototype.registerOnChange = function (fn) { this.onChange = fn; };
- /**
- * @param {?} fn
- * @return {?}
- */
- CheckboxControlValueAccessor.prototype.registerOnTouched = function (fn) { this.onTouched = fn; };
- /**
- * @param {?} isDisabled
- * @return {?}
- */
- CheckboxControlValueAccessor.prototype.setDisabledState = function (isDisabled) {
- this._renderer.setProperty(this._elementRef.nativeElement, 'disabled', isDisabled);
- };
- return CheckboxControlValueAccessor;
- }());
- CheckboxControlValueAccessor.decorators = [
- { type: Directive, args: [{
- selector: 'input[type=checkbox][formControlName],input[type=checkbox][formControl],input[type=checkbox][ngModel]',
- host: { '(change)': 'onChange($event.target.checked)', '(blur)': 'onTouched()' },
- providers: [CHECKBOX_VALUE_ACCESSOR]
- },] },
- ];
- /**
- * @nocollapse
- */
- CheckboxControlValueAccessor.ctorParameters = function () { return [
- { type: Renderer2, },
- { type: ElementRef, },
- ]; };
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var DEFAULT_VALUE_ACCESSOR = {
- provide: NG_VALUE_ACCESSOR,
- useExisting: forwardRef(function () { return DefaultValueAccessor; }),
- multi: true
- };
- /**
- * We must check whether the agent is Android because composition events
- * behave differently between iOS and Android.
- * @return {?}
- */
- function _isAndroid() {
- var /** @type {?} */ userAgent = getDOM() ? getDOM().getUserAgent() : '';
- return /android (\d+)/.test(userAgent.toLowerCase());
- }
- /**
- * Turn this mode on if you want form directives to buffer IME input until compositionend
- * \@experimental
- */
- var COMPOSITION_BUFFER_MODE = new InjectionToken('CompositionEventMode');
- /**
- * The default accessor for writing a value and listening to changes that is used by the
- * {\@link NgModel}, {\@link FormControlDirective}, and {\@link FormControlName} directives.
- *
- * ### Example
- * ```
- * <input type="text" name="searchQuery" ngModel>
- * ```
- *
- * \@stable
- */
- var DefaultValueAccessor = (function () {
- /**
- * @param {?} _renderer
- * @param {?} _elementRef
- * @param {?} _compositionMode
- */
- function DefaultValueAccessor(_renderer, _elementRef, _compositionMode) {
- this._renderer = _renderer;
- this._elementRef = _elementRef;
- this._compositionMode = _compositionMode;
- this.onChange = function (_) { };
- this.onTouched = function () { };
- /**
- * Whether the user is creating a composition string (IME events).
- */
- this._composing = false;
- if (this._compositionMode == null) {
- this._compositionMode = !_isAndroid();
- }
- }
- /**
- * @param {?} value
- * @return {?}
- */
- DefaultValueAccessor.prototype.writeValue = function (value) {
- var /** @type {?} */ normalizedValue = value == null ? '' : value;
- this._renderer.setProperty(this._elementRef.nativeElement, 'value', normalizedValue);
- };
- /**
- * @param {?} fn
- * @return {?}
- */
- DefaultValueAccessor.prototype.registerOnChange = function (fn) { this.onChange = fn; };
- /**
- * @param {?} fn
- * @return {?}
- */
- DefaultValueAccessor.prototype.registerOnTouched = function (fn) { this.onTouched = fn; };
- /**
- * @param {?} isDisabled
- * @return {?}
- */
- DefaultValueAccessor.prototype.setDisabledState = function (isDisabled) {
- this._renderer.setProperty(this._elementRef.nativeElement, 'disabled', isDisabled);
- };
- /**
- * \@internal
- * @param {?} value
- * @return {?}
- */
- DefaultValueAccessor.prototype._handleInput = function (value) {
- if (!this._compositionMode || (this._compositionMode && !this._composing)) {
- this.onChange(value);
- }
- };
- /**
- * \@internal
- * @return {?}
- */
- DefaultValueAccessor.prototype._compositionStart = function () { this._composing = true; };
- /**
- * \@internal
- * @param {?} value
- * @return {?}
- */
- DefaultValueAccessor.prototype._compositionEnd = function (value) {
- this._composing = false;
- this._compositionMode && this.onChange(value);
- };
- return DefaultValueAccessor;
- }());
- DefaultValueAccessor.decorators = [
- { type: Directive, args: [{
- selector: 'input:not([type=checkbox])[formControlName],textarea[formControlName],input:not([type=checkbox])[formControl],textarea[formControl],input:not([type=checkbox])[ngModel],textarea[ngModel],[ngDefaultControl]',
- // TODO: vsavkin replace the above selector with the one below it once
- // https://github.com/angular/angular/issues/3011 is implemented
- // selector: '[ngModel],[formControl],[formControlName]',
- host: {
- '(input)': '_handleInput($event.target.value)',
- '(blur)': 'onTouched()',
- '(compositionstart)': '_compositionStart()',
- '(compositionend)': '_compositionEnd($event.target.value)'
- },
- providers: [DEFAULT_VALUE_ACCESSOR]
- },] },
- ];
- /**
- * @nocollapse
- */
- DefaultValueAccessor.ctorParameters = function () { return [
- { type: Renderer2, },
- { type: ElementRef, },
- { type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [COMPOSITION_BUFFER_MODE,] },] },
- ]; };
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * @param {?} validator
- * @return {?}
- */
- function normalizeValidator(validator) {
- if (((validator)).validate) {
- return function (c) { return ((validator)).validate(c); };
- }
- else {
- return (validator);
- }
- }
- /**
- * @param {?} validator
- * @return {?}
- */
- function normalizeAsyncValidator(validator) {
- if (((validator)).validate) {
- return function (c) { return ((validator)).validate(c); };
- }
- else {
- return (validator);
- }
- }
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var NUMBER_VALUE_ACCESSOR = {
- provide: NG_VALUE_ACCESSOR,
- useExisting: forwardRef(function () { return NumberValueAccessor; }),
- multi: true
- };
- /**
- * The accessor for writing a number value and listening to changes that is used by the
- * {\@link NgModel}, {\@link FormControlDirective}, and {\@link FormControlName} directives.
- *
- * ### Example
- * ```
- * <input type="number" [(ngModel)]="age">
- * ```
- */
- var NumberValueAccessor = (function () {
- /**
- * @param {?} _renderer
- * @param {?} _elementRef
- */
- function NumberValueAccessor(_renderer, _elementRef) {
- this._renderer = _renderer;
- this._elementRef = _elementRef;
- this.onChange = function (_) { };
- this.onTouched = function () { };
- }
- /**
- * @param {?} value
- * @return {?}
- */
- NumberValueAccessor.prototype.writeValue = function (value) {
- // The value needs to be normalized for IE9, otherwise it is set to 'null' when null
- var /** @type {?} */ normalizedValue = value == null ? '' : value;
- this._renderer.setProperty(this._elementRef.nativeElement, 'value', normalizedValue);
- };
- /**
- * @param {?} fn
- * @return {?}
- */
- NumberValueAccessor.prototype.registerOnChange = function (fn) {
- this.onChange = function (value) { fn(value == '' ? null : parseFloat(value)); };
- };
- /**
- * @param {?} fn
- * @return {?}
- */
- NumberValueAccessor.prototype.registerOnTouched = function (fn) { this.onTouched = fn; };
- /**
- * @param {?} isDisabled
- * @return {?}
- */
- NumberValueAccessor.prototype.setDisabledState = function (isDisabled) {
- this._renderer.setProperty(this._elementRef.nativeElement, 'disabled', isDisabled);
- };
- return NumberValueAccessor;
- }());
- NumberValueAccessor.decorators = [
- { type: Directive, args: [{
- selector: 'input[type=number][formControlName],input[type=number][formControl],input[type=number][ngModel]',
- host: {
- '(change)': 'onChange($event.target.value)',
- '(input)': 'onChange($event.target.value)',
- '(blur)': 'onTouched()'
- },
- providers: [NUMBER_VALUE_ACCESSOR]
- },] },
- ];
- /**
- * @nocollapse
- */
- NumberValueAccessor.ctorParameters = function () { return [
- { type: Renderer2, },
- { type: ElementRef, },
- ]; };
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * @return {?}
- */
- function unimplemented() {
- throw new Error('unimplemented');
- }
- /**
- * A base class that all control directive extend.
- * It binds a {\@link FormControl} object to a DOM element.
- *
- * Used internally by Angular forms.
- *
- * \@stable
- * @abstract
- */
- var NgControl = (function (_super) {
- __extends$1(NgControl, _super);
- function NgControl() {
- var _this = _super.apply(this, arguments) || this;
- /**
- * \@internal
- */
- _this._parent = null;
- _this.name = null;
- _this.valueAccessor = null;
- /**
- * \@internal
- */
- _this._rawValidators = [];
- /**
- * \@internal
- */
- _this._rawAsyncValidators = [];
- return _this;
- }
- Object.defineProperty(NgControl.prototype, "validator", {
- /**
- * @return {?}
- */
- get: function () { return (unimplemented()); },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(NgControl.prototype, "asyncValidator", {
- /**
- * @return {?}
- */
- get: function () { return (unimplemented()); },
- enumerable: true,
- configurable: true
- });
- /**
- * @abstract
- * @param {?} newValue
- * @return {?}
- */
- NgControl.prototype.viewToModelUpdate = function (newValue) { };
- return NgControl;
- }(AbstractControlDirective));
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var RADIO_VALUE_ACCESSOR = {
- provide: NG_VALUE_ACCESSOR,
- useExisting: forwardRef(function () { return RadioControlValueAccessor; }),
- multi: true
- };
- /**
- * Internal class used by Angular to uncheck radio buttons with the matching name.
- */
- var RadioControlRegistry = (function () {
- function RadioControlRegistry() {
- this._accessors = [];
- }
- /**
- * @param {?} control
- * @param {?} accessor
- * @return {?}
- */
- RadioControlRegistry.prototype.add = function (control, accessor) {
- this._accessors.push([control, accessor]);
- };
- /**
- * @param {?} accessor
- * @return {?}
- */
- RadioControlRegistry.prototype.remove = function (accessor) {
- for (var /** @type {?} */ i = this._accessors.length - 1; i >= 0; --i) {
- if (this._accessors[i][1] === accessor) {
- this._accessors.splice(i, 1);
- return;
- }
- }
- };
- /**
- * @param {?} accessor
- * @return {?}
- */
- RadioControlRegistry.prototype.select = function (accessor) {
- var _this = this;
- this._accessors.forEach(function (c) {
- if (_this._isSameGroup(c, accessor) && c[1] !== accessor) {
- c[1].fireUncheck(accessor.value);
- }
- });
- };
- /**
- * @param {?} controlPair
- * @param {?} accessor
- * @return {?}
- */
- RadioControlRegistry.prototype._isSameGroup = function (controlPair, accessor) {
- if (!controlPair[0].control)
- return false;
- return controlPair[0]._parent === accessor._control._parent &&
- controlPair[1].name === accessor.name;
- };
- return RadioControlRegistry;
- }());
- RadioControlRegistry.decorators = [
- { type: Injectable },
- ];
- /**
- * @nocollapse
- */
- RadioControlRegistry.ctorParameters = function () { return []; };
- /**
- * \@whatItDoes Writes radio control values and listens to radio control changes.
- *
- * Used by {\@link NgModel}, {\@link FormControlDirective}, and {\@link FormControlName}
- * to keep the view synced with the {\@link FormControl} model.
- *
- * \@howToUse
- *
- * If you have imported the {\@link FormsModule} or the {\@link ReactiveFormsModule}, this
- * value accessor will be active on any radio control that has a form directive. You do
- * **not** need to add a special selector to activate it.
- *
- * ### How to use radio buttons with form directives
- *
- * To use radio buttons in a template-driven form, you'll want to ensure that radio buttons
- * in the same group have the same `name` attribute. Radio buttons with different `name`
- * attributes do not affect each other.
- *
- * {\@example forms/ts/radioButtons/radio_button_example.ts region='TemplateDriven'}
- *
- * When using radio buttons in a reactive form, radio buttons in the same group should have the
- * same `formControlName`. You can also add a `name` attribute, but it's optional.
- *
- * {\@example forms/ts/reactiveRadioButtons/reactive_radio_button_example.ts region='Reactive'}
- *
- * * **npm package**: `\@angular/forms`
- *
- * \@stable
- */
- var RadioControlValueAccessor = (function () {
- /**
- * @param {?} _renderer
- * @param {?} _elementRef
- * @param {?} _registry
- * @param {?} _injector
- */
- function RadioControlValueAccessor(_renderer, _elementRef, _registry, _injector) {
- this._renderer = _renderer;
- this._elementRef = _elementRef;
- this._registry = _registry;
- this._injector = _injector;
- this.onChange = function () { };
- this.onTouched = function () { };
- }
- /**
- * @return {?}
- */
- RadioControlValueAccessor.prototype.ngOnInit = function () {
- this._control = this._injector.get(NgControl);
- this._checkName();
- this._registry.add(this._control, this);
- };
- /**
- * @return {?}
- */
- RadioControlValueAccessor.prototype.ngOnDestroy = function () { this._registry.remove(this); };
- /**
- * @param {?} value
- * @return {?}
- */
- RadioControlValueAccessor.prototype.writeValue = function (value) {
- this._state = value === this.value;
- this._renderer.setProperty(this._elementRef.nativeElement, 'checked', this._state);
- };
- /**
- * @param {?} fn
- * @return {?}
- */
- RadioControlValueAccessor.prototype.registerOnChange = function (fn) {
- var _this = this;
- this._fn = fn;
- this.onChange = function () {
- fn(_this.value);
- _this._registry.select(_this);
- };
- };
- /**
- * @param {?} value
- * @return {?}
- */
- RadioControlValueAccessor.prototype.fireUncheck = function (value) { this.writeValue(value); };
- /**
- * @param {?} fn
- * @return {?}
- */
- RadioControlValueAccessor.prototype.registerOnTouched = function (fn) { this.onTouched = fn; };
- /**
- * @param {?} isDisabled
- * @return {?}
- */
- RadioControlValueAccessor.prototype.setDisabledState = function (isDisabled) {
- this._renderer.setProperty(this._elementRef.nativeElement, 'disabled', isDisabled);
- };
- /**
- * @return {?}
- */
- RadioControlValueAccessor.prototype._checkName = function () {
- if (this.name && this.formControlName && this.name !== this.formControlName) {
- this._throwNameError();
- }
- if (!this.name && this.formControlName)
- this.name = this.formControlName;
- };
- /**
- * @return {?}
- */
- RadioControlValueAccessor.prototype._throwNameError = function () {
- throw new Error("\n If you define both a name and a formControlName attribute on your radio button, their values\n must match. Ex: <input type=\"radio\" formControlName=\"food\" name=\"food\">\n ");
- };
- return RadioControlValueAccessor;
- }());
- RadioControlValueAccessor.decorators = [
- { type: Directive, args: [{
- selector: 'input[type=radio][formControlName],input[type=radio][formControl],input[type=radio][ngModel]',
- host: { '(change)': 'onChange()', '(blur)': 'onTouched()' },
- providers: [RADIO_VALUE_ACCESSOR]
- },] },
- ];
- /**
- * @nocollapse
- */
- RadioControlValueAccessor.ctorParameters = function () { return [
- { type: Renderer2, },
- { type: ElementRef, },
- { type: RadioControlRegistry, },
- { type: Injector, },
- ]; };
- RadioControlValueAccessor.propDecorators = {
- 'name': [{ type: Input },],
- 'formControlName': [{ type: Input },],
- 'value': [{ type: Input },],
- };
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var RANGE_VALUE_ACCESSOR = {
- provide: NG_VALUE_ACCESSOR,
- useExisting: forwardRef(function () { return RangeValueAccessor; }),
- multi: true
- };
- /**
- * The accessor for writing a range value and listening to changes that is used by the
- * {\@link NgModel}, {\@link FormControlDirective}, and {\@link FormControlName} directives.
- *
- * ### Example
- * ```
- * <input type="range" [(ngModel)]="age" >
- * ```
- */
- var RangeValueAccessor = (function () {
- /**
- * @param {?} _renderer
- * @param {?} _elementRef
- */
- function RangeValueAccessor(_renderer, _elementRef) {
- this._renderer = _renderer;
- this._elementRef = _elementRef;
- this.onChange = function (_) { };
- this.onTouched = function () { };
- }
- /**
- * @param {?} value
- * @return {?}
- */
- RangeValueAccessor.prototype.writeValue = function (value) {
- this._renderer.setProperty(this._elementRef.nativeElement, 'value', parseFloat(value));
- };
- /**
- * @param {?} fn
- * @return {?}
- */
- RangeValueAccessor.prototype.registerOnChange = function (fn) {
- this.onChange = function (value) { fn(value == '' ? null : parseFloat(value)); };
- };
- /**
- * @param {?} fn
- * @return {?}
- */
- RangeValueAccessor.prototype.registerOnTouched = function (fn) { this.onTouched = fn; };
- /**
- * @param {?} isDisabled
- * @return {?}
- */
- RangeValueAccessor.prototype.setDisabledState = function (isDisabled) {
- this._renderer.setProperty(this._elementRef.nativeElement, 'disabled', isDisabled);
- };
- return RangeValueAccessor;
- }());
- RangeValueAccessor.decorators = [
- { type: Directive, args: [{
- selector: 'input[type=range][formControlName],input[type=range][formControl],input[type=range][ngModel]',
- host: {
- '(change)': 'onChange($event.target.value)',
- '(input)': 'onChange($event.target.value)',
- '(blur)': 'onTouched()'
- },
- providers: [RANGE_VALUE_ACCESSOR]
- },] },
- ];
- /**
- * @nocollapse
- */
- RangeValueAccessor.ctorParameters = function () { return [
- { type: Renderer2, },
- { type: ElementRef, },
- ]; };
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var SELECT_VALUE_ACCESSOR = {
- provide: NG_VALUE_ACCESSOR,
- useExisting: forwardRef(function () { return SelectControlValueAccessor; }),
- multi: true
- };
- /**
- * @param {?} id
- * @param {?} value
- * @return {?}
- */
- function _buildValueString(id, value) {
- if (id == null)
- return "" + value;
- if (value && typeof value === 'object')
- value = 'Object';
- return (id + ": " + value).slice(0, 50);
- }
- /**
- * @param {?} valueString
- * @return {?}
- */
- function _extractId(valueString) {
- return valueString.split(':')[0];
- }
- /**
- * \@whatItDoes Writes values and listens to changes on a select element.
- *
- * Used by {\@link NgModel}, {\@link FormControlDirective}, and {\@link FormControlName}
- * to keep the view synced with the {\@link FormControl} model.
- *
- * \@howToUse
- *
- * If you have imported the {\@link FormsModule} or the {\@link ReactiveFormsModule}, this
- * value accessor will be active on any select control that has a form directive. You do
- * **not** need to add a special selector to activate it.
- *
- * ### How to use select controls with form directives
- *
- * To use a select in a template-driven form, simply add an `ngModel` and a `name`
- * attribute to the main `<select>` tag.
- *
- * If your option values are simple strings, you can bind to the normal `value` property
- * on the option. If your option values happen to be objects (and you'd like to save the
- * selection in your form as an object), use `ngValue` instead:
- *
- * {\@example forms/ts/selectControl/select_control_example.ts region='Component'}
- *
- * In reactive forms, you'll also want to add your form directive (`formControlName` or
- * `formControl`) on the main `<select>` tag. Like in the former example, you have the
- * choice of binding to the `value` or `ngValue` property on the select's options.
- *
- * {\@example forms/ts/reactiveSelectControl/reactive_select_control_example.ts region='Component'}
- *
- * ### Caveat: Option selection
- *
- * Angular uses object identity to select option. It's possible for the identities of items
- * to change while the data does not. This can happen, for example, if the items are produced
- * from an RPC to the server, and that RPC is re-run. Even if the data hasn't changed, the
- * second response will produce objects with different identities.
- *
- * To customize the default option comparison algorithm, `<select>` supports `compareWith` input.
- * `compareWith` takes a **function** which has two arguments: `option1` and `option2`.
- * If `compareWith` is given, Angular selects option by the return value of the function.
- *
- * #### Syntax
- *
- * ```
- * <select [compareWith]="compareFn" [(ngModel)]="selectedCountries">
- * <option *ngFor="let country of countries" [ngValue]="country">
- * {{country.name}}
- * </option>
- * </select>
- *
- * compareFn(c1: Country, c2: Country): boolean {
- * return c1 && c2 ? c1.id === c2.id : c1 === c2;
- * }
- * ```
- *
- * Note: We listen to the 'change' event because 'input' events aren't fired
- * for selects in Firefox and IE:
- * https://bugzilla.mozilla.org/show_bug.cgi?id=1024350
- * https://developer.microsoft.com/en-us/microsoft-edge/platform/issues/4660045/
- *
- * * **npm package**: `\@angular/forms`
- *
- * \@stable
- */
- var SelectControlValueAccessor = (function () {
- /**
- * @param {?} _renderer
- * @param {?} _elementRef
- */
- function SelectControlValueAccessor(_renderer, _elementRef) {
- this._renderer = _renderer;
- this._elementRef = _elementRef;
- /**
- * \@internal
- */
- this._optionMap = new Map();
- /**
- * \@internal
- */
- this._idCounter = 0;
- this.onChange = function (_) { };
- this.onTouched = function () { };
- this._compareWith = looseIdentical;
- }
- Object.defineProperty(SelectControlValueAccessor.prototype, "compareWith", {
- /**
- * @param {?} fn
- * @return {?}
- */
- set: function (fn) {
- if (typeof fn !== 'function') {
- throw new Error("compareWith must be a function, but received " + JSON.stringify(fn));
- }
- this._compareWith = fn;
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @param {?} value
- * @return {?}
- */
- SelectControlValueAccessor.prototype.writeValue = function (value) {
- this.value = value;
- var /** @type {?} */ id = this._getOptionId(value);
- if (id == null) {
- this._renderer.setProperty(this._elementRef.nativeElement, 'selectedIndex', -1);
- }
- var /** @type {?} */ valueString = _buildValueString(id, value);
- this._renderer.setProperty(this._elementRef.nativeElement, 'value', valueString);
- };
- /**
- * @param {?} fn
- * @return {?}
- */
- SelectControlValueAccessor.prototype.registerOnChange = function (fn) {
- var _this = this;
- this.onChange = function (valueString) {
- _this.value = _this._getOptionValue(valueString);
- fn(_this.value);
- };
- };
- /**
- * @param {?} fn
- * @return {?}
- */
- SelectControlValueAccessor.prototype.registerOnTouched = function (fn) { this.onTouched = fn; };
- /**
- * @param {?} isDisabled
- * @return {?}
- */
- SelectControlValueAccessor.prototype.setDisabledState = function (isDisabled) {
- this._renderer.setProperty(this._elementRef.nativeElement, 'disabled', isDisabled);
- };
- /**
- * \@internal
- * @return {?}
- */
- SelectControlValueAccessor.prototype._registerOption = function () { return (this._idCounter++).toString(); };
- /**
- * \@internal
- * @param {?} value
- * @return {?}
- */
- SelectControlValueAccessor.prototype._getOptionId = function (value) {
- for (var _i = 0, _a = Array.from(this._optionMap.keys()); _i < _a.length; _i++) {
- var id = _a[_i];
- if (this._compareWith(this._optionMap.get(id), value))
- return id;
- }
- return null;
- };
- /**
- * \@internal
- * @param {?} valueString
- * @return {?}
- */
- SelectControlValueAccessor.prototype._getOptionValue = function (valueString) {
- var /** @type {?} */ id = _extractId(valueString);
- return this._optionMap.has(id) ? this._optionMap.get(id) : valueString;
- };
- return SelectControlValueAccessor;
- }());
- SelectControlValueAccessor.decorators = [
- { type: Directive, args: [{
- selector: 'select:not([multiple])[formControlName],select:not([multiple])[formControl],select:not([multiple])[ngModel]',
- host: { '(change)': 'onChange($event.target.value)', '(blur)': 'onTouched()' },
- providers: [SELECT_VALUE_ACCESSOR]
- },] },
- ];
- /**
- * @nocollapse
- */
- SelectControlValueAccessor.ctorParameters = function () { return [
- { type: Renderer2, },
- { type: ElementRef, },
- ]; };
- SelectControlValueAccessor.propDecorators = {
- 'compareWith': [{ type: Input },],
- };
- /**
- * \@whatItDoes Marks `<option>` as dynamic, so Angular can be notified when options change.
- *
- * \@howToUse
- *
- * See docs for {\@link SelectControlValueAccessor} for usage examples.
- *
- * \@stable
- */
- var NgSelectOption = (function () {
- /**
- * @param {?} _element
- * @param {?} _renderer
- * @param {?} _select
- */
- function NgSelectOption(_element, _renderer, _select) {
- this._element = _element;
- this._renderer = _renderer;
- this._select = _select;
- if (this._select)
- this.id = this._select._registerOption();
- }
- Object.defineProperty(NgSelectOption.prototype, "ngValue", {
- /**
- * @param {?} value
- * @return {?}
- */
- set: function (value) {
- if (this._select == null)
- return;
- this._select._optionMap.set(this.id, value);
- this._setElementValue(_buildValueString(this.id, value));
- this._select.writeValue(this._select.value);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(NgSelectOption.prototype, "value", {
- /**
- * @param {?} value
- * @return {?}
- */
- set: function (value) {
- this._setElementValue(value);
- if (this._select)
- this._select.writeValue(this._select.value);
- },
- enumerable: true,
- configurable: true
- });
- /**
- * \@internal
- * @param {?} value
- * @return {?}
- */
- NgSelectOption.prototype._setElementValue = function (value) {
- this._renderer.setProperty(this._element.nativeElement, 'value', value);
- };
- /**
- * @return {?}
- */
- NgSelectOption.prototype.ngOnDestroy = function () {
- if (this._select) {
- this._select._optionMap.delete(this.id);
- this._select.writeValue(this._select.value);
- }
- };
- return NgSelectOption;
- }());
- NgSelectOption.decorators = [
- { type: Directive, args: [{ selector: 'option' },] },
- ];
- /**
- * @nocollapse
- */
- NgSelectOption.ctorParameters = function () { return [
- { type: ElementRef, },
- { type: Renderer2, },
- { type: SelectControlValueAccessor, decorators: [{ type: Optional }, { type: Host },] },
- ]; };
- NgSelectOption.propDecorators = {
- 'ngValue': [{ type: Input, args: ['ngValue',] },],
- 'value': [{ type: Input, args: ['value',] },],
- };
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var SELECT_MULTIPLE_VALUE_ACCESSOR = {
- provide: NG_VALUE_ACCESSOR,
- useExisting: forwardRef(function () { return SelectMultipleControlValueAccessor; }),
- multi: true
- };
- /**
- * @param {?} id
- * @param {?} value
- * @return {?}
- */
- function _buildValueString$1(id, value) {
- if (id == null)
- return "" + value;
- if (typeof value === 'string')
- value = "'" + value + "'";
- if (value && typeof value === 'object')
- value = 'Object';
- return (id + ": " + value).slice(0, 50);
- }
- /**
- * @param {?} valueString
- * @return {?}
- */
- function _extractId$1(valueString) {
- return valueString.split(':')[0];
- }
- /**
- * The accessor for writing a value and listening to changes on a select element.
- *
- * ### Caveat: Options selection
- *
- * Angular uses object identity to select options. It's possible for the identities of items
- * to change while the data does not. This can happen, for example, if the items are produced
- * from an RPC to the server, and that RPC is re-run. Even if the data hasn't changed, the
- * second response will produce objects with different identities.
- *
- * To customize the default option comparison algorithm, `<select multiple>` supports `compareWith`
- * input. `compareWith` takes a **function** which has two arguments: `option1` and `option2`.
- * If `compareWith` is given, Angular selects options by the return value of the function.
- *
- * #### Syntax
- *
- * ```
- * <select multiple [compareWith]="compareFn" [(ngModel)]="selectedCountries">
- * <option *ngFor="let country of countries" [ngValue]="country">
- * {{country.name}}
- * </option>
- * </select>
- *
- * compareFn(c1: Country, c2: Country): boolean {
- * return c1 && c2 ? c1.id === c2.id : c1 === c2;
- * }
- * ```
- *
- * \@stable
- */
- var SelectMultipleControlValueAccessor = (function () {
- /**
- * @param {?} _renderer
- * @param {?} _elementRef
- */
- function SelectMultipleControlValueAccessor(_renderer, _elementRef) {
- this._renderer = _renderer;
- this._elementRef = _elementRef;
- /**
- * \@internal
- */
- this._optionMap = new Map();
- /**
- * \@internal
- */
- this._idCounter = 0;
- this.onChange = function (_) { };
- this.onTouched = function () { };
- this._compareWith = looseIdentical;
- }
- Object.defineProperty(SelectMultipleControlValueAccessor.prototype, "compareWith", {
- /**
- * @param {?} fn
- * @return {?}
- */
- set: function (fn) {
- if (typeof fn !== 'function') {
- throw new Error("compareWith must be a function, but received " + JSON.stringify(fn));
- }
- this._compareWith = fn;
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @param {?} value
- * @return {?}
- */
- SelectMultipleControlValueAccessor.prototype.writeValue = function (value) {
- var _this = this;
- this.value = value;
- var /** @type {?} */ optionSelectedStateSetter;
- if (Array.isArray(value)) {
- // convert values to ids
- var /** @type {?} */ ids_1 = value.map(function (v) { return _this._getOptionId(v); });
- optionSelectedStateSetter = function (opt, o) { opt._setSelected(ids_1.indexOf(o.toString()) > -1); };
- }
- else {
- optionSelectedStateSetter = function (opt, o) { opt._setSelected(false); };
- }
- this._optionMap.forEach(optionSelectedStateSetter);
- };
- /**
- * @param {?} fn
- * @return {?}
- */
- SelectMultipleControlValueAccessor.prototype.registerOnChange = function (fn) {
- var _this = this;
- this.onChange = function (_) {
- var /** @type {?} */ selected = [];
- if (_.hasOwnProperty('selectedOptions')) {
- var /** @type {?} */ options = _.selectedOptions;
- for (var /** @type {?} */ i = 0; i < options.length; i++) {
- var /** @type {?} */ opt = options.item(i);
- var /** @type {?} */ val = _this._getOptionValue(opt.value);
- selected.push(val);
- }
- }
- else {
- var /** @type {?} */ options = (_.options);
- for (var /** @type {?} */ i = 0; i < options.length; i++) {
- var /** @type {?} */ opt = options.item(i);
- if (opt.selected) {
- var /** @type {?} */ val = _this._getOptionValue(opt.value);
- selected.push(val);
- }
- }
- }
- _this.value = selected;
- fn(selected);
- };
- };
- /**
- * @param {?} fn
- * @return {?}
- */
- SelectMultipleControlValueAccessor.prototype.registerOnTouched = function (fn) { this.onTouched = fn; };
- /**
- * @param {?} isDisabled
- * @return {?}
- */
- SelectMultipleControlValueAccessor.prototype.setDisabledState = function (isDisabled) {
- this._renderer.setProperty(this._elementRef.nativeElement, 'disabled', isDisabled);
- };
- /**
- * \@internal
- * @param {?} value
- * @return {?}
- */
- SelectMultipleControlValueAccessor.prototype._registerOption = function (value) {
- var /** @type {?} */ id = (this._idCounter++).toString();
- this._optionMap.set(id, value);
- return id;
- };
- /**
- * \@internal
- * @param {?} value
- * @return {?}
- */
- SelectMultipleControlValueAccessor.prototype._getOptionId = function (value) {
- for (var _i = 0, _a = Array.from(this._optionMap.keys()); _i < _a.length; _i++) {
- var id = _a[_i];
- if (this._compareWith(/** @type {?} */ ((this._optionMap.get(id)))._value, value))
- return id;
- }
- return null;
- };
- /**
- * \@internal
- * @param {?} valueString
- * @return {?}
- */
- SelectMultipleControlValueAccessor.prototype._getOptionValue = function (valueString) {
- var /** @type {?} */ id = _extractId$1(valueString);
- return this._optionMap.has(id) ? ((this._optionMap.get(id)))._value : valueString;
- };
- return SelectMultipleControlValueAccessor;
- }());
- SelectMultipleControlValueAccessor.decorators = [
- { type: Directive, args: [{
- selector: 'select[multiple][formControlName],select[multiple][formControl],select[multiple][ngModel]',
- host: { '(change)': 'onChange($event.target)', '(blur)': 'onTouched()' },
- providers: [SELECT_MULTIPLE_VALUE_ACCESSOR]
- },] },
- ];
- /**
- * @nocollapse
- */
- SelectMultipleControlValueAccessor.ctorParameters = function () { return [
- { type: Renderer2, },
- { type: ElementRef, },
- ]; };
- SelectMultipleControlValueAccessor.propDecorators = {
- 'compareWith': [{ type: Input },],
- };
- /**
- * Marks `<option>` as dynamic, so Angular can be notified when options change.
- *
- * ### Example
- *
- * ```
- * <select multiple name="city" ngModel>
- * <option *ngFor="let c of cities" [value]="c"></option>
- * </select>
- * ```
- */
- var NgSelectMultipleOption = (function () {
- /**
- * @param {?} _element
- * @param {?} _renderer
- * @param {?} _select
- */
- function NgSelectMultipleOption(_element, _renderer, _select) {
- this._element = _element;
- this._renderer = _renderer;
- this._select = _select;
- if (this._select) {
- this.id = this._select._registerOption(this);
- }
- }
- Object.defineProperty(NgSelectMultipleOption.prototype, "ngValue", {
- /**
- * @param {?} value
- * @return {?}
- */
- set: function (value) {
- if (this._select == null)
- return;
- this._value = value;
- this._setElementValue(_buildValueString$1(this.id, value));
- this._select.writeValue(this._select.value);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(NgSelectMultipleOption.prototype, "value", {
- /**
- * @param {?} value
- * @return {?}
- */
- set: function (value) {
- if (this._select) {
- this._value = value;
- this._setElementValue(_buildValueString$1(this.id, value));
- this._select.writeValue(this._select.value);
- }
- else {
- this._setElementValue(value);
- }
- },
- enumerable: true,
- configurable: true
- });
- /**
- * \@internal
- * @param {?} value
- * @return {?}
- */
- NgSelectMultipleOption.prototype._setElementValue = function (value) {
- this._renderer.setProperty(this._element.nativeElement, 'value', value);
- };
- /**
- * \@internal
- * @param {?} selected
- * @return {?}
- */
- NgSelectMultipleOption.prototype._setSelected = function (selected) {
- this._renderer.setProperty(this._element.nativeElement, 'selected', selected);
- };
- /**
- * @return {?}
- */
- NgSelectMultipleOption.prototype.ngOnDestroy = function () {
- if (this._select) {
- this._select._optionMap.delete(this.id);
- this._select.writeValue(this._select.value);
- }
- };
- return NgSelectMultipleOption;
- }());
- NgSelectMultipleOption.decorators = [
- { type: Directive, args: [{ selector: 'option' },] },
- ];
- /**
- * @nocollapse
- */
- NgSelectMultipleOption.ctorParameters = function () { return [
- { type: ElementRef, },
- { type: Renderer2, },
- { type: SelectMultipleControlValueAccessor, decorators: [{ type: Optional }, { type: Host },] },
- ]; };
- NgSelectMultipleOption.propDecorators = {
- 'ngValue': [{ type: Input, args: ['ngValue',] },],
- 'value': [{ type: Input, args: ['value',] },],
- };
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * @param {?} name
- * @param {?} parent
- * @return {?}
- */
- function controlPath(name, parent) {
- return ((parent.path)).concat([name]);
- }
- /**
- * @param {?} control
- * @param {?} dir
- * @return {?}
- */
- function setUpControl(control, dir) {
- if (!control)
- _throwError$1(dir, 'Cannot find control with');
- if (!dir.valueAccessor)
- _throwError$1(dir, 'No value accessor for form control with');
- control.validator = Validators.compose([/** @type {?} */ ((control.validator)), dir.validator]);
- control.asyncValidator = Validators.composeAsync([/** @type {?} */ ((control.asyncValidator)), dir.asyncValidator]); /** @type {?} */
- ((dir.valueAccessor)).writeValue(control.value); /** @type {?} */
- ((
- // view -> model
- dir.valueAccessor)).registerOnChange(function (newValue) {
- dir.viewToModelUpdate(newValue);
- control.markAsDirty();
- control.setValue(newValue, { emitModelToViewChange: false });
- }); /** @type {?} */
- ((
- // touched
- dir.valueAccessor)).registerOnTouched(function () { return control.markAsTouched(); });
- control.registerOnChange(function (newValue, emitModelEvent) {
- ((
- // control -> view
- dir.valueAccessor)).writeValue(newValue);
- // control -> ngModel
- if (emitModelEvent)
- dir.viewToModelUpdate(newValue);
- });
- if (((dir.valueAccessor)).setDisabledState) {
- control.registerOnDisabledChange(function (isDisabled) { /** @type {?} */ ((((dir.valueAccessor)).setDisabledState))(isDisabled); });
- }
- // re-run validation when validator binding changes, e.g. minlength=3 -> minlength=4
- dir._rawValidators.forEach(function (validator) {
- if (((validator)).registerOnValidatorChange)
- ((((validator)).registerOnValidatorChange))(function () { return control.updateValueAndValidity(); });
- });
- dir._rawAsyncValidators.forEach(function (validator) {
- if (((validator)).registerOnValidatorChange)
- ((((validator)).registerOnValidatorChange))(function () { return control.updateValueAndValidity(); });
- });
- }
- /**
- * @param {?} control
- * @param {?} dir
- * @return {?}
- */
- function cleanUpControl(control, dir) {
- ((dir.valueAccessor)).registerOnChange(function () { return _noControlError(dir); }); /** @type {?} */
- ((dir.valueAccessor)).registerOnTouched(function () { return _noControlError(dir); });
- dir._rawValidators.forEach(function (validator) {
- if (validator.registerOnValidatorChange) {
- validator.registerOnValidatorChange(null);
- }
- });
- dir._rawAsyncValidators.forEach(function (validator) {
- if (validator.registerOnValidatorChange) {
- validator.registerOnValidatorChange(null);
- }
- });
- if (control)
- control._clearChangeFns();
- }
- /**
- * @param {?} control
- * @param {?} dir
- * @return {?}
- */
- function setUpFormContainer(control, dir) {
- if (control == null)
- _throwError$1(dir, 'Cannot find control with');
- control.validator = Validators.compose([control.validator, dir.validator]);
- control.asyncValidator = Validators.composeAsync([control.asyncValidator, dir.asyncValidator]);
- }
- /**
- * @param {?} dir
- * @return {?}
- */
- function _noControlError(dir) {
- return _throwError$1(dir, 'There is no FormControl instance attached to form control element with');
- }
- /**
- * @param {?} dir
- * @param {?} message
- * @return {?}
- */
- function _throwError$1(dir, message) {
- var /** @type {?} */ messageEnd;
- if (((dir.path)).length > 1) {
- messageEnd = "path: '" + ((dir.path)).join(' -> ') + "'";
- }
- else if (((dir.path))[0]) {
- messageEnd = "name: '" + dir.path + "'";
- }
- else {
- messageEnd = 'unspecified name attribute';
- }
- throw new Error(message + " " + messageEnd);
- }
- /**
- * @param {?} validators
- * @return {?}
- */
- function composeValidators(validators) {
- return validators != null ? Validators.compose(validators.map(normalizeValidator)) : null;
- }
- /**
- * @param {?} validators
- * @return {?}
- */
- function composeAsyncValidators(validators) {
- return validators != null ? Validators.composeAsync(validators.map(normalizeAsyncValidator)) :
- null;
- }
- /**
- * @param {?} changes
- * @param {?} viewModel
- * @return {?}
- */
- function isPropertyUpdated(changes, viewModel) {
- if (!changes.hasOwnProperty('model'))
- return false;
- var /** @type {?} */ change = changes['model'];
- if (change.isFirstChange())
- return true;
- return !looseIdentical(viewModel, change.currentValue);
- }
- var BUILTIN_ACCESSORS = [
- CheckboxControlValueAccessor,
- RangeValueAccessor,
- NumberValueAccessor,
- SelectControlValueAccessor,
- SelectMultipleControlValueAccessor,
- RadioControlValueAccessor,
- ];
- /**
- * @param {?} valueAccessor
- * @return {?}
- */
- function isBuiltInAccessor(valueAccessor) {
- return BUILTIN_ACCESSORS.some(function (a) { return valueAccessor.constructor === a; });
- }
- /**
- * @param {?} dir
- * @param {?} valueAccessors
- * @return {?}
- */
- function selectValueAccessor(dir, valueAccessors) {
- if (!valueAccessors)
- return null;
- var /** @type {?} */ defaultAccessor = undefined;
- var /** @type {?} */ builtinAccessor = undefined;
- var /** @type {?} */ customAccessor = undefined;
- valueAccessors.forEach(function (v) {
- if (v.constructor === DefaultValueAccessor) {
- defaultAccessor = v;
- }
- else if (isBuiltInAccessor(v)) {
- if (builtinAccessor)
- _throwError$1(dir, 'More than one built-in value accessor matches form control with');
- builtinAccessor = v;
- }
- else {
- if (customAccessor)
- _throwError$1(dir, 'More than one custom value accessor matches form control with');
- customAccessor = v;
- }
- });
- if (customAccessor)
- return customAccessor;
- if (builtinAccessor)
- return builtinAccessor;
- if (defaultAccessor)
- return defaultAccessor;
- _throwError$1(dir, 'No valid value accessor for form control with');
- return null;
- }
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * This is a base class for code shared between {\@link NgModelGroup} and {\@link FormGroupName}.
- *
- * \@stable
- */
- var AbstractFormGroupDirective = (function (_super) {
- __extends$1(AbstractFormGroupDirective, _super);
- function AbstractFormGroupDirective() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- /**
- * @return {?}
- */
- AbstractFormGroupDirective.prototype.ngOnInit = function () {
- this._checkParentType(); /** @type {?} */
- ((this.formDirective)).addFormGroup(this);
- };
- /**
- * @return {?}
- */
- AbstractFormGroupDirective.prototype.ngOnDestroy = function () {
- if (this.formDirective) {
- this.formDirective.removeFormGroup(this);
- }
- };
- Object.defineProperty(AbstractFormGroupDirective.prototype, "control", {
- /**
- * Get the {\@link FormGroup} backing this binding.
- * @return {?}
- */
- get: function () { return ((this.formDirective)).getFormGroup(this); },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(AbstractFormGroupDirective.prototype, "path", {
- /**
- * Get the path to this control group.
- * @return {?}
- */
- get: function () { return controlPath(this.name, this._parent); },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(AbstractFormGroupDirective.prototype, "formDirective", {
- /**
- * Get the {\@link Form} to which this group belongs.
- * @return {?}
- */
- get: function () { return this._parent ? this._parent.formDirective : null; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(AbstractFormGroupDirective.prototype, "validator", {
- /**
- * @return {?}
- */
- get: function () { return composeValidators(this._validators); },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(AbstractFormGroupDirective.prototype, "asyncValidator", {
- /**
- * @return {?}
- */
- get: function () {
- return composeAsyncValidators(this._asyncValidators);
- },
- enumerable: true,
- configurable: true
- });
- /**
- * \@internal
- * @return {?}
- */
- AbstractFormGroupDirective.prototype._checkParentType = function () { };
- return AbstractFormGroupDirective;
- }(ControlContainer));
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var AbstractControlStatus = (function () {
- /**
- * @param {?} cd
- */
- function AbstractControlStatus(cd) {
- this._cd = cd;
- }
- Object.defineProperty(AbstractControlStatus.prototype, "ngClassUntouched", {
- /**
- * @return {?}
- */
- get: function () { return this._cd.control ? this._cd.control.untouched : false; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(AbstractControlStatus.prototype, "ngClassTouched", {
- /**
- * @return {?}
- */
- get: function () { return this._cd.control ? this._cd.control.touched : false; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(AbstractControlStatus.prototype, "ngClassPristine", {
- /**
- * @return {?}
- */
- get: function () { return this._cd.control ? this._cd.control.pristine : false; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(AbstractControlStatus.prototype, "ngClassDirty", {
- /**
- * @return {?}
- */
- get: function () { return this._cd.control ? this._cd.control.dirty : false; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(AbstractControlStatus.prototype, "ngClassValid", {
- /**
- * @return {?}
- */
- get: function () { return this._cd.control ? this._cd.control.valid : false; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(AbstractControlStatus.prototype, "ngClassInvalid", {
- /**
- * @return {?}
- */
- get: function () { return this._cd.control ? this._cd.control.invalid : false; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(AbstractControlStatus.prototype, "ngClassPending", {
- /**
- * @return {?}
- */
- get: function () { return this._cd.control ? this._cd.control.pending : false; },
- enumerable: true,
- configurable: true
- });
- return AbstractControlStatus;
- }());
- var ngControlStatusHost = {
- '[class.ng-untouched]': 'ngClassUntouched',
- '[class.ng-touched]': 'ngClassTouched',
- '[class.ng-pristine]': 'ngClassPristine',
- '[class.ng-dirty]': 'ngClassDirty',
- '[class.ng-valid]': 'ngClassValid',
- '[class.ng-invalid]': 'ngClassInvalid',
- '[class.ng-pending]': 'ngClassPending',
- };
- /**
- * Directive automatically applied to Angular form controls that sets CSS classes
- * based on control status. The following classes are applied as the properties
- * become true:
- *
- * * ng-valid
- * * ng-invalid
- * * ng-pending
- * * ng-pristine
- * * ng-dirty
- * * ng-untouched
- * * ng-touched
- *
- * \@stable
- */
- var NgControlStatus = (function (_super) {
- __extends$1(NgControlStatus, _super);
- /**
- * @param {?} cd
- */
- function NgControlStatus(cd) {
- return _super.call(this, cd) || this;
- }
- return NgControlStatus;
- }(AbstractControlStatus));
- NgControlStatus.decorators = [
- { type: Directive, args: [{ selector: '[formControlName],[ngModel],[formControl]', host: ngControlStatusHost },] },
- ];
- /**
- * @nocollapse
- */
- NgControlStatus.ctorParameters = function () { return [
- { type: NgControl, decorators: [{ type: Self },] },
- ]; };
- /**
- * Directive automatically applied to Angular form groups that sets CSS classes
- * based on control status (valid/invalid/dirty/etc).
- *
- * \@stable
- */
- var NgControlStatusGroup = (function (_super) {
- __extends$1(NgControlStatusGroup, _super);
- /**
- * @param {?} cd
- */
- function NgControlStatusGroup(cd) {
- return _super.call(this, cd) || this;
- }
- return NgControlStatusGroup;
- }(AbstractControlStatus));
- NgControlStatusGroup.decorators = [
- { type: Directive, args: [{
- selector: '[formGroupName],[formArrayName],[ngModelGroup],[formGroup],form:not([ngNoForm]),[ngForm]',
- host: ngControlStatusHost
- },] },
- ];
- /**
- * @nocollapse
- */
- NgControlStatusGroup.ctorParameters = function () { return [
- { type: ControlContainer, decorators: [{ type: Self },] },
- ]; };
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * Indicates that a FormControl is valid, i.e. that no errors exist in the input value.
- */
- var VALID = 'VALID';
- /**
- * Indicates that a FormControl is invalid, i.e. that an error exists in the input value.
- */
- var INVALID = 'INVALID';
- /**
- * Indicates that a FormControl is pending, i.e. that async validation is occurring and
- * errors are not yet available for the input value.
- */
- var PENDING = 'PENDING';
- /**
- * Indicates that a FormControl is disabled, i.e. that the control is exempt from ancestor
- * calculations of validity or value.
- */
- var DISABLED = 'DISABLED';
- /**
- * @param {?} control
- * @param {?} path
- * @param {?} delimiter
- * @return {?}
- */
- function _find(control, path, delimiter) {
- if (path == null)
- return null;
- if (!(path instanceof Array)) {
- path = ((path)).split(delimiter);
- }
- if (path instanceof Array && (path.length === 0))
- return null;
- return ((path)).reduce(function (v, name) {
- if (v instanceof FormGroup) {
- return v.controls[name] || null;
- }
- if (v instanceof FormArray) {
- return v.at(/** @type {?} */ (name)) || null;
- }
- return null;
- }, control);
- }
- /**
- * @param {?=} validator
- * @return {?}
- */
- function coerceToValidator(validator) {
- return Array.isArray(validator) ? composeValidators(validator) : validator || null;
- }
- /**
- * @param {?=} asyncValidator
- * @return {?}
- */
- function coerceToAsyncValidator(asyncValidator) {
- return Array.isArray(asyncValidator) ? composeAsyncValidators(asyncValidator) :
- asyncValidator || null;
- }
- /**
- * \@whatItDoes This is the base class for {\@link FormControl}, {\@link FormGroup}, and
- * {\@link FormArray}.
- *
- * It provides some of the shared behavior that all controls and groups of controls have, like
- * running validators, calculating status, and resetting state. It also defines the properties
- * that are shared between all sub-classes, like `value`, `valid`, and `dirty`. It shouldn't be
- * instantiated directly.
- *
- * \@stable
- * @abstract
- */
- var AbstractControl = (function () {
- /**
- * @param {?} validator
- * @param {?} asyncValidator
- */
- function AbstractControl(validator, asyncValidator) {
- this.validator = validator;
- this.asyncValidator = asyncValidator;
- /**
- * \@internal
- */
- this._onCollectionChange = function () { };
- this._pristine = true;
- this._touched = false;
- /**
- * \@internal
- */
- this._onDisabledChange = [];
- }
- Object.defineProperty(AbstractControl.prototype, "value", {
- /**
- * The value of the control.
- * @return {?}
- */
- get: function () { return this._value; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(AbstractControl.prototype, "parent", {
- /**
- * The parent control.
- * @return {?}
- */
- get: function () { return this._parent; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(AbstractControl.prototype, "status", {
- /**
- * The validation status of the control. There are four possible
- * validation statuses:
- *
- * * **VALID**: control has passed all validation checks
- * * **INVALID**: control has failed at least one validation check
- * * **PENDING**: control is in the midst of conducting a validation check
- * * **DISABLED**: control is exempt from validation checks
- *
- * These statuses are mutually exclusive, so a control cannot be
- * both valid AND invalid or invalid AND disabled.
- * @return {?}
- */
- get: function () { return this._status; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(AbstractControl.prototype, "valid", {
- /**
- * A control is `valid` when its `status === VALID`.
- *
- * In order to have this status, the control must have passed all its
- * validation checks.
- * @return {?}
- */
- get: function () { return this._status === VALID; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(AbstractControl.prototype, "invalid", {
- /**
- * A control is `invalid` when its `status === INVALID`.
- *
- * In order to have this status, the control must have failed
- * at least one of its validation checks.
- * @return {?}
- */
- get: function () { return this._status === INVALID; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(AbstractControl.prototype, "pending", {
- /**
- * A control is `pending` when its `status === PENDING`.
- *
- * In order to have this status, the control must be in the
- * middle of conducting a validation check.
- * @return {?}
- */
- get: function () { return this._status == PENDING; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(AbstractControl.prototype, "disabled", {
- /**
- * A control is `disabled` when its `status === DISABLED`.
- *
- * Disabled controls are exempt from validation checks and
- * are not included in the aggregate value of their ancestor
- * controls.
- * @return {?}
- */
- get: function () { return this._status === DISABLED; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(AbstractControl.prototype, "enabled", {
- /**
- * A control is `enabled` as long as its `status !== DISABLED`.
- *
- * In other words, it has a status of `VALID`, `INVALID`, or
- * `PENDING`.
- * @return {?}
- */
- get: function () { return this._status !== DISABLED; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(AbstractControl.prototype, "errors", {
- /**
- * Returns any errors generated by failing validation. If there
- * are no errors, it will return null.
- * @return {?}
- */
- get: function () { return this._errors; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(AbstractControl.prototype, "pristine", {
- /**
- * A control is `pristine` if the user has not yet changed
- * the value in the UI.
- *
- * Note that programmatic changes to a control's value will
- * *not* mark it dirty.
- * @return {?}
- */
- get: function () { return this._pristine; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(AbstractControl.prototype, "dirty", {
- /**
- * A control is `dirty` if the user has changed the value
- * in the UI.
- *
- * Note that programmatic changes to a control's value will
- * *not* mark it dirty.
- * @return {?}
- */
- get: function () { return !this.pristine; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(AbstractControl.prototype, "touched", {
- /**
- * A control is marked `touched` once the user has triggered
- * a `blur` event on it.
- * @return {?}
- */
- get: function () { return this._touched; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(AbstractControl.prototype, "untouched", {
- /**
- * A control is `untouched` if the user has not yet triggered
- * a `blur` event on it.
- * @return {?}
- */
- get: function () { return !this._touched; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(AbstractControl.prototype, "valueChanges", {
- /**
- * Emits an event every time the value of the control changes, in
- * the UI or programmatically.
- * @return {?}
- */
- get: function () { return this._valueChanges; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(AbstractControl.prototype, "statusChanges", {
- /**
- * Emits an event every time the validation status of the control
- * is re-calculated.
- * @return {?}
- */
- get: function () { return this._statusChanges; },
- enumerable: true,
- configurable: true
- });
- /**
- * Sets the synchronous validators that are active on this control. Calling
- * this will overwrite any existing sync validators.
- * @param {?} newValidator
- * @return {?}
- */
- AbstractControl.prototype.setValidators = function (newValidator) {
- this.validator = coerceToValidator(newValidator);
- };
- /**
- * Sets the async validators that are active on this control. Calling this
- * will overwrite any existing async validators.
- * @param {?} newValidator
- * @return {?}
- */
- AbstractControl.prototype.setAsyncValidators = function (newValidator) {
- this.asyncValidator = coerceToAsyncValidator(newValidator);
- };
- /**
- * Empties out the sync validator list.
- * @return {?}
- */
- AbstractControl.prototype.clearValidators = function () { this.validator = null; };
- /**
- * Empties out the async validator list.
- * @return {?}
- */
- AbstractControl.prototype.clearAsyncValidators = function () { this.asyncValidator = null; };
- /**
- * Marks the control as `touched`.
- *
- * This will also mark all direct ancestors as `touched` to maintain
- * the model.
- * @param {?=} opts
- * @return {?}
- */
- AbstractControl.prototype.markAsTouched = function (opts) {
- if (opts === void 0) { opts = {}; }
- this._touched = true;
- if (this._parent && !opts.onlySelf) {
- this._parent.markAsTouched(opts);
- }
- };
- /**
- * Marks the control as `untouched`.
- *
- * If the control has any children, it will also mark all children as `untouched`
- * to maintain the model, and re-calculate the `touched` status of all parent
- * controls.
- * @param {?=} opts
- * @return {?}
- */
- AbstractControl.prototype.markAsUntouched = function (opts) {
- if (opts === void 0) { opts = {}; }
- this._touched = false;
- this._forEachChild(function (control) { control.markAsUntouched({ onlySelf: true }); });
- if (this._parent && !opts.onlySelf) {
- this._parent._updateTouched(opts);
- }
- };
- /**
- * Marks the control as `dirty`.
- *
- * This will also mark all direct ancestors as `dirty` to maintain
- * the model.
- * @param {?=} opts
- * @return {?}
- */
- AbstractControl.prototype.markAsDirty = function (opts) {
- if (opts === void 0) { opts = {}; }
- this._pristine = false;
- if (this._parent && !opts.onlySelf) {
- this._parent.markAsDirty(opts);
- }
- };
- /**
- * Marks the control as `pristine`.
- *
- * If the control has any children, it will also mark all children as `pristine`
- * to maintain the model, and re-calculate the `pristine` status of all parent
- * controls.
- * @param {?=} opts
- * @return {?}
- */
- AbstractControl.prototype.markAsPristine = function (opts) {
- if (opts === void 0) { opts = {}; }
- this._pristine = true;
- this._forEachChild(function (control) { control.markAsPristine({ onlySelf: true }); });
- if (this._parent && !opts.onlySelf) {
- this._parent._updatePristine(opts);
- }
- };
- /**
- * Marks the control as `pending`.
- * @param {?=} opts
- * @return {?}
- */
- AbstractControl.prototype.markAsPending = function (opts) {
- if (opts === void 0) { opts = {}; }
- this._status = PENDING;
- if (this._parent && !opts.onlySelf) {
- this._parent.markAsPending(opts);
- }
- };
- /**
- * Disables the control. This means the control will be exempt from validation checks and
- * excluded from the aggregate value of any parent. Its status is `DISABLED`.
- *
- * If the control has children, all children will be disabled to maintain the model.
- * @param {?=} opts
- * @return {?}
- */
- AbstractControl.prototype.disable = function (opts) {
- if (opts === void 0) { opts = {}; }
- this._status = DISABLED;
- this._errors = null;
- this._forEachChild(function (control) { control.disable({ onlySelf: true }); });
- this._updateValue();
- if (opts.emitEvent !== false) {
- this._valueChanges.emit(this._value);
- this._statusChanges.emit(this._status);
- }
- this._updateAncestors(!!opts.onlySelf);
- this._onDisabledChange.forEach(function (changeFn) { return changeFn(true); });
- };
- /**
- * Enables the control. This means the control will be included in validation checks and
- * the aggregate value of its parent. Its status is re-calculated based on its value and
- * its validators.
- *
- * If the control has children, all children will be enabled.
- * @param {?=} opts
- * @return {?}
- */
- AbstractControl.prototype.enable = function (opts) {
- if (opts === void 0) { opts = {}; }
- this._status = VALID;
- this._forEachChild(function (control) { control.enable({ onlySelf: true }); });
- this.updateValueAndValidity({ onlySelf: true, emitEvent: opts.emitEvent });
- this._updateAncestors(!!opts.onlySelf);
- this._onDisabledChange.forEach(function (changeFn) { return changeFn(false); });
- };
- /**
- * @param {?} onlySelf
- * @return {?}
- */
- AbstractControl.prototype._updateAncestors = function (onlySelf) {
- if (this._parent && !onlySelf) {
- this._parent.updateValueAndValidity();
- this._parent._updatePristine();
- this._parent._updateTouched();
- }
- };
- /**
- * @param {?} parent
- * @return {?}
- */
- AbstractControl.prototype.setParent = function (parent) { this._parent = parent; };
- /**
- * Sets the value of the control. Abstract method (implemented in sub-classes).
- * @abstract
- * @param {?} value
- * @param {?=} options
- * @return {?}
- */
- AbstractControl.prototype.setValue = function (value, options) { };
- /**
- * Patches the value of the control. Abstract method (implemented in sub-classes).
- * @abstract
- * @param {?} value
- * @param {?=} options
- * @return {?}
- */
- AbstractControl.prototype.patchValue = function (value, options) { };
- /**
- * Resets the control. Abstract method (implemented in sub-classes).
- * @abstract
- * @param {?=} value
- * @param {?=} options
- * @return {?}
- */
- AbstractControl.prototype.reset = function (value, options) { };
- /**
- * Re-calculates the value and validation status of the control.
- *
- * By default, it will also update the value and validity of its ancestors.
- * @param {?=} opts
- * @return {?}
- */
- AbstractControl.prototype.updateValueAndValidity = function (opts) {
- if (opts === void 0) { opts = {}; }
- this._setInitialStatus();
- this._updateValue();
- if (this.enabled) {
- this._cancelExistingSubscription();
- this._errors = this._runValidator();
- this._status = this._calculateStatus();
- if (this._status === VALID || this._status === PENDING) {
- this._runAsyncValidator(opts.emitEvent);
- }
- }
- if (opts.emitEvent !== false) {
- this._valueChanges.emit(this._value);
- this._statusChanges.emit(this._status);
- }
- if (this._parent && !opts.onlySelf) {
- this._parent.updateValueAndValidity(opts);
- }
- };
- /**
- * \@internal
- * @param {?=} opts
- * @return {?}
- */
- AbstractControl.prototype._updateTreeValidity = function (opts) {
- if (opts === void 0) { opts = { emitEvent: true }; }
- this._forEachChild(function (ctrl) { return ctrl._updateTreeValidity(opts); });
- this.updateValueAndValidity({ onlySelf: true, emitEvent: opts.emitEvent });
- };
- /**
- * @return {?}
- */
- AbstractControl.prototype._setInitialStatus = function () { this._status = this._allControlsDisabled() ? DISABLED : VALID; };
- /**
- * @return {?}
- */
- AbstractControl.prototype._runValidator = function () {
- return this.validator ? this.validator(this) : null;
- };
- /**
- * @param {?=} emitEvent
- * @return {?}
- */
- AbstractControl.prototype._runAsyncValidator = function (emitEvent) {
- var _this = this;
- if (this.asyncValidator) {
- this._status = PENDING;
- var /** @type {?} */ obs = toObservable(this.asyncValidator(this));
- this._asyncValidationSubscription =
- obs.subscribe(function (errors) { return _this.setErrors(errors, { emitEvent: emitEvent }); });
- }
- };
- /**
- * @return {?}
- */
- AbstractControl.prototype._cancelExistingSubscription = function () {
- if (this._asyncValidationSubscription) {
- this._asyncValidationSubscription.unsubscribe();
- }
- };
- /**
- * Sets errors on a form control.
- *
- * This is used when validations are run manually by the user, rather than automatically.
- *
- * Calling `setErrors` will also update the validity of the parent control.
- *
- * ### Example
- *
- * ```
- * const login = new FormControl("someLogin");
- * login.setErrors({
- * "notUnique": true
- * });
- *
- * expect(login.valid).toEqual(false);
- * expect(login.errors).toEqual({"notUnique": true});
- *
- * login.setValue("someOtherLogin");
- *
- * expect(login.valid).toEqual(true);
- * ```
- * @param {?} errors
- * @param {?=} opts
- * @return {?}
- */
- AbstractControl.prototype.setErrors = function (errors, opts) {
- if (opts === void 0) { opts = {}; }
- this._errors = errors;
- this._updateControlsErrors(opts.emitEvent !== false);
- };
- /**
- * Retrieves a child control given the control's name or path.
- *
- * Paths can be passed in as an array or a string delimited by a dot.
- *
- * To get a control nested within a `person` sub-group:
- *
- * * `this.form.get('person.name');`
- *
- * -OR-
- *
- * * `this.form.get(['person', 'name']);`
- * @param {?} path
- * @return {?}
- */
- AbstractControl.prototype.get = function (path) { return _find(this, path, '.'); };
- /**
- * Returns error data if the control with the given path has the error specified. Otherwise
- * returns null or undefined.
- *
- * If no path is given, it checks for the error on the present control.
- * @param {?} errorCode
- * @param {?=} path
- * @return {?}
- */
- AbstractControl.prototype.getError = function (errorCode, path) {
- var /** @type {?} */ control = path ? this.get(path) : this;
- return control && control._errors ? control._errors[errorCode] : null;
- };
- /**
- * Returns true if the control with the given path has the error specified. Otherwise
- * returns false.
- *
- * If no path is given, it checks for the error on the present control.
- * @param {?} errorCode
- * @param {?=} path
- * @return {?}
- */
- AbstractControl.prototype.hasError = function (errorCode, path) { return !!this.getError(errorCode, path); };
- Object.defineProperty(AbstractControl.prototype, "root", {
- /**
- * Retrieves the top-level ancestor of this control.
- * @return {?}
- */
- get: function () {
- var /** @type {?} */ x = this;
- while (x._parent) {
- x = x._parent;
- }
- return x;
- },
- enumerable: true,
- configurable: true
- });
- /**
- * \@internal
- * @param {?} emitEvent
- * @return {?}
- */
- AbstractControl.prototype._updateControlsErrors = function (emitEvent) {
- this._status = this._calculateStatus();
- if (emitEvent) {
- this._statusChanges.emit(this._status);
- }
- if (this._parent) {
- this._parent._updateControlsErrors(emitEvent);
- }
- };
- /**
- * \@internal
- * @return {?}
- */
- AbstractControl.prototype._initObservables = function () {
- this._valueChanges = new EventEmitter();
- this._statusChanges = new EventEmitter();
- };
- /**
- * @return {?}
- */
- AbstractControl.prototype._calculateStatus = function () {
- if (this._allControlsDisabled())
- return DISABLED;
- if (this._errors)
- return INVALID;
- if (this._anyControlsHaveStatus(PENDING))
- return PENDING;
- if (this._anyControlsHaveStatus(INVALID))
- return INVALID;
- return VALID;
- };
- /**
- * \@internal
- * @abstract
- * @return {?}
- */
- AbstractControl.prototype._updateValue = function () { };
- /**
- * \@internal
- * @abstract
- * @param {?} cb
- * @return {?}
- */
- AbstractControl.prototype._forEachChild = function (cb) { };
- /**
- * \@internal
- * @abstract
- * @param {?} condition
- * @return {?}
- */
- AbstractControl.prototype._anyControls = function (condition) { };
- /**
- * \@internal
- * @abstract
- * @return {?}
- */
- AbstractControl.prototype._allControlsDisabled = function () { };
- /**
- * \@internal
- * @param {?} status
- * @return {?}
- */
- AbstractControl.prototype._anyControlsHaveStatus = function (status) {
- return this._anyControls(function (control) { return control.status === status; });
- };
- /**
- * \@internal
- * @return {?}
- */
- AbstractControl.prototype._anyControlsDirty = function () {
- return this._anyControls(function (control) { return control.dirty; });
- };
- /**
- * \@internal
- * @return {?}
- */
- AbstractControl.prototype._anyControlsTouched = function () {
- return this._anyControls(function (control) { return control.touched; });
- };
- /**
- * \@internal
- * @param {?=} opts
- * @return {?}
- */
- AbstractControl.prototype._updatePristine = function (opts) {
- if (opts === void 0) { opts = {}; }
- this._pristine = !this._anyControlsDirty();
- if (this._parent && !opts.onlySelf) {
- this._parent._updatePristine(opts);
- }
- };
- /**
- * \@internal
- * @param {?=} opts
- * @return {?}
- */
- AbstractControl.prototype._updateTouched = function (opts) {
- if (opts === void 0) { opts = {}; }
- this._touched = this._anyControlsTouched();
- if (this._parent && !opts.onlySelf) {
- this._parent._updateTouched(opts);
- }
- };
- /**
- * \@internal
- * @param {?} formState
- * @return {?}
- */
- AbstractControl.prototype._isBoxedValue = function (formState) {
- return typeof formState === 'object' && formState !== null &&
- Object.keys(formState).length === 2 && 'value' in formState && 'disabled' in formState;
- };
- /**
- * \@internal
- * @param {?} fn
- * @return {?}
- */
- AbstractControl.prototype._registerOnCollectionChange = function (fn) { this._onCollectionChange = fn; };
- return AbstractControl;
- }());
- /**
- * \@whatItDoes Tracks the value and validation status of an individual form control.
- *
- * It is one of the three fundamental building blocks of Angular forms, along with
- * {\@link FormGroup} and {\@link FormArray}.
- *
- * \@howToUse
- *
- * When instantiating a {\@link FormControl}, you can pass in an initial value as the
- * first argument. Example:
- *
- * ```ts
- * const ctrl = new FormControl('some value');
- * console.log(ctrl.value); // 'some value'
- * ```
- *
- * You can also initialize the control with a form state object on instantiation,
- * which includes both the value and whether or not the control is disabled.
- * You can't use the value key without the disabled key; both are required
- * to use this way of initialization.
- *
- * ```ts
- * const ctrl = new FormControl({value: 'n/a', disabled: true});
- * console.log(ctrl.value); // 'n/a'
- * console.log(ctrl.status); // 'DISABLED'
- * ```
- *
- * To include a sync validator (or an array of sync validators) with the control,
- * pass it in as the second argument. Async validators are also supported, but
- * have to be passed in separately as the third arg.
- *
- * ```ts
- * const ctrl = new FormControl('', Validators.required);
- * console.log(ctrl.value); // ''
- * console.log(ctrl.status); // 'INVALID'
- * ```
- *
- * See its superclass, {\@link AbstractControl}, for more properties and methods.
- *
- * * **npm package**: `\@angular/forms`
- *
- * \@stable
- */
- var FormControl = (function (_super) {
- __extends$1(FormControl, _super);
- /**
- * @param {?=} formState
- * @param {?=} validator
- * @param {?=} asyncValidator
- */
- function FormControl(formState, validator, asyncValidator) {
- if (formState === void 0) { formState = null; }
- var _this = _super.call(this, coerceToValidator(validator), coerceToAsyncValidator(asyncValidator)) || this;
- /**
- * \@internal
- */
- _this._onChange = [];
- _this._applyFormState(formState);
- _this.updateValueAndValidity({ onlySelf: true, emitEvent: false });
- _this._initObservables();
- return _this;
- }
- /**
- * Set the value of the form control to `value`.
- *
- * If `onlySelf` is `true`, this change will only affect the validation of this `FormControl`
- * and not its parent component. This defaults to false.
- *
- * If `emitEvent` is `true`, this
- * change will cause a `valueChanges` event on the `FormControl` to be emitted. This defaults
- * to true (as it falls through to `updateValueAndValidity`).
- *
- * If `emitModelToViewChange` is `true`, the view will be notified about the new value
- * via an `onChange` event. This is the default behavior if `emitModelToViewChange` is not
- * specified.
- *
- * If `emitViewToModelChange` is `true`, an ngModelChange event will be fired to update the
- * model. This is the default behavior if `emitViewToModelChange` is not specified.
- * @param {?} value
- * @param {?=} options
- * @return {?}
- */
- FormControl.prototype.setValue = function (value, options) {
- var _this = this;
- if (options === void 0) { options = {}; }
- this._value = value;
- if (this._onChange.length && options.emitModelToViewChange !== false) {
- this._onChange.forEach(function (changeFn) { return changeFn(_this._value, options.emitViewToModelChange !== false); });
- }
- this.updateValueAndValidity(options);
- };
- /**
- * Patches the value of a control.
- *
- * This function is functionally the same as {\@link FormControl#setValue} at this level.
- * It exists for symmetry with {\@link FormGroup#patchValue} on `FormGroups` and `FormArrays`,
- * where it does behave differently.
- * @param {?} value
- * @param {?=} options
- * @return {?}
- */
- FormControl.prototype.patchValue = function (value, options) {
- if (options === void 0) { options = {}; }
- this.setValue(value, options);
- };
- /**
- * Resets the form control. This means by default:
- *
- * * it is marked as `pristine`
- * * it is marked as `untouched`
- * * value is set to null
- *
- * You can also reset to a specific form state by passing through a standalone
- * value or a form state object that contains both a value and a disabled state
- * (these are the only two properties that cannot be calculated).
- *
- * Ex:
- *
- * ```ts
- * this.control.reset('Nancy');
- *
- * console.log(this.control.value); // 'Nancy'
- * ```
- *
- * OR
- *
- * ```
- * this.control.reset({value: 'Nancy', disabled: true});
- *
- * console.log(this.control.value); // 'Nancy'
- * console.log(this.control.status); // 'DISABLED'
- * ```
- * @param {?=} formState
- * @param {?=} options
- * @return {?}
- */
- FormControl.prototype.reset = function (formState, options) {
- if (formState === void 0) { formState = null; }
- if (options === void 0) { options = {}; }
- this._applyFormState(formState);
- this.markAsPristine(options);
- this.markAsUntouched(options);
- this.setValue(this._value, options);
- };
- /**
- * \@internal
- * @return {?}
- */
- FormControl.prototype._updateValue = function () { };
- /**
- * \@internal
- * @param {?} condition
- * @return {?}
- */
- FormControl.prototype._anyControls = function (condition) { return false; };
- /**
- * \@internal
- * @return {?}
- */
- FormControl.prototype._allControlsDisabled = function () { return this.disabled; };
- /**
- * Register a listener for change events.
- * @param {?} fn
- * @return {?}
- */
- FormControl.prototype.registerOnChange = function (fn) { this._onChange.push(fn); };
- /**
- * \@internal
- * @return {?}
- */
- FormControl.prototype._clearChangeFns = function () {
- this._onChange = [];
- this._onDisabledChange = [];
- this._onCollectionChange = function () { };
- };
- /**
- * Register a listener for disabled events.
- * @param {?} fn
- * @return {?}
- */
- FormControl.prototype.registerOnDisabledChange = function (fn) {
- this._onDisabledChange.push(fn);
- };
- /**
- * \@internal
- * @param {?} cb
- * @return {?}
- */
- FormControl.prototype._forEachChild = function (cb) { };
- /**
- * @param {?} formState
- * @return {?}
- */
- FormControl.prototype._applyFormState = function (formState) {
- if (this._isBoxedValue(formState)) {
- this._value = formState.value;
- formState.disabled ? this.disable({ onlySelf: true, emitEvent: false }) :
- this.enable({ onlySelf: true, emitEvent: false });
- }
- else {
- this._value = formState;
- }
- };
- return FormControl;
- }(AbstractControl));
- /**
- * \@whatItDoes Tracks the value and validity state of a group of {\@link FormControl}
- * instances.
- *
- * A `FormGroup` aggregates the values of each child {\@link FormControl} into one object,
- * with each control name as the key. It calculates its status by reducing the statuses
- * of its children. For example, if one of the controls in a group is invalid, the entire
- * group becomes invalid.
- *
- * `FormGroup` is one of the three fundamental building blocks used to define forms in Angular,
- * along with {\@link FormControl} and {\@link FormArray}.
- *
- * \@howToUse
- *
- * When instantiating a {\@link FormGroup}, pass in a collection of child controls as the first
- * argument. The key for each child will be the name under which it is registered.
- *
- * ### Example
- *
- * ```
- * const form = new FormGroup({
- * first: new FormControl('Nancy', Validators.minLength(2)),
- * last: new FormControl('Drew'),
- * });
- *
- * console.log(form.value); // {first: 'Nancy', last; 'Drew'}
- * console.log(form.status); // 'VALID'
- * ```
- *
- * You can also include group-level validators as the second arg, or group-level async
- * validators as the third arg. These come in handy when you want to perform validation
- * that considers the value of more than one child control.
- *
- * ### Example
- *
- * ```
- * const form = new FormGroup({
- * password: new FormControl('', Validators.minLength(2)),
- * passwordConfirm: new FormControl('', Validators.minLength(2)),
- * }, passwordMatchValidator);
- *
- *
- * function passwordMatchValidator(g: FormGroup) {
- * return g.get('password').value === g.get('passwordConfirm').value
- * ? null : {'mismatch': true};
- * }
- * ```
- *
- * * **npm package**: `\@angular/forms`
- *
- * \@stable
- */
- var FormGroup = (function (_super) {
- __extends$1(FormGroup, _super);
- /**
- * @param {?} controls
- * @param {?=} validator
- * @param {?=} asyncValidator
- */
- function FormGroup(controls, validator, asyncValidator) {
- var _this = _super.call(this, validator || null, asyncValidator || null) || this;
- _this.controls = controls;
- _this._initObservables();
- _this._setUpControls();
- _this.updateValueAndValidity({ onlySelf: true, emitEvent: false });
- return _this;
- }
- /**
- * Registers a control with the group's list of controls.
- *
- * This method does not update value or validity of the control, so for
- * most cases you'll want to use {\@link FormGroup#addControl} instead.
- * @param {?} name
- * @param {?} control
- * @return {?}
- */
- FormGroup.prototype.registerControl = function (name, control) {
- if (this.controls[name])
- return this.controls[name];
- this.controls[name] = control;
- control.setParent(this);
- control._registerOnCollectionChange(this._onCollectionChange);
- return control;
- };
- /**
- * Add a control to this group.
- * @param {?} name
- * @param {?} control
- * @return {?}
- */
- FormGroup.prototype.addControl = function (name, control) {
- this.registerControl(name, control);
- this.updateValueAndValidity();
- this._onCollectionChange();
- };
- /**
- * Remove a control from this group.
- * @param {?} name
- * @return {?}
- */
- FormGroup.prototype.removeControl = function (name) {
- if (this.controls[name])
- this.controls[name]._registerOnCollectionChange(function () { });
- delete (this.controls[name]);
- this.updateValueAndValidity();
- this._onCollectionChange();
- };
- /**
- * Replace an existing control.
- * @param {?} name
- * @param {?} control
- * @return {?}
- */
- FormGroup.prototype.setControl = function (name, control) {
- if (this.controls[name])
- this.controls[name]._registerOnCollectionChange(function () { });
- delete (this.controls[name]);
- if (control)
- this.registerControl(name, control);
- this.updateValueAndValidity();
- this._onCollectionChange();
- };
- /**
- * Check whether there is an enabled control with the given name in the group.
- *
- * It will return false for disabled controls. If you'd like to check for
- * existence in the group only, use {\@link AbstractControl#get} instead.
- * @param {?} controlName
- * @return {?}
- */
- FormGroup.prototype.contains = function (controlName) {
- return this.controls.hasOwnProperty(controlName) && this.controls[controlName].enabled;
- };
- /**
- * Sets the value of the {\@link FormGroup}. It accepts an object that matches
- * the structure of the group, with control names as keys.
- *
- * This method performs strict checks, so it will throw an error if you try
- * to set the value of a control that doesn't exist or if you exclude the
- * value of a control.
- *
- * ### Example
- *
- * ```
- * const form = new FormGroup({
- * first: new FormControl(),
- * last: new FormControl()
- * });
- * console.log(form.value); // {first: null, last: null}
- *
- * form.setValue({first: 'Nancy', last: 'Drew'});
- * console.log(form.value); // {first: 'Nancy', last: 'Drew'}
- *
- * ```
- * @param {?} value
- * @param {?=} options
- * @return {?}
- */
- FormGroup.prototype.setValue = function (value, options) {
- var _this = this;
- if (options === void 0) { options = {}; }
- this._checkAllValuesPresent(value);
- Object.keys(value).forEach(function (name) {
- _this._throwIfControlMissing(name);
- _this.controls[name].setValue(value[name], { onlySelf: true, emitEvent: options.emitEvent });
- });
- this.updateValueAndValidity(options);
- };
- /**
- * Patches the value of the {\@link FormGroup}. It accepts an object with control
- * names as keys, and will do its best to match the values to the correct controls
- * in the group.
- *
- * It accepts both super-sets and sub-sets of the group without throwing an error.
- *
- * ### Example
- *
- * ```
- * const form = new FormGroup({
- * first: new FormControl(),
- * last: new FormControl()
- * });
- * console.log(form.value); // {first: null, last: null}
- *
- * form.patchValue({first: 'Nancy'});
- * console.log(form.value); // {first: 'Nancy', last: null}
- *
- * ```
- * @param {?} value
- * @param {?=} options
- * @return {?}
- */
- FormGroup.prototype.patchValue = function (value, options) {
- var _this = this;
- if (options === void 0) { options = {}; }
- Object.keys(value).forEach(function (name) {
- if (_this.controls[name]) {
- _this.controls[name].patchValue(value[name], { onlySelf: true, emitEvent: options.emitEvent });
- }
- });
- this.updateValueAndValidity(options);
- };
- /**
- * Resets the {\@link FormGroup}. This means by default:
- *
- * * The group and all descendants are marked `pristine`
- * * The group and all descendants are marked `untouched`
- * * The value of all descendants will be null or null maps
- *
- * You can also reset to a specific form state by passing in a map of states
- * that matches the structure of your form, with control names as keys. The state
- * can be a standalone value or a form state object with both a value and a disabled
- * status.
- *
- * ### Example
- *
- * ```ts
- * this.form.reset({first: 'name', last: 'last name'});
- *
- * console.log(this.form.value); // {first: 'name', last: 'last name'}
- * ```
- *
- * - OR -
- *
- * ```
- * this.form.reset({
- * first: {value: 'name', disabled: true},
- * last: 'last'
- * });
- *
- * console.log(this.form.value); // {first: 'name', last: 'last name'}
- * console.log(this.form.get('first').status); // 'DISABLED'
- * ```
- * @param {?=} value
- * @param {?=} options
- * @return {?}
- */
- FormGroup.prototype.reset = function (value, options) {
- if (value === void 0) { value = {}; }
- if (options === void 0) { options = {}; }
- this._forEachChild(function (control, name) {
- control.reset(value[name], { onlySelf: true, emitEvent: options.emitEvent });
- });
- this.updateValueAndValidity(options);
- this._updatePristine(options);
- this._updateTouched(options);
- };
- /**
- * The aggregate value of the {\@link FormGroup}, including any disabled controls.
- *
- * If you'd like to include all values regardless of disabled status, use this method.
- * Otherwise, the `value` property is the best way to get the value of the group.
- * @return {?}
- */
- FormGroup.prototype.getRawValue = function () {
- return this._reduceChildren({}, function (acc, control, name) {
- acc[name] = control instanceof FormControl ? control.value : ((control)).getRawValue();
- return acc;
- });
- };
- /**
- * \@internal
- * @param {?} name
- * @return {?}
- */
- FormGroup.prototype._throwIfControlMissing = function (name) {
- if (!Object.keys(this.controls).length) {
- throw new Error("\n There are no form controls registered with this group yet. If you're using ngModel,\n you may want to check next tick (e.g. use setTimeout).\n ");
- }
- if (!this.controls[name]) {
- throw new Error("Cannot find form control with name: " + name + ".");
- }
- };
- /**
- * \@internal
- * @param {?} cb
- * @return {?}
- */
- FormGroup.prototype._forEachChild = function (cb) {
- var _this = this;
- Object.keys(this.controls).forEach(function (k) { return cb(_this.controls[k], k); });
- };
- /**
- * \@internal
- * @return {?}
- */
- FormGroup.prototype._setUpControls = function () {
- var _this = this;
- this._forEachChild(function (control) {
- control.setParent(_this);
- control._registerOnCollectionChange(_this._onCollectionChange);
- });
- };
- /**
- * \@internal
- * @return {?}
- */
- FormGroup.prototype._updateValue = function () { this._value = this._reduceValue(); };
- /**
- * \@internal
- * @param {?} condition
- * @return {?}
- */
- FormGroup.prototype._anyControls = function (condition) {
- var _this = this;
- var /** @type {?} */ res = false;
- this._forEachChild(function (control, name) {
- res = res || (_this.contains(name) && condition(control));
- });
- return res;
- };
- /**
- * \@internal
- * @return {?}
- */
- FormGroup.prototype._reduceValue = function () {
- var _this = this;
- return this._reduceChildren({}, function (acc, control, name) {
- if (control.enabled || _this.disabled) {
- acc[name] = control.value;
- }
- return acc;
- });
- };
- /**
- * \@internal
- * @param {?} initValue
- * @param {?} fn
- * @return {?}
- */
- FormGroup.prototype._reduceChildren = function (initValue, fn) {
- var /** @type {?} */ res = initValue;
- this._forEachChild(function (control, name) { res = fn(res, control, name); });
- return res;
- };
- /**
- * \@internal
- * @return {?}
- */
- FormGroup.prototype._allControlsDisabled = function () {
- for (var _i = 0, _a = Object.keys(this.controls); _i < _a.length; _i++) {
- var controlName = _a[_i];
- if (this.controls[controlName].enabled) {
- return false;
- }
- }
- return Object.keys(this.controls).length > 0 || this.disabled;
- };
- /**
- * \@internal
- * @param {?} value
- * @return {?}
- */
- FormGroup.prototype._checkAllValuesPresent = function (value) {
- this._forEachChild(function (control, name) {
- if (value[name] === undefined) {
- throw new Error("Must supply a value for form control with name: '" + name + "'.");
- }
- });
- };
- return FormGroup;
- }(AbstractControl));
- /**
- * \@whatItDoes Tracks the value and validity state of an array of {\@link FormControl},
- * {\@link FormGroup} or {\@link FormArray} instances.
- *
- * A `FormArray` aggregates the values of each child {\@link FormControl} into an array.
- * It calculates its status by reducing the statuses of its children. For example, if one of
- * the controls in a `FormArray` is invalid, the entire array becomes invalid.
- *
- * `FormArray` is one of the three fundamental building blocks used to define forms in Angular,
- * along with {\@link FormControl} and {\@link FormGroup}.
- *
- * \@howToUse
- *
- * When instantiating a {\@link FormArray}, pass in an array of child controls as the first
- * argument.
- *
- * ### Example
- *
- * ```
- * const arr = new FormArray([
- * new FormControl('Nancy', Validators.minLength(2)),
- * new FormControl('Drew'),
- * ]);
- *
- * console.log(arr.value); // ['Nancy', 'Drew']
- * console.log(arr.status); // 'VALID'
- * ```
- *
- * You can also include array-level validators as the second arg, or array-level async
- * validators as the third arg. These come in handy when you want to perform validation
- * that considers the value of more than one child control.
- *
- * ### Adding or removing controls
- *
- * To change the controls in the array, use the `push`, `insert`, or `removeAt` methods
- * in `FormArray` itself. These methods ensure the controls are properly tracked in the
- * form's hierarchy. Do not modify the array of `AbstractControl`s used to instantiate
- * the `FormArray` directly, as that will result in strange and unexpected behavior such
- * as broken change detection.
- *
- * * **npm package**: `\@angular/forms`
- *
- * \@stable
- */
- var FormArray = (function (_super) {
- __extends$1(FormArray, _super);
- /**
- * @param {?} controls
- * @param {?=} validator
- * @param {?=} asyncValidator
- */
- function FormArray(controls, validator, asyncValidator) {
- var _this = _super.call(this, validator || null, asyncValidator || null) || this;
- _this.controls = controls;
- _this._initObservables();
- _this._setUpControls();
- _this.updateValueAndValidity({ onlySelf: true, emitEvent: false });
- return _this;
- }
- /**
- * Get the {\@link AbstractControl} at the given `index` in the array.
- * @param {?} index
- * @return {?}
- */
- FormArray.prototype.at = function (index) { return this.controls[index]; };
- /**
- * Insert a new {\@link AbstractControl} at the end of the array.
- * @param {?} control
- * @return {?}
- */
- FormArray.prototype.push = function (control) {
- this.controls.push(control);
- this._registerControl(control);
- this.updateValueAndValidity();
- this._onCollectionChange();
- };
- /**
- * Insert a new {\@link AbstractControl} at the given `index` in the array.
- * @param {?} index
- * @param {?} control
- * @return {?}
- */
- FormArray.prototype.insert = function (index, control) {
- this.controls.splice(index, 0, control);
- this._registerControl(control);
- this.updateValueAndValidity();
- this._onCollectionChange();
- };
- /**
- * Remove the control at the given `index` in the array.
- * @param {?} index
- * @return {?}
- */
- FormArray.prototype.removeAt = function (index) {
- if (this.controls[index])
- this.controls[index]._registerOnCollectionChange(function () { });
- this.controls.splice(index, 1);
- this.updateValueAndValidity();
- this._onCollectionChange();
- };
- /**
- * Replace an existing control.
- * @param {?} index
- * @param {?} control
- * @return {?}
- */
- FormArray.prototype.setControl = function (index, control) {
- if (this.controls[index])
- this.controls[index]._registerOnCollectionChange(function () { });
- this.controls.splice(index, 1);
- if (control) {
- this.controls.splice(index, 0, control);
- this._registerControl(control);
- }
- this.updateValueAndValidity();
- this._onCollectionChange();
- };
- Object.defineProperty(FormArray.prototype, "length", {
- /**
- * Length of the control array.
- * @return {?}
- */
- get: function () { return this.controls.length; },
- enumerable: true,
- configurable: true
- });
- /**
- * Sets the value of the {\@link FormArray}. It accepts an array that matches
- * the structure of the control.
- *
- * This method performs strict checks, so it will throw an error if you try
- * to set the value of a control that doesn't exist or if you exclude the
- * value of a control.
- *
- * ### Example
- *
- * ```
- * const arr = new FormArray([
- * new FormControl(),
- * new FormControl()
- * ]);
- * console.log(arr.value); // [null, null]
- *
- * arr.setValue(['Nancy', 'Drew']);
- * console.log(arr.value); // ['Nancy', 'Drew']
- * ```
- * @param {?} value
- * @param {?=} options
- * @return {?}
- */
- FormArray.prototype.setValue = function (value, options) {
- var _this = this;
- if (options === void 0) { options = {}; }
- this._checkAllValuesPresent(value);
- value.forEach(function (newValue, index) {
- _this._throwIfControlMissing(index);
- _this.at(index).setValue(newValue, { onlySelf: true, emitEvent: options.emitEvent });
- });
- this.updateValueAndValidity(options);
- };
- /**
- * Patches the value of the {\@link FormArray}. It accepts an array that matches the
- * structure of the control, and will do its best to match the values to the correct
- * controls in the group.
- *
- * It accepts both super-sets and sub-sets of the array without throwing an error.
- *
- * ### Example
- *
- * ```
- * const arr = new FormArray([
- * new FormControl(),
- * new FormControl()
- * ]);
- * console.log(arr.value); // [null, null]
- *
- * arr.patchValue(['Nancy']);
- * console.log(arr.value); // ['Nancy', null]
- * ```
- * @param {?} value
- * @param {?=} options
- * @return {?}
- */
- FormArray.prototype.patchValue = function (value, options) {
- var _this = this;
- if (options === void 0) { options = {}; }
- value.forEach(function (newValue, index) {
- if (_this.at(index)) {
- _this.at(index).patchValue(newValue, { onlySelf: true, emitEvent: options.emitEvent });
- }
- });
- this.updateValueAndValidity(options);
- };
- /**
- * Resets the {\@link FormArray}. This means by default:
- *
- * * The array and all descendants are marked `pristine`
- * * The array and all descendants are marked `untouched`
- * * The value of all descendants will be null or null maps
- *
- * You can also reset to a specific form state by passing in an array of states
- * that matches the structure of the control. The state can be a standalone value
- * or a form state object with both a value and a disabled status.
- *
- * ### Example
- *
- * ```ts
- * this.arr.reset(['name', 'last name']);
- *
- * console.log(this.arr.value); // ['name', 'last name']
- * ```
- *
- * - OR -
- *
- * ```
- * this.arr.reset([
- * {value: 'name', disabled: true},
- * 'last'
- * ]);
- *
- * console.log(this.arr.value); // ['name', 'last name']
- * console.log(this.arr.get(0).status); // 'DISABLED'
- * ```
- * @param {?=} value
- * @param {?=} options
- * @return {?}
- */
- FormArray.prototype.reset = function (value, options) {
- if (value === void 0) { value = []; }
- if (options === void 0) { options = {}; }
- this._forEachChild(function (control, index) {
- control.reset(value[index], { onlySelf: true, emitEvent: options.emitEvent });
- });
- this.updateValueAndValidity(options);
- this._updatePristine(options);
- this._updateTouched(options);
- };
- /**
- * The aggregate value of the array, including any disabled controls.
- *
- * If you'd like to include all values regardless of disabled status, use this method.
- * Otherwise, the `value` property is the best way to get the value of the array.
- * @return {?}
- */
- FormArray.prototype.getRawValue = function () {
- return this.controls.map(function (control) {
- return control instanceof FormControl ? control.value : ((control)).getRawValue();
- });
- };
- /**
- * \@internal
- * @param {?} index
- * @return {?}
- */
- FormArray.prototype._throwIfControlMissing = function (index) {
- if (!this.controls.length) {
- throw new Error("\n There are no form controls registered with this array yet. If you're using ngModel,\n you may want to check next tick (e.g. use setTimeout).\n ");
- }
- if (!this.at(index)) {
- throw new Error("Cannot find form control at index " + index);
- }
- };
- /**
- * \@internal
- * @param {?} cb
- * @return {?}
- */
- FormArray.prototype._forEachChild = function (cb) {
- this.controls.forEach(function (control, index) { cb(control, index); });
- };
- /**
- * \@internal
- * @return {?}
- */
- FormArray.prototype._updateValue = function () {
- var _this = this;
- this._value = this.controls.filter(function (control) { return control.enabled || _this.disabled; })
- .map(function (control) { return control.value; });
- };
- /**
- * \@internal
- * @param {?} condition
- * @return {?}
- */
- FormArray.prototype._anyControls = function (condition) {
- return this.controls.some(function (control) { return control.enabled && condition(control); });
- };
- /**
- * \@internal
- * @return {?}
- */
- FormArray.prototype._setUpControls = function () {
- var _this = this;
- this._forEachChild(function (control) { return _this._registerControl(control); });
- };
- /**
- * \@internal
- * @param {?} value
- * @return {?}
- */
- FormArray.prototype._checkAllValuesPresent = function (value) {
- this._forEachChild(function (control, i) {
- if (value[i] === undefined) {
- throw new Error("Must supply a value for form control at index: " + i + ".");
- }
- });
- };
- /**
- * \@internal
- * @return {?}
- */
- FormArray.prototype._allControlsDisabled = function () {
- for (var _i = 0, _a = this.controls; _i < _a.length; _i++) {
- var control = _a[_i];
- if (control.enabled)
- return false;
- }
- return this.controls.length > 0 || this.disabled;
- };
- /**
- * @param {?} control
- * @return {?}
- */
- FormArray.prototype._registerControl = function (control) {
- control.setParent(this);
- control._registerOnCollectionChange(this._onCollectionChange);
- };
- return FormArray;
- }(AbstractControl));
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var formDirectiveProvider = {
- provide: ControlContainer,
- useExisting: forwardRef(function () { return NgForm; })
- };
- var resolvedPromise = Promise.resolve(null);
- /**
- * \@whatItDoes Creates a top-level {\@link FormGroup} instance and binds it to a form
- * to track aggregate form value and validation status.
- *
- * \@howToUse
- *
- * As soon as you import the `FormsModule`, this directive becomes active by default on
- * all `<form>` tags. You don't need to add a special selector.
- *
- * You can export the directive into a local template variable using `ngForm` as the key
- * (ex: `#myForm="ngForm"`). This is optional, but useful. Many properties from the underlying
- * {\@link FormGroup} instance are duplicated on the directive itself, so a reference to it
- * will give you access to the aggregate value and validity status of the form, as well as
- * user interaction properties like `dirty` and `touched`.
- *
- * To register child controls with the form, you'll want to use {\@link NgModel} with a
- * `name` attribute. You can also use {\@link NgModelGroup} if you'd like to create
- * sub-groups within the form.
- *
- * You can listen to the directive's `ngSubmit` event to be notified when the user has
- * triggered a form submission. The `ngSubmit` event will be emitted with the original form
- * submission event.
- *
- * In template driven forms, all `<form>` tags are automatically tagged as `NgForm`.
- * If you want to import the `FormsModule` but skip its usage in some forms,
- * for example, to use native HTML5 validation, you can add `ngNoForm` and the `<form>`
- * tags won't create an `NgForm` directive. In reactive forms, using `ngNoForm` is
- * unnecessary because the `<form>` tags are inert. In that case, you would
- * refrain from using the `formGroup` directive.
- *
- * {\@example forms/ts/simpleForm/simple_form_example.ts region='Component'}
- *
- * * **npm package**: `\@angular/forms`
- *
- * * **NgModule**: `FormsModule`
- *
- * \@stable
- */
- var NgForm = (function (_super) {
- __extends$1(NgForm, _super);
- /**
- * @param {?} validators
- * @param {?} asyncValidators
- */
- function NgForm(validators, asyncValidators) {
- var _this = _super.call(this) || this;
- _this._submitted = false;
- _this.ngSubmit = new EventEmitter();
- _this.form =
- new FormGroup({}, composeValidators(validators), composeAsyncValidators(asyncValidators));
- return _this;
- }
- Object.defineProperty(NgForm.prototype, "submitted", {
- /**
- * @return {?}
- */
- get: function () { return this._submitted; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(NgForm.prototype, "formDirective", {
- /**
- * @return {?}
- */
- get: function () { return this; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(NgForm.prototype, "control", {
- /**
- * @return {?}
- */
- get: function () { return this.form; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(NgForm.prototype, "path", {
- /**
- * @return {?}
- */
- get: function () { return []; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(NgForm.prototype, "controls", {
- /**
- * @return {?}
- */
- get: function () { return this.form.controls; },
- enumerable: true,
- configurable: true
- });
- /**
- * @param {?} dir
- * @return {?}
- */
- NgForm.prototype.addControl = function (dir) {
- var _this = this;
- resolvedPromise.then(function () {
- var /** @type {?} */ container = _this._findContainer(dir.path);
- dir._control = (container.registerControl(dir.name, dir.control));
- setUpControl(dir.control, dir);
- dir.control.updateValueAndValidity({ emitEvent: false });
- });
- };
- /**
- * @param {?} dir
- * @return {?}
- */
- NgForm.prototype.getControl = function (dir) { return (this.form.get(dir.path)); };
- /**
- * @param {?} dir
- * @return {?}
- */
- NgForm.prototype.removeControl = function (dir) {
- var _this = this;
- resolvedPromise.then(function () {
- var /** @type {?} */ container = _this._findContainer(dir.path);
- if (container) {
- container.removeControl(dir.name);
- }
- });
- };
- /**
- * @param {?} dir
- * @return {?}
- */
- NgForm.prototype.addFormGroup = function (dir) {
- var _this = this;
- resolvedPromise.then(function () {
- var /** @type {?} */ container = _this._findContainer(dir.path);
- var /** @type {?} */ group$$1 = new FormGroup({});
- setUpFormContainer(group$$1, dir);
- container.registerControl(dir.name, group$$1);
- group$$1.updateValueAndValidity({ emitEvent: false });
- });
- };
- /**
- * @param {?} dir
- * @return {?}
- */
- NgForm.prototype.removeFormGroup = function (dir) {
- var _this = this;
- resolvedPromise.then(function () {
- var /** @type {?} */ container = _this._findContainer(dir.path);
- if (container) {
- container.removeControl(dir.name);
- }
- });
- };
- /**
- * @param {?} dir
- * @return {?}
- */
- NgForm.prototype.getFormGroup = function (dir) { return (this.form.get(dir.path)); };
- /**
- * @param {?} dir
- * @param {?} value
- * @return {?}
- */
- NgForm.prototype.updateModel = function (dir, value) {
- var _this = this;
- resolvedPromise.then(function () {
- var /** @type {?} */ ctrl = (_this.form.get(/** @type {?} */ ((dir.path))));
- ctrl.setValue(value);
- });
- };
- /**
- * @param {?} value
- * @return {?}
- */
- NgForm.prototype.setValue = function (value) { this.control.setValue(value); };
- /**
- * @param {?} $event
- * @return {?}
- */
- NgForm.prototype.onSubmit = function ($event) {
- this._submitted = true;
- this.ngSubmit.emit($event);
- return false;
- };
- /**
- * @return {?}
- */
- NgForm.prototype.onReset = function () { this.resetForm(); };
- /**
- * @param {?=} value
- * @return {?}
- */
- NgForm.prototype.resetForm = function (value) {
- if (value === void 0) { value = undefined; }
- this.form.reset(value);
- this._submitted = false;
- };
- /**
- * \@internal
- * @param {?} path
- * @return {?}
- */
- NgForm.prototype._findContainer = function (path) {
- path.pop();
- return path.length ? (this.form.get(path)) : this.form;
- };
- return NgForm;
- }(ControlContainer));
- NgForm.decorators = [
- { type: Directive, args: [{
- selector: 'form:not([ngNoForm]):not([formGroup]),ngForm,[ngForm]',
- providers: [formDirectiveProvider],
- host: { '(submit)': 'onSubmit($event)', '(reset)': 'onReset()' },
- outputs: ['ngSubmit'],
- exportAs: 'ngForm'
- },] },
- ];
- /**
- * @nocollapse
- */
- NgForm.ctorParameters = function () { return [
- { type: Array, decorators: [{ type: Optional }, { type: Self }, { type: Inject, args: [NG_VALIDATORS,] },] },
- { type: Array, decorators: [{ type: Optional }, { type: Self }, { type: Inject, args: [NG_ASYNC_VALIDATORS,] },] },
- ]; };
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var FormErrorExamples = {
- formControlName: "\n <div [formGroup]=\"myGroup\">\n <input formControlName=\"firstName\">\n </div>\n\n In your class:\n\n this.myGroup = new FormGroup({\n firstName: new FormControl()\n });",
- formGroupName: "\n <div [formGroup]=\"myGroup\">\n <div formGroupName=\"person\">\n <input formControlName=\"firstName\">\n </div>\n </div>\n\n In your class:\n\n this.myGroup = new FormGroup({\n person: new FormGroup({ firstName: new FormControl() })\n });",
- formArrayName: "\n <div [formGroup]=\"myGroup\">\n <div formArrayName=\"cities\">\n <div *ngFor=\"let city of cityArray.controls; index as i\">\n <input [formControlName]=\"i\">\n </div>\n </div>\n </div>\n\n In your class:\n\n this.cityArray = new FormArray([new FormControl('SF')]);\n this.myGroup = new FormGroup({\n cities: this.cityArray\n });",
- ngModelGroup: "\n <form>\n <div ngModelGroup=\"person\">\n <input [(ngModel)]=\"person.name\" name=\"firstName\">\n </div>\n </form>",
- ngModelWithFormGroup: "\n <div [formGroup]=\"myGroup\">\n <input formControlName=\"firstName\">\n <input [(ngModel)]=\"showMoreControls\" [ngModelOptions]=\"{standalone: true}\">\n </div>\n "
- };
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var TemplateDrivenErrors = (function () {
- function TemplateDrivenErrors() {
- }
- /**
- * @return {?}
- */
- TemplateDrivenErrors.modelParentException = function () {
- throw new Error("\n ngModel cannot be used to register form controls with a parent formGroup directive. Try using\n formGroup's partner directive \"formControlName\" instead. Example:\n\n " + FormErrorExamples.formControlName + "\n\n Or, if you'd like to avoid registering this form control, indicate that it's standalone in ngModelOptions:\n\n Example:\n\n " + FormErrorExamples.ngModelWithFormGroup);
- };
- /**
- * @return {?}
- */
- TemplateDrivenErrors.formGroupNameException = function () {
- throw new Error("\n ngModel cannot be used to register form controls with a parent formGroupName or formArrayName directive.\n\n Option 1: Use formControlName instead of ngModel (reactive strategy):\n\n " + FormErrorExamples.formGroupName + "\n\n Option 2: Update ngModel's parent be ngModelGroup (template-driven strategy):\n\n " + FormErrorExamples.ngModelGroup);
- };
- /**
- * @return {?}
- */
- TemplateDrivenErrors.missingNameException = function () {
- throw new Error("If ngModel is used within a form tag, either the name attribute must be set or the form\n control must be defined as 'standalone' in ngModelOptions.\n\n Example 1: <input [(ngModel)]=\"person.firstName\" name=\"first\">\n Example 2: <input [(ngModel)]=\"person.firstName\" [ngModelOptions]=\"{standalone: true}\">");
- };
- /**
- * @return {?}
- */
- TemplateDrivenErrors.modelGroupParentException = function () {
- throw new Error("\n ngModelGroup cannot be used with a parent formGroup directive.\n\n Option 1: Use formGroupName instead of ngModelGroup (reactive strategy):\n\n " + FormErrorExamples.formGroupName + "\n\n Option 2: Use a regular form tag instead of the formGroup directive (template-driven strategy):\n\n " + FormErrorExamples.ngModelGroup);
- };
- return TemplateDrivenErrors;
- }());
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var modelGroupProvider = {
- provide: ControlContainer,
- useExisting: forwardRef(function () { return NgModelGroup; })
- };
- /**
- * \@whatItDoes Creates and binds a {\@link FormGroup} instance to a DOM element.
- *
- * \@howToUse
- *
- * This directive can only be used as a child of {\@link NgForm} (or in other words,
- * within `<form>` tags).
- *
- * Use this directive if you'd like to create a sub-group within a form. This can
- * come in handy if you want to validate a sub-group of your form separately from
- * the rest of your form, or if some values in your domain model make more sense to
- * consume together in a nested object.
- *
- * Pass in the name you'd like this sub-group to have and it will become the key
- * for the sub-group in the form's full value. You can also export the directive into
- * a local template variable using `ngModelGroup` (ex: `#myGroup="ngModelGroup"`).
- *
- * {\@example forms/ts/ngModelGroup/ng_model_group_example.ts region='Component'}
- *
- * * **npm package**: `\@angular/forms`
- *
- * * **NgModule**: `FormsModule`
- *
- * \@stable
- */
- var NgModelGroup = (function (_super) {
- __extends$1(NgModelGroup, _super);
- /**
- * @param {?} parent
- * @param {?} validators
- * @param {?} asyncValidators
- */
- function NgModelGroup(parent, validators, asyncValidators) {
- var _this = _super.call(this) || this;
- _this._parent = parent;
- _this._validators = validators;
- _this._asyncValidators = asyncValidators;
- return _this;
- }
- /**
- * \@internal
- * @return {?}
- */
- NgModelGroup.prototype._checkParentType = function () {
- if (!(this._parent instanceof NgModelGroup) && !(this._parent instanceof NgForm)) {
- TemplateDrivenErrors.modelGroupParentException();
- }
- };
- return NgModelGroup;
- }(AbstractFormGroupDirective));
- NgModelGroup.decorators = [
- { type: Directive, args: [{ selector: '[ngModelGroup]', providers: [modelGroupProvider], exportAs: 'ngModelGroup' },] },
- ];
- /**
- * @nocollapse
- */
- NgModelGroup.ctorParameters = function () { return [
- { type: ControlContainer, decorators: [{ type: Host }, { type: SkipSelf },] },
- { type: Array, decorators: [{ type: Optional }, { type: Self }, { type: Inject, args: [NG_VALIDATORS,] },] },
- { type: Array, decorators: [{ type: Optional }, { type: Self }, { type: Inject, args: [NG_ASYNC_VALIDATORS,] },] },
- ]; };
- NgModelGroup.propDecorators = {
- 'name': [{ type: Input, args: ['ngModelGroup',] },],
- };
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var formControlBinding = {
- provide: NgControl,
- useExisting: forwardRef(function () { return NgModel; })
- };
- /**
- * `ngModel` forces an additional change detection run when its inputs change:
- * E.g.:
- * ```
- * <div>{{myModel.valid}}</div>
- * <input [(ngModel)]="myValue" #myModel="ngModel">
- * ```
- * I.e. `ngModel` can export itself on the element and then be used in the template.
- * Normally, this would result in expressions before the `input` that use the exported directive
- * to have and old value as they have been
- * dirty checked before. As this is a very common case for `ngModel`, we added this second change
- * detection run.
- *
- * Notes:
- * - this is just one extra run no matter how many `ngModel` have been changed.
- * - this is a general problem when using `exportAs` for directives!
- */
- var resolvedPromise$1 = Promise.resolve(null);
- /**
- * \@whatItDoes Creates a {\@link FormControl} instance from a domain model and binds it
- * to a form control element.
- *
- * The {\@link FormControl} instance will track the value, user interaction, and
- * validation status of the control and keep the view synced with the model. If used
- * within a parent form, the directive will also register itself with the form as a child
- * control.
- *
- * \@howToUse
- *
- * This directive can be used by itself or as part of a larger form. All you need is the
- * `ngModel` selector to activate it.
- *
- * It accepts a domain model as an optional {\@link Input}. If you have a one-way binding
- * to `ngModel` with `[]` syntax, changing the value of the domain model in the component
- * class will set the value in the view. If you have a two-way binding with `[()]` syntax
- * (also known as 'banana-box syntax'), the value in the UI will always be synced back to
- * the domain model in your class as well.
- *
- * If you wish to inspect the properties of the associated {\@link FormControl} (like
- * validity state), you can also export the directive into a local template variable using
- * `ngModel` as the key (ex: `#myVar="ngModel"`). You can then access the control using the
- * directive's `control` property, but most properties you'll need (like `valid` and `dirty`)
- * will fall through to the control anyway, so you can access them directly. You can see a
- * full list of properties directly available in {\@link AbstractControlDirective}.
- *
- * The following is an example of a simple standalone control using `ngModel`:
- *
- * {\@example forms/ts/simpleNgModel/simple_ng_model_example.ts region='Component'}
- *
- * When using the `ngModel` within `<form>` tags, you'll also need to supply a `name` attribute
- * so that the control can be registered with the parent form under that name.
- *
- * It's worth noting that in the context of a parent form, you often can skip one-way or
- * two-way binding because the parent form will sync the value for you. You can access
- * its properties by exporting it into a local template variable using `ngForm` (ex:
- * `#f="ngForm"`). Then you can pass it where it needs to go on submit.
- *
- * If you do need to populate initial values into your form, using a one-way binding for
- * `ngModel` tends to be sufficient as long as you use the exported form's value rather
- * than the domain model's value on submit.
- *
- * Take a look at an example of using `ngModel` within a form:
- *
- * {\@example forms/ts/simpleForm/simple_form_example.ts region='Component'}
- *
- * To see `ngModel` examples with different form control types, see:
- *
- * * Radio buttons: {\@link RadioControlValueAccessor}
- * * Selects: {\@link SelectControlValueAccessor}
- *
- * **npm package**: `\@angular/forms`
- *
- * **NgModule**: `FormsModule`
- *
- * \@stable
- */
- var NgModel = (function (_super) {
- __extends$1(NgModel, _super);
- /**
- * @param {?} parent
- * @param {?} validators
- * @param {?} asyncValidators
- * @param {?} valueAccessors
- */
- function NgModel(parent, validators, asyncValidators, valueAccessors) {
- var _this = _super.call(this) || this;
- /**
- * \@internal
- */
- _this._control = new FormControl();
- /**
- * \@internal
- */
- _this._registered = false;
- _this.update = new EventEmitter();
- _this._parent = parent;
- _this._rawValidators = validators || [];
- _this._rawAsyncValidators = asyncValidators || [];
- _this.valueAccessor = selectValueAccessor(_this, valueAccessors);
- return _this;
- }
- /**
- * @param {?} changes
- * @return {?}
- */
- NgModel.prototype.ngOnChanges = function (changes) {
- this._checkForErrors();
- if (!this._registered)
- this._setUpControl();
- if ('isDisabled' in changes) {
- this._updateDisabled(changes);
- }
- if (isPropertyUpdated(changes, this.viewModel)) {
- this._updateValue(this.model);
- this.viewModel = this.model;
- }
- };
- /**
- * @return {?}
- */
- NgModel.prototype.ngOnDestroy = function () { this.formDirective && this.formDirective.removeControl(this); };
- Object.defineProperty(NgModel.prototype, "control", {
- /**
- * @return {?}
- */
- get: function () { return this._control; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(NgModel.prototype, "path", {
- /**
- * @return {?}
- */
- get: function () {
- return this._parent ? controlPath(this.name, this._parent) : [this.name];
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(NgModel.prototype, "formDirective", {
- /**
- * @return {?}
- */
- get: function () { return this._parent ? this._parent.formDirective : null; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(NgModel.prototype, "validator", {
- /**
- * @return {?}
- */
- get: function () { return composeValidators(this._rawValidators); },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(NgModel.prototype, "asyncValidator", {
- /**
- * @return {?}
- */
- get: function () {
- return composeAsyncValidators(this._rawAsyncValidators);
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @param {?} newValue
- * @return {?}
- */
- NgModel.prototype.viewToModelUpdate = function (newValue) {
- this.viewModel = newValue;
- this.update.emit(newValue);
- };
- /**
- * @return {?}
- */
- NgModel.prototype._setUpControl = function () {
- this._isStandalone() ? this._setUpStandalone() :
- this.formDirective.addControl(this);
- this._registered = true;
- };
- /**
- * @return {?}
- */
- NgModel.prototype._isStandalone = function () {
- return !this._parent || !!(this.options && this.options.standalone);
- };
- /**
- * @return {?}
- */
- NgModel.prototype._setUpStandalone = function () {
- setUpControl(this._control, this);
- this._control.updateValueAndValidity({ emitEvent: false });
- };
- /**
- * @return {?}
- */
- NgModel.prototype._checkForErrors = function () {
- if (!this._isStandalone()) {
- this._checkParentType();
- }
- this._checkName();
- };
- /**
- * @return {?}
- */
- NgModel.prototype._checkParentType = function () {
- if (!(this._parent instanceof NgModelGroup) &&
- this._parent instanceof AbstractFormGroupDirective) {
- TemplateDrivenErrors.formGroupNameException();
- }
- else if (!(this._parent instanceof NgModelGroup) && !(this._parent instanceof NgForm)) {
- TemplateDrivenErrors.modelParentException();
- }
- };
- /**
- * @return {?}
- */
- NgModel.prototype._checkName = function () {
- if (this.options && this.options.name)
- this.name = this.options.name;
- if (!this._isStandalone() && !this.name) {
- TemplateDrivenErrors.missingNameException();
- }
- };
- /**
- * @param {?} value
- * @return {?}
- */
- NgModel.prototype._updateValue = function (value) {
- var _this = this;
- resolvedPromise$1.then(function () { _this.control.setValue(value, { emitViewToModelChange: false }); });
- };
- /**
- * @param {?} changes
- * @return {?}
- */
- NgModel.prototype._updateDisabled = function (changes) {
- var _this = this;
- var /** @type {?} */ disabledValue = changes['isDisabled'].currentValue;
- var /** @type {?} */ isDisabled = disabledValue === '' || (disabledValue && disabledValue !== 'false');
- resolvedPromise$1.then(function () {
- if (isDisabled && !_this.control.disabled) {
- _this.control.disable();
- }
- else if (!isDisabled && _this.control.disabled) {
- _this.control.enable();
- }
- });
- };
- return NgModel;
- }(NgControl));
- NgModel.decorators = [
- { type: Directive, args: [{
- selector: '[ngModel]:not([formControlName]):not([formControl])',
- providers: [formControlBinding],
- exportAs: 'ngModel'
- },] },
- ];
- /**
- * @nocollapse
- */
- NgModel.ctorParameters = function () { return [
- { type: ControlContainer, decorators: [{ type: Optional }, { type: Host },] },
- { type: Array, decorators: [{ type: Optional }, { type: Self }, { type: Inject, args: [NG_VALIDATORS,] },] },
- { type: Array, decorators: [{ type: Optional }, { type: Self }, { type: Inject, args: [NG_ASYNC_VALIDATORS,] },] },
- { type: Array, decorators: [{ type: Optional }, { type: Self }, { type: Inject, args: [NG_VALUE_ACCESSOR,] },] },
- ]; };
- NgModel.propDecorators = {
- 'name': [{ type: Input },],
- 'isDisabled': [{ type: Input, args: ['disabled',] },],
- 'model': [{ type: Input, args: ['ngModel',] },],
- 'options': [{ type: Input, args: ['ngModelOptions',] },],
- 'update': [{ type: Output, args: ['ngModelChange',] },],
- };
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var ReactiveErrors = (function () {
- function ReactiveErrors() {
- }
- /**
- * @return {?}
- */
- ReactiveErrors.controlParentException = function () {
- throw new Error("formControlName must be used with a parent formGroup directive. You'll want to add a formGroup\n directive and pass it an existing FormGroup instance (you can create one in your class).\n\n Example:\n\n " + FormErrorExamples.formControlName);
- };
- /**
- * @return {?}
- */
- ReactiveErrors.ngModelGroupException = function () {
- throw new Error("formControlName cannot be used with an ngModelGroup parent. It is only compatible with parents\n that also have a \"form\" prefix: formGroupName, formArrayName, or formGroup.\n\n Option 1: Update the parent to be formGroupName (reactive form strategy)\n\n " + FormErrorExamples.formGroupName + "\n\n Option 2: Use ngModel instead of formControlName (template-driven strategy)\n\n " + FormErrorExamples.ngModelGroup);
- };
- /**
- * @return {?}
- */
- ReactiveErrors.missingFormException = function () {
- throw new Error("formGroup expects a FormGroup instance. Please pass one in.\n\n Example:\n\n " + FormErrorExamples.formControlName);
- };
- /**
- * @return {?}
- */
- ReactiveErrors.groupParentException = function () {
- throw new Error("formGroupName must be used with a parent formGroup directive. You'll want to add a formGroup\n directive and pass it an existing FormGroup instance (you can create one in your class).\n\n Example:\n\n " + FormErrorExamples.formGroupName);
- };
- /**
- * @return {?}
- */
- ReactiveErrors.arrayParentException = function () {
- throw new Error("formArrayName must be used with a parent formGroup directive. You'll want to add a formGroup\n directive and pass it an existing FormGroup instance (you can create one in your class).\n\n Example:\n\n " + FormErrorExamples.formArrayName);
- };
- /**
- * @return {?}
- */
- ReactiveErrors.disabledAttrWarning = function () {
- console.warn("\n It looks like you're using the disabled attribute with a reactive form directive. If you set disabled to true\n when you set up this control in your component class, the disabled attribute will actually be set in the DOM for\n you. We recommend using this approach to avoid 'changed after checked' errors.\n \n Example: \n form = new FormGroup({\n first: new FormControl({value: 'Nancy', disabled: true}, Validators.required),\n last: new FormControl('Drew', Validators.required)\n });\n ");
- };
- return ReactiveErrors;
- }());
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var formControlBinding$1 = {
- provide: NgControl,
- useExisting: forwardRef(function () { return FormControlDirective; })
- };
- /**
- * \@whatItDoes Syncs a standalone {\@link FormControl} instance to a form control element.
- *
- * In other words, this directive ensures that any values written to the {\@link FormControl}
- * instance programmatically will be written to the DOM element (model -> view). Conversely,
- * any values written to the DOM element through user input will be reflected in the
- * {\@link FormControl} instance (view -> model).
- *
- * \@howToUse
- *
- * Use this directive if you'd like to create and manage a {\@link FormControl} instance directly.
- * Simply create a {\@link FormControl}, save it to your component class, and pass it into the
- * {\@link FormControlDirective}.
- *
- * This directive is designed to be used as a standalone control. Unlike {\@link FormControlName},
- * it does not require that your {\@link FormControl} instance be part of any parent
- * {\@link FormGroup}, and it won't be registered to any {\@link FormGroupDirective} that
- * exists above it.
- *
- * **Get the value**: the `value` property is always synced and available on the
- * {\@link FormControl} instance. See a full list of available properties in
- * {\@link AbstractControl}.
- *
- * **Set the value**: You can pass in an initial value when instantiating the {\@link FormControl},
- * or you can set it programmatically later using {\@link AbstractControl#setValue setValue} or
- * {\@link AbstractControl#patchValue patchValue}.
- *
- * **Listen to value**: If you want to listen to changes in the value of the control, you can
- * subscribe to the {\@link AbstractControl#valueChanges valueChanges} event. You can also listen to
- * {\@link AbstractControl#statusChanges statusChanges} to be notified when the validation status is
- * re-calculated.
- *
- * ### Example
- *
- * {\@example forms/ts/simpleFormControl/simple_form_control_example.ts region='Component'}
- *
- * * **npm package**: `\@angular/forms`
- *
- * * **NgModule**: `ReactiveFormsModule`
- *
- * \@stable
- */
- var FormControlDirective = (function (_super) {
- __extends$1(FormControlDirective, _super);
- /**
- * @param {?} validators
- * @param {?} asyncValidators
- * @param {?} valueAccessors
- */
- function FormControlDirective(validators, asyncValidators, valueAccessors) {
- var _this = _super.call(this) || this;
- _this.update = new EventEmitter();
- _this._rawValidators = validators || [];
- _this._rawAsyncValidators = asyncValidators || [];
- _this.valueAccessor = selectValueAccessor(_this, valueAccessors);
- return _this;
- }
- Object.defineProperty(FormControlDirective.prototype, "isDisabled", {
- /**
- * @param {?} isDisabled
- * @return {?}
- */
- set: function (isDisabled) { ReactiveErrors.disabledAttrWarning(); },
- enumerable: true,
- configurable: true
- });
- /**
- * @param {?} changes
- * @return {?}
- */
- FormControlDirective.prototype.ngOnChanges = function (changes) {
- if (this._isControlChanged(changes)) {
- setUpControl(this.form, this);
- if (this.control.disabled && ((this.valueAccessor)).setDisabledState) {
- ((((this.valueAccessor)).setDisabledState))(true);
- }
- this.form.updateValueAndValidity({ emitEvent: false });
- }
- if (isPropertyUpdated(changes, this.viewModel)) {
- this.form.setValue(this.model);
- this.viewModel = this.model;
- }
- };
- Object.defineProperty(FormControlDirective.prototype, "path", {
- /**
- * @return {?}
- */
- get: function () { return []; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(FormControlDirective.prototype, "validator", {
- /**
- * @return {?}
- */
- get: function () { return composeValidators(this._rawValidators); },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(FormControlDirective.prototype, "asyncValidator", {
- /**
- * @return {?}
- */
- get: function () {
- return composeAsyncValidators(this._rawAsyncValidators);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(FormControlDirective.prototype, "control", {
- /**
- * @return {?}
- */
- get: function () { return this.form; },
- enumerable: true,
- configurable: true
- });
- /**
- * @param {?} newValue
- * @return {?}
- */
- FormControlDirective.prototype.viewToModelUpdate = function (newValue) {
- this.viewModel = newValue;
- this.update.emit(newValue);
- };
- /**
- * @param {?} changes
- * @return {?}
- */
- FormControlDirective.prototype._isControlChanged = function (changes) {
- return changes.hasOwnProperty('form');
- };
- return FormControlDirective;
- }(NgControl));
- FormControlDirective.decorators = [
- { type: Directive, args: [{ selector: '[formControl]', providers: [formControlBinding$1], exportAs: 'ngForm' },] },
- ];
- /**
- * @nocollapse
- */
- FormControlDirective.ctorParameters = function () { return [
- { type: Array, decorators: [{ type: Optional }, { type: Self }, { type: Inject, args: [NG_VALIDATORS,] },] },
- { type: Array, decorators: [{ type: Optional }, { type: Self }, { type: Inject, args: [NG_ASYNC_VALIDATORS,] },] },
- { type: Array, decorators: [{ type: Optional }, { type: Self }, { type: Inject, args: [NG_VALUE_ACCESSOR,] },] },
- ]; };
- FormControlDirective.propDecorators = {
- 'form': [{ type: Input, args: ['formControl',] },],
- 'model': [{ type: Input, args: ['ngModel',] },],
- 'update': [{ type: Output, args: ['ngModelChange',] },],
- 'isDisabled': [{ type: Input, args: ['disabled',] },],
- };
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var formDirectiveProvider$1 = {
- provide: ControlContainer,
- useExisting: forwardRef(function () { return FormGroupDirective; })
- };
- /**
- * \@whatItDoes Binds an existing {\@link FormGroup} to a DOM element.
- *
- * \@howToUse
- *
- * This directive accepts an existing {\@link FormGroup} instance. It will then use this
- * {\@link FormGroup} instance to match any child {\@link FormControl}, {\@link FormGroup},
- * and {\@link FormArray} instances to child {\@link FormControlName}, {\@link FormGroupName},
- * and {\@link FormArrayName} directives.
- *
- * **Set value**: You can set the form's initial value when instantiating the
- * {\@link FormGroup}, or you can set it programmatically later using the {\@link FormGroup}'s
- * {\@link AbstractControl#setValue setValue} or {\@link AbstractControl#patchValue patchValue}
- * methods.
- *
- * **Listen to value**: If you want to listen to changes in the value of the form, you can subscribe
- * to the {\@link FormGroup}'s {\@link AbstractControl#valueChanges valueChanges} event. You can also
- * listen to its {\@link AbstractControl#statusChanges statusChanges} event to be notified when the
- * validation status is re-calculated.
- *
- * Furthermore, you can listen to the directive's `ngSubmit` event to be notified when the user has
- * triggered a form submission. The `ngSubmit` event will be emitted with the original form
- * submission event.
- *
- * ### Example
- *
- * In this example, we create form controls for first name and last name.
- *
- * {\@example forms/ts/simpleFormGroup/simple_form_group_example.ts region='Component'}
- *
- * **npm package**: `\@angular/forms`
- *
- * **NgModule**: {\@link ReactiveFormsModule}
- *
- * \@stable
- */
- var FormGroupDirective = (function (_super) {
- __extends$1(FormGroupDirective, _super);
- /**
- * @param {?} _validators
- * @param {?} _asyncValidators
- */
- function FormGroupDirective(_validators, _asyncValidators) {
- var _this = _super.call(this) || this;
- _this._validators = _validators;
- _this._asyncValidators = _asyncValidators;
- _this._submitted = false;
- _this.directives = [];
- _this.form = ((null));
- _this.ngSubmit = new EventEmitter();
- return _this;
- }
- /**
- * @param {?} changes
- * @return {?}
- */
- FormGroupDirective.prototype.ngOnChanges = function (changes) {
- this._checkFormPresent();
- if (changes.hasOwnProperty('form')) {
- this._updateValidators();
- this._updateDomValue();
- this._updateRegistrations();
- }
- };
- Object.defineProperty(FormGroupDirective.prototype, "submitted", {
- /**
- * @return {?}
- */
- get: function () { return this._submitted; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(FormGroupDirective.prototype, "formDirective", {
- /**
- * @return {?}
- */
- get: function () { return this; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(FormGroupDirective.prototype, "control", {
- /**
- * @return {?}
- */
- get: function () { return this.form; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(FormGroupDirective.prototype, "path", {
- /**
- * @return {?}
- */
- get: function () { return []; },
- enumerable: true,
- configurable: true
- });
- /**
- * @param {?} dir
- * @return {?}
- */
- FormGroupDirective.prototype.addControl = function (dir) {
- var /** @type {?} */ ctrl = this.form.get(dir.path);
- setUpControl(ctrl, dir);
- ctrl.updateValueAndValidity({ emitEvent: false });
- this.directives.push(dir);
- return ctrl;
- };
- /**
- * @param {?} dir
- * @return {?}
- */
- FormGroupDirective.prototype.getControl = function (dir) { return (this.form.get(dir.path)); };
- /**
- * @param {?} dir
- * @return {?}
- */
- FormGroupDirective.prototype.removeControl = function (dir) { remove$1(this.directives, dir); };
- /**
- * @param {?} dir
- * @return {?}
- */
- FormGroupDirective.prototype.addFormGroup = function (dir) {
- var /** @type {?} */ ctrl = this.form.get(dir.path);
- setUpFormContainer(ctrl, dir);
- ctrl.updateValueAndValidity({ emitEvent: false });
- };
- /**
- * @param {?} dir
- * @return {?}
- */
- FormGroupDirective.prototype.removeFormGroup = function (dir) { };
- /**
- * @param {?} dir
- * @return {?}
- */
- FormGroupDirective.prototype.getFormGroup = function (dir) { return (this.form.get(dir.path)); };
- /**
- * @param {?} dir
- * @return {?}
- */
- FormGroupDirective.prototype.addFormArray = function (dir) {
- var /** @type {?} */ ctrl = this.form.get(dir.path);
- setUpFormContainer(ctrl, dir);
- ctrl.updateValueAndValidity({ emitEvent: false });
- };
- /**
- * @param {?} dir
- * @return {?}
- */
- FormGroupDirective.prototype.removeFormArray = function (dir) { };
- /**
- * @param {?} dir
- * @return {?}
- */
- FormGroupDirective.prototype.getFormArray = function (dir) { return (this.form.get(dir.path)); };
- /**
- * @param {?} dir
- * @param {?} value
- * @return {?}
- */
- FormGroupDirective.prototype.updateModel = function (dir, value) {
- var /** @type {?} */ ctrl = (this.form.get(dir.path));
- ctrl.setValue(value);
- };
- /**
- * @param {?} $event
- * @return {?}
- */
- FormGroupDirective.prototype.onSubmit = function ($event) {
- this._submitted = true;
- this.ngSubmit.emit($event);
- return false;
- };
- /**
- * @return {?}
- */
- FormGroupDirective.prototype.onReset = function () { this.resetForm(); };
- /**
- * @param {?=} value
- * @return {?}
- */
- FormGroupDirective.prototype.resetForm = function (value) {
- if (value === void 0) { value = undefined; }
- this.form.reset(value);
- this._submitted = false;
- };
- /**
- * \@internal
- * @return {?}
- */
- FormGroupDirective.prototype._updateDomValue = function () {
- var _this = this;
- this.directives.forEach(function (dir) {
- var /** @type {?} */ newCtrl = _this.form.get(dir.path);
- if (dir._control !== newCtrl) {
- cleanUpControl(dir._control, dir);
- if (newCtrl)
- setUpControl(newCtrl, dir);
- dir._control = newCtrl;
- }
- });
- this.form._updateTreeValidity({ emitEvent: false });
- };
- /**
- * @return {?}
- */
- FormGroupDirective.prototype._updateRegistrations = function () {
- var _this = this;
- this.form._registerOnCollectionChange(function () { return _this._updateDomValue(); });
- if (this._oldForm)
- this._oldForm._registerOnCollectionChange(function () { });
- this._oldForm = this.form;
- };
- /**
- * @return {?}
- */
- FormGroupDirective.prototype._updateValidators = function () {
- var /** @type {?} */ sync = composeValidators(this._validators);
- this.form.validator = Validators.compose([/** @type {?} */ ((this.form.validator)), /** @type {?} */ ((sync))]);
- var /** @type {?} */ async = composeAsyncValidators(this._asyncValidators);
- this.form.asyncValidator = Validators.composeAsync([/** @type {?} */ ((this.form.asyncValidator)), /** @type {?} */ ((async))]);
- };
- /**
- * @return {?}
- */
- FormGroupDirective.prototype._checkFormPresent = function () {
- if (!this.form) {
- ReactiveErrors.missingFormException();
- }
- };
- return FormGroupDirective;
- }(ControlContainer));
- FormGroupDirective.decorators = [
- { type: Directive, args: [{
- selector: '[formGroup]',
- providers: [formDirectiveProvider$1],
- host: { '(submit)': 'onSubmit($event)', '(reset)': 'onReset()' },
- exportAs: 'ngForm'
- },] },
- ];
- /**
- * @nocollapse
- */
- FormGroupDirective.ctorParameters = function () { return [
- { type: Array, decorators: [{ type: Optional }, { type: Self }, { type: Inject, args: [NG_VALIDATORS,] },] },
- { type: Array, decorators: [{ type: Optional }, { type: Self }, { type: Inject, args: [NG_ASYNC_VALIDATORS,] },] },
- ]; };
- FormGroupDirective.propDecorators = {
- 'form': [{ type: Input, args: ['formGroup',] },],
- 'ngSubmit': [{ type: Output },],
- };
- /**
- * @template T
- * @param {?} list
- * @param {?} el
- * @return {?}
- */
- function remove$1(list, el) {
- var /** @type {?} */ index = list.indexOf(el);
- if (index > -1) {
- list.splice(index, 1);
- }
- }
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var formGroupNameProvider = {
- provide: ControlContainer,
- useExisting: forwardRef(function () { return FormGroupName; })
- };
- /**
- * \@whatItDoes Syncs a nested {\@link FormGroup} to a DOM element.
- *
- * \@howToUse
- *
- * This directive can only be used with a parent {\@link FormGroupDirective} (selector:
- * `[formGroup]`).
- *
- * It accepts the string name of the nested {\@link FormGroup} you want to link, and
- * will look for a {\@link FormGroup} registered with that name in the parent
- * {\@link FormGroup} instance you passed into {\@link FormGroupDirective}.
- *
- * Nested form groups can come in handy when you want to validate a sub-group of a
- * form separately from the rest or when you'd like to group the values of certain
- * controls into their own nested object.
- *
- * **Access the group**: You can access the associated {\@link FormGroup} using the
- * {\@link AbstractControl#get} method. Ex: `this.form.get('name')`.
- *
- * You can also access individual controls within the group using dot syntax.
- * Ex: `this.form.get('name.first')`
- *
- * **Get the value**: the `value` property is always synced and available on the
- * {\@link FormGroup}. See a full list of available properties in {\@link AbstractControl}.
- *
- * **Set the value**: You can set an initial value for each child control when instantiating
- * the {\@link FormGroup}, or you can set it programmatically later using
- * {\@link AbstractControl#setValue setValue} or {\@link AbstractControl#patchValue patchValue}.
- *
- * **Listen to value**: If you want to listen to changes in the value of the group, you can
- * subscribe to the {\@link AbstractControl#valueChanges valueChanges} event. You can also listen to
- * {\@link AbstractControl#statusChanges statusChanges} to be notified when the validation status is
- * re-calculated.
- *
- * ### Example
- *
- * {\@example forms/ts/nestedFormGroup/nested_form_group_example.ts region='Component'}
- *
- * * **npm package**: `\@angular/forms`
- *
- * * **NgModule**: `ReactiveFormsModule`
- *
- * \@stable
- */
- var FormGroupName = (function (_super) {
- __extends$1(FormGroupName, _super);
- /**
- * @param {?} parent
- * @param {?} validators
- * @param {?} asyncValidators
- */
- function FormGroupName(parent, validators, asyncValidators) {
- var _this = _super.call(this) || this;
- _this._parent = parent;
- _this._validators = validators;
- _this._asyncValidators = asyncValidators;
- return _this;
- }
- /**
- * \@internal
- * @return {?}
- */
- FormGroupName.prototype._checkParentType = function () {
- if (_hasInvalidParent(this._parent)) {
- ReactiveErrors.groupParentException();
- }
- };
- return FormGroupName;
- }(AbstractFormGroupDirective));
- FormGroupName.decorators = [
- { type: Directive, args: [{ selector: '[formGroupName]', providers: [formGroupNameProvider] },] },
- ];
- /**
- * @nocollapse
- */
- FormGroupName.ctorParameters = function () { return [
- { type: ControlContainer, decorators: [{ type: Optional }, { type: Host }, { type: SkipSelf },] },
- { type: Array, decorators: [{ type: Optional }, { type: Self }, { type: Inject, args: [NG_VALIDATORS,] },] },
- { type: Array, decorators: [{ type: Optional }, { type: Self }, { type: Inject, args: [NG_ASYNC_VALIDATORS,] },] },
- ]; };
- FormGroupName.propDecorators = {
- 'name': [{ type: Input, args: ['formGroupName',] },],
- };
- var formArrayNameProvider = {
- provide: ControlContainer,
- useExisting: forwardRef(function () { return FormArrayName; })
- };
- /**
- * \@whatItDoes Syncs a nested {\@link FormArray} to a DOM element.
- *
- * \@howToUse
- *
- * This directive is designed to be used with a parent {\@link FormGroupDirective} (selector:
- * `[formGroup]`).
- *
- * It accepts the string name of the nested {\@link FormArray} you want to link, and
- * will look for a {\@link FormArray} registered with that name in the parent
- * {\@link FormGroup} instance you passed into {\@link FormGroupDirective}.
- *
- * Nested form arrays can come in handy when you have a group of form controls but
- * you're not sure how many there will be. Form arrays allow you to create new
- * form controls dynamically.
- *
- * **Access the array**: You can access the associated {\@link FormArray} using the
- * {\@link AbstractControl#get} method on the parent {\@link FormGroup}.
- * Ex: `this.form.get('cities')`.
- *
- * **Get the value**: the `value` property is always synced and available on the
- * {\@link FormArray}. See a full list of available properties in {\@link AbstractControl}.
- *
- * **Set the value**: You can set an initial value for each child control when instantiating
- * the {\@link FormArray}, or you can set the value programmatically later using the
- * {\@link FormArray}'s {\@link AbstractControl#setValue} or {\@link AbstractControl#patchValue}
- * methods.
- *
- * **Listen to value**: If you want to listen to changes in the value of the array, you can
- * subscribe to the {\@link FormArray}'s {\@link AbstractControl#valueChanges} event. You can also
- * listen to its {\@link AbstractControl#statusChanges} event to be notified when the validation
- * status is re-calculated.
- *
- * **Add new controls**: You can add new controls to the {\@link FormArray} dynamically by
- * calling its {\@link FormArray#push} method.
- * Ex: `this.form.get('cities').push(new FormControl());`
- *
- * ### Example
- *
- * {\@example forms/ts/nestedFormArray/nested_form_array_example.ts region='Component'}
- *
- * * **npm package**: `\@angular/forms`
- *
- * * **NgModule**: `ReactiveFormsModule`
- *
- * \@stable
- */
- var FormArrayName = (function (_super) {
- __extends$1(FormArrayName, _super);
- /**
- * @param {?} parent
- * @param {?} validators
- * @param {?} asyncValidators
- */
- function FormArrayName(parent, validators, asyncValidators) {
- var _this = _super.call(this) || this;
- _this._parent = parent;
- _this._validators = validators;
- _this._asyncValidators = asyncValidators;
- return _this;
- }
- /**
- * @return {?}
- */
- FormArrayName.prototype.ngOnInit = function () {
- this._checkParentType(); /** @type {?} */
- ((this.formDirective)).addFormArray(this);
- };
- /**
- * @return {?}
- */
- FormArrayName.prototype.ngOnDestroy = function () {
- if (this.formDirective) {
- this.formDirective.removeFormArray(this);
- }
- };
- Object.defineProperty(FormArrayName.prototype, "control", {
- /**
- * @return {?}
- */
- get: function () { return ((this.formDirective)).getFormArray(this); },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(FormArrayName.prototype, "formDirective", {
- /**
- * @return {?}
- */
- get: function () {
- return this._parent ? (this._parent.formDirective) : null;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(FormArrayName.prototype, "path", {
- /**
- * @return {?}
- */
- get: function () { return controlPath(this.name, this._parent); },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(FormArrayName.prototype, "validator", {
- /**
- * @return {?}
- */
- get: function () { return composeValidators(this._validators); },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(FormArrayName.prototype, "asyncValidator", {
- /**
- * @return {?}
- */
- get: function () {
- return composeAsyncValidators(this._asyncValidators);
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @return {?}
- */
- FormArrayName.prototype._checkParentType = function () {
- if (_hasInvalidParent(this._parent)) {
- ReactiveErrors.arrayParentException();
- }
- };
- return FormArrayName;
- }(ControlContainer));
- FormArrayName.decorators = [
- { type: Directive, args: [{ selector: '[formArrayName]', providers: [formArrayNameProvider] },] },
- ];
- /**
- * @nocollapse
- */
- FormArrayName.ctorParameters = function () { return [
- { type: ControlContainer, decorators: [{ type: Optional }, { type: Host }, { type: SkipSelf },] },
- { type: Array, decorators: [{ type: Optional }, { type: Self }, { type: Inject, args: [NG_VALIDATORS,] },] },
- { type: Array, decorators: [{ type: Optional }, { type: Self }, { type: Inject, args: [NG_ASYNC_VALIDATORS,] },] },
- ]; };
- FormArrayName.propDecorators = {
- 'name': [{ type: Input, args: ['formArrayName',] },],
- };
- /**
- * @param {?} parent
- * @return {?}
- */
- function _hasInvalidParent(parent) {
- return !(parent instanceof FormGroupName) && !(parent instanceof FormGroupDirective) &&
- !(parent instanceof FormArrayName);
- }
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var controlNameBinding = {
- provide: NgControl,
- useExisting: forwardRef(function () { return FormControlName; })
- };
- /**
- * \@whatItDoes Syncs a {\@link FormControl} in an existing {\@link FormGroup} to a form control
- * element by name.
- *
- * In other words, this directive ensures that any values written to the {\@link FormControl}
- * instance programmatically will be written to the DOM element (model -> view). Conversely,
- * any values written to the DOM element through user input will be reflected in the
- * {\@link FormControl} instance (view -> model).
- *
- * \@howToUse
- *
- * This directive is designed to be used with a parent {\@link FormGroupDirective} (selector:
- * `[formGroup]`).
- *
- * It accepts the string name of the {\@link FormControl} instance you want to
- * link, and will look for a {\@link FormControl} registered with that name in the
- * closest {\@link FormGroup} or {\@link FormArray} above it.
- *
- * **Access the control**: You can access the {\@link FormControl} associated with
- * this directive by using the {\@link AbstractControl#get get} method.
- * Ex: `this.form.get('first');`
- *
- * **Get value**: the `value` property is always synced and available on the {\@link FormControl}.
- * See a full list of available properties in {\@link AbstractControl}.
- *
- * **Set value**: You can set an initial value for the control when instantiating the
- * {\@link FormControl}, or you can set it programmatically later using
- * {\@link AbstractControl#setValue setValue} or {\@link AbstractControl#patchValue patchValue}.
- *
- * **Listen to value**: If you want to listen to changes in the value of the control, you can
- * subscribe to the {\@link AbstractControl#valueChanges valueChanges} event. You can also listen to
- * {\@link AbstractControl#statusChanges statusChanges} to be notified when the validation status is
- * re-calculated.
- *
- * ### Example
- *
- * In this example, we create form controls for first name and last name.
- *
- * {\@example forms/ts/simpleFormGroup/simple_form_group_example.ts region='Component'}
- *
- * To see `formControlName` examples with different form control types, see:
- *
- * * Radio buttons: {\@link RadioControlValueAccessor}
- * * Selects: {\@link SelectControlValueAccessor}
- *
- * **npm package**: `\@angular/forms`
- *
- * **NgModule**: {\@link ReactiveFormsModule}
- *
- * \@stable
- */
- var FormControlName = (function (_super) {
- __extends$1(FormControlName, _super);
- /**
- * @param {?} parent
- * @param {?} validators
- * @param {?} asyncValidators
- * @param {?} valueAccessors
- */
- function FormControlName(parent, validators, asyncValidators, valueAccessors) {
- var _this = _super.call(this) || this;
- _this._added = false;
- _this.update = new EventEmitter();
- _this._parent = parent;
- _this._rawValidators = validators || [];
- _this._rawAsyncValidators = asyncValidators || [];
- _this.valueAccessor = selectValueAccessor(_this, valueAccessors);
- return _this;
- }
- Object.defineProperty(FormControlName.prototype, "isDisabled", {
- /**
- * @param {?} isDisabled
- * @return {?}
- */
- set: function (isDisabled) { ReactiveErrors.disabledAttrWarning(); },
- enumerable: true,
- configurable: true
- });
- /**
- * @param {?} changes
- * @return {?}
- */
- FormControlName.prototype.ngOnChanges = function (changes) {
- if (!this._added)
- this._setUpControl();
- if (isPropertyUpdated(changes, this.viewModel)) {
- this.viewModel = this.model;
- this.formDirective.updateModel(this, this.model);
- }
- };
- /**
- * @return {?}
- */
- FormControlName.prototype.ngOnDestroy = function () {
- if (this.formDirective) {
- this.formDirective.removeControl(this);
- }
- };
- /**
- * @param {?} newValue
- * @return {?}
- */
- FormControlName.prototype.viewToModelUpdate = function (newValue) {
- this.viewModel = newValue;
- this.update.emit(newValue);
- };
- Object.defineProperty(FormControlName.prototype, "path", {
- /**
- * @return {?}
- */
- get: function () { return controlPath(this.name, /** @type {?} */ ((this._parent))); },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(FormControlName.prototype, "formDirective", {
- /**
- * @return {?}
- */
- get: function () { return this._parent ? this._parent.formDirective : null; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(FormControlName.prototype, "validator", {
- /**
- * @return {?}
- */
- get: function () { return composeValidators(this._rawValidators); },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(FormControlName.prototype, "asyncValidator", {
- /**
- * @return {?}
- */
- get: function () {
- return ((composeAsyncValidators(this._rawAsyncValidators)));
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(FormControlName.prototype, "control", {
- /**
- * @return {?}
- */
- get: function () { return this._control; },
- enumerable: true,
- configurable: true
- });
- /**
- * @return {?}
- */
- FormControlName.prototype._checkParentType = function () {
- if (!(this._parent instanceof FormGroupName) &&
- this._parent instanceof AbstractFormGroupDirective) {
- ReactiveErrors.ngModelGroupException();
- }
- else if (!(this._parent instanceof FormGroupName) && !(this._parent instanceof FormGroupDirective) &&
- !(this._parent instanceof FormArrayName)) {
- ReactiveErrors.controlParentException();
- }
- };
- /**
- * @return {?}
- */
- FormControlName.prototype._setUpControl = function () {
- this._checkParentType();
- this._control = this.formDirective.addControl(this);
- if (this.control.disabled && ((this.valueAccessor)).setDisabledState) {
- ((((this.valueAccessor)).setDisabledState))(true);
- }
- this._added = true;
- };
- return FormControlName;
- }(NgControl));
- FormControlName.decorators = [
- { type: Directive, args: [{ selector: '[formControlName]', providers: [controlNameBinding] },] },
- ];
- /**
- * @nocollapse
- */
- FormControlName.ctorParameters = function () { return [
- { type: ControlContainer, decorators: [{ type: Optional }, { type: Host }, { type: SkipSelf },] },
- { type: Array, decorators: [{ type: Optional }, { type: Self }, { type: Inject, args: [NG_VALIDATORS,] },] },
- { type: Array, decorators: [{ type: Optional }, { type: Self }, { type: Inject, args: [NG_ASYNC_VALIDATORS,] },] },
- { type: Array, decorators: [{ type: Optional }, { type: Self }, { type: Inject, args: [NG_VALUE_ACCESSOR,] },] },
- ]; };
- FormControlName.propDecorators = {
- 'name': [{ type: Input, args: ['formControlName',] },],
- 'model': [{ type: Input, args: ['ngModel',] },],
- 'update': [{ type: Output, args: ['ngModelChange',] },],
- 'isDisabled': [{ type: Input, args: ['disabled',] },],
- };
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var REQUIRED_VALIDATOR = {
- provide: NG_VALIDATORS,
- useExisting: forwardRef(function () { return RequiredValidator; }),
- multi: true
- };
- var CHECKBOX_REQUIRED_VALIDATOR = {
- provide: NG_VALIDATORS,
- useExisting: forwardRef(function () { return CheckboxRequiredValidator; }),
- multi: true
- };
- /**
- * A Directive that adds the `required` validator to any controls marked with the
- * `required` attribute, via the {\@link NG_VALIDATORS} binding.
- *
- * ### Example
- *
- * ```
- * <input name="fullName" ngModel required>
- * ```
- *
- * \@stable
- */
- var RequiredValidator = (function () {
- function RequiredValidator() {
- }
- Object.defineProperty(RequiredValidator.prototype, "required", {
- /**
- * @return {?}
- */
- get: function () { return this._required; },
- /**
- * @param {?} value
- * @return {?}
- */
- set: function (value) {
- this._required = value != null && value !== false && "" + value !== 'false';
- if (this._onChange)
- this._onChange();
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @param {?} c
- * @return {?}
- */
- RequiredValidator.prototype.validate = function (c) {
- return this.required ? Validators.required(c) : null;
- };
- /**
- * @param {?} fn
- * @return {?}
- */
- RequiredValidator.prototype.registerOnValidatorChange = function (fn) { this._onChange = fn; };
- return RequiredValidator;
- }());
- RequiredValidator.decorators = [
- { type: Directive, args: [{
- selector: ':not([type=checkbox])[required][formControlName],:not([type=checkbox])[required][formControl],:not([type=checkbox])[required][ngModel]',
- providers: [REQUIRED_VALIDATOR],
- host: { '[attr.required]': 'required ? "" : null' }
- },] },
- ];
- /**
- * @nocollapse
- */
- RequiredValidator.ctorParameters = function () { return []; };
- RequiredValidator.propDecorators = {
- 'required': [{ type: Input },],
- };
- /**
- * A Directive that adds the `required` validator to checkbox controls marked with the
- * `required` attribute, via the {\@link NG_VALIDATORS} binding.
- *
- * ### Example
- *
- * ```
- * <input type="checkbox" name="active" ngModel required>
- * ```
- *
- * \@experimental
- */
- var CheckboxRequiredValidator = (function (_super) {
- __extends$1(CheckboxRequiredValidator, _super);
- function CheckboxRequiredValidator() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- /**
- * @param {?} c
- * @return {?}
- */
- CheckboxRequiredValidator.prototype.validate = function (c) {
- return this.required ? Validators.requiredTrue(c) : null;
- };
- return CheckboxRequiredValidator;
- }(RequiredValidator));
- CheckboxRequiredValidator.decorators = [
- { type: Directive, args: [{
- selector: 'input[type=checkbox][required][formControlName],input[type=checkbox][required][formControl],input[type=checkbox][required][ngModel]',
- providers: [CHECKBOX_REQUIRED_VALIDATOR],
- host: { '[attr.required]': 'required ? "" : null' }
- },] },
- ];
- /**
- * @nocollapse
- */
- CheckboxRequiredValidator.ctorParameters = function () { return []; };
- /**
- * Provider which adds {\@link EmailValidator} to {\@link NG_VALIDATORS}.
- */
- var EMAIL_VALIDATOR = {
- provide: NG_VALIDATORS,
- useExisting: forwardRef(function () { return EmailValidator; }),
- multi: true
- };
- /**
- * A Directive that adds the `email` validator to controls marked with the
- * `email` attribute, via the {\@link NG_VALIDATORS} binding.
- *
- * ### Example
- *
- * ```
- * <input type="email" name="email" ngModel email>
- * <input type="email" name="email" ngModel email="true">
- * <input type="email" name="email" ngModel [email]="true">
- * ```
- *
- * \@experimental
- */
- var EmailValidator = (function () {
- function EmailValidator() {
- }
- Object.defineProperty(EmailValidator.prototype, "email", {
- /**
- * @param {?} value
- * @return {?}
- */
- set: function (value) {
- this._enabled = value === '' || value === true || value === 'true';
- if (this._onChange)
- this._onChange();
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @param {?} c
- * @return {?}
- */
- EmailValidator.prototype.validate = function (c) {
- return this._enabled ? Validators.email(c) : null;
- };
- /**
- * @param {?} fn
- * @return {?}
- */
- EmailValidator.prototype.registerOnValidatorChange = function (fn) { this._onChange = fn; };
- return EmailValidator;
- }());
- EmailValidator.decorators = [
- { type: Directive, args: [{
- selector: '[email][formControlName],[email][formControl],[email][ngModel]',
- providers: [EMAIL_VALIDATOR]
- },] },
- ];
- /**
- * @nocollapse
- */
- EmailValidator.ctorParameters = function () { return []; };
- EmailValidator.propDecorators = {
- 'email': [{ type: Input },],
- };
- /**
- * Provider which adds {\@link MinLengthValidator} to {\@link NG_VALIDATORS}.
- *
- * ## Example:
- *
- * {\@example common/forms/ts/validators/validators.ts region='min'}
- */
- var MIN_LENGTH_VALIDATOR = {
- provide: NG_VALIDATORS,
- useExisting: forwardRef(function () { return MinLengthValidator; }),
- multi: true
- };
- /**
- * A directive which installs the {\@link MinLengthValidator} for any `formControlName`,
- * `formControl`, or control with `ngModel` that also has a `minlength` attribute.
- *
- * \@stable
- */
- var MinLengthValidator = (function () {
- function MinLengthValidator() {
- }
- /**
- * @param {?} changes
- * @return {?}
- */
- MinLengthValidator.prototype.ngOnChanges = function (changes) {
- if ('minlength' in changes) {
- this._createValidator();
- if (this._onChange)
- this._onChange();
- }
- };
- /**
- * @param {?} c
- * @return {?}
- */
- MinLengthValidator.prototype.validate = function (c) {
- return this.minlength == null ? null : this._validator(c);
- };
- /**
- * @param {?} fn
- * @return {?}
- */
- MinLengthValidator.prototype.registerOnValidatorChange = function (fn) { this._onChange = fn; };
- /**
- * @return {?}
- */
- MinLengthValidator.prototype._createValidator = function () {
- this._validator = Validators.minLength(parseInt(this.minlength, 10));
- };
- return MinLengthValidator;
- }());
- MinLengthValidator.decorators = [
- { type: Directive, args: [{
- selector: '[minlength][formControlName],[minlength][formControl],[minlength][ngModel]',
- providers: [MIN_LENGTH_VALIDATOR],
- host: { '[attr.minlength]': 'minlength ? minlength : null' }
- },] },
- ];
- /**
- * @nocollapse
- */
- MinLengthValidator.ctorParameters = function () { return []; };
- MinLengthValidator.propDecorators = {
- 'minlength': [{ type: Input },],
- };
- /**
- * Provider which adds {\@link MaxLengthValidator} to {\@link NG_VALIDATORS}.
- *
- * ## Example:
- *
- * {\@example common/forms/ts/validators/validators.ts region='max'}
- */
- var MAX_LENGTH_VALIDATOR = {
- provide: NG_VALIDATORS,
- useExisting: forwardRef(function () { return MaxLengthValidator; }),
- multi: true
- };
- /**
- * A directive which installs the {\@link MaxLengthValidator} for any `formControlName,
- * `formControl`,
- * or control with `ngModel` that also has a `maxlength` attribute.
- *
- * \@stable
- */
- var MaxLengthValidator = (function () {
- function MaxLengthValidator() {
- }
- /**
- * @param {?} changes
- * @return {?}
- */
- MaxLengthValidator.prototype.ngOnChanges = function (changes) {
- if ('maxlength' in changes) {
- this._createValidator();
- if (this._onChange)
- this._onChange();
- }
- };
- /**
- * @param {?} c
- * @return {?}
- */
- MaxLengthValidator.prototype.validate = function (c) {
- return this.maxlength != null ? this._validator(c) : null;
- };
- /**
- * @param {?} fn
- * @return {?}
- */
- MaxLengthValidator.prototype.registerOnValidatorChange = function (fn) { this._onChange = fn; };
- /**
- * @return {?}
- */
- MaxLengthValidator.prototype._createValidator = function () {
- this._validator = Validators.maxLength(parseInt(this.maxlength, 10));
- };
- return MaxLengthValidator;
- }());
- MaxLengthValidator.decorators = [
- { type: Directive, args: [{
- selector: '[maxlength][formControlName],[maxlength][formControl],[maxlength][ngModel]',
- providers: [MAX_LENGTH_VALIDATOR],
- host: { '[attr.maxlength]': 'maxlength ? maxlength : null' }
- },] },
- ];
- /**
- * @nocollapse
- */
- MaxLengthValidator.ctorParameters = function () { return []; };
- MaxLengthValidator.propDecorators = {
- 'maxlength': [{ type: Input },],
- };
- var PATTERN_VALIDATOR = {
- provide: NG_VALIDATORS,
- useExisting: forwardRef(function () { return PatternValidator; }),
- multi: true
- };
- /**
- * A Directive that adds the `pattern` validator to any controls marked with the
- * `pattern` attribute, via the {\@link NG_VALIDATORS} binding. Uses attribute value
- * as the regex to validate Control value against. Follows pattern attribute
- * semantics; i.e. regex must match entire Control value.
- *
- * ### Example
- *
- * ```
- * <input [name]="fullName" pattern="[a-zA-Z ]*" ngModel>
- * ```
- * \@stable
- */
- var PatternValidator = (function () {
- function PatternValidator() {
- }
- /**
- * @param {?} changes
- * @return {?}
- */
- PatternValidator.prototype.ngOnChanges = function (changes) {
- if ('pattern' in changes) {
- this._createValidator();
- if (this._onChange)
- this._onChange();
- }
- };
- /**
- * @param {?} c
- * @return {?}
- */
- PatternValidator.prototype.validate = function (c) { return this._validator(c); };
- /**
- * @param {?} fn
- * @return {?}
- */
- PatternValidator.prototype.registerOnValidatorChange = function (fn) { this._onChange = fn; };
- /**
- * @return {?}
- */
- PatternValidator.prototype._createValidator = function () { this._validator = Validators.pattern(this.pattern); };
- return PatternValidator;
- }());
- PatternValidator.decorators = [
- { type: Directive, args: [{
- selector: '[pattern][formControlName],[pattern][formControl],[pattern][ngModel]',
- providers: [PATTERN_VALIDATOR],
- host: { '[attr.pattern]': 'pattern ? pattern : null' }
- },] },
- ];
- /**
- * @nocollapse
- */
- PatternValidator.ctorParameters = function () { return []; };
- PatternValidator.propDecorators = {
- 'pattern': [{ type: Input },],
- };
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * \@whatItDoes Creates an {\@link AbstractControl} from a user-specified configuration.
- *
- * It is essentially syntactic sugar that shortens the `new FormGroup()`,
- * `new FormControl()`, and `new FormArray()` boilerplate that can build up in larger
- * forms.
- *
- * \@howToUse
- *
- * To use, inject `FormBuilder` into your component class. You can then call its methods
- * directly.
- *
- * {\@example forms/ts/formBuilder/form_builder_example.ts region='Component'}
- *
- * * **npm package**: `\@angular/forms`
- *
- * * **NgModule**: {\@link ReactiveFormsModule}
- *
- * \@stable
- */
- var FormBuilder = (function () {
- function FormBuilder() {
- }
- /**
- * Construct a new {\@link FormGroup} with the given map of configuration.
- * Valid keys for the `extra` parameter map are `validator` and `asyncValidator`.
- *
- * See the {\@link FormGroup} constructor for more details.
- * @param {?} controlsConfig
- * @param {?=} extra
- * @return {?}
- */
- FormBuilder.prototype.group = function (controlsConfig, extra) {
- if (extra === void 0) { extra = null; }
- var /** @type {?} */ controls = this._reduceControls(controlsConfig);
- var /** @type {?} */ validator = extra != null ? extra['validator'] : null;
- var /** @type {?} */ asyncValidator = extra != null ? extra['asyncValidator'] : null;
- return new FormGroup(controls, validator, asyncValidator);
- };
- /**
- * Construct a new {\@link FormControl} with the given `formState`,`validator`, and
- * `asyncValidator`.
- *
- * `formState` can either be a standalone value for the form control or an object
- * that contains both a value and a disabled status.
- *
- * @param {?} formState
- * @param {?=} validator
- * @param {?=} asyncValidator
- * @return {?}
- */
- FormBuilder.prototype.control = function (formState, validator, asyncValidator) {
- return new FormControl(formState, validator, asyncValidator);
- };
- /**
- * Construct a {\@link FormArray} from the given `controlsConfig` array of
- * configuration, with the given optional `validator` and `asyncValidator`.
- * @param {?} controlsConfig
- * @param {?=} validator
- * @param {?=} asyncValidator
- * @return {?}
- */
- FormBuilder.prototype.array = function (controlsConfig, validator, asyncValidator) {
- var _this = this;
- var /** @type {?} */ controls = controlsConfig.map(function (c) { return _this._createControl(c); });
- return new FormArray(controls, validator, asyncValidator);
- };
- /**
- * \@internal
- * @param {?} controlsConfig
- * @return {?}
- */
- FormBuilder.prototype._reduceControls = function (controlsConfig) {
- var _this = this;
- var /** @type {?} */ controls = {};
- Object.keys(controlsConfig).forEach(function (controlName) {
- controls[controlName] = _this._createControl(controlsConfig[controlName]);
- });
- return controls;
- };
- /**
- * \@internal
- * @param {?} controlConfig
- * @return {?}
- */
- FormBuilder.prototype._createControl = function (controlConfig) {
- if (controlConfig instanceof FormControl || controlConfig instanceof FormGroup ||
- controlConfig instanceof FormArray) {
- return controlConfig;
- }
- else if (Array.isArray(controlConfig)) {
- var /** @type {?} */ value = controlConfig[0];
- var /** @type {?} */ validator = controlConfig.length > 1 ? controlConfig[1] : null;
- var /** @type {?} */ asyncValidator = controlConfig.length > 2 ? controlConfig[2] : null;
- return this.control(value, validator, asyncValidator);
- }
- else {
- return this.control(controlConfig);
- }
- };
- return FormBuilder;
- }());
- FormBuilder.decorators = [
- { type: Injectable },
- ];
- /**
- * @nocollapse
- */
- FormBuilder.ctorParameters = function () { return []; };
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * @module
- * @description
- * Entry point for all public APIs of the common package.
- */
- /**
- * \@stable
- */
- var VERSION$3 = new Version('4.4.6');
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * \@whatItDoes Adds `novalidate` attribute to all forms by default.
- *
- * `novalidate` is used to disable browser's native form validation.
- *
- * If you want to use native validation with Angular forms, just add `ngNativeValidate` attribute:
- *
- * ```
- * <form ngNativeValidate></form>
- * ```
- *
- * \@experimental
- */
- var NgNoValidate = (function () {
- function NgNoValidate() {
- }
- return NgNoValidate;
- }());
- NgNoValidate.decorators = [
- { type: Directive, args: [{
- selector: 'form:not([ngNoForm]):not([ngNativeValidate])',
- host: { 'novalidate': '' },
- },] },
- ];
- /**
- * @nocollapse
- */
- NgNoValidate.ctorParameters = function () { return []; };
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- var SHARED_FORM_DIRECTIVES = [
- NgNoValidate,
- NgSelectOption,
- NgSelectMultipleOption,
- DefaultValueAccessor,
- NumberValueAccessor,
- RangeValueAccessor,
- CheckboxControlValueAccessor,
- SelectControlValueAccessor,
- SelectMultipleControlValueAccessor,
- RadioControlValueAccessor,
- NgControlStatus,
- NgControlStatusGroup,
- RequiredValidator,
- MinLengthValidator,
- MaxLengthValidator,
- PatternValidator,
- CheckboxRequiredValidator,
- EmailValidator,
- ];
- var TEMPLATE_DRIVEN_DIRECTIVES = [NgModel, NgModelGroup, NgForm];
- var REACTIVE_DRIVEN_DIRECTIVES = [FormControlDirective, FormGroupDirective, FormControlName, FormGroupName, FormArrayName];
- /**
- * Internal module used for sharing directives between FormsModule and ReactiveFormsModule
- */
- var InternalFormsSharedModule = (function () {
- function InternalFormsSharedModule() {
- }
- return InternalFormsSharedModule;
- }());
- InternalFormsSharedModule.decorators = [
- { type: NgModule, args: [{
- declarations: SHARED_FORM_DIRECTIVES,
- exports: SHARED_FORM_DIRECTIVES,
- },] },
- ];
- /**
- * @nocollapse
- */
- InternalFormsSharedModule.ctorParameters = function () { return []; };
- /**
- * @license
- * Copyright Google Inc. All Rights Reserved.
- *
- * Use of this source code is governed by an MIT-style license that can be
- * found in the LICENSE file at https://angular.io/license
- */
- /**
- * The ng module for forms.
- * \@stable
- */
- var FormsModule = (function () {
- function FormsModule() {
- }
- return FormsModule;
- }());
- FormsModule.decorators = [
- { type: NgModule, args: [{
- declarations: TEMPLATE_DRIVEN_DIRECTIVES,
- providers: [RadioControlRegistry],
- exports: [InternalFormsSharedModule, TEMPLATE_DRIVEN_DIRECTIVES]
- },] },
- ];
- /**
- * @nocollapse
- */
- FormsModule.ctorParameters = function () { return []; };
- /**
- * The ng module for reactive forms.
- * \@stable
- */
- var ReactiveFormsModule = (function () {
- function ReactiveFormsModule() {
- }
- return ReactiveFormsModule;
- }());
- ReactiveFormsModule.decorators = [
- { type: NgModule, args: [{
- declarations: [REACTIVE_DRIVEN_DIRECTIVES],
- providers: [FormBuilder, RadioControlRegistry],
- exports: [InternalFormsSharedModule, REACTIVE_DRIVEN_DIRECTIVES]
- },] },
- ];
- /**
- * @nocollapse
- */
- ReactiveFormsModule.ctorParameters = function () { return []; };
-
- /**
- * @hidden
- */
- var Form = (function () {
- function Form() {
- this._focused = null;
- this._ids = -1;
- this._inputs = [];
- }
- Form.prototype.register = function (input) {
- this._inputs.push(input);
- };
- Form.prototype.deregister = function (input) {
- removeArrayItem(this._inputs, input);
- this.unsetAsFocused(input);
- };
- Form.prototype.setAsFocused = function (input) {
- this._focused = input;
- };
- Form.prototype.unsetAsFocused = function (input) {
- if (input === this._focused) {
- this._focused = null;
- }
- };
- /**
- * Focuses the next input element, if it exists.
- */
- Form.prototype.tabFocus = function (currentInput) {
- var inputs = this._inputs;
- var index = inputs.indexOf(currentInput) + 1;
- if (index > 0 && index < inputs.length) {
- var nextInput = inputs[index];
- if (nextInput !== this._focused) {
- (void 0) /* console.debug */;
- return nextInput.initFocus();
- }
- }
- index = inputs.indexOf(this._focused);
- if (index > 0) {
- var previousInput = inputs[index - 1];
- if (previousInput) {
- (void 0) /* console.debug */;
- previousInput.initFocus();
- }
- }
- };
- Form.prototype.nextId = function () {
- return ++this._ids;
- };
- Form.decorators = [
- { type: Injectable },
- ];
- /** @nocollapse */
- Form.ctorParameters = function () { return []; };
- return Form;
- }());
- /**
- * @hidden
- */
- var IonicTapInput = (function () {
- function IonicTapInput() {
- }
- return IonicTapInput;
- }());
- /**
- * @hidden
- */
- var IonicFormInput = (function () {
- function IonicFormInput() {
- }
- return IonicFormInput;
- }());
-
- var TimeoutDebouncer = (function () {
- function TimeoutDebouncer(wait) {
- this.wait = wait;
- this.timer = null;
- }
- TimeoutDebouncer.prototype.debounce = function (callback) {
- this.callback = callback;
- this.schedule();
- };
- TimeoutDebouncer.prototype.schedule = function () {
- this.cancel();
- if (this.wait <= 0) {
- this.callback();
- }
- else {
- this.timer = setTimeout(this.callback, this.wait);
- }
- };
- TimeoutDebouncer.prototype.cancel = function () {
- if (this.timer) {
- clearTimeout(this.timer);
- this.timer = null;
- }
- };
- return TimeoutDebouncer;
- }());
-
- var __extends$38 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- var BaseInput = (function (_super) {
- __extends$38(BaseInput, _super);
- function BaseInput(config, elementRef, renderer, name, _defaultValue, _form, _item, _ngControl) {
- var _this = _super.call(this, config, elementRef, renderer, name) || this;
- _this._defaultValue = _defaultValue;
- _this._form = _form;
- _this._item = _item;
- _this._ngControl = _ngControl;
- _this._isFocus = false;
- _this._disabled = false;
- _this._debouncer = new TimeoutDebouncer(0);
- _this._init = false;
- _this._initModel = false;
- /**
- * @output {Range} Emitted when the range selector drag starts.
- */
- _this.ionFocus = new EventEmitter();
- /**
- * @output {Range} Emitted when the range value changes.
- */
- _this.ionChange = new EventEmitter();
- /**
- * @output {Range} Emitted when the range selector drag ends.
- */
- _this.ionBlur = new EventEmitter();
- _form && _form.register(_this);
- _this._value = deepCopy(_this._defaultValue);
- if (_item) {
- (void 0) /* assert */;
- _this.id = name + '-' + _item.registerInput(name);
- _this._labelId = _item.labelId;
- _this._item.setElementClass('item-' + name, true);
- }
- // If the user passed a ngControl we need to set the valueAccessor
- if (_ngControl) {
- _ngControl.valueAccessor = _this;
- }
- return _this;
- }
- Object.defineProperty(BaseInput.prototype, "disabled", {
- /**
- * @input {boolean} If true, the user cannot interact with this element.
- */
- get: function () {
- return this._disabled;
- },
- set: function (val) {
- this.setDisabledState(val);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(BaseInput.prototype, "value", {
- get: function () {
- return this._value;
- },
- set: function (val) {
- if (this._writeValue(val)) {
- this.onChange();
- this._fireIonChange();
- }
- },
- enumerable: true,
- configurable: true
- });
- // 1. Updates the value
- // 2. Calls _inputUpdated()
- // 3. Dispatch onChange events
- BaseInput.prototype.setValue = function (val) {
- this.value = val;
- };
- /**
- * @hidden
- */
- BaseInput.prototype.setDisabledState = function (isDisabled) {
- this._disabled = isDisabled = isTrueProperty(isDisabled);
- this._item && this._item.setElementClass("item-" + this._componentName + "-disabled", isDisabled);
- };
- /**
- * @hidden
- */
- BaseInput.prototype.writeValue = function (val) {
- if (this._writeValue(val)) {
- if (this._initModel) {
- this._fireIonChange();
- }
- else if (this._init) {
- // ngModel fires the first time too late, we need to skip the first ngModel update
- this._initModel = true;
- }
- }
- };
- /**
- * @hidden
- */
- BaseInput.prototype._writeValue = function (val) {
- (void 0) /* assert */;
- if (isUndefined(val)) {
- return false;
- }
- var normalized = (val === null)
- ? deepCopy(this._defaultValue)
- : this._inputNormalize(val);
- var notUpdate = isUndefined(normalized) || !this._inputShouldChange(normalized);
- if (notUpdate) {
- return false;
- }
- (void 0) /* console.debug */;
- this._value = normalized;
- if (this._init) {
- this._inputUpdated();
- }
- return true;
- };
- /**
- * @hidden
- */
- BaseInput.prototype._fireIonChange = function () {
- var _this = this;
- if (this._init) {
- this._debouncer.debounce(function () {
- (void 0) /* assert */;
- _this.ionChange.emit(_this._inputChangeEvent());
- _this._initModel = true;
- });
- }
- };
- /**
- * @hidden
- */
- BaseInput.prototype.registerOnChange = function (fn) {
- this._onChanged = fn;
- };
- /**
- * @hidden
- */
- BaseInput.prototype.registerOnTouched = function (fn) {
- this._onTouched = fn;
- };
- /**
- * @hidden
- */
- BaseInput.prototype._initialize = function () {
- if (this._init) {
- (void 0) /* assert */;
- return;
- }
- this._init = true;
- if (isPresent(this._value)) {
- this._inputUpdated();
- }
- };
- /**
- * @hidden
- */
- BaseInput.prototype._fireFocus = function () {
- if (this._isFocus) {
- return;
- }
- (void 0) /* console.debug */;
- this._form && this._form.setAsFocused(this);
- this._setFocus(true);
- this.ionFocus.emit(this);
- };
- /**
- * @hidden
- */
- BaseInput.prototype._fireBlur = function () {
- if (!this._isFocus) {
- return;
- }
- (void 0) /* console.debug */;
- this._form && this._form.unsetAsFocused(this);
- this._setFocus(false);
- this._fireTouched();
- this.ionBlur.emit(this);
- };
- /**
- * @hidden
- */
- BaseInput.prototype._fireTouched = function () {
- this._onTouched && this._onTouched();
- };
- /**
- * @hidden
- */
- BaseInput.prototype._setFocus = function (isFocused) {
- (void 0) /* assert */;
- (void 0) /* assert */;
- (void 0) /* assert */;
- this._isFocus = isFocused;
- var item = this._item;
- if (item) {
- item.setElementClass('input-has-focus', isFocused);
- item.setElementClass('item-input-has-focus', isFocused);
- }
- this._inputUpdated();
- };
- /**
- * @hidden
- */
- BaseInput.prototype.onChange = function () {
- this._onChanged && this._onChanged(this._inputNgModelEvent());
- };
- /**
- * @hidden
- */
- BaseInput.prototype.isFocus = function () {
- return this._isFocus;
- };
- /**
- * @hidden
- */
- BaseInput.prototype.hasValue = function () {
- var val = this._value;
- if (!isPresent(val)) {
- return false;
- }
- if (isArray$2(val) || isString(val)) {
- return val.length > 0;
- }
- return true;
- };
- /**
- * @hidden
- */
- BaseInput.prototype.focusNext = function () {
- this._form && this._form.tabFocus(this);
- };
- /**
- * @hidden
- */
- BaseInput.prototype.ngOnDestroy = function () {
- (void 0) /* assert */;
- var form = this._form;
- form && form.deregister(this);
- this._init = false;
- };
- /**
- * @hidden
- */
- BaseInput.prototype.ngAfterContentInit = function () {
- this._initialize();
- };
- /**
- * @hidden
- */
- BaseInput.prototype.initFocus = function () {
- var ele = this._elementRef.nativeElement.querySelector('button');
- ele && ele.focus();
- };
- /**
- * @hidden
- */
- BaseInput.prototype._inputNormalize = function (val) {
- return val;
- };
- /**
- * @hidden
- */
- BaseInput.prototype._inputShouldChange = function (val) {
- return this._value !== val;
- };
- /**
- * @hidden
- */
- BaseInput.prototype._inputChangeEvent = function () {
- return this;
- };
- /**
- * @hidden
- */
- BaseInput.prototype._inputNgModelEvent = function () {
- return this._value;
- };
- /**
- * @hidden
- */
- BaseInput.prototype._inputUpdated = function () {
- (void 0) /* assert */;
- var item = this._item;
- if (item) {
- setControlCss(item, this._ngControl);
- // TODO remove all uses of input-has-value in v4
- var hasValue = this.hasValue();
- item.setElementClass('input-has-value', hasValue);
- item.setElementClass('item-input-has-value', hasValue);
- }
- };
- BaseInput.propDecorators = {
- 'ionFocus': [{ type: Output },],
- 'ionChange': [{ type: Output },],
- 'ionBlur': [{ type: Output },],
- 'disabled': [{ type: Input },],
- };
- return BaseInput;
- }(Ion));
- function setControlCss(element, control) {
- if (!control) {
- return;
- }
- element.setElementClass('ng-untouched', control.untouched);
- element.setElementClass('ng-touched', control.touched);
- element.setElementClass('ng-pristine', control.pristine);
- element.setElementClass('ng-dirty', control.dirty);
- element.setElementClass('ng-valid', control.valid);
- element.setElementClass('ng-invalid', !control.valid);
- }
-
- var __extends$40 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @name Icon
- * @description
- * Icons can be used on their own, or inside of a number of Ionic components.
- * For a full list of available icons, check out the
- * [Ionicons docs](../../../../ionicons).
- *
- * One feature of Ionicons in Ionic is when icon names are set, the actual icon
- * which is rendered can change slightly depending on the mode the app is
- * running from. For example, by setting the icon name of `alarm`, on iOS the
- * icon will automatically apply `ios-alarm`, and on Material Design it will
- * automatically apply `md-alarm`. This allows the developer to write the
- * markup once while Ionic applies the appropriate icon based on the mode.
- *
- * @usage
- * ```html
- * <!-- automatically uses the correct "star" icon depending on the mode -->
- * <ion-icon name="star"></ion-icon>
- *
- * <!-- explicity set the icon for each mode -->
- * <ion-icon ios="ios-home" md="md-home"></ion-icon>
- *
- * <!-- always use the same icon, no matter what the mode -->
- * <ion-icon name="ios-clock"></ion-icon>
- * <ion-icon name="logo-twitter"></ion-icon>
- * ```
- *
- * @demo /docs/demos/src/icon/
- * @see {@link /docs/components#icons Icon Component Docs}
- *
- */
- var Icon = (function (_super) {
- __extends$40(Icon, _super);
- function Icon(config, elementRef, renderer) {
- var _this = _super.call(this, config, elementRef, renderer, 'icon') || this;
- /** @hidden */
- _this._isActive = true;
- /** @hidden */
- _this._name = '';
- /** @hidden */
- _this._ios = '';
- /** @hidden */
- _this._md = '';
- /** @hidden */
- _this._css = '';
- /**
- * @hidden
- */
- _this._hidden = false;
- _this._iconMode = config.get('iconMode');
- return _this;
- }
- /**
- * @hidden
- */
- Icon.prototype.ngOnDestroy = function () {
- if (this._css) {
- this.setElementClass(this._css, false);
- }
- };
- Object.defineProperty(Icon.prototype, "name", {
- /**
- * @input {string} Specifies which icon to use. The appropriate icon will be used based on the mode.
- * For more information, see [Ionicons](/docs/ionicons/).
- */
- get: function () {
- return this._name;
- },
- set: function (val) {
- if (!(/^md-|^ios-|^logo-/.test(val))) {
- // this does not have one of the defaults
- // so lets auto add in the mode prefix for them
- this._name = this._iconMode + '-' + val;
- }
- else {
- this._name = val;
- }
- this.update();
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Icon.prototype, "ios", {
- /**
- * @input {string} Specifies which icon to use on `ios` mode.
- */
- get: function () {
- return this._ios;
- },
- set: function (val) {
- this._ios = val;
- this.update();
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Icon.prototype, "md", {
- /**
- * @input {string} Specifies which icon to use on `md` mode.
- */
- get: function () {
- return this._md;
- },
- set: function (val) {
- this._md = val;
- this.update();
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Icon.prototype, "isActive", {
- /**
- * @input {boolean} If true, the icon is styled with an "active" appearance.
- * An active icon is filled in, and an inactive icon is the outline of the icon.
- * The `isActive` property is largely used by the tabbar. Only affects `ios` icons.
- */
- get: function () {
- return this._isActive;
- },
- set: function (val) {
- this._isActive = isTrueProperty(val);
- this.update();
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @hidden
- */
- Icon.prototype.update = function () {
- var iconName;
- if (this._ios && this._iconMode === 'ios') {
- iconName = this._ios;
- }
- else if (this._md && this._iconMode === 'md') {
- iconName = this._md;
- }
- else {
- iconName = this._name;
- }
- var hidden = this._hidden = (iconName === null);
- if (hidden) {
- return;
- }
- var iconMode = iconName.split('-', 2)[0];
- if (iconMode === 'ios' &&
- !this._isActive &&
- iconName.indexOf('logo-') < 0 &&
- iconName.indexOf('-outline') < 0) {
- iconName += '-outline';
- }
- var css = 'ion-' + iconName;
- if (this._css === css) {
- return;
- }
- if (this._css) {
- this.setElementClass(this._css, false);
- }
- this._css = css;
- this.setElementClass(css, true);
- var label = iconName
- .replace('ios-', '')
- .replace('md-', '')
- .replace('-', ' ');
- this.setElementAttribute('aria-label', label);
- };
- Icon.decorators = [
- { type: Directive, args: [{
- selector: 'ion-icon',
- host: {
- 'role': 'img'
- }
- },] },
- ];
- /** @nocollapse */
- Icon.ctorParameters = function () { return [
- { type: Config, },
- { type: ElementRef, },
- { type: Renderer, },
- ]; };
- Icon.propDecorators = {
- 'name': [{ type: Input },],
- 'ios': [{ type: Input },],
- 'md': [{ type: Input },],
- 'isActive': [{ type: Input },],
- '_hidden': [{ type: HostBinding, args: ['class.hide',] },],
- };
- return Icon;
- }(Ion));
-
- var __extends$41 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @name Label
- * @description
- * Labels are placed inside of an `ion-item` element and can be used
- * to describe an `ion-input`, `ion-toggle`, `ion-checkbox`, and more.
- *
- * @property [fixed] - A persistent label that sits next the input.
- * @property [floating] - A label that will float above the input if the input is empty or loses focus.
- * @property [stacked] - A stacked label will always appear on top of the input.
-
- *
- * @usage
- * ```html
- * <ion-item>
- * <ion-label>Username</ion-label>
- * <ion-input></ion-input>
- * </ion-item>
- *
- * <ion-item>
- * <ion-label fixed>Website</ion-label>
- * <ion-input type="url"></ion-input>
- * </ion-item>
- *
- * <ion-item>
- * <ion-label floating>Email</ion-label>
- * <ion-input type="email"></ion-input>
- * </ion-item>
- *
- * <ion-item>
- * <ion-label stacked>Phone</ion-label>
- * <ion-input type="tel"></ion-input>
- * </ion-item>
- *
- * <ion-item>
- * <ion-label>Toggle</ion-label>
- * <ion-toggle></ion-toggle>
- * </ion-item>
- *
- * <ion-item>
- * <ion-label>Checkbox</ion-label>
- * <ion-checkbox></ion-checkbox>
- * </ion-item>
- * ```
- *
- * @demo /docs/demos/src/label/
- * @see {@link ../../../../components#inputs Input Component Docs}
- * @see {@link ../../input/Input Input API Docs}
- *
- */
- var Label = (function (_super) {
- __extends$41(Label, _super);
- function Label(config, elementRef, renderer, isFloating, isStacked, isFixed, isInset) {
- var _this = _super.call(this, config, elementRef, renderer, 'label') || this;
- _this.type = (isFloating === '' ? 'floating' : (isStacked === '' ? 'stacked' : (isFixed === '' ? 'fixed' : (isInset === '' ? 'inset' : null))));
- return _this;
- }
- Object.defineProperty(Label.prototype, "id", {
- /**
- * @hidden
- */
- get: function () {
- return this._id;
- },
- set: function (val) {
- this._id = val;
- if (val) {
- this.setElementAttribute('id', val);
- }
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Label.prototype, "text", {
- /**
- * @hidden
- */
- get: function () {
- return this.getNativeElement().textContent || '';
- },
- enumerable: true,
- configurable: true
- });
- Label.decorators = [
- { type: Directive, args: [{
- selector: 'ion-label'
- },] },
- ];
- /** @nocollapse */
- Label.ctorParameters = function () { return [
- { type: Config, },
- { type: ElementRef, },
- { type: Renderer, },
- { type: undefined, decorators: [{ type: Attribute, args: ['floating',] },] },
- { type: undefined, decorators: [{ type: Attribute, args: ['stacked',] },] },
- { type: undefined, decorators: [{ type: Attribute, args: ['fixed',] },] },
- { type: undefined, decorators: [{ type: Attribute, args: ['inset',] },] },
- ]; };
- Label.propDecorators = {
- 'id': [{ type: Input },],
- };
- return Label;
- }(Ion));
-
- /**
- * @name Keyboard
- * @description
- * The `Keyboard` class allows you to work with the keyboard events provided
- * by the Ionic keyboard plugin.
- *
- * @usage
- * ```ts
- * export class MyClass {
- *
- * constructor(public keyboard: Keyboard) { }
- *
- * }
- * ```
- */
- var Keyboard = (function () {
- function Keyboard(config, _plt, _zone, _dom) {
- this._plt = _plt;
- this._zone = _zone;
- this._dom = _dom;
- this.willShow = new EventEmitter();
- this.willHide = new EventEmitter();
- this.didShow = new EventEmitter();
- this.didHide = new EventEmitter();
- this.eventsAvailable = false;
- this.focusOutline(config.get('focusOutline'));
- var win = _plt.win();
- if (win.Ionic && win.Ionic.keyboardPlugin) {
- this.listenV2(win);
- }
- else {
- this.listenV1(win);
- }
- }
- Keyboard.prototype.listenV2 = function (win) {
- var _this = this;
- var platform = this._plt;
- platform.registerListener(win, 'keyboardWillShow', function (ev) {
- _this._zone.run(function () {
- _this.willShow.emit(ev.keyboardHeight);
- });
- }, { zone: false, passive: true });
- platform.registerListener(win, 'keyboardWillHide', function () {
- _this._zone.run(function () {
- _this.willHide.emit();
- });
- }, { zone: false, passive: true });
- platform.registerListener(win, 'keyboardDidShow', function (ev) {
- _this._zone.run(function () {
- _this.didShow.emit(ev.keyboardHeight);
- });
- }, { zone: false, passive: true });
- platform.registerListener(win, 'keyboardDidHide', function () {
- _this._zone.run(function () {
- _this.didHide.emit();
- });
- }, { zone: false, passive: true });
- this.eventsAvailable = true;
- };
- Keyboard.prototype.listenV1 = function (win) {
- var _this = this;
- var platform = this._plt;
- platform.registerListener(win, 'native.keyboardhide', function () {
- _this.blurActiveInput(true);
- }, { zone: false, passive: true });
- platform.registerListener(win, 'native.keyboardshow', function () {
- _this.blurActiveInput(false);
- }, { zone: false, passive: true });
- };
- Keyboard.prototype.blurActiveInput = function (shouldBlur) {
- var _this = this;
- var platform = this._plt;
- platform.cancelTimeout(this._tmr);
- if (shouldBlur) {
- this._tmr = platform.timeout(function () {
- // this custom cordova plugin event fires when the keyboard will hide
- // useful when the virtual keyboard is closed natively
- // https://github.com/ionic-team/ionic-plugin-keyboard
- if (_this.isOpen()) {
- platform.focusOutActiveElement();
- }
- }, 80);
- }
- };
- /**
- * Check to see if the keyboard is open or not.
- *
- * ```ts
- * export class MyClass {
- * constructor(public keyboard: Keyboard) {
- *
- * }
- *
- * keyboardCheck() {
- * console.log('The keyboard is open:', this.keyboard.isOpen());
- * }
- * }
- * ```
- *
- * @return {boolean} returns a true or false value if the keyboard is open or not.
- */
- Keyboard.prototype.isOpen = function () {
- return this.hasFocusedTextInput();
- };
- /**
- * When the keyboard is closed, call any methods you want.
- *
- * ```ts
- * export class MyClass {
- * constructor(public keyboard: Keyboard) {
- * this.keyboard.onClose(this.closeCallback);
- * }
- * closeCallback() {
- * // call what ever functionality you want on keyboard close
- * console.log('Closing time');
- * }
- * }
- * ```
- *
- * @param {function} callback method you want to call when the keyboard has been closed.
- * @return {function} returns a callback that gets fired when the keyboard is closed.
- */
- Keyboard.prototype.onClose = function (callback, pollingInternval, pollingChecksMax) {
- if (pollingInternval === void 0) { pollingInternval = KEYBOARD_CLOSE_POLLING; }
- if (pollingChecksMax === void 0) { pollingChecksMax = KEYBOARD_POLLING_CHECKS_MAX; }
- (void 0) /* console.debug */;
- var self = this;
- var checks = 0;
- var promise = null;
- if (!callback) {
- // a callback wasn't provided, so let's return a promise instead
- promise = new Promise(function (resolve) { callback = resolve; });
- }
- function checkKeyboard() {
- (void 0) /* console.debug */;
- if (!self.isOpen() || checks > pollingChecksMax) {
- self._plt.timeout(function () {
- self._zone.run(function () {
- (void 0) /* console.debug */;
- callback();
- });
- }, 400);
- }
- else {
- self._plt.timeout(checkKeyboard, pollingInternval);
- }
- checks++;
- }
- self._plt.timeout(checkKeyboard, pollingInternval);
- return promise;
- };
- /**
- * Programmatically close the keyboard.
- */
- Keyboard.prototype.close = function () {
- var _this = this;
- this._dom.read(function () {
- if (_this.isOpen()) {
- // only focus out when a text input has focus
- (void 0) /* console.debug */;
- _this._dom.write(function () {
- _this._plt.focusOutActiveElement();
- });
- }
- });
- };
- /**
- * @hidden
- */
- Keyboard.prototype.focusOutline = function (setting) {
- /* Focus Outline
- * --------------------------------------------------
- * By default, when a keydown event happens from a tab key, then
- * the 'focus-outline' css class is added to the body element
- * so focusable elements have an outline. On a mousedown or
- * touchstart event, then the 'focus-outline' css class is removed.
- *
- * Config default overrides:
- * focusOutline: true - Always add the focus-outline
- * focusOutline: false - Do not add the focus-outline
- */
- var self = this;
- var platform = self._plt;
- var doc = platform.doc();
- var isKeyInputEnabled = false;
- var unRegMouse;
- var unRegTouch;
- var evOpts = { passive: true, zone: false };
- function cssClass() {
- self._dom.write(function () {
- platform.doc().body.classList[isKeyInputEnabled ? 'add' : 'remove']('focus-outline');
- });
- }
- if (setting === true) {
- isKeyInputEnabled = true;
- return cssClass();
- }
- else if (setting === false) {
- return;
- }
- // default is to add the focus-outline when the tab key is used
- function keyDown(ev) {
- if (!isKeyInputEnabled && ev.keyCode === KEY_TAB) {
- isKeyInputEnabled = true;
- enableKeyInput();
- }
- }
- function pointerDown() {
- isKeyInputEnabled = false;
- enableKeyInput();
- }
- function enableKeyInput() {
- cssClass();
- unRegMouse && unRegMouse();
- unRegTouch && unRegTouch();
- if (isKeyInputEnabled) {
- // listen for when a mousedown or touchstart event happens
- unRegMouse = platform.registerListener(doc, 'mousedown', pointerDown, evOpts);
- unRegTouch = platform.registerListener(doc, 'touchstart', pointerDown, evOpts);
- }
- }
- // always listen for tab keydown events
- platform.registerListener(platform.doc(), 'keydown', keyDown, evOpts);
- };
- Keyboard.prototype.hasFocusedTextInput = function () {
- var activeEle = this._plt.getActiveElement();
- if (isTextInput(activeEle)) {
- return (activeEle.parentElement.querySelector(':focus') === activeEle);
- }
- return false;
- };
- /**
- * Set to true to hide the additional toolbar that is on top of the keyboard.
- * This toolbar features the Prev, Next, and Done buttons.
- * @param hidden
- */
- Keyboard.prototype.hideFormAccessoryBar = function (hidden) {
- var win = this._plt.win();
- if (win && win.Keyboard && win.Keyboard.hideFormAccessoryBar) {
- win.Keyboard.hideFormAccessoryBar(hidden);
- }
- };
- Keyboard.decorators = [
- { type: Injectable },
- ];
- /** @nocollapse */
- Keyboard.ctorParameters = function () { return [
- { type: Config, },
- { type: Platform, },
- { type: NgZone, },
- { type: DomController, },
- ]; };
- return Keyboard;
- }());
- var KEYBOARD_CLOSE_POLLING = 150;
- var KEYBOARD_POLLING_CHECKS_MAX = 100;
-
- var ScrollView = (function () {
- function ScrollView(_app, _plt, _dom) {
- this._app = _app;
- this._plt = _plt;
- this._dom = _dom;
- this.isScrolling = false;
- this.initialized = false;
- this._eventsEnabled = false;
- this._t = 0;
- this._l = 0;
- this.ev = {
- timeStamp: 0,
- scrollTop: 0,
- scrollLeft: 0,
- scrollHeight: 0,
- scrollWidth: 0,
- contentHeight: 0,
- contentWidth: 0,
- contentTop: 0,
- contentBottom: 0,
- startY: 0,
- startX: 0,
- deltaY: 0,
- deltaX: 0,
- velocityY: 0,
- velocityX: 0,
- directionY: 'down',
- directionX: null,
- domWrite: _dom.write.bind(_dom)
- };
- }
- ScrollView.prototype.init = function (ele, contentTop, contentBottom) {
- (void 0) /* assert */;
- this._el = ele;
- if (!this.initialized) {
- this.initialized = true;
- if (this._js) {
- this.enableJsScroll(contentTop, contentBottom);
- }
- else {
- this.enableNativeScrolling();
- }
- }
- };
- ScrollView.prototype.enableEvents = function () {
- this._eventsEnabled = true;
- };
- ScrollView.prototype.setScrolling = function (isScrolling, ev) {
- if (this.isScrolling) {
- if (isScrolling) {
- this.onScroll && this.onScroll(ev);
- }
- else {
- this.isScrolling = false;
- this.onScrollEnd && this.onScrollEnd(ev);
- }
- }
- else if (isScrolling) {
- this.isScrolling = true;
- this.onScrollStart && this.onScrollStart(ev);
- }
- };
- ScrollView.prototype.enableNativeScrolling = function () {
- (void 0) /* assert */;
- (void 0) /* assert */;
- (void 0) /* assert */;
- this._js = false;
- if (!this._el) {
- return;
- }
- (void 0) /* console.debug */;
- var self = this;
- var ev = self.ev;
- var positions = [];
- function scrollCallback(scrollEvent) {
- // remind the app that it's currently scrolling
- self._app.setScrolling();
- // if events are disabled, we do nothing
- if (!self._eventsEnabled) {
- return;
- }
- ev.timeStamp = scrollEvent.timeStamp;
- // Event.timeStamp is 0 in firefox
- if (!ev.timeStamp) {
- ev.timeStamp = Date.now();
- }
- // get the current scrollTop
- // ******** DOM READ ****************
- ev.scrollTop = self.getTop();
- // get the current scrollLeft
- // ******** DOM READ ****************
- ev.scrollLeft = self.getLeft();
- if (!self.isScrolling) {
- // remember the start positions
- ev.startY = ev.scrollTop;
- ev.startX = ev.scrollLeft;
- // new scroll, so do some resets
- ev.velocityY = ev.velocityX = 0;
- ev.deltaY = ev.deltaX = 0;
- positions.length = 0;
- }
- // actively scrolling
- positions.push(ev.scrollTop, ev.scrollLeft, ev.timeStamp);
- if (positions.length > 3) {
- // we've gotten at least 2 scroll events so far
- ev.deltaY = (ev.scrollTop - ev.startY);
- ev.deltaX = (ev.scrollLeft - ev.startX);
- var endPos = (positions.length - 1);
- var startPos = endPos;
- var timeRange = (ev.timeStamp - 100);
- // move pointer to position measured 100ms ago
- for (var i = endPos; i > 0 && positions[i] > timeRange; i -= 3) {
- startPos = i;
- }
- if (startPos !== endPos) {
- // compute relative movement between these two points
- var movedTop = (positions[startPos - 2] - positions[endPos - 2]);
- var movedLeft = (positions[startPos - 1] - positions[endPos - 1]);
- var factor = FRAME_MS / (positions[endPos] - positions[startPos]);
- // based on XXms compute the movement to apply for each render step
- ev.velocityY = movedTop * factor;
- ev.velocityX = movedLeft * factor;
- // figure out which direction we're scrolling
- ev.directionY = (movedTop > 0 ? 'up' : 'down');
- ev.directionX = (movedLeft > 0 ? 'left' : 'right');
- }
- }
- function scrollEnd() {
- // reset velocity, do not reset the directions or deltas
- ev.velocityY = ev.velocityX = 0;
- // emit that the scroll has ended
- self.setScrolling(false, ev);
- self._endTmr = null;
- }
- // emit on each scroll event
- self.setScrolling(true, ev);
- // debounce for a moment after the last scroll event
- self._dom.cancel(self._endTmr);
- self._endTmr = self._dom.read(scrollEnd, SCROLL_END_DEBOUNCE_MS);
- }
- // clear out any existing listeners (just to be safe)
- self._lsn && self._lsn();
- // assign the raw scroll listener
- // note that it does not have a wrapping requestAnimationFrame on purpose
- // a scroll event callback will always be right before the raf callback
- // so there's little to no value of using raf here since it'll all ways immediately
- // call the raf if it was set within the scroll event, so this will save us some time
- self._lsn = self._plt.registerListener(self._el, 'scroll', scrollCallback, EVENT_OPTS);
- };
- /**
- * @hidden
- * JS Scrolling has been provided only as a temporary solution
- * until iOS apps can take advantage of scroll events at all times.
- * The goal is to eventually remove JS scrolling entirely. When we
- * no longer have to worry about iOS not firing scroll events during
- * inertia then this can be burned to the ground. iOS's more modern
- * WKWebView does not have this issue, only UIWebView does.
- */
- ScrollView.prototype.enableJsScroll = function (contentTop, contentBottom) {
- var self = this;
- self._js = true;
- var ele = self._el;
- if (!ele) {
- return;
- }
- (void 0) /* console.debug */;
- var ev = self.ev;
- var positions = [];
- var rafCancel;
- var max;
- function setMax() {
- if (!max) {
- // ******** DOM READ ****************
- max = ele.scrollHeight - ele.parentElement.offsetHeight + contentTop + contentBottom;
- }
- }
- function jsScrollDecelerate(timeStamp) {
- ev.timeStamp = timeStamp;
- (void 0) /* console.debug */;
- if (ev.velocityY) {
- ev.velocityY *= DECELERATION_FRICTION;
- // update top with updated velocity
- // clamp top within scroll limits
- // ******** DOM READ ****************
- setMax();
- self._t = Math.min(Math.max(self._t + ev.velocityY, 0), max);
- ev.scrollTop = self._t;
- // emit on each scroll event
- self.onScroll(ev);
- self._dom.write(function () {
- // ******** DOM WRITE ****************
- self.setTop(self._t);
- if (self._t > 0 && self._t < max && Math.abs(ev.velocityY) > MIN_VELOCITY_CONTINUE_DECELERATION) {
- rafCancel = self._dom.read(function (rafTimeStamp) {
- jsScrollDecelerate(rafTimeStamp);
- });
- }
- else {
- // haven't scrolled in a while, so it's a scrollend
- self.isScrolling = false;
- // reset velocity, do not reset the directions or deltas
- ev.velocityY = ev.velocityX = 0;
- // emit that the scroll has ended
- self.onScrollEnd(ev);
- }
- });
- }
- }
- function jsScrollTouchStart(touchEvent) {
- positions.length = 0;
- max = null;
- self._dom.cancel(rafCancel);
- positions.push(pointerCoord(touchEvent).y, touchEvent.timeStamp);
- }
- function jsScrollTouchMove(touchEvent) {
- if (!positions.length) {
- return;
- }
- ev.timeStamp = touchEvent.timeStamp;
- var y = pointerCoord(touchEvent).y;
- // ******** DOM READ ****************
- setMax();
- self._t -= (y - positions[positions.length - 2]);
- self._t = Math.min(Math.max(self._t, 0), max);
- positions.push(y, ev.timeStamp);
- if (!self.isScrolling) {
- // remember the start position
- ev.startY = self._t;
- // new scroll, so do some resets
- ev.velocityY = ev.deltaY = 0;
- self.isScrolling = true;
- // emit only on the first scroll event
- self.onScrollStart(ev);
- }
- self._dom.write(function () {
- // ******** DOM WRITE ****************
- self.setTop(self._t);
- });
- }
- function jsScrollTouchEnd(touchEvent) {
- // figure out what the scroll position was about 100ms ago
- self._dom.cancel(rafCancel);
- if (!positions.length && self.isScrolling) {
- self.isScrolling = false;
- ev.velocityY = ev.velocityX = 0;
- self.onScrollEnd(ev);
- return;
- }
- var y = pointerCoord(touchEvent).y;
- positions.push(y, touchEvent.timeStamp);
- var endPos = (positions.length - 1);
- var startPos = endPos;
- var timeRange = (touchEvent.timeStamp - 100);
- // move pointer to position measured 100ms ago
- for (var i = endPos; i > 0 && positions[i] > timeRange; i -= 2) {
- startPos = i;
- }
- if (startPos !== endPos) {
- // compute relative movement between these two points
- var timeOffset = (positions[endPos] - positions[startPos]);
- var movedTop = (positions[startPos - 1] - positions[endPos - 1]);
- // based on XXms compute the movement to apply for each render step
- ev.velocityY = ((movedTop / timeOffset) * FRAME_MS);
- // verify that we have enough velocity to start deceleration
- if (Math.abs(ev.velocityY) > MIN_VELOCITY_START_DECELERATION) {
- // ******** DOM READ ****************
- setMax();
- rafCancel = self._dom.read(function (rafTimeStamp) {
- jsScrollDecelerate(rafTimeStamp);
- });
- }
- }
- else {
- self.isScrolling = false;
- ev.velocityY = 0;
- self.onScrollEnd(ev);
- }
- positions.length = 0;
- }
- var plt = self._plt;
- var unRegStart = plt.registerListener(ele, 'touchstart', jsScrollTouchStart, EVENT_OPTS);
- var unRegMove = plt.registerListener(ele, 'touchmove', jsScrollTouchMove, EVENT_OPTS);
- var unRegEnd = plt.registerListener(ele, 'touchend', jsScrollTouchEnd, EVENT_OPTS);
- ele.parentElement.classList.add('js-scroll');
- // stop listening for actual scroll events
- self._lsn && self._lsn();
- // create an unregister for all of these events
- self._lsn = function () {
- unRegStart();
- unRegMove();
- unRegEnd();
- ele.parentElement.classList.remove('js-scroll');
- };
- };
- /**
- * DOM READ
- */
- ScrollView.prototype.getTop = function () {
- if (this._js) {
- return this._t;
- }
- return this._t = this._el.scrollTop;
- };
- /**
- * DOM READ
- */
- ScrollView.prototype.getLeft = function () {
- if (this._js) {
- return 0;
- }
- return this._l = this._el.scrollLeft;
- };
- /**
- * DOM WRITE
- */
- ScrollView.prototype.setTop = function (top) {
- this._t = top;
- if (this._js) {
- this._el.style[this._plt.Css.transform] = "translate3d(" + this._l * -1 + "px," + top * -1 + "px,0px)";
- }
- else {
- this._el.scrollTop = top;
- }
- };
- /**
- * DOM WRITE
- */
- ScrollView.prototype.setLeft = function (left) {
- this._l = left;
- if (this._js) {
- this._el.style[this._plt.Css.transform] = "translate3d(" + left * -1 + "px," + this._t * -1 + "px,0px)";
- }
- else {
- this._el.scrollLeft = left;
- }
- };
- ScrollView.prototype.scrollTo = function (x, y, duration, done) {
- // scroll animation loop w/ easing
- // credit https://gist.github.com/dezinezync/5487119
- var promise;
- if (done === undefined) {
- // only create a promise if a done callback wasn't provided
- // done can be a null, which avoids any functions
- promise = new Promise(function (resolve) {
- done = resolve;
- });
- }
- var self = this;
- var el = self._el;
- if (!el) {
- // invalid element
- done();
- return promise;
- }
- if (duration < 32) {
- self.setTop(y);
- self.setLeft(x);
- done();
- return promise;
- }
- var fromY = el.scrollTop;
- var fromX = el.scrollLeft;
- var maxAttempts = (duration / 16) + 100;
- var transform = self._plt.Css.transform;
- var startTime;
- var attempts = 0;
- var stopScroll = false;
- // scroll loop
- function step(timeStamp) {
- attempts++;
- if (!self._el || stopScroll || attempts > maxAttempts) {
- self.setScrolling(false, null);
- el.style[transform] = '';
- done();
- return;
- }
- var time = Math.min(1, ((timeStamp - startTime) / duration));
- // where .5 would be 50% of time on a linear scale easedT gives a
- // fraction based on the easing method
- var easedT = (--time) * time * time + 1;
- if (fromY !== y) {
- self.setTop((easedT * (y - fromY)) + fromY);
- }
- if (fromX !== x) {
- self.setLeft(Math.floor((easedT * (x - fromX)) + fromX));
- }
- if (easedT < 1) {
- // do not use DomController here
- // must use nativeRaf in order to fire in the next frame
- self._plt.raf(step);
- }
- else {
- stopScroll = true;
- self.setScrolling(false, null);
- el.style[transform] = '';
- done();
- }
- }
- // start scroll loop
- self.setScrolling(true, null);
- self.isScrolling = true;
- // chill out for a frame first
- self._dom.write(function (timeStamp) {
- startTime = timeStamp;
- step(timeStamp);
- }, 16);
- return promise;
- };
- ScrollView.prototype.scrollToTop = function (duration) {
- return this.scrollTo(0, 0, duration);
- };
- ScrollView.prototype.scrollToBottom = function (duration) {
- var y = 0;
- if (this._el) {
- y = this._el.scrollHeight - this._el.clientHeight;
- }
- return this.scrollTo(0, y, duration);
- };
- ScrollView.prototype.stop = function () {
- this.setScrolling(false, null);
- };
- /**
- * @hidden
- */
- ScrollView.prototype.destroy = function () {
- this.stop();
- this._endTmr && this._dom.cancel(this._endTmr);
- this._lsn && this._lsn();
- var ev = this.ev;
- ev.domWrite = ev.contentElement = ev.fixedElement = ev.scrollElement = ev.headerElement = null;
- this._lsn = this._el = this._dom = this.ev = ev = null;
- this.onScrollStart = this.onScroll = this.onScrollEnd = null;
- };
- return ScrollView;
- }());
- var SCROLL_END_DEBOUNCE_MS = 80;
- var MIN_VELOCITY_START_DECELERATION = 4;
- var MIN_VELOCITY_CONTINUE_DECELERATION = 0.12;
- var DECELERATION_FRICTION = 0.97;
- var FRAME_MS = (1000 / 60);
- var EVENT_OPTS = {
- passive: true,
- zone: false
- };
-
- var __extends$42 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- var EventEmitterProxy = (function (_super) {
- __extends$42(EventEmitterProxy, _super);
- function EventEmitterProxy() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- EventEmitterProxy.prototype.subscribe = function (generatorOrNext, error, complete) {
- this.onSubscribe();
- return _super.prototype.subscribe.call(this, generatorOrNext, error, complete);
- };
- return EventEmitterProxy;
- }(EventEmitter));
- /**
- * @name Content
- * @description
- * The Content component provides an easy to use content area with
- * some useful methods to control the scrollable area. There should
- * only be one content in a single view component. If additional scrollable
- * elements are needed, use [ionScroll](../../scroll/Scroll).
- *
- *
- * The content area can also implement pull-to-refresh with the
- * [Refresher](../../refresher/Refresher) component.
- *
- * @usage
- * ```html
- * <ion-content>
- * Add your content here!
- * </ion-content>
- * ```
- *
- * To get a reference to the content component from a Page's logic,
- * you can use Angular's `@ViewChild` annotation:
- *
- * ```ts
- * import { Component, ViewChild } from '@angular/core';
- * import { Content } from 'ionic-angular';
- *
- * @Component({...})
- * export class MyPage{
- * @ViewChild(Content) content: Content;
- *
- * scrollToTop() {
- * this.content.scrollToTop();
- * }
- * }
- * ```
- *
- * @advanced
- *
- * ### Scroll Events
- *
- * Scroll events happen outside of Angular's Zones. This is for performance reasons. So
- * if you're trying to bind a value to any scroll event, it will need to be wrapped in
- * a `zone.run()`
- *
- * ```ts
- * import { Component, NgZone } from '@angular/core';
- * @Component({
- * template: `
- * <ion-header>
- * <ion-navbar>
- * <ion-title>{{scrollAmount}}</ion-title>
- * </ion-navbar>
- * </ion-header>
- * <ion-content (ionScroll)="scrollHandler($event)">
- * <p> Some realllllllly long content </p>
- * </ion-content>
- * `})
- * class E2EPage {
- * public scrollAmount = 0;
- * constructor( public zone: NgZone){}
- * scrollHandler(event) {
- * console.log(`ScrollEvent: ${event}`)
- * this.zone.run(()=>{
- * // since scrollAmount is data-binded,
- * // the update needs to happen in zone
- * this.scrollAmount++
- * })
- * }
- * }
- * ```
- *
- * This goes for any scroll event, not just `ionScroll`.
- *
- * ### Resizing the content
- *
- * If the height of `ion-header`, `ion-footer` or `ion-tabbar`
- * changes dynamically, `content.resize()` has to be called in order to update the
- * layout of `Content`.
- *
- *
- * ```ts
- * @Component({
- * template: `
- * <ion-header>
- * <ion-navbar>
- * <ion-title>Main Navbar</ion-title>
- * </ion-navbar>
- * <ion-toolbar *ngIf="showToolbar">
- * <ion-title>Dynamic Toolbar</ion-title>
- * </ion-toolbar>
- * </ion-header>
- * <ion-content>
- * <button ion-button (click)="toggleToolbar()">Toggle Toolbar</button>
- * </ion-content>
- * `})
- *
- * class E2EPage {
- * @ViewChild(Content) content: Content;
- * showToolbar: boolean = false;
- *
- * toggleToolbar() {
- * this.showToolbar = !this.showToolbar;
- * this.content.resize();
- * }
- * }
- * ```
- *
- *
- * Scroll to a specific position
- *
- * ```ts
- * import { Component, ViewChild } from '@angular/core';
- * import { Content } from 'ionic-angular';
- *
- * @Component({
- * template: `<ion-content>
- * <button ion-button (click)="scrollTo()">Down 500px</button>
- * </ion-content>`
- * )}
- * export class MyPage{
- * @ViewChild(Content) content: Content;
- *
- * scrollTo() {
- * // set the scrollLeft to 0px, and scrollTop to 500px
- * // the scroll duration should take 200ms
- * this.content.scrollTo(0, 500, 200);
- * }
- * }
- * ```
- *
- */
- var Content = (function (_super) {
- __extends$42(Content, _super);
- function Content(config, _plt, _dom, elementRef, renderer, _app, _keyboard, _zone, viewCtrl, navCtrl) {
- var _this = _super.call(this, config, elementRef, renderer, 'content') || this;
- _this._plt = _plt;
- _this._dom = _dom;
- _this._app = _app;
- _this._keyboard = _keyboard;
- _this._zone = _zone;
- /** @internal */
- _this._scrollPadding = 0;
- /** @internal */
- _this._inputPolling = false;
- /** @internal */
- _this._hasRefresher = false;
- /** @internal */
- _this._imgs = [];
- /** @internal */
- _this._scrollDownOnLoad = false;
- /**
- * @output {ScrollEvent} Emitted when the scrolling first starts.
- */
- _this.ionScrollStart = new EventEmitterProxy();
- /**
- * @output {ScrollEvent} Emitted on every scroll event.
- */
- _this.ionScroll = new EventEmitterProxy();
- /**
- * @output {ScrollEvent} Emitted when scrolling ends.
- */
- _this.ionScrollEnd = new EventEmitterProxy();
- var enableScrollListener = function () { return _this._scroll.enableEvents(); };
- _this.ionScroll.onSubscribe = enableScrollListener;
- _this.ionScrollStart.onSubscribe = enableScrollListener;
- _this.ionScrollEnd.onSubscribe = enableScrollListener;
- _this.statusbarPadding = config.getBoolean('statusbarPadding', false);
- _this._imgReqBfr = config.getNumber('imgRequestBuffer', 1400);
- _this._imgRndBfr = config.getNumber('imgRenderBuffer', 400);
- _this._imgVelMax = config.getNumber('imgVelocityMax', 3);
- _this._scroll = new ScrollView(_app, _plt, _dom);
- while (navCtrl) {
- if (isTabs(navCtrl)) {
- _this._tabs = navCtrl;
- break;
- }
- navCtrl = navCtrl.parent;
- }
- if (viewCtrl) {
- _this._viewCtrl = viewCtrl;
- // content has a view controller
- viewCtrl._setIONContent(_this);
- viewCtrl._setIONContentRef(elementRef);
- _this._viewCtrlReadSub = viewCtrl.readReady.subscribe(function () {
- _this._viewCtrlReadSub.unsubscribe();
- _this._readDimensions();
- });
- _this._viewCtrlWriteSub = viewCtrl.writeReady.subscribe(function () {
- _this._viewCtrlWriteSub.unsubscribe();
- _this._writeDimensions();
- });
- }
- else {
- // content does not have a view controller
- _dom.read(_this._readDimensions.bind(_this));
- _dom.write(_this._writeDimensions.bind(_this));
- }
- return _this;
- }
- Object.defineProperty(Content.prototype, "contentHeight", {
- /**
- * Content height of the viewable area. This does not include content
- * which is outside the overflow area, or content area which is under
- * headers and footers. Read-only.
- *
- * @return {number}
- */
- get: function () {
- return this._scroll.ev.contentHeight;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Content.prototype, "contentWidth", {
- /**
- * Content width including content which is not visible on the screen
- * due to overflow. Read-only.
- *
- * @return {number}
- */
- get: function () {
- return this._scroll.ev.contentWidth;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Content.prototype, "scrollHeight", {
- /**
- * Content height including content which is not visible on the screen
- * due to overflow. Read-only.
- *
- * @return {number}
- */
- get: function () {
- return this._scroll.ev.scrollHeight;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Content.prototype, "scrollWidth", {
- /**
- * Content width including content which is not visible due to
- * overflow. Read-only.
- *
- * @return {number}
- */
- get: function () {
- return this._scroll.ev.scrollWidth;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Content.prototype, "scrollTop", {
- /**
- * The distance of the content's top to its topmost visible content.
- *
- * @return {number}
- */
- get: function () {
- return this._scroll.ev.scrollTop;
- },
- /**
- * @param {number} top
- */
- set: function (top) {
- this._scroll.setTop(top);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Content.prototype, "scrollLeft", {
- /**
- * The distance of the content's left to its leftmost visible content.
- *
- * @return {number}
- */
- get: function () {
- return this._scroll.ev.scrollLeft;
- },
- /**
- * @param {number} top
- */
- set: function (top) {
- this._scroll.setLeft(top);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Content.prototype, "isScrolling", {
- /**
- * If the content is actively scrolling or not.
- *
- * @return {boolean}
- */
- get: function () {
- return this._scroll.isScrolling;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Content.prototype, "directionY", {
- /**
- * The current, or last known, vertical scroll direction. Possible
- * string values include `down` and `up`.
- *
- * @return {string}
- */
- get: function () {
- return this._scroll.ev.directionY;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Content.prototype, "directionX", {
- /**
- * The current, or last known, horizontal scroll direction. Possible
- * string values include `right` and `left`.
- *
- * @return {string}
- */
- get: function () {
- return this._scroll.ev.directionX;
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @hidden
- */
- Content.prototype.ngAfterViewInit = function () {
- var _this = this;
- (void 0) /* assert */;
- (void 0) /* assert */;
- var scroll = this._scroll;
- scroll.ev.fixedElement = this.getFixedElement();
- scroll.ev.scrollElement = this.getScrollElement();
- // subscribe to the scroll start
- scroll.onScrollStart = function (ev) {
- _this.ionScrollStart.emit(ev);
- };
- // subscribe to every scroll move
- scroll.onScroll = function (ev) {
- // emit to all of our other friends things be scrolling
- _this.ionScroll.emit(ev);
- _this.imgsUpdate();
- };
- // subscribe to the scroll end
- scroll.onScrollEnd = function (ev) {
- _this.ionScrollEnd.emit(ev);
- _this.imgsUpdate();
- };
- };
- /**
- * @hidden
- */
- Content.prototype.enableJsScroll = function () {
- this._scroll.enableJsScroll(this._cTop, this._cBottom);
- };
- /**
- * @hidden
- */
- Content.prototype.ngOnDestroy = function () {
- this._scLsn && this._scLsn();
- this._viewCtrlReadSub && this._viewCtrlReadSub.unsubscribe();
- this._viewCtrlWriteSub && this._viewCtrlWriteSub.unsubscribe();
- this._viewCtrlReadSub = this._viewCtrlWriteSub = null;
- this._scroll && this._scroll.destroy();
- this._footerEle = this._scLsn = this._scroll = null;
- };
- /**
- * @hidden
- */
- Content.prototype.getScrollElement = function () {
- return this._scrollContent.nativeElement;
- };
- /**
- * @private
- */
- Content.prototype.getFixedElement = function () {
- return this._fixedContent.nativeElement;
- };
- /**
- * @hidden
- */
- Content.prototype.onScrollElementTransitionEnd = function (callback) {
- this._plt.transitionEnd(this.getScrollElement(), callback);
- };
- /**
- * Scroll to the specified position.
- *
- * @param {number} x The x-value to scroll to.
- * @param {number} y The y-value to scroll to.
- * @param {number} [duration] Duration of the scroll animation in milliseconds. Defaults to `300`.
- * @returns {Promise} Returns a promise which is resolved when the scroll has completed.
- */
- Content.prototype.scrollTo = function (x, y, duration, done) {
- if (duration === void 0) { duration = 300; }
- (void 0) /* console.debug */;
- return this._scroll.scrollTo(x, y, duration, done);
- };
- /**
- * Scroll to the top of the content component.
- *
- * @param {number} [duration] Duration of the scroll animation in milliseconds. Defaults to `300`.
- * @returns {Promise} Returns a promise which is resolved when the scroll has completed.
- */
- Content.prototype.scrollToTop = function (duration) {
- if (duration === void 0) { duration = 300; }
- (void 0) /* console.debug */;
- return this._scroll.scrollToTop(duration);
- };
- /**
- * Scroll to the bottom of the content component.
- *
- * @param {number} [duration] Duration of the scroll animation in milliseconds. Defaults to `300`.
- * @returns {Promise} Returns a promise which is resolved when the scroll has completed.
- */
- Content.prototype.scrollToBottom = function (duration) {
- if (duration === void 0) { duration = 300; }
- (void 0) /* console.debug */;
- return this._scroll.scrollToBottom(duration);
- };
- Object.defineProperty(Content.prototype, "fullscreen", {
- /**
- * @input {boolean} If true, the content will scroll behind the headers
- * and footers. This effect can easily be seen by setting the toolbar
- * to transparent.
- */
- get: function () {
- return this._fullscreen;
- },
- set: function (val) {
- this._fullscreen = isTrueProperty(val);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Content.prototype, "scrollDownOnLoad", {
- /**
- * @input {boolean} If true, the content will scroll down on load.
- */
- get: function () {
- return this._scrollDownOnLoad;
- },
- set: function (val) {
- this._scrollDownOnLoad = isTrueProperty(val);
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @private
- */
- Content.prototype.addImg = function (img) {
- this._imgs.push(img);
- };
- /**
- * @hidden
- */
- Content.prototype.removeImg = function (img) {
- removeArrayItem(this._imgs, img);
- };
- /**
- * @hidden
- * DOM WRITE
- */
- Content.prototype.setScrollElementStyle = function (prop, val) {
- var scrollEle = this.getScrollElement();
- if (scrollEle) {
- this._dom.write(function () {
- scrollEle.style[prop] = val;
- });
- }
- };
- /**
- * Returns the content and scroll elements' dimensions.
- * @returns {object} dimensions The content and scroll elements' dimensions
- * {number} dimensions.contentHeight content offsetHeight
- * {number} dimensions.contentTop content offsetTop
- * {number} dimensions.contentBottom content offsetTop+offsetHeight
- * {number} dimensions.contentWidth content offsetWidth
- * {number} dimensions.contentLeft content offsetLeft
- * {number} dimensions.contentRight content offsetLeft + offsetWidth
- * {number} dimensions.scrollHeight scroll scrollHeight
- * {number} dimensions.scrollTop scroll scrollTop
- * {number} dimensions.scrollBottom scroll scrollTop + scrollHeight
- * {number} dimensions.scrollWidth scroll scrollWidth
- * {number} dimensions.scrollLeft scroll scrollLeft
- * {number} dimensions.scrollRight scroll scrollLeft + scrollWidth
- */
- Content.prototype.getContentDimensions = function () {
- var scrollEle = this.getScrollElement();
- var parentElement = scrollEle.parentElement;
- return {
- contentHeight: parentElement.offsetHeight - this._cTop - this._cBottom,
- contentTop: this._cTop,
- contentBottom: this._cBottom,
- contentWidth: parentElement.offsetWidth,
- contentLeft: parentElement.offsetLeft,
- scrollHeight: scrollEle.scrollHeight,
- scrollTop: scrollEle.scrollTop,
- scrollWidth: scrollEle.scrollWidth,
- scrollLeft: scrollEle.scrollLeft,
- };
- };
- /**
- * @hidden
- * DOM WRITE
- * Adds padding to the bottom of the scroll element when the keyboard is open
- * so content below the keyboard can be scrolled into view.
- */
- Content.prototype.addScrollPadding = function (newPadding) {
- (void 0) /* assert */;
- if (newPadding === 0) {
- this._inputPolling = false;
- this._scrollPadding = -1;
- }
- if (newPadding > this._scrollPadding) {
- (void 0) /* console.debug */;
- this._scrollPadding = newPadding;
- var scrollEle = this.getScrollElement();
- if (scrollEle) {
- this._dom.write(function () {
- scrollEle.style.paddingBottom = (newPadding > 0) ? newPadding + 'px' : '';
- });
- }
- }
- };
- /**
- * @hidden
- * DOM WRITE
- */
- Content.prototype.clearScrollPaddingFocusOut = function () {
- var _this = this;
- if (!this._inputPolling) {
- (void 0) /* console.debug */;
- this._inputPolling = true;
- this._keyboard.onClose(function () {
- (void 0) /* console.debug */;
- _this.addScrollPadding(0);
- }, 200, 3000);
- }
- };
- /**
- * Tell the content to recalculate its dimensions. This should be called
- * after dynamically adding/removing headers, footers, or tabs.
- */
- Content.prototype.resize = function () {
- this._dom.read(this._readDimensions.bind(this));
- this._dom.write(this._writeDimensions.bind(this));
- };
- /**
- * @hidden
- * DOM READ
- */
- Content.prototype._readDimensions = function () {
- var cachePaddingTop = this._pTop;
- var cachePaddingRight = this._pRight;
- var cachePaddingBottom = this._pBottom;
- var cachePaddingLeft = this._pLeft;
- var cacheHeaderHeight = this._hdrHeight;
- var cacheFooterHeight = this._ftrHeight;
- var cacheTabsPlacement = this._tabsPlacement;
- var tabsTop = 0;
- var scrollEvent;
- this._pTop = 0;
- this._pRight = 0;
- this._pBottom = 0;
- this._pLeft = 0;
- this._hdrHeight = 0;
- this._ftrHeight = 0;
- this._tabsPlacement = null;
- this._tTop = 0;
- this._fTop = 0;
- this._fBottom = 0;
- // In certain cases this._scroll is undefined
- // if that is the case then we should just return
- if (!this._scroll) {
- return;
- }
- scrollEvent = this._scroll.ev;
- var ele = this.getNativeElement();
- if (!ele) {
- (void 0) /* assert */;
- return;
- }
- var computedStyle;
- var tagName;
- var parentEle = ele.parentElement;
- var children = parentEle.children;
- for (var i = children.length - 1; i >= 0; i--) {
- ele = children[i];
- tagName = ele.tagName;
- if (tagName === 'ION-CONTENT') {
- scrollEvent.contentElement = ele;
- if (this._fullscreen) {
- // ******** DOM READ ****************
- computedStyle = getComputedStyle(ele);
- this._pTop = parsePxUnit(computedStyle.paddingTop);
- this._pBottom = parsePxUnit(computedStyle.paddingBottom);
- this._pRight = parsePxUnit(computedStyle.paddingRight);
- this._pLeft = parsePxUnit(computedStyle.paddingLeft);
- }
- }
- else if (tagName === 'ION-HEADER') {
- scrollEvent.headerElement = ele;
- // ******** DOM READ ****************
- this._hdrHeight = ele.clientHeight;
- }
- else if (tagName === 'ION-FOOTER') {
- scrollEvent.footerElement = ele;
- // ******** DOM READ ****************
- this._ftrHeight = ele.clientHeight;
- this._footerEle = ele;
- }
- }
- ele = parentEle;
- var tabbarEle;
- while (ele && ele.tagName !== 'ION-MODAL' && !ele.classList.contains('tab-subpage')) {
- if (ele.tagName === 'ION-TABS') {
- tabbarEle = ele.firstElementChild;
- // ******** DOM READ ****************
- this._tabbarHeight = tabbarEle.clientHeight;
- if (this._tabsPlacement === null) {
- // this is the first tabbar found, remember it's position
- this._tabsPlacement = ele.getAttribute('tabsplacement');
- }
- }
- ele = ele.parentElement;
- }
- // Tabs top
- if (this._tabs && this._tabsPlacement === 'top') {
- this._tTop = this._hdrHeight;
- tabsTop = this._tabs._top;
- }
- // Toolbar height
- this._cTop = this._hdrHeight;
- this._cBottom = this._ftrHeight;
- // Tabs height
- if (this._tabsPlacement === 'top') {
- this._cTop += this._tabbarHeight;
- }
- else if (this._tabsPlacement === 'bottom') {
- this._cBottom += this._tabbarHeight;
- }
- // Refresher uses a border which should be hidden unless pulled
- if (this._hasRefresher) {
- this._cTop -= 1;
- }
- // Fixed content shouldn't include content padding
- this._fTop = this._cTop;
- this._fBottom = this._cBottom;
- // Handle fullscreen viewport (padding vs margin)
- if (this._fullscreen) {
- this._cTop += this._pTop;
- this._cBottom += this._pBottom;
- }
- // ******** DOM READ ****************
- var contentDimensions = this.getContentDimensions();
- scrollEvent.scrollHeight = contentDimensions.scrollHeight;
- scrollEvent.scrollWidth = contentDimensions.scrollWidth;
- scrollEvent.contentHeight = contentDimensions.contentHeight;
- scrollEvent.contentWidth = contentDimensions.contentWidth;
- scrollEvent.contentTop = contentDimensions.contentTop;
- scrollEvent.contentBottom = contentDimensions.contentBottom;
- this._dirty = (cachePaddingTop !== this._pTop ||
- cachePaddingBottom !== this._pBottom ||
- cachePaddingLeft !== this._pLeft ||
- cachePaddingRight !== this._pRight ||
- cacheHeaderHeight !== this._hdrHeight ||
- cacheFooterHeight !== this._ftrHeight ||
- cacheTabsPlacement !== this._tabsPlacement ||
- tabsTop !== this._tTop ||
- this._cTop !== this.contentTop ||
- this._cBottom !== this.contentBottom);
- this._scroll.init(this.getScrollElement(), this._cTop, this._cBottom);
- // initial imgs refresh
- this.imgsUpdate();
- };
- /**
- * @hidden
- * DOM WRITE
- */
- Content.prototype._writeDimensions = function () {
- if (!this._dirty) {
- (void 0) /* console.debug */;
- return;
- }
- var scrollEle = this.getScrollElement();
- if (!scrollEle) {
- (void 0) /* assert */;
- return;
- }
- var fixedEle = this.getFixedElement();
- if (!fixedEle) {
- (void 0) /* assert */;
- return;
- }
- // Tabs height
- if (this._tabsPlacement === 'bottom' && this._cBottom > 0 && this._footerEle) {
- var footerPos = this._cBottom - this._ftrHeight;
- (void 0) /* assert */;
- // ******** DOM WRITE ****************
- this._footerEle.style.bottom = cssFormat(footerPos);
- }
- // Handle fullscreen viewport (padding vs margin)
- var topProperty = 'marginTop';
- var bottomProperty = 'marginBottom';
- var fixedTop = this._fTop;
- var fixedBottom = this._fBottom;
- if (this._fullscreen) {
- (void 0) /* assert */;
- (void 0) /* assert */;
- // adjust the content with padding, allowing content to scroll under headers/footers
- // however, on iOS you cannot control the margins of the scrollbar (last tested iOS9.2)
- // only add inline padding styles if the computed padding value, which would
- // have come from the app's css, is different than the new padding value
- topProperty = 'paddingTop';
- bottomProperty = 'paddingBottom';
- }
- // Only update top margin if value changed
- if (this._cTop !== this.contentTop) {
- (void 0) /* assert */;
- (void 0) /* assert */;
- // ******** DOM WRITE ****************
- scrollEle.style[topProperty] = cssFormat(this._cTop);
- // ******** DOM WRITE ****************
- fixedEle.style.marginTop = cssFormat(fixedTop);
- this.contentTop = this._cTop;
- }
- // Only update bottom margin if value changed
- if (this._cBottom !== this.contentBottom) {
- (void 0) /* assert */;
- (void 0) /* assert */;
- // ******** DOM WRITE ****************
- scrollEle.style[bottomProperty] = cssFormat(this._cBottom);
- // ******** DOM WRITE ****************
- fixedEle.style.marginBottom = cssFormat(fixedBottom);
- this.contentBottom = this._cBottom;
- }
- if (this._tabsPlacement !== null && this._tabs) {
- // set the position of the tabbar
- if (this._tabsPlacement === 'top') {
- // ******** DOM WRITE ****************
- this._tabs.setTabbarPosition(this._tTop, -1);
- }
- else {
- (void 0) /* assert */;
- // ******** DOM WRITE ****************
- this._tabs.setTabbarPosition(-1, 0);
- }
- }
- // Scroll the page all the way down after setting dimensions
- if (this._scrollDownOnLoad) {
- this.scrollToBottom(0);
- this._scrollDownOnLoad = false;
- }
- };
- /**
- * @hidden
- */
- Content.prototype.imgsUpdate = function () {
- if (this._scroll.initialized && this._imgs.length && this.isImgsUpdatable()) {
- updateImgs(this._imgs, this.scrollTop, this.contentHeight, this.directionY, this._imgReqBfr, this._imgRndBfr);
- }
- };
- /**
- * @hidden
- */
- Content.prototype.isImgsUpdatable = function () {
- // an image is only "updatable" if the content isn't scrolling too fast
- // if scroll speed is above the maximum velocity, then let current
- // requests finish, but do not start new requets or render anything
- // if scroll speed is below the maximum velocity, then it's ok
- // to start new requests and render images
- return Math.abs(this._scroll.ev.velocityY) < this._imgVelMax;
- };
- Content.decorators = [
- { type: Component, args: [{
- selector: 'ion-content',
- template: '<div class="fixed-content" #fixedContent>' +
- '<ng-content select="[ion-fixed],ion-fab"></ng-content>' +
- '</div>' +
- '<div class="scroll-content" #scrollContent>' +
- '<ng-content></ng-content>' +
- '</div>' +
- '<ng-content select="ion-refresher"></ng-content>',
- host: {
- '[class.statusbar-padding]': 'statusbarPadding',
- '[class.has-refresher]': '_hasRefresher'
- },
- changeDetection: ChangeDetectionStrategy.OnPush,
- encapsulation: ViewEncapsulation.None
- },] },
- ];
- /** @nocollapse */
- Content.ctorParameters = function () { return [
- { type: Config, },
- { type: Platform, },
- { type: DomController, },
- { type: ElementRef, },
- { type: Renderer, },
- { type: App, },
- { type: Keyboard, },
- { type: NgZone, },
- { type: ViewController, decorators: [{ type: Optional },] },
- { type: NavController, decorators: [{ type: Optional },] },
- ]; };
- Content.propDecorators = {
- '_fixedContent': [{ type: ViewChild, args: ['fixedContent', { read: ElementRef },] },],
- '_scrollContent': [{ type: ViewChild, args: ['scrollContent', { read: ElementRef },] },],
- 'ionScrollStart': [{ type: Output },],
- 'ionScroll': [{ type: Output },],
- 'ionScrollEnd': [{ type: Output },],
- 'fullscreen': [{ type: Input },],
- 'scrollDownOnLoad': [{ type: Input },],
- };
- return Content;
- }(Ion));
- function updateImgs(imgs, viewableTop, contentHeight, scrollDirectionY, requestableBuffer, renderableBuffer) {
- // ok, so it's time to see which images, if any, should be requested and rendered
- // ultimately, if we're scrolling fast then don't bother requesting or rendering
- // when scrolling is done, then it needs to do a check to see which images are
- // important to request and render, and which image requests should be aborted.
- // Additionally, images which are not near the viewable area should not be
- // rendered at all in order to save browser resources.
- var viewableBottom = (viewableTop + contentHeight);
- var priority1 = [];
- var priority2 = [];
- var img;
- // all images should be paused
- for (var i = 0, ilen = imgs.length; i < ilen; i++) {
- img = imgs[i];
- if (scrollDirectionY === 'up') {
- // scrolling up
- if (img.top < viewableBottom && img.bottom > viewableTop - renderableBuffer) {
- // scrolling up, img is within viewable area
- // or about to be viewable area
- img.canRequest = img.canRender = true;
- priority1.push(img);
- continue;
- }
- if (img.bottom <= viewableTop && img.bottom > viewableTop - requestableBuffer) {
- // scrolling up, img is within requestable area
- img.canRequest = true;
- img.canRender = false;
- priority2.push(img);
- continue;
- }
- if (img.top >= viewableBottom && img.top < viewableBottom + renderableBuffer) {
- // scrolling up, img below viewable area
- // but it's still within renderable area
- // don't allow a reset
- img.canRequest = img.canRender = false;
- continue;
- }
- }
- else {
- // scrolling down
- if (img.bottom > viewableTop && img.top < viewableBottom + renderableBuffer) {
- // scrolling down, img is within viewable area
- // or about to be viewable area
- img.canRequest = img.canRender = true;
- priority1.push(img);
- continue;
- }
- if (img.top >= viewableBottom && img.top < viewableBottom + requestableBuffer) {
- // scrolling down, img is within requestable area
- img.canRequest = true;
- img.canRender = false;
- priority2.push(img);
- continue;
- }
- if (img.bottom <= viewableTop && img.bottom > viewableTop - renderableBuffer) {
- // scrolling down, img above viewable area
- // but it's still within renderable area
- // don't allow a reset
- img.canRequest = img.canRender = false;
- continue;
- }
- }
- img.canRequest = img.canRender = false;
- img.reset();
- }
- // update all imgs which are viewable
- priority1.sort(sortTopToBottom).forEach(function (i) { return i.update(); });
- if (scrollDirectionY === 'up') {
- // scrolling up
- priority2.sort(sortTopToBottom).reverse().forEach(function (i) { return i.update(); });
- }
- else {
- // scrolling down
- priority2.sort(sortTopToBottom).forEach(function (i) { return i.update(); });
- }
- }
- function sortTopToBottom(a, b) {
- if (a.top < b.top) {
- return -1;
- }
- if (a.top > b.top) {
- return 1;
- }
- return 0;
- }
- function parsePxUnit(val) {
- return (val.indexOf('px') > 0) ? parseInt(val, 10) : 0;
- }
- function cssFormat(val) {
- return (val > 0 ? val + 'px' : '');
- }
-
- /**
- * @hidden
- */
- function indexForItem(element) {
- return element['$ionIndex'];
- }
- /**
- * @hidden
- */
-
- /**
- * @hidden
- */
- function findReorderItem(node, listNode) {
- var nested = 0;
- while (node && nested < 4) {
- if (indexForItem(node) !== undefined) {
- if (listNode && node.parentNode !== listNode) {
- return null;
- }
- return node;
- }
- node = node.parentNode;
- nested++;
- }
- return null;
- }
-
- /**
- * @hidden
- */
- var ItemReorderGesture = (function () {
- function ItemReorderGesture(plt, reorderList) {
- this.plt = plt;
- this.reorderList = reorderList;
- this.selectedItemEle = null;
- this.events = new UIEventManager(plt);
- this.events.pointerEvents({
- element: this.reorderList.getNativeElement(),
- pointerDown: this.onDragStart.bind(this),
- pointerMove: this.onDragMove.bind(this),
- pointerUp: this.onDragEnd.bind(this),
- zone: false
- });
- }
- ItemReorderGesture.prototype.onDragStart = function (ev) {
- if (this.selectedItemEle) {
- return false;
- }
- var reorderElement = ev.target;
- if (reorderElement.nodeName !== 'ION-REORDER') {
- return false;
- }
- var reorderMark = reorderElement['$ionComponent'];
- if (!reorderMark) {
- console.error('ion-reorder does not contain $ionComponent');
- return false;
- }
- this.reorderList._reorderPrepare();
- var item = reorderMark.getReorderNode();
- if (!item) {
- console.error('reorder node not found');
- return false;
- }
- ev.preventDefault();
- // Preparing state
- this.selectedItemEle = item;
- this.selectedItemHeight = item.offsetHeight;
- this.lastYcoord = -100;
- this.lastToIndex = indexForItem(item);
- this.windowHeight = this.plt.height() - AUTO_SCROLL_MARGIN;
- this.lastScrollPosition = this.reorderList._scrollContent(0);
- this.offset = pointerCoord(ev);
- this.offset.y += this.lastScrollPosition;
- item.classList.add(ITEM_REORDER_ACTIVE);
- this.reorderList._reorderStart();
- return true;
- };
- ItemReorderGesture.prototype.onDragMove = function (ev) {
- var selectedItem = this.selectedItemEle;
- if (!selectedItem) {
- return;
- }
- ev.preventDefault();
- // Get coordinate
- var coord = pointerCoord(ev);
- var posY = coord.y;
- // Scroll if we reach the scroll margins
- var scrollPosition = this.scroll(posY);
- // Only perform hit test if we moved at least 30px from previous position
- if (Math.abs(posY - this.lastYcoord) > 30) {
- var overItem = this.itemForCoord(coord);
- if (overItem) {
- var toIndex = indexForItem(overItem);
- if (toIndex !== undefined && (toIndex !== this.lastToIndex || this.emptyZone)) {
- var fromIndex = indexForItem(selectedItem);
- this.lastToIndex = toIndex;
- this.lastYcoord = posY;
- this.emptyZone = false;
- this.reorderList._reorderMove(fromIndex, toIndex, this.selectedItemHeight);
- }
- }
- else {
- this.emptyZone = true;
- }
- }
- // Update selected item position
- var ydiff = Math.round(posY - this.offset.y + scrollPosition);
- selectedItem.style[this.plt.Css.transform] = "translateY(" + ydiff + "px)";
- };
- ItemReorderGesture.prototype.onDragEnd = function (ev) {
- var _this = this;
- var selectedItem = this.selectedItemEle;
- if (!selectedItem) {
- return;
- }
- if (ev) {
- ev.preventDefault();
- ev.stopPropagation();
- }
- var toIndex = this.lastToIndex;
- var fromIndex = indexForItem(selectedItem);
- var reorderInactive = function () {
- _this.selectedItemEle.style.transition = '';
- _this.selectedItemEle.classList.remove(ITEM_REORDER_ACTIVE);
- _this.selectedItemEle = null;
- };
- if (toIndex === fromIndex) {
- selectedItem.style.transition = 'transform 200ms ease-in-out';
- setTimeout(reorderInactive, 200);
- }
- else {
- reorderInactive();
- }
- this.reorderList._reorderEmit(fromIndex, toIndex);
- };
- ItemReorderGesture.prototype.itemForCoord = function (coord) {
- var sideOffset = this.reorderList._isStart === this.plt.isRTL ? -100 : 100;
- var x = this.offset.x + sideOffset;
- var y = coord.y;
- var element = this.plt.getElementFromPoint(x, y);
- return findReorderItem(element, this.reorderList.getNativeElement());
- };
- ItemReorderGesture.prototype.scroll = function (posY) {
- if (posY < AUTO_SCROLL_MARGIN) {
- this.lastScrollPosition = this.reorderList._scrollContent(-SCROLL_JUMP);
- }
- else if (posY > this.windowHeight) {
- this.lastScrollPosition = this.reorderList._scrollContent(SCROLL_JUMP);
- }
- return this.lastScrollPosition;
- };
- /**
- * @hidden
- */
- ItemReorderGesture.prototype.destroy = function () {
- this.onDragEnd(null);
- this.events.destroy();
- this.events = null;
- this.reorderList = null;
- };
- return ItemReorderGesture;
- }());
- var AUTO_SCROLL_MARGIN = 60;
- var SCROLL_JUMP = 10;
- var ITEM_REORDER_ACTIVE = 'reorder-active';
-
- var ReorderIndexes = (function () {
- function ReorderIndexes(from, to) {
- this.from = from;
- this.to = to;
- }
- ReorderIndexes.prototype.applyTo = function (array) {
- reorderArray(array, this);
- };
- return ReorderIndexes;
- }());
- /**
- * @name ItemReorder
- * @description
- * Item reorder adds the ability to change an item's order in a group.
- * It can be used within an `ion-list` or `ion-item-group` to provide a
- * visual drag and drop interface.
- *
- * ## Grouping Items
- *
- * All reorderable items must be grouped in the same element. If an item
- * should not be reordered, it shouldn't be included in this group. For
- * example, the following code works because the items are grouped in the
- * `<ion-list>`:
- *
- * ```html
- * <ion-list reorder="true">
- * <ion-item *ngFor="let item of items">{% raw %}{{ item }}{% endraw %}</ion-item>
- * </ion-list>
- * ```
- *
- * However, the below list includes a header that shouldn't be reordered:
- *
- * ```html
- * <ion-list reorder="true">
- * <ion-list-header>Header</ion-list-header>
- * <ion-item *ngFor="let item of items">{% raw %}{{ item }}{% endraw %}</ion-item>
- * </ion-list>
- * ```
- *
- * In order to mix different sets of items, `ion-item-group` should be used to
- * group the reorderable items:
- *
- * ```html
- * <ion-list>
- * <ion-list-header>Header</ion-list-header>
- * <ion-item-group reorder="true">
- * <ion-item *ngFor="let item of items">{% raw %}{{ item }}{% endraw %}</ion-item>
- * </ion-item-group>
- * </ion-list>
- * ```
- *
- * It's important to note that in this example, the `[reorder]` directive is applied to
- * the `<ion-item-group>` instead of the `<ion-list>`. This way makes it possible to
- * mix items that should and shouldn't be reordered.
- *
- *
- * ## Implementing the Reorder Function
- *
- * When the item is dragged and dropped into the new position, the `(ionItemReorder)` event is
- * emitted. This event provides the initial index (from) and the new index (to) of the reordered
- * item. For example, if the first item is dragged to the fifth position, the event will emit
- * `{from: 0, to: 4}`. Note that the index starts at zero.
- *
- * A function should be called when the event is emitted that handles the reordering of the items.
- * See [usage](#usage) below for some examples.
- *
- *
- * @usage
- *
- * ```html
- * <ion-list>
- * <ion-list-header>Header</ion-list-header>
- * <ion-item-group reorder="true" (ionItemReorder)="reorderItems($event)">
- * <ion-item *ngFor="let item of items">{% raw %}{{ item }}{% endraw %}</ion-item>
- * </ion-item-group>
- * </ion-list>
- * ```
- *
- * ```ts
- * class MyComponent {
- * items = [];
- *
- * constructor() {
- * for (let x = 0; x < 5; x++) {
- * this.items.push(x);
- * }
- * }
- *
- * reorderItems(indexes) {
- * let element = this.items[indexes.from];
- * this.items.splice(indexes.from, 1);
- * this.items.splice(indexes.to, 0, element);
- * }
- * }
- * ```
- *
- * Ionic also provides a helper function called `reorderArray` to
- * reorder the array of items. This can be used instead:
- *
- * ```ts
- * import { reorderArray } from 'ionic-angular';
- *
- * class MyComponent {
- * items = [];
- *
- * constructor() {
- * for (let x = 0; x < 5; x++) {
- * this.items.push(x);
- * }
- * }
- *
- * reorderItems(indexes) {
- * this.items = reorderArray(this.items, indexes);
- * }
- * }
- * ```
- * Alternatevely you can execute helper function inside template:
- *
- * ```html
- * <ion-list>
- * <ion-list-header>Header</ion-list-header>
- * <ion-item-group reorder="true" (ionItemReorder)="$event.applyTo(items)">
- * <ion-item *ngFor="let item of items">{% raw %}{{ item }}{% endraw %}</ion-item>
- * </ion-item-group>
- * </ion-list>
- * ```
- *
- * @demo /docs/demos/src/item-reorder/
- * @see {@link /docs/components#lists List Component Docs}
- * @see {@link ../../list/List List API Docs}
- * @see {@link ../Item Item API Docs}
- */
- var ItemReorder = (function () {
- function ItemReorder(_plt, _dom, elementRef, _rendered, _zone, _content) {
- this._plt = _plt;
- this._dom = _dom;
- this._rendered = _rendered;
- this._zone = _zone;
- this._content = _content;
- this._enableReorder = false;
- this._visibleReorder = false;
- this._isStart = false;
- this._lastToIndex = -1;
- /**
- * @output {object} Emitted when the item is reordered. Emits an object
- * with `from` and `to` properties.
- */
- this.ionItemReorder = new EventEmitter();
- this._element = elementRef.nativeElement;
- }
- Object.defineProperty(ItemReorder.prototype, "side", {
- /**
- * @input {string} Which side of the view the ion-reorder should be placed. Default `"end"`.
- */
- set: function (side) {
- this._isStart = side === 'start';
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @hidden
- */
- ItemReorder.prototype.ngOnDestroy = function () {
- this._element = null;
- this._reorderGesture && this._reorderGesture.destroy();
- };
- Object.defineProperty(ItemReorder.prototype, "reorder", {
- /**
- * @hidden
- */
- get: function () {
- return this._enableReorder;
- },
- set: function (val) {
- var _this = this;
- var enabled = isTrueProperty(val);
- if (!enabled && this._reorderGesture) {
- this._reorderGesture.destroy();
- this._reorderGesture = null;
- this._visibleReorder = false;
- setTimeout(function () { return _this._enableReorder = false; }, 400);
- }
- else if (enabled && !this._reorderGesture) {
- (void 0) /* console.debug */;
- this._reorderGesture = new ItemReorderGesture(this._plt, this);
- this._enableReorder = true;
- this._dom.write(function () {
- _this._zone.run(function () {
- _this._visibleReorder = true;
- });
- }, 16);
- }
- },
- enumerable: true,
- configurable: true
- });
- ItemReorder.prototype._reorderPrepare = function () {
- var ele = this._element;
- var children = ele.children;
- for (var i = 0, ilen = children.length; i < ilen; i++) {
- var child = children[i];
- child.$ionIndex = i;
- child.$ionReorderList = ele;
- }
- };
- ItemReorder.prototype._reorderStart = function () {
- this.setElementClass('reorder-list-active', true);
- };
- ItemReorder.prototype._reorderEmit = function (fromIndex, toIndex) {
- var _this = this;
- this._reorderReset();
- if (fromIndex !== toIndex) {
- this._zone.run(function () {
- var indexes = new ReorderIndexes(fromIndex, toIndex);
- _this.ionItemReorder.emit(indexes);
- });
- }
- };
- ItemReorder.prototype._scrollContent = function (scroll) {
- var scrollTop = this._content.scrollTop + scroll;
- if (scroll !== 0) {
- this._content.scrollTo(0, scrollTop, 0);
- }
- return scrollTop;
- };
- ItemReorder.prototype._reorderReset = function () {
- var children = this._element.children;
- var len = children.length;
- this.setElementClass('reorder-list-active', false);
- var transform = this._plt.Css.transform;
- for (var i = 0; i < len; i++) {
- children[i].style[transform] = '';
- }
- this._lastToIndex = -1;
- };
- ItemReorder.prototype._reorderMove = function (fromIndex, toIndex, itemHeight) {
- if (this._lastToIndex === -1) {
- this._lastToIndex = fromIndex;
- }
- var lastToIndex = this._lastToIndex;
- this._lastToIndex = toIndex;
- // TODO: I think both loops can be merged into a single one
- // but I had no luck last time I tried
- /********* DOM READ ********** */
- var children = this._element.children;
- /********* DOM WRITE ********* */
- var transform = this._plt.Css.transform;
- if (toIndex >= lastToIndex) {
- for (var i = lastToIndex; i <= toIndex; i++) {
- if (i !== fromIndex) {
- children[i].style[transform] = (i > fromIndex)
- ? "translateY(" + -itemHeight + "px)" : '';
- }
- }
- }
- if (toIndex <= lastToIndex) {
- for (var i = toIndex; i <= lastToIndex; i++) {
- if (i !== fromIndex) {
- children[i].style[transform] = (i < fromIndex)
- ? "translateY(" + itemHeight + "px)" : '';
- }
- }
- }
- };
- /**
- * @hidden
- */
- ItemReorder.prototype.setElementClass = function (classname, add) {
- this._rendered.setElementClass(this._element, classname, add);
- };
- /**
- * @hidden
- */
- ItemReorder.prototype.getNativeElement = function () {
- return this._element;
- };
- ItemReorder.decorators = [
- { type: Directive, args: [{
- selector: 'ion-list[reorder],ion-item-group[reorder]',
- host: {
- '[class.reorder-enabled]': '_enableReorder',
- '[class.reorder-visible]': '_visibleReorder',
- '[class.reorder-side-start]': '_isStart'
- }
- },] },
- ];
- /** @nocollapse */
- ItemReorder.ctorParameters = function () { return [
- { type: Platform, },
- { type: DomController, },
- { type: ElementRef, },
- { type: Renderer, },
- { type: NgZone, },
- { type: Content, decorators: [{ type: Optional },] },
- ]; };
- ItemReorder.propDecorators = {
- 'ionItemReorder': [{ type: Output },],
- 'side': [{ type: Input, args: ['side',] },],
- 'reorder': [{ type: Input },],
- };
- return ItemReorder;
- }());
-
- var __extends$39 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @name Item
- * @description
- * An item can contain text, images, and anything else. Generally it is placed in a list with other
- * items. It can easily be swiped, deleted, reordered, edited, and more. An item is only required to
- * be in a [List](../../list/List) if manipulating the item via gestures is required. It requires an
- * [ItemSliding](../ItemSliding) wrapper element in order to be swiped.
- *
- *
- * ## Common Usage
- * There are a few elements that are considered items, but not all of them are styled to look the same.
- * The basic item can be written as an `<ion-item>` element or it can be added to any element by adding
- * `ion-item` as an attribute. List headers and item dividers, although styled differently, are also items
- * and can be written as `<ion-list-header>` and `<ion-item-divider>`, respectively.
- *
- * ### As an Element
- * A basic item should be written as a `<ion-item>` element when it is not clickable.
- *
- * ```html
- * <ion-item>
- * Item
- * </ion-item>
- * ```
- *
- * A list header should be written as `<ion-list-header>`.
- *
- * ```html
- * <ion-list-header>
- * List Header
- * </ion-list-header>
- * ```
- *
- * An item divider should be written as `<ion-item-divider>`.
- *
- * ```html
- * <ion-item-divider>
- * Item Divider
- * </ion-item-divider>
- * ```
- *
- * ### As an Attribute
- * The attribute `ion-item` should be added to a `<button>` when the item can be clicked or tapped. It
- * should be added to an `<a>` element when the item needs to contain a `href`. It can be added as an
- * attribute to any element to take on the item styling.
- *
- * ```html
- * <button ion-item (click)="buttonClick()">
- * Button Item
- * </button>
- *
- * <a ion-item href="https://www.ionicframework.com">
- * Anchor Item
- * </a>
- * ```
- *
- * Note: do not add `ion-item` as an attribute to an `<ion-list-header>` or `<ion-item-divider>` element
- * as they are already items and their styling will be changed to look like a basic item.
- *
- * ## Detail Arrows
- * By default, `<button>` and `<a>` elements with the `ion-item` attribute will display a right arrow icon
- * on `ios` mode. To hide the right arrow icon on either of these elements, add the `detail-none` attribute
- * to the item. To show the right arrow icon on an element that doesn't display it naturally, add the
- * `detail-push` attribute to the item.
- *
- * ```html
- * <ion-item detail-push>
- * Item with Detail Arrow
- * </ion-item>
- *
- * <button ion-item (click)="buttonClick()">
- * Button Item with Detail Arrow
- * </button>
- *
- * <a ion-item detail-none href="https://www.ionicframework.com">
- * Anchor Item with no Detail Arrow
- * </a>
- * ```
- *
- * This feature is not enabled by default for `md` and `wp` modes, but it can be enabled by setting the
- * Sass variables `$item-md-detail-push-show` and `$item-wp-detail-push-show`, respectively, to `true`.
- * It can also be disabled for ios by setting `$item-ios-detail-push-show` to `false`. See the
- * [theming documentation](http://ionicframework.com/docs/theming/overriding-ionic-variables/) for
- * more information on overriding Sass variables.
- *
- *
- * ## Item Placement
- * Items rely heavily on content projection to position content. The item grabs content based on the
- * element or attribute and positions it that way. This logic makes it possible to write a complex
- * item with simple, understandable markup without having to worry about styling and positioning
- * the elements.
- *
- * The below chart details the attributes item looks for and where it will place the element with
- * that attribute inside of the item:
- *
- * | Attribute | Description |
- * |----------------|----------------------------------------------------------------------------------------------------- |
- * | `item-start` | Placed to the left of all other elements, outside of the inner item. |
- * | `item-end` | Placed to the right of all other elements, inside of the inner item, outside of the input wrapper. |
- * | `item-content` | Placed to the right of any `ion-label`, inside of the input wrapper. |
- *
- * ### Checkboxes, Radios and Toggles
- * [Checkboxes](../../checkbox/Checkbox) are positioned in the same place as the `item-start` attribute.
- * [Radios](../../radio/RadioButton) and [Toggles](../../toggle/Toggle) are positioned in the same place
- * as the `item-end` attribute. All of these components can be positioned differently by adding the
- * `item-start` or `item-end` attribute.
- *
- * ### Content and Inputs
- * A [Label](../../label/Label) is placed inside of the item to the left of all content and inputs. The
- * following components are all placed in the same position as the `item-content` attribute: [Select](../../select/Select),
- * [Input](../../input/Input), [TextArea](../../input/TextArea), [DateTime](../../datetime/DateTime), and
- * [Range](../../range/Range).
- *
- * Any element directly placed inside of an `<ion-item>` that does not have one of the previously mentioned
- * attributes and isn't one of the above elements will be placed inside of a [Label](../../label/Label).
- *
- * ### Text Alignment
- * By default, Items will align text to the left and add an ellipsis when the text is wider than the item.
- * See the [Utility Attributes Documentation](../../../../theming/css-utilities/) for attributes that can
- * be added to `ion-item` to transform the text.
- *
- * @usage
- *
- * ```html
- * <ion-list>
- *
- * <ion-list-header>
- * Header
- * </ion-list-header>
- *
- * <ion-item>
- * Item
- * </ion-item>
- *
- * <ion-item detail-push>
- * Item with Detail Arrow
- * </ion-item>
- *
- * <button ion-item (click)="buttonClick()">
- * Button Item
- * </button>
- *
- * <ion-item-divider>
- * Item Divider
- * </ion-item-divider>
- *
- * <button ion-item detail-none (click)="buttonClick()">
- * Button Item with no Detail Arrow
- * </button>
- *
- * <a ion-item href="https://www.ionicframework.com">
- * Anchor Item
- * </a>
- *
- * <ion-item no-lines>
- * Item with no border
- * </ion-item>
- *
- * <ion-item text-wrap>
- * Multiline text that should wrap when it is too long
- * to fit on one line in the item.
- * </ion-item>
- *
- * </ion-list>
- * ```
- *
- *
- * @advanced
- *
- * ```html
- * <ion-list>
- *
- * <!-- List header with buttons on each side -->
- * <ion-list-header>
- * <button ion-button item-start (click)="buttonClick()">Button</button>
- * List Header
- * <button ion-button outline item-end (click)="buttonClick()">Outline</button>
- * </ion-list-header>
- *
- * <!-- Loops through and creates multiple items -->
- * <ion-item *ngFor="let item of items">
- * Item {% raw %}{{item}}{% endraw %}
- * </ion-item>
- *
- * <!-- Button item with an icon on the left -->
- * <button ion-item>
- * <ion-icon name="star" item-start></ion-icon>
- * Button Item
- * </button>
- *
- * <!-- Item with a label and content -->
- * <ion-item>
- * <ion-label>
- * Item Label
- * </ion-label>
- * <div item-content>
- * Item Content next to the label
- * </div>
- * </ion-item>
- *
- * <!-- Item with left and right buttons -->
- * <ion-item>
- * <button ion-button item-start (click)="buttonClick()">Button</button>
- * Item
- * <button ion-button outline item-end (click)="buttonClick()">Outline</button>
- * </ion-item>
- *
- * <!-- Item divider with a right button -->
- * <ion-item-divider>
- * Item Divider
- * <button ion-button item-end>Button</button>
- * </ion-item-divider>
- *
- * <!-- Disabled button item with left and right buttons -->
- * <button ion-item disabled>
- * <button ion-button item-start (click)="buttonClick()">
- * <ion-icon name="home"></ion-icon>
- * Left Icon
- * </button>
- * Disabled Button Item
- * <button ion-button outline item-end (click)="buttonClick()">
- * <ion-icon name="star"></ion-icon>
- * Left Icon
- * </button>
- * </button>
- *
- * <!-- Item with an avatar on the left and button on the right -->
- * <ion-item>
- * <ion-avatar item-start>
- * <img src="img/my-avatar.png">
- * </ion-avatar>
- * Avatar Item
- * <button ion-button outline item-end>View</button>
- * </ion-item>
- *
- * <!-- Item with a thumbnail on the right -->
- * <ion-item>
- * <h2>Item</h2>
- * <p>Item Paragraph</p>
- * <ion-thumbnail item-end>
- * <img src="img/my-thumbnail.png">
- * </ion-thumbnail>
- * </ion-item>
- *
- * <!-- Sliding item -->
- * <ion-item-sliding>
- * <ion-item>
- * Item
- * </ion-item>
- * <ion-item-options>
- * <button ion-button color="primary" (click)="archive()">Archive</button>
- * </ion-item-options>
- * </ion-item-sliding>
- *
- * </ion-list>
- * ```
- *
- *
- * @demo /docs/demos/src/item/
- * @see {@link /docs/components#lists List Component Docs}
- * @see {@link ../../list/List List API Docs}
- * @see {@link ../ItemSliding ItemSliding API Docs}
- */
- var Item = (function (_super) {
- __extends$39(Item, _super);
- function Item(form, config, elementRef, renderer, reorder) {
- var _this = _super.call(this, config, elementRef, renderer, 'item') || this;
- _this._ids = -1;
- _this._inputs = [];
- _this._viewLabel = true;
- _this._name = 'item';
- /**
- * @hidden
- */
- _this.labelId = null;
- _this._setName(elementRef);
- _this._hasReorder = !!reorder;
- _this.id = form.nextId().toString();
- _this.labelId = 'lbl-' + _this.id;
- // auto add "tappable" attribute to ion-item components that have a click listener
- if (!renderer.orgListen) {
- renderer.orgListen = renderer.listen;
- renderer.listen = function (renderElement, name, callback) {
- if (name === 'click' && renderElement.setAttribute) {
- renderElement.setAttribute('tappable', '');
- }
- return renderer.orgListen(renderElement, name, callback);
- };
- }
- return _this;
- }
- /**
- * @hidden
- */
- Item.prototype.registerInput = function (type) {
- this._inputs.push(type);
- return this.id + '-' + (++this._ids);
- };
- /**
- * @hidden
- */
- Item.prototype.ngAfterContentInit = function () {
- if (this._viewLabel && this._inputs.length) {
- var labelText = this.getLabelText().trim();
- this._viewLabel = (labelText.length > 0);
- }
- if (this._inputs.length > 1) {
- this.setElementClass('item-multiple-inputs', true);
- }
- };
- /**
- * @hidden
- */
- Item.prototype._updateColor = function (newColor, componentName) {
- componentName = componentName || 'item'; // item-radio
- this._setColor(newColor, componentName);
- };
- /**
- * @hidden
- */
- Item.prototype._setName = function (elementRef) {
- var nodeName = elementRef.nativeElement.nodeName.replace('ION-', '');
- if (nodeName === 'LIST-HEADER' || nodeName === 'ITEM-DIVIDER') {
- this._name = nodeName;
- }
- };
- /**
- * @hidden
- */
- Item.prototype.getLabelText = function () {
- return this._label ? this._label.text : '';
- };
- Object.defineProperty(Item.prototype, "contentLabel", {
- /**
- * @hidden
- */
- set: function (label) {
- if (label) {
- this._label = label;
- label.id = this.labelId;
- if (label.type) {
- this.setElementClass('item-label-' + label.type, true);
- }
- this._viewLabel = false;
- }
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Item.prototype, "viewLabel", {
- /**
- * @hidden
- */
- set: function (label) {
- if (!this._label) {
- this._label = label;
- }
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Item.prototype, "_buttons", {
- /**
- * @hidden
- */
- set: function (buttons) {
- buttons.forEach(function (button) {
- if (!button._size) {
- button.setElementClass('item-button', true);
- }
- });
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Item.prototype, "_icons", {
- /**
- * @hidden
- */
- set: function (icons) {
- icons.forEach(function (icon) {
- icon.setElementClass('item-icon', true);
- });
- },
- enumerable: true,
- configurable: true
- });
- Item.decorators = [
- { type: Component, args: [{
- selector: 'ion-list-header,ion-item,[ion-item],ion-item-divider',
- template: '<ng-content select="[item-start],[item-left],ion-checkbox:not([item-end]):not([item-right])"></ng-content>' +
- '<div class="item-inner">' +
- '<div class="input-wrapper">' +
- '<ng-content select="ion-label"></ng-content>' +
- '<ion-label *ngIf="_viewLabel">' +
- '<ng-content></ng-content>' +
- '</ion-label>' +
- '<ng-content select="ion-select,ion-input,ion-textarea,ion-datetime,ion-range,[item-content]"></ng-content>' +
- '</div>' +
- '<ng-content select="[item-end],[item-right],ion-radio,ion-toggle"></ng-content>' +
- '<ion-reorder *ngIf="_hasReorder"></ion-reorder>' +
- '</div>' +
- '<div class="button-effect"></div>',
- host: {
- 'class': 'item'
- },
- changeDetection: ChangeDetectionStrategy.OnPush,
- encapsulation: ViewEncapsulation.None,
- },] },
- ];
- /** @nocollapse */
- Item.ctorParameters = function () { return [
- { type: Form, },
- { type: Config, },
- { type: ElementRef, },
- { type: Renderer, },
- { type: ItemReorder, decorators: [{ type: Optional },] },
- ]; };
- Item.propDecorators = {
- 'contentLabel': [{ type: ContentChild, args: [Label,] },],
- 'viewLabel': [{ type: ViewChild, args: [Label,] },],
- '_buttons': [{ type: ContentChildren, args: [Button,] },],
- '_icons': [{ type: ContentChildren, args: [Icon,] },],
- };
- return Item;
- }(Ion));
-
- var __extends$34 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @name Checkbox
- * @module ionic
- *
- * @description
- * The Checkbox is a simple component styled based on the mode. It can be
- * placed in an `ion-item` or used as a stand-alone checkbox.
- *
- * See the [Angular Docs](https://angular.io/docs/ts/latest/guide/forms.html)
- * for more info on forms and inputs.
- *
- *
- * @usage
- * ```html
- *
- * <ion-list>
- *
- * <ion-item>
- * <ion-label>Pepperoni</ion-label>
- * <ion-checkbox [(ngModel)]="pepperoni"></ion-checkbox>
- * </ion-item>
- *
- * <ion-item>
- * <ion-label>Sausage</ion-label>
- * <ion-checkbox [(ngModel)]="sausage" disabled="true"></ion-checkbox>
- * </ion-item>
- *
- * <ion-item>
- * <ion-label>Mushrooms</ion-label>
- * <ion-checkbox [(ngModel)]="mushrooms"></ion-checkbox>
- * </ion-item>
- *
- * </ion-list>
- * ```
- *
- * @advanced
- *
- * ```html
- *
- * <!-- Call function when state changes -->
- * <ion-list>
- *
- * <ion-item>
- * <ion-label>Cucumber</ion-label>
- * <ion-checkbox [(ngModel)]="cucumber" (ionChange)="updateCucumber()"></ion-checkbox>
- * </ion-item>
- *
- * </ion-list>
- * ```
- *
- * ```ts
- * @Component({
- * templateUrl: 'main.html'
- * })
- * class SaladPage {
- * cucumber: boolean;
- *
- * updateCucumber() {
- * console.log('Cucumbers new state:' + this.cucumber);
- * }
- * }
- * ```
- *
- * @demo /docs/demos/src/checkbox/
- * @see {@link /docs/components#checkbox Checkbox Component Docs}
- */
- var Checkbox = (function (_super) {
- __extends$34(Checkbox, _super);
- function Checkbox(config, form, item, elementRef, renderer) {
- return _super.call(this, config, elementRef, renderer, 'checkbox', false, form, item, null) || this;
- }
- Object.defineProperty(Checkbox.prototype, "checked", {
- /**
- * @input {boolean} If true, the element is selected.
- */
- get: function () {
- return this.value;
- },
- set: function (val) {
- this.value = val;
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @hidden
- */
- Checkbox.prototype._click = function (ev) {
- ev.preventDefault();
- ev.stopPropagation();
- this.value = !this.value;
- this._fireTouched();
- };
- /**
- * @hidden
- */
- Checkbox.prototype._inputNormalize = function (val) {
- return isTrueProperty(val);
- };
- /**
- * @hidden
- */
- Checkbox.prototype._inputUpdated = function () {
- this._item && this._item.setElementClass('item-checkbox-checked', this._value);
- };
- Checkbox.decorators = [
- { type: Component, args: [{
- selector: 'ion-checkbox',
- template: '<div class="checkbox-icon" [class.checkbox-checked]="_value">' +
- '<div class="checkbox-inner"></div>' +
- '</div>' +
- '<button role="checkbox" ' +
- 'type="button" ' +
- 'ion-button="item-cover" ' +
- '[id]="id" ' +
- '[attr.aria-checked]="_value" ' +
- '[attr.aria-labelledby]="_labelId" ' +
- '[attr.aria-disabled]="_disabled" ' +
- 'class="item-cover"> ' +
- '</button>',
- host: {
- '[class.checkbox-disabled]': '_disabled'
- },
- providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: Checkbox, multi: true }],
- encapsulation: ViewEncapsulation.None,
- },] },
- ];
- /** @nocollapse */
- Checkbox.ctorParameters = function () { return [
- { type: Config, },
- { type: Form, },
- { type: Item, decorators: [{ type: Optional },] },
- { type: ElementRef, },
- { type: Renderer, },
- ]; };
- Checkbox.propDecorators = {
- 'checked': [{ type: Input },],
- '_click': [{ type: HostListener, args: ['click', ['$event'],] },],
- };
- return Checkbox;
- }(BaseInput));
-
- var __extends$43 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @name Chip
- * @module ionic
- * @description
- * Chips represent complex entities in small blocks, such as a contact.
- *
- *
- * @usage
- *
- * ```html
- * <ion-chip>
- * <ion-label>Default</ion-label>
- * </ion-chip>
- *
- * <ion-chip>
- * <ion-label color="secondary">Secondary Label</ion-label>
- * </ion-chip>
- *
- * <ion-chip color="secondary">
- * <ion-label color="dark">Secondary w/ Dark label</ion-label>
- * </ion-chip>
- *
- * <ion-chip color="danger">
- * <ion-label>Danger</ion-label>
- * </ion-chip>
- *
- * <ion-chip>
- * <ion-icon name="pin"></ion-icon>
- * <ion-label>Default</ion-label>
- * </ion-chip>
- *
- * <ion-chip>
- * <ion-icon name="heart" color="dark"></ion-icon>
- * <ion-label>Default</ion-label>
- * </ion-chip>
- *
- * <ion-chip>
- * <ion-avatar>
- * <img src="assets/img/my-img.png">
- * </ion-avatar>
- * <ion-label>Default</ion-label>
- * </ion-chip>
- * ```
- *
- *
- * @advanced
- *
- * ```html
- * <ion-chip #chip1>
- * <ion-label>Default</ion-label>
- * <button ion-button clear color="light" (click)="delete(chip1)">
- * <ion-icon name="close-circle"></ion-icon>
- * </button>
- * </ion-chip>
- *
- * <ion-chip #chip2>
- * <ion-icon name="pin" color="primary"></ion-icon>
- * <ion-label>With Icon</ion-label>
- * <button ion-button (click)="delete(chip2)">
- * <ion-icon name="close"></ion-icon>
- * </button>
- * </ion-chip>
- *
- * <ion-chip #chip3>
- * <ion-avatar>
- * <img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAAAAACH5BAAAAAAALAAAAAABAAEAAAICTAEAOw==">
- * </ion-avatar>
- * <ion-label>With Avatar</ion-label>
- * <button ion-button clear color="dark" (click)="delete(chip3)">
- * <ion-icon name="close-circle"></ion-icon>
- * </button>
- * </ion-chip>
- * ```
- *
- * ```ts
- * @Component({
- * templateUrl: 'main.html'
- * })
- * class E2EPage {
- * delete(chip: Element) {
- * chip.remove();
- * }
- * }
- * ```
- *
- * @demo /docs/demos/src/chip/
- **/
- var Chip = (function (_super) {
- __extends$43(Chip, _super);
- function Chip(config, elementRef, renderer) {
- return _super.call(this, config, elementRef, renderer, 'chip') || this;
- }
- Chip.decorators = [
- { type: Directive, args: [{
- selector: 'ion-chip'
- },] },
- ];
- /** @nocollapse */
- Chip.ctorParameters = function () { return [
- { type: Config, },
- { type: ElementRef, },
- { type: Renderer, },
- ]; };
- return Chip;
- }(Ion));
-
- /**
- * @name Haptic
- * @description
- * The `Haptic` class interacts with a haptic engine on the device, if
- * available. Generally, Ionic components use this under the hood, but you're
- * welcome to get a bit crazy with it if you fancy.
- *
- * Currently, this uses the Taptic engine on iOS.
- *
- * @usage
- * ```ts
- * export class MyClass {
- *
- * constructor(haptic: Haptic) {
- * haptic.selection();
- * }
- * }
- *
- * ```
- */
- var Haptic = (function () {
- function Haptic(plt) {
- var _this = this;
- if (plt) {
- plt.ready().then(function () {
- _this._p = plt.win().TapticEngine;
- });
- }
- }
- /**
- * Check to see if the Haptic Plugin is available
- * @return {boolean} Returns true or false if the plugin is available
- *
- */
- Haptic.prototype.available = function () {
- return !!this._p;
- };
- /**
- * Trigger a selection changed haptic event. Good for one-time events
- * (not for gestures)
- */
- Haptic.prototype.selection = function () {
- this._p && this._p.selection();
- };
- /**
- * Tell the haptic engine that a gesture for a selection change is starting.
- */
- Haptic.prototype.gestureSelectionStart = function () {
- this._p && this._p.gestureSelectionStart();
- };
- /**
- * Tell the haptic engine that a selection changed during a gesture.
- */
- Haptic.prototype.gestureSelectionChanged = function () {
- this._p && this._p.gestureSelectionChanged();
- };
- /**
- * Tell the haptic engine we are done with a gesture. This needs to be
- * called lest resources are not properly recycled.
- */
- Haptic.prototype.gestureSelectionEnd = function () {
- this._p && this._p.gestureSelectionEnd();
- };
- /**
- * Use this to indicate success/failure/warning to the user.
- * options should be of the type `{ type: 'success' }` (or `warning`/`error`)
- */
- Haptic.prototype.notification = function (options) {
- this._p && this._p.notification(options);
- };
- /**
- * Use this to indicate success/failure/warning to the user.
- * options should be of the type `{ style: 'light' }` (or `medium`/`heavy`)
- */
- Haptic.prototype.impact = function (options) {
- this._p && this._p.impact(options);
- };
- Haptic.decorators = [
- { type: Injectable },
- ];
- /** @nocollapse */
- Haptic.ctorParameters = function () { return [
- { type: Platform, },
- ]; };
- return Haptic;
- }());
-
- var PICKER_OPT_SELECTED = 'picker-opt-selected';
- var DECELERATION_FRICTION$1 = 0.97;
- var FRAME_MS$1 = (1000 / 60);
- var MAX_PICKER_SPEED = 60;
-
- /**
- * @hidden
- */
- var PickerColumnCmp = (function () {
- function PickerColumnCmp(config, _plt, elementRef, _zone, _haptic, plt, domCtrl) {
- this._plt = _plt;
- this.elementRef = elementRef;
- this._zone = _zone;
- this._haptic = _haptic;
- this.y = 0;
- this.pos = [];
- this.startY = null;
- this.ionChange = new EventEmitter();
- this.events = new UIEventManager(plt);
- this.rotateFactor = config.getNumber('pickerRotateFactor', 0);
- this.scaleFactor = config.getNumber('pickerScaleFactor', 1);
- this.decelerateFunc = this.decelerate.bind(this);
- this.debouncer = domCtrl.debouncer();
- }
- PickerColumnCmp.prototype.ngAfterViewInit = function () {
- // get the scrollable element within the column
- var colEle = this.colEle.nativeElement;
- this.colHeight = colEle.clientHeight;
- // get the height of one option
- this.optHeight = (colEle.firstElementChild ? colEle.firstElementChild.clientHeight : 0);
- // Listening for pointer events
- this.events.pointerEvents({
- element: this.elementRef.nativeElement,
- pointerDown: this.pointerStart.bind(this),
- pointerMove: this.pointerMove.bind(this),
- pointerUp: this.pointerEnd.bind(this),
- capture: true,
- zone: false
- });
- };
- PickerColumnCmp.prototype.ngOnDestroy = function () {
- this._plt.cancelRaf(this.rafId);
- this.events.destroy();
- };
- PickerColumnCmp.prototype.pointerStart = function (ev) {
- (void 0) /* console.debug */;
- this._haptic.gestureSelectionStart();
- // We have to prevent default in order to block scrolling under the picker
- // but we DO NOT have to stop propagation, since we still want
- // some "click" events to capture
- ev.preventDefault();
- // cancel any previous raf's that haven't fired yet
- this._plt.cancelRaf(this.rafId);
- // remember where the pointer started from`
- this.startY = pointerCoord(ev).y;
- // reset everything
- this.velocity = 0;
- this.pos.length = 0;
- this.pos.push(this.startY, Date.now());
- var options = this.col.options;
- var minY = (options.length - 1);
- var maxY = 0;
- for (var i = 0; i < options.length; i++) {
- if (!options[i].disabled) {
- minY = Math.min(minY, i);
- maxY = Math.max(maxY, i);
- }
- }
- this.minY = (minY * this.optHeight * -1);
- this.maxY = (maxY * this.optHeight * -1);
- return true;
- };
- PickerColumnCmp.prototype.pointerMove = function (ev) {
- var _this = this;
- ev.preventDefault();
- ev.stopPropagation();
- var currentY = pointerCoord(ev).y;
- this.pos.push(currentY, Date.now());
- this.debouncer.write(function () {
- if (_this.startY === null) {
- return;
- }
- // update the scroll position relative to pointer start position
- var y = _this.y + (currentY - _this.startY);
- if (y > _this.minY) {
- // scrolling up higher than scroll area
- y = Math.pow(y, 0.8);
- _this.bounceFrom = y;
- }
- else if (y < _this.maxY) {
- // scrolling down below scroll area
- y += Math.pow(_this.maxY - y, 0.9);
- _this.bounceFrom = y;
- }
- else {
- _this.bounceFrom = 0;
- }
- _this.update(y, 0, false, false);
- var currentIndex = Math.max(Math.abs(Math.round(y / _this.optHeight)), 0);
- if (currentIndex !== _this.lastTempIndex) {
- // Trigger a haptic event for physical feedback that the index has changed
- _this._haptic.gestureSelectionChanged();
- _this.lastTempIndex = currentIndex;
- }
- });
- };
- PickerColumnCmp.prototype.pointerEnd = function (ev) {
- ev.preventDefault();
- this.debouncer.cancel();
- if (this.startY === null) {
- return;
- }
- (void 0) /* console.debug */;
- this.velocity = 0;
- if (this.bounceFrom > 0) {
- // bounce back up
- this.update(this.minY, 100, true, true);
- return;
- }
- else if (this.bounceFrom < 0) {
- // bounce back down
- this.update(this.maxY, 100, true, true);
- return;
- }
- var endY = pointerCoord(ev).y;
- this.pos.push(endY, Date.now());
- var endPos = (this.pos.length - 1);
- var startPos = endPos;
- var timeRange = (Date.now() - 100);
- // move pointer to position measured 100ms ago
- for (var i = endPos; i > 0 && this.pos[i] > timeRange; i -= 2) {
- startPos = i;
- }
- if (startPos !== endPos) {
- // compute relative movement between these two points
- var timeOffset = (this.pos[endPos] - this.pos[startPos]);
- var movedTop = (this.pos[startPos - 1] - this.pos[endPos - 1]);
- // based on XXms compute the movement to apply for each render step
- var velocity = ((movedTop / timeOffset) * FRAME_MS$1);
- this.velocity = clamp(-MAX_PICKER_SPEED, velocity, MAX_PICKER_SPEED);
- }
- if (Math.abs(endY - this.startY) > 3) {
- var y = this.y + (endY - this.startY);
- this.update(y, 0, true, true);
- }
- this.startY = null;
- this.decelerate();
- };
- PickerColumnCmp.prototype.decelerate = function () {
- var y = 0;
- if (isNaN(this.y) || !this.optHeight) {
- // fallback in case numbers get outta wack
- this.update(y, 0, true, true);
- this._haptic.gestureSelectionEnd();
- }
- else if (Math.abs(this.velocity) > 0) {
- // still decelerating
- this.velocity *= DECELERATION_FRICTION$1;
- // do not let it go slower than a velocity of 1
- this.velocity = (this.velocity > 0)
- ? Math.max(this.velocity, 1)
- : Math.min(this.velocity, -1);
- y = Math.round(this.y - this.velocity);
- if (y > this.minY) {
- // whoops, it's trying to scroll up farther than the options we have!
- y = this.minY;
- this.velocity = 0;
- }
- else if (y < this.maxY) {
- // gahh, it's trying to scroll down farther than we can!
- y = this.maxY;
- this.velocity = 0;
- }
- var notLockedIn = (y % this.optHeight !== 0 || Math.abs(this.velocity) > 1);
- this.update(y, 0, true, !notLockedIn);
- if (notLockedIn) {
- // isn't locked in yet, keep decelerating until it is
- this.rafId = this._plt.raf(this.decelerateFunc);
- }
- }
- else if (this.y % this.optHeight !== 0) {
- // needs to still get locked into a position so options line up
- var currentPos = Math.abs(this.y % this.optHeight);
- // create a velocity in the direction it needs to scroll
- this.velocity = (currentPos > (this.optHeight / 2) ? 1 : -1);
- this._haptic.gestureSelectionEnd();
- this.decelerate();
- }
- var currentIndex = Math.max(Math.abs(Math.round(y / this.optHeight)), 0);
- if (currentIndex !== this.lastTempIndex) {
- // Trigger a haptic event for physical feedback that the index has changed
- this._haptic.gestureSelectionChanged();
- }
- this.lastTempIndex = currentIndex;
- };
- PickerColumnCmp.prototype.optClick = function (ev, index) {
- if (!this.velocity) {
- ev.preventDefault();
- ev.stopPropagation();
- this.setSelected(index, 150);
- }
- };
- PickerColumnCmp.prototype.setSelected = function (selectedIndex, duration) {
- // if there is a selected index, then figure out it's y position
- // if there isn't a selected index, then just use the top y position
- var y = (selectedIndex > -1) ? ((selectedIndex * this.optHeight) * -1) : 0;
- this._plt.cancelRaf(this.rafId);
- this.velocity = 0;
- // so what y position we're at
- this.update(y, duration, true, true);
- };
- PickerColumnCmp.prototype.update = function (y, duration, saveY, emitChange) {
- // ensure we've got a good round number :)
- y = Math.round(y);
- var i;
- var button;
- var opt;
- var optOffset;
- var visible;
- var translateX;
- var translateY;
- var translateZ;
- var rotateX;
- var transform;
- var selected;
- var parent = this.colEle.nativeElement;
- var children = parent.children;
- var length = children.length;
- var selectedIndex = this.col.selectedIndex = Math.min(Math.max(Math.round(-y / this.optHeight), 0), length - 1);
- var durationStr = (duration === 0) ? null : duration + 'ms';
- var scaleStr = "scale(" + this.scaleFactor + ")";
- for (i = 0; i < length; i++) {
- button = children[i];
- opt = this.col.options[i];
- optOffset = (i * this.optHeight) + y;
- visible = true;
- transform = '';
- if (this.rotateFactor !== 0) {
- rotateX = optOffset * this.rotateFactor;
- if (Math.abs(rotateX) > 90) {
- visible = false;
- }
- else {
- translateX = 0;
- translateY = 0;
- translateZ = 90;
- transform = "rotateX(" + rotateX + "deg) ";
- }
- }
- else {
- translateX = 0;
- translateZ = 0;
- translateY = optOffset;
- if (Math.abs(translateY) > 170) {
- visible = false;
- }
- }
- selected = selectedIndex === i;
- if (visible) {
- transform += "translate3d(0px," + translateY + "px," + translateZ + "px) ";
- if (this.scaleFactor !== 1 && !selected) {
- transform += scaleStr;
- }
- }
- else {
- transform = 'translate3d(-9999px,0px,0px)';
- }
- // Update transition duration
- if (duration !== opt._dur) {
- opt._dur = duration;
- button.style[this._plt.Css.transitionDuration] = durationStr;
- }
- // Update transform
- if (transform !== opt._trans) {
- opt._trans = transform;
- button.style[this._plt.Css.transform] = transform;
- }
- // Update selected item
- if (selected !== opt._selected) {
- opt._selected = selected;
- if (selected) {
- button.classList.add(PICKER_OPT_SELECTED);
- }
- else {
- button.classList.remove(PICKER_OPT_SELECTED);
- }
- }
- }
- this.col.prevSelected = selectedIndex;
- if (saveY) {
- this.y = y;
- }
- if (emitChange) {
- if (this.lastIndex === undefined) {
- // have not set a last index yet
- this.lastIndex = this.col.selectedIndex;
- }
- else if (this.lastIndex !== this.col.selectedIndex) {
- // new selected index has changed from the last index
- // update the lastIndex and emit that it has changed
- this.lastIndex = this.col.selectedIndex;
- var ionChange = this.ionChange;
- if (ionChange.observers.length > 0) {
- this._zone.run(ionChange.emit.bind(ionChange, this.col.options[this.col.selectedIndex]));
- }
- }
- }
- };
- PickerColumnCmp.prototype.refresh = function () {
- var min = this.col.options.length - 1;
- var max = 0;
- var options = this.col.options;
- for (var i = 0; i < options.length; i++) {
- if (!options[i].disabled) {
- min = Math.min(min, i);
- max = Math.max(max, i);
- }
- }
- var selectedIndex = clamp(min, this.col.selectedIndex, max);
- if (this.col.prevSelected !== selectedIndex) {
- var y = (selectedIndex * this.optHeight) * -1;
- this._plt.cancelRaf(this.rafId);
- this.velocity = 0;
- this.update(y, 150, true, false);
- }
- };
- PickerColumnCmp.decorators = [
- { type: Component, args: [{
- selector: '.picker-col',
- template: '<div *ngIf="col.prefix" class="picker-prefix" [style.width]="col.prefixWidth">{{col.prefix}}</div>' +
- '<div class="picker-opts" #colEle [style.max-width]="col.optionsWidth">' +
- '<button *ngFor="let o of col.options; let i=index"' +
- '[class.picker-opt-disabled]="o.disabled" ' +
- 'class="picker-opt" disable-activated (click)="optClick($event, i)">' +
- '{{o.text}}' +
- '</button>' +
- '</div>' +
- '<div *ngIf="col.suffix" class="picker-suffix" [style.width]="col.suffixWidth">{{col.suffix}}</div>',
- host: {
- '[style.max-width]': 'col.columnWidth',
- '[class.picker-opts-left]': 'col.align=="left"',
- '[class.picker-opts-right]': 'col.align=="right"',
- }
- },] },
- ];
- /** @nocollapse */
- PickerColumnCmp.ctorParameters = function () { return [
- { type: Config, },
- { type: Platform, },
- { type: ElementRef, },
- { type: NgZone, },
- { type: Haptic, },
- { type: Platform, },
- { type: DomController, },
- ]; };
- PickerColumnCmp.propDecorators = {
- 'colEle': [{ type: ViewChild, args: ['colEle',] },],
- 'col': [{ type: Input },],
- 'ionChange': [{ type: Output },],
- };
- return PickerColumnCmp;
- }());
-
- /**
- * @hidden
- */
- var PickerCmp = (function () {
- function PickerCmp(_viewCtrl, _elementRef, config, gestureCtrl, params, renderer) {
- this._viewCtrl = _viewCtrl;
- this._elementRef = _elementRef;
- this._gestureBlocker = gestureCtrl.createBlocker(BLOCK_ALL);
- this.d = params.data;
- this.mode = config.get('mode');
- renderer.setElementClass(_elementRef.nativeElement, "picker-" + this.mode, true);
- if (this.d.cssClass) {
- this.d.cssClass.split(' ').forEach(function (cssClass) {
- renderer.setElementClass(_elementRef.nativeElement, cssClass, true);
- });
- }
- this.id = (++pickerIds);
- this.lastClick = 0;
- }
- PickerCmp.prototype.ionViewWillLoad = function () {
- // normalize the data
- var data = this.d;
- data.buttons = data.buttons.map(function (button) {
- if (isString(button)) {
- return { text: button };
- }
- if (button.role) {
- button.cssRole = "picker-toolbar-" + button.role;
- }
- return button;
- });
- // clean up dat data
- data.columns = data.columns.map(function (column) {
- if (!isPresent(column.options)) {
- column.options = [];
- }
- column.selectedIndex = column.selectedIndex || 0;
- column.options = column.options.map(function (inputOpt) {
- var opt = {
- text: '',
- value: '',
- disabled: inputOpt.disabled,
- };
- if (isPresent(inputOpt)) {
- if (isString(inputOpt) || isNumber(inputOpt)) {
- opt.text = inputOpt.toString();
- opt.value = inputOpt;
- }
- else {
- opt.text = isPresent(inputOpt.text) ? inputOpt.text : inputOpt.value;
- opt.value = isPresent(inputOpt.value) ? inputOpt.value : inputOpt.text;
- }
- }
- return opt;
- });
- return column;
- });
- };
- PickerCmp.prototype.ionViewDidLoad = function () {
- this.refresh();
- };
- PickerCmp.prototype.ionViewWillEnter = function () {
- this._gestureBlocker.block();
- };
- PickerCmp.prototype.ionViewDidLeave = function () {
- this._gestureBlocker.unblock();
- };
- PickerCmp.prototype.refresh = function () {
- this._cols.forEach(function (column) { return column.refresh(); });
- };
- PickerCmp.prototype._colChange = function () {
- // one of the columns has changed its selected index
- var picker = this._viewCtrl;
- picker.ionChange.emit(this.getSelected());
- };
- PickerCmp.prototype._keyUp = function (ev) {
- if (this.enabled && this._viewCtrl.isLast()) {
- if (ev.keyCode === KEY_ENTER) {
- if (this.lastClick + 1000 < Date.now()) {
- // do not fire this click if there recently was already a click
- // this can happen when the button has focus and used the enter
- // key to click the button. However, both the click handler and
- // this keyup event will fire, so only allow one of them to go.
- (void 0) /* console.debug */;
- var button = this.d.buttons[this.d.buttons.length - 1];
- this.btnClick(button);
- }
- }
- else if (ev.keyCode === KEY_ESCAPE) {
- (void 0) /* console.debug */;
- this.bdClick();
- }
- }
- };
- PickerCmp.prototype.ionViewDidEnter = function () {
- var focusableEle = this._elementRef.nativeElement.querySelector('button');
- if (focusableEle) {
- focusableEle.focus();
- }
- this.enabled = true;
- };
- PickerCmp.prototype.btnClick = function (button) {
- if (!this.enabled) {
- return;
- }
- // keep the time of the most recent button click
- this.lastClick = Date.now();
- var shouldDismiss = true;
- if (button.handler) {
- // a handler has been provided, execute it
- // pass the handler the values from the inputs
- if (button.handler(this.getSelected()) === false) {
- // if the return value of the handler is false then do not dismiss
- shouldDismiss = false;
- }
- }
- if (shouldDismiss) {
- this.dismiss(button.role);
- }
- };
- PickerCmp.prototype.bdClick = function () {
- if (this.enabled && this.d.enableBackdropDismiss) {
- var cancelBtn = this.d.buttons.find(function (b) { return b.role === 'cancel'; });
- if (cancelBtn) {
- this.btnClick(cancelBtn);
- }
- else {
- this.dismiss('backdrop');
- }
- }
- };
- PickerCmp.prototype.dismiss = function (role) {
- return this._viewCtrl.dismiss(this.getSelected(), role);
- };
- PickerCmp.prototype.getSelected = function () {
- var selected = {};
- this.d.columns.forEach(function (col, index) {
- var selectedColumn = col.options[col.selectedIndex];
- selected[col.name] = {
- text: selectedColumn ? selectedColumn.text : null,
- value: selectedColumn ? selectedColumn.value : null,
- columnIndex: index,
- };
- });
- return selected;
- };
- PickerCmp.prototype.ngOnDestroy = function () {
- (void 0) /* assert */;
- this._gestureBlocker.destroy();
- };
- PickerCmp.decorators = [
- { type: Component, args: [{
- selector: 'ion-picker-cmp',
- template: "\n <ion-backdrop (click)=\"bdClick()\"></ion-backdrop>\n <div class=\"picker-wrapper\">\n <div class=\"picker-toolbar\">\n <div *ngFor=\"let b of d.buttons\" class=\"picker-toolbar-button\" [ngClass]=\"b.cssRole\">\n <button ion-button (click)=\"btnClick(b)\" [ngClass]=\"b.cssClass\" class=\"picker-button\" clear>\n {{b.text}}\n </button>\n </div>\n </div>\n <div class=\"picker-columns\">\n <div class=\"picker-above-highlight\"></div>\n <div *ngFor=\"let c of d.columns\" [col]=\"c\" class=\"picker-col\" (ionChange)=\"_colChange($event)\"></div>\n <div class=\"picker-below-highlight\"></div>\n </div>\n </div>\n ",
- host: {
- 'role': 'dialog'
- },
- encapsulation: ViewEncapsulation.None,
- },] },
- ];
- /** @nocollapse */
- PickerCmp.ctorParameters = function () { return [
- { type: ViewController, },
- { type: ElementRef, },
- { type: Config, },
- { type: GestureController, },
- { type: NavParams, },
- { type: Renderer, },
- ]; };
- PickerCmp.propDecorators = {
- '_cols': [{ type: ViewChildren, args: [PickerColumnCmp,] },],
- '_keyUp': [{ type: HostListener, args: ['body:keyup', ['$event'],] },],
- };
- return PickerCmp;
- }());
- var pickerIds = -1;
-
- var __extends$46 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * Animations for pickers
- */
- var PickerSlideIn = (function (_super) {
- __extends$46(PickerSlideIn, _super);
- function PickerSlideIn() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- PickerSlideIn.prototype.init = function () {
- var ele = this.enteringView.pageRef().nativeElement;
- var backdrop = new Animation(this.plt, ele.querySelector('ion-backdrop'));
- var wrapper = new Animation(this.plt, ele.querySelector('.picker-wrapper'));
- backdrop.fromTo('opacity', 0.01, 0.26);
- wrapper.fromTo('translateY', '100%', '0%');
- this.easing('cubic-bezier(.36,.66,.04,1)').duration(400).add(backdrop).add(wrapper);
- };
- return PickerSlideIn;
- }(Transition));
- var PickerSlideOut = (function (_super) {
- __extends$46(PickerSlideOut, _super);
- function PickerSlideOut() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- PickerSlideOut.prototype.init = function () {
- var ele = this.leavingView.pageRef().nativeElement;
- var backdrop = new Animation(this.plt, ele.querySelector('ion-backdrop'));
- var wrapper = new Animation(this.plt, ele.querySelector('.picker-wrapper'));
- backdrop.fromTo('opacity', 0.26, 0);
- wrapper.fromTo('translateY', '0%', '100%');
- this.easing('cubic-bezier(.36,.66,.04,1)').duration(450).add(backdrop).add(wrapper);
- };
- return PickerSlideOut;
- }(Transition));
-
- var __extends$45 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @hidden
- */
- var Picker = (function (_super) {
- __extends$45(Picker, _super);
- function Picker(app, opts, config) {
- if (opts === void 0) { opts = {}; }
- var _this = this;
- if (!opts) {
- opts = {};
- }
- opts.columns = opts.columns || [];
- opts.buttons = opts.buttons || [];
- opts.enableBackdropDismiss = isPresent(opts.enableBackdropDismiss) ? Boolean(opts.enableBackdropDismiss) : true;
- _this = _super.call(this, PickerCmp, opts, null) || this;
- _this._app = app;
- _this.isOverlay = true;
- _this.ionChange = new EventEmitter();
- config.setTransition('picker-slide-in', PickerSlideIn);
- config.setTransition('picker-slide-out', PickerSlideOut);
- return _this;
- }
- /**
- * @hidden
- */
- Picker.prototype.getTransitionName = function (direction) {
- var key = (direction === 'back' ? 'pickerLeave' : 'pickerEnter');
- return this._nav && this._nav.config.get(key);
- };
- /**
- * @param {any} button Picker toolbar button
- */
- Picker.prototype.addButton = function (button) {
- this.data.buttons.push(button);
- };
- /**
- * @param {PickerColumn} column Picker toolbar button
- */
- Picker.prototype.addColumn = function (column) {
- this.data.columns.push(column);
- };
- Picker.prototype.getColumns = function () {
- return this.data.columns;
- };
- Picker.prototype.getColumn = function (name) {
- return this.getColumns().find(function (column) { return column.name === name; });
- };
- Picker.prototype.refresh = function () {
- (void 0) /* assert */;
- (void 0) /* assert */;
- this._cmp && this._cmp.instance.refresh && this._cmp.instance.refresh();
- };
- /**
- * @param {string} cssClass CSS class name to add to the picker's outer wrapper.
- */
- Picker.prototype.setCssClass = function (cssClass) {
- this.data.cssClass = cssClass;
- };
- /**
- * Present the picker instance.
- *
- * @param {NavOptions} [navOptions={}] Nav options to go with this transition.
- * @returns {Promise} Returns a promise which is resolved when the transition has completed.
- */
- Picker.prototype.present = function (navOptions) {
- if (navOptions === void 0) { navOptions = {}; }
- return this._app.present(this, navOptions);
- };
- Picker.propDecorators = {
- 'ionChange': [{ type: Output },],
- };
- return Picker;
- }(ViewController));
-
- /**
- * @hidden
- * @name PickerController
- * @description
- *
- */
- var PickerController = (function () {
- function PickerController(_app, config) {
- this._app = _app;
- this.config = config;
- }
- /**
- * Open a picker.
- */
- PickerController.prototype.create = function (opts) {
- if (opts === void 0) { opts = {}; }
- return new Picker(this._app, opts, this.config);
- };
- PickerController.decorators = [
- { type: Injectable },
- ];
- /** @nocollapse */
- PickerController.ctorParameters = function () { return [
- { type: App, },
- { type: Config, },
- ]; };
- return PickerController;
- }());
-
- function renderDateTime(template, value, locale) {
- if (isBlank$1(value)) {
- return '';
- }
- var tokens = [];
- var hasText = false;
- FORMAT_KEYS.forEach(function (format, index) {
- if (template.indexOf(format.f) > -1) {
- var token = '{' + index + '}';
- var text = renderTextFormat(format.f, value[format.k], value, locale);
- if (!hasText && text && isPresent(value[format.k])) {
- hasText = true;
- }
- tokens.push(token, text);
- template = template.replace(format.f, token);
- }
- });
- if (!hasText) {
- return '';
- }
- for (var i = 0; i < tokens.length; i += 2) {
- template = template.replace(tokens[i], tokens[i + 1]);
- }
- return template;
- }
- function renderTextFormat(format, value, date, locale) {
- if (format === FORMAT_DDDD || format === FORMAT_DDD) {
- try {
- value = (new Date(date.year, date.month - 1, date.day)).getDay();
- if (format === FORMAT_DDDD) {
- return (isPresent(locale.dayNames) ? locale.dayNames : DAY_NAMES)[value];
- }
- return (isPresent(locale.dayShortNames) ? locale.dayShortNames : DAY_SHORT_NAMES)[value];
- }
- catch (e) { }
- return '';
- }
- if (format === FORMAT_A) {
- return date ? date.hour < 12 ? 'AM' : 'PM' : isPresent(value) ? value.toUpperCase() : '';
- }
- if (format === FORMAT_a) {
- return date ? date.hour < 12 ? 'am' : 'pm' : isPresent(value) ? value : '';
- }
- if (isBlank$1(value)) {
- return '';
- }
- if (format === FORMAT_YY || format === FORMAT_MM ||
- format === FORMAT_DD || format === FORMAT_HH ||
- format === FORMAT_mm || format === FORMAT_ss) {
- return twoDigit(value);
- }
- if (format === FORMAT_YYYY) {
- return fourDigit(value);
- }
- if (format === FORMAT_MMMM) {
- return (isPresent(locale.monthNames) ? locale.monthNames : MONTH_NAMES)[value - 1];
- }
- if (format === FORMAT_MMM) {
- return (isPresent(locale.monthShortNames) ? locale.monthShortNames : MONTH_SHORT_NAMES)[value - 1];
- }
- if (format === FORMAT_hh || format === FORMAT_h) {
- if (value === 0) {
- return '12';
- }
- if (value > 12) {
- value -= 12;
- }
- if (format === FORMAT_hh && value < 10) {
- return ('0' + value);
- }
- }
- return value.toString();
- }
- function dateValueRange(format, min, max) {
- var opts = [];
- var i;
- if (format === FORMAT_YYYY || format === FORMAT_YY) {
- // year
- i = max.year;
- while (i >= min.year) {
- opts.push(i--);
- }
- }
- else if (format === FORMAT_MMMM || format === FORMAT_MMM ||
- format === FORMAT_MM || format === FORMAT_M ||
- format === FORMAT_hh || format === FORMAT_h) {
- // month or 12-hour
- for (i = 1; i < 13; i++) {
- opts.push(i);
- }
- }
- else if (format === FORMAT_DDDD || format === FORMAT_DDD ||
- format === FORMAT_DD || format === FORMAT_D) {
- // day
- for (i = 1; i < 32; i++) {
- opts.push(i);
- }
- }
- else if (format === FORMAT_HH || format === FORMAT_H) {
- // 24-hour
- for (i = 0; i < 24; i++) {
- opts.push(i);
- }
- }
- else if (format === FORMAT_mm || format === FORMAT_m) {
- // minutes
- for (i = 0; i < 60; i++) {
- opts.push(i);
- }
- }
- else if (format === FORMAT_ss || format === FORMAT_s) {
- // seconds
- for (i = 0; i < 60; i++) {
- opts.push(i);
- }
- }
- else if (format === FORMAT_A || format === FORMAT_a) {
- // AM/PM
- opts.push('am', 'pm');
- }
- return opts;
- }
- function dateSortValue(year, month, day, hour, minute) {
- if (hour === void 0) { hour = 0; }
- if (minute === void 0) { minute = 0; }
- return parseInt("1" + fourDigit(year) + twoDigit(month) + twoDigit(day) + twoDigit(hour) + twoDigit(minute), 10);
- }
- function dateDataSortValue(data) {
- if (data) {
- return dateSortValue(data.year, data.month, data.day, data.hour, data.minute);
- }
- return -1;
- }
- function daysInMonth(month, year) {
- return (month === 4 || month === 6 || month === 9 || month === 11) ? 30 : (month === 2) ? isLeapYear(year) ? 29 : 28 : 31;
- }
- function isLeapYear(year) {
- return (year % 4 === 0 && year % 100 !== 0) || (year % 400 === 0);
- }
- var ISO_8601_REGEXP = /^(\d{4}|[+\-]\d{6})(?:-(\d{2})(?:-(\d{2}))?)?(?:T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{3}))?)?(?:(Z)|([+\-])(\d{2})(?::(\d{2}))?)?)?$/;
- var TIME_REGEXP = /^((\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{3}))?)?(?:(Z)|([+\-])(\d{2})(?::(\d{2}))?)?)?$/;
- function parseDate(val) {
- // manually parse IS0 cuz Date.parse cannot be trusted
- // ISO 8601 format: 1994-12-15T13:47:20Z
- var parse;
- if (isPresent(val) && val !== '') {
- // try parsing for just time first, HH:MM
- parse = TIME_REGEXP.exec(val);
- if (isPresent(parse)) {
- // adjust the array so it fits nicely with the datetime parse
- parse.unshift(undefined, undefined);
- parse[2] = parse[3] = undefined;
- }
- else {
- // try parsing for full ISO datetime
- parse = ISO_8601_REGEXP.exec(val);
- }
- }
- if (isBlank$1(parse)) {
- // wasn't able to parse the ISO datetime
- return null;
- }
- // ensure all the parse values exist with at least 0
- for (var i = 1; i < 8; i++) {
- parse[i] = (parse[i] !== undefined ? parseInt(parse[i], 10) : null);
- }
- var tzOffset = 0;
- if (isPresent(parse[9]) && isPresent(parse[10])) {
- // hours
- tzOffset = parseInt(parse[10], 10) * 60;
- if (isPresent(parse[11])) {
- // minutes
- tzOffset += parseInt(parse[11], 10);
- }
- if (parse[9] === '-') {
- // + or -
- tzOffset *= -1;
- }
- }
- return {
- year: parse[1],
- month: parse[2],
- day: parse[3],
- hour: parse[4],
- minute: parse[5],
- second: parse[6],
- millisecond: parse[7],
- tzOffset: tzOffset,
- };
- }
- function compareDates(d1, d2) {
- var date1 = new Date(d1.year, d1.month, d1.day, d1.hour, d1.minute, d1.second);
- var date2 = new Date(d2.year, d2.month, d2.day, d2.hour, d2.minute, d2.second);
- return date1.getTime() - date2.getTime();
- }
- function updateDate(existingData, newData) {
- if (isPresent(newData) && newData !== '') {
- if (isString(newData)) {
- // new date is a string, and hopefully in the ISO format
- // convert it to our DateTimeData if a valid ISO
- newData = parseDate(newData);
- if (newData) {
- // successfully parsed the ISO string to our DateTimeData
- Object.assign(existingData, newData);
- return true;
- }
- }
- else if ((isPresent(newData.year) || isPresent(newData.hour) || isPresent(newData.month) || isPresent(newData.day) || isPresent(newData.minute) || isPresent(newData.second))) {
- // newData is from of a datetime picker's selected values
- // update the existing DateTimeData data with the new values
- // do some magic for 12-hour values
- if (isPresent(newData.ampm) && isPresent(newData.hour)) {
- if (newData.ampm.value === 'pm') {
- newData.hour.value = (newData.hour.value === 12 ? 12 : newData.hour.value + 12);
- }
- else {
- newData.hour.value = (newData.hour.value === 12 ? 0 : newData.hour.value);
- }
- }
- // merge new values from the picker's selection
- // to the existing DateTimeData values
- for (var k in newData) {
- existingData[k] = newData[k].value;
- }
- return true;
- }
- // eww, invalid data
- console.warn("Error parsing date: \"" + newData + "\". Please provide a valid ISO 8601 datetime format: https://www.w3.org/TR/NOTE-datetime");
- }
- else {
- // blank data, clear everything out
- for (var k in existingData) {
- delete existingData[k];
- }
- }
- return false;
- }
- function parseTemplate(template) {
- var formats = [];
- template = template.replace(/[^\w\s]/gi, ' ');
- FORMAT_KEYS.forEach(function (format) {
- if (format.f.length > 1 && template.indexOf(format.f) > -1 && template.indexOf(format.f + format.f.charAt(0)) < 0) {
- template = template.replace(format.f, ' ' + format.f + ' ');
- }
- });
- var words = template.split(' ').filter(function (w) { return w.length > 0; });
- words.forEach(function (word, i) {
- FORMAT_KEYS.forEach(function (format) {
- if (word === format.f) {
- if (word === FORMAT_A || word === FORMAT_a) {
- // this format is an am/pm format, so it's an "a" or "A"
- if ((formats.indexOf(FORMAT_h) < 0 && formats.indexOf(FORMAT_hh) < 0) ||
- VALID_AMPM_PREFIX.indexOf(words[i - 1]) === -1) {
- // template does not already have a 12-hour format
- // or this am/pm format doesn't have a hour, minute, or second format immediately before it
- // so do not treat this word "a" or "A" as the am/pm format
- return;
- }
- }
- formats.push(word);
- }
- });
- });
- return formats;
- }
- function getValueFromFormat(date, format) {
- if (format === FORMAT_A || format === FORMAT_a) {
- return (date.hour < 12 ? 'am' : 'pm');
- }
- if (format === FORMAT_hh || format === FORMAT_h) {
- return (date.hour > 12 ? date.hour - 12 : date.hour);
- }
- return date[convertFormatToKey(format)];
- }
- function convertFormatToKey(format) {
- for (var k in FORMAT_KEYS) {
- if (FORMAT_KEYS[k].f === format) {
- return FORMAT_KEYS[k].k;
- }
- }
- return null;
- }
- function convertDataToISO(data) {
- // https://www.w3.org/TR/NOTE-datetime
- var rtn = '';
- if (isPresent(data)) {
- if (isPresent(data.year)) {
- // YYYY
- rtn = fourDigit(data.year);
- if (isPresent(data.month)) {
- // YYYY-MM
- rtn += '-' + twoDigit(data.month);
- if (isPresent(data.day)) {
- // YYYY-MM-DD
- rtn += '-' + twoDigit(data.day);
- if (isPresent(data.hour)) {
- // YYYY-MM-DDTHH:mm:SS
- rtn += "T" + twoDigit(data.hour) + ":" + twoDigit(data.minute) + ":" + twoDigit(data.second);
- if (data.millisecond > 0) {
- // YYYY-MM-DDTHH:mm:SS.SSS
- rtn += '.' + threeDigit(data.millisecond);
- }
- if (isBlank$1(data.tzOffset) || data.tzOffset === 0) {
- // YYYY-MM-DDTHH:mm:SSZ
- rtn += 'Z';
- }
- else {
- // YYYY-MM-DDTHH:mm:SS+/-HH:mm
- rtn += (data.tzOffset > 0 ? '+' : '-') + twoDigit(Math.floor(data.tzOffset / 60)) + ':' + twoDigit(data.tzOffset % 60);
- }
- }
- }
- }
- }
- else if (isPresent(data.hour)) {
- // HH:mm
- rtn = twoDigit(data.hour) + ':' + twoDigit(data.minute);
- if (isPresent(data.second)) {
- // HH:mm:SS
- rtn += ':' + twoDigit(data.second);
- if (isPresent(data.millisecond)) {
- // HH:mm:SS.SSS
- rtn += '.' + threeDigit(data.millisecond);
- }
- }
- }
- }
- return rtn;
- }
- function twoDigit(val) {
- return ('0' + (isPresent(val) ? Math.abs(val) : '0')).slice(-2);
- }
- function threeDigit(val) {
- return ('00' + (isPresent(val) ? Math.abs(val) : '0')).slice(-3);
- }
- function fourDigit(val) {
- return ('000' + (isPresent(val) ? Math.abs(val) : '0')).slice(-4);
- }
- var FORMAT_YYYY = 'YYYY';
- var FORMAT_YY = 'YY';
- var FORMAT_MMMM = 'MMMM';
- var FORMAT_MMM = 'MMM';
- var FORMAT_MM = 'MM';
- var FORMAT_M = 'M';
- var FORMAT_DDDD = 'DDDD';
- var FORMAT_DDD = 'DDD';
- var FORMAT_DD = 'DD';
- var FORMAT_D = 'D';
- var FORMAT_HH = 'HH';
- var FORMAT_H = 'H';
- var FORMAT_hh = 'hh';
- var FORMAT_h = 'h';
- var FORMAT_mm = 'mm';
- var FORMAT_m = 'm';
- var FORMAT_ss = 'ss';
- var FORMAT_s = 's';
- var FORMAT_A = 'A';
- var FORMAT_a = 'a';
- var FORMAT_KEYS = [
- { f: FORMAT_YYYY, k: 'year' },
- { f: FORMAT_MMMM, k: 'month' },
- { f: FORMAT_DDDD, k: 'day' },
- { f: FORMAT_MMM, k: 'month' },
- { f: FORMAT_DDD, k: 'day' },
- { f: FORMAT_YY, k: 'year' },
- { f: FORMAT_MM, k: 'month' },
- { f: FORMAT_DD, k: 'day' },
- { f: FORMAT_HH, k: 'hour' },
- { f: FORMAT_hh, k: 'hour' },
- { f: FORMAT_mm, k: 'minute' },
- { f: FORMAT_ss, k: 'second' },
- { f: FORMAT_M, k: 'month' },
- { f: FORMAT_D, k: 'day' },
- { f: FORMAT_H, k: 'hour' },
- { f: FORMAT_h, k: 'hour' },
- { f: FORMAT_m, k: 'minute' },
- { f: FORMAT_s, k: 'second' },
- { f: FORMAT_A, k: 'ampm' },
- { f: FORMAT_a, k: 'ampm' },
- ];
- var DAY_NAMES = [
- 'Sunday',
- 'Monday',
- 'Tuesday',
- 'Wednesday',
- 'Thursday',
- 'Friday',
- 'Saturday',
- ];
- var DAY_SHORT_NAMES = [
- 'Sun',
- 'Mon',
- 'Tue',
- 'Wed',
- 'Thu',
- 'Fri',
- 'Sat',
- ];
- var MONTH_NAMES = [
- 'January',
- 'February',
- 'March',
- 'April',
- 'May',
- 'June',
- 'July',
- 'August',
- 'September',
- 'October',
- 'November',
- 'December',
- ];
- var MONTH_SHORT_NAMES = [
- 'Jan',
- 'Feb',
- 'Mar',
- 'Apr',
- 'May',
- 'Jun',
- 'Jul',
- 'Aug',
- 'Sep',
- 'Oct',
- 'Nov',
- 'Dec',
- ];
- var VALID_AMPM_PREFIX = [
- FORMAT_hh, FORMAT_h, FORMAT_mm, FORMAT_m, FORMAT_ss, FORMAT_s
- ];
-
- var __extends$44 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- var __assign$1 = (undefined && undefined.__assign) || Object.assign || function(t) {
- for (var s, i = 1, n = arguments.length; i < n; i++) {
- s = arguments[i];
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
- t[p] = s[p];
- }
- return t;
- };
- /**
- * @name DateTime
- * @description
- * The DateTime component is used to present an interface which makes it easy for
- * users to select dates and times. Tapping on `<ion-datetime>` will display a picker
- * interface that slides up from the bottom of the page. The picker then displays
- * scrollable columns that can be used to individually select years, months, days,
- * hours and minute values. The DateTime component is similar to the native
- * `<input type="datetime-local">` element, however, Ionic's DateTime component makes
- * it easy to display the date and time in a preferred format, and manage the datetime
- * values.
- *
- * ```html
- * <ion-item>
- * <ion-label>Date</ion-label>
- * <ion-datetime displayFormat="MM/DD/YYYY" [(ngModel)]="myDate"></ion-datetime>
- * </ion-item>
- * ```
- *
- *
- * ## Display and Picker Formats
- *
- * The DateTime component displays the values in two places: in the `<ion-datetime>`
- * component, and in the interface that is presented from the bottom of the screen.
- * The following chart lists all of the formats that can be used.
- *
- * | Format | Description | Example |
- * |---------|--------------------------------|-------------------------|
- * | `YYYY` | Year, 4 digits | `2018` |
- * | `YY` | Year, 2 digits | `18` |
- * | `M` | Month | `1` ... `12` |
- * | `MM` | Month, leading zero | `01` ... `12` |
- * | `MMM` | Month, short name | `Jan` |
- * | `MMMM` | Month, full name | `January` |
- * | `D` | Day | `1` ... `31` |
- * | `DD` | Day, leading zero | `01` ... `31` |
- * | `DDD` | Day, short name | `Fri` |
- * | `DDDD` | Day, full name | `Friday` |
- * | `H` | Hour, 24-hour | `0` ... `23` |
- * | `HH` | Hour, 24-hour, leading zero | `00` ... `23` |
- * | `h` | Hour, 12-hour | `1` ... `12` |
- * | `hh` | Hour, 12-hour, leading zero | `01` ... `12` |
- * | `a` | 12-hour time period, lowercase | `am` `pm` |
- * | `A` | 12-hour time period, uppercase | `AM` `PM` |
- * | `m` | Minute | `1` ... `59` |
- * | `mm` | Minute, leading zero | `01` ... `59` |
- * | `s` | Second | `1` ... `59` |
- * | `ss` | Second, leading zero | `01` ... `59` |
- * | `Z` | UTC Timezone Offset | `Z or +HH:mm or -HH:mm` |
- *
- * **Important**: See the [Month Names and Day of the Week Names](#month-names-and-day-of-the-week-names)
- * section below on how to use different names for the month and day.
- *
- * ### Display Format
- *
- * The `displayFormat` input property specifies how a datetime's value should be
- * printed, as formatted text, within the `ion-datetime` component.
- *
- * In the following example, the display in the `<ion-datetime>` will use the
- * month's short name, the numerical day with a leading zero, a comma and the
- * four-digit year. In addition to the date, it will display the time with the hours
- * in the 24-hour format and the minutes. Any character can be used as a separator.
- * An example display using this format is: `Jun 17, 2005 11:06`.
- *
- * ```html
- * <ion-item>
- * <ion-label>Date</ion-label>
- * <ion-datetime displayFormat="MMM DD, YYYY HH:mm" [(ngModel)]="myDate"></ion-datetime>
- * </ion-item>
- * ```
- *
- * ### Picker Format
- *
- * The `pickerFormat` input property determines which columns should be shown in the
- * interface, the order of the columns, and which format to use within each column.
- * If the `pickerFormat` input is not provided then it will default to the `displayFormat`.
- *
- * In the following example, the display in the `<ion-datetime>` will use the
- * `MM/YYYY` format, such as `06/2020`. However, the picker interface
- * will display two columns with the month's long name, and the four-digit year.
- *
- * ```html
- * <ion-item>
- * <ion-label>Date</ion-label>
- * <ion-datetime displayFormat="MM/YYYY" pickerFormat="MMMM YYYY" [(ngModel)]="myDate"></ion-datetime>
- * </ion-item>
- * ```
- *
- * ### Datetime Data
- *
- * Historically, handling datetime values within JavaScript, or even within HTML
- * inputs, has always been a challenge. Specifically, JavaScript's `Date` object is
- * notoriously difficult to correctly parse apart datetime strings or to format
- * datetime values. Even worse is how different browsers and JavaScript versions
- * parse various datetime strings differently, especially per locale.
- *
- * But no worries, all is not lost! Ionic's datetime input has been designed so
- * developers can avoid the common pitfalls, allowing developers to easily format
- * datetime values within the input, and give the user a simple datetime picker for a
- * great user experience.
- *
- * ##### ISO 8601 Datetime Format: YYYY-MM-DDTHH:mmZ
- *
- * Ionic uses the [ISO 8601 datetime format](https://www.w3.org/TR/NOTE-datetime)
- * for its value. The value is simply a string, rather than using JavaScript's `Date`
- * object. Additionally, when using the ISO datetime format, it makes it easier
- * to serialize and pass within JSON objects, and sending databases a standardized
- * format which it can be easily parsed if need be.
- *
- * To create an ISO datetime string for the current date and time, e.g. use `const currentDate = (new Date()).toISOString();`.
- *
- * An ISO format can be used as a simple year, or just the hour and minute, or get more
- * detailed down to the millisecond and timezone. Any of the ISO formats below can be used,
- * and after a user selects a new value, Ionic will continue to use the same ISO format
- * which datetime value was originally given as.
- *
- * | Description | Format | Datetime Value Example |
- * |----------------------|------------------------|------------------------------|
- * | Year | YYYY | 1994 |
- * | Year and Month | YYYY-MM | 1994-12 |
- * | Complete Date | YYYY-MM-DD | 1994-12-15 |
- * | Date and Time | YYYY-MM-DDTHH:mm | 1994-12-15T13:47 |
- * | UTC Timezone | YYYY-MM-DDTHH:mm:ssTZD | 1994-12-15T13:47:20.789Z |
- * | Timezone Offset | YYYY-MM-DDTHH:mm:ssTZD | 1994-12-15T13:47:20.789+5:00 |
- * | Hour and Minute | HH:mm | 13:47 |
- * | Hour, Minute, Second | HH:mm:ss | 13:47:20 |
- *
- * Note that the year is always four-digits, milliseconds (if it's added) is always
- * three-digits, and all others are always two-digits. So the number representing
- * January always has a leading zero, such as `01`. Additionally, the hour is always
- * in the 24-hour format, so `00` is `12am` on a 12-hour clock, `13` means `1pm`,
- * and `23` means `11pm`.
- *
- * It's also important to note that neither the `displayFormat` or `pickerFormat` can
- * set the datetime value's output, which is the value that is set by the component's
- * `ngModel`. The format's are merely for displaying the value as text and the picker's
- * interface, but the datetime's value is always persisted as a valid ISO 8601 datetime
- * string.
- *
- *
- * ## Min and Max Datetimes
- *
- * Dates are infinite in either direction, so for a user's selection there should be at
- * least some form of restricting the dates that can be selected. By default, the maximum
- * date is to the end of the current year, and the minimum date is from the beginning
- * of the year that was 100 years ago.
- *
- * To customize the minimum and maximum datetime values, the `min` and `max` component
- * inputs can be provided which may make more sense for the app's use-case, rather
- * than the default of the last 100 years. Following the same IS0 8601 format listed
- * in the table above, each component can restrict which dates can be selected by the
- * user. Below is an example of restricting the date selection between the beginning
- * of 2016, and October 31st of 2020:
- *
- * ```html
- * <ion-item>
- * <ion-label>Date</ion-label>
- * <ion-datetime displayFormat="MMMM YYYY" min="2016" max="2020-10-31" [(ngModel)]="myDate">
- * </ion-datetime>
- * </ion-item>
- * ```
- *
- *
- * ## Month Names and Day of the Week Names
- *
- * At this time, there is no one-size-fits-all standard to automatically choose the correct
- * language/spelling for a month name, or day of the week name, depending on the language
- * or locale. Good news is that there is an
- * [Intl.DateTimeFormat](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat)
- * standard which *most* browsers have adopted. However, at this time the standard has not
- * been fully implemented by all popular browsers so Ionic is unavailable to take advantage
- * of it *yet*. Additionally, Angular also provides an internationalization service, but it
- * is still under heavy development so Ionic does not depend on it at this time.
- *
- * All things considered, the by far easiest solution is to just provide an array of names
- * if the app needs to use names other than the default English version of month and day
- * names. The month names and day names can be either configured at the app level, or
- * individual `ion-datetime` level.
- *
- * ### App Config Level
- *
- * ```ts
- * //app.module.ts
- * @NgModule({
- * ...,
- * imports: [
- * IonicModule.forRoot(MyApp, {
- * monthNames: ['janeiro', 'fevereiro', 'mar\u00e7o', ... ],
- * monthShortNames: ['jan', 'fev', 'mar', ... ],
- * dayNames: ['domingo', 'segunda-feira', 'ter\u00e7a-feira', ... ],
- * dayShortNames: ['dom', 'seg', 'ter', ... ],
- * })
- * ],
- * ...
- * })
- * ```
- *
- * ### Component Input Level
- *
- * ```html
- * <ion-item>
- * <ion-label>Período</ion-label>
- * <ion-datetime displayFormat="DDDD MMM D, YYYY" [(ngModel)]="myDate"
- * monthNames="janeiro, fevereiro, mar\u00e7o, ..."
- * monthShortNames="jan, fev, mar, ..."
- * dayNames="domingo, segunda-feira, ter\u00e7a-feira, ..."
- * dayShortNames="dom, seg, ter, ..."></ion-datetime>
- * </ion-item>
- * ```
- *
- *
- * ### Advanced Datetime Validation and Manipulation
- *
- * The datetime picker provides the simplicity of selecting an exact format, and persists
- * the datetime values as a string using the standardized
- * [ISO 8601 datetime format](https://www.w3.org/TR/NOTE-datetime).
- * However, it's important to note that `ion-datetime` does not attempt to solve all
- * situtations when validating and manipulating datetime values. If datetime values need
- * to be parsed from a certain format, or manipulated (such as adding 5 days to a date,
- * subtracting 30 minutes, etc.), or even formatting data to a specific locale, then we highly
- * recommend using [moment.js](http://momentjs.com/) to "Parse, validate, manipulate, and
- * display dates in JavaScript". [Moment.js](http://momentjs.com/) has quickly become
- * our goto standard when dealing with datetimes within JavaScript, but Ionic does not
- * prepackage this dependency since most apps will not require it, and its locale
- * configuration should be decided by the end-developer.
- *
- *
- * @usage
- * ```html
- * <ion-item>
- * <ion-label>Date</ion-label>
- * <ion-datetime displayFormat="MM/DD/YYYY" [(ngModel)]="myDate">
- * </ion-datetime>
- * </ion-item>
- * ```
- *
- *
- * @demo /docs/demos/src/datetime/
- */
- var DateTime = (function (_super) {
- __extends$44(DateTime, _super);
- function DateTime(form, config, elementRef, renderer, item, _pickerCtrl) {
- var _this = _super.call(this, config, elementRef, renderer, 'datetime', {}, form, item, null) || this;
- _this._pickerCtrl = _pickerCtrl;
- _this._text = '';
- _this._locale = {};
- /**
- * @input {string} The text to display on the picker's cancel button. Default: `Cancel`.
- */
- _this.cancelText = 'Cancel';
- /**
- * @input {string} The text to display on the picker's "Done" button. Default: `Done`.
- */
- _this.doneText = 'Done';
- /**
- * @input {any} Any additional options that the picker interface can accept.
- * See the [Picker API docs](../../picker/Picker) for the picker options.
- */
- _this.pickerOptions = {};
- /**
- * @input {string} The text to display when there's no date selected yet.
- * Using lowercase to match the input attribute
- */
- _this.placeholder = '';
- /**
- * @output {any} Emitted when the datetime selection was cancelled.
- */
- _this.ionCancel = new EventEmitter();
- return _this;
- }
- /**
- * @hidden
- */
- DateTime.prototype.ngAfterContentInit = function () {
- var _this = this;
- // first see if locale names were provided in the inputs
- // then check to see if they're in the config
- // if neither were provided then it will use default English names
- ['monthNames', 'monthShortNames', 'dayNames', 'dayShortNames'].forEach(function (type) {
- _this._locale[type] = convertToArrayOfStrings(isPresent(_this[type]) ? _this[type] : _this._config.get(type), type);
- });
- this._initialize();
- };
- /**
- * @hidden
- */
- DateTime.prototype._inputNormalize = function (val) {
- updateDate(this._value, val);
- return this._value;
- };
- /**
- * @hidden
- */
- DateTime.prototype._inputUpdated = function () {
- _super.prototype._inputUpdated.call(this);
- this.updateText();
- };
- /**
- * @hidden
- */
- DateTime.prototype._inputShouldChange = function () {
- return true;
- };
- /**
- * TODO: REMOVE THIS
- * @hidden
- */
- DateTime.prototype._inputChangeEvent = function () {
- return this.value;
- };
- /**
- * @hidden
- */
- DateTime.prototype._inputNgModelEvent = function () {
- return convertDataToISO(this.value);
- };
- DateTime.prototype._click = function (ev) {
- ev.preventDefault();
- ev.stopPropagation();
- this.open();
- };
- DateTime.prototype._keyup = function () {
- this.open();
- };
- /**
- * @hidden
- */
- DateTime.prototype.open = function () {
- var _this = this;
- if (this.isFocus() || this._disabled) {
- return;
- }
- (void 0) /* console.debug */;
- // the user may have assigned some options specifically for the picker
- var pickerOptions = __assign$1({}, this.pickerOptions);
- // Add a cancel and done button by default to the picker
- var defaultButtons = [{
- text: this.cancelText,
- role: 'cancel',
- handler: function () { return _this.ionCancel.emit(_this); }
- }, {
- text: this.doneText,
- handler: function (data) { return _this.value = data; },
- }];
- pickerOptions.buttons = (pickerOptions.buttons || []).concat(defaultButtons);
- // Configure picker under the hood
- var picker = this._picker = this._pickerCtrl.create(pickerOptions);
- picker.ionChange.subscribe(function () {
- _this.validate();
- picker.refresh();
- });
- // Update picker status before presenting
- this.generate();
- this.validate();
- // Present picker
- this._fireFocus();
- picker.present(pickerOptions);
- picker.onDidDismiss(function () {
- _this._fireBlur();
- });
- };
- /**
- * @hidden
- */
- DateTime.prototype.generate = function () {
- var _this = this;
- var picker = this._picker;
- // if a picker format wasn't provided, then fallback
- // to use the display format
- var template = this.pickerFormat || this.displayFormat || DEFAULT_FORMAT;
- if (isPresent(template)) {
- // make sure we've got up to date sizing information
- this.calcMinMax();
- // does not support selecting by day name
- // automaticallly remove any day name formats
- template = template.replace('DDDD', '{~}').replace('DDD', '{~}');
- if (template.indexOf('D') === -1) {
- // there is not a day in the template
- // replace the day name with a numeric one if it exists
- template = template.replace('{~}', 'D');
- }
- // make sure no day name replacer is left in the string
- template = template.replace(/{~}/g, '');
- // parse apart the given template into an array of "formats"
- parseTemplate(template).forEach(function (format) {
- // loop through each format in the template
- // create a new picker column to build up with data
- var key = convertFormatToKey(format);
- var values;
- // first see if they have exact values to use for this input
- if (isPresent(_this[key + 'Values'])) {
- // user provide exact values for this date part
- values = convertToArrayOfNumbers(_this[key + 'Values'], key);
- }
- else {
- // use the default date part values
- values = dateValueRange(format, _this._min, _this._max);
- }
- var column = {
- name: key,
- selectedIndex: 0,
- options: values.map(function (val) {
- return {
- value: val,
- text: renderTextFormat(format, val, null, _this._locale),
- };
- })
- };
- // cool, we've loaded up the columns with options
- // preselect the option for this column
- var optValue = getValueFromFormat(_this.getValueOrDefault(), format);
- var selectedIndex = column.options.findIndex(function (opt) { return opt.value === optValue; });
- if (selectedIndex >= 0) {
- // set the select index for this column's options
- column.selectedIndex = selectedIndex;
- }
- // add our newly created column to the picker
- picker.addColumn(column);
- });
- // Normalize min/max
- var min_1 = this._min;
- var max_1 = this._max;
- var columns_1 = this._picker.getColumns();
- ['month', 'day', 'hour', 'minute']
- .filter(function (name) { return !columns_1.find(function (column) { return column.name === name; }); })
- .forEach(function (name) {
- min_1[name] = 0;
- max_1[name] = 0;
- });
- this.divyColumns();
- }
- };
- /**
- * @hidden
- */
- DateTime.prototype.validateColumn = function (name, index, min, max, lowerBounds, upperBounds) {
- (void 0) /* assert */;
- (void 0) /* assert */;
- var column = this._picker.getColumn(name);
- if (!column) {
- return 0;
- }
- var lb = lowerBounds.slice();
- var ub = upperBounds.slice();
- var options = column.options;
- var indexMin = options.length - 1;
- var indexMax = 0;
- for (var i = 0; i < options.length; i++) {
- var opt = options[i];
- var value = opt.value;
- lb[index] = opt.value;
- ub[index] = opt.value;
- var disabled = opt.disabled = (value < lowerBounds[index] ||
- value > upperBounds[index] ||
- dateSortValue(ub[0], ub[1], ub[2], ub[3], ub[4]) < min ||
- dateSortValue(lb[0], lb[1], lb[2], lb[3], lb[4]) > max);
- if (!disabled) {
- indexMin = Math.min(indexMin, i);
- indexMax = Math.max(indexMax, i);
- }
- }
- var selectedIndex = column.selectedIndex = clamp(indexMin, column.selectedIndex, indexMax);
- opt = column.options[selectedIndex];
- if (opt) {
- return opt.value;
- }
- return 0;
- };
- /**
- * @private
- */
- DateTime.prototype.validate = function () {
- var today = new Date();
- var minCompareVal = dateDataSortValue(this._min);
- var maxCompareVal = dateDataSortValue(this._max);
- var yearCol = this._picker.getColumn('year');
- (void 0) /* assert */;
- var selectedYear = today.getFullYear();
- if (yearCol) {
- // default to the first value if the current year doesn't exist in the options
- if (!yearCol.options.find(function (col) { return col.value === today.getFullYear(); })) {
- selectedYear = yearCol.options[0].value;
- }
- var yearOpt = yearCol.options[yearCol.selectedIndex];
- if (yearOpt) {
- // they have a selected year value
- selectedYear = yearOpt.value;
- }
- }
- var selectedMonth = this.validateColumn('month', 1, minCompareVal, maxCompareVal, [selectedYear, 0, 0, 0, 0], [selectedYear, 12, 31, 23, 59]);
- var numDaysInMonth = daysInMonth(selectedMonth, selectedYear);
- var selectedDay = this.validateColumn('day', 2, minCompareVal, maxCompareVal, [selectedYear, selectedMonth, 0, 0, 0], [selectedYear, selectedMonth, numDaysInMonth, 23, 59]);
- var selectedHour = this.validateColumn('hour', 3, minCompareVal, maxCompareVal, [selectedYear, selectedMonth, selectedDay, 0, 0], [selectedYear, selectedMonth, selectedDay, 23, 59]);
- this.validateColumn('minute', 4, minCompareVal, maxCompareVal, [selectedYear, selectedMonth, selectedDay, selectedHour, 0], [selectedYear, selectedMonth, selectedDay, selectedHour, 59]);
- };
- /**
- * @hidden
- */
- DateTime.prototype.divyColumns = function () {
- var pickerColumns = this._picker.getColumns();
- var columnsWidth = [];
- var col;
- var width;
- for (var i = 0; i < pickerColumns.length; i++) {
- col = pickerColumns[i];
- columnsWidth.push(0);
- for (var j = 0; j < col.options.length; j++) {
- width = col.options[j].text.length;
- if (width > columnsWidth[i]) {
- columnsWidth[i] = width;
- }
- }
- }
- if (columnsWidth.length === 2) {
- width = Math.max(columnsWidth[0], columnsWidth[1]);
- pickerColumns[0].align = 'right';
- pickerColumns[1].align = 'left';
- pickerColumns[0].optionsWidth = pickerColumns[1].optionsWidth = width * 17 + "px";
- }
- else if (columnsWidth.length === 3) {
- width = Math.max(columnsWidth[0], columnsWidth[2]);
- pickerColumns[0].align = 'right';
- pickerColumns[1].columnWidth = columnsWidth[1] * 17 + "px";
- pickerColumns[0].optionsWidth = pickerColumns[2].optionsWidth = width * 17 + "px";
- pickerColumns[2].align = 'left';
- }
- };
- /**
- * @hidden
- */
- DateTime.prototype.updateText = function () {
- // create the text of the formatted data
- var template = this.displayFormat || this.pickerFormat || DEFAULT_FORMAT;
- this._text = renderDateTime(template, this.getValue(), this._locale);
- };
- /**
- * @hidden
- */
- DateTime.prototype.getValue = function () {
- return this._value;
- };
- /**
- * @hidden
- */
- DateTime.prototype.getValueOrDefault = function () {
- if (this.hasValue()) {
- return this._value;
- }
- var initialDateString = this.getDefaultValueDateString();
- var _default = {};
- updateDate(_default, initialDateString);
- return _default;
- };
- /**
- * Get the default value as a date string
- * @hidden
- */
- DateTime.prototype.getDefaultValueDateString = function () {
- if (this.initialValue) {
- return this.initialValue;
- }
- var nowString = (new Date).toISOString();
- if (this.max) {
- var now = parseDate(nowString);
- var max = parseDate(this.max);
- var v = void 0;
- for (var i in max) {
- v = max[i];
- if (v === null) {
- max[i] = now[i];
- }
- }
- var diff = compareDates(now, max);
- // If max is before current time, return max
- if (diff > 0) {
- return this.max;
- }
- }
- return nowString;
- };
- /**
- * @hidden
- */
- DateTime.prototype.hasValue = function () {
- var val = this._value;
- return isPresent(val)
- && isObject$1(val)
- && Object.keys(val).length > 0;
- };
- /**
- * @hidden
- */
- DateTime.prototype.calcMinMax = function (now) {
- var todaysYear = (now || new Date()).getFullYear();
- if (isPresent(this.yearValues)) {
- var years = convertToArrayOfNumbers(this.yearValues, 'year');
- if (isBlank$1(this.min)) {
- this.min = Math.min.apply(Math, years);
- }
- if (isBlank$1(this.max)) {
- this.max = Math.max.apply(Math, years);
- }
- }
- else {
- if (isBlank$1(this.min)) {
- this.min = (todaysYear - 100).toString();
- }
- if (isBlank$1(this.max)) {
- this.max = todaysYear.toString();
- }
- }
- var min = this._min = parseDate(this.min);
- var max = this._max = parseDate(this.max);
- min.year = min.year || todaysYear;
- max.year = max.year || todaysYear;
- min.month = min.month || 1;
- max.month = max.month || 12;
- min.day = min.day || 1;
- max.day = max.day || 31;
- min.hour = min.hour || 0;
- max.hour = max.hour || 23;
- min.minute = min.minute || 0;
- max.minute = max.minute || 59;
- min.second = min.second || 0;
- max.second = max.second || 59;
- // Ensure min/max constraits
- if (min.year > max.year) {
- console.error('min.year > max.year');
- min.year = max.year - 100;
- }
- if (min.year === max.year) {
- if (min.month > max.month) {
- console.error('min.month > max.month');
- min.month = 1;
- }
- else if (min.month === max.month && min.day > max.day) {
- console.error('min.day > max.day');
- min.day = 1;
- }
- }
- };
- DateTime.decorators = [
- { type: Component, args: [{
- selector: 'ion-datetime',
- template: '<div *ngIf="!_text" class="datetime-text datetime-placeholder">{{placeholder}}</div>' +
- '<div *ngIf="_text" class="datetime-text">{{_text}}</div>' +
- '<button aria-haspopup="true" ' +
- 'type="button" ' +
- '[id]="id" ' +
- 'ion-button="item-cover" ' +
- '[attr.aria-labelledby]="_labelId" ' +
- '[attr.aria-disabled]="_disabled" ' +
- 'class="item-cover">' +
- '</button>',
- host: {
- '[class.datetime-disabled]': '_disabled'
- },
- providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: DateTime, multi: true }],
- encapsulation: ViewEncapsulation.None,
- },] },
- ];
- /** @nocollapse */
- DateTime.ctorParameters = function () { return [
- { type: Form, },
- { type: Config, },
- { type: ElementRef, },
- { type: Renderer, },
- { type: Item, decorators: [{ type: Optional },] },
- { type: PickerController, decorators: [{ type: Optional },] },
- ]; };
- DateTime.propDecorators = {
- 'min': [{ type: Input },],
- 'max': [{ type: Input },],
- 'displayFormat': [{ type: Input },],
- 'initialValue': [{ type: Input },],
- 'pickerFormat': [{ type: Input },],
- 'cancelText': [{ type: Input },],
- 'doneText': [{ type: Input },],
- 'yearValues': [{ type: Input },],
- 'monthValues': [{ type: Input },],
- 'dayValues': [{ type: Input },],
- 'hourValues': [{ type: Input },],
- 'minuteValues': [{ type: Input },],
- 'monthNames': [{ type: Input },],
- 'monthShortNames': [{ type: Input },],
- 'dayNames': [{ type: Input },],
- 'dayShortNames': [{ type: Input },],
- 'pickerOptions': [{ type: Input },],
- 'placeholder': [{ type: Input },],
- 'ionCancel': [{ type: Output },],
- '_click': [{ type: HostListener, args: ['click', ['$event'],] },],
- '_keyup': [{ type: HostListener, args: ['keyup.space',] },],
- };
- return DateTime;
- }(BaseInput));
- /**
- * @hidden
- * Use to convert a string of comma separated numbers or
- * an array of numbers, and clean up any user input
- */
- function convertToArrayOfNumbers(input, type) {
- if (isString(input)) {
- // convert the string to an array of strings
- // auto remove any whitespace and [] characters
- input = input.replace(/\[|\]|\s/g, '').split(',');
- }
- var values;
- if (isArray$2(input)) {
- // ensure each value is an actual number in the returned array
- values = input
- .map(function (num) { return parseInt(num, 10); })
- .filter(isFinite);
- }
- if (!values || !values.length) {
- console.warn("Invalid \"" + type + "Values\". Must be an array of numbers, or a comma separated string of numbers.");
- }
- return values;
- }
- /**
- * @hidden
- * Use to convert a string of comma separated strings or
- * an array of strings, and clean up any user input
- */
- function convertToArrayOfStrings(input, type) {
- if (isPresent(input)) {
- if (isString(input)) {
- // convert the string to an array of strings
- // auto remove any [] characters
- input = input.replace(/\[|\]/g, '').split(',');
- }
- var values;
- if (isArray$2(input)) {
- // trim up each string value
- values = input.map(function (val) { return val.trim(); });
- }
- if (!values || !values.length) {
- console.warn("Invalid \"" + type + "Names\". Must be an array of strings, or a comma separated string.");
- }
- return values;
- }
- }
- var DEFAULT_FORMAT = 'MMM D, YYYY';
-
- var __extends$47 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @name FabButton
- * @module ionic
- *
- * @description
- * FABs (Floating Action Buttons) are standard material design components. They are shaped as a circle that represents a promoted action. When pressed, it may contain more related actions.
- * FABs as its name suggests are floating over the content in a fixed position. This is not achieved exclusively with `<button ion-fab>Button</button>` but it has to wrapped with the `<ion-fab>` component, like this:
- *
- * ```html
- * <ion-content>
- * <!-- Real floating action button, fixed. It will not scroll with the content -->
- * <ion-fab>
- * <button ion-fab>Button</button>
- * </ion-fab>
- *
- * <!-- Button shaped as a circle that just like a normal button scrolls with the content -->
- * <button ion-fab>Button</button>
- * </ion-content>
- *
- * ```
- *
- * In case the button is not wrapped with `<ion-fab>`, the fab button will behave like a normal button, scrolling with the content.
- *
- * See [ion-fab] to learn more information about how to position the fab button.
- *
- * @property [mini] - Makes a fab button with a reduced size.
- *
- * @usage
- *
- * ```html
- *
- * <!-- Colors -->
- * <ion-fab>
- * <button ion-fab color="primary">Button</button>
- * </ion-fab>
- *
- * <!-- Mini -->
- * <ion-fab>
- * <button ion-fab mini>Small</button>
- * </ion-fab>
- * ```
- *
- * @demo /docs/demos/src/fab/
- * @see {@link /docs/components#fabs FAB Component Docs}
- */
- var FabButton = (function (_super) {
- __extends$47(FabButton, _super);
- function FabButton(config, elementRef, renderer) {
- return _super.call(this, config, elementRef, renderer, 'fab') || this;
- }
- /**
- * @hidden
- */
- FabButton.prototype.setActiveClose = function (closeVisible) {
- this.setElementClass('fab-close-active', closeVisible);
- };
- FabButton.decorators = [
- { type: Component, args: [{
- selector: '[ion-fab]',
- template: '<ion-icon name="close" class="fab-close-icon"></ion-icon>' +
- '<span class="button-inner">' +
- '<ng-content></ng-content>' +
- '</span>' +
- '<div class="button-effect"></div>',
- changeDetection: ChangeDetectionStrategy.OnPush,
- encapsulation: ViewEncapsulation.None,
- },] },
- ];
- /** @nocollapse */
- FabButton.ctorParameters = function () { return [
- { type: Config, },
- { type: ElementRef, },
- { type: Renderer, },
- ]; };
- return FabButton;
- }(Ion));
-
- /**
- * @name FabList
- * @description
- * `ion-fab-list` is a container for multiple FAB buttons. They are components of `ion-fab` and allow you to specificy the buttons position, left, right, top, bottom.
- * @usage
- *
- * ```html
- * <ion-fab bottom right >
- * <button ion-fab>Share</button>
- * <ion-fab-list side="top">
- * <button ion-fab>Facebook</button>
- * <button ion-fab>Twitter</button>
- * <button ion-fab>Youtube</button>
- * </ion-fab-list>
- * <ion-fab-list side="left">
- * <button ion-fab>Vimeo</button>
- * </ion-fab-list>
- * </ion-fab>
- * ```
- * @module ionic
- *
- * @demo /docs/demos/src/fab/
- * @see {@link /docs/components#fab Fab Component Docs}
- */
- var FabList = (function () {
- function FabList(_elementRef, _renderer, config, _plt) {
- this._elementRef = _elementRef;
- this._renderer = _renderer;
- this._plt = _plt;
- this._visible = false;
- this._fabs = [];
- this._mode = config.get('mode');
- }
- Object.defineProperty(FabList.prototype, "_setbuttons", {
- set: function (query) {
- var fabs = this._fabs = query.toArray();
- var className = "fab-" + this._mode + "-in-list";
- for (var _i = 0, fabs_1 = fabs; _i < fabs_1.length; _i++) {
- var fab = fabs_1[_i];
- fab.setElementClass('fab-in-list', true);
- fab.setElementClass(className, true);
- }
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @hidden
- */
- FabList.prototype.setVisible = function (val) {
- var _this = this;
- var visible = isTrueProperty(val);
- if (visible === this._visible) {
- return;
- }
- this._visible = visible;
- var fabs = this._fabs;
- var i = 1;
- if (visible) {
- fabs.forEach(function (fab) {
- _this._plt.timeout(function () { return fab.setElementClass('show', true); }, i * 30);
- i++;
- });
- }
- else {
- fabs.forEach(function (fab) { return fab.setElementClass('show', false); });
- }
- this.setElementClass('fab-list-active', visible);
- };
- /**
- * @internal
- */
- FabList.prototype.setElementClass = function (className, add) {
- this._renderer.setElementClass(this._elementRef.nativeElement, className, add);
- };
- FabList.decorators = [
- { type: Directive, args: [{
- selector: 'ion-fab-list',
- },] },
- ];
- /** @nocollapse */
- FabList.ctorParameters = function () { return [
- { type: ElementRef, },
- { type: Renderer, },
- { type: Config, },
- { type: Platform, },
- ]; };
- FabList.propDecorators = {
- '_setbuttons': [{ type: ContentChildren, args: [FabButton,] },],
- };
- return FabList;
- }());
-
- /**
- * @name FabContainer
- * @module ionic
- *
- * @description
- * `<ion-fab>` is not a FAB button by itself but a container that assist the fab button (`<button ion-fab>`) allowing it
- * to be placed in fixed position that does not scroll with the content. It is also used to implement "material design speed dial",
- * ie. a FAB buttons displays a small lists of related actions when clicked.
- *
- * @property [top] - Places the container on the top of the content
- * @property [bottom] - Places the container on the bottom of the content
- * @property [left] - Places the container on the left
- * @property [right] - Places the container on the right
- * @property [middle] - Places the container on the middle vertically
- * @property [center] - Places the container on the center horizontally
- * @property [edge] - Used to place the container between the content and the header/footer
- *
- * @usage
- *
- * ```html
- * <!-- this fab is placed at top right -->
- * <ion-content>
- * <ion-fab top right>
- * <button ion-fab>Button</button>
- * </ion-fab>
- *
- * <!-- this fab is placed at the center of the content viewport -->
- * <ion-fab center middle>
- * <button ion-fab>Button</button>
- * </ion-fab>
- * </ion-content>
- * ```
- *
- * Ionic's FAB also supports "material design's fab speed dial". It is a normal fab button
- * that shows a list of related actions when clicked.
- *
- * The same `ion-fab` container can contain several `ion-fab-list` with different side values:
- * `top`, `bottom`, `left` and `right`. For example, if you want to have a list of button that are
- * on the top of the main button, you should use `side="top"` and so on. By default, if side is ommited, `side="bottom"`.
- *
- * ```html
- * <ion-content>
- * <!-- this fab is placed at bottom right -->
- * <ion-fab bottom right >
- * <button ion-fab>Share</button>
- * <ion-fab-list side="top">
- * <button ion-fab>Facebook</button>
- * <button ion-fab>Twitter</button>
- * <button ion-fab>Youtube</button>
- * </ion-fab-list>
- * <ion-fab-list side="left">
- * <button ion-fab>Vimeo</button>
- * </ion-fab-list>
- * </ion-fab>
- * </ion-content>
- * ```
- *
- * A FAB speed dial can also be closed programatically.
- *
- * ```html
- * <ion-content>
- * <ion-fab bottom right #fab>
- * <button ion-fab>Share</button>
- * <ion-fab-list side="top">
- * <button ion-fab (click)="share('facebook', fab)">Facebook</button>
- * <button ion-fab (click)="share('twitter', fab)">Twitter</button>
- * </ion-fab-list>
- * </ion-fab>
- * </ion-content>
- * ```
- *
- * ```ts
- * share(socialNet: string, fab: FabContainer) {
- * fab.close();
- * console.log("Sharing in", socialNet);
- * }
- * ```
- *
- * @demo /docs/demos/src/fab/
- * @see {@link /docs/components#fabs FAB Component Docs}
- */
- var FabContainer = (function () {
- function FabContainer(plt) {
- /**
- * @hidden
- */
- this._listsActive = false;
- this._events = new UIEventManager(plt);
- }
- /**
- * @hidden
- */
- FabContainer.prototype.ngAfterContentInit = function () {
- var mainButton = this._mainButton;
- if (!mainButton || !mainButton.getNativeElement()) {
- console.error('FAB container needs a main <button ion-fab>');
- return;
- }
- this._events.listen(mainButton.getNativeElement(), 'click', this.clickHandler.bind(this), { zone: true });
- };
- /**
- * @hidden
- */
- FabContainer.prototype.clickHandler = function (ev) {
- if (this.canActivateList(ev)) {
- this.toggleList();
- }
- };
- /**
- * @hidden
- */
- FabContainer.prototype.canActivateList = function (ev) {
- if (this._fabLists.length > 0 && this._mainButton && ev.target) {
- var ele = ev.target.closest('ion-fab>[ion-fab]');
- return (ele && ele === this._mainButton.getNativeElement());
- }
- return false;
- };
- /**
- * @hidden
- */
- FabContainer.prototype.toggleList = function () {
- this.setActiveLists(!this._listsActive);
- };
- /**
- * @hidden
- */
- FabContainer.prototype.setActiveLists = function (isActive) {
- if (isActive === this._listsActive) {
- return;
- }
- var lists = this._fabLists.toArray();
- for (var _i = 0, lists_1 = lists; _i < lists_1.length; _i++) {
- var list = lists_1[_i];
- list.setVisible(isActive);
- }
- this._mainButton.setActiveClose(isActive);
- this._listsActive = isActive;
- };
- /**
- * Close an active FAB list container
- */
- FabContainer.prototype.close = function () {
- this.setActiveLists(false);
- };
- /**
- * @hidden
- */
- FabContainer.prototype.ngOnDestroy = function () {
- this._events.destroy();
- };
- FabContainer.decorators = [
- { type: Component, args: [{
- selector: 'ion-fab',
- template: '<ng-content></ng-content>'
- },] },
- ];
- /** @nocollapse */
- FabContainer.ctorParameters = function () { return [
- { type: Platform, },
- ]; };
- FabContainer.propDecorators = {
- '_mainButton': [{ type: ContentChild, args: [FabButton,] },],
- '_fabLists': [{ type: ContentChildren, args: [FabList,] },],
- };
- return FabContainer;
- }());
-
- /**
- * @name Col
- * @module ionic
- * @description
- *
- * Columns are cellular components of the [grid](../Grid) system and go inside of a [row](../Row).
- * They will expand to fill their row. All content within a grid should go inside of a column.
- *
- * ## Column attributes
- *
- * By default, columns will stretch to fill the entire height of the row.
- * There are several attributes that can be added to a column to customize this behavior.
- *
- * | Property | Description |
- * |-----------------------|-------------------------------------------------------------------------------------------------------------|
- * | align-self-start | Adds `align-self: flex-start`. The column will be vertically aligned at the top. |
- * | align-self-center | Adds `align-self: center`. The column will be vertically aligned in the center. |
- * | align-self-end | Adds `align-self: flex-end`. The column will be vertically aligned at the bottom. |
- * | align-self-stretch | Adds `align-self: stretch`. The column will be stretched to take up the entire height of the row. |
- * | align-self-baseline | Adds `align-self: baseline`. The column will be vertically aligned at its baseline. |
- *
- *
- */
- var Col = (function () {
- function Col() {
- }
- Col.decorators = [
- { type: Directive, args: [{
- selector: 'ion-col, [ion-col]',
- host: {
- 'class': 'col'
- }
- },] },
- ];
- /** @nocollapse */
- Col.ctorParameters = function () { return []; };
- return Col;
- }());
-
- /**
- * @name Grid
- * @module ionic
- * @description
- *
- * The grid is a powerful mobile-first flexbox system for building custom layouts.
- * It is heavily influenced by [Bootstrap's grid system](http://v4-alpha.getbootstrap.com/layout/grid/).
- *
- * The grid is composed of three units — a grid, row(s) and column(s). Columns will expand to fill their
- * row, and will resize to fit additional columns. It is based on a 12 column layout with different
- * breakpoints based on the screen size. The number of columns and breakpoints can be fully customized
- * using Sass.
- *
- * - [How it works](#how-it-works)
- * - [Grid size](#grid-size)
- * - [Grid attributes](#grid-attributes)
- * - [Default breakpoints](#default-breakpoints)
- * - [Auto-layout columns](#auto-layout-columns)
- * - [Equal-width](#equal-width)
- * - [Setting one column width](#setting-one-column-width)
- * - [Variable-width](#variable-width)
- * - [Responsive attributes](#responsive-attributes)
- * - [All breakpoints](#all-breakpoints)
- * - [Stacked to horizontal](#stacked-to-horizontal)
- * - [Reordering](#reordering)
- * - [Offsetting columns](#offsetting-columns)
- * - [Push and pull](#push-and-pull)
- * - [Alignment](#alignment)
- * - [Vertical Alignment](#vertical-alignment)
- * - [Horizontal Alignment](#horizontal-alignment)
- * - [Customizing the grid](#customizing-the-grid)
- * - [Number of columns and padding](#number-of-columns-and-padding)
- * - [Grid tiers](#grid-tiers)
- *
- *
- * ## How it works
- *
- * The grid is a mobile-first system made up of any number of rows and columns.
- * It is built with flexbox making it extremely responsive. The components that
- * make up the grid can be written as an element (e.g., `<ion-grid>`) or added as
- * an attribute to any element (e.g., `<div ion-row>`).
- *
- * Here's how it works:
- *
- * - Grids act as a container for all rows and columns. Grids take up the full width of their container,
- * but adding the `fixed` attribute will specify the width per screen size, see [grid size](#grid-size) below.
- * - Rows are horizontal groups of columns that line the columns up properly.
- * - Content should be placed within columns, and only columns may be immediate children of rows.
- * - Grid columns without a specified width will automatically have equal widths.
- * For example, four instances of `col-sm` will each automatically be 25% wide for small breakpoints.
- * - Column attributes indicate the number of columns to use out of the default 12 per row.
- * So, `col-4` can be added in order to have three equal-width columns.
- * - Column widths are set as a percentage, so they’re always fluid and sized relative to their parent element.
- * - Columns have padding between individual columns, however, the padding can be removed from the grid and
- * columns by adding `no-padding` on the grid.
- * - There are five grid tiers by default, one for each responsive breakpoint: all breakpoints (extra small),
- * small, medium, large, and extra large.
- * - Grid tiers are based on minimum widths, meaning they apply to their tier and all those larger than it
- * (e.g., `col-sm-4` applies to small, medium, large, and extra large devices).
- * - Grids can easily be customized via Sass variables. See [customizing the grid](#customizing-the-grid).
- *
- * There are some [known bugs with flexbox](https://github.com/philipwalton/flexbugs) that
- * should be checked prior to creating issues with Ionic.
- *
- * ## Grid size
- *
- * By default, the grid will take up 100% width. To set a maximum width based on the screen
- * size add the `fixed` attribute. The maximum width of the grid for each breakpoint is defined
- * in the `$grid-max-widths` Sass variable. For more information, see
- * [customizing the grid](#customizing-the-grid).
- *
- * | Name | Value | Description |
- * |----------|----------|-----------------------------------------------------|
- * | xs | auto | Don't set the grid width for xs screens |
- * | sm | 540px | Set grid width to 540px when (min-width: 576px) |
- * | md | 720px | Set grid width to 720px when (min-width: 768px) |
- * | lg | 960px | Set grid width to 960px when (min-width: 992px) |
- * | xl | 1140px | Set grid width to 1140px when (min-width: 1200px) |
- *
- *
- * ## Grid attributes
- *
- * The grid takes up full width and has padding added to it based on the screen size. There are two
- * attributes that can be used to adjust this behavior.
- *
- * | Property | Description |
- * |-----------------|-------------------------------------------------------------------------------------------------------------------|
- * | no-padding | Removes padding from the grid and immediate children columns. |
- * | fixed | Set a max width based on the screen size. |
- *
- *
- * ## Default breakpoints
- *
- * The default breakpoints are defined by the `$grid-breakpoints` Sass variable. It can be
- * customized to use different values for the breakpoint, rename and add/remove breakpoints.
- * For more information, see [customizing the grid](#customizing-the-grid).
- *
- * | Name | Value | Width Prefix | Offset Prefix | Push Prefix | Pull Prefix | Description |
- * |----------|----------|--------------|---------------|--------------|-------------|---------------------------------------------------|
- * | xs | 0 | `col-` | `offset-` | `push-` | `pull-` | Set columns when (min-width: 0) |
- * | sm | 576px | `col-sm-` | `offset-sm-` | `push-sm-` | `pull-sm-` | Set columns when (min-width: 576px) |
- * | md | 768px | `col-md-` | `offset-md-` | `push-md-` | `pull-md-` | Set columns when (min-width: 768px) |
- * | lg | 992px | `col-lg-` | `offset-lg-` | `push-lg-` | `pull-lg-` | Set columns when (min-width: 992px) |
- * | xl | 1200px | `col-xl-` | `offset-xl-` | `push-xl-` | `pull-xl-` | Set columns when (min-width: 1200px) |
- *
- * _Note: the first breakpoint must have the value set to 0 and all breakpoint values must be in
- * ascending order._
- *
- * ## Auto-layout columns
- *
- * ### Equal-width
- *
- * By default, columns will take up equal width inside of a row for all devices and screen sizes.
- *
- * ```
- * <ion-grid>
- * <ion-row>
- * <ion-col>
- * 1 of 2
- * </ion-col>
- * <ion-col>
- * 2 of 2
- * </ion-col>
- * </ion-row>
- * <ion-row>
- * <ion-col>
- * 1 of 3
- * </ion-col>
- * <ion-col>
- * 2 of 3
- * </ion-col>
- * <ion-col>
- * 3 of 3
- * </ion-col>
- * </ion-row>
- * </ion-grid>
- * ```
- *
- * ### Setting one column width
- *
- * Set the width of one column and the others will automatically resize around it.
- * This can be done using our predefined grid attributes. In the example below,
- * the other columns will resize no matter the width of the center column.
- *
- * ```
- * <ion-grid>
- * <ion-row>
- * <ion-col>
- * 1 of 3
- * </ion-col>
- * <ion-col col-8>
- * 2 of 3 (wider)
- * </ion-col>
- * <ion-col>
- * 3 of 3
- * </ion-col>
- * </ion-row>
- * <ion-row>
- * <ion-col>
- * 1 of 3
- * </ion-col>
- * <ion-col col-6>
- * 2 of 3 (wider)
- * </ion-col>
- * <ion-col>
- * 3 of 3
- * </ion-col>
- * </ion-row>
- * </ion-grid>
- * ```
- *
- * ### Variable-width
- *
- * Using the `col-{breakpoint}-auto` attributes, the column can size itself based on the
- * natural width of its content. This is extremely useful for setting a column width
- * using pixels. The columns next to the variable-width column will resize to fill the row.
- *
- * ```
- * <ion-grid>
- * <ion-row>
- * <ion-col>
- * 1 of 3
- * </ion-col>
- * <ion-col col-auto>
- * Variable width content
- * </ion-col>
- * <ion-col>
- * 3 of 3
- * </ion-col>
- * </ion-row>
- * <ion-row>
- * <ion-col>
- * 1 of 4
- * </ion-col>
- * <ion-col>
- * 2 of 4
- * </ion-col>
- * <ion-col col-auto>
- * <ion-input placeholder="Variable width input"></ion-input>
- * </ion-col>
- * <ion-col>
- * 4 of 4
- * </ion-col>
- * </ion-row>
- * </ion-grid>
- * ```
- *
- *
- * ## Responsive attributes
- *
- * ### All breakpoints
- *
- * To customize a column's width for all devices and screens, add the `col-*`
- * attribute. These attributes tell the column to take up `*` columns out
- * of the available columns.
- *
- * ```
- * <ion-grid>
- * <ion-row>
- * <ion-col col-4>
- * 1 of 4
- * </ion-col>
- * <ion-col col-2>
- * 2 of 4
- * </ion-col>
- * <ion-col col-2>
- * 3 of 4
- * </ion-col>
- * <ion-col col-4>
- * 4 of 4
- * </ion-col>
- * </ion-row>
- * </ion-grid>
- * ```
- *
- * ### Stacked to horizontal
- *
- * Use a combination of width and breakpoint attributes to create a grid that starts out stacked
- * on extra small screens before becoming horizontal on small screens.
- *
- * ```
- * <ion-grid>
- * <ion-row>
- * <ion-col col-12 col-sm>
- * 1 of 4
- * </ion-col>
- * <ion-col col-12 col-sm>
- * 2 of 4
- * </ion-col>
- * <ion-col col-12 col-sm>
- * 3 of 4
- * </ion-col>
- * <ion-col col-12 col-sm>
- * 4 of 4
- * </ion-col>
- * </ion-row>
- * </ion-grid>
- * ```
- *
- *
- * ## Reordering
- *
- * ### Offsetting columns
- *
- * Move columns to the right by adding the `offset-*` attributes. These attributes
- * increase the margin start of the column by `*` columns. For example, in the following
- * grid the last column will be offset by 3 columns and take up 3 columns:
- *
- * ```
- * <ion-grid>
- * <ion-row>
- * <ion-col col-3>
- * 1 of 2
- * </ion-col>
- * <ion-col col-3 offset-3>
- * 2 of 2
- * </ion-col>
- * </ion-row>
- * </ion-grid>
- * ```
- *
- * Offsets can also be added based on screen breakpoints. Here's an example of a
- * grid where the last column will be offset by 3 columns for `md` screens and up:
- *
- * ```
- * <ion-grid>
- * <ion-row>
- * <ion-col col-md-3>
- * 1 of 3
- * </ion-col>
- * <ion-col col-md-3>
- * 2 of 3
- * </ion-col>
- * <ion-col col-md-3 offset-md-3>
- * 3 of 3
- * </ion-col>
- * </ion-row>
- * </ion-grid>
- * ```
- *
- * ### Push and pull
- *
- * Reorder the columns by adding the `push-*` and `pull-*` attributes. These attributes
- * adjust the `left` and `right` of the columns by `*` columns making it easy to reorder
- * columns. For example, in the following grid the column with the `1st col` description
- * will actually be the last column and the `2nd col` will be the first column.
- *
- * ```
- * <ion-grid>
- * <ion-row>
- * <ion-col col-9 push-3>
- * 1 of 2
- * </ion-col>
- * <ion-col col-3 pull-9>
- * 2 of 2
- * </ion-col>
- * </ion-row>
- * </ion-grid>
- * ```
- *
- * Push and pull can also be added based on screen breakpoints. In the following example,
- * the column with the `3rd` column description will actually be the first column for
- * `md` screens and up:
- *
- * ```
- * <ion-grid>
- * <ion-row>
- * <ion-col col-md-6 push-md-3>
- * 1 of 3
- * </ion-col>
- * <ion-col col-md-3 push-md-3>
- * 2 of 3
- * </ion-col>
- * <ion-col col-md-3 pull-md-9>
- * 3 of 3
- * </ion-col>
- * </ion-row>
- * </ion-grid>
- * ```
- *
- *
- * ## Alignment
- *
- * ### Vertical alignment
- *
- * All columns can be vertically aligned inside of a row by adding different
- * attributes to the row. For a list of available attributes, see
- * [row attributes](../Row#row-attributes).
- *
- * ```
- * <ion-grid>
- * <ion-row align-items-start>
- * <ion-col>
- * 1 of 4
- * </ion-col>
- * <ion-col>
- * 2 of 4
- * </ion-col>
- * <ion-col>
- * 3 of 4
- * </ion-col>
- * <ion-col>
- * 4 of 4 <br>#<br>#<br>#
- * </ion-col>
- * </ion-row>
- *
- * <ion-row align-items-center>
- * <ion-col>
- * 1 of 4
- * </ion-col>
- * <ion-col>
- * 2 of 4
- * </ion-col>
- * <ion-col>
- * 3 of 4
- * </ion-col>
- * <ion-col>
- * 4 of 4 <br>#<br>#<br>#
- * </ion-col>
- * </ion-row>
- *
- * <ion-row align-items-end>
- * <ion-col>
- * 1 of 4
- * </ion-col>
- * <ion-col>
- * 2 of 4
- * </ion-col>
- * <ion-col>
- * 3 of 4
- * </ion-col>
- * <ion-col>
- * 4 of 4 <br>#<br>#<br>#
- * </ion-col>
- * </ion-row>
- * </ion-grid>
- * ```
- *
- * Columns can also align themselves differently than other columns by
- * adding the alignment attribute directly to the column. For a list of available
- * attributes, see [column attributes](../Col#column-attributes).
- *
- * ```
- * <ion-grid>
- * <ion-row>
- * <ion-col align-self-start>
- * <div>
- * 1 of 4
- * </div>
- * </ion-col>
- * <ion-col align-self-center>
- * <div>
- * 2 of 4
- * </div>
- * </ion-col>
- * <ion-col align-self-end>
- * <div>
- * 3 of 4
- * </div>
- * </ion-col>
- * <ion-col>
- * <div>
- * 4 of 4 <br>#<br>#<br>#
- * </div>
- * </ion-col>
- * </ion-row>
- * </ion-grid>
- * ```
- *
- * ### Horizontal alignment
- *
- * All columns can be horizontally aligned inside of a row by adding different
- * attributes to the row. For a list of available attributes, see
- * [row attributes](../Row#row-attributes).
- *
- * ```
- * <ion-grid>
- * <ion-row justify-content-start>
- * <ion-col col-3>
- * 1 of 2
- * </ion-col>
- * <ion-col col-3>
- * 2 of 2
- * </ion-col>
- * </ion-row>
- *
- * <ion-row justify-content-center>
- * <ion-col col-3>
- * 1 of 2
- * </ion-col>
- * <ion-col col-3>
- * 2 of 2
- * </ion-col>
- * </ion-row>
- *
- * <ion-row justify-content-end>
- * <ion-col col-3>
- * 1 of 2
- * </ion-col>
- * <ion-col col-3>
- * 2 of 2
- * </ion-col>
- * </ion-row>
- *
- * <ion-row justify-content-around>
- * <ion-col col-3>
- * 1 of 2
- * </ion-col>
- * <ion-col col-3>
- * 2 of 2
- * </ion-col>
- * </ion-row>
- *
- * <ion-row justify-content-between>
- * <ion-col col-3>
- * 1 of 2
- * </ion-col>
- * <ion-col col-3>
- * 2 of 2
- * </ion-col>
- * </ion-row>
- * </ion-grid>
- * ```
- *
- *
- * ## Customizing the grid
- *
- * Using our built-in grid Sass variables and maps, it’s possible to completely customize
- * the predefined grid attributes. Change the number of breakpoints, the media query values,
- * the number of columns, and more.
- *
- * ### Number of columns and padding
- *
- * The number of grid columns and their padding can be modified via Sass variables.
- * `$grid-columns` is used to generate the widths (in percent) of each individual column.
- * `$grid-padding-width` is used for the padding on the grid, while `$grid-padding-widths`
- * allows breakpoint-specific widths that are divided evenly across `padding-left` and
- * `padding-right` as well as `padding-top` and `padding-bottom` of the grid and columns.
- *
- * ```
- * $grid-columns: 12 !default;
- *
- * $grid-padding-width: 10px !default;
- *
- * $grid-padding-widths: (
- * xs: $grid-padding-width,
- * sm: $grid-padding-width,
- * md: $grid-padding-width,
- * lg: $grid-padding-width,
- * xl: $grid-padding-width
- * ) !default;
- * ```
- *
- * ### Grid tiers
- *
- * To customize the breakpoints and their values, override the values of
- * `$grid-breakpoints` and `$grid-max-widths`. For example, to only use
- * 3 breakpoints, the following could be written:
- *
- * ```
- * $grid-breakpoints: (
- * sm: 0,
- * md: 768px,
- * lg: 1024px
- * );
- *
- * $grid-max-widths: (
- * sm: 420px,
- * md: 720px,
- * lg: 960px
- * );
- * ```
- *
- */
- var Grid = (function () {
- function Grid() {
- }
- Grid.decorators = [
- { type: Directive, args: [{
- selector: 'ion-grid, [ion-grid]',
- host: {
- 'class': 'grid'
- }
- },] },
- ];
- /** @nocollapse */
- Grid.ctorParameters = function () { return []; };
- return Grid;
- }());
-
- /**
- * @name Row
- * @module ionic
- * @description
- *
- * Rows are horizontal components of the [grid](../Grid) system and contain varying numbers of
- * [columns](../Col). They ensure the columns are positioned properly.
- *
- * ## Row attributes
- *
- * By default, columns will stretch to fill the entire height of the row and wrap when necessary.
- * There are several attributes that can be added to a row to customize this behavior.
- *
- * | Property | Description |
- * |-----------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------|
- * | nowrap | Adds `flex-wrap: nowrap`. Forces the columns to a single row. |
- * | wrap-reverse | Adds `flex-wrap: wrap-reverse`. The columns will wrap in reverse. |
- * | align-items-start | Adds `align-items: flex-start`. All columns will be vertically aligned at the top, unless they specify their own alignment. |
- * | align-items-center | Adds `align-items: center`. All columns will be vertically aligned in the center, unless they specify their own alignment. |
- * | align-items-end | Adds `align-items: flex-end`. All columns will be vertically aligned at the bottom, unless they specify their own alignment. |
- * | align-items-stretch | Adds `align-items: stretch`. All columns will be stretched to take up the entire height of the row, unless they specify their own alignment. |
- * | align-items-baseline | Adds `align-items: baseline`. All columns will be vertically aligned at their baselines, unless they specify their own alignment. |
- * | justify-content-start | Adds `justify-content: start`. All columns will be horizontally aligned at the start. |
- * | justify-content-center | Adds `justify-content: center`. All columns will be horizontally aligned at the center. |
- * | justify-content-end | Adds `justify-content: end`. All columns will be horizontally aligned at the end. |
- * | justify-content-around | Adds `justify-content: space-around`. All columns will be horizontally aligned with equal space around them. |
- * | justify-content-between | Adds `justify-content: space-between`. All columns will be horizontally aligned with a half-size space on either end. |
- *
- *
- */
- var Row = (function () {
- function Row() {
- }
- Row.decorators = [
- { type: Directive, args: [{
- selector: 'ion-row, [ion-row]',
- host: {
- 'class': 'row'
- }
- },] },
- ];
- /** @nocollapse */
- Row.ctorParameters = function () { return []; };
- return Row;
- }());
-
- /**
- * @name Img
- * @description
- * Two of the biggest cuprits of scroll jank is starting up a new HTTP
- * request, and rendering images. These two reasons is largely why
- * `ion-img` was created. The standard HTML `img` element is often a large
- * source of these problems, and what makes matters worse is that the app
- * does not have fine-grained control of requests and rendering for each
- * `img` element.
- *
- * The `ion-img` component is similar to the standard `img` element,
- * but it also adds features in order to provide improved performance.
- * Features include only loading images which are visible, using web workers
- * for HTTP requests, preventing jank while scrolling and in-memory caching.
- *
- * Note that `ion-img` also comes with a few more restrictions in comparison
- * to the standard `img` element. A good rule is, if there are only a few
- * images to be rendered on a page, then the standard `img` is probably
- * best. However, if a page has the potential for hundreds or even thousands
- * of images within a scrollable area, then `ion-img` would be better suited
- * for the job.
- *
- * > Note: `ion-img` is only meant to be used inside of [virtual-scroll](/docs/api/components/virtual-scroll/VirtualScroll/)
- *
- *
- * ### Lazy Loading
- *
- * Lazy loading images refers to only loading images which are actually
- * visible within the user's viewport. This also means that images which are
- * not viewable on the initial load would not be downloaded or rendered. Next,
- * as the user scrolls, each image which becomes visible is then requested
- * then rendered on-demand.
- *
- * The benefits of this approach is that unnecessary and resource intensive
- * HTTP requests are not started, valuable bandwidth isn't wasted, and this
- * allows the browser to free up resources which would be wasted on images
- * which are not even viewable. For example, animated GIFs are enourmous
- * performance drains, however, with `ion-img` the app is able to dedicate
- * resources to just the viewable images. But again, if the problems listed
- * above are not problems within your app, then the standard `img` element
- * may be best.
- *
- *
- * ### Image Dimensions
- *
- * By providing image dimensions up front, Ionic is able to accurately size
- * up the image's location within the viewport, which helps lazy load only
- * images which are viewable. Image dimensions can either by set as
- * properties, inline styles, or external stylesheets. It doesn't matter
- * which method of setting dimensions is used, but it's important that somehow
- * each `ion-img` has been given an exact size.
- *
- * For example, by default `<ion-avatar>` and `<ion-thumbnail>` already come
- * with exact sizes when placed within an `<ion-item>`. By giving each image
- * an exact size, this then further locks in the size of each `ion-item`,
- * which again helps improve scroll performance.
- *
- * ```html
- * <!-- dimensions set using attributes -->
- * <ion-img width="80" height="80" src="..."></ion-img>
- *
- * <!-- dimensions set using input properties -->
- * <ion-img [width]="imgWidth" [height]="imgHeight" src="..."></ion-img>
- *
- * <!-- dimensions set using inline styles -->
- * <ion-img style="width: 80px; height: 80px;" src="..."></ion-img>
- * ```
- *
- * Additionally, each `ion-img` uses the `object-fit: cover` CSS property.
- * What this means is that the actual rendered image will center itself within
- * it's container. Or to really get detailed: The image is sized to maintain
- * its aspect ratio while filling the containing element’s entire content box.
- * Its concrete object size is resolved as a cover constraint against the
- * element’s used width and height.
- *
- * ### Future Optimizations
- *
- * Future goals are to place image requests within web workers, and cache
- * images in-memory as datauris. This method has proven to be effective,
- * however there are some current limitations with Cordova which we are
- * currently working on.
- *
- */
- var Img = (function () {
- function Img(_elementRef, _renderer, _plt, _content, _dom) {
- this._elementRef = _elementRef;
- this._renderer = _renderer;
- this._plt = _plt;
- this._content = _content;
- this._dom = _dom;
- /** @internal */
- this._cache = true;
- /** @internal */
- this._w = '';
- /** @internal */
- this._h = '';
- /** @internal */
- this._wQ = '';
- /** @internal */
- this._hQ = '';
- /**
- * @input {string} Set the `alt` attribute which gets assigned to
- * the inner `img` element.
- */
- this.alt = '';
- if (!this._content) {
- console.warn("ion-img can only be used within an ion-content");
- }
- else {
- this._content.addImg(this);
- }
- this._isLoaded(false);
- }
- Object.defineProperty(Img.prototype, "src", {
- /**
- * @input {string} The source of the image.
- */
- get: function () {
- return this._src;
- },
- set: function (newSrc) {
- // if the source hasn't changed, then um, let's not change it
- if (newSrc !== this._src) {
- // we're changing the source
- // so abort any active http requests
- // and render the image empty
- this.reset();
- // update to the new src
- this._src = newSrc;
- // Are they using an actual datauri already,
- // or reset any existing datauri we might be holding onto
- this._hasLoaded = newSrc.indexOf('data:') === 0;
- // run update to kick off requests or render if everything is good
- this.update();
- }
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @hidden
- */
- Img.prototype.reset = function () {
- if (this._requestingSrc) {
- // abort any active requests
- (void 0) /* console.debug */;
- this._srcAttr('');
- this._requestingSrc = null;
- }
- if (this._renderedSrc) {
- // clear out the currently rendered img
- (void 0) /* console.debug */;
- this._renderedSrc = null;
- this._isLoaded(false);
- }
- };
- /**
- * @hidden
- */
- Img.prototype.update = function () {
- var _this = this;
- // only attempt an update if there is an active src
- // and the content containing the image considers it updatable
- if (this._src && this._content.isImgsUpdatable()) {
- if (this.canRequest && (this._src !== this._renderedSrc && this._src !== this._requestingSrc) && !this._hasLoaded) {
- // only begin the request if we "can" request
- // begin the image request if the src is different from the rendered src
- // and if we don't already has a tmpDataUri
- (void 0) /* console.debug */;
- this._requestingSrc = this._src;
- this._isLoaded(false);
- this._srcAttr(this._src);
- // set the dimensions of the image if we do have different data
- this._setDims();
- }
- if (this.canRender && this._hasLoaded && this._src !== this._renderedSrc) {
- // we can render and we have a datauri to render
- this._renderedSrc = this._src;
- this._setDims();
- this._dom.write(function () {
- if (_this._hasLoaded) {
- (void 0) /* console.debug */;
- _this._isLoaded(true);
- _this._srcAttr(_this._src);
- }
- });
- }
- }
- };
- /**
- * @internal
- */
- Img.prototype._isLoaded = function (isLoaded) {
- var renderer = this._renderer;
- var ele = this._elementRef.nativeElement;
- renderer.setElementClass(ele, 'img-loaded', isLoaded);
- renderer.setElementClass(ele, 'img-unloaded', !isLoaded);
- };
- /**
- * @internal
- */
- Img.prototype._srcAttr = function (srcAttr) {
- var imgEle = this._img;
- var renderer = this._renderer;
- if (imgEle && imgEle.src !== srcAttr) {
- renderer.setElementAttribute(this._img, 'src', srcAttr);
- renderer.setElementAttribute(this._img, 'alt', this.alt);
- }
- };
- Object.defineProperty(Img.prototype, "top", {
- /**
- * @hidden
- */
- get: function () {
- var bounds = this._getBounds();
- return bounds && bounds.top || 0;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Img.prototype, "bottom", {
- /**
- * @hidden
- */
- get: function () {
- var bounds = this._getBounds();
- return bounds && bounds.bottom || 0;
- },
- enumerable: true,
- configurable: true
- });
- Img.prototype._getBounds = function () {
- if (this._bounds) {
- // we've been manually passed bounds data
- // this is probably from Virtual Scroll items
- return this._bounds;
- }
- if (!this._rect) {
- // we don't have bounds from virtual scroll
- // so let's do the raw DOM lookup w/ getBoundingClientRect
- this._rect = this._elementRef.nativeElement.getBoundingClientRect();
- (void 0) /* console.debug */;
- }
- return this._rect;
- };
- Object.defineProperty(Img.prototype, "bounds", {
- /**
- * @input {any} Sets the bounding rectangle of the element relative to the viewport.
- * When using `VirtualScroll`, each virtual item should pass its bounds to each
- * `ion-img`. The passed in data object should include `top` and `bottom` properties.
- */
- set: function (b) {
- if (isPresent(b)) {
- this._bounds = b;
- }
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Img.prototype, "cache", {
- /**
- * @input {boolean} After an image has been successfully downloaded, it can be cached
- * in-memory. This is useful for `VirtualScroll` by allowing image responses to be
- * cached, and not rendered, until after scrolling has completed, which allows for
- * smoother scrolling.
- */
- get: function () {
- return this._cache;
- },
- set: function (val) {
- this._cache = isTrueProperty(val);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Img.prototype, "width", {
- /**
- * @input {string} Image width. If this property is not set it's important that
- * the dimensions are still set using CSS. If the dimension is just a number it
- * will assume the `px` unit.
- */
- set: function (val) {
- this._wQ = getUnitValue(val);
- this._setDims();
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Img.prototype, "height", {
- /**
- * @input {string} Image height. If this property is not set it's important that
- * the dimensions are still set using CSS. If the dimension is just a number it
- * will assume the `px` unit.
- */
- set: function (val) {
- this._hQ = getUnitValue(val);
- this._setDims();
- },
- enumerable: true,
- configurable: true
- });
- Img.prototype._setDims = function () {
- var _this = this;
- // only set the dimensions if we can render
- // and only if the dimensions have changed from when we last set it
- if (this.canRender && (this._w !== this._wQ || this._h !== this._hQ)) {
- var wrapperEle = this._elementRef.nativeElement;
- var renderer = this._renderer;
- this._dom.write(function () {
- if (_this._w !== _this._wQ) {
- _this._w = _this._wQ;
- renderer.setElementStyle(wrapperEle, 'width', _this._w);
- }
- if (_this._h !== _this._hQ) {
- _this._h = _this._hQ;
- renderer.setElementStyle(wrapperEle, 'height', _this._h);
- }
- });
- }
- };
- /**
- * @hidden
- */
- Img.prototype.ngAfterContentInit = function () {
- var _this = this;
- this._img = this._elementRef.nativeElement.firstChild;
- this._unreg = this._plt.registerListener(this._img, 'load', function () {
- _this._hasLoaded = true;
- _this.update();
- }, { passive: true });
- };
- /**
- * @hidden
- */
- Img.prototype.ngOnDestroy = function () {
- this._unreg && this._unreg();
- this._content && this._content.removeImg(this);
- };
- Img.decorators = [
- { type: Component, args: [{
- selector: 'ion-img',
- template: '<img>',
- changeDetection: ChangeDetectionStrategy.OnPush,
- encapsulation: ViewEncapsulation.None,
- },] },
- ];
- /** @nocollapse */
- Img.ctorParameters = function () { return [
- { type: ElementRef, },
- { type: Renderer, },
- { type: Platform, },
- { type: Content, decorators: [{ type: Optional },] },
- { type: DomController, },
- ]; };
- Img.propDecorators = {
- 'src': [{ type: Input },],
- 'bounds': [{ type: Input },],
- 'cache': [{ type: Input },],
- 'width': [{ type: Input },],
- 'height': [{ type: Input },],
- 'alt': [{ type: Input },],
- };
- return Img;
- }());
- function getUnitValue(val) {
- if (isPresent(val)) {
- if (typeof val === 'string') {
- if (val.indexOf('%') > -1 || val.indexOf('px') > -1) {
- return val;
- }
- if (val.length) {
- return val + 'px';
- }
- }
- else if (typeof val === 'number') {
- return val + 'px';
- }
- }
- return '';
- }
-
- /**
- * @name InfiniteScroll
- * @description
- * The Infinite Scroll allows you to perform an action when the user
- * scrolls a specified distance from the bottom or top of the page.
- *
- * The expression assigned to the `infinite` event is called when
- * the user scrolls to the specified distance. When this expression
- * has finished its tasks, it should call the `complete()` method
- * on the infinite scroll instance.
- *
- * @usage
- * ```html
- * <ion-content>
- *
- * <ion-list>
- * <ion-item *ngFor="let i of items">{% raw %}{{i}}{% endraw %}</ion-item>
- * </ion-list>
- *
- * <ion-infinite-scroll (ionInfinite)="doInfinite($event)">
- * <ion-infinite-scroll-content></ion-infinite-scroll-content>
- * </ion-infinite-scroll>
- *
- * </ion-content>
- * ```
- *
- * ```ts
- * @Component({...})
- * export class NewsFeedPage {
- * items = [];
- *
- * constructor() {
- * for (let i = 0; i < 30; i++) {
- * this.items.push( this.items.length );
- * }
- * }
- *
- * doInfinite(infiniteScroll) {
- * console.log('Begin async operation');
- *
- * setTimeout(() => {
- * for (let i = 0; i < 30; i++) {
- * this.items.push( this.items.length );
- * }
- *
- * console.log('Async operation has ended');
- * infiniteScroll.complete();
- * }, 500);
- * }
- *
- * }
- * ```
- *
- * ## `waitFor` method of InfiniteScroll
- *
- * In case if your async operation returns promise you can utilize
- * `waitFor` method inside your template.
- *
- * ```html
- * <ion-content>
- *
- * <ion-list>
- * <ion-item *ngFor="let item of items">{{item}}</ion-item>
- * </ion-list>
- *
- * <ion-infinite-scroll (ionInfinite)="$event.waitFor(doInfinite())">
- * <ion-infinite-scroll-content></ion-infinite-scroll-content>
- * </ion-infinite-scroll>
- *
- * </ion-content>
- * ```
- *
- * ```ts
- * @Component({...})
- * export class NewsFeedPage {
- * items = [];
- *
- * constructor() {
- * for (var i = 0; i < 30; i++) {
- * this.items.push( this.items.length );
- * }
- * }
- *
- * doInfinite(): Promise<any> {
- * console.log('Begin async operation');
- *
- * return new Promise((resolve) => {
- * setTimeout(() => {
- * for (var i = 0; i < 30; i++) {
- * this.items.push( this.items.length );
- * }
- *
- * console.log('Async operation has ended');
- * resolve();
- * }, 500);
- * })
- * }
- * }
- * ```
- *
- * ## Infinite Scroll Content
- *
- * By default, Ionic uses the infinite scroll spinner that looks
- * best for the platform the user is on. However, you can change the
- * default spinner or add text by adding properties to the
- * `ion-infinite-scroll-content` component.
- *
- * ```html
- * <ion-content>
- *
- * <ion-infinite-scroll (ionInfinite)="doInfinite($event)">
- * <ion-infinite-scroll-content
- * loadingSpinner="bubbles"
- * loadingText="Loading more data...">
- * </ion-infinite-scroll-content>
- * </ion-infinite-scroll>
- *
- * </ion-content>
- * ```
- *
- *
- * ## Further Customizing Infinite Scroll Content
- *
- * The `ion-infinite-scroll` component holds the infinite scroll logic.
- * It requires a child component in order to display the content.
- * Ionic uses `ion-infinite-scroll-content` by default. This component
- * displays the infinite scroll and changes the look depending
- * on the infinite scroll's state. Separating these components allows
- * developers to create their own infinite scroll content components.
- * You could replace our default content with custom SVG or CSS animations.
- *
- * @demo /docs/demos/src/infinite-scroll/
- *
- */
- var InfiniteScroll = (function () {
- function InfiniteScroll(_content, _zone, _elementRef, _dom) {
- this._content = _content;
- this._zone = _zone;
- this._elementRef = _elementRef;
- this._dom = _dom;
- this._lastCheck = 0;
- this._highestY = 0;
- this._thr = '15%';
- this._thrPx = 0;
- this._thrPc = 0.15;
- this._position = POSITION_BOTTOM;
- this._init = false;
- /**
- * @internal
- */
- this.state = STATE_ENABLED;
- /**
- * @output {event} Emitted when the scroll reaches
- * the threshold distance. From within your infinite handler,
- * you must call the infinite scroll's `complete()` method when
- * your async operation has completed.
- */
- this.ionInfinite = new EventEmitter();
- _content.setElementClass('has-infinite-scroll', true);
- }
- Object.defineProperty(InfiniteScroll.prototype, "threshold", {
- /**
- * @input {string} The threshold distance from the bottom
- * of the content to call the `infinite` output event when scrolled.
- * The threshold value can be either a percent, or
- * in pixels. For example, use the value of `10%` for the `infinite`
- * output event to get called when the user has scrolled 10%
- * from the bottom of the page. Use the value `100px` when the
- * scroll is within 100 pixels from the bottom of the page.
- * Default is `15%`.
- */
- get: function () {
- return this._thr;
- },
- set: function (val) {
- this._thr = val;
- if (val.indexOf('%') > -1) {
- this._thrPx = 0;
- this._thrPc = (parseFloat(val) / 100);
- }
- else {
- this._thrPx = parseFloat(val);
- this._thrPc = 0;
- }
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(InfiniteScroll.prototype, "enabled", {
- /**
- * @input {boolean} If true, Whether or not the infinite scroll should be
- * enabled or not. Setting to `false` will remove scroll event listeners
- * and hide the display.
- */
- set: function (shouldEnable) {
- this.enable(shouldEnable);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(InfiniteScroll.prototype, "position", {
- /**
- * @input {string} The position of the infinite scroll element.
- * The value can be either `top` or `bottom`.
- * Default is `bottom`.
- */
- get: function () {
- return this._position;
- },
- set: function (val) {
- if (val === POSITION_TOP || val === POSITION_BOTTOM) {
- this._position = val;
- }
- else {
- console.error("Invalid value for ion-infinite-scroll's position input. Its value should be '" + POSITION_BOTTOM + "' or '" + POSITION_TOP + "'.");
- }
- },
- enumerable: true,
- configurable: true
- });
- InfiniteScroll.prototype._onScroll = function (ev) {
- var _this = this;
- if (this.state === STATE_LOADING || this.state === STATE_DISABLED) {
- return 1;
- }
- if (this._lastCheck + 32 > ev.timeStamp) {
- // no need to check less than every XXms
- return 2;
- }
- this._lastCheck = ev.timeStamp;
- // ******** DOM READ ****************
- var infiniteHeight = this._elementRef.nativeElement.scrollHeight;
- if (!infiniteHeight) {
- // if there is no height of this element then do nothing
- return 3;
- }
- // ******** DOM READ ****************
- var d = this._content.getContentDimensions();
- var height = d.contentHeight;
- var threshold = this._thrPc ? (height * this._thrPc) : this._thrPx;
- // ******** DOM READS ABOVE / DOM WRITES BELOW ****************
- var distanceFromInfinite;
- if (this._position === POSITION_BOTTOM) {
- distanceFromInfinite = d.scrollHeight - infiniteHeight - d.scrollTop - height - threshold;
- }
- else {
- (void 0) /* assert */;
- distanceFromInfinite = d.scrollTop - infiniteHeight - threshold;
- }
- if (distanceFromInfinite < 0) {
- // ******** DOM WRITE ****************
- this._dom.write(function () {
- _this._zone.run(function () {
- if (_this.state !== STATE_LOADING && _this.state !== STATE_DISABLED) {
- _this.state = STATE_LOADING;
- _this.ionInfinite.emit(_this);
- }
- });
- });
- return 5;
- }
- return 6;
- };
- /**
- * Call `complete()` within the `infinite` output event handler when
- * your async operation has completed. For example, the `loading`
- * state is while the app is performing an asynchronous operation,
- * such as receiving more data from an AJAX request to add more items
- * to a data list. Once the data has been received and UI updated, you
- * then call this method to signify that the loading has completed.
- * This method will change the infinite scroll's state from `loading`
- * to `enabled`.
- */
- InfiniteScroll.prototype.complete = function () {
- var _this = this;
- if (this.state !== STATE_LOADING) {
- return;
- }
- if (this._position === POSITION_BOTTOM) {
- this.state = STATE_ENABLED;
- return;
- }
- (void 0) /* assert */;
- /* New content is being added at the top, but the scrollTop position stays the same,
- which causes a scroll jump visually. This algorithm makes sure to prevent this.
-
- (Frame 1)
- complete() is called, but the UI hasn't had time to update yet.
- Save the current content dimensions.
- Wait for the next frame using _dom.read, so the UI will be updated.
-
- (Frame 2)
- Read the new content dimensions.
- Calculate the height difference and the new scroll position.
- Delay the scroll position change until other possible dom reads are done using _dom.write to be performant.
-
- (Still frame 2, if I'm correct)
- Change the scroll position (= visually maintain the scroll position).
- Change the state to re-enable the InfiniteScroll. This should be after changing the scroll position, or it could cause the InfiniteScroll to be triggered again immediately.
-
- (Frame 3)
- Done.
- */
- // ******** DOM READ ****************
- // Save the current content dimensions before the UI updates
- var prevDim = this._content.getContentDimensions();
- // ******** DOM READ ****************
- this._dom.read(function () {
- // UI has updated, save the new content dimensions
- var newDim = _this._content.getContentDimensions();
- // New content was added on top, so the scroll position should be changed immediately to prevent it from jumping around
- var newScrollTop = newDim.scrollHeight - (prevDim.scrollHeight - prevDim.scrollTop);
- // ******** DOM WRITE ****************
- _this._dom.write(function () {
- _this._content.scrollTop = newScrollTop;
- _this.state = STATE_ENABLED;
- });
- });
- };
- /**
- * Pass a promise inside `waitFor()` within the `infinite` output event handler in order to
- * change state of infiniteScroll to "complete"
- */
- InfiniteScroll.prototype.waitFor = function (action) {
- var enable = this.complete.bind(this);
- action.then(enable, enable);
- };
- /**
- * Call `enable(false)` to disable the infinite scroll from actively
- * trying to receive new data while scrolling. This method is useful
- * when it is known that there is no more data that can be added, and
- * the infinite scroll is no longer needed.
- * @param {boolean} shouldEnable If the infinite scroll should be
- * enabled or not. Setting to `false` will remove scroll event listeners
- * and hide the display.
- */
- InfiniteScroll.prototype.enable = function (shouldEnable) {
- this.state = (shouldEnable ? STATE_ENABLED : STATE_DISABLED);
- this._setListeners(shouldEnable);
- };
- /**
- * @hidden
- */
- InfiniteScroll.prototype._setListeners = function (shouldListen) {
- if (this._init) {
- if (shouldListen) {
- if (!this._scLsn) {
- this._scLsn = this._content.ionScroll.subscribe(this._onScroll.bind(this));
- }
- }
- else {
- this._scLsn && this._scLsn.unsubscribe();
- this._scLsn = null;
- }
- }
- };
- /**
- * @hidden
- */
- InfiniteScroll.prototype.ngAfterContentInit = function () {
- this._init = true;
- this._setListeners(this.state !== STATE_DISABLED);
- if (this._position === POSITION_TOP) {
- this._content.scrollDownOnLoad = true;
- }
- };
- /**
- * @hidden
- */
- InfiniteScroll.prototype.ngOnDestroy = function () {
- this._setListeners(false);
- };
- InfiniteScroll.decorators = [
- { type: Directive, args: [{
- selector: 'ion-infinite-scroll'
- },] },
- ];
- /** @nocollapse */
- InfiniteScroll.ctorParameters = function () { return [
- { type: Content, },
- { type: NgZone, },
- { type: ElementRef, },
- { type: DomController, },
- ]; };
- InfiniteScroll.propDecorators = {
- 'threshold': [{ type: Input },],
- 'enabled': [{ type: Input },],
- 'position': [{ type: Input },],
- 'ionInfinite': [{ type: Output },],
- };
- return InfiniteScroll;
- }());
- var STATE_ENABLED = 'enabled';
- var STATE_DISABLED = 'disabled';
- var STATE_LOADING = 'loading';
- var POSITION_TOP = 'top';
- var POSITION_BOTTOM = 'bottom';
-
- /**
- * @hidden
- */
- var InfiniteScrollContent = (function () {
- function InfiniteScrollContent(inf, _config) {
- this.inf = inf;
- this._config = _config;
- }
- /**
- * @hidden
- */
- InfiniteScrollContent.prototype.ngOnInit = function () {
- if (!this.loadingSpinner) {
- this.loadingSpinner = this._config.get('infiniteLoadingSpinner', this._config.get('spinner', 'ios'));
- }
- };
- InfiniteScrollContent.decorators = [
- { type: Component, args: [{
- selector: 'ion-infinite-scroll-content',
- template: '<div class="infinite-loading">' +
- '<div class="infinite-loading-spinner" *ngIf="loadingSpinner">' +
- '<ion-spinner [name]="loadingSpinner"></ion-spinner>' +
- '</div>' +
- '<div class="infinite-loading-text" [innerHTML]="loadingText" *ngIf="loadingText"></div>' +
- '</div>',
- host: {
- '[attr.state]': 'inf.state'
- },
- encapsulation: ViewEncapsulation.None,
- },] },
- ];
- /** @nocollapse */
- InfiniteScrollContent.ctorParameters = function () { return [
- { type: InfiniteScroll, },
- { type: Config, },
- ]; };
- InfiniteScrollContent.propDecorators = {
- 'loadingSpinner': [{ type: Input },],
- 'loadingText': [{ type: Input },],
- };
- return InfiniteScrollContent;
- }());
-
- var __extends$49 = (commonjsGlobal && commonjsGlobal.__extends) || function (d, b) {
- for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
-
-
- /**
- * Emits the values emitted by the source Observable until a `notifier`
- * Observable emits a value.
- *
- * <span class="informal">Lets values pass until a second Observable,
- * `notifier`, emits something. Then, it completes.</span>
- *
- * <img src="./img/takeUntil.png" width="100%">
- *
- * `takeUntil` subscribes and begins mirroring the source Observable. It also
- * monitors a second Observable, `notifier` that you provide. If the `notifier`
- * emits a value or a complete notification, the output Observable stops
- * mirroring the source Observable and completes.
- *
- * @example <caption>Tick every second until the first click happens</caption>
- * var interval = Rx.Observable.interval(1000);
- * var clicks = Rx.Observable.fromEvent(document, 'click');
- * var result = interval.takeUntil(clicks);
- * result.subscribe(x => console.log(x));
- *
- * @see {@link take}
- * @see {@link takeLast}
- * @see {@link takeWhile}
- * @see {@link skip}
- *
- * @param {Observable} notifier The Observable whose first emitted value will
- * cause the output Observable of `takeUntil` to stop emitting values from the
- * source Observable.
- * @return {Observable<T>} An Observable that emits the values from the source
- * Observable until such time as `notifier` emits its first value.
- * @method takeUntil
- * @owner Observable
- */
- function takeUntil$2(notifier) {
- return this.lift(new TakeUntilOperator(notifier));
- }
- var takeUntil_2 = takeUntil$2;
- var TakeUntilOperator = (function () {
- function TakeUntilOperator(notifier) {
- this.notifier = notifier;
- }
- TakeUntilOperator.prototype.call = function (subscriber, source) {
- return source.subscribe(new TakeUntilSubscriber(subscriber, this.notifier));
- };
- return TakeUntilOperator;
- }());
- /**
- * We need this JSDoc comment for affecting ESDoc.
- * @ignore
- * @extends {Ignored}
- */
- var TakeUntilSubscriber = (function (_super) {
- __extends$49(TakeUntilSubscriber, _super);
- function TakeUntilSubscriber(destination, notifier) {
- _super.call(this, destination);
- this.notifier = notifier;
- this.add(subscribeToResult_1.subscribeToResult(this, notifier));
- }
- TakeUntilSubscriber.prototype.notifyNext = function (outerValue, innerValue, outerIndex, innerIndex, innerSub) {
- this.complete();
- };
- TakeUntilSubscriber.prototype.notifyComplete = function () {
- // noop
- };
- return TakeUntilSubscriber;
- }(OuterSubscriber_1.OuterSubscriber));
-
- var takeUntil_1 = {
- takeUntil: takeUntil_2
- };
-
- Observable_1.Observable.prototype.takeUntil = takeUntil_1.takeUntil;
-
- var __extends$48 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @name Input
- * @description
- *
- * `ion-input` is meant for text type inputs only, such as `text`,
- * `password`, `email`, `number`, `search`, `tel`, and `url`. Ionic
- * still uses an actual `<input type="text">` HTML element within the
- * component, however, with Ionic wrapping the native HTML input
- * element it's better able to handle the user experience and
- * interactivity.
- *
- * Similarly, `<ion-textarea>` should be used in place of `<textarea>`.
- *
- * An `ion-input` is **not** used for non-text type inputs, such as a
- * `checkbox`, `radio`, `toggle`, `range`, `select`, etc.
- *
- * Along with the blur/focus events, `input` support all standard text input
- * events like `keyup`, `keydown`, `keypress`, `input`,etc. Any standard event
- * can be attached and will function as expected.
- *
- * @usage
- * ```html
- * <ion-list>
- * <ion-item>
- * <ion-label color="primary">Inline Label</ion-label>
- * <ion-input placeholder="Text Input"></ion-input>
- * </ion-item>
- *
- * <ion-item>
- * <ion-label color="primary" fixed>Fixed Label</ion-label>
- * <ion-input type="tel" placeholder="Tel Input"></ion-input>
- * </ion-item>
- *
- * <ion-item>
- * <ion-input type="number" placeholder="Number Input with no label"></ion-input>
- * </ion-item>
- *
- * <ion-item>
- * <ion-label color="primary" stacked>Stacked Label</ion-label>
- * <ion-input type="email" placeholder="Email Input"></ion-input>
- * </ion-item>
- *
- * <ion-item>
- * <ion-label color="primary" stacked>Stacked Label</ion-label>
- * <ion-input type="password" placeholder="Password Input"></ion-input>
- * </ion-item>
- *
- * <ion-item>
- * <ion-label color="primary" floating>Floating Label</ion-label>
- * <ion-input></ion-input>
- * </ion-item>
- *
- * <ion-item>
- * <ion-input placeholder="Clear Input" clearInput></ion-input>
- * </ion-item>
- *
- * <ion-item>
- * <ion-textarea placeholder="Enter a description"></ion-textarea>
- * </ion-item>
- * </ion-list>
- * ```
- *
- * @demo /docs/demos/src/input/
- */
- var TextInput = (function (_super) {
- __extends$48(TextInput, _super);
- function TextInput(config, _plt, _form, _app, elementRef, renderer, _content, _item, ngControl, _dom) {
- var _this = _super.call(this, config, elementRef, renderer, 'input', '', _form, _item, ngControl) || this;
- _this._plt = _plt;
- _this._app = _app;
- _this._content = _content;
- _this.ngControl = ngControl;
- _this._dom = _dom;
- _this._clearInput = false;
- _this._readonly = false;
- _this._type = 'text';
- _this._isTextarea = false;
- _this._onDestroy = new Subject_2();
- _this._useAssist = false;
- _this._relocated = false;
- /**
- * @input {string} Set the input's autocomplete property. Values: `"on"`, `"off"`. Default `"off"`.
- */
- _this.autocomplete = '';
- /**
- * @input {string} Set the input's autocorrect property. Values: `"on"`, `"off"`. Default `"off"`.
- */
- _this.autocorrect = '';
- /**
- * @input {string} Instructional text that shows before the input has a value.
- */
- _this.placeholder = '';
- /**
- * @input {any} The minimum value, which must not be greater than its maximum (max attribute) value.
- */
- _this.min = null;
- /**
- * @input {any} The maximum value, which must not be less than its minimum (min attribute) value.
- */
- _this.max = null;
- /**
- * @input {any} Works with the min and max attributes to limit the increments at which a value can be set.
- */
- _this.step = null;
- /**
- * @hidden
- */
- _this.input = new EventEmitter();
- /**
- * @hidden
- */
- _this.blur = new EventEmitter();
- /**
- * @hidden
- */
- _this.focus = new EventEmitter();
- _this.autocomplete = config.get('autocomplete', 'off');
- _this.autocorrect = config.get('autocorrect', 'off');
- _this._autoFocusAssist = config.get('autoFocusAssist', 'delay');
- _this._keyboardHeight = config.getNumber('keyboardHeight');
- _this._isTextarea = !!(elementRef.nativeElement.tagName === 'ION-TEXTAREA');
- if (_this._isTextarea && _item) {
- _item.setElementClass('item-textarea', true);
- }
- // If not inside content, let's disable all the hacks
- if (!_content) {
- return _this;
- }
- var hideCaretOnScroll = config.getBoolean('hideCaretOnScroll', false);
- if (hideCaretOnScroll) {
- _this._enableHideCaretOnScroll();
- }
- var win = _plt.win();
- var keyboardPlugin = win.Ionic && win.Ionic.keyboardPlugin;
- if (keyboardPlugin) {
- var keyboardResizes = config.getBoolean('keyboardResizes', false);
- if (keyboardResizes) {
- _this._keyboardHeight = config.getNumber('keyboardSafeArea', 60);
- _this._enableScrollMove();
- }
- else {
- _this._enableScrollPadding();
- _this._enableScrollMove();
- }
- }
- else {
- _this._useAssist = config.getBoolean('scrollAssist', false);
- var usePadding = config.getBoolean('scrollPadding', _this._useAssist);
- if (usePadding) {
- _this._enableScrollPadding();
- }
- }
- return _this;
- }
- Object.defineProperty(TextInput.prototype, "clearInput", {
- /**
- * @input {boolean} If true, a clear icon will appear in the input when there is a value. Clicking it clears the input.
- */
- get: function () {
- return this._clearInput;
- },
- set: function (val) {
- this._clearInput = (!this._isTextarea && isTrueProperty(val));
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(TextInput.prototype, "type", {
- /**
- * @input {string} The type of control to display. The default type is text.
- * Possible values are: `"text"`, `"password"`, `"email"`, `"number"`, `"search"`, `"tel"`, or `"url"`.
- */
- get: function () {
- return (this._isTextarea)
- ? 'text'
- : this._type;
- },
- set: function (val) {
- this._type = val;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(TextInput.prototype, "readonly", {
- /**
- * @input {boolean} If true, the user cannot modify the value.
- */
- get: function () {
- return this._readonly;
- },
- set: function (val) {
- this._readonly = isTrueProperty(val);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(TextInput.prototype, "clearOnEdit", {
- /**
- * @input {boolean} If true, the value will be cleared after focus upon edit.
- * Defaults to `true` when `type` is `"password"`, `false` for all other types.
- */
- get: function () {
- return this._clearOnEdit;
- },
- set: function (val) {
- this._clearOnEdit = isTrueProperty(val);
- },
- enumerable: true,
- configurable: true
- });
- TextInput.prototype.ngAfterContentInit = function () { };
- /**
- * @hidden
- */
- TextInput.prototype.ngAfterViewInit = function () {
- (void 0) /* assert */;
- // By default, password inputs clear after focus when they have content
- if (this.clearOnEdit !== false && this.type === 'password') {
- this.clearOnEdit = true;
- }
- var ionInputEle = this._elementRef.nativeElement;
- var nativeInputEle = this._native.nativeElement;
- // Copy remaining attributes, not handled by ionic/angular
- copyInputAttributes(ionInputEle, nativeInputEle);
- // prevent having tabIndex duplicated
- if (ionInputEle.hasAttribute('tabIndex')) {
- ionInputEle.removeAttribute('tabIndex');
- }
- // handle the autofocus attribute
- if (ionInputEle.hasAttribute('autofocus')) {
- ionInputEle.removeAttribute('autofocus');
- switch (this._autoFocusAssist) {
- case 'immediate':
- // config says to immediate focus on the input
- // works best on android devices
- nativeInputEle.focus();
- break;
- case 'delay':
- // config says to chill out a bit and focus on the input after transitions
- // works best on desktop
- this._plt.timeout(function () { return nativeInputEle.focus(); }, 800);
- break;
- }
- // traditionally iOS has big issues with autofocus on actual devices
- // autoFocus is disabled by default with the iOS mode config
- }
- // Initialize the input (can start emitting events)
- this._initialize();
- if (this.focus.observers.length > 0) {
- console.warn('(focus) is deprecated in ion-input, use (ionFocus) instead');
- }
- if (this.blur.observers.length > 0) {
- console.warn('(blur) is deprecated in ion-input, use (ionBlur) instead');
- }
- };
- /**
- * @hidden
- */
- TextInput.prototype.ngOnDestroy = function () {
- _super.prototype.ngOnDestroy.call(this);
- this._onDestroy.next();
- this._onDestroy = null;
- };
- /**
- * @hidden
- */
- TextInput.prototype.initFocus = function () {
- this.setFocus();
- };
- /**
- * @hidden
- */
- TextInput.prototype.setFocus = function () {
- // let's set focus to the element
- // but only if it does not already have focus
- if (!this.isFocus()) {
- this._native.nativeElement.focus();
- }
- };
- /**
- * @hidden
- */
- TextInput.prototype.setBlur = function () {
- if (this.isFocus()) {
- this._native.nativeElement.blur();
- }
- };
- /**
- * @hidden
- */
- TextInput.prototype.onInput = function (ev) {
- this.value = ev.target.value;
- // TODO: deprecate this
- this.input.emit(ev);
- };
- /**
- * @hidden
- */
- TextInput.prototype.onBlur = function (ev) {
- this._fireBlur();
- // TODO: deprecate this (06/07/2017)
- this.blur.emit(ev);
- this._scrollData = null;
- if (this._clearOnEdit && this.hasValue()) {
- this._didBlurAfterEdit = true;
- }
- };
- /**
- * @hidden
- */
- TextInput.prototype.onFocus = function (ev) {
- this._fireFocus();
- // TODO: deprecate this (06/07/2017)
- this.focus.emit(ev);
- };
- /**
- * @hidden
- */
- TextInput.prototype.onKeydown = function (ev) {
- if (ev && this._clearOnEdit) {
- this.checkClearOnEdit(ev.target.value);
- }
- };
- /**
- * @hidden
- */
- TextInput.prototype._inputUpdated = function () {
- _super.prototype._inputUpdated.call(this);
- var inputEle = this._native.nativeElement;
- var value = this._value;
- if (inputEle.value !== value) {
- inputEle.value = value;
- }
- };
- /**
- * @hidden
- */
- TextInput.prototype.clearTextInput = function () {
- this.value = '';
- };
- /**
- * Check if we need to clear the text input if clearOnEdit is enabled
- * @hidden
- */
- TextInput.prototype.checkClearOnEdit = function (_) {
- if (!this._clearOnEdit) {
- return;
- }
- // Did the input value change after it was blurred and edited?
- if (this._didBlurAfterEdit && this.hasValue()) {
- // Clear the input
- this.clearTextInput();
- }
- // Reset the flag
- this._didBlurAfterEdit = false;
- };
- TextInput.prototype._getScrollData = function () {
- if (!this._content) {
- return newScrollData();
- }
- // get container of this input, probably an ion-item a few nodes up
- if (this._scrollData) {
- return this._scrollData;
- }
- var ele = this._elementRef.nativeElement;
- ele = ele.closest('ion-item,[ion-item]') || ele;
- return this._scrollData = getScrollData(ele.offsetTop, ele.offsetHeight, this._content.getContentDimensions(), this._keyboardHeight, this._plt.height());
- };
- TextInput.prototype._relocateInput = function (shouldRelocate) {
- if (this._relocated === shouldRelocate) {
- return;
- }
- var platform = this._plt;
- var componentEle = this.getNativeElement();
- var focusedInputEle = this._native.nativeElement;
- (void 0) /* console.debug */;
- if (shouldRelocate) {
- // this allows for the actual input to receive the focus from
- // the user's touch event, but before it receives focus, it
- // moves the actual input to a location that will not screw
- // up the app's layout, and does not allow the native browser
- // to attempt to scroll the input into place (messing up headers/footers)
- // the cloned input fills the area of where native input should be
- // while the native input fakes out the browser by relocating itself
- // before it receives the actual focus event
- // We hide the focused input (with the visible caret) invisiable by making it scale(0),
- cloneInputComponent(platform, componentEle, focusedInputEle);
- var inputRelativeY = this._getScrollData().inputSafeY;
- // fix for #11817
- var tx = this._plt.isRTL ? 9999 : -9999;
- focusedInputEle.style[platform.Css.transform] = "translate3d(" + tx + "px," + inputRelativeY + "px,0)";
- focusedInputEle.style.opacity = '0';
- }
- else {
- removeClone(platform, componentEle, focusedInputEle);
- }
- this._relocated = shouldRelocate;
- };
- TextInput.prototype._enableScrollPadding = function () {
- var _this = this;
- (void 0) /* assert */;
- (void 0) /* console.debug */;
- this.ionFocus.subscribe(function () {
- var content = _this._content;
- var scrollPadding = _this._getScrollData().scrollPadding;
- content.addScrollPadding(scrollPadding);
- content.clearScrollPaddingFocusOut();
- });
- };
- TextInput.prototype._enableHideCaretOnScroll = function () {
- var _this = this;
- (void 0) /* assert */;
- var content = this._content;
- (void 0) /* console.debug */;
- content.ionScrollStart
- .takeUntil(this._onDestroy)
- .subscribe(function () { return scrollHideCaret(true); });
- content.ionScrollEnd
- .takeUntil(this._onDestroy)
- .subscribe(function () { return scrollHideCaret(false); });
- this.ionBlur.subscribe(function () { return _this._relocateInput(false); });
- var self = this;
- function scrollHideCaret(shouldHideCaret) {
- // if it does have focus, then do the dom write
- if (self.isFocus()) {
- self._dom.write(function () { return self._relocateInput(shouldHideCaret); });
- }
- }
- };
- TextInput.prototype._enableScrollMove = function () {
- var _this = this;
- (void 0) /* assert */;
- (void 0) /* console.debug */;
- this.ionFocus.subscribe(function () {
- var scrollData = _this._getScrollData();
- if (Math.abs(scrollData.scrollAmount) > 4) {
- _this._content.scrollTo(0, scrollData.scrollTo, scrollData.scrollDuration);
- }
- });
- };
- TextInput.prototype._pointerStart = function (ev) {
- (void 0) /* assert */;
- // input cover touchstart
- if (ev.type === 'touchstart') {
- this._isTouch = true;
- }
- if ((this._isTouch || (!this._isTouch && ev.type === 'mousedown')) && this._app.isEnabled()) {
- // remember where the touchstart/mousedown started
- this._coord = pointerCoord(ev);
- }
- (void 0) /* console.debug */;
- };
- TextInput.prototype._pointerEnd = function (ev) {
- (void 0) /* assert */;
- // input cover touchend/mouseup
- (void 0) /* console.debug */;
- if ((this._isTouch && ev.type === 'mouseup') || !this._app.isEnabled()) {
- // the app is actively doing something right now
- // don't try to scroll in the input
- ev.preventDefault();
- ev.stopPropagation();
- }
- else if (this._coord) {
- // get where the touchend/mouseup ended
- var endCoord = pointerCoord(ev);
- // focus this input if the pointer hasn't moved XX pixels
- // and the input doesn't already have focus
- if (!hasPointerMoved(8, this._coord, endCoord) && !this.isFocus()) {
- ev.preventDefault();
- ev.stopPropagation();
- // begin the input focus process
- this._jsSetFocus();
- }
- }
- this._coord = null;
- };
- TextInput.prototype._jsSetFocus = function () {
- var _this = this;
- (void 0) /* assert */;
- // begin the process of setting focus to the inner input element
- var content = this._content;
- (void 0) /* console.debug */;
- if (!content) {
- // not inside of a scroll view, just focus it
- this.setFocus();
- }
- var scrollData = this._getScrollData();
- if (Math.abs(scrollData.scrollAmount) < 4) {
- // the text input is in a safe position that doesn't
- // require it to be scrolled into view, just set focus now
- this.setFocus();
- return;
- }
- // temporarily move the focus to the focus holder so the browser
- // doesn't freak out while it's trying to get the input in place
- // at this point the native text input still does not have focus
- this._relocateInput(true);
- this.setFocus();
- // scroll the input into place
- content.scrollTo(0, scrollData.scrollTo, scrollData.scrollDuration, function () {
- // the scroll view is in the correct position now
- // give the native text input focus
- _this._relocateInput(false);
- // ensure this is the focused input
- _this.setFocus();
- });
- };
- TextInput.decorators = [
- { type: Component, args: [{
- selector: 'ion-input,ion-textarea',
- template: '<input #textInput *ngIf="!_isTextarea" class="text-input" ' +
- '[ngClass]="\'text-input-\' + _mode"' +
- '(input)="onInput($event)" ' +
- '(blur)="onBlur($event)" ' +
- '(focus)="onFocus($event)" ' +
- '(keydown)="onKeydown($event)" ' +
- '[type]="_type" ' +
- 'dir="auto" ' +
- '[attr.aria-labelledby]="_labelId" ' +
- '[attr.min]="min" ' +
- '[attr.max]="max" ' +
- '[attr.step]="step" ' +
- '[attr.autocomplete]="autocomplete" ' +
- '[attr.autocorrect]="autocorrect" ' +
- '[placeholder]="placeholder" ' +
- '[disabled]="_disabled" ' +
- '[readonly]="_readonly">' +
- '<textarea #textInput *ngIf="_isTextarea" class="text-input" ' +
- '[ngClass]="\'text-input-\' + _mode"' +
- '(input)="onInput($event)" ' +
- '(blur)="onBlur($event)" ' +
- '(focus)="onFocus($event)" ' +
- '(keydown)="onKeydown($event)" ' +
- '[attr.aria-labelledby]="_labelId" ' +
- '[attr.autocomplete]="autocomplete" ' +
- '[attr.autocorrect]="autocorrect" ' +
- '[placeholder]="placeholder" ' +
- '[disabled]="_disabled" ' +
- '[readonly]="_readonly"></textarea>' +
- '<button ion-button *ngIf="_clearInput" clear class="text-input-clear-icon" ' +
- 'type="button" ' +
- '(click)="clearTextInput($event)" ' +
- '(mousedown)="clearTextInput($event)" ' +
- 'tabindex="-1"></button>' +
- '<div class="input-cover" *ngIf="_useAssist" ' +
- '(touchstart)="_pointerStart($event)" ' +
- '(touchend)="_pointerEnd($event)" ' +
- '(mousedown)="_pointerStart($event)" ' +
- '(mouseup)="_pointerEnd($event)"></div>',
- encapsulation: ViewEncapsulation.None,
- changeDetection: ChangeDetectionStrategy.OnPush,
- inputs: ['value']
- },] },
- ];
- /** @nocollapse */
- TextInput.ctorParameters = function () { return [
- { type: Config, },
- { type: Platform, },
- { type: Form, },
- { type: App, },
- { type: ElementRef, },
- { type: Renderer, },
- { type: Content, decorators: [{ type: Optional },] },
- { type: Item, decorators: [{ type: Optional },] },
- { type: NgControl, decorators: [{ type: Optional },] },
- { type: DomController, },
- ]; };
- TextInput.propDecorators = {
- 'clearInput': [{ type: Input },],
- 'type': [{ type: Input },],
- 'readonly': [{ type: Input },],
- 'clearOnEdit': [{ type: Input },],
- '_native': [{ type: ViewChild, args: ['textInput', { read: ElementRef },] },],
- 'autocomplete': [{ type: Input },],
- 'autocorrect': [{ type: Input },],
- 'placeholder': [{ type: Input },],
- 'min': [{ type: Input },],
- 'max': [{ type: Input },],
- 'step': [{ type: Input },],
- 'input': [{ type: Output },],
- 'blur': [{ type: Output },],
- 'focus': [{ type: Output },],
- };
- return TextInput;
- }(BaseInput));
- /**
- * @name TextArea
- * @description
- *
- * `ion-textarea` is used for multi-line text inputs. Ionic still
- * uses an actual `<textarea>` HTML element within the component;
- * however, with Ionic wrapping the native HTML text area element, Ionic
- * is able to better handle the user experience and interactivity.
- *
- * Note that `<ion-textarea>` must load its value from the `value` or
- * `[(ngModel)]` attribute. Unlike the native `<textarea>` element,
- * `<ion-textarea>` does not support loading its value from the
- * textarea's inner content.
- *
- * When requiring only a single-line text input, we recommend using
- * `<ion-input>` instead.
- *
- * @usage
- * ```html
- * <ion-item>
- * <ion-label>Comments</ion-label>
- * <ion-textarea></ion-textarea>
- * </ion-item>
- *
- * <ion-item>
- * <ion-label stacked>Message</ion-label>
- * <ion-textarea [(ngModel)]="msg"></ion-textarea>
- * </ion-item>
- *
- * <ion-item>
- * <ion-label floating>Description</ion-label>
- * <ion-textarea></ion-textarea>
- * </ion-item>
- *
- * <ion-item>
- * <ion-label>Long Description</ion-label>
- * <ion-textarea rows="6" placeholder="enter long description here..."></ion-textarea>
- * </ion-item>
- * ```
- *
- * @demo /docs/demos/src/textarea/
- */
- var SCROLL_ASSIST_SPEED = 0.3;
- function newScrollData() {
- return {
- scrollAmount: 0,
- scrollTo: 0,
- scrollPadding: 0,
- scrollDuration: 0,
- inputSafeY: 0
- };
- }
- /**
- * @hidden
- */
- function getScrollData(inputOffsetTop, inputOffsetHeight, scrollViewDimensions, keyboardHeight, plaformHeight) {
- // compute input's Y values relative to the body
- var inputTop = (inputOffsetTop + scrollViewDimensions.contentTop - scrollViewDimensions.scrollTop);
- var inputBottom = (inputTop + inputOffsetHeight);
- // compute the safe area which is the viewable content area when the soft keyboard is up
- var safeAreaTop = scrollViewDimensions.contentTop;
- var safeAreaHeight = (plaformHeight - keyboardHeight - safeAreaTop) / 2;
- var safeAreaBottom = safeAreaTop + safeAreaHeight;
- // figure out if each edge of teh input is within the safe area
- var inputTopWithinSafeArea = (inputTop >= safeAreaTop && inputTop <= safeAreaBottom);
- var inputTopAboveSafeArea = (inputTop < safeAreaTop);
- var inputTopBelowSafeArea = (inputTop > safeAreaBottom);
- var inputBottomWithinSafeArea = (inputBottom >= safeAreaTop && inputBottom <= safeAreaBottom);
- var inputBottomBelowSafeArea = (inputBottom > safeAreaBottom);
- /*
- Text Input Scroll To Scenarios
- ---------------------------------------
- 1) Input top within safe area, bottom within safe area
- 2) Input top within safe area, bottom below safe area, room to scroll
- 3) Input top above safe area, bottom within safe area, room to scroll
- 4) Input top below safe area, no room to scroll, input smaller than safe area
- 5) Input top within safe area, bottom below safe area, no room to scroll, input smaller than safe area
- 6) Input top within safe area, bottom below safe area, no room to scroll, input larger than safe area
- 7) Input top below safe area, no room to scroll, input larger than safe area
- */
- var scrollData = newScrollData();
- // when auto-scrolling, there also needs to be enough
- // content padding at the bottom of the scroll view
- // always add scroll padding when a text input has focus
- // this allows for the content to scroll above of the keyboard
- // content behind the keyboard would be blank
- // some cases may not need it, but when jumping around it's best
- // to have the padding already rendered so there's no jank
- scrollData.scrollPadding = keyboardHeight;
- if (inputTopWithinSafeArea && inputBottomWithinSafeArea) {
- // Input top within safe area, bottom within safe area
- // no need to scroll to a position, it's good as-is
- return scrollData;
- }
- // looks like we'll have to do some auto-scrolling
- if (inputTopBelowSafeArea || inputBottomBelowSafeArea || inputTopAboveSafeArea) {
- // Input top or bottom below safe area
- // auto scroll the input up so at least the top of it shows
- if (safeAreaHeight > inputOffsetHeight) {
- // safe area height is taller than the input height, so we
- // can bring up the input just enough to show the input bottom
- scrollData.scrollAmount = Math.round(safeAreaBottom - inputBottom);
- }
- else {
- // safe area height is smaller than the input height, so we can
- // only scroll it up so the input top is at the top of the safe area
- // however the input bottom will be below the safe area
- scrollData.scrollAmount = Math.round(safeAreaTop - inputTop);
- }
- scrollData.inputSafeY = -(inputTop - safeAreaTop) + 4;
- if (inputTopAboveSafeArea && scrollData.scrollAmount > inputOffsetHeight) {
- // the input top is above the safe area and we're already scrolling it into place
- // don't let it scroll more than the height of the input
- scrollData.scrollAmount = inputOffsetHeight;
- }
- }
- // figure out where it should scroll to for the best position to the input
- scrollData.scrollTo = (scrollViewDimensions.scrollTop - scrollData.scrollAmount);
- // calculate animation duration
- var distance = Math.abs(scrollData.scrollAmount);
- var duration = distance / SCROLL_ASSIST_SPEED;
- scrollData.scrollDuration = Math.min(400, Math.max(150, duration));
- return scrollData;
- }
- function cloneInputComponent(plt, srcComponentEle, srcNativeInputEle) {
- // Make sure we kill all the clones before creating new ones
- // It is a defensive, removeClone() should do nothing
- // removeClone(plt, srcComponentEle, srcNativeInputEle);
- (void 0) /* assert */;
- // given a native <input> or <textarea> element
- // find its parent wrapping component like <ion-input> or <ion-textarea>
- // then clone the entire component
- if (srcComponentEle) {
- // DOM READ
- var srcTop = srcComponentEle.offsetTop;
- var srcLeft = srcComponentEle.offsetLeft;
- var srcWidth = srcComponentEle.offsetWidth;
- var srcHeight = srcComponentEle.offsetHeight;
- // DOM WRITE
- // not using deep clone so we don't pull in unnecessary nodes
- var clonedComponentEle = srcComponentEle.cloneNode(false);
- var clonedStyle = clonedComponentEle.style;
- clonedComponentEle.classList.add('cloned-input');
- clonedComponentEle.setAttribute('aria-hidden', 'true');
- clonedStyle.pointerEvents = 'none';
- clonedStyle.position = 'absolute';
- clonedStyle.top = srcTop + 'px';
- clonedStyle.left = srcLeft + 'px';
- clonedStyle.width = srcWidth + 'px';
- clonedStyle.height = srcHeight + 'px';
- var clonedNativeInputEle = srcNativeInputEle.cloneNode(false);
- clonedNativeInputEle.value = srcNativeInputEle.value;
- clonedNativeInputEle.tabIndex = -1;
- clonedComponentEle.appendChild(clonedNativeInputEle);
- srcComponentEle.parentNode.appendChild(clonedComponentEle);
- srcComponentEle.style.pointerEvents = 'none';
- }
- srcNativeInputEle.style[plt.Css.transform] = 'scale(0)';
- }
- function removeClone(plt, srcComponentEle, srcNativeInputEle) {
- if (srcComponentEle && srcComponentEle.parentElement) {
- var clonedInputEles = srcComponentEle.parentElement.querySelectorAll('.cloned-input');
- for (var i = 0; i < clonedInputEles.length; i++) {
- clonedInputEles[i].parentNode.removeChild(clonedInputEles[i]);
- }
- srcComponentEle.style.pointerEvents = '';
- }
- srcNativeInputEle.style[plt.Css.transform] = '';
- srcNativeInputEle.style.opacity = '';
- }
-
- /**
- * @hidden
- */
- var ItemContent = (function () {
- function ItemContent() {
- }
- ItemContent.decorators = [
- { type: Directive, args: [{
- selector: 'ion-item,[ion-item]',
- host: {
- 'class': 'item-block'
- }
- },] },
- ];
- /** @nocollapse */
- ItemContent.ctorParameters = function () { return []; };
- return ItemContent;
- }());
-
- var __extends$50 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @hidden
- */
- var ItemDivider = (function (_super) {
- __extends$50(ItemDivider, _super);
- function ItemDivider(config, elementRef, renderer) {
- return _super.call(this, config, elementRef, renderer, 'item-divider') || this;
- }
- ItemDivider.decorators = [
- { type: Directive, args: [{
- selector: 'ion-item-divider',
- host: {
- 'class': 'item-divider'
- }
- },] },
- ];
- /** @nocollapse */
- ItemDivider.ctorParameters = function () { return [
- { type: Config, },
- { type: ElementRef, },
- { type: Renderer, },
- ]; };
- return ItemDivider;
- }(Ion));
-
- /**
- * @hidden
- */
- var ItemGroup = (function () {
- function ItemGroup() {
- }
- ItemGroup.decorators = [
- { type: Directive, args: [{
- selector: 'ion-item-group'
- },] },
- ];
- /** @nocollapse */
- ItemGroup.ctorParameters = function () { return []; };
- return ItemGroup;
- }());
-
- /**
- * @name ItemOptions
- * @description
- * The option buttons for an `ion-item-sliding`. These buttons can be placed either on the left or right side.
- * You can combine the `(ionSwipe)` event plus the `expandable` directive to create a full swipe action for the item.
- *
- * @usage
- *
- * ```html
- * <ion-item-sliding>
- * <ion-item>
- * Item 1
- * </ion-item>
- * <ion-item-options side="right" (ionSwipe)="saveItem(item)">
- * <button ion-button expandable (click)="saveItem(item)">
- * <ion-icon name="star"></ion-icon>
- * </button>
- * </ion-item-options>
- * </ion-item-sliding>
- *```
- */
- var ItemOptions = (function () {
- function ItemOptions(_elementRef, _plt) {
- this._elementRef = _elementRef;
- this._plt = _plt;
- /**
- * @output {event} Emitted when the item has been fully swiped.
- */
- this.ionSwipe = new EventEmitter();
- }
- /**
- * @hidden
- */
- ItemOptions.prototype.isRightSide = function () {
- return isRightSide(this.side, this._plt.isRTL, true);
- };
- /**
- * @hidden
- */
- ItemOptions.prototype.width = function () {
- return this._elementRef.nativeElement.offsetWidth;
- };
- ItemOptions.decorators = [
- { type: Directive, args: [{
- selector: 'ion-item-options',
- },] },
- ];
- /** @nocollapse */
- ItemOptions.ctorParameters = function () { return [
- { type: ElementRef, },
- { type: Platform, },
- ]; };
- ItemOptions.propDecorators = {
- 'side': [{ type: Input },],
- 'ionSwipe': [{ type: Output },],
- };
- return ItemOptions;
- }());
-
- var __extends$52 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @hidden
- */
- var ItemSlidingGesture = (function (_super) {
- __extends$52(ItemSlidingGesture, _super);
- function ItemSlidingGesture(plt, list, gestureCtrl, domCtrl) {
- var _this = _super.call(this, plt, list.getNativeElement(), {
- maxAngle: 20,
- threshold: 5,
- zone: false,
- domController: domCtrl,
- gesture: gestureCtrl.createGesture({
- name: GESTURE_ITEM_SWIPE,
- priority: GESTURE_PRIORITY_SLIDING_ITEM,
- disableScroll: true
- })
- }) || this;
- _this.list = list;
- _this.preSelectedContainer = null;
- _this.selectedContainer = null;
- _this.openContainer = null;
- return _this;
- }
- ItemSlidingGesture.prototype.canStart = function (ev) {
- if (this.selectedContainer) {
- return false;
- }
- // Get swiped sliding container
- var container = getContainer(ev);
- if (!container) {
- this.closeOpened();
- return false;
- }
- // Close open container if it is not the selected one.
- if (container !== this.openContainer) {
- this.closeOpened();
- }
- var coord = pointerCoord(ev);
- this.preSelectedContainer = container;
- this.firstCoordX = coord.x;
- this.firstTimestamp = Date.now();
- return true;
- };
- ItemSlidingGesture.prototype.onDragStart = function (ev) {
- ev.preventDefault();
- var coord = pointerCoord(ev);
- this.selectedContainer = this.openContainer = this.preSelectedContainer;
- this.selectedContainer.startSliding(coord.x);
- };
- ItemSlidingGesture.prototype.onDragMove = function (ev) {
- ev.preventDefault();
- this.selectedContainer.moveSliding(pointerCoord(ev).x);
- };
- ItemSlidingGesture.prototype.onDragEnd = function (ev) {
- ev.preventDefault();
- var coordX = pointerCoord(ev).x;
- var deltaX = (coordX - this.firstCoordX);
- var deltaT = (Date.now() - this.firstTimestamp);
- this.selectedContainer.endSliding(deltaX / deltaT);
- this.selectedContainer = null;
- this.preSelectedContainer = null;
- };
- ItemSlidingGesture.prototype.notCaptured = function (ev) {
- if (!clickedOptionButton(ev)) {
- this.closeOpened();
- }
- };
- ItemSlidingGesture.prototype.closeOpened = function () {
- this.selectedContainer = null;
- if (this.openContainer) {
- this.openContainer.close();
- this.openContainer = null;
- return true;
- }
- return false;
- };
- ItemSlidingGesture.prototype.destroy = function () {
- _super.prototype.destroy.call(this);
- this.closeOpened();
- this.list = null;
- this.preSelectedContainer = null;
- this.selectedContainer = null;
- this.openContainer = null;
- };
- return ItemSlidingGesture;
- }(PanGesture));
- function getContainer(ev) {
- var ele = ev.target.closest('ion-item-sliding');
- if (ele) {
- return ele['$ionComponent'];
- }
- return null;
- }
- function clickedOptionButton(ev) {
- var ele = ev.target.closest('ion-item-options>button');
- return !!ele;
- }
-
- var __extends$51 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * The List is a widely used interface element in almost any mobile app,
- * and can include content ranging from basic text all the way to
- * buttons, toggles, icons, and thumbnails.
- *
- * Both the list, which contains items, and the list items themselves
- * can be any HTML element.
- *
- * Using the List and Item components make it easy to support various
- * interaction modes such as swipe to edit, drag to reorder, and
- * removing items.
- *
- * @demo /docs/demos/src/list/
- * @see {@link /docs/components#lists List Component Docs}
- * @advanced
- *
- * Enable the sliding items.
- *
- * ```ts
- * import { Component, ViewChild } from '@angular/core';
- * import { List } from 'ionic-angular';
- *
- * @Component({...})
- * export class MyClass {
- * @ViewChild(List) list: List;
- *
- * constructor() { }
- *
- * stopSliding() {
- * this.list.enableSlidingItems(false);
- * }
- * }
- * ```
- *
- */
- var List = (function (_super) {
- __extends$51(List, _super);
- function List(config, elementRef, renderer, _plt, _gestureCtrl, _domCtrl) {
- var _this = _super.call(this, config, elementRef, renderer, 'list') || this;
- _this._plt = _plt;
- _this._gestureCtrl = _gestureCtrl;
- _this._domCtrl = _domCtrl;
- _this._enableSliding = true;
- _this._containsSlidingItems = false;
- return _this;
- }
- Object.defineProperty(List.prototype, "sliding", {
- /**
- * @input {boolean} If true, the sliding items will be enabled.
- */
- get: function () {
- return this._enableSliding;
- },
- set: function (val) {
- this._enableSliding = isTrueProperty(val);
- this._updateSlidingState();
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @hidden
- */
- List.prototype.containsSlidingItem = function (contains) {
- this._containsSlidingItems = contains;
- this._updateSlidingState();
- };
- List.prototype._updateSlidingState = function () {
- var shouldSlide = this._enableSliding && this._containsSlidingItems;
- if (!shouldSlide) {
- this._slidingGesture && this._slidingGesture.destroy();
- this._slidingGesture = null;
- }
- else if (!this._slidingGesture) {
- (void 0) /* console.debug */;
- this._slidingGesture = new ItemSlidingGesture(this._plt, this, this._gestureCtrl, this._domCtrl);
- this._slidingGesture.listen();
- }
- };
- /**
- * Close any sliding items that are open.
- */
- List.prototype.closeSlidingItems = function () {
- this._slidingGesture && this._slidingGesture.closeOpened();
- };
- /**
- * @hidden
- */
- List.prototype.destroy = function () {
- this._slidingGesture && this._slidingGesture.destroy();
- };
- List.decorators = [
- { type: Directive, args: [{
- selector: 'ion-list',
- },] },
- ];
- /** @nocollapse */
- List.ctorParameters = function () { return [
- { type: Config, },
- { type: ElementRef, },
- { type: Renderer, },
- { type: Platform, },
- { type: GestureController, },
- { type: DomController, },
- ]; };
- List.propDecorators = {
- 'sliding': [{ type: Input },],
- };
- return List;
- }(Ion));
-
- var SWIPE_MARGIN = 30;
- var ELASTIC_FACTOR = 0.55;
- var ITEM_SIDE_FLAG_NONE = 0;
- var ITEM_SIDE_FLAG_LEFT = 1 << 0;
- var ITEM_SIDE_FLAG_RIGHT = 1 << 1;
- var ITEM_SIDE_FLAG_BOTH = ITEM_SIDE_FLAG_LEFT | ITEM_SIDE_FLAG_RIGHT;
- /**
- * @name ItemSliding
- * @description
- * A sliding item is a list item that can be swiped to reveal buttons. It requires
- * an [Item](../Item) component as a child and a [List](../../list/List) component as
- * a parent. All buttons to reveal can be placed in the `<ion-item-options>` element.
- *
- * @usage
- * ```html
- * <ion-list>
- * <ion-item-sliding #item>
- * <ion-item>
- * Item
- * </ion-item>
- * <ion-item-options side="left">
- * <button ion-button (click)="favorite(item)">Favorite</button>
- * <button ion-button color="danger" (click)="share(item)">Share</button>
- * </ion-item-options>
- *
- * <ion-item-options side="right">
- * <button ion-button (click)="unread(item)">Unread</button>
- * </ion-item-options>
- * </ion-item-sliding>
- * </ion-list>
- * ```
- *
- * ### Swipe Direction
- * By default, the buttons are revealed when the sliding item is swiped from right to left,
- * so the buttons are placed in the right side. But it's also possible to reveal them
- * in the right side (sliding from left to right) by setting the `side` attribute
- * on the `ion-item-options` element. Up to 2 `ion-item-options` can used at the same time
- * in order to reveal two different sets of buttons depending the swipping direction.
- *
- * ```html
- * <ion-item-options side="right">
- * <button ion-button (click)="archive(item)">
- * <ion-icon name="archive"></ion-icon>
- * Archive
- * </button>
- * </ion-item-options>
- *
- * <ion-item-options side="left">
- * <button ion-button (click)="archive(item)">
- * <ion-icon name="archive"></ion-icon>
- * Archive
- * </button>
- * </ion-item-options>
- * ```
- *
- * ### Listening for events (ionDrag) and (ionSwipe)
- * It's possible to know the current relative position of the sliding item by subscribing
- * to the (ionDrag)` event.
- *
- * ```html
- * <ion-item-sliding (ionDrag)="logDrag($event)">
- * <ion-item>Item</ion-item>
- * <ion-item-options>
- * <button ion-button>Favorite</button>
- * </ion-item-options>
- * </ion-item-sliding>
- * ```
- *
- * ### Button Layout
- * If an icon is placed with text in the option button, by default it will
- * display the icon on top of the text. This can be changed to display the icon
- * to the left of the text by setting `icon-start` as an attribute on the
- * `<ion-item-options>` element.
- *
- * ```html
- * <ion-item-options icon-start>
- * <button ion-button (click)="archive(item)">
- * <ion-icon name="archive"></ion-icon>
- * Archive
- * </button>
- * </ion-item-options>
- *
- * ```
- *
- * ### Expandable Options
- *
- * Options can be expanded to take up the full width of the item if you swipe past
- * a certain point. This can be combined with the `ionSwipe` event to call methods
- * on the class.
- *
- * ```html
- *
- * <ion-item-sliding (ionSwipe)="delete(item)">
- * <ion-item>Item</ion-item>
- * <ion-item-options>
- * <button ion-button expandable (click)="delete(item)">Delete</button>
- * </ion-item-options>
- * </ion-item-sliding>
- * ```
- *
- * We can call `delete` by either clicking the button, or by doing a full swipe on the item.
- *
- * @demo /docs/demos/src/item-sliding/
- * @see {@link /docs/components#lists List Component Docs}
- * @see {@link ../Item Item API Docs}
- * @see {@link ../../list/List List API Docs}
- */
- var ItemSliding = (function () {
- function ItemSliding(list, _plt, _renderer, _elementRef, _zone) {
- this._plt = _plt;
- this._renderer = _renderer;
- this._elementRef = _elementRef;
- this._zone = _zone;
- this._openAmount = 0;
- this._startX = 0;
- this._optsWidthRightSide = 0;
- this._optsWidthLeftSide = 0;
- this._tmr = null;
- this._optsDirty = true;
- this._state = 2 /* Disabled */;
- /**
- * @output {event} Emitted when the sliding position changes.
- * It reports the relative position.
- *
- * ```ts
- * ondrag(item) {
- * let percent = item.getSlidingPercent();
- * if (percent > 0) {
- * // positive
- * console.log('right side');
- * } else {
- * // negative
- * console.log('left side');
- * }
- * if (Math.abs(percent) > 1) {
- * console.log('overscroll');
- * }
- * }
- * ```
- *
- */
- this.ionDrag = new EventEmitter();
- list && list.containsSlidingItem(true);
- _elementRef.nativeElement.$ionComponent = this;
- this.setElementClass('item-wrapper', true);
- }
- Object.defineProperty(ItemSliding.prototype, "_itemOptions", {
- set: function (itemOptions) {
- var sides = 0;
- // Reset left and right options in case they were removed
- this._leftOptions = this._rightOptions = null;
- for (var _i = 0, _a = itemOptions.toArray(); _i < _a.length; _i++) {
- var item = _a[_i];
- if (item.isRightSide()) {
- this._rightOptions = item;
- sides |= ITEM_SIDE_FLAG_RIGHT;
- }
- else {
- this._leftOptions = item;
- sides |= ITEM_SIDE_FLAG_LEFT;
- }
- }
- this._optsDirty = true;
- this._sides = sides;
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @hidden
- */
- ItemSliding.prototype.getOpenAmount = function () {
- return this._openAmount;
- };
- /**
- * @hidden
- */
- ItemSliding.prototype.getSlidingPercent = function () {
- var openAmount = this._openAmount;
- if (openAmount > 0) {
- return openAmount / this._optsWidthRightSide;
- }
- else if (openAmount < 0) {
- return openAmount / this._optsWidthLeftSide;
- }
- else {
- return 0;
- }
- };
- /**
- * @hidden
- */
- ItemSliding.prototype.startSliding = function (startX) {
- if (this._tmr) {
- this._plt.cancelTimeout(this._tmr);
- this._tmr = null;
- }
- if (this._openAmount === 0) {
- this._optsDirty = true;
- this._setState(4 /* Enabled */);
- }
- this._startX = startX + this._openAmount;
- this.item.setElementStyle(this._plt.Css.transition, 'none');
- };
- /**
- * @hidden
- */
- ItemSliding.prototype.moveSliding = function (x) {
- if (this._optsDirty) {
- this.calculateOptsWidth();
- return;
- }
- var openAmount = (this._startX - x);
- switch (this._sides) {
- case ITEM_SIDE_FLAG_RIGHT:
- openAmount = Math.max(0, openAmount);
- break;
- case ITEM_SIDE_FLAG_LEFT:
- openAmount = Math.min(0, openAmount);
- break;
- case ITEM_SIDE_FLAG_BOTH: break;
- case ITEM_SIDE_FLAG_NONE: return;
- default:
- (void 0) /* assert */;
- break;
- }
- if (openAmount > this._optsWidthRightSide) {
- var optsWidth = this._optsWidthRightSide;
- openAmount = optsWidth + (openAmount - optsWidth) * ELASTIC_FACTOR;
- }
- else if (openAmount < -this._optsWidthLeftSide) {
- var optsWidth = -this._optsWidthLeftSide;
- openAmount = optsWidth + (openAmount - optsWidth) * ELASTIC_FACTOR;
- }
- this._setOpenAmount(openAmount, false);
- return openAmount;
- };
- /**
- * @hidden
- */
- ItemSliding.prototype.endSliding = function (velocity) {
- var restingPoint = (this._openAmount > 0)
- ? this._optsWidthRightSide
- : -this._optsWidthLeftSide;
- // Check if the drag didn't clear the buttons mid-point
- // and we aren't moving fast enough to swipe open
- var isResetDirection = (this._openAmount > 0) === !(velocity < 0);
- var isMovingFast = Math.abs(velocity) > 0.3;
- var isOnCloseZone = Math.abs(this._openAmount) < Math.abs(restingPoint / 2);
- if (swipeShouldReset(isResetDirection, isMovingFast, isOnCloseZone)) {
- restingPoint = 0;
- }
- this.fireSwipeEvent();
- this._setOpenAmount(restingPoint, true);
- return restingPoint;
- };
- /**
- * @hidden
- */
- ItemSliding.prototype.fireSwipeEvent = function () {
- var _this = this;
- if (this._state & 32 /* SwipeRight */) {
- this._zone.run(function () { return _this._rightOptions.ionSwipe.emit(_this); });
- }
- else if (this._state & 64 /* SwipeLeft */) {
- this._zone.run(function () { return _this._leftOptions.ionSwipe.emit(_this); });
- }
- };
- /**
- * @hidden
- */
- ItemSliding.prototype.calculateOptsWidth = function () {
- if (!this._optsDirty) {
- return;
- }
- this._optsWidthRightSide = 0;
- if (this._rightOptions) {
- this._optsWidthRightSide = this._rightOptions.width();
- (void 0) /* assert */;
- }
- this._optsWidthLeftSide = 0;
- if (this._leftOptions) {
- this._optsWidthLeftSide = this._leftOptions.width();
- (void 0) /* assert */;
- }
- this._optsDirty = false;
- };
- ItemSliding.prototype._setOpenAmount = function (openAmount, isFinal) {
- var _this = this;
- var platform = this._plt;
- if (this._tmr) {
- platform.cancelTimeout(this._tmr);
- this._tmr = null;
- }
- this._openAmount = openAmount;
- if (isFinal) {
- this.item.setElementStyle(platform.Css.transition, '');
- }
- if (openAmount > 0) {
- var state$$1 = (openAmount >= (this._optsWidthRightSide + SWIPE_MARGIN))
- ? 8 /* Right */ | 32 /* SwipeRight */
- : 8;
- this._setState(state$$1);
- }
- else if (openAmount < 0) {
- var state_1 = (openAmount <= (-this._optsWidthLeftSide - SWIPE_MARGIN))
- ? 16 /* Left */ | 64 /* SwipeLeft */
- : 16;
- this._setState(state_1);
- }
- else {
- (void 0) /* assert */;
- this._tmr = platform.timeout(function () {
- _this._setState(2 /* Disabled */);
- _this._tmr = null;
- }, 600);
- this.item.setElementStyle(platform.Css.transform, '');
- return;
- }
- this.item.setElementStyle(platform.Css.transform, "translate3d(" + -openAmount + "px,0,0)");
- var ionDrag = this.ionDrag;
- if (ionDrag.observers.length > 0) {
- ionDrag.emit(this);
- }
- };
- ItemSliding.prototype._setState = function (state$$1) {
- if (state$$1 === this._state) {
- return;
- }
- this.setElementClass('active-slide', (state$$1 !== 2 /* Disabled */));
- this.setElementClass('active-options-right', !!(state$$1 & 8 /* Right */));
- this.setElementClass('active-options-left', !!(state$$1 & 16 /* Left */));
- this.setElementClass('active-swipe-right', !!(state$$1 & 32 /* SwipeRight */));
- this.setElementClass('active-swipe-left', !!(state$$1 & 64 /* SwipeLeft */));
- this._state = state$$1;
- };
- /**
- * Close the sliding item. Items can also be closed from the [List](../../list/List).
- *
- * The sliding item can be closed by grabbing a reference to `ItemSliding`. In the
- * below example, the template reference variable `slidingItem` is placed on the element
- * and passed to the `share` method.
- *
- * ```html
- * <ion-list>
- * <ion-item-sliding #slidingItem>
- * <ion-item>
- * Item
- * </ion-item>
- * <ion-item-options>
- * <button ion-button (click)="share(slidingItem)">Share</button>
- * </ion-item-options>
- * </ion-item-sliding>
- * </ion-list>
- * ```
- *
- * ```ts
- * import { Component } from '@angular/core';
- * import { ItemSliding } from 'ionic-angular';
- *
- * @Component({...})
- * export class MyClass {
- * constructor() { }
- *
- * share(slidingItem: ItemSliding) {
- * slidingItem.close();
- * }
- * }
- * ```
- */
- ItemSliding.prototype.close = function () {
- this._setOpenAmount(0, true);
- };
- /**
- * @hidden
- */
- ItemSliding.prototype.setElementClass = function (cssClass, shouldAdd) {
- this._renderer.setElementClass(this._elementRef.nativeElement, cssClass, shouldAdd);
- };
- ItemSliding.decorators = [
- { type: Component, args: [{
- selector: 'ion-item-sliding',
- template: "\n <ng-content select=\"ion-item,[ion-item]\"></ng-content>\n <ng-content select=\"ion-item-options\"></ng-content>\n ",
- changeDetection: ChangeDetectionStrategy.OnPush,
- encapsulation: ViewEncapsulation.None
- },] },
- ];
- /** @nocollapse */
- ItemSliding.ctorParameters = function () { return [
- { type: List, decorators: [{ type: Optional },] },
- { type: Platform, },
- { type: Renderer, },
- { type: ElementRef, },
- { type: NgZone, },
- ]; };
- ItemSliding.propDecorators = {
- 'item': [{ type: ContentChild, args: [Item,] },],
- 'ionDrag': [{ type: Output },],
- '_itemOptions': [{ type: ContentChildren, args: [forwardRef(function () { return ItemOptions; }),] },],
- };
- return ItemSliding;
- }());
-
- /**
- * @hidden
- */
- var Reorder = (function () {
- function Reorder(elementRef) {
- this.elementRef = elementRef;
- elementRef.nativeElement['$ionComponent'] = this;
- }
- Reorder.prototype.getReorderNode = function () {
- return findReorderItem(this.elementRef.nativeElement, null);
- };
- Reorder.prototype.onClick = function (ev) {
- // Stop propagation if click event reaches ion-reorder
- ev.preventDefault();
- ev.stopPropagation();
- };
- Reorder.decorators = [
- { type: Component, args: [{
- selector: 'ion-reorder',
- template: "<ion-icon name=\"reorder\"></ion-icon>"
- },] },
- ];
- /** @nocollapse */
- Reorder.ctorParameters = function () { return [
- { type: ElementRef, },
- ]; };
- Reorder.propDecorators = {
- 'onClick': [{ type: HostListener, args: ['click', ['$event'],] },],
- };
- return Reorder;
- }());
-
- var __extends$53 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @hidden
- */
- var ListHeader = (function (_super) {
- __extends$53(ListHeader, _super);
- function ListHeader(config, renderer, elementRef, _id) {
- var _this = _super.call(this, config, elementRef, renderer, 'list-header') || this;
- _this._id = _id;
- return _this;
- }
- Object.defineProperty(ListHeader.prototype, "id", {
- get: function () {
- return this._id;
- },
- set: function (val) {
- this._id = val;
- this.setElementAttribute('id', val);
- },
- enumerable: true,
- configurable: true
- });
- ListHeader.decorators = [
- { type: Directive, args: [{
- selector: 'ion-list-header'
- },] },
- ];
- /** @nocollapse */
- ListHeader.ctorParameters = function () { return [
- { type: Config, },
- { type: Renderer, },
- { type: ElementRef, },
- { type: undefined, decorators: [{ type: Attribute, args: ['id',] },] },
- ]; };
- return ListHeader;
- }(Ion));
-
- /**
- * @hidden
- */
- var LoadingCmp = (function () {
- function LoadingCmp(_viewCtrl, _config, _elementRef, gestureCtrl, params, renderer) {
- this._viewCtrl = _viewCtrl;
- this._config = _config;
- (void 0) /* assert */;
- this.gestureBlocker = gestureCtrl.createBlocker(BLOCK_ALL);
- this.d = params.data;
- renderer.setElementClass(_elementRef.nativeElement, "loading-" + _config.get('mode'), true);
- if (this.d.cssClass) {
- this.d.cssClass.split(' ').forEach(function (cssClass) {
- // Make sure the class isn't whitespace, otherwise it throws exceptions
- if (cssClass.trim() !== '')
- renderer.setElementClass(_elementRef.nativeElement, cssClass, true);
- });
- }
- this.id = (++loadingIds);
- }
- LoadingCmp.prototype.ngOnInit = function () {
- // If no spinner was passed in loading options we need to fall back
- // to the loadingSpinner in the app's config, then the mode spinner
- if (isUndefined(this.d.spinner)) {
- this.d.spinner = this._config.get('loadingSpinner', this._config.get('spinner', 'ios'));
- }
- // If the user passed hide to the spinner we don't want to show it
- this.showSpinner = isDefined(this.d.spinner) && this.d.spinner !== 'hide';
- };
- LoadingCmp.prototype.ionViewWillEnter = function () {
- this.gestureBlocker.block();
- };
- LoadingCmp.prototype.ionViewDidLeave = function () {
- this.gestureBlocker.unblock();
- };
- LoadingCmp.prototype.ionViewDidEnter = function () {
- var _this = this;
- // If there is a duration, dismiss after that amount of time
- if (this.d && this.d.duration) {
- this.durationTimeout = setTimeout(function () { return _this.dismiss('backdrop'); }, this.d.duration);
- }
- };
- LoadingCmp.prototype.keyUp = function (ev) {
- if (this._viewCtrl.isLast() && ev.keyCode === KEY_ESCAPE) {
- this.bdClick();
- }
- };
- LoadingCmp.prototype.bdClick = function () {
- if (this.d.enableBackdropDismiss) {
- this.dismiss('backdrop');
- }
- };
- LoadingCmp.prototype.dismiss = function (role) {
- if (this.durationTimeout) {
- clearTimeout(this.durationTimeout);
- }
- return this._viewCtrl.dismiss(null, role);
- };
- LoadingCmp.prototype.ngOnDestroy = function () {
- (void 0) /* assert */;
- this.gestureBlocker.destroy();
- };
- LoadingCmp.decorators = [
- { type: Component, args: [{
- selector: 'ion-loading',
- template: '<ion-backdrop [hidden]="!d.showBackdrop" (click)="bdClick()" [class.backdrop-no-tappable]="!d.enableBackdropDismiss"></ion-backdrop>' +
- '<div class="loading-wrapper">' +
- '<div *ngIf="showSpinner" class="loading-spinner">' +
- '<ion-spinner [name]="d.spinner"></ion-spinner>' +
- '</div>' +
- '<div *ngIf="d.content" [innerHTML]="d.content" class="loading-content"></div>' +
- '</div>',
- host: {
- 'role': 'dialog'
- },
- encapsulation: ViewEncapsulation.None,
- },] },
- ];
- /** @nocollapse */
- LoadingCmp.ctorParameters = function () { return [
- { type: ViewController, },
- { type: Config, },
- { type: ElementRef, },
- { type: GestureController, },
- { type: NavParams, },
- { type: Renderer, },
- ]; };
- LoadingCmp.propDecorators = {
- 'keyUp': [{ type: HostListener, args: ['body:keyup', ['$event'],] },],
- };
- return LoadingCmp;
- }());
- var loadingIds = -1;
-
- var __extends$55 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * Animations for loading
- */
- var LoadingPopIn = (function (_super) {
- __extends$55(LoadingPopIn, _super);
- function LoadingPopIn() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- LoadingPopIn.prototype.init = function () {
- var ele = this.enteringView.pageRef().nativeElement;
- var backdrop = new Animation(this.plt, ele.querySelector('ion-backdrop'));
- var wrapper = new Animation(this.plt, ele.querySelector('.loading-wrapper'));
- wrapper.fromTo('opacity', 0.01, 1).fromTo('scale', 1.1, 1);
- backdrop.fromTo('opacity', 0.01, 0.3);
- this
- .easing('ease-in-out')
- .duration(200)
- .add(backdrop)
- .add(wrapper);
- };
- return LoadingPopIn;
- }(Transition));
- var LoadingPopOut = (function (_super) {
- __extends$55(LoadingPopOut, _super);
- function LoadingPopOut() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- LoadingPopOut.prototype.init = function () {
- var ele = this.leavingView.pageRef().nativeElement;
- var backdrop = new Animation(this.plt, ele.querySelector('ion-backdrop'));
- var wrapper = new Animation(this.plt, ele.querySelector('.loading-wrapper'));
- wrapper.fromTo('opacity', 0.99, 0).fromTo('scale', 1, 0.9);
- backdrop.fromTo('opacity', 0.3, 0);
- this
- .easing('ease-in-out')
- .duration(200)
- .add(backdrop)
- .add(wrapper);
- };
- return LoadingPopOut;
- }(Transition));
- var LoadingMdPopIn = (function (_super) {
- __extends$55(LoadingMdPopIn, _super);
- function LoadingMdPopIn() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- LoadingMdPopIn.prototype.init = function () {
- var ele = this.enteringView.pageRef().nativeElement;
- var backdrop = new Animation(this.plt, ele.querySelector('ion-backdrop'));
- var wrapper = new Animation(this.plt, ele.querySelector('.loading-wrapper'));
- wrapper.fromTo('opacity', 0.01, 1).fromTo('scale', 1.1, 1);
- backdrop.fromTo('opacity', 0.01, 0.5);
- this
- .easing('ease-in-out')
- .duration(200)
- .add(backdrop)
- .add(wrapper);
- };
- return LoadingMdPopIn;
- }(Transition));
- var LoadingMdPopOut = (function (_super) {
- __extends$55(LoadingMdPopOut, _super);
- function LoadingMdPopOut() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- LoadingMdPopOut.prototype.init = function () {
- var ele = this.leavingView.pageRef().nativeElement;
- var backdrop = new Animation(this.plt, ele.querySelector('ion-backdrop'));
- var wrapper = new Animation(this.plt, ele.querySelector('.loading-wrapper'));
- wrapper.fromTo('opacity', 0.99, 0).fromTo('scale', 1, 0.9);
- backdrop.fromTo('opacity', 0.5, 0);
- this
- .easing('ease-in-out')
- .duration(200)
- .add(backdrop)
- .add(wrapper);
- };
- return LoadingMdPopOut;
- }(Transition));
- var LoadingWpPopIn = (function (_super) {
- __extends$55(LoadingWpPopIn, _super);
- function LoadingWpPopIn() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- LoadingWpPopIn.prototype.init = function () {
- var ele = this.enteringView.pageRef().nativeElement;
- var backdrop = new Animation(this.plt, ele.querySelector('ion-backdrop'));
- var wrapper = new Animation(this.plt, ele.querySelector('.loading-wrapper'));
- wrapper.fromTo('opacity', 0.01, 1).fromTo('scale', 1.3, 1);
- backdrop.fromTo('opacity', 0.01, 0.16);
- this
- .easing('cubic-bezier(0,0,0.05,1)')
- .duration(200)
- .add(backdrop)
- .add(wrapper);
- };
- return LoadingWpPopIn;
- }(Transition));
- var LoadingWpPopOut = (function (_super) {
- __extends$55(LoadingWpPopOut, _super);
- function LoadingWpPopOut() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- LoadingWpPopOut.prototype.init = function () {
- var ele = this.leavingView.pageRef().nativeElement;
- var backdrop = new Animation(this.plt, ele.querySelector('ion-backdrop'));
- var wrapper = new Animation(this.plt, ele.querySelector('.loading-wrapper'));
- wrapper.fromTo('opacity', 0.99, 0).fromTo('scale', 1, 1.3);
- backdrop.fromTo('opacity', 0.16, 0);
- this
- .easing('ease-out')
- .duration(150)
- .add(backdrop)
- .add(wrapper);
- };
- return LoadingWpPopOut;
- }(Transition));
-
- var __extends$54 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @hidden
- */
- var Loading = (function (_super) {
- __extends$54(Loading, _super);
- function Loading(app, opts, config) {
- if (opts === void 0) { opts = {}; }
- var _this = this;
- opts.showBackdrop = isPresent(opts.showBackdrop) ? !!opts.showBackdrop : true;
- opts.enableBackdropDismiss = isPresent(opts.enableBackdropDismiss) ? !!opts.enableBackdropDismiss : false;
- opts.dismissOnPageChange = isPresent(opts.dismissOnPageChange) ? !!opts.dismissOnPageChange : false;
- _this = _super.call(this, LoadingCmp, opts, null) || this;
- _this._app = app;
- _this.isOverlay = true;
- config.setTransition('loading-pop-in', LoadingPopIn);
- config.setTransition('loading-pop-out', LoadingPopOut);
- config.setTransition('loading-md-pop-in', LoadingMdPopIn);
- config.setTransition('loading-md-pop-out', LoadingMdPopOut);
- config.setTransition('loading-wp-pop-in', LoadingWpPopIn);
- config.setTransition('loading-wp-pop-out', LoadingWpPopOut);
- return _this;
- }
- /**
- * @hidden
- */
- Loading.prototype.getTransitionName = function (direction) {
- var key = (direction === 'back' ? 'loadingLeave' : 'loadingEnter');
- return this._nav && this._nav.config.get(key);
- };
- /**
- * @param {string} content sets the html content for the loading indicator.
- */
- Loading.prototype.setContent = function (content) {
- this.data.content = content;
- return this;
- };
- /**
- * @param {string} spinner sets the name of the SVG spinner for the loading indicator.
- */
- Loading.prototype.setSpinner = function (spinner) {
- this.data.spinner = spinner;
- return this;
- };
- /**
- * @param {string} cssClass sets additional classes for custom styles, separated by spaces.
- */
- Loading.prototype.setCssClass = function (cssClass) {
- this.data.cssClass = cssClass;
- return this;
- };
- /**
- * @param {boolean} showBackdrop sets whether to show the backdrop.
- */
- Loading.prototype.setShowBackdrop = function (showBackdrop) {
- this.data.showBackdrop = showBackdrop;
- return this;
- };
- /**
- * @param {number} dur how many milliseconds to wait before hiding the indicator.
- */
- Loading.prototype.setDuration = function (dur) {
- this.data.duration = dur;
- return this;
- };
- /**
- * Present the loading instance.
- *
- * @param {NavOptions} [navOptions={}] Nav options to go with this transition.
- * @returns {Promise} Returns a promise which is resolved when the transition has completed.
- */
- Loading.prototype.present = function (navOptions) {
- if (navOptions === void 0) { navOptions = {}; }
- return this._app.present(this, navOptions, PORTAL_LOADING);
- };
- /**
- * Dismiss all loading components which have been presented.
- */
- Loading.prototype.dismissAll = function () {
- this._nav && this._nav.popAll();
- };
- return Loading;
- }(ViewController));
-
- /**
- * @name LoadingController
- * @description
- * An overlay that can be used to indicate activity while blocking user
- * interaction. The loading indicator appears on top of the app's content,
- * and can be dismissed by the app to resume user interaction with
- * the app. It includes an optional backdrop, which can be disabled
- * by setting `showBackdrop: false` upon creation.
- *
- * ### Creating
- * You can pass all of the loading options in the first argument of
- * the create method: `create(opts)`. The spinner name should be
- * passed in the `spinner` property, and any optional HTML can be passed
- * in the `content` property. If you do not pass a value to `spinner`
- * the loading indicator will use the spinner specified by the mode. To
- * set the spinner name across the app, set the value of `loadingSpinner`
- * in your app's config. To hide the spinner, set `loadingSpinner: 'hide'`
- * in the app's config or pass `spinner: 'hide'` in the loading
- * options. See the [create](#create) method below for all available options.
- *
- * ### Dismissing
- * The loading indicator can be dismissed automatically after a specific
- * amount of time by passing the number of milliseconds to display it in
- * the `duration` of the loading options. By default the loading indicator
- * will show even during page changes, but this can be disabled by setting
- * `dismissOnPageChange` to `true`. To dismiss the loading indicator after
- * creation, call the `dismiss()` method on the Loading instance. The
- * `onDidDismiss` function can be called to perform an action after the loading
- * indicator is dismissed.
- *
- * >Note that after the component is dismissed, it will not be usable anymore
- * and another one must be created. This can be avoided by wrapping the
- * creation and presentation of the component in a reusable function as shown
- * in the `usage` section below.
- *
- * ### Limitations
- * The element is styled to appear on top of other content by setting its
- * `z-index` property. You must ensure no element has a stacking context with
- * a higher `z-index` than this element.
- *
- * @usage
- * ```ts
- * import { LoadingController } from 'ionic-angular';
- *
- * constructor(public loadingCtrl: LoadingController) { }
- *
- * presentLoadingDefault() {
- * const loading = this.loadingCtrl.create({
- * content: 'Please wait...'
- * });
- *
- * loading.present();
- *
- * setTimeout(() => {
- * loading.dismiss();
- * }, 5000);
- * }
- *
- * presentLoadingCustom() {
- * const loading = this.loadingCtrl.create({
- * spinner: 'hide',
- * content: `
- * <div class="custom-spinner-container">
- * <div class="custom-spinner-box"></div>
- * </div>`,
- * duration: 5000
- * });
- *
- * loading.onDidDismiss(() => {
- * console.log('Dismissed loading');
- * });
- *
- * loading.present();
- * }
- *
- * presentLoadingText() {
- * const loading = this.loadingCtrl.create({
- * spinner: 'hide',
- * content: 'Loading Please Wait...'
- * });
- *
- * loading.present();
- *
- * setTimeout(() => {
- * this.nav.push(Page2);
- * }, 1000);
- *
- * setTimeout(() => {
- * loading.dismiss();
- * }, 5000);
- * }
- * ```
- * @advanced
- *
- * Loading options
- *
- * | Option | Type | Description |
- * |-----------------------|------------|------------------------------------------------------------------------------------------------------------------|
- * | spinner |`string` | The name of the SVG spinner for the loading indicator. |
- * | content |`string` | The html content for the loading indicator. |
- * | cssClass |`string` | Additional classes for custom styles, separated by spaces. |
- * | showBackdrop |`boolean` | Whether to show the backdrop. Default true. |
- * | enableBackdropDismiss | `boolean` | Whether the loading indicator should be dismissed by tapping the backdrop. Default false. |
- * | dismissOnPageChange |`boolean` | Whether to dismiss the indicator when navigating to a new page. Default false. |
- * | duration |`number` | How many milliseconds to wait before hiding the indicator. By default, it will show until `dismiss()` is called. |
- *
- * @demo /docs/demos/src/loading/
- * @see {@link /docs/api/components/spinner/Spinner Spinner API Docs}
- */
- var LoadingController = (function () {
- function LoadingController(_app, config) {
- this._app = _app;
- this.config = config;
- }
- /**
- * Create a loading indicator. See below for options.
- * @param {LoadingOptions} [opts] Loading options
- * @returns {Loading} Returns a Loading Instance
- */
- LoadingController.prototype.create = function (opts) {
- if (opts === void 0) { opts = {}; }
- return new Loading(this._app, opts, this.config);
- };
- LoadingController.decorators = [
- { type: Injectable },
- ];
- /** @nocollapse */
- LoadingController.ctorParameters = function () { return [
- { type: App, },
- { type: Config, },
- ]; };
- return LoadingController;
- }());
-
- var __extends$56 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * Gesture attached to the content which the menu is assigned to
- */
- var MenuContentGesture = (function (_super) {
- __extends$56(MenuContentGesture, _super);
- function MenuContentGesture(plt, menu, gestureCtrl, domCtrl) {
- var _this = _super.call(this, plt, plt.doc().body, {
- direction: 'x',
- edge: menu.side,
- threshold: 5,
- maxEdgeStart: menu.maxEdgeStart || 50,
- zone: false,
- passive: true,
- domController: domCtrl,
- gesture: gestureCtrl.createGesture({
- name: GESTURE_MENU_SWIPE,
- priority: GESTURE_PRIORITY_MENU_SWIPE,
- disableScroll: true
- })
- }) || this;
- _this.menu = menu;
- return _this;
- }
- MenuContentGesture.prototype.canStart = function (ev) {
- var menu = this.menu;
- if (!menu.canSwipe()) {
- return false;
- }
- if (menu.isOpen) {
- return true;
- }
- else if (menu.getMenuController().getOpen()) {
- return false;
- }
- return _super.prototype.canStart.call(this, ev);
- };
- // Set CSS, then wait one frame for it to apply before sliding starts
- MenuContentGesture.prototype.onSlideBeforeStart = function () {
- (void 0) /* console.debug */;
- this.menu._swipeBeforeStart();
- };
- MenuContentGesture.prototype.onSlideStart = function () {
- (void 0) /* console.debug */;
- this.menu._swipeStart();
- };
- MenuContentGesture.prototype.onSlide = function (slide) {
- var z = (this.menu.isRightSide !== this.plt.isRTL ? slide.min : slide.max);
- var stepValue = (slide.distance / z);
- this.menu._swipeProgress(stepValue);
- };
- MenuContentGesture.prototype.onSlideEnd = function (slide) {
- var z = (this.menu.isRightSide !== this.plt.isRTL ? slide.min : slide.max);
- var currentStepValue = (slide.distance / z);
- var velocity = slide.velocity;
- z = Math.abs(z * 0.5);
- var shouldCompleteRight = (velocity >= 0)
- && (velocity > 0.2 || slide.delta > z);
- var shouldCompleteLeft = (velocity <= 0)
- && (velocity < -0.2 || slide.delta < -z);
- (void 0) /* console.debug */;
- this.menu._swipeEnd(shouldCompleteLeft, shouldCompleteRight, currentStepValue, velocity);
- };
- MenuContentGesture.prototype.getElementStartPos = function (slide) {
- var menu = this.menu;
- if (menu.isRightSide !== this.plt.isRTL) {
- return menu.isOpen ? slide.min : slide.max;
- }
- // left menu
- return menu.isOpen ? slide.max : slide.min;
- };
- MenuContentGesture.prototype.getSlideBoundaries = function () {
- var menu = this.menu;
- if (menu.isRightSide !== this.plt.isRTL) {
- return {
- min: -menu.width(),
- max: 0
- };
- }
- // left menu
- return {
- min: 0,
- max: menu.width()
- };
- };
- return MenuContentGesture;
- }(SlideEdgeGesture));
-
- var __extends$58 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- var QUERY = {
- xs: '(min-width: 0px)',
- sm: '(min-width: 576px)',
- md: '(min-width: 768px)',
- lg: '(min-width: 992px)',
- xl: '(min-width: 1200px)',
- never: ''
- };
- /**
- * @hidden
- */
- var RootNode = (function () {
- function RootNode() {
- }
- return RootNode;
- }());
- /**
- * @name SplitPane
- *
- * @description
- * SplitPane is a component that makes it possible to create multi-view layout.
- * Similar to iPad apps, SplitPane allows UI elements, like Menus, to be
- * displayed as the viewport increases.
- *
- * If the devices screen size is below a certain size, the SplitPane will
- * collapse and the menu will become hidden again. This is especially useful when
- * creating an app that will be served over a browser or deployed through the app
- * store to phones and tablets.
- *
- * @usage
- * To use SplitPane, simply add the component around your root component.
- * In this example, we'll be using a sidemenu layout, similar to what is
- * provided from the sidemenu starter template.
- *
- * ```html
- * <ion-split-pane>
- * <!-- our side menu -->
- * <ion-menu [content]="content">
- * <ion-header>
- * <ion-toolbar>
- * <ion-title>Menu</ion-title>
- * </ion-toolbar>
- * </ion-header>
- * </ion-menu>
- *
- * <!-- the main content -->
- * <ion-nav [root]="root" main #content></ion-nav>
- * </ion-split-pane>
- * ```
- *
- * Here, SplitPane will look for the element with the `main` attribute and make
- * that the central component on larger screens. The `main` component can be any
- * Ionic component (`ion-nav` or `ion-tabs`) except `ion-menu`.
- *
- * ### Setting breakpoints
- *
- * By default, SplitPane will expand when the screen is larger than 768px.
- * If you want to customize this, use the `when` input. The `when` input can
- * accept any valid media query, as it uses `matchMedia()` underneath.
- *
- * ```
- * <ion-split-pane when="(min-width: 475px)">
- *
- * <!-- our side menu -->
- * <ion-menu [content]="content">
- * ....
- * </ion-menu>
- *
- * <!-- the main content -->
- * <ion-nav [root]="root" main #content></ion-nav>
- * </ion-split-pane>
- * ```
- *
- * SplitPane also provides some predefined media queries that can be used.
- *
- * ```html
- * <!-- could be "xs", "sm", "md", "lg", or "xl" -->
- * <ion-split-pane when="lg">
- * ...
- * </ion-split-pane>
- * ```
- *
- *
- * | Size | Value | Description |
- * |------|-----------------------|-----------------------------------------------------------------------|
- * | `xs` | `(min-width: 0px)` | Show the split-pane when the min-width is 0px (meaning, always) |
- * | `sm` | `(min-width: 576px)` | Show the split-pane when the min-width is 576px |
- * | `md` | `(min-width: 768px)` | Show the split-pane when the min-width is 768px (default break point) |
- * | `lg` | `(min-width: 992px)` | Show the split-pane when the min-width is 992px |
- * | `xl` | `(min-width: 1200px)` | Show the split-pane when the min-width is 1200px |
- *
- * You can also pass in boolean values that will trigger SplitPane when the value
- * or expression evaluates to true.
- *
- *
- * ```html
- * <ion-split-pane [when]="isLarge">
- * ...
- * </ion-split-pane>
- * ```
- *
- * ```ts
- * class MyClass {
- * public isLarge = false;
- * constructor(){}
- * }
- * ```
- *
- * Or
- *
- * ```html
- * <ion-split-pane [when]="shouldShow()">
- * ...
- * </ion-split-pane>
- * ```
- *
- * ```ts
- * class MyClass {
- * constructor(){}
- * shouldShow(){
- * if(conditionA){
- * return true
- * } else {
- * return false
- * }
- * }
- * }
- * ```
- *
- */
- var SplitPane = (function (_super) {
- __extends$58(SplitPane, _super);
- function SplitPane(_zone, _plt, config, elementRef, renderer) {
- var _this = _super.call(this, config, elementRef, renderer, 'split-pane') || this;
- _this._zone = _zone;
- _this._plt = _plt;
- _this._init = false;
- _this._visible = false;
- _this._isEnabled = true;
- _this._mediaQuery = QUERY['md'];
- /**
- * @hidden
- */
- _this.sideContent = null;
- /**
- * @hidden
- */
- _this.mainContent = null;
- /**
- * @output {any} Expression to be called when the split-pane visibility has changed
- */
- _this.ionChange = new EventEmitter();
- return _this;
- }
- Object.defineProperty(SplitPane.prototype, "_setchildren", {
- /**
- * @hidden
- */
- set: function (query) {
- var _this = this;
- var children = this._children = query.filter((function (child) { return child !== _this; }));
- children.forEach(function (child) {
- var isMain = child.initPane();
- _this._setPaneCSSClass(child.getElementRef(), isMain);
- });
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(SplitPane.prototype, "when", {
- get: function () {
- return this._mediaQuery;
- },
- /**
- * @input {string | boolean} When the split-pane should be shown.
- * Can be a CSS media query expression, or a shortcut expression.
- * Can also be a boolean expression.
- */
- set: function (query) {
- if (typeof query === 'boolean') {
- this._mediaQuery = query;
- }
- else {
- var defaultQuery = QUERY[query];
- this._mediaQuery = (defaultQuery)
- ? defaultQuery
- : query;
- }
- this._update();
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(SplitPane.prototype, "enabled", {
- get: function () {
- return this._isEnabled;
- },
- /**
- * @input {boolean} If `false`, the split-pane is disabled, ie. the side pane will
- * never be displayed. Default `true`.
- */
- set: function (val) {
- this._isEnabled = isTrueProperty(val);
- this._update();
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @hidden
- */
- SplitPane.prototype._register = function (node, isMain, callback) {
- if (this.getElementRef().nativeElement !== node.getElementRef().nativeElement.parentNode) {
- return false;
- }
- this._setPaneCSSClass(node.getElementRef(), isMain);
- if (callback) {
- this.ionChange.subscribe(callback);
- }
- if (isMain) {
- if (this.mainContent) {
- console.error('split pane: main content was already set');
- }
- this.mainContent = node;
- }
- return true;
- };
- /**
- * @hidden
- */
- SplitPane.prototype.ngAfterViewInit = function () {
- this._init = true;
- this._update();
- };
- /**
- * @hidden
- */
- SplitPane.prototype._update = function () {
- var _this = this;
- if (!this._init) {
- return;
- }
- // Unlisten
- this._rmListener && this._rmListener();
- this._rmListener = null;
- // Check if the split-pane is disabled
- if (!this._isEnabled) {
- this._setVisible(false);
- return;
- }
- var query = this._mediaQuery;
- if (typeof query === 'boolean') {
- this._setVisible(query);
- return;
- }
- if (query && query.length > 0) {
- // Listen
- var callback_1 = function (query) { return _this._setVisible(query.matches); };
- var mediaList_1 = this._plt.win().matchMedia(query);
- mediaList_1.addListener(callback_1);
- this._setVisible(mediaList_1.matches);
- this._rmListener = function () {
- mediaList_1.removeListener(callback_1);
- };
- }
- else {
- this._setVisible(false);
- }
- };
- /**
- * @hidden
- */
- SplitPane.prototype._updateChildren = function () {
- this.mainContent = null;
- this.sideContent = null;
- var visible = this._visible;
- this._children.forEach(function (child) { return child.paneChanged && child.paneChanged(visible); });
- };
- /**
- * @hidden
- */
- SplitPane.prototype._setVisible = function (visible) {
- var _this = this;
- if (this._visible === visible) {
- return;
- }
- this._visible = visible;
- this.setElementClass('split-pane-visible', visible);
- this._updateChildren();
- this._zone.run(function () {
- _this.ionChange.emit(_this);
- });
- };
- /**
- * @hidden
- */
- SplitPane.prototype.isVisible = function () {
- return this._visible;
- };
- /**
- * @hidden
- */
- SplitPane.prototype.setElementClass = function (className, add) {
- this._renderer.setElementClass(this._elementRef.nativeElement, className, add);
- };
- /**
- * @hidden
- */
- SplitPane.prototype._setPaneCSSClass = function (elementRef, isMain) {
- var ele = elementRef.nativeElement;
- this._renderer.setElementClass(ele, 'split-pane-main', isMain);
- this._renderer.setElementClass(ele, 'split-pane-side', !isMain);
- };
- /**
- * @hidden
- */
- SplitPane.prototype.ngOnDestroy = function () {
- (void 0) /* assert */;
- this._rmListener && this._rmListener();
- this._rmListener = null;
- };
- /**
- * @hidden
- */
- SplitPane.prototype.initPane = function () {
- return true;
- };
- SplitPane.decorators = [
- { type: Directive, args: [{
- selector: 'ion-split-pane',
- providers: [{ provide: RootNode, useExisting: forwardRef(function () { return SplitPane; }) }]
- },] },
- ];
- /** @nocollapse */
- SplitPane.ctorParameters = function () { return [
- { type: NgZone, },
- { type: Platform, },
- { type: Config, },
- { type: ElementRef, },
- { type: Renderer, },
- ]; };
- SplitPane.propDecorators = {
- '_setchildren': [{ type: ContentChildren, args: [RootNode, { descendants: false },] },],
- 'when': [{ type: Input },],
- 'enabled': [{ type: Input },],
- 'ionChange': [{ type: Output },],
- };
- return SplitPane;
- }(Ion));
-
- var __extends$57 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @name Nav
- * @description
- *
- * `ion-nav` is the declarative component for a [NavController](../../../navigation/NavController/).
- *
- * For more information on using nav controllers like Nav or [Tab](../../Tabs/Tab/),
- * take a look at the [NavController API Docs](../../../navigation/NavController/).
- *
- *
- * @usage
- * You must set a root page to be loaded initially by any Nav you create, using
- * the 'root' property:
- *
- * ```ts
- * import { Component } from '@angular/core';
- * import { GettingStartedPage } from './getting-started';
- *
- * @Component({
- * template: `<ion-nav [root]="root"></ion-nav>`
- * })
- * class MyApp {
- * root = GettingStartedPage;
- *
- * constructor(){
- * }
- * }
- * ```
- *
- * @demo /docs/demos/src/navigation/
- * @see {@link /docs/components#navigation Navigation Component Docs}
- */
- var Nav = (function (_super) {
- __extends$57(Nav, _super);
- function Nav(viewCtrl, parent, app, config, plt, elementRef, zone, renderer, cfr, gestureCtrl, transCtrl, linker, domCtrl, errHandler) {
- var _this = _super.call(this, parent, app, config, plt, elementRef, zone, renderer, cfr, gestureCtrl, transCtrl, linker, domCtrl, errHandler) || this;
- _this._hasInit = false;
- if (viewCtrl) {
- // an ion-nav can also act as an ion-page within a parent ion-nav
- // this would happen when an ion-nav nests a child ion-nav.
- viewCtrl._setContent(_this);
- }
- if (parent) {
- // this Nav has a parent Nav
- parent.registerChildNav(_this);
- }
- else if (viewCtrl && viewCtrl.getNav()) {
- // this Nav was opened from a modal
- _this.parent = viewCtrl.getNav();
- _this.parent.registerChildNav(_this);
- }
- else if (app && !app.getRootNavById(_this.id)) {
- // a root nav has not been registered yet with the app
- // this is the root navcontroller for the entire app
- app.registerRootNav(_this);
- }
- return _this;
- }
- Object.defineProperty(Nav.prototype, "_vp", {
- /**
- * @hidden
- */
- set: function (val) {
- this.setViewport(val);
- },
- enumerable: true,
- configurable: true
- });
- Nav.prototype.ngAfterViewInit = function () {
- var _this = this;
- this._hasInit = true;
- var segment = this._linker.getSegmentByNavIdOrName(this.id, this.name);
- if (segment && (segment.component || segment.loadChildren)) {
- return this._linker.initViews(segment).then(function (views) {
- return _this.setPages(views, null, null);
- });
- }
- else if (this._root) {
- // no segment match, so use the root property but don't set the url I guess
- var setUrl = segment ? false : true;
- return this.push(this._root, this.rootParams, {
- isNavRoot: (this._app.getRootNavById(this.id) === this),
- updateUrl: setUrl
- }, null);
- }
- };
- Object.defineProperty(Nav.prototype, "root", {
- /**
- * @input {Page} The Page component to load as the root page within this nav.
- */
- get: function () {
- return this._root;
- },
- set: function (page) {
- this._root = page;
- if (this._hasInit) {
- this.setRoot(page);
- }
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @hidden
- */
- Nav.prototype.ngOnDestroy = function () {
- this.destroy();
- };
- Nav.prototype.initPane = function () {
- var isMain = this._elementRef.nativeElement.hasAttribute('main');
- return isMain;
- };
- Nav.prototype.paneChanged = function (isPane) {
- if (isPane) {
- this.resize();
- }
- };
- Nav.prototype.goToRoot = function (opts) {
- return this.setRoot(this._root, this.rootParams, opts, null);
- };
- /*
- * @private
- */
- Nav.prototype.getType = function () {
- return 'nav';
- };
- /*
- * @private
- */
- Nav.prototype.getSecondaryIdentifier = function () {
- return null;
- };
- Nav.decorators = [
- { type: Component, args: [{
- selector: 'ion-nav',
- template: '<div #viewport nav-viewport></div>' +
- '<div class="nav-decor"></div>',
- encapsulation: ViewEncapsulation.None,
- providers: [{ provide: RootNode, useExisting: forwardRef(function () { return Nav; }) }]
- },] },
- ];
- /** @nocollapse */
- Nav.ctorParameters = function () { return [
- { type: ViewController, decorators: [{ type: Optional },] },
- { type: NavController, decorators: [{ type: Optional },] },
- { type: App, },
- { type: Config, },
- { type: Platform, },
- { type: ElementRef, },
- { type: NgZone, },
- { type: Renderer, },
- { type: ComponentFactoryResolver, },
- { type: GestureController, },
- { type: TransitionController, },
- { type: DeepLinker, decorators: [{ type: Optional },] },
- { type: DomController, },
- { type: ErrorHandler, },
- ]; };
- Nav.propDecorators = {
- '_vp': [{ type: ViewChild, args: ['viewport', { read: ViewContainerRef },] },],
- 'root': [{ type: Input },],
- 'rootParams': [{ type: Input },],
- 'name': [{ type: Input },],
- };
- return Nav;
- }(NavControllerBase));
-
- /**
- * @name Menu
- * @description
- * The Menu component is a navigation drawer that slides in from the side of the current
- * view. By default, it slides in from the left, but the side can be overridden. The menu
- * will be displayed differently based on the mode, however the display type can be changed
- * to any of the available [menu types](#menu-types). The menu element should be a sibling
- * to the app's content element. There can be any number of menus attached to the content.
- * These can be controlled from the templates, or programmatically using the [MenuController](../../app/MenuController).
- *
- * @usage
- *
- * ```html
- * <ion-menu [content]="mycontent">
- * <ion-content>
- * <ion-list>
- * <p>some menu content, could be list items</p>
- * </ion-list>
- * </ion-content>
- * </ion-menu>
- *
- * <ion-nav #mycontent [root]="rootPage"></ion-nav>
- * ```
- *
- * To add a menu to an app, the `<ion-menu>` element should be added as a sibling to the `ion-nav` it will belongs
- * to. A [local variable](https://angular.io/docs/ts/latest/guide/user-input.html#local-variables)
- * should be added to the `ion-nav` and passed to the `ion-menu`s `content` property.
- *
- * This tells the menu what it is bound to and what element to watch for gestures.
- * In the below example, `content` is using [property binding](https://angular.io/docs/ts/latest/guide/template-syntax.html#!#property-binding)
- * because `mycontent` is a reference to the `<ion-nav>` element, and not a string.
- *
- *
- * ### Opening/Closing Menus
- *
- * There are several ways to open or close a menu. The menu can be **toggled** open or closed
- * from the template using the [MenuToggle](../MenuToggle) directive. It can also be
- * **closed** from the template using the [MenuClose](../MenuClose) directive. To display a menu
- * programmatically, inject the [MenuController](../MenuController) provider and call any of the
- * `MenuController` methods.
- *
- *
- * ### Menu Types
- *
- * The menu supports several display types: `overlay`, `reveal` and `push`. By default,
- * it will use the correct type based on the mode, but this can be changed. The default
- * type for both Material Design and Windows mode is `overlay`, and `reveal` is the default
- * type for iOS mode. The menu type can be changed in the app's [config](../../config/Config)
- * via the `menuType` property, or passed in the `type` property on the `<ion-menu>` element.
- * See [usage](#usage) below for examples of changing the menu type.
- *
- *
- * ### Navigation Bar Behavior
- *
- * If a [MenuToggle](../MenuToggle) button is added to the [Navbar](../../navbar/Navbar) of
- * a page, the button will only appear when the page it's in is currently a root page. The
- * root page is the initial page loaded in the app, or a page that has been set as the root
- * using the [setRoot](../../nav/NavController/#setRoot) method on the [NavController](../../nav/NavController).
- *
- * For example, say the application has two pages, `Page1` and `Page2`, and both have a
- * `MenuToggle` button in their navigation bars. Assume the initial page loaded into the app
- * is `Page1`, making it the root page. `Page1` will display the `MenuToggle` button, but once
- * `Page2` is pushed onto the navigation stack, the `MenuToggle` will not be displayed.
- *
- *
- * ### Persistent Menus
- *
- * Persistent menus display the [MenuToggle](../MenuToggle) button in the [Navbar](../../navbar/Navbar)
- * on all pages in the navigation stack. To make a menu persistent set `persistent` to `true` on the
- * `<ion-menu>` element. Note that this will only affect the `MenuToggle` button in the `Navbar` attached
- * to the `Menu` with `persistent` set to true, any other `MenuToggle` buttons will not be affected.
- * ### Menu Side
- *
- * By default, menus slide in from the left, but this can be overridden by passing `right`
- * to the `side` property:
- *
- * ```html
- * <ion-menu side="right" [content]="mycontent">...</ion-menu>
- * ```
- *
- *
- * ### Menu Type
- *
- * The menu type can be changed by passing the value to `type` on the `<ion-menu>`:
- *
- * ```html
- * <ion-menu type="overlay" [content]="mycontent">...</ion-menu>
- * ```
- *
- * It can also be set in the app's config. The below will set the menu type to
- * `push` for all modes, and then set the type to `overlay` for the `ios` mode.
- *
- * ```ts
- * // in NgModules
- *
- * imports: [
- * IonicModule.forRoot(MyApp,{
- * menuType: 'push',
- * platforms: {
- * ios: {
- * menuType: 'overlay',
- * }
- * }
- * })
- * ],
- * ```
- *
- *
- * ### Displaying the Menu
- *
- * To toggle a menu from the template, add a button with the `menuToggle`
- * directive anywhere in the page's template:
- *
- * ```html
- * <button ion-button menuToggle>Toggle Menu</button>
- * ```
- *
- * To close a menu, add the `menuClose` button. It can be added anywhere
- * in the content, or even the menu itself. Below it is added to the menu's
- * content:
- *
- * ```html
- * <ion-menu [content]="mycontent">
- * <ion-content>
- * <ion-list>
- * <ion-item menuClose detail-none>Close Menu</ion-item>
- * </ion-list>
- * </ion-content>
- * </ion-menu>
- * ```
- *
- * See the [MenuToggle](../MenuToggle) and [MenuClose](../MenuClose) docs
- * for more information on these directives.
- *
- * The menu can also be controlled from the Page by using the `MenuController`.
- * Inject the `MenuController` provider into the page and then call any of its
- * methods. In the below example, the `openMenu` method will open the menu
- * when it is called.
- *
- * ```ts
- * import { Component } from '@angular/core';
- * import { MenuController } from 'ionic-angular';
- *
- * @Component({...})
- * export class MyPage {
- * constructor(public menuCtrl: MenuController) {}
- *
- * openMenu() {
- * this.menuCtrl.open();
- * }
- * }
- * ```
- *
- * See the [MenuController](../../app/MenuController) API docs for all of the methods
- * and usage information.
- *
- *
- * @demo /docs/demos/src/menu/
- *
- * @see {@link /docs/components#menus Menu Component Docs}
- * @see {@link ../../app/MenuController MenuController API Docs}
- * @see {@link ../../nav/Nav Nav API Docs}
- * @see {@link ../../nav/NavController NavController API Docs}
- */
- var Menu = (function () {
- function Menu(_menuCtrl, _elementRef, _config, _plt, _renderer, _keyboard, _gestureCtrl, _domCtrl, _app) {
- this._menuCtrl = _menuCtrl;
- this._elementRef = _elementRef;
- this._config = _config;
- this._plt = _plt;
- this._renderer = _renderer;
- this._keyboard = _keyboard;
- this._gestureCtrl = _gestureCtrl;
- this._domCtrl = _domCtrl;
- this._app = _app;
- this._isSwipeEnabled = true;
- this._isAnimating = false;
- this._isPersistent = false;
- this._init = false;
- this._isPane = false;
- /**
- * @hidden
- */
- this.isOpen = false;
- /**
- * @hidden
- */
- this.isRightSide = false;
- /**
- * @output {event} Emitted when the menu is being dragged open.
- */
- this.ionDrag = new EventEmitter();
- /**
- * @output {event} Emitted when the menu has been opened.
- */
- this.ionOpen = new EventEmitter();
- /**
- * @output {event} Emitted when the menu has been closed.
- */
- this.ionClose = new EventEmitter();
- this._events = new UIEventManager(_plt);
- this._gestureBlocker = _gestureCtrl.createBlocker({
- disable: [GESTURE_GO_BACK_SWIPE]
- });
- this.side = 'start';
- }
- Object.defineProperty(Menu.prototype, "enabled", {
- /**
- * @input {boolean} If true, the menu is enabled. Default `true`.
- */
- get: function () {
- return this._isEnabled;
- },
- set: function (val) {
- var isEnabled = isTrueProperty(val);
- this.enable(isEnabled);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Menu.prototype, "side", {
- /**
- * @input {string} Which side of the view the menu should be placed. Default `"left"`.
- */
- get: function () {
- return this._side;
- },
- set: function (val) {
- this.isRightSide = isRightSide(val, this._plt.isRTL);
- if (this.isRightSide) {
- this._side = 'right';
- }
- else {
- this._side = 'left';
- }
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Menu.prototype, "swipeEnabled", {
- /**
- * @input {boolean} If true, swiping the menu is enabled. Default `true`.
- */
- get: function () {
- return this._isSwipeEnabled;
- },
- set: function (val) {
- var isEnabled = isTrueProperty(val);
- this.swipeEnable(isEnabled);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Menu.prototype, "persistent", {
- /**
- * @input {boolean} If true, the menu will persist on child pages.
- */
- get: function () {
- return this._isPersistent;
- },
- set: function (val) {
- this._isPersistent = isTrueProperty(val);
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @hidden
- */
- Menu.prototype.ngOnInit = function () {
- var _this = this;
- this._init = true;
- var content = this.content;
- this._cntEle = (content instanceof Node) ? content : content && content.getNativeElement && content.getNativeElement();
- // requires content element
- if (!this._cntEle) {
- return console.error('Menu: must have a [content] element to listen for drag events on. Example:\n\n<ion-menu [content]="content"></ion-menu>\n\n<ion-nav #content></ion-nav>');
- }
- this.setElementAttribute('side', this._side);
- // normalize the "type"
- if (!this.type) {
- this.type = this._config.get('menuType');
- }
- this.setElementAttribute('type', this.type);
- // add the gestures
- this._gesture = new MenuContentGesture(this._plt, this, this._gestureCtrl, this._domCtrl);
- // add menu's content classes
- this._cntEle.classList.add('menu-content');
- this._cntEle.classList.add('menu-content-' + this.type);
- var isEnabled = this._isEnabled;
- if (isEnabled === true || typeof isEnabled === 'undefined') {
- // check if more than one menu is on the same side
- isEnabled = !this._menuCtrl.getMenus().some(function (m) {
- return m.side === _this.side && m.enabled;
- });
- }
- // register this menu with the app's menu controller
- this._menuCtrl._register(this);
- // mask it as enabled / disabled
- this.enable(isEnabled);
- };
- /**
- * @hidden
- */
- Menu.prototype.onBackdropClick = function (ev) {
- ev.preventDefault();
- ev.stopPropagation();
- this._menuCtrl.close();
- };
- /**
- * @hidden
- */
- Menu.prototype._getType = function () {
- if (!this._type) {
- this._type = MenuController.create(this.type, this, this._plt);
- if (this._config.get('animate') === false) {
- this._type.ani.duration(0);
- }
- }
- return this._type;
- };
- /**
- * @hidden
- */
- Menu.prototype.setOpen = function (shouldOpen, animated) {
- var _this = this;
- if (animated === void 0) { animated = true; }
- // If the menu is disabled or it is currenly being animated, let's do nothing
- if ((shouldOpen === this.isOpen) || !this._canOpen() || this._isAnimating) {
- return Promise.resolve(this.isOpen);
- }
- return new Promise(function (resolve) {
- _this._before();
- _this._getType().setOpen(shouldOpen, animated, function () {
- _this._after(shouldOpen);
- resolve(_this.isOpen);
- });
- });
- };
- Menu.prototype._forceClosing = function () {
- var _this = this;
- (void 0) /* assert */;
- this._isAnimating = true;
- this._getType().setOpen(false, false, function () {
- _this._after(false);
- });
- };
- /**
- * @hidden
- */
- Menu.prototype.canSwipe = function () {
- return this._isSwipeEnabled &&
- !this._isAnimating &&
- this._canOpen() &&
- this._app.isEnabled();
- };
- /**
- * @hidden
- */
- Menu.prototype.isAnimating = function () {
- return this._isAnimating;
- };
- Menu.prototype._swipeBeforeStart = function () {
- if (!this.canSwipe()) {
- (void 0) /* assert */;
- return;
- }
- this._before();
- };
- Menu.prototype._swipeStart = function () {
- if (!this._isAnimating) {
- (void 0) /* assert */;
- return;
- }
- this._getType().setProgressStart(this.isOpen);
- };
- Menu.prototype._swipeProgress = function (stepValue) {
- if (!this._isAnimating) {
- (void 0) /* assert */;
- return;
- }
- this._getType().setProgessStep(stepValue);
- var ionDrag = this.ionDrag;
- if (ionDrag.observers.length > 0) {
- ionDrag.emit(stepValue);
- }
- };
- Menu.prototype._swipeEnd = function (shouldCompleteLeft, shouldCompleteRight, stepValue, velocity) {
- var _this = this;
- if (!this._isAnimating) {
- (void 0) /* assert */;
- return;
- }
- // user has finished dragging the menu
- var isRightSide$$1 = this.isRightSide;
- var isRTL = this._plt.isRTL;
- var opening = !this.isOpen;
- var shouldComplete = (opening)
- ? (isRightSide$$1 !== isRTL) ? shouldCompleteLeft : shouldCompleteRight
- : (isRightSide$$1 !== isRTL) ? shouldCompleteRight : shouldCompleteLeft;
- this._getType().setProgressEnd(shouldComplete, stepValue, velocity, function (isOpen) {
- (void 0) /* console.debug */;
- _this._after(isOpen);
- });
- };
- Menu.prototype._before = function () {
- (void 0) /* assert */;
- // this places the menu into the correct location before it animates in
- // this css class doesn't actually kick off any animations
- this.setElementClass('show-menu', true);
- this.backdrop.setElementClass('show-backdrop', true);
- this.resize();
- this._keyboard.close();
- this._isAnimating = true;
- };
- Menu.prototype._after = function (isOpen) {
- (void 0) /* assert */;
- this._app.setEnabled(false, 100);
- // keep opening/closing the menu disabled for a touch more yet
- // only add listeners/css if it's enabled and isOpen
- // and only remove listeners/css if it's not open
- // emit opened/closed events
- this.isOpen = isOpen;
- this._isAnimating = false;
- this._events.unlistenAll();
- if (isOpen) {
- // Disable swipe to go back gesture
- this._gestureBlocker.block();
- this._cntEle.classList.add('menu-content-open');
- var callback = this.onBackdropClick.bind(this);
- this._events.listen(this._cntEle, 'click', callback, { capture: true });
- this._events.listen(this.backdrop.getNativeElement(), 'click', callback, { capture: true });
- this.ionOpen.emit(true);
- }
- else {
- // Enable swipe to go back gesture
- this._gestureBlocker.unblock();
- this._cntEle.classList.remove('menu-content-open');
- this.setElementClass('show-menu', false);
- this.backdrop.setElementClass('show-menu', false);
- this.ionClose.emit(true);
- }
- };
- /**
- * @hidden
- */
- Menu.prototype.open = function () {
- return this.setOpen(true);
- };
- /**
- * @hidden
- */
- Menu.prototype.close = function () {
- return this.setOpen(false);
- };
- /**
- * @hidden
- */
- Menu.prototype.resize = function () {
- var content = this.menuContent
- ? this.menuContent
- : this.menuNav;
- content && content.resize();
- };
- /**
- * @hidden
- */
- Menu.prototype.toggle = function () {
- return this.setOpen(!this.isOpen);
- };
- Menu.prototype._canOpen = function () {
- return this._isEnabled && !this._isPane;
- };
- /**
- * @hidden
- */
- Menu.prototype._updateState = function () {
- var canOpen = this._canOpen();
- // Close menu inmediately
- if (!canOpen && this.isOpen) {
- (void 0) /* assert */;
- // close if this menu is open, and should not be enabled
- this._forceClosing();
- }
- if (this._isEnabled && this._menuCtrl) {
- this._menuCtrl._setActiveMenu(this);
- }
- if (!this._init) {
- return;
- }
- var gesture = this._gesture;
- // only listen/unlisten if the menu has initialized
- if (canOpen && this._isSwipeEnabled && !gesture.isListening) {
- // should listen, but is not currently listening
- (void 0) /* console.debug */;
- gesture.listen();
- }
- else if (gesture.isListening && (!canOpen || !this._isSwipeEnabled)) {
- // should not listen, but is currently listening
- (void 0) /* console.debug */;
- gesture.unlisten();
- }
- if (this.isOpen || (this._isPane && this._isEnabled)) {
- this.resize();
- }
- (void 0) /* assert */;
- };
- /**
- * @hidden
- */
- Menu.prototype.enable = function (shouldEnable) {
- this._isEnabled = shouldEnable;
- this.setElementClass('menu-enabled', shouldEnable);
- this._updateState();
- return this;
- };
- /**
- * @internal
- */
- Menu.prototype.initPane = function () {
- return false;
- };
- /**
- * @internal
- */
- Menu.prototype.paneChanged = function (isPane) {
- this._isPane = isPane;
- this._updateState();
- };
- /**
- * @hidden
- */
- Menu.prototype.swipeEnable = function (shouldEnable) {
- this._isSwipeEnabled = shouldEnable;
- this._updateState();
- return this;
- };
- /**
- * @hidden
- */
- Menu.prototype.getNativeElement = function () {
- return this._elementRef.nativeElement;
- };
- /**
- * @hidden
- */
- Menu.prototype.getMenuElement = function () {
- return this.getNativeElement().querySelector('.menu-inner');
- };
- /**
- * @hidden
- */
- Menu.prototype.getContentElement = function () {
- return this._cntEle;
- };
- /**
- * @hidden
- */
- Menu.prototype.getBackdropElement = function () {
- return this.backdrop.getNativeElement();
- };
- /**
- * @hidden
- */
- Menu.prototype.width = function () {
- return this.getMenuElement().offsetWidth;
- };
- /**
- * @hidden
- */
- Menu.prototype.getMenuController = function () {
- return this._menuCtrl;
- };
- /**
- * @hidden
- */
- Menu.prototype.setElementClass = function (className, add) {
- this._renderer.setElementClass(this._elementRef.nativeElement, className, add);
- };
- /**
- * @hidden
- */
- Menu.prototype.setElementAttribute = function (attributeName, value) {
- this._renderer.setElementAttribute(this._elementRef.nativeElement, attributeName, value);
- };
- /**
- * @hidden
- */
- Menu.prototype.getElementRef = function () {
- return this._elementRef;
- };
- /**
- * @hidden
- */
- Menu.prototype.ngOnDestroy = function () {
- this._menuCtrl._unregister(this);
- this._events.destroy();
- this._gesture && this._gesture.destroy();
- this._type && this._type.destroy();
- this._gesture = null;
- this._type = null;
- this._cntEle = null;
- };
- Menu.decorators = [
- { type: Component, args: [{
- selector: 'ion-menu',
- template: '<div class="menu-inner"><ng-content></ng-content></div>' +
- '<ion-backdrop></ion-backdrop>',
- host: {
- 'role': 'navigation'
- },
- changeDetection: ChangeDetectionStrategy.OnPush,
- encapsulation: ViewEncapsulation.None,
- providers: [{ provide: RootNode, useExisting: forwardRef(function () { return Menu; }) }]
- },] },
- ];
- /** @nocollapse */
- Menu.ctorParameters = function () { return [
- { type: MenuController, },
- { type: ElementRef, },
- { type: Config, },
- { type: Platform, },
- { type: Renderer, },
- { type: Keyboard, },
- { type: GestureController, },
- { type: DomController, },
- { type: App, },
- ]; };
- Menu.propDecorators = {
- 'backdrop': [{ type: ViewChild, args: [Backdrop,] },],
- 'menuContent': [{ type: ContentChild, args: [Content,] },],
- 'menuNav': [{ type: ContentChild, args: [Nav,] },],
- 'content': [{ type: Input },],
- 'id': [{ type: Input },],
- 'type': [{ type: Input },],
- 'enabled': [{ type: Input },],
- 'side': [{ type: Input },],
- 'swipeEnabled': [{ type: Input },],
- 'persistent': [{ type: Input },],
- 'maxEdgeStart': [{ type: Input },],
- 'ionDrag': [{ type: Output },],
- 'ionOpen': [{ type: Output },],
- 'ionClose': [{ type: Output },],
- };
- return Menu;
- }());
-
- /**
- * @name MenuClose
- * @description
- * The `menuClose` directive can be placed on any button to close an open menu.
- *
- * @usage
- *
- * A simple `menuClose` button can be added using the following markup:
- *
- * ```html
- * <button ion-button menuClose>Close Menu</button>
- * ```
- *
- * To close a certain menu by its id or side, give the `menuClose`
- * directive a value.
- *
- * ```html
- * <button ion-button menuClose="left">Close Left Menu</button>
- * ```
- *
- * @demo /docs/demos/src/menu/
- * @see {@link /docs/components#menus Menu Component Docs}
- * @see {@link ../../menu/Menu Menu API Docs}
- */
- var MenuClose = (function () {
- function MenuClose(_menu) {
- this._menu = _menu;
- }
- /**
- * @hidden
- */
- MenuClose.prototype.close = function () {
- var menu = this._menu.get(this.menuClose);
- menu && menu.close();
- };
- MenuClose.decorators = [
- { type: Directive, args: [{
- selector: '[menuClose]'
- },] },
- ];
- /** @nocollapse */
- MenuClose.ctorParameters = function () { return [
- { type: MenuController, },
- ]; };
- MenuClose.propDecorators = {
- 'menuClose': [{ type: Input },],
- 'close': [{ type: HostListener, args: ['click',] },],
- };
- return MenuClose;
- }());
-
- var __extends$60 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @hidden
- */
- var ToolbarBase = (function (_super) {
- __extends$60(ToolbarBase, _super);
- function ToolbarBase(config, elementRef, renderer) {
- return _super.call(this, config, elementRef, renderer, 'toolbar') || this;
- }
- /**
- * @hidden
- */
- ToolbarBase.prototype._setTitle = function (titleCmp) {
- this._title = titleCmp;
- };
- /**
- * @hidden
- * Returns the toolbar title text if it exists or an empty string
- */
- ToolbarBase.prototype.getTitleText = function () {
- return (this._title && this._title.getTitleText()) || '';
- };
- return ToolbarBase;
- }(Ion));
-
- var __extends$59 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @name Navbar
- * @description
- * Navbar acts as the navigational toolbar, which also comes with a back
- * button. A navbar can contain a `ion-title`, any number of buttons,
- * a segment, or a searchbar. Navbars must be placed within an
- * `<ion-header>` in order for them to be placed above the content.
- * It's important to note that navbar's are part of the dynamic navigation
- * stack. If you need a static toolbar, use ion-toolbar.
- *
- * @usage
- * ```html
- * <ion-header>
- *
- * <ion-navbar>
- * <button ion-button icon-only menuToggle>
- * <ion-icon name="menu"></ion-icon>
- * </button>
- *
- * <ion-title>
- * Page Title
- * </ion-title>
- *
- * <ion-buttons end>
- * <button ion-button icon-only (click)="openModal()">
- * <ion-icon name="options"></ion-icon>
- * </button>
- * </ion-buttons>
- * </ion-navbar>
- *
- * </ion-header>
- * ```
- *
- * @demo /docs/demos/src/navbar/
- * @see {@link ../../toolbar/Toolbar/ Toolbar API Docs}
- */
- var Navbar = (function (_super) {
- __extends$59(Navbar, _super);
- function Navbar(_app, viewCtrl, navCtrl, config, elementRef, renderer) {
- var _this = _super.call(this, config, elementRef, renderer) || this;
- _this._app = _app;
- _this.navCtrl = navCtrl;
- /**
- * @hidden
- */
- _this._hidden = false;
- /**
- * @hidden
- */
- _this._hideBb = false;
- viewCtrl && viewCtrl._setNavbar(_this);
- _this._bbIcon = config.get('backButtonIcon');
- _this._sbPadding = config.getBoolean('statusbarPadding');
- _this._backText = config.get('backButtonText', 'Back');
- return _this;
- }
- Object.defineProperty(Navbar.prototype, "hideBackButton", {
- /**
- * @input {boolean} If true, the back button will be hidden.
- */
- get: function () {
- return this._hideBb;
- },
- set: function (val) {
- this._hideBb = isTrueProperty(val);
- },
- enumerable: true,
- configurable: true
- });
- Navbar.prototype.backButtonClick = function (ev) {
- ev.preventDefault();
- ev.stopPropagation();
- this.navCtrl && this.navCtrl.pop(null, null);
- };
- /**
- * Set the text of the Back Button in the Nav Bar. Defaults to "Back".
- */
- Navbar.prototype.setBackButtonText = function (text) {
- this._backText = text;
- };
- /**
- * @hidden
- */
- Navbar.prototype.didEnter = function () {
- try {
- this._app.setTitle(this.getTitleText());
- }
- catch (e) {
- console.error(e);
- }
- };
- /**
- * @hidden
- */
- Navbar.prototype.setHidden = function (isHidden) {
- // used to display none/block the navbar
- this._hidden = isHidden;
- };
- Navbar.decorators = [
- { type: Component, args: [{
- selector: 'ion-navbar',
- template: '<div class="toolbar-background" [ngClass]="\'toolbar-background-\' + _mode"></div>' +
- '<button (click)="backButtonClick($event)" ion-button="bar-button" class="back-button" [ngClass]="\'back-button-\' + _mode" [hidden]="_hideBb">' +
- '<ion-icon class="back-button-icon" [ngClass]="\'back-button-icon-\' + _mode" [name]="_bbIcon"></ion-icon>' +
- '<span class="back-button-text" [ngClass]="\'back-button-text-\' + _mode">{{_backText}}</span>' +
- '</button>' +
- '<ng-content select="[menuToggle],ion-buttons[left]"></ng-content>' +
- '<ng-content select="ion-buttons[start]"></ng-content>' +
- '<ng-content select="ion-buttons[end],ion-buttons[right]"></ng-content>' +
- '<div class="toolbar-content" [ngClass]="\'toolbar-content-\' + _mode">' +
- '<ng-content></ng-content>' +
- '</div>',
- host: {
- '[hidden]': '_hidden',
- 'class': 'toolbar',
- '[class.statusbar-padding]': '_sbPadding'
- }
- },] },
- ];
- /** @nocollapse */
- Navbar.ctorParameters = function () { return [
- { type: App, },
- { type: ViewController, decorators: [{ type: Optional },] },
- { type: NavController, decorators: [{ type: Optional },] },
- { type: Config, },
- { type: ElementRef, },
- { type: Renderer, },
- ]; };
- Navbar.propDecorators = {
- 'hideBackButton': [{ type: Input },],
- };
- return Navbar;
- }(ToolbarBase));
-
- /**
- * @name MenuToggle
- * @description
- * The `menuToggle` directive can be placed on any button to toggle a menu open or closed.
- * If it is added to the [NavBar](../../toolbar/Navbar) of a page, the button will only appear
- * when the page it's in is currently a root page. See the [Menu Navigation Bar Behavior](../Menu#navigation-bar-behavior)
- * docs for more information.
- *
- *
- * @usage
- *
- * A simple `menuToggle` button can be added using the following markup:
- *
- * ```html
- * <button ion-button menuToggle>Toggle Menu</button>
- * ```
- *
- * To toggle a specific menu by its id or side, give the `menuToggle`
- * directive a value.
- *
- * ```html
- * <button ion-button menuToggle="right">Toggle Right Menu</button>
- * ```
- *
- * If placing the `menuToggle` in a navbar or toolbar, it should be
- * placed as a child of the `<ion-navbar>` or `<ion-toolbar>`, and not in
- * the `<ion-buttons>` element:
- *
- * ```html
- * <ion-header>
- *
- * <ion-navbar>
- * <ion-buttons start>
- * <button ion-button>
- * <ion-icon name="contact"></ion-icon>
- * </button>
- * </ion-buttons>
- * <button ion-button menuToggle>
- * <ion-icon name="menu"></ion-icon>
- * </button>
- * <ion-title>
- * Title
- * </ion-title>
- * <ion-buttons end>
- * <button ion-button (click)="doClick()">
- * <ion-icon name="more"></ion-icon>
- * </button>
- * </ion-buttons>
- * </ion-navbar>
- *
- * </ion-header>
- * ```
- *
- * Similar to `<ion-buttons>`, the `menuToggle` can be positioned using
- * `start`, `end`, `left`, or `right`:
- *
- * ```html
- * <ion-toolbar>
- * <button ion-button menuToggle right>
- * <ion-icon name="menu"></ion-icon>
- * </button>
- * <ion-title>
- * Title
- * </ion-title>
- * <ion-buttons end>
- * <button ion-button (click)="doClick()">
- * <ion-icon name="more"></ion-icon>
- * </button>
- * </ion-buttons>
- * </ion-toolbar>
- * ```
- *
- * See the [Toolbar API docs](../../toolbar/Toolbar) for more information
- * on the different positions.
- *
- * @demo /docs/demos/src/menu/
- * @see {@link /docs/components#menus Menu Component Docs}
- * @see {@link ../../menu/Menu Menu API Docs}
- */
- var MenuToggle = (function () {
- function MenuToggle(_menu, _viewCtrl, _button, _navbar) {
- this._menu = _menu;
- this._viewCtrl = _viewCtrl;
- this._button = _button;
- this._isButton = !!_button;
- this._inNavbar = !!_navbar;
- }
- MenuToggle.prototype.ngAfterContentInit = function () {
- // Add the bar-button-menutoggle / button-menutoggle class
- if (this._isButton) {
- this._button._setClass('menutoggle', true);
- }
- };
- /**
- * @hidden
- */
- MenuToggle.prototype.toggle = function () {
- var menu = this._menu.get(this.menuToggle);
- menu && menu.toggle();
- };
- Object.defineProperty(MenuToggle.prototype, "isHidden", {
- /**
- * @hidden
- */
- get: function () {
- var menu = this._menu.get(this.menuToggle);
- if (this._inNavbar && this._viewCtrl) {
- if (!menu || !menu._canOpen()) {
- return true;
- }
- if (this._viewCtrl.isFirst()) {
- // this is the first view, so it should always show
- return false;
- }
- if (menu) {
- // this is not the root view, so see if this menu
- // is configured to still be enabled if it's not the root view
- return !menu.persistent;
- }
- }
- return false;
- },
- enumerable: true,
- configurable: true
- });
- MenuToggle.decorators = [
- { type: Directive, args: [{
- selector: '[menuToggle]',
- host: {
- '[hidden]': 'isHidden'
- }
- },] },
- ];
- /** @nocollapse */
- MenuToggle.ctorParameters = function () { return [
- { type: MenuController, },
- { type: ViewController, decorators: [{ type: Optional },] },
- { type: Button, decorators: [{ type: Optional },] },
- { type: Navbar, decorators: [{ type: Optional },] },
- ]; };
- MenuToggle.propDecorators = {
- 'menuToggle': [{ type: Input },],
- 'toggle': [{ type: HostListener, args: ['click',] },],
- };
- return MenuToggle;
- }());
-
- var __extends$61 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @hidden
- * Menu Type
- * Base class which is extended by the various types. Each
- * type will provide their own animations for open and close
- * and registers itself with Menu.
- */
- var MenuType = (function () {
- function MenuType(plt) {
- this.ani = new Animation(plt);
- this.ani
- .easing('cubic-bezier(0.0, 0.0, 0.2, 1)')
- .easingReverse('cubic-bezier(0.4, 0.0, 0.6, 1)')
- .duration(280);
- }
- MenuType.prototype.setOpen = function (shouldOpen, animated, done) {
- var ani = this.ani
- .onFinish(done, true, true)
- .reverse(!shouldOpen);
- if (animated) {
- ani.play();
- }
- else {
- ani.syncPlay();
- }
- };
- MenuType.prototype.setProgressStart = function (isOpen) {
- this.isOpening = !isOpen;
- // the cloned animation should not use an easing curve during seek
- this.ani
- .reverse(isOpen)
- .progressStart();
- };
- MenuType.prototype.setProgessStep = function (stepValue) {
- // adjust progress value depending if it opening or closing
- this.ani.progressStep(stepValue);
- };
- MenuType.prototype.setProgressEnd = function (shouldComplete, currentStepValue, velocity, done) {
- var _this = this;
- var isOpen = (this.isOpening && shouldComplete);
- if (!this.isOpening && !shouldComplete) {
- isOpen = true;
- }
- var ani = this.ani;
- ani.onFinish(function () {
- _this.isOpening = false;
- done(isOpen);
- }, true);
- var factor = 1 - Math.min(Math.abs(velocity) / 4, 0.7);
- var dur = ani.getDuration() * factor;
- ani.progressEnd(shouldComplete, currentStepValue, dur);
- };
- MenuType.prototype.destroy = function () {
- this.ani.destroy();
- this.ani = null;
- };
- return MenuType;
- }());
- /**
- * @hidden
- * Menu Reveal Type
- * The content slides over to reveal the menu underneath.
- * The menu itself, which is under the content, does not move.
- */
- var MenuRevealType = (function (_super) {
- __extends$61(MenuRevealType, _super);
- function MenuRevealType(menu, plt) {
- var _this = _super.call(this, plt) || this;
- var openedX = (menu.width() * (menu.isRightSide ? -1 : 1)) + 'px';
- var contentOpen = new Animation(plt, menu.getContentElement());
- contentOpen.fromTo('translateX', '0px', openedX);
- _this.ani.add(contentOpen);
- return _this;
- }
- return MenuRevealType;
- }(MenuType));
- MenuController.registerType('reveal', MenuRevealType);
- /**
- * @hidden
- * Menu Push Type
- * The content slides over to reveal the menu underneath.
- * The menu itself also slides over to reveal its bad self.
- */
- var MenuPushType = (function (_super) {
- __extends$61(MenuPushType, _super);
- function MenuPushType(menu, plt) {
- var _this = _super.call(this, plt) || this;
- var contentOpenedX, menuClosedX, menuOpenedX;
- var width = menu.width();
- if (menu.isRightSide) {
- // right side
- contentOpenedX = -width + 'px';
- menuClosedX = width + 'px';
- menuOpenedX = '0px';
- }
- else {
- contentOpenedX = width + 'px';
- menuOpenedX = '0px';
- menuClosedX = -width + 'px';
- }
- var menuAni = new Animation(plt, menu.getMenuElement());
- menuAni.fromTo('translateX', menuClosedX, menuOpenedX);
- _this.ani.add(menuAni);
- var contentApi = new Animation(plt, menu.getContentElement());
- contentApi.fromTo('translateX', '0px', contentOpenedX);
- _this.ani.add(contentApi);
- return _this;
- }
- return MenuPushType;
- }(MenuType));
- MenuController.registerType('push', MenuPushType);
- /**
- * @hidden
- * Menu Overlay Type
- * The menu slides over the content. The content
- * itself, which is under the menu, does not move.
- */
- var MenuOverlayType = (function (_super) {
- __extends$61(MenuOverlayType, _super);
- function MenuOverlayType(menu, plt) {
- var _this = _super.call(this, plt) || this;
- var closedX, openedX;
- var width = menu.width();
- if (menu.isRightSide) {
- // right side
- closedX = 8 + width + 'px';
- openedX = '0px';
- }
- else {
- // left side
- closedX = -(8 + width) + 'px';
- openedX = '0px';
- }
- var menuAni = new Animation(plt, menu.getMenuElement());
- menuAni.fromTo('translateX', closedX, openedX);
- _this.ani.add(menuAni);
- var backdropApi = new Animation(plt, menu.getBackdropElement());
- backdropApi.fromTo('opacity', 0.01, 0.35);
- _this.ani.add(backdropApi);
- return _this;
- }
- return MenuOverlayType;
- }(MenuType));
- MenuController.registerType('overlay', MenuOverlayType);
-
- var OverlayProxy = (function () {
- function OverlayProxy(_app, _component, _config, _deepLinker) {
- this._app = _app;
- this._component = _component;
- this._config = _config;
- this._deepLinker = _deepLinker;
- }
- OverlayProxy.prototype.getImplementation = function () {
- throw new Error('Child class must implement "getImplementation" method');
- };
- /**
- * Present the modal instance.
- *
- * @param {NavOptions} [navOptions={}] Nav options to go with this transition.
- * @returns {Promise} Returns a promise which is resolved when the transition has completed.
- */
- OverlayProxy.prototype.present = function (navOptions) {
- var _this = this;
- if (navOptions === void 0) { navOptions = {}; }
- // check if it's a lazy loaded component, or not
- var isLazyLoaded = isString(this._component);
- if (isLazyLoaded) {
- return this._deepLinker.getComponentFromName(this._component).then(function (loadedComponent) {
- _this._component = loadedComponent;
- return _this.createAndPresentOverlay(navOptions);
- });
- }
- else {
- return this.createAndPresentOverlay(navOptions);
- }
- };
- OverlayProxy.prototype.dismiss = function (data, role, navOptions) {
- if (this.overlay) {
- return this.overlay.dismiss(data, role, navOptions);
- }
- };
- /**
- * Called when the current viewController has be successfully dismissed
- */
- OverlayProxy.prototype.onDidDismiss = function (callback) {
- this._onDidDismiss = callback;
- if (this.overlay) {
- this.overlay.onDidDismiss(this._onDidDismiss);
- }
- };
- OverlayProxy.prototype.createAndPresentOverlay = function (navOptions) {
- this.overlay = this.getImplementation();
- this.overlay.onWillDismiss(this._onWillDismiss);
- this.overlay.onDidDismiss(this._onDidDismiss);
- return this.overlay.present(navOptions);
- };
- /**
- * Called when the current viewController will be dismissed
- */
- OverlayProxy.prototype.onWillDismiss = function (callback) {
- this._onWillDismiss = callback;
- if (this.overlay) {
- this.overlay.onWillDismiss(this._onWillDismiss);
- }
- };
- return OverlayProxy;
- }());
-
- /**
- * NgModuleFactoryLoader that uses SystemJS to load NgModuleFactory
- */
- var NgModuleLoader = (function () {
- function NgModuleLoader(_compiler) {
- this._compiler = _compiler;
- }
- NgModuleLoader.prototype.load = function (modulePath, ngModuleExport) {
- var offlineMode = this._compiler instanceof Compiler;
- return offlineMode ? loadPrecompiledFactory(modulePath, ngModuleExport) : loadAndCompile(this._compiler, modulePath, ngModuleExport);
- };
- NgModuleLoader.decorators = [
- { type: Injectable },
- ];
- /** @nocollapse */
- NgModuleLoader.ctorParameters = function () { return [
- { type: Compiler, },
- ]; };
- return NgModuleLoader;
- }());
- function loadAndCompile(compiler, modulePath, ngModuleExport) {
- if (!ngModuleExport) {
- ngModuleExport = 'default';
- }
- return System.import(modulePath)
- .then(function (rawModule) {
- var module = rawModule[ngModuleExport];
- if (!module) {
- throw new Error("Module " + modulePath + " does not export " + ngModuleExport);
- }
- return compiler.compileModuleAsync(module);
- });
- }
- function loadPrecompiledFactory(modulePath, ngModuleExport) {
- return System.import(modulePath)
- .then(function (rawModule) {
- var ngModuleFactory = rawModule[ngModuleExport];
- if (!ngModuleFactory) {
- throw new Error("Module " + modulePath + " does not export " + ngModuleExport);
- }
- return ngModuleFactory;
- });
- }
-
- var LAZY_LOADED_TOKEN = new InjectionToken('LZYCMP');
- /**
- * @hidden
- */
- var ModuleLoader = (function () {
- function ModuleLoader(_ngModuleLoader, _injector) {
- this._ngModuleLoader = _ngModuleLoader;
- this._injector = _injector;
- /** @internal */
- this._cfrMap = new Map();
- this._promiseMap = new Map();
- }
- ModuleLoader.prototype.load = function (modulePath) {
- var _this = this;
- (void 0) /* console.time */;
- var splitString = modulePath.split(SPLITTER);
- var promise = this._promiseMap.get(modulePath);
- if (!promise) {
- promise = this._ngModuleLoader.load(splitString[0], splitString[1]);
- this._promiseMap.set(modulePath, promise);
- }
- return promise.then(function (loadedModule) {
- (void 0) /* console.timeEnd */;
- var ref = loadedModule.create(_this._injector);
- var component = ref.injector.get(LAZY_LOADED_TOKEN);
- _this._cfrMap.set(component, ref.componentFactoryResolver);
- return {
- componentFactoryResolver: ref.componentFactoryResolver,
- component: component
- };
- });
- };
- ModuleLoader.prototype.getComponentFactoryResolver = function (component) {
- return this._cfrMap.get(component);
- };
- ModuleLoader.decorators = [
- { type: Injectable },
- ];
- /** @nocollapse */
- ModuleLoader.ctorParameters = function () { return [
- { type: NgModuleLoader, },
- { type: Injector, },
- ]; };
- return ModuleLoader;
- }());
- var SPLITTER = '#';
- /**
- * @hidden
- */
- function provideModuleLoader(ngModuleLoader, injector) {
- return new ModuleLoader(ngModuleLoader, injector);
- }
- /**
- * @hidden
- */
- function setupPreloadingImplementation(config, deepLinkConfig, moduleLoader) {
- if (!deepLinkConfig || !deepLinkConfig.links || !config.getBoolean('preloadModules')) {
- return Promise.resolve();
- }
- var linksToLoad = deepLinkConfig.links.filter(function (link) { return !!link.loadChildren && link.priority !== 'off'; });
- // Load the high priority modules first
- var highPriorityPromises = linksToLoad
- .filter(function (link) { return link.priority === 'high'; })
- .map(function (link) { return moduleLoader.load(link.loadChildren); });
- return Promise.all(highPriorityPromises).then(function () {
- // Load the low priority modules after the high priority are done
- var lowPriorityPromises = linksToLoad
- .filter(function (link) { return link.priority === 'low'; })
- .map(function (link) { return moduleLoader.load(link.loadChildren); });
- return Promise.all(lowPriorityPromises);
- }).catch(function (err) {
- console.error(err.message);
- });
- }
- /**
- * @hidden
- */
- function setupPreloading(config, deepLinkConfig, moduleLoader, ngZone) {
- return function () {
- requestIonicCallback(function () {
- ngZone.runOutsideAngular(function () {
- setupPreloadingImplementation(config, deepLinkConfig, moduleLoader);
- });
- });
- };
- }
-
- /**
- * @hidden
- */
- var ModalCmp = (function () {
- function ModalCmp(_cfr, _renderer, _elementRef, _navParams, _viewCtrl, gestureCtrl, moduleLoader) {
- this._cfr = _cfr;
- this._renderer = _renderer;
- this._elementRef = _elementRef;
- this._navParams = _navParams;
- this._viewCtrl = _viewCtrl;
- this.moduleLoader = moduleLoader;
- var opts = _navParams.get('opts');
- (void 0) /* assert */;
- this._gestureBlocker = gestureCtrl.createBlocker({
- disable: [GESTURE_MENU_SWIPE, GESTURE_GO_BACK_SWIPE]
- });
- this._bdDismiss = opts.enableBackdropDismiss;
- if (opts.cssClass) {
- opts.cssClass.split(' ').forEach(function (cssClass) {
- // Make sure the class isn't whitespace, otherwise it throws exceptions
- if (cssClass.trim() !== '')
- _renderer.setElementClass(_elementRef.nativeElement, cssClass, true);
- });
- }
- }
- ModalCmp.prototype.ionViewPreLoad = function () {
- var component = this._navParams.data.component;
- if (!component) {
- console.warn('modal\'s page was not defined');
- return;
- }
- var cfr = this.moduleLoader.getComponentFactoryResolver(component);
- if (!cfr) {
- cfr = this._cfr;
- }
- var componentFactory = cfr.resolveComponentFactory(component);
- // ******** DOM WRITE ****************
- var componentRef = this._viewport.createComponent(componentFactory, this._viewport.length, this._viewport.parentInjector, []);
- this._setCssClass(componentRef, 'ion-page');
- this._setCssClass(componentRef, 'show-page');
- // Change the viewcontroller's instance to point the user provided page
- // Lifecycle events will be sent to the new instance, instead of the modal's component
- // we need to manually subscribe to them
- this._viewCtrl._setInstance(componentRef.instance);
- this._viewCtrl.willEnter.subscribe(this._viewWillEnter.bind(this));
- this._viewCtrl.didLeave.subscribe(this._viewDidLeave.bind(this));
- this._enabled = true;
- };
- ModalCmp.prototype._viewWillEnter = function () {
- this._gestureBlocker.block();
- };
- ModalCmp.prototype._viewDidLeave = function () {
- this._gestureBlocker.unblock();
- };
- ModalCmp.prototype._setCssClass = function (componentRef, className) {
- this._renderer.setElementClass(componentRef.location.nativeElement, className, true);
- };
- ModalCmp.prototype._bdClick = function () {
- if (this._enabled && this._bdDismiss) {
- var opts = {
- minClickBlockDuration: 400
- };
- return this._viewCtrl.dismiss(null, 'backdrop', opts);
- }
- };
- ModalCmp.prototype._keyUp = function (ev) {
- if (this._enabled && this._viewCtrl.isLast() && ev.keyCode === KEY_ESCAPE) {
- this._bdClick();
- }
- };
- ModalCmp.prototype.ngOnDestroy = function () {
- (void 0) /* assert */;
- this._gestureBlocker.destroy();
- };
- ModalCmp.decorators = [
- { type: Component, args: [{
- selector: 'ion-modal',
- template: '<ion-backdrop (click)="_bdClick()" [class.backdrop-no-tappable]="!_bdDismiss"></ion-backdrop>' +
- '<div class="modal-wrapper">' +
- '<div #viewport nav-viewport></div>' +
- '</div>'
- },] },
- ];
- /** @nocollapse */
- ModalCmp.ctorParameters = function () { return [
- { type: ComponentFactoryResolver, },
- { type: Renderer, },
- { type: ElementRef, },
- { type: NavParams, },
- { type: ViewController, },
- { type: GestureController, },
- { type: ModuleLoader, },
- ]; };
- ModalCmp.propDecorators = {
- '_viewport': [{ type: ViewChild, args: ['viewport', { read: ViewContainerRef },] },],
- '_keyUp': [{ type: HostListener, args: ['body:keyup', ['$event'],] },],
- };
- return ModalCmp;
- }());
-
- var __extends$64 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * Animations for modals
- */
- var ModalSlideIn = (function (_super) {
- __extends$64(ModalSlideIn, _super);
- function ModalSlideIn() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- ModalSlideIn.prototype.init = function () {
- _super.prototype.init.call(this);
- var ele = this.enteringView.pageRef().nativeElement;
- var backdropEle = ele.querySelector('ion-backdrop');
- var backdrop = new Animation(this.plt, backdropEle);
- var wrapper = new Animation(this.plt, ele.querySelector('.modal-wrapper'));
- wrapper.beforeStyles({ 'opacity': 1 });
- wrapper.fromTo('translateY', '100%', '0%');
- backdrop.fromTo('opacity', 0.01, 0.4);
- this
- .element(this.enteringView.pageRef())
- .easing('cubic-bezier(0.36,0.66,0.04,1)')
- .duration(400)
- .add(backdrop)
- .add(wrapper);
- };
- return ModalSlideIn;
- }(PageTransition));
- var ModalSlideOut = (function (_super) {
- __extends$64(ModalSlideOut, _super);
- function ModalSlideOut() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- ModalSlideOut.prototype.init = function () {
- _super.prototype.init.call(this);
- var ele = this.leavingView.pageRef().nativeElement;
- var backdrop = new Animation(this.plt, ele.querySelector('ion-backdrop'));
- var wrapperEle = ele.querySelector('.modal-wrapper');
- var wrapperEleRect = wrapperEle.getBoundingClientRect();
- var wrapper = new Animation(this.plt, wrapperEle);
- // height of the screen - top of the container tells us how much to scoot it down
- // so it's off-screen
- wrapper.fromTo('translateY', '0px', this.plt.height() - wrapperEleRect.top + "px");
- backdrop.fromTo('opacity', 0.4, 0.0);
- this
- .element(this.leavingView.pageRef())
- .easing('ease-out')
- .duration(250)
- .add(backdrop)
- .add(wrapper);
- };
- return ModalSlideOut;
- }(PageTransition));
- var ModalMDSlideIn = (function (_super) {
- __extends$64(ModalMDSlideIn, _super);
- function ModalMDSlideIn() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- ModalMDSlideIn.prototype.init = function () {
- _super.prototype.init.call(this);
- var ele = this.enteringView.pageRef().nativeElement;
- var backdrop = new Animation(this.plt, ele.querySelector('ion-backdrop'));
- var wrapper = new Animation(this.plt, ele.querySelector('.modal-wrapper'));
- backdrop.fromTo('opacity', 0.01, 0.4);
- wrapper.fromTo('translateY', '40px', '0px');
- wrapper.fromTo('opacity', 0.01, 1);
- var DURATION = 280;
- var EASING = 'cubic-bezier(0.36,0.66,0.04,1)';
- this.element(this.enteringView.pageRef()).easing(EASING).duration(DURATION)
- .add(backdrop)
- .add(wrapper);
- };
- return ModalMDSlideIn;
- }(PageTransition));
- var ModalMDSlideOut = (function (_super) {
- __extends$64(ModalMDSlideOut, _super);
- function ModalMDSlideOut() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- ModalMDSlideOut.prototype.init = function () {
- _super.prototype.init.call(this);
- var ele = this.leavingView.pageRef().nativeElement;
- var backdrop = new Animation(this.plt, ele.querySelector('ion-backdrop'));
- var wrapper = new Animation(this.plt, ele.querySelector('.modal-wrapper'));
- backdrop.fromTo('opacity', 0.4, 0.0);
- wrapper.fromTo('translateY', '0px', '40px');
- wrapper.fromTo('opacity', 0.99, 0);
- this
- .element(this.leavingView.pageRef())
- .duration(200)
- .easing('cubic-bezier(0.47,0,0.745,0.715)')
- .add(wrapper)
- .add(backdrop);
- };
- return ModalMDSlideOut;
- }(PageTransition));
-
- var __extends$63 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @hidden
- */
- var ModalImpl = (function (_super) {
- __extends$63(ModalImpl, _super);
- function ModalImpl(app, component, data, opts, config) {
- if (opts === void 0) { opts = {}; }
- var _this = this;
- data = data || {};
- data.component = component;
- opts.showBackdrop = isPresent(opts.showBackdrop) ? !!opts.showBackdrop : true;
- opts.enableBackdropDismiss = isPresent(opts.enableBackdropDismiss) ? !!opts.enableBackdropDismiss : true;
- data.opts = opts;
- _this = _super.call(this, ModalCmp, data, null) || this;
- _this._app = app;
- _this._enterAnimation = opts.enterAnimation;
- _this._leaveAnimation = opts.leaveAnimation;
- _this.isOverlay = true;
- config.setTransition('modal-slide-in', ModalSlideIn);
- config.setTransition('modal-slide-out', ModalSlideOut);
- config.setTransition('modal-md-slide-in', ModalMDSlideIn);
- config.setTransition('modal-md-slide-out', ModalMDSlideOut);
- return _this;
- }
- /**
- * @hidden
- */
- ModalImpl.prototype.getTransitionName = function (direction) {
- var key;
- if (direction === 'back') {
- if (this._leaveAnimation) {
- return this._leaveAnimation;
- }
- key = 'modalLeave';
- }
- else {
- if (this._enterAnimation) {
- return this._enterAnimation;
- }
- key = 'modalEnter';
- }
- return this._nav && this._nav.config.get(key);
- };
- /**
- * Present the action sheet instance.
- *
- * @param {NavOptions} [navOptions={}] Nav options to go with this transition.
- * @returns {Promise} Returns a promise which is resolved when the transition has completed.
- */
- ModalImpl.prototype.present = function (navOptions) {
- if (navOptions === void 0) { navOptions = {}; }
- navOptions.minClickBlockDuration = navOptions.minClickBlockDuration || 400;
- return this._app.present(this, navOptions, PORTAL_MODAL);
- };
- return ModalImpl;
- }(ViewController));
-
- var __extends$62 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @hidden
- */
- var Modal = (function (_super) {
- __extends$62(Modal, _super);
- function Modal(app, component, data, opts, config, deepLinker) {
- if (opts === void 0) { opts = {}; }
- var _this = _super.call(this, app, component, config, deepLinker) || this;
- _this.data = data;
- _this.opts = opts;
- _this.isOverlay = true;
- return _this;
- }
- Modal.prototype.getImplementation = function () {
- return new ModalImpl(this._app, this._component, this.data, this.opts, this._config);
- };
- return Modal;
- }(OverlayProxy));
-
- /**
- * @name ModalController
- * @description
- * A Modal is a content pane that goes over the user's current page.
- * Usually it is used for making a choice or editing an item. A modal uses the
- * `NavController` to
- * {@link /docs/api/components/nav/NavController/#present present}
- * itself in the root nav stack. It is added to the stack similar to how
- * {@link /docs/api/components/nav/NavController/#push NavController.push}
- * works.
- *
- * When a modal (or any other overlay such as an alert or actionsheet) is
- * "presented" to a nav controller, the overlay is added to the app's root nav.
- * After the modal has been presented, from within the component instance, the
- * modal can later be closed or "dismissed" by using the ViewController's
- * `dismiss` method. Additionally, you can dismiss any overlay by using `pop`
- * on the root nav controller. Modals are not reusable. When a modal is dismissed
- * it is destroyed.
- *
- * Data can be passed to a new modal through `Modal.create()` as the second
- * argument. The data can then be accessed from the opened page by injecting
- * `NavParams`. Note that the page, which opened as a modal, has no special
- * "modal" logic within it, but uses `NavParams` no differently than a
- * standard page.
- *
- * @usage
- * ```ts
- * import { ModalController, NavParams } from 'ionic-angular';
- *
- * @Component(...)
- * class HomePage {
- *
- * constructor(public modalCtrl: ModalController) { }
- *
- * presentProfileModal() {
- * const profileModal = this.modalCtrl.create(Profile, { userId: 8675309 });
- * profileModal.present();
- * }
- *
- * }
- *
- * @Component(...)
- * class Profile {
- *
- * constructor(params: NavParams) {
- * console.log('UserId', params.get('userId'));
- * }
- *
- * }
- * ```
- *
- * @advanced
- *
- * | Option | Type | Description |
- * |-----------------------|------------|------------------------------------------------------------------------------------------------------------------|
- * | showBackdrop |`boolean` | Whether to show the backdrop. Default true. |
- * | enableBackdropDismiss |`boolean` | Whether the popover should be dismissed by tapping the backdrop. Default true. |
- * | cssClass |`string` | Additional classes for custom styles, separated by spaces. |
- *
- * A modal can also emit data, which is useful when it is used to add or edit
- * data. For example, a profile page could slide up in a modal, and on submit,
- * the submit button could pass the updated profile data, then dismiss the
- * modal.
- *
- * ```ts
- * import { Component } from '@angular/core';
- * import { ModalController, ViewController } from 'ionic-angular';
- *
- * @Component(...)
- * class HomePage {
- *
- * constructor(public modalCtrl: ModalController) {
- *
- * }
- *
- * presentContactModal() {
- * let contactModal = this.modalCtrl.create(ContactUs);
- * contactModal.present();
- * }
- *
- * presentProfileModal() {
- * let profileModal = this.modalCtrl.create(Profile, { userId: 8675309 });
- * profileModal.onDidDismiss(data => {
- * console.log(data);
- * });
- * profileModal.present();
- * }
- *
- * }
- *
- * @Component(...)
- * class Profile {
- *
- * constructor(public viewCtrl: ViewController) {
- *
- * }
- *
- * dismiss() {
- * let data = { 'foo': 'bar' };
- * this.viewCtrl.dismiss(data);
- * }
- *
- * }
- * ```
- *
- * A common issue is that a developer may try to implement navigation in a modal, but when you try NavController.push(),
- * you will notice that the status bar on iOS gets cut off. The proper way to implement navigation in a modal is to
- * make the modal component a navigation container, and set the root page to the page you want to show in your modal.
- *
- * ```ts
- * @Component({
- * template: '<ion-nav [root]="rootPage" [rootParams]="rootParams"></ion-nav>'
- * })
- * export class MyModalWrapper {
- * rootPage = 'MyModalContentPage'; // This is the page you want your modal to display
- * rootParams;
- *
- * constructor(navParams: NavParams, private viewCtrl: ViewController) {
- * this.rootParams = Object.assign({}, navParams.data, {viewCtrl: viewCtrl});
- * // This line will send the view controller into your child views, so you can dismiss the modals from there.
- * }
- * }
- * ```
- * @demo /docs/demos/src/modal/
- * @see {@link /docs/components#modals Modal Component Docs}
- */
- var ModalController = (function () {
- function ModalController(_app, config, deepLinker) {
- this._app = _app;
- this.config = config;
- this.deepLinker = deepLinker;
- }
- /**
- * Create a modal to display. See below for options.
- *
- * @param {object} component The Modal view
- * @param {object} data Any data to pass to the Modal view
- * @param {object} opts Modal options
- */
- ModalController.prototype.create = function (component, data, opts) {
- if (data === void 0) { data = {}; }
- if (opts === void 0) { opts = {}; }
- return new Modal(this._app, component, data, opts, this.config, this.deepLinker);
- };
- ModalController.decorators = [
- { type: Injectable },
- ];
- /** @nocollapse */
- ModalController.ctorParameters = function () { return [
- { type: App, },
- { type: Config, },
- { type: DeepLinker, },
- ]; };
- return ModalController;
- }());
-
- /**
- * @name NavPop
- * @description
- * Directive to declaratively pop the current page off from the
- * navigation stack.
- *
- * @usage
- * ```html
- * <ion-content>
- *
- * <button ion-button navPop>Go Back</button>
- *
- * </ion-content>
- * ```
- *
- * Similar to {@link /docs/api/components/nav/NavPush/ `NavPush` }
- * @demo /docs/demos/src/navigation/
- * @see {@link /docs/components#navigation Navigation Component Docs}
- * @see {@link ../NavPush NavPush API Docs}
- */
- var NavPop = (function () {
- function NavPop(_nav) {
- this._nav = _nav;
- if (!_nav) {
- console.error('navPop must be within a NavController');
- }
- }
- /**
- * @hidden
- */
- NavPop.prototype.onClick = function () {
- // If no target, or if target is _self, prevent default browser behavior
- if (this._nav) {
- this._nav.pop().catch(function () {
- (void 0) /* console.debug */;
- });
- return false;
- }
- return true;
- };
- NavPop.decorators = [
- { type: Directive, args: [{
- selector: '[navPop]'
- },] },
- ];
- /** @nocollapse */
- NavPop.ctorParameters = function () { return [
- { type: NavController, decorators: [{ type: Optional },] },
- ]; };
- NavPop.propDecorators = {
- 'onClick': [{ type: HostListener, args: ['click',] },],
- };
- return NavPop;
- }());
-
- /**
- * @hidden
- */
- var NavPopAnchor = (function () {
- function NavPopAnchor(host, linker, viewCtrl) {
- this.host = host;
- this.linker = linker;
- this.viewCtrl = viewCtrl;
- }
- NavPopAnchor.prototype.updateHref = function () {
- if (this.host && this.viewCtrl) {
- var previousView = this.host._nav.getPrevious(this.viewCtrl);
- this._href = (previousView && this.linker.createUrl(this.host._nav, this.viewCtrl.component, this.viewCtrl.data)) || '#';
- }
- else {
- this._href = '#';
- }
- };
- NavPopAnchor.prototype.ngAfterContentInit = function () {
- this.updateHref();
- };
- NavPopAnchor.decorators = [
- { type: Directive, args: [{
- selector: 'a[navPop]',
- host: {
- '[attr.href]': '_href'
- }
- },] },
- ];
- /** @nocollapse */
- NavPopAnchor.ctorParameters = function () { return [
- { type: NavPop, decorators: [{ type: Optional },] },
- { type: DeepLinker, },
- { type: ViewController, decorators: [{ type: Optional },] },
- ]; };
- return NavPopAnchor;
- }());
-
- /**
- * @name NavPush
- * @description
- * Directive to declaratively push a new page to the current nav
- * stack.
- *
- * @usage
- * ```html
- * <button ion-button [navPush]="pushPage"></button>
- * ```
- *
- * To specify parameters you can use array syntax or the `navParams`
- * property:
- *
- * ```html
- * <button ion-button [navPush]="pushPage" [navParams]="params">Go</button>
- * ```
- *
- * Where `pushPage` and `params` are specified in your component,
- * and `pushPage` contains a reference to a
- * component you would like to push:
- *
- * ```ts
- * import { LoginPage } from './login';
- *
- * @Component({
- * template: `<button ion-button [navPush]="pushPage" [navParams]="params">Go</button>`
- * })
- * class MyPage {
- * pushPage: any;
- * params: Object;
- * constructor(){
- * this.pushPage = LoginPage;
- * this.params = { id: 42 };
- * }
- * }
- * ```
- *
- * @demo /docs/demos/src/navigation/
- * @see {@link /docs/components#navigation Navigation Component Docs}
- * @see {@link ../NavPop NavPop API Docs}
- *
- */
- var NavPush = (function () {
- function NavPush(_nav) {
- this._nav = _nav;
- if (!_nav) {
- console.error('navPush must be within a NavController');
- }
- }
- /**
- * @hidden
- */
- NavPush.prototype.onClick = function () {
- if (this._nav && this.navPush) {
- this._nav.push(this.navPush, this.navParams);
- return false;
- }
- return true;
- };
- NavPush.decorators = [
- { type: Directive, args: [{
- selector: '[navPush]'
- },] },
- ];
- /** @nocollapse */
- NavPush.ctorParameters = function () { return [
- { type: NavController, decorators: [{ type: Optional },] },
- ]; };
- NavPush.propDecorators = {
- 'navPush': [{ type: Input },],
- 'navParams': [{ type: Input },],
- 'onClick': [{ type: HostListener, args: ['click',] },],
- };
- return NavPush;
- }());
-
- /**
- * @hidden
- */
- var NavPushAnchor = (function () {
- function NavPushAnchor(host, linker) {
- this.host = host;
- this.linker = linker;
- }
- NavPushAnchor.prototype.updateHref = function () {
- if (this.host && this.linker) {
- this._href = this.linker.createUrl(this.host._nav, this.host.navPush, this.host.navParams) || '#';
- }
- else {
- this._href = '#';
- }
- };
- NavPushAnchor.prototype.ngAfterContentInit = function () {
- this.updateHref();
- };
- NavPushAnchor.decorators = [
- { type: Directive, args: [{
- selector: 'a[navPush]',
- host: {
- '[attr.href]': '_href'
- }
- },] },
- ];
- /** @nocollapse */
- NavPushAnchor.ctorParameters = function () { return [
- { type: NavPush, decorators: [{ type: Host },] },
- { type: DeepLinker, decorators: [{ type: Optional },] },
- ]; };
- return NavPushAnchor;
- }());
-
- var __extends$65 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @name Note
- * @module ionic
- * @description
- * A note is detailed item in an ion-item. It creates greyed out element that can be on the left or right side of an item.
- * @usage
- *
- * ```html
- * <ion-content>
- * <ion-list>
- * <ion-item>
- * <ion-note item-start>
- * Left Note
- * </ion-note>
- * My Item
- * <ion-note item-end>
- * Right Note
- * </ion-note>
- * </ion-item>
- * </ion-list>
- * </ion-content>
- *```
- * {@link /docs/api/components/api/components/item/item ion-item}
- */
- var Note = (function (_super) {
- __extends$65(Note, _super);
- function Note(config, elementRef, renderer) {
- return _super.call(this, config, elementRef, renderer, 'note') || this;
- }
- Note.decorators = [
- { type: Directive, args: [{
- selector: 'ion-note'
- },] },
- ];
- /** @nocollapse */
- Note.ctorParameters = function () { return [
- { type: Config, },
- { type: ElementRef, },
- { type: Renderer, },
- ]; };
- return Note;
- }(Ion));
-
- /**
- * @name Option
- * @description
- * `ion-option` is a child component of `ion-select`. Similar to the native option element, `ion-option` can take a value and a selected property.
- *
- * @demo /docs/demos/src/select/
- */
- var Option = (function () {
- function Option(_elementRef) {
- this._elementRef = _elementRef;
- this._selected = false;
- this._disabled = false;
- /**
- * @output {any} Event to evaluate when option is selected.
- */
- this.ionSelect = new EventEmitter();
- }
- Object.defineProperty(Option.prototype, "disabled", {
- /**
- * @input {boolean} If true, the user cannot interact with this element.
- */
- get: function () {
- return this._disabled;
- },
- set: function (val) {
- this._disabled = isTrueProperty(val);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Option.prototype, "selected", {
- /**
- * @input {boolean} If true, the element is selected.
- */
- get: function () {
- return this._selected;
- },
- set: function (val) {
- this._selected = isTrueProperty(val);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Option.prototype, "value", {
- /**
- * @input {any} The value of the option.
- */
- get: function () {
- if (isPresent(this._value)) {
- return this._value;
- }
- return this.text;
- },
- set: function (val) {
- this._value = val;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Option.prototype, "text", {
- /**
- * @hidden
- */
- get: function () {
- return this._elementRef.nativeElement.textContent;
- },
- enumerable: true,
- configurable: true
- });
- Option.decorators = [
- { type: Directive, args: [{
- selector: 'ion-option'
- },] },
- ];
- /** @nocollapse */
- Option.ctorParameters = function () { return [
- { type: ElementRef, },
- ]; };
- Option.propDecorators = {
- 'disabled': [{ type: Input },],
- 'selected': [{ type: Input },],
- 'value': [{ type: Input },],
- 'ionSelect': [{ type: Output },],
- };
- return Option;
- }());
-
- /**
- * @hidden
- */
- var PopoverCmp = (function () {
- function PopoverCmp(_cfr, _elementRef, _renderer, _config, _navParams, _viewCtrl, gestureCtrl, moduleLoader) {
- this._cfr = _cfr;
- this._elementRef = _elementRef;
- this._renderer = _renderer;
- this._config = _config;
- this._navParams = _navParams;
- this._viewCtrl = _viewCtrl;
- this.moduleLoader = moduleLoader;
- this._gestureBlocker = gestureCtrl.createBlocker(BLOCK_ALL);
- this.d = _navParams.data.opts;
- _renderer.setElementClass(_elementRef.nativeElement, "popover-" + _config.get('mode'), true);
- if (this.d.cssClass) {
- this.d.cssClass.split(' ').forEach(function (cssClass) {
- // Make sure the class isn't whitespace, otherwise it throws exceptions
- if (cssClass.trim() !== '')
- _renderer.setElementClass(_elementRef.nativeElement, cssClass, true);
- });
- }
- this.id = (++popoverIds);
- }
- PopoverCmp.prototype.ionViewPreLoad = function () {
- this._load(this._navParams.data.component);
- };
- PopoverCmp.prototype._load = function (component) {
- if (component) {
- var cfr = this.moduleLoader.getComponentFactoryResolver(component);
- if (!cfr) {
- cfr = this._cfr;
- }
- var componentFactory = cfr.resolveComponentFactory(component);
- // ******** DOM WRITE ****************
- var componentRef = this._viewport.createComponent(componentFactory, this._viewport.length, this._viewport.parentInjector, []);
- this._viewCtrl._setInstance(componentRef.instance);
- this._enabled = true;
- // Subscribe to events in order to block gestures
- // TODO, should we unsubscribe? memory leak?
- this._viewCtrl.willEnter.subscribe(this._viewWillEnter.bind(this));
- this._viewCtrl.didLeave.subscribe(this._viewDidLeave.bind(this));
- }
- };
- PopoverCmp.prototype._viewWillEnter = function () {
- this._gestureBlocker.block();
- };
- PopoverCmp.prototype._viewDidLeave = function () {
- this._gestureBlocker.unblock();
- };
- PopoverCmp.prototype._setCssClass = function (componentRef, className) {
- this._renderer.setElementClass(componentRef.location.nativeElement, className, true);
- };
- PopoverCmp.prototype._bdClick = function () {
- if (this._enabled && this.d.enableBackdropDismiss) {
- return this._viewCtrl.dismiss(null, 'backdrop');
- }
- };
- PopoverCmp.prototype._keyUp = function (ev) {
- if (this._enabled && ev.keyCode === KEY_ESCAPE && this._viewCtrl.isLast()) {
- this._bdClick();
- }
- };
- PopoverCmp.prototype.ngOnDestroy = function () {
- (void 0) /* assert */;
- this._gestureBlocker.destroy();
- };
- PopoverCmp.decorators = [
- { type: Component, args: [{
- selector: 'ion-popover',
- template: '<ion-backdrop (click)="_bdClick()" [hidden]="!d.showBackdrop"></ion-backdrop>' +
- '<div class="popover-wrapper">' +
- '<div class="popover-arrow"></div>' +
- '<div class="popover-content">' +
- '<div class="popover-viewport">' +
- '<div #viewport nav-viewport></div>' +
- '</div>' +
- '</div>' +
- '</div>'
- },] },
- ];
- /** @nocollapse */
- PopoverCmp.ctorParameters = function () { return [
- { type: ComponentFactoryResolver, },
- { type: ElementRef, },
- { type: Renderer, },
- { type: Config, },
- { type: NavParams, },
- { type: ViewController, },
- { type: GestureController, },
- { type: ModuleLoader, },
- ]; };
- PopoverCmp.propDecorators = {
- '_viewport': [{ type: ViewChild, args: ['viewport', { read: ViewContainerRef },] },],
- '_keyUp': [{ type: HostListener, args: ['body:keyup', ['$event'],] },],
- };
- return PopoverCmp;
- }());
- var popoverIds = -1;
-
- var __extends$68 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * Animations for popover
- */
- var PopoverTransition = (function (_super) {
- __extends$68(PopoverTransition, _super);
- function PopoverTransition() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- PopoverTransition.prototype.mdPositionView = function (nativeEle, ev) {
- var originY = 'top';
- var originX = 'left';
- var popoverWrapperEle = nativeEle.querySelector('.popover-wrapper');
- // Popover content width and height
- var popoverEle = nativeEle.querySelector('.popover-content');
- var popoverDim = popoverEle.getBoundingClientRect();
- var popoverWidth = popoverDim.width;
- var popoverHeight = popoverDim.height;
- // Window body width and height
- var bodyWidth = this.plt.width();
- var bodyHeight = this.plt.height();
- // If ev was passed, use that for target element
- var targetDim = ev && ev.target && ev.target.getBoundingClientRect();
- var targetTop = (targetDim && 'top' in targetDim) ? targetDim.top : (bodyHeight / 2) - (popoverHeight / 2);
- var targetLeft = (targetDim && 'left' in targetDim) ? targetDim.left : (bodyWidth / 2) - (popoverWidth / 2);
- var targetHeight = targetDim && targetDim.height || 0;
- var popoverCSS = {
- top: targetTop,
- left: targetLeft
- };
- // If the popover left is less than the padding it is off screen
- // to the left so adjust it, else if the width of the popover
- // exceeds the body width it is off screen to the right so adjust
- if (popoverCSS.left < POPOVER_MD_BODY_PADDING) {
- popoverCSS.left = POPOVER_MD_BODY_PADDING;
- }
- else if (popoverWidth + POPOVER_MD_BODY_PADDING + popoverCSS.left > bodyWidth) {
- popoverCSS.left = bodyWidth - popoverWidth - POPOVER_MD_BODY_PADDING;
- originX = 'right';
- }
- // If the popover when popped down stretches past bottom of screen,
- // make it pop up if there's room above
- if (targetTop + targetHeight + popoverHeight > bodyHeight && targetTop - popoverHeight > 0) {
- popoverCSS.top = targetTop - popoverHeight;
- nativeEle.className = nativeEle.className + ' popover-bottom';
- originY = 'bottom';
- // If there isn't room for it to pop up above the target cut it off
- }
- else if (targetTop + targetHeight + popoverHeight > bodyHeight) {
- popoverEle.style.bottom = POPOVER_MD_BODY_PADDING + 'px';
- }
- popoverEle.style.top = popoverCSS.top + 'px';
- popoverEle.style.left = popoverCSS.left + 'px';
- popoverEle.style[this.plt.Css.transformOrigin] = originY + ' ' + originX;
- // Since the transition starts before styling is done we
- // want to wait for the styles to apply before showing the wrapper
- popoverWrapperEle.style.opacity = '1';
- };
- PopoverTransition.prototype.iosPositionView = function (nativeEle, ev) {
- var originY = 'top';
- var originX = 'left';
- var popoverWrapperEle = nativeEle.querySelector('.popover-wrapper');
- // Popover content width and height
- var popoverEle = nativeEle.querySelector('.popover-content');
- var popoverDim = popoverEle.getBoundingClientRect();
- var popoverWidth = popoverDim.width;
- var popoverHeight = popoverDim.height;
- // Window body width and height
- var bodyWidth = this.plt.width();
- var bodyHeight = this.plt.height();
- // If ev was passed, use that for target element
- var targetDim = ev && ev.target && ev.target.getBoundingClientRect();
- var targetTop = (targetDim && 'top' in targetDim) ? targetDim.top : (bodyHeight / 2) - (popoverHeight / 2);
- var targetLeft = (targetDim && 'left' in targetDim) ? targetDim.left : (bodyWidth / 2);
- var targetWidth = targetDim && targetDim.width || 0;
- var targetHeight = targetDim && targetDim.height || 0;
- // The arrow that shows above the popover on iOS
- var arrowEle = nativeEle.querySelector('.popover-arrow');
- var arrowDim = arrowEle.getBoundingClientRect();
- var arrowWidth = arrowDim.width;
- var arrowHeight = arrowDim.height;
- // If no ev was passed, hide the arrow
- if (!targetDim) {
- arrowEle.style.display = 'none';
- }
- var arrowCSS = {
- top: targetTop + targetHeight,
- left: targetLeft + (targetWidth / 2) - (arrowWidth / 2)
- };
- var popoverCSS = {
- top: targetTop + targetHeight + (arrowHeight - 1),
- left: targetLeft + (targetWidth / 2) - (popoverWidth / 2)
- };
- // If the popover left is less than the padding it is off screen
- // to the left so adjust it, else if the width of the popover
- // exceeds the body width it is off screen to the right so adjust
- //
- var checkSafeAreaLeft = false;
- var checkSafeAreaRight = false;
- // If the popover left is less than the padding it is off screen
- // to the left so adjust it, else if the width of the popover
- // exceeds the body width it is off screen to the right so adjust
- // 25 is a random/arbitrary number. It seems to work fine for ios11
- // and iPhoneX. Is it perfect? No. Does it work? Yes.
- if (popoverCSS.left < (POPOVER_IOS_BODY_PADDING + 25)) {
- checkSafeAreaLeft = true;
- popoverCSS.left = POPOVER_IOS_BODY_PADDING;
- }
- else if ((popoverWidth + POPOVER_IOS_BODY_PADDING + popoverCSS.left + 25) > bodyWidth) {
- // Ok, so we're on the right side of the screen,
- // but now we need to make sure we're still a bit further right
- // cus....notchurally... Again, 25 is random. It works tho
- checkSafeAreaRight = true;
- popoverCSS.left = bodyWidth - popoverWidth - POPOVER_IOS_BODY_PADDING;
- originX = 'right';
- }
- // make it pop up if there's room above
- if (targetTop + targetHeight + popoverHeight > bodyHeight && targetTop - popoverHeight > 0) {
- arrowCSS.top = targetTop - (arrowHeight + 1);
- popoverCSS.top = targetTop - popoverHeight - (arrowHeight - 1);
- nativeEle.className = nativeEle.className + ' popover-bottom';
- originY = 'bottom';
- // If there isn't room for it to pop up above the target cut it off
- }
- else if (targetTop + targetHeight + popoverHeight > bodyHeight) {
- popoverEle.style.bottom = POPOVER_IOS_BODY_PADDING + '%';
- }
- arrowEle.style.top = arrowCSS.top + 'px';
- arrowEle.style.left = arrowCSS.left + 'px';
- popoverEle.style.top = popoverCSS.top + 'px';
- popoverEle.style.left = popoverCSS.left + 'px';
- if (checkSafeAreaLeft) {
- if (CSS.supports('left', 'constant(safe-area-inset-left)')) {
- popoverEle.style.left = "calc(" + popoverCSS.left + "px + constant(safe-area-inset-left)";
- }
- else if (CSS.supports('left', 'env(safe-area-inset-left)')) {
- popoverEle.style.left = "calc(" + popoverCSS.left + "px + env(safe-area-inset-left)";
- }
- }
- if (checkSafeAreaRight) {
- if (CSS.supports('right', 'constant(safe-area-inset-right)')) {
- popoverEle.style.left = "calc(" + popoverCSS.left + "px - constant(safe-area-inset-right)";
- }
- else if (CSS.supports('right', 'env(safe-area-inset-right)')) {
- popoverEle.style.left = "calc(" + popoverCSS.left + "px - env(safe-area-inset-right)";
- }
- }
- popoverEle.style[this.plt.Css.transformOrigin] = originY + ' ' + originX;
- // Since the transition starts before styling is done we
- // want to wait for the styles to apply before showing the wrapper
- popoverWrapperEle.style.opacity = '1';
- };
- return PopoverTransition;
- }(PageTransition));
- var PopoverPopIn = (function (_super) {
- __extends$68(PopoverPopIn, _super);
- function PopoverPopIn() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- PopoverPopIn.prototype.init = function () {
- var ele = this.enteringView.pageRef().nativeElement;
- var backdrop = new Animation(this.plt, ele.querySelector('ion-backdrop'));
- var wrapper = new Animation(this.plt, ele.querySelector('.popover-wrapper'));
- wrapper.fromTo('opacity', 0.01, 1);
- backdrop.fromTo('opacity', 0.01, 0.08);
- this
- .easing('ease')
- .duration(100)
- .add(backdrop)
- .add(wrapper);
- };
- PopoverPopIn.prototype.play = function () {
- var _this = this;
- this.plt.raf(function () {
- _this.iosPositionView(_this.enteringView.pageRef().nativeElement, _this.opts.ev);
- _super.prototype.play.call(_this);
- });
- };
- return PopoverPopIn;
- }(PopoverTransition));
- var PopoverPopOut = (function (_super) {
- __extends$68(PopoverPopOut, _super);
- function PopoverPopOut() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- PopoverPopOut.prototype.init = function () {
- var ele = this.leavingView.pageRef().nativeElement;
- var backdrop = new Animation(this.plt, ele.querySelector('ion-backdrop'));
- var wrapper = new Animation(this.plt, ele.querySelector('.popover-wrapper'));
- wrapper.fromTo('opacity', 0.99, 0);
- backdrop.fromTo('opacity', 0.08, 0);
- this
- .easing('ease')
- .duration(500)
- .add(backdrop)
- .add(wrapper);
- };
- return PopoverPopOut;
- }(PopoverTransition));
- var PopoverMdPopIn = (function (_super) {
- __extends$68(PopoverMdPopIn, _super);
- function PopoverMdPopIn() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- PopoverMdPopIn.prototype.init = function () {
- var ele = this.enteringView.pageRef().nativeElement;
- var content = new Animation(this.plt, ele.querySelector('.popover-content'));
- var viewport = new Animation(this.plt, ele.querySelector('.popover-viewport'));
- content.fromTo('scale', 0.001, 1);
- viewport.fromTo('opacity', 0.01, 1);
- this
- .easing('cubic-bezier(0.36,0.66,0.04,1)')
- .duration(300)
- .add(content)
- .add(viewport);
- };
- PopoverMdPopIn.prototype.play = function () {
- var _this = this;
- this.plt.raf(function () {
- _this.mdPositionView(_this.enteringView.pageRef().nativeElement, _this.opts.ev);
- _super.prototype.play.call(_this);
- });
- };
- return PopoverMdPopIn;
- }(PopoverTransition));
- var PopoverMdPopOut = (function (_super) {
- __extends$68(PopoverMdPopOut, _super);
- function PopoverMdPopOut() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- PopoverMdPopOut.prototype.init = function () {
- var ele = this.leavingView.pageRef().nativeElement;
- var wrapper = new Animation(this.plt, ele.querySelector('.popover-wrapper'));
- wrapper.fromTo('opacity', 0.99, 0);
- this
- .easing('ease')
- .duration(500)
- .fromTo('opacity', 0.01, 1)
- .add(wrapper);
- };
- return PopoverMdPopOut;
- }(PopoverTransition));
- var POPOVER_IOS_BODY_PADDING = 2;
- var POPOVER_MD_BODY_PADDING = 12;
-
- var __extends$67 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @hidden
- */
- var PopoverImpl = (function (_super) {
- __extends$67(PopoverImpl, _super);
- function PopoverImpl(app, component, data, opts, config) {
- if (data === void 0) { data = {}; }
- if (opts === void 0) { opts = {}; }
- var _this = this;
- opts.showBackdrop = isPresent(opts.showBackdrop) ? !!opts.showBackdrop : true;
- opts.enableBackdropDismiss = isPresent(opts.enableBackdropDismiss) ? !!opts.enableBackdropDismiss : true;
- data.component = component;
- data.opts = opts;
- _this = _super.call(this, PopoverCmp, data, null) || this;
- _this._app = app;
- _this.isOverlay = true;
- config.setTransition('popover-pop-in', PopoverPopIn);
- config.setTransition('popover-pop-out', PopoverPopOut);
- config.setTransition('popover-md-pop-in', PopoverMdPopIn);
- config.setTransition('popover-md-pop-out', PopoverMdPopOut);
- return _this;
- }
- /**
- * @hidden
- */
- PopoverImpl.prototype.getTransitionName = function (direction) {
- var key = (direction === 'back' ? 'popoverLeave' : 'popoverEnter');
- return this._nav && this._nav.config.get(key);
- };
- /**
- * Present the popover instance.
- *
- * @param {NavOptions} [navOptions={}] Nav options to go with this transition.
- * @returns {Promise} Returns a promise which is resolved when the transition has completed.
- */
- PopoverImpl.prototype.present = function (navOptions) {
- if (navOptions === void 0) { navOptions = {}; }
- return this._app.present(this, navOptions);
- };
- return PopoverImpl;
- }(ViewController));
-
- var __extends$66 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @hidden
- */
- var Popover = (function (_super) {
- __extends$66(Popover, _super);
- function Popover(app, component, data, opts, config, deepLinker) {
- if (opts === void 0) { opts = {}; }
- var _this = _super.call(this, app, component, config, deepLinker) || this;
- _this.data = data;
- _this.opts = opts;
- _this.isOverlay = true;
- return _this;
- }
- Popover.prototype.getImplementation = function () {
- return new PopoverImpl(this._app, this._component, this.data, this.opts, this._config);
- };
- return Popover;
- }(OverlayProxy));
-
- /**
- * @name PopoverController
- * @description
- * A Popover is a dialog that appears on top of the current page.
- * It can be used for anything, but generally it is used for overflow
- * actions that don't fit in the navigation bar.
- *
- * ### Creating
- * A popover can be created by calling the `create` method. The view
- * to display in the popover should be passed as the first argument.
- * Any data to pass to the popover view can optionally be passed in
- * the second argument. Options for the popover can optionally be
- * passed in the third argument. See the [create](#create) method
- * below for all available options.
- *
- * ### Presenting
- * To present a popover, call the `present` method on a PopoverController instance.
- * In order to position the popover relative to the element clicked, a click event
- * needs to be passed into the options of the the `present method. If the event
- * is not passed, the popover will be positioned in the center of the current
- * view. See the [usage](#usage) section for an example of passing this event.
- *
- * ### Dismissing
- * To dismiss the popover after creation, call the `dismiss()` method on the
- * `Popover` instance. The popover can also be dismissed from within the popover's
- * view by calling the `dismiss()` method on the [ViewController](../../navigation/ViewController).
- * The `dismiss()` call accepts an optional parameter that will be passed to the callback described
- * as follows. The `onDidDismiss(<func>)` function can be called to set up a callback action that will
- * be performed after the popover is dismissed, receiving the parameter passed to `dismiss()`.
- * The popover will dismiss when the backdrop is clicked by implicitly performing `dismiss(null)`,
- * but this can be disabled by setting `enableBackdropDismiss` to `false` in the popover options.
- *
- * > Note that after the component is dismissed, it will not be usable anymore and
- * another one must be created. This can be avoided by wrapping the creation and
- * presentation of the component in a reusable function as shown in the [usage](#usage)
- * section below.
- *
- * @usage
- *
- * To open a popover on the click of a button, pass `$event` to the method
- * which creates and presents the popover:
- *
- * ```html
- * <button ion-button icon-only (click)="presentPopover($event)">
- * <ion-icon name="more"></ion-icon>
- * </button>
- * ```
- *
- * ```ts
- * import { PopoverController } from 'ionic-angular';
- *
- * @Component({})
- * class MyPage {
- * constructor(public popoverCtrl: PopoverController) {}
- *
- * presentPopover(myEvent) {
- * let popover = this.popoverCtrl.create(PopoverPage);
- * popover.present({
- * ev: myEvent
- * });
- * }
- * }
- * ```
- *
- * The `PopoverPage` will display inside of the popover, and
- * can be anything. Below is an example of a page with items
- * that close the popover on click.
- *
- * ```ts
- * @Component({
- * template: `
- * <ion-list>
- * <ion-list-header>Ionic</ion-list-header>
- * <button ion-item (click)="close()">Learn Ionic</button>
- * <button ion-item (click)="close()">Documentation</button>
- * <button ion-item (click)="close()">Showcase</button>
- * <button ion-item (click)="close()">GitHub Repo</button>
- * </ion-list>
- * `
- * })
- * class PopoverPage {
- * constructor(public viewCtrl: ViewController) {}
- *
- * close() {
- * this.viewCtrl.dismiss();
- * }
- * }
- * ```
- * @advanced
- * Popover Options
- *
- * | Option | Type | Description |
- * |-----------------------|------------|------------------------------------------------------------------------------------------------------------------|
- * | cssClass |`string` | Additional classes for custom styles, separated by spaces. |
- * | showBackdrop |`boolean` | Whether to show the backdrop. Default true. |
- * | enableBackdropDismiss |`boolean` | Whether the popover should be dismissed by tapping the backdrop. Default true. |
- *
- *
- *
- * @demo /docs/demos/src/popover/
- */
- var PopoverController = (function () {
- function PopoverController(_app, config, _deepLinker) {
- this._app = _app;
- this.config = config;
- this._deepLinker = _deepLinker;
- }
- /**
- * Present a popover. See below for options
- * @param {object} component The Popover
- * @param {object} data Any data to pass to the Popover view
- * @param {PopoverOptions} opts Popover options
- */
- PopoverController.prototype.create = function (component, data, opts) {
- if (data === void 0) { data = {}; }
- if (opts === void 0) { opts = {}; }
- return new Popover(this._app, component, data, opts, this.config, this._deepLinker);
- };
- PopoverController.decorators = [
- { type: Injectable },
- ];
- /** @nocollapse */
- PopoverController.ctorParameters = function () { return [
- { type: App, },
- { type: Config, },
- { type: DeepLinker, },
- ]; };
- return PopoverController;
- }());
-
- /**
- * @name RadioGroup
- * @description
- * A radio group is a group of [radio buttons](../RadioButton). It allows
- * a user to select at most one radio button from a set. Checking one radio
- * button that belongs to a radio group unchecks any previous checked
- * radio button within the same group.
- *
- * See the [Angular Forms Docs](https://angular.io/docs/ts/latest/guide/forms.html)
- * for more information on forms and inputs.
- *
- * @usage
- * ```html
- * <ion-list radio-group [(ngModel)]="autoManufacturers">
- *
- * <ion-list-header>
- * Auto Manufacturers
- * </ion-list-header>
- *
- * <ion-item>
- * <ion-label>Cord</ion-label>
- * <ion-radio value="cord"></ion-radio>
- * </ion-item>
- *
- * <ion-item>
- * <ion-label>Duesenberg</ion-label>
- * <ion-radio value="duesenberg"></ion-radio>
- * </ion-item>
- *
- * <ion-item>
- * <ion-label>Hudson</ion-label>
- * <ion-radio value="hudson"></ion-radio>
- * </ion-item>
- *
- * <ion-item>
- * <ion-label>Packard</ion-label>
- * <ion-radio value="packard"></ion-radio>
- * </ion-item>
- *
- * <ion-item>
- * <ion-label>Studebaker</ion-label>
- * <ion-radio value="studebaker"></ion-radio>
- * </ion-item>
- *
- * </ion-list>
- * ```
- *
- * @demo /docs/demos/src/radio/
- * @see {@link /docs/components#radio Radio Component Docs}
- * @see {@link ../RadioButton RadioButton API Docs}
- */
- var RadioGroup = (function () {
- function RadioGroup(_renderer, _elementRef, _cd) {
- this._renderer = _renderer;
- this._elementRef = _elementRef;
- this._cd = _cd;
- /**
- * @internal
- */
- this._disabled = false;
- /**
- * @hidden
- */
- this._btns = [];
- /**
- * @hidden
- */
- this._ids = -1;
- /**
- * @hidden
- */
- this._init = false;
- /**
- * @output {any} Emitted when the selected button has changed.
- */
- this.ionChange = new EventEmitter();
- this.id = ++radioGroupIds;
- }
- Object.defineProperty(RadioGroup.prototype, "disabled", {
- /**
- * @input {boolean} If true, the user cannot interact with any of the buttons in the group.
- */
- get: function () {
- return this._disabled;
- },
- set: function (val) {
- this._disabled = isTrueProperty(val);
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @hidden
- */
- RadioGroup.prototype.ngAfterContentInit = function () {
- var activeButton = this._btns.find(function (b) { return b.checked; });
- if (activeButton) {
- this._setActive(activeButton);
- }
- };
- /**
- * @hidden
- */
- RadioGroup.prototype.writeValue = function (val) {
- (void 0) /* console.debug */;
- this.value = val;
- if (this._init) {
- this._update();
- this.onTouched();
- this.ionChange.emit(val);
- }
- this._init = true;
- };
- /**
- * @hidden
- */
- RadioGroup.prototype.registerOnChange = function (fn) {
- var _this = this;
- this._fn = fn;
- this.onChange = function (val) {
- // onChange used when there's an formControlName
- (void 0) /* console.debug */;
- fn(val);
- _this.value = val;
- _this._update();
- _this.onTouched();
- _this.ionChange.emit(val);
- };
- };
- /**
- * @hidden
- */
- RadioGroup.prototype.registerOnTouched = function (fn) { this.onTouched = fn; };
- /**
- * @hidden
- */
- RadioGroup.prototype._update = function () {
- var _this = this;
- // loop through each of the radiobuttons
- var hasChecked = false;
- this._btns.forEach(function (radioButton) {
- // check this radiobutton if its value is
- // the same as the radiogroups value
- radioButton.checked = isCheckedProperty(_this.value, radioButton.value) && !hasChecked;
- if (radioButton.checked) {
- // if this button is checked, then set it as
- // the radiogroup's active descendant
- _this._setActive(radioButton);
- hasChecked = true;
- }
- });
- };
- /**
- * @hidden
- */
- RadioGroup.prototype._setActive = function (radioButton) {
- this._renderer.setElementAttribute(this._elementRef.nativeElement, 'aria-activedescendant', radioButton.id);
- };
- /**
- * @hidden
- */
- RadioGroup.prototype.add = function (button) {
- var _this = this;
- this._btns.push(button);
- // listen for radiobutton select events
- button.ionSelect.subscribe(function (val) {
- // this radiobutton has been selected
- _this.onChange(val);
- });
- return this.id + '-' + (++this._ids);
- };
- /**
- * @hidden
- */
- RadioGroup.prototype.remove = function (button) {
- var index = this._btns.indexOf(button);
- if (index > -1) {
- if (button.value === this.value) {
- this.value = null;
- }
- this._btns.splice(index, 1);
- }
- };
- Object.defineProperty(RadioGroup.prototype, "_header", {
- /**
- * @hidden
- */
- set: function (header) {
- if (header) {
- if (!header.id) {
- header.id = 'rg-hdr-' + this.id;
- }
- this._renderer.setElementAttribute(this._elementRef.nativeElement, 'aria-describedby', header.id);
- }
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @hidden
- */
- RadioGroup.prototype.onChange = function (val) {
- // onChange used when there is not an formControlName
- (void 0) /* console.debug */;
- this.value = val;
- this._update();
- this.onTouched();
- this.ionChange.emit(val);
- this._cd.detectChanges();
- };
- /**
- * @hidden
- */
- RadioGroup.prototype.onTouched = function () { };
- /**
- * @hidden
- */
- RadioGroup.prototype.setDisabledState = function (isDisabled) {
- this.disabled = isDisabled;
- };
- RadioGroup.decorators = [
- { type: Directive, args: [{
- selector: '[radio-group]',
- host: {
- 'role': 'radiogroup'
- },
- providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: RadioGroup, multi: true }],
- },] },
- ];
- /** @nocollapse */
- RadioGroup.ctorParameters = function () { return [
- { type: Renderer, },
- { type: ElementRef, },
- { type: ChangeDetectorRef, },
- ]; };
- RadioGroup.propDecorators = {
- 'disabled': [{ type: Input },],
- 'ionChange': [{ type: Output },],
- '_header': [{ type: ContentChild, args: [ListHeader,] },],
- };
- return RadioGroup;
- }());
- var radioGroupIds = -1;
-
- var __extends$69 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @description
- * A radio button is a button that can be either checked or unchecked. A user can tap
- * the button to check or uncheck it. It can also be checked from the template using
- * the `checked` property.
- *
- * Use an element with a `radio-group` attribute to group a set of radio buttons. When
- * radio buttons are inside a [radio group](../RadioGroup), exactly one radio button
- * in the group can be checked at any time. If a radio button is not placed in a group,
- * they will all have the ability to be checked at the same time.
- *
- * See the [Angular Forms Docs](https://angular.io/docs/ts/latest/guide/forms.html) for
- * more information on forms and input.
- *
- * @usage
- * ```html
- * <ion-list radio-group [(ngModel)]="relationship">
- * <ion-item>
- * <ion-label>Friends</ion-label>
- * <ion-radio value="friends" checked></ion-radio>
- * </ion-item>
- * <ion-item>
- * <ion-label>Family</ion-label>
- * <ion-radio value="family"></ion-radio>
- * </ion-item>
- * <ion-item>
- * <ion-label>Enemies</ion-label>
- * <ion-radio value="enemies" [disabled]="isDisabled"></ion-radio>
- * </ion-item>
- * </ion-list>
- * ```
- * @demo /docs/demos/src/radio/
- * @see {@link /docs/components#radio Radio Component Docs}
- * @see {@link ../RadioGroup RadioGroup API Docs}
- */
- var RadioButton = (function (_super) {
- __extends$69(RadioButton, _super);
- function RadioButton(_form, config, elementRef, renderer, _item, _group) {
- var _this = _super.call(this, config, elementRef, renderer, 'radio') || this;
- _this._form = _form;
- _this._item = _item;
- _this._group = _group;
- /**
- * @internal
- */
- _this._checked = false;
- /**
- * @internal
- */
- _this._disabled = false;
- /**
- * @internal
- */
- _this._value = null;
- /**
- * @output {any} Emitted when the radio button is selected.
- */
- _this.ionSelect = new EventEmitter();
- _form.register(_this);
- if (_group) {
- // register with the radiogroup
- _this.id = 'rb-' + _group.add(_this);
- }
- if (_item) {
- // register the input inside of the item
- // reset to the item's id instead of the radiogroup id
- _this.id = 'rb-' + _item.registerInput('radio');
- _this._labelId = 'lbl-' + _item.id;
- _this._item.setElementClass('item-radio', true);
- }
- return _this;
- }
- Object.defineProperty(RadioButton.prototype, "color", {
- /**
- * @input {string} The color to use from your Sass `$colors` map.
- * Default options are: `"primary"`, `"secondary"`, `"danger"`, `"light"`, and `"dark"`.
- * For more information, see [Theming your App](/docs/theming/theming-your-app).
- */
- set: function (val) {
- this._setColor(val);
- if (this._item) {
- this._item._updateColor(val, 'item-radio');
- }
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(RadioButton.prototype, "value", {
- /**
- * @input {any} The value of the radio button. Defaults to the generated id.
- */
- get: function () {
- // if the value is not defined then use it's unique id
- return isBlank$1(this._value) ? this.id : this._value;
- },
- set: function (val) {
- this._value = val;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(RadioButton.prototype, "checked", {
- /**
- * @input {boolean} If true, the element is selected, and other buttons in the group are unselected.
- */
- get: function () {
- return this._checked;
- },
- set: function (val) {
- this._checked = isTrueProperty(val);
- if (this._item) {
- this._item.setElementClass('item-radio-checked', this._checked);
- }
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(RadioButton.prototype, "disabled", {
- /**
- * @input {boolean} If true, the user cannot interact with this element.
- */
- get: function () {
- return this._disabled || (this._group != null && this._group.disabled);
- },
- set: function (val) {
- this._disabled = isTrueProperty(val);
- this._item && this._item.setElementClass('item-radio-disabled', this._disabled);
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @hidden
- */
- RadioButton.prototype.initFocus = function () {
- this._elementRef.nativeElement.querySelector('button').focus();
- };
- /**
- * @internal
- */
- RadioButton.prototype._click = function (ev) {
- (void 0) /* console.debug */;
- ev.preventDefault();
- ev.stopPropagation();
- this.checked = true;
- this.ionSelect.emit(this.value);
- };
- /**
- * @internal
- */
- RadioButton.prototype.ngOnInit = function () {
- if (this._group && isPresent(this._group.value)) {
- this.checked = isCheckedProperty(this._group.value, this.value);
- }
- if (this._group && this._group.disabled) {
- this.disabled = this._group.disabled;
- }
- };
- /**
- * @internal
- */
- RadioButton.prototype.ngOnDestroy = function () {
- this._form.deregister(this);
- this._group && this._group.remove(this);
- };
- RadioButton.decorators = [
- { type: Component, args: [{
- selector: 'ion-radio',
- template: '<div class="radio-icon" [class.radio-checked]="_checked"> ' +
- '<div class="radio-inner"></div> ' +
- '</div> ' +
- '<button role="radio" ' +
- 'type="button" ' +
- 'ion-button="item-cover" ' +
- '[id]="id" ' +
- '[attr.aria-checked]="_checked" ' +
- '[attr.aria-labelledby]="_labelId" ' +
- '[attr.aria-disabled]="_disabled" ' +
- 'class="item-cover"> ' +
- '</button>',
- host: {
- '[class.radio-disabled]': '_disabled'
- },
- encapsulation: ViewEncapsulation.None,
- },] },
- ];
- /** @nocollapse */
- RadioButton.ctorParameters = function () { return [
- { type: Form, },
- { type: Config, },
- { type: ElementRef, },
- { type: Renderer, },
- { type: Item, decorators: [{ type: Optional },] },
- { type: RadioGroup, decorators: [{ type: Optional },] },
- ]; };
- RadioButton.propDecorators = {
- 'color': [{ type: Input },],
- 'ionSelect': [{ type: Output },],
- 'value': [{ type: Input },],
- 'checked': [{ type: Input },],
- 'disabled': [{ type: Input },],
- '_click': [{ type: HostListener, args: ['click', ['$event'],] },],
- };
- return RadioButton;
- }(Ion));
-
- var __extends$70 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @name Range
- * @description
- * The Range slider lets users select from a range of values by moving
- * the slider knob. It can accept dual knobs, but by default one knob
- * controls the value of the range.
- *
- * ### Range Labels
- * Labels can be placed on either side of the range by adding the
- * `range-left` or `range-right` property to the element. The element
- * doesn't have to be an `ion-label`, it can be added to any element
- * to place it to the left or right of the range. See [usage](#usage)
- * below for examples.
- *
- *
- * ### Minimum and Maximum Values
- * Minimum and maximum values can be passed to the range through the `min`
- * and `max` properties, respectively. By default, the range sets the `min`
- * to `0` and the `max` to `100`.
- *
- *
- * ### Steps and Snaps
- * The `step` property specifies the value granularity of the range's value.
- * It can be useful to set the `step` when the value isn't in increments of `1`.
- * Setting the `step` property will show tick marks on the range for each step.
- * The `snaps` property can be set to automatically move the knob to the nearest
- * tick mark based on the step property value.
- *
- *
- * ### Dual Knobs
- * Setting the `dualKnobs` property to `true` on the range component will
- * enable two knobs on the range. If the range has two knobs, the value will
- * be an object containing two properties: `lower` and `upper`.
- *
- *
- * @usage
- * ```html
- * <ion-list>
- * <ion-item>
- * <ion-range [(ngModel)]="singleValue" color="danger" pin="true"></ion-range>
- * </ion-item>
- *
- * <ion-item>
- * <ion-range min="-200" max="200" [(ngModel)]="saturation" color="secondary">
- * <ion-label range-left>-200</ion-label>
- * <ion-label range-right>200</ion-label>
- * </ion-range>
- * </ion-item>
- *
- * <ion-item>
- * <ion-range min="20" max="80" step="2" [(ngModel)]="brightness">
- * <ion-icon small range-left name="sunny"></ion-icon>
- * <ion-icon range-right name="sunny"></ion-icon>
- * </ion-range>
- * </ion-item>
- *
- * <ion-item>
- * <ion-label>step=100, snaps, {{singleValue4}}</ion-label>
- * <ion-range min="1000" max="2000" step="100" snaps="true" color="secondary" [(ngModel)]="singleValue4"></ion-range>
- * </ion-item>
- *
- * <ion-item>
- * <ion-label>dual, step=3, snaps, {{dualValue2 | json}}</ion-label>
- * <ion-range dualKnobs="true" [(ngModel)]="dualValue2" min="21" max="72" step="3" snaps="true"></ion-range>
- * </ion-item>
- * </ion-list>
- * ```
- *
- *
- * @demo /docs/demos/src/range/
- */
- var Range = (function (_super) {
- __extends$70(Range, _super);
- function Range(form, _haptic, item, config, _plt, elementRef, renderer, _dom, _cd) {
- var _this = _super.call(this, config, elementRef, renderer, 'range', 0, form, item, null) || this;
- _this._haptic = _haptic;
- _this._plt = _plt;
- _this._dom = _dom;
- _this._cd = _cd;
- _this._min = 0;
- _this._max = 100;
- _this._step = 1;
- _this._valA = 0;
- _this._valB = 0;
- _this._ratioA = 0;
- _this._ratioB = 0;
- _this._events = new UIEventManager(_plt);
- return _this;
- }
- Object.defineProperty(Range.prototype, "min", {
- /**
- * @input {number} Minimum integer value of the range. Defaults to `0`.
- */
- get: function () {
- return this._min;
- },
- set: function (val) {
- val = Math.round(val);
- if (!isNaN(val)) {
- this._min = val;
- this._inputUpdated();
- }
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Range.prototype, "max", {
- /**
- * @input {number} Maximum integer value of the range. Defaults to `100`.
- */
- get: function () {
- return this._max;
- },
- set: function (val) {
- val = Math.round(val);
- if (!isNaN(val)) {
- this._max = val;
- this._inputUpdated();
- }
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Range.prototype, "step", {
- /**
- * @input {number} Specifies the value granularity. Defaults to `1`.
- */
- get: function () {
- return this._step;
- },
- set: function (val) {
- val = Math.round(val);
- if (!isNaN(val) && val > 0) {
- this._step = val;
- }
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Range.prototype, "snaps", {
- /**
- * @input {boolean} If true, the knob snaps to tick marks evenly spaced based
- * on the step property value. Defaults to `false`.
- */
- get: function () {
- return this._snaps;
- },
- set: function (val) {
- this._snaps = isTrueProperty(val);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Range.prototype, "pin", {
- /**
- * @input {boolean} If true, a pin with integer value is shown when the knob
- * is pressed. Defaults to `false`.
- */
- get: function () {
- return this._pin;
- },
- set: function (val) {
- this._pin = isTrueProperty(val);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Range.prototype, "debounce", {
- /**
- * @input {number} How long, in milliseconds, to wait to trigger the
- * `ionChange` event after each change in the range value. Default `0`.
- */
- get: function () {
- return this._debouncer.wait;
- },
- set: function (val) {
- this._debouncer.wait = val;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Range.prototype, "dualKnobs", {
- /**
- * @input {boolean} Show two knobs. Defaults to `false`.
- */
- get: function () {
- return this._dual;
- },
- set: function (val) {
- this._dual = isTrueProperty(val);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Range.prototype, "ratio", {
- /**
- * Returns the ratio of the knob's is current location, which is a number
- * between `0` and `1`. If two knobs are used, this property represents
- * the lower value.
- */
- get: function () {
- if (this._dual) {
- return Math.min(this._ratioA, this._ratioB);
- }
- return this._ratioA;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Range.prototype, "ratioUpper", {
- /**
- * Returns the ratio of the upper value's is current location, which is
- * a number between `0` and `1`. If there is only one knob, then this
- * will return `null`.
- */
- get: function () {
- if (this._dual) {
- return Math.max(this._ratioA, this._ratioB);
- }
- return null;
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @hidden
- */
- Range.prototype.ngAfterContentInit = function () {
- this._initialize();
- // add touchstart/mousedown listeners
- this._events.pointerEvents({
- element: this._slider.nativeElement,
- pointerDown: this._pointerDown.bind(this),
- pointerMove: this._pointerMove.bind(this),
- pointerUp: this._pointerUp.bind(this),
- zone: true
- });
- // build all the ticks if there are any to show
- this._createTicks();
- };
- /** @internal */
- Range.prototype._pointerDown = function (ev) {
- // TODO: we could stop listening for events instead of checking this._disabled.
- // since there are a lot of events involved, this solution is
- // enough for the moment
- if (this._disabled) {
- return false;
- }
- // trigger ionFocus event
- this._fireFocus();
- // prevent default so scrolling does not happen
- ev.preventDefault();
- ev.stopPropagation();
- // get the start coordinates
- var current = pointerCoord(ev);
- // get the full dimensions of the slider element
- var rect = this._rect = this._plt.getElementBoundingClientRect(this._slider.nativeElement);
- // figure out which knob they started closer to
- var ratio = clamp(0, (current.x - rect.left) / (rect.width), 1);
- this._activeB = this._dual && (Math.abs(ratio - this._ratioA) > Math.abs(ratio - this._ratioB));
- // update the active knob's position
- this._update(current, rect, true);
- // trigger a haptic start
- this._haptic.gestureSelectionStart();
- // return true so the pointer events
- // know everything's still valid
- return true;
- };
- /** @internal */
- Range.prototype._pointerMove = function (ev) {
- if (this._disabled) {
- return;
- }
- // prevent default so scrolling does not happen
- ev.preventDefault();
- ev.stopPropagation();
- // update the active knob's position
- var hasChanged = this._update(pointerCoord(ev), this._rect, true);
- if (hasChanged && this._snaps) {
- // trigger a haptic selection changed event
- // if this is a snap range
- this._haptic.gestureSelectionChanged();
- }
- };
- /** @internal */
- Range.prototype._pointerUp = function (ev) {
- if (this._disabled) {
- return;
- }
- // prevent default so scrolling does not happen
- ev.preventDefault();
- ev.stopPropagation();
- // update the active knob's position
- this._update(pointerCoord(ev), this._rect, false);
- // trigger a haptic end
- this._haptic.gestureSelectionEnd();
- // trigger ionBlur event
- this._fireBlur();
- };
- /** @internal */
- Range.prototype._update = function (current, rect, isPressed) {
- // figure out where the pointer is currently at
- // update the knob being interacted with
- var ratio = clamp(0, (current.x - rect.left) / (rect.width), 1);
- var val = this._ratioToValue(ratio);
- if (this._snaps) {
- // snaps the ratio to the current value
- ratio = this._valueToRatio(val);
- }
- // update which knob is pressed
- this._pressed = isPressed;
- var valChanged = false;
- if (this._activeB) {
- // when the pointer down started it was determined
- // that knob B was the one they were interacting with
- this._pressedB = isPressed;
- this._pressedA = false;
- this._ratioB = ratio;
- valChanged = val === this._valB;
- this._valB = val;
- }
- else {
- // interacting with knob A
- this._pressedA = isPressed;
- this._pressedB = false;
- this._ratioA = ratio;
- valChanged = val === this._valA;
- this._valA = val;
- }
- this._updateBar();
- if (valChanged) {
- return false;
- }
- // value has been updated
- var value;
- if (this._dual) {
- // dual knobs have an lower and upper value
- value = {
- lower: Math.min(this._valA, this._valB),
- upper: Math.max(this._valA, this._valB)
- };
- (void 0) /* console.debug */;
- }
- else {
- // single knob only has one value
- value = this._valA;
- (void 0) /* console.debug */;
- }
- // Update input value
- this.value = value;
- return true;
- };
- /** @internal */
- Range.prototype._updateBar = function () {
- var ratioA = this._ratioA;
- var ratioB = this._ratioB;
- if (this._dual) {
- this._barL = (Math.min(ratioA, ratioB) * 100) + "%";
- this._barR = 100 - (Math.max(ratioA, ratioB) * 100) + "%";
- }
- else {
- this._barL = '';
- this._barR = 100 - (ratioA * 100) + "%";
- }
- this._updateTicks();
- };
- /** @internal */
- Range.prototype._createTicks = function () {
- var _this = this;
- if (this._snaps) {
- this._dom.write(function () {
- // TODO: Fix to not use RAF
- _this._ticks = [];
- for (var value = _this._min; value <= _this._max; value += _this._step) {
- var ratio = _this._valueToRatio(value);
- _this._ticks.push({
- ratio: ratio,
- left: ratio * 100 + "%",
- });
- }
- _this._updateTicks();
- });
- }
- };
- /** @internal */
- Range.prototype._updateTicks = function () {
- var ticks = this._ticks;
- var ratio = this.ratio;
- if (this._snaps && ticks) {
- if (this._dual) {
- var upperRatio = this.ratioUpper;
- ticks.forEach(function (t) {
- t.active = (t.ratio >= ratio && t.ratio <= upperRatio);
- });
- }
- else {
- ticks.forEach(function (t) {
- t.active = (t.ratio <= ratio);
- });
- }
- }
- };
- /** @hidden */
- Range.prototype._keyChg = function (isIncrease, isKnobB) {
- var step = this._step;
- if (isKnobB) {
- if (isIncrease) {
- this._valB += step;
- }
- else {
- this._valB -= step;
- }
- this._valB = clamp(this._min, this._valB, this._max);
- this._ratioB = this._valueToRatio(this._valB);
- }
- else {
- if (isIncrease) {
- this._valA += step;
- }
- else {
- this._valA -= step;
- }
- this._valA = clamp(this._min, this._valA, this._max);
- this._ratioA = this._valueToRatio(this._valA);
- }
- this._updateBar();
- };
- /** @internal */
- Range.prototype._ratioToValue = function (ratio) {
- ratio = Math.round(((this._max - this._min) * ratio));
- ratio = Math.round(ratio / this._step) * this._step + this._min;
- return clamp(this._min, ratio, this._max);
- };
- /** @internal */
- Range.prototype._valueToRatio = function (value) {
- value = Math.round((value - this._min) / this._step) * this._step;
- value = value / (this._max - this._min);
- return clamp(0, value, 1);
- };
- Range.prototype._inputNormalize = function (val) {
- if (this._dual) {
- return val;
- }
- else {
- val = parseFloat(val);
- return isNaN(val) ? undefined : val;
- }
- };
- /**
- * @hidden
- */
- Range.prototype._inputUpdated = function () {
- var val = this.value;
- if (this._dual) {
- this._valA = val.lower;
- this._valB = val.upper;
- this._ratioA = this._valueToRatio(val.lower);
- this._ratioB = this._valueToRatio(val.upper);
- }
- else {
- this._valA = val;
- this._ratioA = this._valueToRatio(val);
- }
- this._updateBar();
- this._cd.detectChanges();
- };
- /**
- * @hidden
- */
- Range.prototype.ngOnDestroy = function () {
- _super.prototype.ngOnDestroy.call(this);
- this._events.destroy();
- };
- Range.decorators = [
- { type: Component, args: [{
- selector: 'ion-range',
- template: '<ng-content select="[range-left]"></ng-content>' +
- '<div class="range-slider" #slider>' +
- '<div class="range-tick" *ngFor="let t of _ticks" [style.left]="t.left" [class.range-tick-active]="t.active" role="presentation"></div>' +
- '<div class="range-bar" role="presentation"></div>' +
- '<div class="range-bar range-bar-active" [style.left]="_barL" [style.right]="_barR" #bar role="presentation"></div>' +
- '<div class="range-knob-handle" (ionIncrease)="_keyChg(true, false)" (ionDecrease)="_keyChg(false, false)" [ratio]="_ratioA" [val]="_valA" [pin]="_pin" [pressed]="_pressedA" [min]="_min" [max]="_max" [disabled]="_disabled" [labelId]="_labelId"></div>' +
- '<div class="range-knob-handle" (ionIncrease)="_keyChg(true, true)" (ionDecrease)="_keyChg(false, true)" [ratio]="_ratioB" [val]="_valB" [pin]="_pin" [pressed]="_pressedB" [min]="_min" [max]="_max" [disabled]="_disabled" [labelId]="_labelId" *ngIf="_dual"></div>' +
- '</div>' +
- '<ng-content select="[range-right]"></ng-content>',
- host: {
- '[class.range-disabled]': '_disabled',
- '[class.range-pressed]': '_pressed',
- '[class.range-has-pin]': '_pin'
- },
- providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: Range, multi: true }],
- encapsulation: ViewEncapsulation.None,
- },] },
- ];
- /** @nocollapse */
- Range.ctorParameters = function () { return [
- { type: Form, },
- { type: Haptic, },
- { type: Item, decorators: [{ type: Optional },] },
- { type: Config, },
- { type: Platform, },
- { type: ElementRef, },
- { type: Renderer, },
- { type: DomController, },
- { type: ChangeDetectorRef, },
- ]; };
- Range.propDecorators = {
- '_slider': [{ type: ViewChild, args: ['slider',] },],
- 'min': [{ type: Input },],
- 'max': [{ type: Input },],
- 'step': [{ type: Input },],
- 'snaps': [{ type: Input },],
- 'pin': [{ type: Input },],
- 'debounce': [{ type: Input },],
- 'dualKnobs': [{ type: Input },],
- };
- return Range;
- }(BaseInput));
-
- /**
- * @hidden
- */
- var RangeKnob = (function () {
- function RangeKnob() {
- this.ionIncrease = new EventEmitter();
- this.ionDecrease = new EventEmitter();
- }
- Object.defineProperty(RangeKnob.prototype, "ratio", {
- set: function (r) {
- this._x = r * 100 + "%";
- },
- enumerable: true,
- configurable: true
- });
- RangeKnob.prototype._keyup = function (ev) {
- var keyCode = ev.keyCode;
- if (keyCode === KEY_LEFT || keyCode === KEY_DOWN) {
- (void 0) /* console.debug */;
- this.ionDecrease.emit();
- ev.preventDefault();
- ev.stopPropagation();
- }
- else if (keyCode === KEY_RIGHT || keyCode === KEY_UP) {
- (void 0) /* console.debug */;
- this.ionIncrease.emit();
- ev.preventDefault();
- ev.stopPropagation();
- }
- };
- RangeKnob.decorators = [
- { type: Component, args: [{
- selector: '.range-knob-handle',
- template: '<div class="range-pin" *ngIf="pin" role="presentation">{{val}}</div>' +
- '<div class="range-knob" role="presentation"></div>',
- host: {
- '[class.range-knob-pressed]': 'pressed',
- '[class.range-knob-min]': 'val===min||val===undefined',
- '[class.range-knob-max]': 'val===max',
- '[style.left]': '_x',
- '[attr.aria-valuenow]': 'val',
- '[attr.aria-valuemin]': 'min',
- '[attr.aria-valuemax]': 'max',
- '[attr.aria-disabled]': 'disabled',
- '[attr.aria-labelledby]': 'labelId',
- '[tabindex]': 'disabled?-1:0',
- 'role': 'slider'
- }
- },] },
- ];
- /** @nocollapse */
- RangeKnob.ctorParameters = function () { return []; };
- RangeKnob.propDecorators = {
- 'ratio': [{ type: Input },],
- 'pressed': [{ type: Input },],
- 'pin': [{ type: Input },],
- 'min': [{ type: Input },],
- 'max': [{ type: Input },],
- 'val': [{ type: Input },],
- 'disabled': [{ type: Input },],
- 'labelId': [{ type: Input },],
- 'ionIncrease': [{ type: Output },],
- 'ionDecrease': [{ type: Output },],
- '_keyup': [{ type: HostListener, args: ['keydown', ['$event'],] },],
- };
- return RangeKnob;
- }());
-
- /**
- * @name Refresher
- * @description
- * The Refresher provides pull-to-refresh functionality on a content component.
- * Place the `ion-refresher` as the first child of your `ion-content` element.
- *
- * Pages can then listen to the refresher's various output events. The
- * `refresh` output event is fired when the user has pulled down far
- * enough to kick off the refreshing process. Once the async operation
- * has completed and the refreshing should end, call `complete()`.
- *
- * Note: Do not wrap the `ion-refresher` in a `*ngIf`. It will not render
- * properly this way. Please use the `enabled` property instead to
- * display or hide the refresher.
- *
- * @usage
- * ```html
- * <ion-content>
- *
- * <ion-refresher (ionRefresh)="doRefresh($event)">
- * <ion-refresher-content></ion-refresher-content>
- * </ion-refresher>
- *
- * </ion-content>
- * ```
- *
- * ```ts
- * @Component({...})
- * export class NewsFeedPage {
- *
- * doRefresh(refresher) {
- * console.log('Begin async operation', refresher);
- *
- * setTimeout(() => {
- * console.log('Async operation has ended');
- * refresher.complete();
- * }, 2000);
- * }
- *
- * }
- * ```
- *
- *
- * ## Refresher Content
- *
- * By default, Ionic provides the pulling icon and refreshing spinner that
- * looks best for the platform the user is on. However, you can change the
- * default icon and spinner, along with adding text for each state by
- * adding properties to the child `ion-refresher-content` component.
- *
- * ```html
- * <ion-content>
- *
- * <ion-refresher (ionRefresh)="doRefresh($event)">
- * <ion-refresher-content
- * pullingIcon="arrow-dropdown"
- * pullingText="Pull to refresh"
- * refreshingSpinner="circles"
- * refreshingText="Refreshing...">
- * </ion-refresher-content>
- * </ion-refresher>
- *
- * </ion-content>
- * ```
- *
- *
- * ## Further Customizing Refresher Content
- *
- * The `ion-refresher` component holds the refresh logic.
- * It requires a child component in order to display the content.
- * Ionic uses `ion-refresher-content` by default. This component
- * displays the refresher and changes the look depending
- * on the refresher's state. Separating these components
- * allows developers to create their own refresher content
- * components. You could replace our default content with
- * custom SVG or CSS animations.
- *
- * @demo /docs/demos/src/refresher/
- *
- */
- var Refresher = (function () {
- function Refresher(_plt, _content, _zone, gestureCtrl) {
- this._plt = _plt;
- this._content = _content;
- this._zone = _zone;
- this._appliedStyles = false;
- this._lastCheck = 0;
- this._isEnabled = true;
- this._top = '';
- /**
- * The current state which the refresher is in. The refresher's states include:
- *
- * - `inactive` - The refresher is not being pulled down or refreshing and is currently hidden.
- * - `pulling` - The user is actively pulling down the refresher, but has not reached the point yet that if the user lets go, it'll refresh.
- * - `cancelling` - The user pulled down the refresher and let go, but did not pull down far enough to kick off the `refreshing` state. After letting go, the refresher is in the `cancelling` state while it is closing, and will go back to the `inactive` state once closed.
- * - `ready` - The user has pulled down the refresher far enough that if they let go, it'll begin the `refreshing` state.
- * - `refreshing` - The refresher is actively waiting on the async operation to end. Once the refresh handler calls `complete()` it will begin the `completing` state.
- * - `completing` - The `refreshing` state has finished and the refresher is in the process of closing itself. Once closed, the refresher will go back to the `inactive` state.
- */
- this.state = STATE_INACTIVE;
- /**
- * The Y coordinate of where the user started to the pull down the content.
- */
- this.startY = null;
- /**
- * The current touch or mouse event's Y coordinate.
- */
- this.currentY = null;
- /**
- * The distance between the start of the pull and the current touch or
- * mouse event's Y coordinate.
- */
- this.deltaY = null;
- /**
- * A number representing how far down the user has pulled.
- * The number `0` represents the user hasn't pulled down at all. The
- * number `1`, and anything greater than `1`, represents that the user
- * has pulled far enough down that when they let go then the refresh will
- * happen. If they let go and the number is less than `1`, then the
- * refresh will not happen, and the content will return to it's original
- * position.
- */
- this.progress = 0;
- /**
- * @input {number} The min distance the user must pull down until the
- * refresher can go into the `refreshing` state. Default is `60`.
- */
- this.pullMin = 60;
- /**
- * @input {number} The maximum distance of the pull until the refresher
- * will automatically go into the `refreshing` state. By default, the pull
- * maximum will be the result of `pullMin + 60`.
- */
- this.pullMax = this.pullMin + 60;
- /**
- * @input {number} How many milliseconds it takes to close the refresher. Default is `280`.
- */
- this.closeDuration = 280;
- /**
- * @input {number} How many milliseconds it takes the refresher to to snap back to the `refreshing` state. Default is `280`.
- */
- this.snapbackDuration = 280;
- /**
- * @output {event} Emitted when the user lets go and has pulled down
- * far enough, which would be farther than the `pullMin`, then your refresh hander if
- * fired and the state is updated to `refreshing`. From within your refresh handler,
- * you must call the `complete()` method when your async operation has completed.
- */
- this.ionRefresh = new EventEmitter();
- /**
- * @output {event} Emitted while the user is pulling down the content and exposing the refresher.
- */
- this.ionPull = new EventEmitter();
- /**
- * @output {event} Emitted when the user begins to start pulling down.
- */
- this.ionStart = new EventEmitter();
- this._events = new UIEventManager(_plt);
- _content._hasRefresher = true;
- this._gesture = gestureCtrl.createGesture({
- name: GESTURE_REFRESHER,
- priority: GESTURE_PRIORITY_REFRESHER
- });
- }
- Object.defineProperty(Refresher.prototype, "enabled", {
- /**
- * @input {boolean} If the refresher is enabled or not. This should be used in place of an `ngIf`. Default is `true`.
- */
- get: function () {
- return this._isEnabled;
- },
- set: function (val) {
- this._isEnabled = isTrueProperty(val);
- this._setListeners(this._isEnabled);
- },
- enumerable: true,
- configurable: true
- });
- Refresher.prototype._onStart = function (ev) {
- // if multitouch then get out immediately
- if (ev.touches && ev.touches.length > 1) {
- return false;
- }
- if (this.state !== STATE_INACTIVE) {
- return false;
- }
- var scrollHostScrollTop = this._content.getContentDimensions().scrollTop;
- // if the scrollTop is greater than zero then it's
- // not possible to pull the content down yet
- if (scrollHostScrollTop > 0) {
- return false;
- }
- if (!this._gesture.canStart()) {
- return false;
- }
- var coord = pointerCoord(ev);
- (void 0) /* console.debug */;
- if (this._content.contentTop > 0) {
- var newTop = this._content.contentTop + 'px';
- if (this._top !== newTop) {
- this._top = newTop;
- }
- }
- this.startY = this.currentY = coord.y;
- this.progress = 0;
- this.state = STATE_INACTIVE;
- return true;
- };
- Refresher.prototype._onMove = function (ev) {
- // this method can get called like a bazillion times per second,
- // so it's built to be as efficient as possible, and does its
- // best to do any DOM read/writes only when absolutely necessary
- var _this = this;
- // if multitouch then get out immediately
- if (ev.touches && ev.touches.length > 1) {
- return 1;
- }
- if (!this._gesture.canStart()) {
- return 0;
- }
- // do nothing if it's actively refreshing
- // or it's in the process of closing
- // or this was never a startY
- if (this.startY === null || this.state === STATE_REFRESHING || this.state === STATE_CANCELLING || this.state === STATE_COMPLETING) {
- return 2;
- }
- // if we just updated stuff less than 16ms ago
- // then don't check again, just chillout plz
- var now = Date.now();
- if (this._lastCheck + 16 > now) {
- return 3;
- }
- // remember the last time we checked all this
- this._lastCheck = now;
- // get the current pointer coordinates
- var coord = pointerCoord(ev);
- this.currentY = coord.y;
- // it's now possible they could be pulling down the content
- // how far have they pulled so far?
- this.deltaY = (coord.y - this.startY);
- // don't bother if they're scrolling up
- // and have not already started dragging
- if (this.deltaY <= 0) {
- // the current Y is higher than the starting Y
- // so they scrolled up enough to be ignored
- this.progress = 0;
- if (this.state !== STATE_INACTIVE) {
- this._zone.run(function () {
- _this.state = STATE_INACTIVE;
- });
- }
- if (this._appliedStyles) {
- // reset the styles only if they were applied
- this._setCss(0, '', false, '');
- return 5;
- }
- return 6;
- }
- if (this.state === STATE_INACTIVE) {
- // this refresh is not already actively pulling down
- // get the content's scrollTop
- var scrollHostScrollTop = this._content.getContentDimensions().scrollTop;
- // if the scrollTop is greater than zero then it's
- // not possible to pull the content down yet
- if (scrollHostScrollTop > 0) {
- this.progress = 0;
- this.startY = null;
- return 7;
- }
- // content scrolled all the way to the top, and dragging down
- this.state = STATE_PULLING;
- }
- // prevent native scroll events
- ev.preventDefault();
- // the refresher is actively pulling at this point
- // move the scroll element within the content element
- this._setCss(this.deltaY, '0ms', true, '');
- if (!this.deltaY) {
- // don't continue if there's no delta yet
- this.progress = 0;
- return 8;
- }
- // so far so good, let's run this all back within zone now
- this._zone.run(function () {
- _this._onMoveInZone();
- });
- };
- Refresher.prototype._onMoveInZone = function () {
- // set pull progress
- this.progress = (this.deltaY / this.pullMin);
- // emit "start" if it hasn't started yet
- if (!this._didStart) {
- this._didStart = true;
- this.ionStart.emit(this);
- }
- // emit "pulling" on every move
- this.ionPull.emit(this);
- // do nothing if the delta is less than the pull threshold
- if (this.deltaY < this.pullMin) {
- // ensure it stays in the pulling state, cuz its not ready yet
- this.state = STATE_PULLING;
- return 2;
- }
- if (this.deltaY > this.pullMax) {
- // they pulled farther than the max, so kick off the refresh
- this._beginRefresh();
- return 3;
- }
- // pulled farther than the pull min!!
- // it is now in the `ready` state!!
- // if they let go then it'll refresh, kerpow!!
- this.state = STATE_READY;
- return 4;
- };
- Refresher.prototype._onEnd = function () {
- // only run in a zone when absolutely necessary
- var _this = this;
- if (this.state === STATE_READY) {
- this._zone.run(function () {
- // they pulled down far enough, so it's ready to refresh
- _this._beginRefresh();
- });
- }
- else if (this.state === STATE_PULLING) {
- this._zone.run(function () {
- // they were pulling down, but didn't pull down far enough
- // set the content back to it's original location
- // and close the refresher
- // set that the refresh is actively cancelling
- _this.cancel();
- });
- }
- // reset on any touchend/mouseup
- this.startY = null;
- };
- Refresher.prototype._beginRefresh = function () {
- // assumes we're already back in a zone
- // they pulled down far enough, so it's ready to refresh
- this.state = STATE_REFRESHING;
- // place the content in a hangout position while it thinks
- this._setCss(this.pullMin, (this.snapbackDuration + 'ms'), true, '');
- // emit "refresh" because it was pulled down far enough
- // and they let go to begin refreshing
- this.ionRefresh.emit(this);
- };
- /**
- * Call `complete()` when your async operation has completed.
- * For example, the `refreshing` state is while the app is performing
- * an asynchronous operation, such as receiving more data from an
- * AJAX request. Once the data has been received, you then call this
- * method to signify that the refreshing has completed and to close
- * the refresher. This method also changes the refresher's state from
- * `refreshing` to `completing`.
- */
- Refresher.prototype.complete = function () {
- this._close(STATE_COMPLETING, '120ms');
- };
- /**
- * Changes the refresher's state from `refreshing` to `cancelling`.
- */
- Refresher.prototype.cancel = function () {
- this._close(STATE_CANCELLING, '');
- };
- Refresher.prototype._close = function (state$$1, delay) {
- var timer;
- function close(ev) {
- // closing is done, return to inactive state
- if (ev) {
- clearTimeout(timer);
- }
- this.state = STATE_INACTIVE;
- this.progress = 0;
- this._didStart = this.startY = this.currentY = this.deltaY = null;
- this._setCss(0, '0ms', false, '');
- }
- // create fallback timer incase something goes wrong with transitionEnd event
- timer = setTimeout(close.bind(this), 600);
- // create transition end event on the content's scroll element
- this._content.onScrollElementTransitionEnd(close.bind(this));
- // reset set the styles on the scroll element
- // set that the refresh is actively cancelling/completing
- this.state = state$$1;
- this._setCss(0, '', true, delay);
- if (this._pointerEvents) {
- this._pointerEvents.stop();
- }
- };
- Refresher.prototype._setCss = function (y, duration, overflowVisible, delay) {
- this._appliedStyles = (y > 0);
- var content = this._content;
- var Css = this._plt.Css;
- content.setScrollElementStyle(Css.transform, ((y > 0) ? 'translateY(' + y + 'px) translateZ(0px)' : 'translateZ(0px)'));
- content.setScrollElementStyle(Css.transitionDuration, duration);
- content.setScrollElementStyle(Css.transitionDelay, delay);
- content.setScrollElementStyle('overflow', (overflowVisible ? 'hidden' : ''));
- };
- Refresher.prototype._setListeners = function (shouldListen) {
- this._events.unlistenAll();
- this._pointerEvents = null;
- if (shouldListen) {
- this._pointerEvents = this._events.pointerEvents({
- element: this._content.getScrollElement(),
- pointerDown: this._onStart.bind(this),
- pointerMove: this._onMove.bind(this),
- pointerUp: this._onEnd.bind(this),
- zone: false
- });
- }
- };
- /**
- * @hidden
- */
- Refresher.prototype.ngOnInit = function () {
- // bind event listeners
- // save the unregister listener functions to use onDestroy
- this._setListeners(this._isEnabled);
- };
- /**
- * @hidden
- */
- Refresher.prototype.ngOnDestroy = function () {
- this._setListeners(false);
- this._events.destroy();
- this._gesture.destroy();
- };
- Refresher.decorators = [
- { type: Directive, args: [{
- selector: 'ion-refresher',
- host: {
- '[class.refresher-active]': 'state !== "inactive"',
- '[style.top]': '_top'
- }
- },] },
- ];
- /** @nocollapse */
- Refresher.ctorParameters = function () { return [
- { type: Platform, },
- { type: Content, decorators: [{ type: Host },] },
- { type: NgZone, },
- { type: GestureController, },
- ]; };
- Refresher.propDecorators = {
- 'pullMin': [{ type: Input },],
- 'pullMax': [{ type: Input },],
- 'closeDuration': [{ type: Input },],
- 'snapbackDuration': [{ type: Input },],
- 'enabled': [{ type: Input },],
- 'ionRefresh': [{ type: Output },],
- 'ionPull': [{ type: Output },],
- 'ionStart': [{ type: Output },],
- };
- return Refresher;
- }());
- var STATE_INACTIVE = 'inactive';
- var STATE_PULLING = 'pulling';
- var STATE_READY = 'ready';
- var STATE_REFRESHING = 'refreshing';
- var STATE_CANCELLING = 'cancelling';
- var STATE_COMPLETING = 'completing';
-
- /**
- * @hidden
- */
- var RefresherContent = (function () {
- function RefresherContent(r, _config) {
- this.r = r;
- this._config = _config;
- }
- /**
- * @hidden
- */
- RefresherContent.prototype.ngOnInit = function () {
- if (!this.pullingIcon) {
- this.pullingIcon = this._config.get('ionPullIcon', 'arrow-down');
- }
- if (!this.refreshingSpinner) {
- this.refreshingSpinner = this._config.get('ionRefreshingSpinner', this._config.get('spinner', 'ios'));
- }
- };
- RefresherContent.decorators = [
- { type: Component, args: [{
- selector: 'ion-refresher-content',
- template: '<div class="refresher-pulling">' +
- '<div class="refresher-pulling-icon" *ngIf="pullingIcon">' +
- '<ion-icon [name]="pullingIcon"></ion-icon>' +
- '</div>' +
- '<div class="refresher-pulling-text" [innerHTML]="pullingText" *ngIf="pullingText"></div>' +
- '</div>' +
- '<div class="refresher-refreshing">' +
- '<div class="refresher-refreshing-icon">' +
- '<ion-spinner [name]="refreshingSpinner"></ion-spinner>' +
- '</div>' +
- '<div class="refresher-refreshing-text" [innerHTML]="refreshingText" *ngIf="refreshingText"></div>' +
- '</div>',
- host: {
- '[attr.state]': 'r.state'
- },
- encapsulation: ViewEncapsulation.None,
- },] },
- ];
- /** @nocollapse */
- RefresherContent.ctorParameters = function () { return [
- { type: Refresher, },
- { type: Config, },
- ]; };
- RefresherContent.propDecorators = {
- 'pullingIcon': [{ type: Input },],
- 'pullingText': [{ type: Input },],
- 'refreshingSpinner': [{ type: Input },],
- 'refreshingText': [{ type: Input },],
- };
- return RefresherContent;
- }());
-
- /**
- * @name Scroll
- * @description
- * Scroll is a non-flexboxed scroll area that can scroll horizontally or vertically. `ion-Scroll` Can be used in places where you may not need a full page scroller, but a highly customized one, such as image scubber or comment scroller.
- * @usage
- * ```html
- * <ion-scroll scrollX="true">
- * </ion-scroll>
- *
- * <ion-scroll scrollY="true">
- * </ion-scroll>
- *
- * <ion-scroll scrollX="true" scrollY="true">
- * </ion-scroll>
- * ```
- * @demo /docs/demos/src/scroll/
- */
- var Scroll = (function () {
- function Scroll() {
- this._scrollX = false;
- this._scrollY = false;
- this._zoom = false;
- this._maxZoom = 1;
- /**
- * @hidden
- */
- this.maxScale = 3;
- /**
- * @hidden
- */
- this.zoomDuration = 250;
- }
- Object.defineProperty(Scroll.prototype, "scrollX", {
- /**
- * @input {boolean} If true, scrolling along the X axis is enabled.
- */
- get: function () {
- return this._scrollX;
- },
- set: function (val) {
- this._scrollX = isTrueProperty(val);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Scroll.prototype, "scrollY", {
- /**
- * @input {boolean} If true, scrolling along the Y axis is enabled; requires the following CSS declaration: ion-scroll { white-space: nowrap; }
- */
- get: function () {
- return this._scrollY;
- },
- set: function (val) {
- this._scrollY = isTrueProperty(val);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Scroll.prototype, "zoom", {
- /**
- * @input {boolean} If true, zooming is enabled.
- */
- get: function () {
- return this._zoom;
- },
- set: function (val) {
- this._zoom = isTrueProperty(val);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Scroll.prototype, "maxZoom", {
- /**
- * @input {number} Set the max zoom amount.
- */
- get: function () {
- return this._maxZoom;
- },
- set: function (val) {
- this._maxZoom = val;
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @hidden
- * Add a scroll event handler to the scroll element if it exists.
- * @param {Function} handler The scroll handler to add to the scroll element.
- * @returns {?Function} a function to remove the specified handler, otherwise
- * undefined if the scroll element doesn't exist.
- */
- Scroll.prototype.addScrollEventListener = function (handler) {
- (void 0) /* assert */;
- var ele = this._scrollContent.nativeElement;
- ele.addEventListener('scroll', handler);
- return function () {
- ele.removeEventListener('scroll', handler);
- };
- };
- Scroll.decorators = [
- { type: Component, args: [{
- selector: 'ion-scroll',
- template: '<div class="scroll-content" #scrollContent>' +
- '<div class="scroll-zoom-wrapper">' +
- '<ng-content></ng-content>' +
- '</div>' +
- '</div>',
- host: {
- '[class.scroll-x]': 'scrollX',
- '[class.scroll-y]': 'scrollY'
- },
- changeDetection: ChangeDetectionStrategy.OnPush,
- encapsulation: ViewEncapsulation.None,
- },] },
- ];
- /** @nocollapse */
- Scroll.ctorParameters = function () { return []; };
- Scroll.propDecorators = {
- 'scrollX': [{ type: Input },],
- 'scrollY': [{ type: Input },],
- 'zoom': [{ type: Input },],
- 'maxZoom': [{ type: Input },],
- '_scrollContent': [{ type: ViewChild, args: ['scrollContent', { read: ElementRef },] },],
- };
- return Scroll;
- }());
-
- var __extends$71 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @name Searchbar
- * @module ionic
- * @description
- * Manages the display of a Searchbar which can be used to search or filter items.
- *
- * @usage
- * ```html
- * <ion-searchbar
- * [(ngModel)]="myInput"
- * [showCancelButton]="shouldShowCancel"
- * (ionInput)="onInput($event)"
- * (ionCancel)="onCancel($event)">
- * </ion-searchbar>
- * ```
- *
- * @demo /docs/demos/src/searchbar/
- * @see {@link /docs/components#searchbar Searchbar Component Docs}
- */
- var Searchbar = (function (_super) {
- __extends$71(Searchbar, _super);
- function Searchbar(config, _plt, elementRef, renderer, ngControl) {
- var _this = _super.call(this, config, elementRef, renderer, 'searchbar', '', null, null, ngControl) || this;
- _this._plt = _plt;
- _this._shouldBlur = true;
- _this._shouldAlignLeft = true;
- _this._isCancelVisible = false;
- _this._spellcheck = false;
- _this._autocomplete = 'off';
- _this._autocorrect = 'off';
- _this._isActive = false;
- _this._showCancelButton = false;
- _this._animated = false;
- _this._inputDebouncer = new TimeoutDebouncer(0);
- /**
- * @input {string} Set the the cancel button text. Default: `"Cancel"`.
- */
- _this.cancelButtonText = 'Cancel';
- /**
- * @input {string} Set the input's placeholder. Default `"Search"`.
- */
- _this.placeholder = 'Search';
- /**
- * @input {string} Set the type of the input. Values: `"text"`, `"password"`, `"email"`, `"number"`, `"search"`, `"tel"`, `"url"`. Default `"search"`.
- */
- _this.type = 'search';
- /**
- * @output {event} Emitted when the Searchbar input has changed, including when it's cleared.
- */
- _this.ionInput = new EventEmitter();
- /**
- * @output {event} Emitted when the cancel button is clicked.
- */
- _this.ionCancel = new EventEmitter();
- /**
- * @output {event} Emitted when the clear input button is clicked.
- */
- _this.ionClear = new EventEmitter();
- _this.debounce = 250;
- return _this;
- }
- Object.defineProperty(Searchbar.prototype, "showCancelButton", {
- /**
- * @input {boolean} If true, show the cancel button. Default `false`.
- */
- get: function () {
- return this._showCancelButton;
- },
- set: function (val) {
- this._showCancelButton = isTrueProperty(val);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Searchbar.prototype, "debounce", {
- /**
- * @input {number} How long, in milliseconds, to wait to trigger the `ionInput` event after each keystroke. Default `250`.
- */
- get: function () {
- return this._debouncer.wait;
- },
- set: function (val) {
- this._debouncer.wait = val;
- this._inputDebouncer.wait = val;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Searchbar.prototype, "autocomplete", {
- /**
- * @input {string} Set the input's autocomplete property. Values: `"on"`, `"off"`. Default `"off"`.
- */
- set: function (val) {
- this._autocomplete = (val === '' || val === 'on') ? 'on' : this._config.get('autocomplete', 'off');
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Searchbar.prototype, "autocorrect", {
- /**
- * @input {string} Set the input's autocorrect property. Values: `"on"`, `"off"`. Default `"off"`.
- */
- set: function (val) {
- this._autocorrect = (val === '' || val === 'on') ? 'on' : this._config.get('autocorrect', 'off');
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Searchbar.prototype, "spellcheck", {
- /**
- * @input {string|boolean} Set the input's spellcheck property. Values: `true`, `false`. Default `false`.
- */
- set: function (val) {
- this._spellcheck = (val === '' || val === 'true' || val === true) ? true : this._config.getBoolean('spellcheck', false);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Searchbar.prototype, "animated", {
- /**
- * @input {boolean} If true, enable searchbar animation. Default `false`.
- */
- get: function () {
- return this._animated;
- },
- set: function (val) {
- this._animated = isTrueProperty(val);
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @hidden
- * On Initialization check for attributes
- */
- Searchbar.prototype.ngOnInit = function () {
- var showCancelButton = this.showCancelButton;
- if (typeof showCancelButton === 'string') {
- this.showCancelButton = (showCancelButton === '' || showCancelButton === 'true');
- }
- };
- /**
- * @hidden
- */
- Searchbar.prototype._inputUpdated = function () {
- var ele = this._searchbarInput.nativeElement;
- var value = this._value;
- // It is important not to re-assign the value if it is the same, because,
- // otherwise, the caret is moved to the end of the input
- if (ele.value !== value) {
- ele.value = value;
- }
- this.positionElements();
- };
- /**
- * @hidden
- * Positions the input search icon, placeholder, and the cancel button
- * based on the input value and if it is focused. (ios only)
- */
- Searchbar.prototype.positionElements = function () {
- var isAnimated = this._animated;
- var prevAlignLeft = this._shouldAlignLeft;
- var shouldAlignLeft = (!isAnimated || (this._value && this._value.toString().trim() !== '') || this._isFocus === true);
- this._shouldAlignLeft = shouldAlignLeft;
- if (this._mode !== 'ios') {
- return;
- }
- if (prevAlignLeft !== shouldAlignLeft) {
- this.positionPlaceholder();
- }
- if (isAnimated) {
- this.positionCancelButton();
- }
- };
- Searchbar.prototype.positionPlaceholder = function () {
- var inputEle = this._searchbarInput.nativeElement;
- var iconEle = this._searchbarIcon.nativeElement;
- if (this._shouldAlignLeft) {
- inputEle.removeAttribute('style');
- iconEle.removeAttribute('style');
- }
- else {
- // Create a dummy span to get the placeholder width
- var doc = this._plt.doc();
- var tempSpan = doc.createElement('span');
- tempSpan.innerHTML = this.placeholder;
- doc.body.appendChild(tempSpan);
- // Get the width of the span then remove it
- var textWidth = tempSpan.offsetWidth;
- doc.body.removeChild(tempSpan);
- // Set the input padding start
- var inputLeft = 'calc(50% - ' + (textWidth / 2) + 'px)';
- if (this._plt.isRTL) {
- inputEle.style.paddingRight = inputLeft;
- }
- else {
- inputEle.style.paddingLeft = inputLeft;
- }
- // Set the icon margin start
- var iconLeft = 'calc(50% - ' + ((textWidth / 2) + 30) + 'px)';
- if (this._plt.isRTL) {
- iconEle.style.marginRight = iconLeft;
- }
- else {
- iconEle.style.marginLeft = iconLeft;
- }
- }
- };
- /**
- * @hidden
- * Show the iOS Cancel button on focus, hide it offscreen otherwise
- */
- Searchbar.prototype.positionCancelButton = function () {
- var showShowCancel = this._isFocus;
- if (showShowCancel !== this._isCancelVisible) {
- var cancelStyleEle = this._cancelButton.nativeElement;
- var cancelStyle = cancelStyleEle.style;
- this._isCancelVisible = showShowCancel;
- if (showShowCancel) {
- if (this._plt.isRTL) {
- cancelStyle.marginLeft = '0';
- }
- else {
- cancelStyle.marginRight = '0';
- }
- }
- else {
- var offset = cancelStyleEle.offsetWidth;
- if (offset > 0) {
- if (this._plt.isRTL) {
- cancelStyle.marginLeft = -offset + 'px';
- }
- else {
- cancelStyle.marginRight = -offset + 'px';
- }
- }
- }
- }
- };
- /**
- * @hidden
- * Update the Searchbar input value when the input changes
- */
- Searchbar.prototype.inputChanged = function (ev) {
- var _this = this;
- this.value = ev.target.value;
- this._inputDebouncer.debounce(function () {
- _this.ionInput.emit(ev);
- });
- };
- /**
- * @hidden
- * Sets the Searchbar to focused and active on input focus.
- */
- Searchbar.prototype.inputFocused = function () {
- this._isActive = true;
- this._fireFocus();
- this.positionElements();
- };
- /**
- * @hidden
- * Sets the Searchbar to not focused and checks if it should align left
- * based on whether there is a value in the searchbar or not.
- */
- Searchbar.prototype.inputBlurred = function () {
- // _shouldBlur determines if it should blur
- // if we are clearing the input we still want to stay focused in the input
- if (this._shouldBlur === false) {
- this._searchbarInput.nativeElement.focus();
- this._shouldBlur = true;
- return;
- }
- this._fireBlur();
- this.positionElements();
- };
- /**
- * @hidden
- * Clears the input field and triggers the control change.
- */
- Searchbar.prototype.clearInput = function (ev) {
- var _this = this;
- this.ionClear.emit(ev);
- // setTimeout() fixes https://github.com/ionic-team/ionic/issues/7527
- // wait for 4 frames
- setTimeout(function () {
- var value = _this._value;
- if (isPresent(value) && value !== '') {
- _this.value = ''; // DOM WRITE
- _this.ionInput.emit(ev);
- }
- }, 16 * 4);
- this._shouldBlur = false;
- };
- /**
- * @hidden
- * Clears the input field and tells the input to blur since
- * the clearInput function doesn't want the input to blur
- * then calls the custom cancel function if the user passed one in.
- */
- Searchbar.prototype.cancelSearchbar = function (ev) {
- this.ionCancel.emit(ev);
- this.clearInput(ev);
- this._shouldBlur = true;
- this._isActive = false;
- };
- Searchbar.prototype.setFocus = function () {
- this._renderer.invokeElementMethod(this._searchbarInput.nativeElement, 'focus');
- };
- Searchbar.decorators = [
- { type: Component, args: [{
- selector: 'ion-searchbar',
- template: '<div class="searchbar-input-container">' +
- '<button ion-button mode="md" (click)="cancelSearchbar($event)" (mousedown)="cancelSearchbar($event)" clear color="dark" class="searchbar-md-cancel" type="button">' +
- '<ion-icon name="md-arrow-back"></ion-icon>' +
- '</button>' +
- '<div #searchbarIcon class="searchbar-search-icon"></div>' +
- '<input #searchbarInput class="searchbar-input" (input)="inputChanged($event)" (blur)="inputBlurred()" (focus)="inputFocused()" ' +
- 'dir="auto" ' +
- '[attr.placeholder]="placeholder" ' +
- '[attr.type]="type" ' +
- '[attr.autocomplete]="_autocomplete" ' +
- '[attr.autocorrect]="_autocorrect" ' +
- '[attr.spellcheck]="_spellcheck">' +
- '<button ion-button clear class="searchbar-clear-icon" [mode]="_mode" (click)="clearInput($event)" (mousedown)="clearInput($event)" type="button"></button>' +
- '</div>' +
- '<button ion-button #cancelButton mode="ios" [tabindex]="_isActive ? 1 : -1" clear (click)="cancelSearchbar($event)" (mousedown)="cancelSearchbar($event)" class="searchbar-ios-cancel" type="button">{{cancelButtonText}}</button>',
- host: {
- '[class.searchbar-animated]': '_animated',
- '[class.searchbar-has-value]': '_value',
- '[class.searchbar-active]': '_isActive',
- '[class.searchbar-show-cancel]': '_showCancelButton',
- '[class.searchbar-left-aligned]': '_shouldAlignLeft',
- '[class.searchbar-has-focus]': '_isFocus'
- },
- encapsulation: ViewEncapsulation.None
- },] },
- ];
- /** @nocollapse */
- Searchbar.ctorParameters = function () { return [
- { type: Config, },
- { type: Platform, },
- { type: ElementRef, },
- { type: Renderer, },
- { type: NgControl, decorators: [{ type: Optional },] },
- ]; };
- Searchbar.propDecorators = {
- 'cancelButtonText': [{ type: Input },],
- 'showCancelButton': [{ type: Input },],
- 'debounce': [{ type: Input },],
- 'placeholder': [{ type: Input },],
- 'autocomplete': [{ type: Input },],
- 'autocorrect': [{ type: Input },],
- 'spellcheck': [{ type: Input },],
- 'type': [{ type: Input },],
- 'animated': [{ type: Input },],
- 'ionInput': [{ type: Output },],
- 'ionCancel': [{ type: Output },],
- 'ionClear': [{ type: Output },],
- '_searchbarInput': [{ type: ViewChild, args: ['searchbarInput',] },],
- '_searchbarIcon': [{ type: ViewChild, args: ['searchbarIcon',] },],
- '_cancelButton': [{ type: ViewChild, args: ['cancelButton', { read: ElementRef },] },],
- };
- return Searchbar;
- }(BaseInput));
-
- /**
- * @name SegmentButton
- * @description
- * The child buttons of the `ion-segment` component. Each `ion-segment-button` must have a value.
- *
- * @usage
- *
- * ```html
- * <ion-content>
- * <!-- Segment buttons with icons -->
- * <ion-segment [(ngModel)]="icons" color="secondary">
- * <ion-segment-button value="camera">
- * <ion-icon name="camera"></ion-icon>
- * </ion-segment-button>
- * <ion-segment-button value="bookmark">
- * <ion-icon name="bookmark"></ion-icon>
- * </ion-segment-button>
- * </ion-segment>
- *
- * <!-- Segment buttons with text -->
- * <ion-segment [(ngModel)]="relationship" color="primary">
- * <ion-segment-button value="friends" (ionSelect)="selectedFriends()">
- * Friends
- * </ion-segment-button>
- * <ion-segment-button value="enemies" (ionSelect)="selectedEnemies()">
- * Enemies
- * </ion-segment-button>
- * </ion-segment>
- * </ion-content>
- * ```
- *
- *
- * @demo /docs/demos/src/segment/
- * @see {@link /docs/components#segment Segment Component Docs}
- * @see {@link /docs/api/components/segment/Segment/ Segment API Docs}
- */
- var SegmentButton = (function () {
- function SegmentButton() {
- this.isActive = false;
- this._disabled = false;
- /**
- * @output {SegmentButton} Emitted when a segment button has been clicked.
- */
- this.ionSelect = new EventEmitter();
- }
- Object.defineProperty(SegmentButton.prototype, "disabled", {
- /**
- * @input {boolean} If true, the user cannot interact with this element.
- */
- get: function () {
- return this._disabled;
- },
- set: function (val) {
- this._disabled = isTrueProperty(val);
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @hidden
- * On click of a SegmentButton
- */
- SegmentButton.prototype.onClick = function () {
- (void 0) /* console.debug */;
- this.ionSelect.emit(this);
- };
- /**
- * @hidden
- */
- SegmentButton.prototype.ngOnInit = function () {
- if (!isPresent(this.value)) {
- console.warn('<ion-segment-button> requires a "value" attribute');
- }
- };
- SegmentButton.decorators = [
- { type: Component, args: [{
- selector: 'ion-segment-button',
- template: '<ng-content></ng-content>' +
- '<div class="button-effect"></div>',
- host: {
- 'tappable': '',
- 'class': 'segment-button',
- 'role': 'button',
- '[class.segment-button-disabled]': '_disabled',
- '[class.segment-activated]': 'isActive',
- '[attr.aria-pressed]': 'isActive'
- },
- encapsulation: ViewEncapsulation.None,
- },] },
- ];
- /** @nocollapse */
- SegmentButton.ctorParameters = function () { return []; };
- SegmentButton.propDecorators = {
- 'value': [{ type: Input },],
- 'ionSelect': [{ type: Output },],
- 'disabled': [{ type: Input },],
- 'onClick': [{ type: HostListener, args: ['click',] },],
- };
- return SegmentButton;
- }());
-
- var __extends$72 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @name Segment
- * @description
- * A Segment is a group of buttons, sometimes known as Segmented Controls, that allow the user to interact with a compact group of a number of controls.
- * Segments provide functionality similar to tabs, selecting one will unselect all others. You should use a tab bar instead of a segmented control when you want to let the user move back and forth between distinct pages in your app.
- * You could use Angular's `ngModel` or `FormBuilder` API. For an overview on how `FormBuilder` works, checkout [Angular Forms](http://learnangular2.com/forms/), or [Angular FormBuilder](https://angular.io/docs/ts/latest/api/forms/index/FormBuilder-class.html)
- *
- *
- * ```html
- * <!-- Segment in a header -->
- * <ion-header>
- * <ion-toolbar>
- * <ion-segment [(ngModel)]="icons" color="secondary">
- * <ion-segment-button value="camera">
- * <ion-icon name="camera"></ion-icon>
- * </ion-segment-button>
- * <ion-segment-button value="bookmark">
- * <ion-icon name="bookmark"></ion-icon>
- * </ion-segment-button>
- * </ion-segment>
- * </ion-toolbar>
- * </ion-header>
- *
- * <ion-content>
- * <!-- Segment in content -->
- * <ion-segment [(ngModel)]="relationship" color="primary" (ionChange)="segmentChanged($event)">
- * <ion-segment-button value="friends">
- * Friends
- * </ion-segment-button>
- * <ion-segment-button value="enemies">
- * Enemies
- * </ion-segment-button>
- * </ion-segment>
- *
- * <!-- Segment in a form -->
- * <form [formGroup]="myForm">
- * <ion-segment formControlName="mapStyle" color="danger">
- * <ion-segment-button value="standard">
- * Standard
- * </ion-segment-button>
- * <ion-segment-button value="hybrid">
- * Hybrid
- * </ion-segment-button>
- * <ion-segment-button value="sat">
- * Satellite
- * </ion-segment-button>
- * </ion-segment>
- * </form>
- * </ion-content>
- * ```
- *
- *
- * @demo /docs/demos/src/segment/
- * @see {@link /docs/components#segment Segment Component Docs}
- * @see [Angular Forms](http://learnangular2.com/forms/)
- */
- var Segment = (function (_super) {
- __extends$72(Segment, _super);
- function Segment(config, elementRef, renderer, ngControl) {
- return _super.call(this, config, elementRef, renderer, 'segment', null, null, null, ngControl) || this;
- }
- /**
- * @hidden
- */
- Segment.prototype.ngAfterContentInit = function () {
- var _this = this;
- this._initialize();
- this._buttons.forEach(function (button) {
- button.ionSelect.subscribe(function (selectedButton) {
- _this.value = selectedButton.value;
- _this._fireTouched();
- });
- });
- };
- /**
- * @hidden
- * Write a new value to the element.
- */
- Segment.prototype._inputUpdated = function () {
- if (!this._buttons) {
- (void 0) /* assert */;
- return;
- }
- var buttons = this._buttons.toArray();
- var value = this.value;
- for (var _i = 0, buttons_1 = buttons; _i < buttons_1.length; _i++) {
- var button = buttons_1[_i];
- button.isActive = (button.value === value);
- }
- };
- Segment.decorators = [
- { type: Directive, args: [{
- selector: 'ion-segment',
- host: {
- '[class.segment-disabled]': '_disabled'
- }
- },] },
- ];
- /** @nocollapse */
- Segment.ctorParameters = function () { return [
- { type: Config, },
- { type: ElementRef, },
- { type: Renderer, },
- { type: NgControl, decorators: [{ type: Optional },] },
- ]; };
- Segment.propDecorators = {
- '_buttons': [{ type: ContentChildren, args: [SegmentButton,] },],
- };
- return Segment;
- }(BaseInput));
-
- /** @hidden */
- var SelectPopover = (function () {
- function SelectPopover(navParams, viewController) {
- this.navParams = navParams;
- this.viewController = viewController;
- }
- Object.defineProperty(SelectPopover.prototype, "value", {
- get: function () {
- var checkedOption = this.options.find(function (option) { return option.checked; });
- return checkedOption ? checkedOption.value : undefined;
- },
- set: function (value) {
- var checkedOption = this.options.find(function (option) { return option.value === value; });
- if (checkedOption && checkedOption.handler) {
- checkedOption.handler();
- }
- this.viewController.dismiss(value);
- },
- enumerable: true,
- configurable: true
- });
- SelectPopover.prototype.ngOnInit = function () {
- this.options = this.navParams.data.options;
- };
- SelectPopover.decorators = [
- { type: Component, args: [{
- template: "\n <ion-list radio-group [(ngModel)]=\"value\">\n <ion-item *ngFor=\"let option of options\">\n <ion-label>{{option.text}}</ion-label>\n <ion-radio [checked]=\"option.checked\" [value]=\"option.value\" [disabled]=\"option.disabled\"></ion-radio>\n </ion-item>\n </ion-list>\n "
- },] },
- ];
- /** @nocollapse */
- SelectPopover.ctorParameters = function () { return [
- { type: NavParams, },
- { type: ViewController, },
- ]; };
- return SelectPopover;
- }());
-
- var __extends$73 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @name Select
- * @description
- * The `ion-select` component is similar to an HTML `<select>` element, however,
- * Ionic's select component makes it easier for users to sort through and select
- * the preferred option or options. When users tap the select component, a
- * dialog will appear with all of the options in a large, easy to select list
- * for users.
- *
- * The select component takes child `ion-option` components. If `ion-option` is not
- * given a `value` attribute then it will use its text as the value.
- *
- * If `ngModel` is bound to `ion-select`, the selected value will be based on the
- * bound value of the model. Otherwise, the `selected` attribute can be used on
- * `ion-option` components.
- *
- * ### Interfaces
- *
- * By default, the `ion-select` uses the {@link ../../alert/AlertController AlertController API}
- * to open up the overlay of options in an alert. The interface can be changed to use the
- * {@link ../../action-sheet/ActionSheetController ActionSheetController API} or
- * {@link ../../popover/PopoverController PopoverController API} by passing `action-sheet` or `popover`,
- * respectively, to the `interface` property. Read on to the other sections for the limitations
- * of the different interfaces.
- *
- * ### Single Value: Radio Buttons
- *
- * The standard `ion-select` component allows the user to select only one
- * option. When selecting only one option the alert interface presents users with
- * a radio button styled list of options. The action sheet interface can only be
- * used with a single value select. If the number of options exceed 6, it will
- * use the `alert` interface even if `action-sheet` is passed. The `ion-select`
- * component's value receives the value of the selected option's value.
- *
- * ```html
- * <ion-item>
- * <ion-label>Gender</ion-label>
- * <ion-select [(ngModel)]="gender">
- * <ion-option value="f">Female</ion-option>
- * <ion-option value="m">Male</ion-option>
- * </ion-select>
- * </ion-item>
- * ```
- *
- * ### Multiple Value: Checkboxes
- *
- * By adding the `multiple="true"` attribute to `ion-select`, users are able
- * to select multiple options. When multiple options can be selected, the alert
- * overlay presents users with a checkbox styled list of options. The
- * `ion-select multiple="true"` component's value receives an array of all the
- * selected option values. In the example below, because each option is not given
- * a `value`, then it'll use its text as the value instead.
- *
- * Note: the `action-sheet` and `popover` interfaces will not work with a multi-value select.
- *
- * ```html
- * <ion-item>
- * <ion-label>Toppings</ion-label>
- * <ion-select [(ngModel)]="toppings" multiple="true">
- * <ion-option>Bacon</ion-option>
- * <ion-option>Black Olives</ion-option>
- * <ion-option>Extra Cheese</ion-option>
- * <ion-option>Mushrooms</ion-option>
- * <ion-option>Pepperoni</ion-option>
- * <ion-option>Sausage</ion-option>
- * </ion-select>
- * </ion-item>
- * ```
- *
- * ### Select Buttons
- * By default, the two buttons read `Cancel` and `OK`. Each button's text
- * can be customized using the `cancelText` and `okText` attributes:
- *
- * ```html
- * <ion-select okText="Okay" cancelText="Dismiss">
- * ...
- * </ion-select>
- * ```
- *
- * The `action-sheet` and `popover` interfaces do not have an `OK` button, clicking
- * on any of the options will automatically close the overlay and select
- * that value.
- *
- * ### Select Options
- *
- * Since `ion-select` uses the `Alert`, `Action Sheet` and `Popover` interfaces, options can be
- * passed to these components through the `selectOptions` property. This can be used
- * to pass a custom title, subtitle, css class, and more. See the
- * {@link ../../alert/AlertController/#create AlertController API docs},
- * {@link ../../action-sheet/ActionSheetController/#create ActionSheetController API docs}, and
- * {@link ../../popover/PopoverController/#create PopoverController API docs}
- * for the properties that each interface accepts.
- *
- * For example, to change the `mode` of the overlay, pass it into `selectOptions`.
- *
- * ```html
- * <ion-select [selectOptions]="selectOptions">
- * ...
- * </ion-select>
- * ```
- *
- * ```ts
- * this.selectOptions = {
- * title: 'Pizza Toppings',
- * subTitle: 'Select your toppings',
- * mode: 'md'
- * };
- * ```
- *
- * ### Object Value References
- *
- * When using objects for select values, it is possible for the identities of these objects to
- * change if they are coming from a server or database, while the selected value's identity
- * remains the same. For example, this can occur when an existing record with the desired object value
- * is loaded into the select, but the newly retrieved select options now have different identities. This will
- * result in the select appearing to have no value at all, even though the original selection in still intact.
- *
- * Using the `compareWith` `Input` is the solution to this problem
- *
- * ```html
- * <ion-item>
- * <ion-label>Employee</ion-label>
- * <ion-select [(ngModel)]="employee" [compareWith]="compareFn">
- * <ion-option *ngFor="let employee of employees" [value]="employee">{{employee.name}}</ion-option>
- * </ion-select>
- * </ion-item>
- * ```
- *
- * ```ts
- * compareFn(e1: Employee, e2: Employee): boolean {
- * return e1 && e2 ? e1.id === e2.id : e1 === e2;
- * }
- * ```
- *
- * @demo /docs/demos/src/select/
- */
- var Select = (function (_super) {
- __extends$73(Select, _super);
- function Select(_app, form, config, elementRef, renderer, item, deepLinker) {
- var _this = _super.call(this, config, elementRef, renderer, 'select', [], form, item, null) || this;
- _this._app = _app;
- _this.config = config;
- _this.deepLinker = deepLinker;
- _this._multi = false;
- _this._texts = [];
- _this._text = '';
- _this._compareWith = isCheckedProperty;
- /**
- * @input {string} The text to display on the cancel button. Default: `Cancel`.
- */
- _this.cancelText = 'Cancel';
- /**
- * @input {string} The text to display on the ok button. Default: `OK`.
- */
- _this.okText = 'OK';
- /**
- * @input {any} Any additional options that the `alert` or `action-sheet` interface can take.
- * See the [AlertController API docs](../../alert/AlertController/#create) and the
- * [ActionSheetController API docs](../../action-sheet/ActionSheetController/#create) for the
- * create options for each interface.
- */
- _this.selectOptions = {};
- /**
- * @input {string} The interface the select should use: `action-sheet`, `popover` or `alert`. Default: `alert`.
- */
- _this.interface = '';
- /**
- * @input {string} The text to display instead of the selected option's value.
- */
- _this.selectedText = '';
- /**
- * @output {any} Emitted when the selection was cancelled.
- */
- _this.ionCancel = new EventEmitter();
- return _this;
- }
- Object.defineProperty(Select.prototype, "compareWith", {
- /**
- * @input {Function} The function that will be called to compare object values
- */
- set: function (fn) {
- if (typeof fn !== 'function') {
- throw new Error("compareWith must be a function, but received " + JSON.stringify(fn));
- }
- this._compareWith = fn;
- },
- enumerable: true,
- configurable: true
- });
- Select.prototype._click = function (ev) {
- ev.preventDefault();
- ev.stopPropagation();
- this.open(ev);
- };
- Select.prototype._keyup = function () {
- this.open();
- };
- /**
- * @hidden
- */
- Select.prototype.getValues = function () {
- var values = Array.isArray(this._value) ? this._value : [this._value];
- (void 0) /* assert */;
- return values;
- };
- /**
- * Open the select interface.
- */
- Select.prototype.open = function (ev) {
- var _this = this;
- if (this.isFocus() || this._disabled) {
- return;
- }
- (void 0) /* console.debug */;
- // the user may have assigned some options specifically for the alert
- var selectOptions = deepCopy(this.selectOptions);
- // make sure their buttons array is removed from the options
- // and we create a new array for the alert's two buttons
- selectOptions.buttons = [{
- text: this.cancelText,
- role: 'cancel',
- handler: function () {
- _this.ionCancel.emit(_this);
- }
- }];
- // if the selectOptions didn't provide a title then use the label's text
- if (!selectOptions.title && this._item) {
- selectOptions.title = this._item.getLabelText();
- }
- var options = this._options.toArray();
- if ((this.interface === 'action-sheet' || this.interface === 'popover') && this._multi) {
- console.warn('Interface cannot be "' + this.interface + '" with a multi-value select. Using the "alert" interface.');
- this.interface = 'alert';
- }
- if (this.interface === 'popover' && !ev) {
- console.warn('Interface cannot be "popover" without UIEvent.');
- this.interface = 'alert';
- }
- var overlay;
- if (this.interface === 'action-sheet') {
- selectOptions.buttons = selectOptions.buttons.concat(options.map(function (input) {
- return {
- role: (input.selected ? 'selected' : ''),
- text: input.text,
- handler: function () {
- _this.value = input.value;
- input.ionSelect.emit(input.value);
- }
- };
- }));
- var selectCssClass = 'select-action-sheet';
- // If the user passed a cssClass for the select, add it
- selectCssClass += selectOptions.cssClass ? ' ' + selectOptions.cssClass : '';
- selectOptions.cssClass = selectCssClass;
- overlay = new ActionSheet(this._app, selectOptions, this.config);
- }
- else if (this.interface === 'popover') {
- var popoverOptions = options.map(function (input) { return ({
- text: input.text,
- checked: input.selected,
- disabled: input.disabled,
- value: input.value,
- handler: function () {
- _this.value = input.value;
- input.ionSelect.emit(input.value);
- }
- }); });
- var popoverCssClass = 'select-popover';
- // If the user passed a cssClass for the select, add it
- popoverCssClass += selectOptions.cssClass ? ' ' + selectOptions.cssClass : '';
- overlay = new Popover(this._app, SelectPopover, {
- options: popoverOptions
- }, {
- cssClass: popoverCssClass
- }, this.config, this.deepLinker);
- // ev.target is readonly.
- // place popover regarding to ion-select instead of .button-inner
- Object.defineProperty(ev, 'target', { value: ev.currentTarget });
- selectOptions.ev = ev;
- }
- else {
- // default to use the alert interface
- this.interface = 'alert';
- // user cannot provide inputs from selectOptions
- // alert inputs must be created by ionic from ion-options
- selectOptions.inputs = this._options.map(function (input) {
- return {
- type: (_this._multi ? 'checkbox' : 'radio'),
- label: input.text,
- value: input.value,
- checked: input.selected,
- disabled: input.disabled,
- handler: function (selectedOption) {
- // Only emit the select event if it is being checked
- // For multi selects this won't emit when unchecking
- if (selectedOption.checked) {
- input.ionSelect.emit(input.value);
- }
- }
- };
- });
- var selectCssClass_1 = 'select-alert';
- // create the alert instance from our built up selectOptions
- overlay = new Alert(this._app, selectOptions, this.config);
- if (this._multi) {
- // use checkboxes
- selectCssClass_1 += ' multiple-select-alert';
- }
- else {
- // use radio buttons
- selectCssClass_1 += ' single-select-alert';
- }
- // If the user passed a cssClass for the select, add it
- selectCssClass_1 += selectOptions.cssClass ? ' ' + selectOptions.cssClass : '';
- overlay.setCssClass(selectCssClass_1);
- overlay.addButton({
- text: this.okText,
- handler: function (selectedValues) { return _this.value = selectedValues; }
- });
- }
- overlay.present(selectOptions);
- this._fireFocus();
- overlay.onDidDismiss(function () {
- _this._fireBlur();
- _this._overlay = undefined;
- });
- this._overlay = overlay;
- };
- /**
- * Close the select interface.
- */
- Select.prototype.close = function () {
- if (!this._overlay || !this.isFocus()) {
- return;
- }
- return this._overlay.dismiss();
- };
- Object.defineProperty(Select.prototype, "multiple", {
- /**
- * @input {boolean} If true, the element can accept multiple values.
- */
- get: function () {
- return this._multi;
- },
- set: function (val) {
- this._multi = isTrueProperty(val);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Select.prototype, "text", {
- /**
- * @hidden
- */
- get: function () {
- return (this._multi ? this._texts : this._texts.join());
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Select.prototype, "options", {
- /**
- * @private
- */
- set: function (val) {
- this._options = val;
- var values = this.getValues();
- if (values.length === 0) {
- // there are no values set at this point
- // so check to see who should be selected
- // we use writeValue() because we don't want to update ngModel
- this.writeValue(val.filter(function (o) { return o.selected; }).map(function (o) { return o.value; }));
- }
- else {
- this._updateText();
- }
- },
- enumerable: true,
- configurable: true
- });
- Select.prototype._inputShouldChange = function (val) {
- return !deepEqual(this._value, val);
- };
- /**
- * TODO: REMOVE THIS
- * @hidden
- */
- Select.prototype._inputChangeEvent = function () {
- return this.value;
- };
- /**
- * @hidden
- */
- Select.prototype._updateText = function () {
- var _this = this;
- this._texts.length = 0;
- if (this._options) {
- this._options.forEach(function (option) {
- // check this option if the option's value is in the values array
- option.selected = _this.getValues().some(function (selectValue) {
- return _this._compareWith(selectValue, option.value);
- });
- if (option.selected) {
- _this._texts.push(option.text);
- }
- });
- }
- this._text = this._texts.join(', ');
- };
- /**
- * @hidden
- */
- Select.prototype._inputUpdated = function () {
- this._updateText();
- _super.prototype._inputUpdated.call(this);
- };
- Select.decorators = [
- { type: Component, args: [{
- selector: 'ion-select',
- template: '<div *ngIf="!_text" class="select-placeholder select-text">{{placeholder}}</div>' +
- '<div *ngIf="_text" class="select-text">{{selectedText || _text}}</div>' +
- '<div class="select-icon">' +
- '<div class="select-icon-inner"></div>' +
- '</div>' +
- '<button aria-haspopup="true" ' +
- 'type="button" ' +
- '[id]="id" ' +
- 'ion-button="item-cover" ' +
- '[attr.aria-labelledby]="_labelId" ' +
- '[attr.aria-disabled]="_disabled" ' +
- 'class="item-cover">' +
- '</button>',
- host: {
- '[class.select-disabled]': '_disabled'
- },
- providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: Select, multi: true }],
- encapsulation: ViewEncapsulation.None,
- },] },
- ];
- /** @nocollapse */
- Select.ctorParameters = function () { return [
- { type: App, },
- { type: Form, },
- { type: Config, },
- { type: ElementRef, },
- { type: Renderer, },
- { type: Item, decorators: [{ type: Optional },] },
- { type: DeepLinker, },
- ]; };
- Select.propDecorators = {
- 'cancelText': [{ type: Input },],
- 'okText': [{ type: Input },],
- 'placeholder': [{ type: Input },],
- 'selectOptions': [{ type: Input },],
- 'interface': [{ type: Input },],
- 'selectedText': [{ type: Input },],
- 'compareWith': [{ type: Input },],
- 'ionCancel': [{ type: Output },],
- '_click': [{ type: HostListener, args: ['click', ['$event'],] },],
- '_keyup': [{ type: HostListener, args: ['keyup.space',] },],
- 'multiple': [{ type: Input },],
- 'options': [{ type: ContentChildren, args: [Option,] },],
- };
- return Select;
- }(BaseInput));
-
- /**
- * @hidden
- */
- var DisplayWhen = (function () {
- function DisplayWhen(conditions, _plt, zone) {
- this._plt = _plt;
- this.zone = zone;
- this.isMatch = false;
- if (!conditions)
- return;
- this.conditions = conditions.replace(/\s/g, '').split(',');
- // check if its one of the matching platforms first
- // a platform does not change during the life of an app
- for (var i = 0; i < this.conditions.length; i++) {
- if (this.conditions[i] && _plt.is(this.conditions[i])) {
- this.isMatch = true;
- return;
- }
- }
- if (this.orientation()) {
- // add window resize listener
- this.resizeObs = _plt.resize.subscribe(this.orientation.bind(this));
- }
- }
- DisplayWhen.prototype.orientation = function () {
- for (var i = 0; i < this.conditions.length; i++) {
- if (this.conditions[i] === 'portrait') {
- this.isMatch = this._plt.isPortrait();
- return true;
- }
- if (this.conditions[i] === 'landscape') {
- this.isMatch = this._plt.isLandscape();
- return true;
- }
- }
- return false;
- };
- DisplayWhen.prototype.ngOnDestroy = function () {
- this.resizeObs && this.resizeObs.unsubscribe();
- this.resizeObs = null;
- };
- return DisplayWhen;
- }());
-
- var __extends$74 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- *
- * @name ShowWhen
- * @description
- * The `showWhen` attribute takes a string that represents a platform or screen orientation.
- * The element the attribute is added to will only be shown when that platform or screen orientation is active.
- *
- * Complements the [hideWhen attribute](../HideWhen). If the `showWhen` attribute is used on an
- * element that also has the `hideWhen` attribute, the element will not show if `hideWhen` evaluates
- * to `true` or `showWhen` evaluates to `false`. If the `hidden` attribute is also added, the element
- * will not show if `hidden` evaluates to `true`.
- *
- * View the [Platform API docs](../../../platform/Platform) for more information on the different
- * platforms you can use.
- *
- * @usage
- * ```html
- * <div showWhen="android">
- * I am visible on Android!
- * </div>
- *
- * <div showWhen="ios">
- * I am visible on iOS!
- * </div>
- *
- * <div showWhen="android,ios">
- * I am visible on Android and iOS!
- * </div>
- *
- * <div showWhen="portrait">
- * I am visible on Portrait!
- * </div>
- *
- * <div showWhen="landscape">
- * I am visible on Landscape!
- * </div>
- * ```
- * @demo /docs/demos/src/show-when/
- * @see {@link ../HideWhen HideWhen API Docs}
- * @see {@link ../../../platform/Platform Platform API Docs}
- */
- var ShowWhen = (function (_super) {
- __extends$74(ShowWhen, _super);
- function ShowWhen(showWhen, plt, zone) {
- return _super.call(this, showWhen, plt, zone) || this;
- }
- // ngOnDestroy is implemented in DisplayWhen
- ShowWhen.decorators = [
- { type: Directive, args: [{
- selector: '[showWhen]',
- host: {
- '[class.hidden-show-when]': '!isMatch'
- }
- },] },
- ];
- /** @nocollapse */
- ShowWhen.ctorParameters = function () { return [
- { type: undefined, decorators: [{ type: Attribute, args: ['showWhen',] },] },
- { type: Platform, },
- { type: NgZone, },
- ]; };
- return ShowWhen;
- }(DisplayWhen));
-
- var __extends$75 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @name HideWhen
- * @description
- * The `hideWhen` attribute takes a string that represents a plaform or screen orientation.
- * The element the attribute is added to will only be hidden when that platform or screen orientation is active.
- *
- * Complements the [showWhen attribute](../ShowWhen). If the `hideWhen` attribute is used on an
- * element that also has the `showWhen` attribute, the element will not show if `hideWhen` evaluates
- * to `true` or `showWhen` evaluates to `false`. If the `hidden` attribute is also added, the element
- * will not show if `hidden` evaluates to `true`.
- *
- * View the [Platform API docs](../../../platform/Platform) for more information on the different
- * platforms you can use.
- *
- * @usage
- * ```html
- * <div hideWhen="android">
- * I am hidden on Android!
- * </div>
- *
- * <div hideWhen="ios">
- * I am hidden on iOS!
- * </div>
- *
- * <div hideWhen="android,ios">
- * I am hidden on Android and iOS!
- * </div>
- *
- * <div hideWhen="portrait">
- * I am hidden on Portrait!
- * </div>
- *
- * <div hideWhen="landscape">
- * I am hidden on Landscape!
- * </div>
- * ```
- *
- * @demo /docs/demos/src/hide-when/
- * @see {@link ../ShowWhen ShowWhen API Docs}
- * @see {@link ../../../platform/Platform Platform API Docs}
- */
- var HideWhen = (function (_super) {
- __extends$75(HideWhen, _super);
- function HideWhen(hideWhen, plt, zone) {
- return _super.call(this, hideWhen, plt, zone) || this;
- }
- HideWhen.decorators = [
- { type: Directive, args: [{
- selector: '[hideWhen]',
- host: {
- '[class.hidden-hide-when]': 'isMatch'
- }
- },] },
- ];
- /** @nocollapse */
- HideWhen.ctorParameters = function () { return [
- { type: undefined, decorators: [{ type: Attribute, args: ['hideWhen',] },] },
- { type: Platform, },
- { type: NgZone, },
- ]; };
- return HideWhen;
- }(DisplayWhen));
-
- function round(a) {
- return Math.floor(a);
- }
- function inlineStyle(ele, styles) {
- if (ele) {
- if (ele.length) {
- for (var i = 0; i < ele.length; i++) {
- inlineStyle(ele[i], styles);
- }
- }
- else if (ele.nodeType) {
- var cssProps = Object.keys(styles);
- for (var i_1 = 0; i_1 < cssProps.length; i_1++) {
- ele.style[cssProps[i_1]] = styles[cssProps[i_1]];
- }
- }
- }
- }
- function addClass(ele, className) {
- if (ele) {
- if (ele.length) {
- for (var i = 0; i < ele.length; i++) {
- addClass(ele[i], className);
- }
- }
- else if (ele.nodeType) {
- if (Array.isArray(className)) {
- className.forEach(function (cls) {
- ele.classList.add(cls);
- });
- }
- else {
- ele.classList.add(className);
- }
- }
- }
- }
- function removeClass(ele, className) {
- if (ele) {
- if (ele.length) {
- for (var i = 0; i < ele.length; i++) {
- removeClass(ele[i], className);
- }
- }
- else if (ele.nodeType) {
- if (Array.isArray(className)) {
- className.forEach(function (cls) {
- ele.classList.remove(cls);
- });
- }
- else {
- ele.classList.remove(className);
- }
- }
- }
- }
- function getElementIndex(ele) {
- var i = 0;
- if (ele) {
- while ((ele = ele.previousSibling) !== null) {
- if (ele.nodeType === 1)
- i++;
- }
- }
- return i;
- }
- function queryChildren(parentEle, query) {
- if (parentEle) {
- return parentEle.querySelectorAll(query);
- }
- return [];
- }
- function eachChild(parentEle, query, callback) {
- if (parentEle) {
- var nodes = parentEle.querySelectorAll(query);
- for (var i = 0; i < nodes.length; i++) {
- callback(nodes[i]);
- }
- }
- }
- function transform(ele, val) {
- if (ele) {
- var elStyle = ele.style;
- elStyle.webkitTransform = elStyle.MsTransform = elStyle.msTransform = elStyle.transform = val;
- }
- }
- function transition(ele, duration) {
- if (ele) {
- if (typeof duration !== 'string') {
- duration = duration + 'ms';
- }
- var elStyle = ele.style;
- elStyle.webkitTransitionDuration = elStyle.MsTransitionDuration = elStyle.msTransitionDuration = elStyle.transitionDuration = duration;
- }
- }
- function triggerTransitionEnd(plt, ele) {
- try {
- var win = plt.win();
- var evt = new win.CustomEvent('transitionend', { bubbles: true, cancelable: true });
- ele.dispatchEvent(evt);
- }
- catch (e) { }
- }
- function offset(ele, plt) {
- if (ele) {
- var box = plt.getElementBoundingClientRect(ele);
- var body = plt.doc().body;
- var win = plt.win();
- var clientTop = ele.clientTop || body.clientTop || 0;
- var clientLeft = ele.clientLeft || body.clientLeft || 0;
- var scrollTop = win.pageYOffset || ele.scrollTop;
- var scrollLeft = win.pageXOffset || ele.scrollLeft;
- return {
- top: box.top + scrollTop - clientTop,
- left: box.left + scrollLeft - clientLeft
- };
- }
- return null;
- }
- function updateSlidesOffset(s) {
- for (var i = 0; i < s._slides.length; i++) {
- s._slides[i].swiperSlideOffset = isHorizontal(s) ? s._slides[i].offsetLeft : s._slides[i].offsetTop;
- }
- }
- function isHorizontal(s) {
- return s.direction === 'horizontal';
- }
- var formElements = ['INPUT', 'SELECT', 'TEXTAREA', 'BUTTON', 'VIDEO'];
- function isFormElement(el) {
- return !!el && formElements.indexOf(el.tagName) > -1;
- }
- /*=========================
- Min/Max Translate
- ===========================*/
- function minTranslate(s) {
- return (-s._snapGrid[0]);
- }
- function maxTranslate(s) {
- return (-s._snapGrid[s._snapGrid.length - 1]);
- }
- var CLS = {
- // Classnames
- noSwiping: 'swiper-no-swiping',
- containerModifier: 'swiper-container-',
- slide: 'swiper-slide',
- slideActive: 'swiper-slide-active',
- slideDuplicateActive: 'swiper-slide-duplicate-active',
- slideVisible: 'swiper-slide-visible',
- slideDuplicate: 'swiper-slide-duplicate',
- slideNext: 'swiper-slide-next',
- slideDuplicateNext: 'swiper-slide-duplicate-next',
- slidePrev: 'swiper-slide-prev',
- slideDuplicatePrev: 'swiper-slide-duplicate-prev',
- wrapper: 'swiper-wrapper',
- bullet: 'swiper-pagination-bullet',
- bulletActive: 'swiper-pagination-bullet-active',
- buttonDisabled: 'swiper-button-disabled',
- paginationCurrent: 'swiper-pagination-current',
- paginationTotal: 'swiper-pagination-total',
- paginationHidden: 'swiper-pagination-hidden',
- paginationProgressbar: 'swiper-pagination-progressbar',
- paginationClickable: 'swiper-pagination-clickable',
- paginationModifier: 'swiper-pagination-',
- lazyLoading: 'swiper-lazy',
- lazyStatusLoading: 'swiper-lazy-loading',
- lazyStatusLoaded: 'swiper-lazy-loaded',
- lazyPreloader: 'swiper-lazy-preloader',
- notification: 'swiper-notification',
- preloader: 'preloader',
- zoomContainer: 'swiper-zoom-container',
- };
-
- /*=========================
- Parallax
- ===========================*/
- function setParallaxTransform(s, el, progress) {
- var p;
- var pX;
- var pY;
- var rtlFactor = s._rtl ? -1 : 1;
- p = el.getAttribute('data-swiper-parallax') || '0';
- pX = el.getAttribute('data-swiper-parallax-x');
- pY = el.getAttribute('data-swiper-parallax-y');
- if (pX || pY) {
- pX = pX || '0';
- pY = pY || '0';
- }
- else {
- if (isHorizontal(s)) {
- pX = p;
- pY = '0';
- }
- else {
- pY = p;
- pX = '0';
- }
- }
- if ((pX).indexOf('%') >= 0) {
- pX = parseInt(pX, 10) * progress * rtlFactor + '%';
- }
- else {
- pX = pX * progress * rtlFactor + 'px';
- }
- if ((pY).indexOf('%') >= 0) {
- pY = parseInt(pY, 10) * progress + '%';
- }
- else {
- pY = pY * progress + 'px';
- }
- transform(el, 'translate3d(' + pX + ', ' + pY + ',0px)');
- }
- function parallaxSetTranslate(s) {
- eachChild(s.container, '[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y]', function (el) {
- setParallaxTransform(s, el, s.progress);
- });
- for (var i = 0; i < s._slides.length; i++) {
- var slide = s._slides[i];
- eachChild(slide, '[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y]', function () {
- var progress = Math.min(Math.max(slide.progress, -1), 1);
- setParallaxTransform(s, slide, progress);
- });
- }
- }
- function parallaxSetTransition(s, duration) {
- if (typeof duration === 'undefined')
- duration = s.speed;
- eachChild(s.container, '[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y]', function (el) {
- var parallaxDuration = parseInt(el.getAttribute('data-swiper-parallax-duration'), 10) || duration;
- if (duration === 0)
- parallaxDuration = 0;
- transition(el, parallaxDuration);
- });
- }
-
- function updateProgress(s, translate) {
- if (typeof translate === 'undefined') {
- translate = s._translate || 0;
- }
- var translatesDiff = maxTranslate(s) - minTranslate(s);
- var wasBeginning = s._isBeginning;
- var wasEnd = s._isEnd;
- if (translatesDiff === 0) {
- s.progress = 0;
- s._isBeginning = s._isEnd = true;
- }
- else {
- s.progress = (translate - minTranslate(s)) / (translatesDiff);
- s._isBeginning = s.progress <= 0;
- s._isEnd = s.progress >= 1;
- }
- s._zone.run(function () {
- if (s._isBeginning && !wasBeginning) {
- s.ionSlideReachStart.emit();
- }
- if (s._isEnd && !wasEnd) {
- s.ionSlideReachEnd.emit();
- }
- if (s.watchSlidesProgress) {
- updateSlidesProgress(s, translate);
- }
- s.ionSlideProgress.emit(s.progress);
- });
- }
- function updateSlidesProgress(s, translate) {
- if (typeof translate === 'undefined') {
- translate = s._translate || 0;
- }
- if (s._slides.length === 0)
- return;
- if (typeof s._slides[0].swiperSlideOffset === 'undefined') {
- updateSlidesOffset(s);
- }
- var offsetCenter = -translate;
- if (s._rtl)
- offsetCenter = translate;
- // Visible Slides
- removeClass(s._slides, CLS.slideVisible);
- for (var i = 0; i < s._slides.length; i++) {
- var slide = s._slides[i];
- var slideProgress = (offsetCenter + (s.centeredSlides ? minTranslate(s) : 0) - slide.swiperSlideOffset) / (slide.swiperSlideSize + s.spaceBetween);
- if (s.watchSlidesVisibility) {
- var slideBefore = -(offsetCenter - slide.swiperSlideOffset);
- var slideAfter = slideBefore + s._slidesSizesGrid[i];
- var isVisible = (slideBefore >= 0 && slideBefore < s._renderedSize) ||
- (slideAfter > 0 && slideAfter <= s._renderedSize) ||
- (slideBefore <= 0 && slideAfter >= s._renderedSize);
- if (isVisible) {
- s._slides[i].classList.add(CLS.slideVisible);
- }
- }
- slide.progress = s._rtl ? -slideProgress : slideProgress;
- }
- }
-
- function makeFocusable(ele) {
- ele.setAttribute('tabIndex', '0');
- }
- function addRole(ele, role) {
- ele.setAttribute('role', role);
- }
- function addLabel(ele, label) {
- ele.setAttribute('aria-label', label);
- }
- function ariaDisable(ele, isDisabled) {
- if (isDisabled) {
- ele.setAttribute('aria-disabled', 'true');
- }
- else if (ele.hasAttribute('aria-disabled')) {
- ele.removeAttribute('aria-disabled');
- }
- }
- function ariaHidden(ele, isHidden) {
- if (isHidden) {
- ele.setAttribute('aria-hidden', 'true');
- }
- else if (ele.hasAttribute('aria-hidden')) {
- ele.removeAttribute('aria-hidden');
- }
- }
- function onEnterKey(_, __) {
- // if (event.keyCode !== 13) return;
- // const target: HTMLElement = <any>event.target;
- // if (target.classList.contains(PARAMS.nextButtonClass)) {
- // if (s.isEnd) {
- // notify(s, PARAMS.lastSlideMessage);
- // } else {
- // notify(s, PARAMS.nextSlideMessage);
- // }
- // } else if (target.classList.contains(PARAMS.prevButtonClass)) {
- // if (s.isBeginning) {
- // notify(s, PARAMS.firstSlideMessage);
- // } else {
- // notify(s, PARAMS.prevSlideMessage);
- // }
- // }
- }
- // function notify(s: Slides, message: string) {
- // var notification = s._liveRegion;
- // if (notification) {
- // notification.innerHTML = message || '';
- // }
- // }
-
- /*=========================
- Pagination
- ===========================*/
- function updatePagination(s) {
- if (!s.paginationType || !s._paginationContainer)
- return;
- var paginationHTML = '';
- if (s.paginationType === 'bullets') {
- var numberOfBullets = s.loop ? Math.ceil((s._slides.length - s.loopedSlides * 2) / s.slidesPerGroup) : s._snapGrid.length;
- for (var i = 0; i < numberOfBullets; i++) {
- if (s.paginationBulletRender) {
- paginationHTML += s.paginationBulletRender(i, CLS.bullet);
- }
- else {
- paginationHTML += "<button class=\"" + CLS.bullet + "\" aria-label=\"Go to slide " + (i + 1) + "\" data-slide-index=\"" + i + "\"></button>";
- }
- }
- }
- else if (s.paginationType === 'fraction') {
- paginationHTML =
- '<span class="' + CLS.paginationCurrent + '"></span>' +
- ' / ' +
- '<span class="' + CLS.paginationTotal + '"></span>';
- }
- else if (s.paginationType === 'progress') {
- paginationHTML = '<span class="' + CLS.paginationProgressbar + '"></span>';
- }
- s._paginationContainer.innerHTML = paginationHTML;
- s._bullets = s._paginationContainer.querySelectorAll('.' + CLS.bullet);
- }
- function updatePaginationClasses(s) {
- // Current/Total
- var current;
- var total = s.loop ? Math.ceil((s._slides.length - s.loopedSlides * 2) / s.slidesPerGroup) : s._snapGrid.length;
- if (s.loop) {
- current = Math.ceil((s._activeIndex - s.loopedSlides) / s.slidesPerGroup);
- if (current > s._slides.length - 1 - s.loopedSlides * 2) {
- current = current - (s._slides.length - s.loopedSlides * 2);
- }
- if (current > total - 1) {
- current = current - total;
- }
- if (current < 0 && s.paginationType !== 'bullets') {
- current = total + current;
- }
- }
- else {
- if (typeof s._snapIndex !== 'undefined') {
- current = s._snapIndex;
- }
- else {
- current = s._activeIndex || 0;
- }
- }
- // Types
- if (s.paginationType === 'bullets' && s._bullets) {
- var selector = current + (current < 0 ? s._bullets.length : 0);
- for (var i = 0; i < s._bullets.length; i++) {
- if (i === selector) {
- addClass(s._bullets[i], CLS.bulletActive);
- }
- else {
- removeClass(s._bullets[i], CLS.bulletActive);
- }
- }
- }
- if (s.paginationType === 'fraction') {
- eachChild(s._paginationContainer, '.' + CLS.paginationCurrent, function (ele) {
- ele.textContent = (current + 1);
- });
- eachChild(s._paginationContainer, '.' + CLS.paginationTotal, function (ele) {
- ele.textContent = total;
- });
- }
- if (s.paginationType === 'progress') {
- var scale = (current + 1) / total, scaleX = scale, scaleY = 1;
- if (!isHorizontal(s)) {
- scaleY = scale;
- scaleX = 1;
- }
- eachChild(s._paginationContainer, '.' + CLS.paginationProgressbar, function (ele) {
- transform(ele, 'translate3d(0,0,0) scaleX(' + scaleX + ') scaleY(' + scaleY + ')');
- transition(ele, s.speed);
- });
- }
- }
-
- /*=========================
- Classes
- ===========================*/
- function updateClasses(s) {
- var childElements;
- removeClass(s._slides, [CLS.slideActive, CLS.slideNext, CLS.slidePrev, CLS.slideDuplicateActive, CLS.slideDuplicateNext, CLS.slideDuplicatePrev]);
- for (var i = 0; i < s._slides.length; i++) {
- ariaHidden(s._slides[i], true);
- }
- var activeSlide = s._slides[s._activeIndex];
- if (!activeSlide) {
- return;
- }
- // Active classes
- addClass(activeSlide, CLS.slideActive);
- ariaHidden(activeSlide, false);
- if (s.loop) {
- // Duplicate to all looped slides
- if (activeSlide.classList.contains(CLS.slideDuplicate)) {
- childElements = queryChildren(s._wrapper, '.' + CLS.slide + ':not(.' + CLS.slideDuplicate + ')[data-swiper-slide-index="' + s.realIndex + '"]');
- }
- else {
- childElements = queryChildren(s._wrapper, '.' + CLS.slide + '.' + CLS.slideDuplicate + '[data-swiper-slide-index="' + s.realIndex + '"]');
- }
- addClass(childElements, CLS.slideDuplicateActive);
- }
- // Next Slide
- var nextSlide = activeSlide.nextElementSibling;
- if (s.loop && !nextSlide) {
- nextSlide = s._slides[0];
- }
- nextSlide && nextSlide.classList.add(CLS.slideNext);
- // Prev Slide
- var prevSlide = activeSlide.previousElementSibling;
- if (s.loop && !prevSlide) {
- prevSlide = s._slides[s._slides.length - 1];
- }
- prevSlide && prevSlide.classList.add(CLS.slidePrev);
- if (s.loop) {
- // Duplicate to all looped slides
- if (nextSlide.classList.contains(CLS.slideDuplicate)) {
- childElements = queryChildren(s._wrapper, '.' + CLS.slide + ':not(.' + CLS.slideDuplicate + ')[data-swiper-slide-index="' + nextSlide.getAttribute('data-swiper-slide-index') + '"]');
- }
- else {
- childElements = queryChildren(s._wrapper, '.' + CLS.slide + '.' + CLS.slideDuplicate + '[data-swiper-slide-index="' + nextSlide.getAttribute('data-swiper-slide-index') + '"]');
- }
- addClass(childElements, CLS.slideDuplicateNext);
- if (prevSlide.classList.contains(CLS.slideDuplicate)) {
- childElements = queryChildren(s._wrapper, '.' + CLS.slide + ':not(.' + CLS.slideDuplicate + ')[data-swiper-slide-index="' + prevSlide.getAttribute('data-swiper-slide-index') + '"]');
- }
- else {
- childElements = queryChildren(s._wrapper, '.' + CLS.slide + '.' + CLS.slideDuplicate + '[data-swiper-slide-index="' + prevSlide.getAttribute('data-swiper-slide-index') + '"]');
- }
- addClass(childElements, CLS.slideDuplicatePrev);
- }
- // Pagination
- if (s._paginationContainer) {
- updatePaginationClasses(s);
- }
- // Next/active buttons
- if (!s.loop) {
- if (s.prevButton) {
- if (s._isBeginning) {
- s.prevButton.classList.add(CLS.buttonDisabled);
- ariaDisable(s.prevButton, true);
- }
- else {
- s.prevButton.classList.remove(CLS.buttonDisabled);
- ariaDisable(s.prevButton, false);
- }
- }
- if (s.nextButton) {
- if (s._isEnd) {
- s.nextButton.classList.add(CLS.buttonDisabled);
- ariaDisable(s.nextButton, true);
- }
- else {
- s.nextButton.classList.remove(CLS.buttonDisabled);
- ariaDisable(s.nextButton, false);
- }
- }
- }
- }
-
- function updateActiveIndex(s) {
- var translate = s._rtl ? s._translate : -s._translate;
- var newActiveIndex;
- var i;
- var snapIndex;
- for (i = 0; i < s._slidesGrid.length; i++) {
- if (typeof s._slidesGrid[i + 1] !== 'undefined') {
- if (translate >= s._slidesGrid[i] && translate < s._slidesGrid[i + 1] - (s._slidesGrid[i + 1] - s._slidesGrid[i]) / 2) {
- newActiveIndex = i;
- }
- else if (translate >= s._slidesGrid[i] && translate < s._slidesGrid[i + 1]) {
- newActiveIndex = i + 1;
- }
- }
- else {
- if (translate >= s._slidesGrid[i]) {
- newActiveIndex = i;
- }
- }
- }
- snapIndex = Math.floor(newActiveIndex / s.slidesPerGroup);
- if (snapIndex >= s._snapGrid.length)
- snapIndex = s._snapGrid.length - 1;
- if (newActiveIndex === s._activeIndex) {
- return;
- }
- s._snapIndex = snapIndex;
- s._previousIndex = s._activeIndex;
- s._activeIndex = newActiveIndex;
- updateClasses(s);
- updateRealIndex(s);
- }
- function updateRealIndex(s) {
- var activeSlide = s._slides[s._activeIndex];
- if (activeSlide) {
- s.realIndex = parseInt(activeSlide.getAttribute('data-swiper-slide-index') || s._activeIndex, 10);
- }
- }
-
- /*=========================
- Controller
- ===========================*/
- var SWIPER_CONTROLLER = {
- LinearSpline: function (_s, _platform, x, y) {
- this.x = x;
- this.y = y;
- this.lastIndex = x.length - 1;
- // Given an x value (x2), return the expected y2 value:
- // (x1,y1) is the known point before given value,
- // (x3,y3) is the known point after given value.
- var i1, i3;
- this.interpolate = function (x2) {
- if (!x2)
- return 0;
- // Get the indexes of x1 and x3 (the array indexes before and after given x2):
- i3 = binarySearch(this.x, x2);
- i1 = i3 - 1;
- // We have our indexes i1 & i3, so we can calculate already:
- // y2 := ((x2−x1) × (y3−y1)) ÷ (x3−x1) + y1
- return ((x2 - this.x[i1]) * (this.y[i3] - this.y[i1])) / (this.x[i3] - this.x[i1]) + this.y[i1];
- };
- var binarySearch = (function () {
- var maxIndex, minIndex, guess;
- return function (array, val) {
- minIndex = -1;
- maxIndex = array.length;
- while (maxIndex - minIndex > 1)
- if (array[guess = maxIndex + minIndex >> 1] <= val) {
- minIndex = guess;
- }
- else {
- maxIndex = guess;
- }
- return maxIndex;
- };
- })();
- },
- // xxx: for now i will just save one spline function to to
- getInterpolateFunction: function (s, plt, c) {
- if (!s._spline)
- s._spline = s.loop ?
- new SWIPER_CONTROLLER.LinearSpline(s, plt, s._slidesGrid, c._slidesGrid) :
- new SWIPER_CONTROLLER.LinearSpline(s, plt, s._snapGrid, c._snapGrid);
- },
- setTranslate: function (s, plt, translate, byController, setWrapperTranslate) {
- var controlled = s.control;
- var multiplier, controlledTranslate;
- function setControlledTranslate(c) {
- // this will create an Interpolate function based on the snapGrids
- // x is the Grid of the scrolled scroller and y will be the controlled scroller
- // it makes sense to create this only once and recall it for the interpolation
- // the function does a lot of value caching for performance
- translate = c._rtl && isHorizontal(c) ? -s._translate : s._translate;
- if (s.controlBy === 'slide') {
- SWIPER_CONTROLLER.getInterpolateFunction(s, plt, c);
- // i am not sure why the values have to be multiplicated this way, tried to invert the snapGrid
- // but it did not work out
- controlledTranslate = -s._spline.interpolate(-translate);
- }
- if (!controlledTranslate || s.controlBy === 'container') {
- multiplier = (maxTranslate(c) - minTranslate(c)) / (maxTranslate(s) - minTranslate(s));
- controlledTranslate = (translate - minTranslate(s)) * multiplier + minTranslate(c);
- }
- if (s.controlInverse) {
- controlledTranslate = maxTranslate(c) - controlledTranslate;
- }
- updateProgress(c, controlledTranslate);
- setWrapperTranslate(c, plt, controlledTranslate, false, s);
- updateActiveIndex(c);
- }
- if (Array.isArray(controlled)) {
- for (var i = 0; i < controlled.length; i++) {
- if (controlled[i] !== byController) {
- setControlledTranslate(controlled[i]);
- }
- }
- }
- else if (byController !== controlled) {
- setControlledTranslate(controlled);
- }
- },
- setTransition: function (s, plt, duration, byController, setWrapperTransition) {
- var controlled = s.control;
- var i;
- function setControlledTransition(c) {
- setWrapperTransition(c, plt, duration, s);
- if (duration !== 0) {
- onTransitionStart(c);
- plt.transitionEnd(c._wrapper, function () {
- if (!controlled)
- return;
- if (c.loop && s.controlBy === 'slide') {
- fixLoop(c, plt);
- }
- onTransitionEnd(c, plt);
- });
- }
- }
- if (Array.isArray(controlled)) {
- for (i = 0; i < controlled.length; i++) {
- if (controlled[i] !== byController) {
- setControlledTransition(controlled[i]);
- }
- }
- }
- else if (byController !== controlled) {
- setControlledTransition(controlled);
- }
- }
- };
-
- function isCordova(plt) {
- var win = plt.win();
- return !!(win['cordova'] || win['PhoneGap'] || win['phonegap']);
- }
- function isElectron(plt) {
- return plt.testUserAgent('Electron');
- }
- function isIos(plt) {
- // shortcut function to be reused internally
- // checks navigator.platform to see if it's an actual iOS device
- // this does not use the user-agent string because it is often spoofed
- // an actual iPad will return true, a chrome dev tools iPad will return false
- return plt.testNavigatorPlatform('iphone|ipad|ipod');
- }
- function isSafari(plt) {
- return plt.testUserAgent('Safari');
- }
- function isWKWebView(plt) {
- return isIos(plt) && !!plt.win()['webkit'];
- }
- function isIosUIWebView(plt) {
- return isIos(plt) && !isWKWebView(plt) && !isSafari(plt);
- }
-
- /*=========================
- Effects
- ===========================*/
- var SWIPER_EFFECTS = {
- 'fade': {
- setTranslate: function (s) {
- for (var i = 0; i < s._slides.length; i++) {
- var slide = s._slides[i];
- var offset$$1 = slide.swiperSlideOffset;
- var tx = -offset$$1;
- if (!s.virtualTranslate) {
- tx = tx - s._translate;
- }
- var ty = 0;
- if (!isHorizontal(s)) {
- ty = tx;
- tx = 0;
- }
- var slideOpacity = s.fade.crossFade ?
- Math.max(1 - Math.abs(slide.progress), 0) :
- 1 + Math.min(Math.max(slide.progress, -1), 0);
- slide.style.opacity = slideOpacity;
- transform(slide, 'translate3d(' + tx + 'px, ' + ty + 'px, 0px)');
- }
- },
- setTransition: function (s, plt, duration) {
- var slides = s._slides;
- for (var i = 0; i < slides.length; i++) {
- transition(slides[i], duration);
- }
- if (s.virtualTranslate && duration !== 0) {
- var eventTriggered = false;
- for (var i_1 = 0; i_1 < slides.length; i_1++) {
- plt.transitionEnd(slides[i_1], function () {
- if (eventTriggered || !s)
- return;
- eventTriggered = true;
- s._animating = false;
- triggerTransitionEnd(plt, s._wrapper);
- });
- }
- }
- }
- },
- 'flip': {
- setTranslate: function (s, plt) {
- for (var i = 0; i < s._slides.length; i++) {
- var slide = s._slides[i];
- var progress = slide.progress;
- if (s.flip.limitRotation) {
- progress = Math.max(Math.min(slide.progress, 1), -1);
- }
- var offset$$1 = slide.swiperSlideOffset;
- var rotate = -180 * progress, rotateY = rotate, rotateX = 0, tx = -offset$$1, ty = 0;
- if (!isHorizontal(s)) {
- ty = tx;
- tx = 0;
- rotateX = -rotateY;
- rotateY = 0;
- }
- else if (s._rtl) {
- rotateY = -rotateY;
- }
- slide.style.zIndex = -Math.abs(Math.round(progress)) + s._slides.length;
- if (s.flip.slideShadows) {
- // Set shadows
- var shadowBefore = (isHorizontal(s) ? slide.querySelector('.swiper-slide-shadow-left') : slide.querySelector('.swiper-slide-shadow-top'));
- var shadowAfter = (isHorizontal(s) ? slide.querySelector('.swiper-slide-shadow-right') : slide.querySelector('.swiper-slide-shadow-bottom'));
- if (!shadowBefore) {
- shadowBefore = plt.doc().createElement('div');
- shadowBefore.className = 'swiper-slide-shadow-' + (isHorizontal(s) ? 'left' : 'top');
- slide.appendChild(shadowBefore);
- }
- if (!shadowAfter) {
- shadowAfter = plt.doc().createElement('div');
- shadowAfter.className = 'swiper-slide-shadow-' + (isHorizontal(s) ? 'right' : 'bottom');
- slide.appendChild(shadowAfter);
- }
- if (shadowBefore) {
- shadowBefore.style.opacity = Math.max(-progress, 0);
- }
- if (shadowAfter) {
- shadowAfter.style.opacity = Math.max(progress, 0);
- }
- }
- transform(slide, 'translate3d(' + tx + 'px, ' + ty + 'px, 0px) rotateX(' + rotateX + 'deg) rotateY(' + rotateY + 'deg)');
- }
- },
- setTransition: function (s, plt, duration) {
- for (var i = 0; i < s._slides.length; i++) {
- var slide = s._slides[i];
- transition(slide, duration);
- eachChild(slide, '.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left', function (el) {
- transition(el, duration);
- });
- }
- if (s.virtualTranslate && duration !== 0) {
- var eventTriggered = false;
- plt.transitionEnd(s._slides[s._activeIndex], function (ev) {
- if (eventTriggered || !s)
- return;
- if (!ev.target.classList.contains(CLS.slideActive)) {
- return;
- }
- eventTriggered = true;
- s._animating = false;
- triggerTransitionEnd(plt, s._wrapper);
- });
- }
- }
- },
- 'cube': {
- setTranslate: function (s, plt) {
- var wrapperRotate = 0;
- var cubeShadow;
- if (s.cube.shadow) {
- if (isHorizontal(s)) {
- cubeShadow = s._wrapper.querySelector('.swiper-cube-shadow');
- if (!cubeShadow) {
- cubeShadow = plt.doc().createElement('div');
- cubeShadow.className = 'swiper-cube-shadow';
- s._wrapper.appendChild(cubeShadow);
- }
- cubeShadow.style.height = s.renderedWidth + 'px';
- }
- else {
- cubeShadow = s.container.querySelector('.swiper-cube-shadow');
- if (!cubeShadow) {
- cubeShadow = plt.doc().createElement('div');
- cubeShadow.className = 'swiper-cube-shadow';
- s._wrapper.appendChild(cubeShadow);
- }
- }
- }
- for (var i = 0; i < s._slides.length; i++) {
- var slide = s._slides[i];
- var slideAngle = i * 90;
- var round$$1 = Math.floor(slideAngle / 360);
- if (s._rtl) {
- slideAngle = -slideAngle;
- round$$1 = Math.floor(-slideAngle / 360);
- }
- var progress = Math.max(Math.min(slide.progress, 1), -1);
- var tx = 0, ty = 0, tz = 0;
- if (i % 4 === 0) {
- tx = -round$$1 * 4 * s._renderedSize;
- tz = 0;
- }
- else if ((i - 1) % 4 === 0) {
- tx = 0;
- tz = -round$$1 * 4 * s._renderedSize;
- }
- else if ((i - 2) % 4 === 0) {
- tx = s._renderedSize + round$$1 * 4 * s._renderedSize;
- tz = s._renderedSize;
- }
- else if ((i - 3) % 4 === 0) {
- tx = -s._renderedSize;
- tz = 3 * s._renderedSize + s._renderedSize * 4 * round$$1;
- }
- if (s._rtl) {
- tx = -tx;
- }
- if (!isHorizontal(s)) {
- ty = tx;
- tx = 0;
- }
- var transformStr = 'rotateX(' + (isHorizontal(s) ? 0 : -slideAngle) + 'deg) rotateY(' + (isHorizontal(s) ? slideAngle : 0) + 'deg) translate3d(' + tx + 'px, ' + ty + 'px, ' + tz + 'px)';
- if (progress <= 1 && progress > -1) {
- wrapperRotate = i * 90 + progress * 90;
- if (s._rtl)
- wrapperRotate = -i * 90 - progress * 90;
- }
- transform(slide, transformStr);
- if (s.cube.slideShadows) {
- // Set shadows
- var shadowBefore = (isHorizontal(s) ? slide.querySelector('.swiper-slide-shadow-left') : slide.querySelector('.swiper-slide-shadow-top'));
- var shadowAfter = (isHorizontal(s) ? slide.querySelector('.swiper-slide-shadow-right') : slide.querySelector('.swiper-slide-shadow-bottom'));
- if (!shadowBefore) {
- shadowBefore = plt.doc().createElement('div');
- shadowBefore.className = 'swiper-slide-shadow-' + (isHorizontal(s) ? 'left' : 'top');
- slide.appendChild(shadowBefore);
- }
- if (!shadowAfter) {
- shadowAfter = plt.doc().createElement('div');
- shadowAfter.className = 'swiper-slide-shadow-' + (isHorizontal(s) ? 'right' : 'bottom');
- slide.appendChild(shadowAfter);
- }
- if (shadowBefore)
- shadowBefore.style.opacity = Math.max(-progress, 0);
- if (shadowAfter)
- shadowAfter.style.opacity = Math.max(progress, 0);
- }
- }
- s._wrapper.style.transformOrigin = s._wrapper.style.webkitTransformOrigin = '50% 50% -' + (s._renderedSize / 2) + 'px';
- if (s.cube.shadow) {
- if (isHorizontal(s)) {
- transform(cubeShadow, 'translate3d(0px, ' + (s.renderedWidth / 2 + s.cube.shadowOffset) + 'px, ' + (-s.renderedWidth / 2) + 'px) rotateX(90deg) rotateZ(0deg) scale(' + (s.cube.shadowScale) + ')');
- }
- else {
- var shadowAngle = Math.abs(wrapperRotate) - Math.floor(Math.abs(wrapperRotate) / 90) * 90;
- var multiplier = 1.5 - (Math.sin(shadowAngle * 2 * Math.PI / 360) / 2 + Math.cos(shadowAngle * 2 * Math.PI / 360) / 2);
- var scale1 = s.cube.shadowScale;
- var scale2 = s.cube.shadowScale / multiplier;
- var offset$$1 = s.cube.shadowOffset;
- transform(cubeShadow, 'scale3d(' + scale1 + ', 1, ' + scale2 + ') translate3d(0px, ' + (s.renderedHeight / 2 + offset$$1) + 'px, ' + (-s.renderedHeight / 2 / scale2) + 'px) rotateX(-90deg)');
- }
- }
- var zFactor = (isSafari(plt) || isIosUIWebView(plt)) ? (-s._renderedSize / 2) : 0;
- transform(s._wrapper, 'translate3d(0px,0,' + zFactor + 'px) rotateX(' + (isHorizontal(s) ? 0 : wrapperRotate) + 'deg) rotateY(' + (isHorizontal(s) ? -wrapperRotate : 0) + 'deg)');
- },
- setTransition: function (s, _plt, duration) {
- for (var i = 0; i < s._slides.length; i++) {
- var slide = s._slides[i];
- transition(slide, duration);
- eachChild(slide, '.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left', function (el) {
- transition(el, duration);
- });
- }
- if (s.cube.shadow && !isHorizontal(s)) {
- eachChild(s.container, '.swiper-cube-shadow', function (el) {
- transition(el, duration);
- });
- }
- }
- },
- 'coverflow': {
- setTranslate: function (s, plt) {
- var transformStr = s._translate;
- var center = isHorizontal(s) ? -transformStr + s.renderedWidth / 2 : -transformStr + s.renderedHeight / 2;
- var rotate = isHorizontal(s) ? s.coverflow.rotate : -s.coverflow.rotate;
- var translate = s.coverflow.depth;
- // Each slide offset from center
- for (var i = 0, length = s._slides.length; i < length; i++) {
- var slide = s._slides[i];
- var slideSize = s._slidesSizesGrid[i];
- var slideOffset = slide.swiperSlideOffset;
- var offsetMultiplier = (center - slideOffset - slideSize / 2) / slideSize * s.coverflow.modifier;
- var rotateY = isHorizontal(s) ? rotate * offsetMultiplier : 0;
- var rotateX = isHorizontal(s) ? 0 : rotate * offsetMultiplier;
- // var rotateZ = 0
- var translateZ = -translate * Math.abs(offsetMultiplier);
- var translateY = isHorizontal(s) ? 0 : s.coverflow.stretch * (offsetMultiplier);
- var translateX = isHorizontal(s) ? s.coverflow.stretch * (offsetMultiplier) : 0;
- // Fix for ultra small values
- if (Math.abs(translateX) < 0.001)
- translateX = 0;
- if (Math.abs(translateY) < 0.001)
- translateY = 0;
- if (Math.abs(translateZ) < 0.001)
- translateZ = 0;
- if (Math.abs(rotateY) < 0.001)
- rotateY = 0;
- if (Math.abs(rotateX) < 0.001)
- rotateX = 0;
- var slideTransform = 'translate3d(' + translateX + 'px,' + translateY + 'px,' + translateZ + 'px) rotateX(' + rotateX + 'deg) rotateY(' + rotateY + 'deg)';
- transform(slide, slideTransform);
- slide.style.zIndex = -Math.abs(Math.round(offsetMultiplier)) + 1;
- if (s.coverflow.slideShadows) {
- // Set shadows
- var shadowBefore = (isHorizontal(s) ? slide.querySelector('.swiper-slide-shadow-left') : slide.querySelector('.swiper-slide-shadow-top'));
- var shadowAfter = (isHorizontal(s) ? slide.querySelector('.swiper-slide-shadow-right') : slide.querySelector('.swiper-slide-shadow-bottom'));
- if (!shadowBefore) {
- shadowBefore = plt.doc().createElement('div');
- shadowBefore.className = 'swiper-slide-shadow-' + (isHorizontal(s) ? 'left' : 'top');
- slide.appendChild(shadowBefore);
- }
- if (!shadowAfter) {
- shadowAfter = plt.doc().createElement('div');
- shadowAfter.className = 'swiper-slide-shadow-' + (isHorizontal(s) ? 'right' : 'bottom');
- slide.appendChild(shadowAfter);
- }
- if (shadowBefore) {
- shadowBefore.style.opacity = (offsetMultiplier > 0 ? offsetMultiplier : 0);
- }
- if (shadowAfter) {
- shadowAfter.style.opacity = ((-offsetMultiplier) > 0 ? -offsetMultiplier : 0);
- }
- }
- }
- },
- setTransition: function (s, _plt, duration) {
- for (var i = 0; i < s._slides.length; i++) {
- var slide = s._slides[i];
- transition(slide, duration);
- eachChild(slide, '.swiper-slide-shadow-top, .swiper-slide-shadow-right, .swiper-slide-shadow-bottom, .swiper-slide-shadow-left', function (el) {
- transition(el, duration);
- });
- }
- }
- }
- };
-
- function setWrapperTranslate(s, plt, translate, shouldUpdateActiveIndex, byController) {
- var x = 0, y = 0, z = 0;
- if (isHorizontal(s)) {
- x = s._rtl ? -translate : translate;
- }
- else {
- y = translate;
- }
- if (s.roundLengths) {
- x = round(x);
- y = round(y);
- }
- if (!s.virtualTranslate) {
- transform(s._wrapper, 'translate3d(' + x + 'px, ' + y + 'px, ' + z + 'px)');
- }
- s._translate = isHorizontal(s) ? x : y;
- // Check if we need to update progress
- var progress;
- var translatesDiff = maxTranslate(s) - minTranslate(s);
- if (translatesDiff === 0) {
- progress = 0;
- }
- else {
- progress = (translate - minTranslate(s)) / (translatesDiff);
- }
- if (progress !== s.progress) {
- updateProgress(s, translate);
- }
- if (shouldUpdateActiveIndex) {
- updateActiveIndex(s);
- }
- if (s.effect !== 'slide' && SWIPER_EFFECTS[s.effect]) {
- SWIPER_EFFECTS[s.effect].setTranslate(s, plt);
- }
- if (s.parallax) {
- parallaxSetTranslate(s);
- }
- if (s.control) {
- SWIPER_CONTROLLER.setTranslate(s, plt, s._translate, byController, setWrapperTranslate);
- }
- }
- function getTranslate(s, plt, el, axis) {
- var win = plt.win();
- var matrix;
- var curTransform;
- var curStyle;
- var transformMatrix;
- // automatic axis detection
- if (typeof axis === 'undefined') {
- axis = 'x';
- }
- if (s.virtualTranslate) {
- return s._rtl ? -s._translate : s._translate;
- }
- curStyle = plt.getElementComputedStyle(el);
- if (win.WebKitCSSMatrix) {
- curTransform = curStyle.transform || curStyle.webkitTransform;
- if (curTransform.split(',').length > 6) {
- curTransform = curTransform.split(', ').map(function (a) {
- return a.replace(',', '.');
- }).join(', ');
- }
- // Some old versions of Webkit choke when 'none' is passed; pass
- // empty string instead in this case
- transformMatrix = new win.WebKitCSSMatrix(curTransform === 'none' ? '' : curTransform);
- }
- else {
- transformMatrix = curStyle.MozTransform || curStyle.OTransform || curStyle.MsTransform || curStyle.msTransform || curStyle.transform || curStyle.getPropertyValue('transform').replace('translate(', 'matrix(1, 0, 0, 1,');
- matrix = transformMatrix.toString().split(',');
- }
- if (axis === 'x') {
- if (win.WebKitCSSMatrix) {
- // Latest Chrome and webkits Fix
- curTransform = transformMatrix.m41;
- }
- else if (matrix.length === 16) {
- // Crazy IE10 Matrix
- curTransform = parseFloat(matrix[12]);
- }
- else {
- // Normal Browsers
- curTransform = parseFloat(matrix[4]);
- }
- }
- if (axis === 'y') {
- if (win.WebKitCSSMatrix) {
- // Latest Chrome and webkits Fix
- curTransform = transformMatrix.m42;
- }
- else if (matrix.length === 16) {
- // Crazy IE10 Matrix
- curTransform = parseFloat(matrix[13]);
- }
- else {
- // Normal Browsers
- curTransform = parseFloat(matrix[5]);
- }
- }
- if (s._rtl && curTransform) {
- curTransform = -curTransform;
- }
- return curTransform || 0;
- }
- function getWrapperTranslate(s, plt, axis) {
- if (typeof axis === 'undefined') {
- axis = isHorizontal(s) ? 'x' : 'y';
- }
- return getTranslate(s, plt, s._wrapper, axis);
- }
- function setWrapperTransition(s, plt, duration, byController) {
- transition(s._wrapper, duration);
- if (s.effect !== 'slide' && SWIPER_EFFECTS[s.effect]) {
- SWIPER_EFFECTS[s.effect].setTransition(s, plt, duration);
- }
- if (s.parallax) {
- parallaxSetTransition(s, duration);
- }
- if (s.control) {
- SWIPER_CONTROLLER.setTransition(s, plt, duration, byController, setWrapperTransition);
- }
- }
-
- function initZoom(s, plt) {
- s._supportGestures = ('ongesturestart' in plt.win());
- s._zoom = {
- // "Global" Props
- scale: 1,
- currentScale: 1,
- isScaling: false,
- gesture: {
- slide: undefined,
- slideWidth: undefined,
- slideHeight: undefined,
- image: undefined,
- imageWrap: undefined,
- zoomMax: s.zoomMax
- },
- image: {
- isTouched: undefined,
- isMoved: undefined,
- currentX: undefined,
- currentY: undefined,
- minX: undefined,
- minY: undefined,
- maxX: undefined,
- maxY: undefined,
- width: undefined,
- height: undefined,
- startX: undefined,
- startY: undefined,
- touchesStart: {},
- touchesCurrent: {}
- },
- velocity: {
- x: undefined,
- y: undefined,
- prevPositionX: undefined,
- prevPositionY: undefined,
- prevTime: undefined
- },
- unRegs: []
- };
- resetZoomEvents(s, plt);
- return function () {
- detachZoomEvents(s);
- };
- }
- // Calc Scale From Multi-touches
- function getDistanceBetweenTouches(ev) {
- if (ev.targetTouches.length < 2)
- return 1;
- var x1 = ev.targetTouches[0].pageX, y1 = ev.targetTouches[0].pageY, x2 = ev.targetTouches[1].pageX, y2 = ev.targetTouches[1].pageY;
- return Math.sqrt(Math.pow(x2 - x1, 2) + Math.pow(y2 - y1, 2));
- }
- // Events
- function onGestureStart(s, _plt, ev) {
- var z = s._zoom;
- s.originalEvent = ev;
- if (!s._supportGestures) {
- if (ev.type !== 'touchstart' || ev.type === 'touchstart' && ev.targetTouches.length < 2) {
- return;
- }
- z.gesture.scaleStart = getDistanceBetweenTouches(ev);
- }
- if (!z.gesture.slide) {
- if (ev.currentTarget && ev.currentTarget.classList.contains(CLS.slide)) {
- z.gesture.slide = ev.currentTarget;
- }
- if (!z.gesture.slide) {
- z.gesture.slide = s._slides[s._activeIndex];
- }
- z.gesture.image = z.gesture.slide.querySelector('img, svg, canvas, ion-img');
- if (z.gesture.image) {
- z.gesture.imageWrap = z.gesture.image.closest('.' + CLS.zoomContainer);
- if (!z.gesture.imageWrap) {
- z.gesture.image = undefined;
- return;
- }
- z.gesture.zoomMax = parseInt(z.gesture.imageWrap.getAttribute('data-swiper-zoom') || s.zoomMax, 10);
- }
- }
- transition(z.gesture.image, 0);
- z.isScaling = true;
- }
- function onGestureChange(s, _plt, ev) {
- var z = s._zoom;
- s.originalEvent = ev;
- if (!s._supportGestures) {
- if (ev.type !== 'touchmove' || ev.type === 'touchmove' && ev.targetTouches.length < 2) {
- return;
- }
- z.gesture.scaleMove = getDistanceBetweenTouches(ev);
- }
- if (!z.gesture.image)
- return;
- if (s._supportGestures) {
- z.scale = ev.scale * z.currentScale;
- }
- else {
- z.scale = (z.gesture.scaleMove / z.gesture.scaleStart) * z.currentScale;
- }
- if (z.scale > z.gesture.zoomMax) {
- z.scale = z.gesture.zoomMax - 1 + Math.pow((z.scale - z.gesture.zoomMax + 1), 0.5);
- }
- if (z.scale < s.zoomMin) {
- z.scale = s.zoomMin + 1 - Math.pow((s.zoomMin - z.scale + 1), 0.5);
- }
- transform(z.gesture.image, 'translate3d(0,0,0) scale(' + z.scale + ')');
- }
- function onGestureEnd(s, _plt, ev) {
- var z = s._zoom;
- s.originalEvent = ev;
- if (!s._supportGestures) {
- if (ev.type !== 'touchend' || ev.type === 'touchend' && ev.changedTouches.length < 2) {
- return;
- }
- }
- if (!z.gesture.image)
- return;
- z.scale = Math.max(Math.min(z.scale, z.gesture.zoomMax), s.zoomMin);
- transition(z.gesture.image, s.speed);
- transform(z.gesture.image, 'translate3d(0,0,0) scale(' + z.scale + ')');
- z.currentScale = z.scale;
- z.isScaling = false;
- if (z.scale === 1) {
- z.gesture.slide = undefined;
- }
- }
- function onTouchStart(s, plt, ev) {
- var z = s._zoom;
- s.originalEvent = ev;
- if (!z.gesture.image || z.image.isTouched)
- return;
- if (plt.is('android')) {
- ev.preventDefault();
- }
- z.image.isTouched = true;
- z.image.touchesStart.x = ev.type === 'touchstart' ? ev.targetTouches[0].pageX : ev.pageX;
- z.image.touchesStart.y = ev.type === 'touchstart' ? ev.targetTouches[0].pageY : ev.pageY;
- }
- function onTouchMove(s, plt, ev) {
- var z = s._zoom;
- s.originalEvent = ev;
- if (!z.gesture.image)
- return;
- s._allowClick = false;
- if (!z.image.isTouched || !z.gesture.slide)
- return;
- if (!z.image.isMoved) {
- z.image.width = z.gesture.image.offsetWidth;
- z.image.height = z.gesture.image.offsetHeight;
- z.image.startX = getTranslate(s, plt, z.gesture.imageWrap, 'x') || 0;
- z.image.startY = getTranslate(s, plt, z.gesture.imageWrap, 'y') || 0;
- z.gesture.slideWidth = z.gesture.slide.offsetWidth;
- z.gesture.slideHeight = z.gesture.slide.offsetHeight;
- transition(z.gesture.imageWrap, 0);
- if (s._rtl) {
- z.image.startX = -z.image.startX;
- z.image.startY = -z.image.startY;
- }
- }
- // Define if we need image drag
- var scaledWidth = z.image.width * z.scale;
- var scaledHeight = z.image.height * z.scale;
- if (scaledWidth < z.gesture.slideWidth && scaledHeight < z.gesture.slideHeight) {
- return;
- }
- z.image.minX = Math.min((z.gesture.slideWidth / 2 - scaledWidth / 2), 0);
- z.image.maxX = -z.image.minX;
- z.image.minY = Math.min((z.gesture.slideHeight / 2 - scaledHeight / 2), 0);
- z.image.maxY = -z.image.minY;
- z.image.touchesCurrent.x = ev.type === 'touchmove' ? ev.targetTouches[0].pageX : ev.pageX;
- z.image.touchesCurrent.y = ev.type === 'touchmove' ? ev.targetTouches[0].pageY : ev.pageY;
- if (!z.image.isMoved && !z.isScaling) {
- if (isHorizontal(s) &&
- (Math.floor(z.image.minX) === Math.floor(z.image.startX) && z.image.touchesCurrent.x < z.image.touchesStart.x) ||
- (Math.floor(z.image.maxX) === Math.floor(z.image.startX) && z.image.touchesCurrent.x > z.image.touchesStart.x)) {
- z.image.isTouched = false;
- return;
- }
- else if (!isHorizontal(s) &&
- (Math.floor(z.image.minY) === Math.floor(z.image.startY) && z.image.touchesCurrent.y < z.image.touchesStart.y) ||
- (Math.floor(z.image.maxY) === Math.floor(z.image.startY) && z.image.touchesCurrent.y > z.image.touchesStart.y)) {
- z.image.isTouched = false;
- return;
- }
- }
- ev.preventDefault();
- ev.stopPropagation();
- z.image.isMoved = true;
- z.image.currentX = z.image.touchesCurrent.x - z.image.touchesStart.x + z.image.startX;
- z.image.currentY = z.image.touchesCurrent.y - z.image.touchesStart.y + z.image.startY;
- if (z.image.currentX < z.image.minX) {
- z.image.currentX = z.image.minX + 1 - Math.pow((z.image.minX - z.image.currentX + 1), 0.8);
- }
- if (z.image.currentX > z.image.maxX) {
- z.image.currentX = z.image.maxX - 1 + Math.pow((z.image.currentX - z.image.maxX + 1), 0.8);
- }
- if (z.image.currentY < z.image.minY) {
- z.image.currentY = z.image.minY + 1 - Math.pow((z.image.minY - z.image.currentY + 1), 0.8);
- }
- if (z.image.currentY > z.image.maxY) {
- z.image.currentY = z.image.maxY - 1 + Math.pow((z.image.currentY - z.image.maxY + 1), 0.8);
- }
- // Velocity
- if (!z.velocity.prevPositionX)
- z.velocity.prevPositionX = z.image.touchesCurrent.x;
- if (!z.velocity.prevPositionY)
- z.velocity.prevPositionY = z.image.touchesCurrent.y;
- if (!z.velocity.prevTime)
- z.velocity.prevTime = Date.now();
- z.velocity.x = (z.image.touchesCurrent.x - z.velocity.prevPositionX) / (Date.now() - z.velocity.prevTime) / 2;
- z.velocity.y = (z.image.touchesCurrent.y - z.velocity.prevPositionY) / (Date.now() - z.velocity.prevTime) / 2;
- if (Math.abs(z.image.touchesCurrent.x - z.velocity.prevPositionX) < 2)
- z.velocity.x = 0;
- if (Math.abs(z.image.touchesCurrent.y - z.velocity.prevPositionY) < 2)
- z.velocity.y = 0;
- z.velocity.prevPositionX = z.image.touchesCurrent.x;
- z.velocity.prevPositionY = z.image.touchesCurrent.y;
- z.velocity.prevTime = Date.now();
- transform(z.gesture.imageWrap, 'translate3d(' + z.image.currentX + 'px, ' + z.image.currentY + 'px,0)');
- }
- function onTouchEnd(s) {
- var z = s._zoom;
- if (!z.gesture.image)
- return;
- if (!z.image.isTouched || !z.image.isMoved) {
- z.image.isTouched = false;
- z.image.isMoved = false;
- return;
- }
- z.image.isTouched = false;
- z.image.isMoved = false;
- var momentumDurationX = 300;
- var momentumDurationY = 300;
- var momentumDistanceX = z.velocity.x * momentumDurationX;
- var newPositionX = z.image.currentX + momentumDistanceX;
- var momentumDistanceY = z.velocity.y * momentumDurationY;
- var newPositionY = z.image.currentY + momentumDistanceY;
- // Fix duration
- if (z.velocity.x !== 0)
- momentumDurationX = Math.abs((newPositionX - z.image.currentX) / z.velocity.x);
- if (z.velocity.y !== 0)
- momentumDurationY = Math.abs((newPositionY - z.image.currentY) / z.velocity.y);
- var momentumDuration = Math.max(momentumDurationX, momentumDurationY);
- z.image.currentX = newPositionX;
- z.image.currentY = newPositionY;
- // Define if we need image drag
- var scaledWidth = z.image.width * z.scale;
- var scaledHeight = z.image.height * z.scale;
- z.image.minX = Math.min((z.gesture.slideWidth / 2 - scaledWidth / 2), 0);
- z.image.maxX = -z.image.minX;
- z.image.minY = Math.min((z.gesture.slideHeight / 2 - scaledHeight / 2), 0);
- z.image.maxY = -z.image.minY;
- z.image.currentX = Math.max(Math.min(z.image.currentX, z.image.maxX), z.image.minX);
- z.image.currentY = Math.max(Math.min(z.image.currentY, z.image.maxY), z.image.minY);
- transition(z.gesture.imageWrap, momentumDuration);
- transform(z.gesture.imageWrap, 'translate3d(' + z.image.currentX + 'px, ' + z.image.currentY + 'px,0)');
- }
- function onTransitionEnd$1(s) {
- var z = s._zoom;
- if (z.gesture.slide && s._previousIndex !== s._activeIndex) {
- transform(z.gesture.image, 'translate3d(0,0,0) scale(1)');
- transform(z.gesture.imageWrap, 'translate3d(0,0,0)');
- z.gesture.slide = z.gesture.image = z.gesture.imageWrap = undefined;
- z.scale = z.currentScale = 1;
- }
- }
- function toggleZoom(s, plt) {
- var z = s._zoom;
- var ev = s.originalEvent;
- if (!z.gesture.slide) {
- z.gesture.slide = s.clickedSlide ? s.clickedSlide : s._slides[s._activeIndex];
- z.gesture.image = z.gesture.slide.querySelector('img, svg, canvas, ion-img');
- z.gesture.imageWrap = z.gesture.image && z.gesture.image.closest('.' + CLS.zoomContainer);
- }
- if (!z.gesture.imageWrap)
- return;
- var touchX;
- var touchY;
- var offsetX;
- var offsetY;
- var diffX;
- var diffY;
- var translateX;
- var translateY;
- var imageWidth;
- var imageHeight;
- var scaledWidth;
- var scaledHeight;
- var translateMinX;
- var translateMinY;
- var translateMaxX;
- var translateMaxY;
- var slideWidth;
- var slideHeight;
- if (typeof z.image.touchesStart.x === 'undefined' && ev) {
- touchX = ev.type === 'touchend' ? ev.changedTouches[0].pageX : ev.pageX;
- touchY = ev.type === 'touchend' ? ev.changedTouches[0].pageY : ev.pageY;
- }
- else {
- touchX = z.image.touchesStart.x;
- touchY = z.image.touchesStart.y;
- }
- if (z.scale && z.scale !== 1) {
- // Zoom Out
- z.scale = z.currentScale = 1;
- transition(z.gesture.imageWrap, 300);
- transform(z.gesture.imageWrap, 'translate3d(0,0,0)');
- transition(z.gesture.image, 300);
- transform(z.gesture.image, 'translate3d(0,0,0) scale(1)');
- z.gesture.slide = undefined;
- }
- else {
- // Zoom In
- z.scale = z.currentScale = parseInt(z.gesture.imageWrap.getAttribute('data-swiper-zoom') || s.zoomMax, 10);
- if (ev) {
- slideWidth = z.gesture.slide.offsetWidth;
- slideHeight = z.gesture.slide.offsetHeight;
- var slideOffsets = offset(z.gesture.slide, plt);
- offsetX = slideOffsets.left;
- offsetY = slideOffsets.top;
- diffX = offsetX + slideWidth / 2 - touchX;
- diffY = offsetY + slideHeight / 2 - touchY;
- imageWidth = z.gesture.image.offsetWidth;
- imageHeight = z.gesture.image.offsetHeight;
- scaledWidth = imageWidth * z.scale;
- scaledHeight = imageHeight * z.scale;
- translateMinX = Math.min((slideWidth / 2 - scaledWidth / 2), 0);
- translateMinY = Math.min((slideHeight / 2 - scaledHeight / 2), 0);
- translateMaxX = -translateMinX;
- translateMaxY = -translateMinY;
- translateX = diffX * z.scale;
- translateY = diffY * z.scale;
- if (translateX < translateMinX) {
- translateX = translateMinX;
- }
- if (translateX > translateMaxX) {
- translateX = translateMaxX;
- }
- if (translateY < translateMinY) {
- translateY = translateMinY;
- }
- if (translateY > translateMaxY) {
- translateY = translateMaxY;
- }
- }
- else {
- translateX = 0;
- translateY = 0;
- }
- transition(z.gesture.imageWrap, 300);
- transform(z.gesture.imageWrap, 'translate3d(' + translateX + 'px, ' + translateY + 'px,0)');
- transition(z.gesture.image, 300);
- transform(z.gesture.image, 'translate3d(0,0,0) scale(' + z.scale + ')');
- }
- }
- function resetZoomEvents(s, plt) {
- detachZoomEvents(s);
- var unRegs = s._zoom.unRegs;
- var evtOpts = { passive: s._touchEvents.start === 'touchstart', zone: false };
- var slides = s._slides;
- var slide;
- // Scale image
- if (s._supportGestures) {
- for (var i = 0; i < slides.length; i++) {
- slide = slides[i];
- // gesturestart
- plt.registerListener(slide, 'gesturestart', function (ev) {
- onGestureStart(s, plt, ev);
- }, evtOpts, unRegs);
- // gesturechange
- plt.registerListener(slide, 'gesturechange', function (ev) {
- onGestureChange(s, plt, ev);
- }, evtOpts, unRegs);
- // gestureend
- plt.registerListener(slide, 'gestureend', function (ev) {
- onGestureEnd(s, plt, ev);
- }, evtOpts, unRegs);
- }
- }
- else if (s._touchEvents.start === 'touchstart') {
- for (var i = 0; i < slides.length; i++) {
- slide = slides[i];
- // touchstart
- plt.registerListener(slide, s._touchEvents.start, function (ev) {
- onGestureStart(s, plt, ev);
- }, evtOpts, unRegs);
- // touchmove
- plt.registerListener(slide, s._touchEvents.move, function (ev) {
- onGestureChange(s, plt, ev);
- }, evtOpts, unRegs);
- // touchend
- plt.registerListener(slide, s._touchEvents.end, function (ev) {
- onGestureEnd(s, plt, ev);
- }, evtOpts, unRegs);
- }
- }
- // Move image
- var touchStartSub = s.ionSlideTouchStart.subscribe(function (ev) {
- onTouchStart(s, plt, ev);
- });
- unRegs.push(function () { touchStartSub.unsubscribe(); });
- for (var i = 0; i < slides.length; i++) {
- slide = slides[i];
- if (slide.querySelector('.' + CLS.zoomContainer)) {
- plt.registerListener(slide, 's.touchEvents.move', function (ev) {
- onTouchMove(s, plt, ev);
- }, evtOpts, unRegs);
- }
- }
- var touchEndSub = s.ionSlideTouchEnd.subscribe(function () {
- onTouchEnd(s);
- });
- unRegs.push(function () { touchEndSub.unsubscribe(); });
- // Scale Out
- var transEndSub = s.ionSlideTouchEnd.subscribe(function () {
- onTransitionEnd$1(s);
- });
- unRegs.push(function () { transEndSub.unsubscribe(); });
- if (s.zoomToggle) {
- var doubleTapSub = s.ionSlideDoubleTap.subscribe(function () {
- toggleZoom(s, plt);
- });
- unRegs.push(function () { doubleTapSub.unsubscribe(); });
- }
- }
- function detachZoomEvents(s) {
- s._zoom.unRegs.forEach(function (unReg) {
- unReg();
- });
- s._zoom.unRegs.length = 0;
- }
-
- /**
- * Adopted from Swiper
- * Most modern mobile touch slider and framework with hardware
- * accelerated transitions.
- *
- * http://www.idangero.us/swiper/
- *
- * Copyright 2016, Vladimir Kharlampidi
- * The iDangero.us
- * http://www.idangero.us/
- *
- * Licensed under MIT
- */
- function initSwiper(s, plt) {
- // Classname
- s._classNames = [];
- /*=========================
- Preparation - Define Container, Wrapper and Pagination
- ===========================*/
- if (!s.container) {
- return;
- }
- // Save instance in container HTML Element and in data
- s.container.swiper = s;
- var containerModifierClass = CLS.containerModifier;
- s._classNames.push(containerModifierClass + s.direction);
- if (s.freeMode) {
- s._classNames.push(containerModifierClass + 'free-mode');
- }
- if (s.autoHeight) {
- s._classNames.push(containerModifierClass + 'autoheight');
- }
- // Enable slides progress when required
- if (s.parallax || s.watchSlidesVisibility) {
- s.watchSlidesProgress = true;
- }
- // Max resistance when touchReleaseOnEdges
- if (s.touchReleaseOnEdges) {
- s.resistanceRatio = 0;
- }
- var effect = s.effect;
- // Coverflow / 3D
- if (['cube', 'coverflow', 'flip'].indexOf(effect) >= 0) {
- s.watchSlidesProgress = true;
- s._classNames.push(containerModifierClass + '3d');
- }
- if (effect !== 'slide') {
- s._classNames.push(containerModifierClass + effect);
- }
- if (effect === 'cube') {
- s.resistanceRatio = 0;
- s.slidesPerView = 1;
- s.slidesPerColumn = 1;
- s.slidesPerGroup = 1;
- s.centeredSlides = false;
- s.spaceBetween = 0;
- s.virtualTranslate = true;
- s.setWrapperSize = false;
- }
- if (effect === 'fade' || effect === 'flip') {
- s.slidesPerView = 1;
- s.slidesPerColumn = 1;
- s.slidesPerGroup = 1;
- s.watchSlidesProgress = true;
- s.spaceBetween = 0;
- s.setWrapperSize = false;
- s.virtualTranslate = true;
- }
- // Wrapper
- s._wrapper = s.container.querySelector('.' + CLS.wrapper);
- // Pagination
- if (s.paginationType) {
- s._paginationContainer = s.container.querySelector('.swiper-pagination');
- if (s.paginationType === 'bullets') {
- s._paginationContainer.classList.add(CLS.paginationModifier + 'clickable');
- }
- s._paginationContainer.classList.add(CLS.paginationModifier + s.paginationType);
- }
- // Next/Prev Buttons
- // if (s.nextButton || s.prevButton) {
- // if (s.nextButton) {
- // s.nextButton = <any>s.container.closest('ion-content').querySelector(s.nextButton);
- // }
- // if (s.prevButton) {
- // s.prevButton = <any>s.container.closest('ion-content').querySelector(s.prevButton);
- // }
- // }
- // RTL
- s._rtl = isHorizontal(s) && (s.container.dir.toLowerCase() === 'rtl' || s.container.style.direction === 'rtl');
- if (s._rtl) {
- s._classNames.push(containerModifierClass + 'rtl');
- }
- // Columns
- if (s.slidesPerColumn > 1) {
- s._classNames.push(containerModifierClass + 'multirow');
- }
- // Check for Android
- if (plt.is('android')) {
- s._classNames.push(containerModifierClass + 'android');
- }
- // Add classes
- s._classNames.forEach(function (clsName) {
- s.container.classList.add(clsName);
- });
- // Translate
- s._translate = 0;
- // Progress
- s.progress = 0;
- // Velocity
- s.velocity = 0;
- /*=========================
- Autoplay
- ===========================*/
- s._autoplayTimeoutId = undefined;
- s._autoplaying = false;
- s._autoplayPaused = false;
- s._allowClick = true;
- // Animating Flag
- s._animating = false;
- // Touches information
- s._touches = {
- startX: 0,
- startY: 0,
- currentX: 0,
- currentY: 0,
- diff: 0
- };
- if (s.loop) {
- createLoop(s);
- }
- updateContainerSize(s, plt);
- updateSlidesSize(s, plt);
- updatePagination(s);
- if (effect !== 'slide' && SWIPER_EFFECTS[effect]) {
- if (!s.loop) {
- updateProgress(s);
- }
- SWIPER_EFFECTS[effect].setTranslate(s, plt);
- }
- if (s.loop) {
- slideTo(s, plt, s.initialSlide + s.loopedSlides, 0, s.runCallbacksOnInit);
- }
- else {
- slideTo(s, plt, s.initialSlide, 0, s.runCallbacksOnInit);
- if (s.initialSlide === 0) {
- parallaxSetTranslate(s);
- }
- }
- if (s.autoplay) {
- startAutoplay(s, plt);
- }
- }
- /*=========================
- Autoplay
- ===========================*/
- function autoplay(s, plt) {
- var autoplayDelay = s.autoplay;
- var activeSlide = s._slides[s._activeIndex];
- if (activeSlide.hasAttribute('data-swiper-autoplay')) {
- autoplayDelay = (activeSlide.getAttribute('data-swiper-autoplay') || s.autoplay);
- }
- s._autoplayTimeoutId = plt.timeout(function () {
- s._zone.run(function () {
- if (s.loop) {
- fixLoop(s, plt);
- slideNext(s, plt, true, undefined, true);
- s.ionSlideAutoplay.emit(s);
- }
- else {
- if (!s._isEnd) {
- slideNext(s, plt, true, undefined, true);
- s.ionSlideAutoplay.emit(s);
- }
- else {
- if (!s.autoplayStopOnLast) {
- slideTo(s, plt, 0);
- s.ionSlideAutoplay.emit(s);
- }
- else {
- stopAutoplay(s);
- }
- }
- }
- });
- }, autoplayDelay);
- }
- function startAutoplay(s, plt) {
- if (typeof s._autoplayTimeoutId !== 'undefined')
- return false;
- if (!s.autoplay || s._autoplaying) {
- return false;
- }
- s._autoplaying = true;
- s._zone.run(function () {
- s.ionSlideAutoplayStart.emit(s);
- });
- autoplay(s, plt);
- }
- function stopAutoplay(s) {
- if (!s._autoplayTimeoutId)
- return;
- if (s._autoplayTimeoutId)
- clearTimeout(s._autoplayTimeoutId);
- s._autoplaying = false;
- s._autoplayTimeoutId = undefined;
- s._zone.run(function () {
- s.ionSlideAutoplayStop.emit(s);
- });
- }
- function pauseAutoplay(s, plt, speed) {
- if (s._autoplayPaused)
- return;
- if (s._autoplayTimeoutId)
- clearTimeout(s._autoplayTimeoutId);
- s._autoplayPaused = true;
- if (speed === 0) {
- s._autoplayPaused = false;
- autoplay(s, plt);
- }
- else {
- plt.transitionEnd(s._wrapper, function () {
- if (!s)
- return;
- s._autoplayPaused = false;
- if (!s._autoplaying) {
- stopAutoplay(s);
- }
- else {
- autoplay(s, plt);
- }
- });
- }
- }
- /*=========================
- Slider/slides sizes
- ===========================*/
- function updateAutoHeight(s) {
- var activeSlides = [];
- var newHeight = 0;
- var i;
- // Find slides currently in view
- if (s.slidesPerView !== 'auto' && s.slidesPerView > 1) {
- for (i = 0; i < Math.ceil(s.slidesPerView); i++) {
- var index = s._activeIndex + i;
- if (index > s._slides.length)
- break;
- activeSlides.push(s._slides[index]);
- }
- }
- else {
- activeSlides.push(s._slides[s._activeIndex]);
- }
- // Find new height from heighest slide in view
- for (i = 0; i < activeSlides.length; i++) {
- if (typeof activeSlides[i] !== 'undefined') {
- var height = activeSlides[i].offsetHeight;
- newHeight = height > newHeight ? height : newHeight;
- }
- }
- // Update Height
- if (newHeight) {
- s._wrapper.style.height = newHeight + 'px';
- }
- }
- function updateContainerSize(s, plt) {
- var container = s.container;
- var width;
- var height;
- if (typeof s.width !== 'undefined') {
- // manually assign user width
- width = s.width;
- }
- else {
- width = container.clientWidth;
- }
- if (typeof s.renderedHeight !== 'undefined') {
- // manually assign user height
- height = s.renderedHeight;
- }
- else {
- height = container.clientHeight;
- }
- if (width === 0 && isHorizontal(s) || height === 0 && !isHorizontal(s)) {
- return;
- }
- // Subtract paddings
- var containerStyles = plt.getElementComputedStyle(container);
- width = width - parseInt(containerStyles.paddingLeft, 10) - parseInt(containerStyles.paddingRight, 10);
- height = height - parseInt(containerStyles.paddingTop, 10) - parseInt(containerStyles.paddingBottom, 10);
- // Store values
- s.renderedWidth = width;
- s.renderedHeight = height;
- s._renderedSize = isHorizontal(s) ? width : height;
- }
- function updateSlidesSize(s, plt) {
- s._slides = s._wrapper.querySelectorAll('.' + CLS.slide);
- s._snapGrid = [];
- s._slidesGrid = [];
- s._slidesSizesGrid = [];
- var spaceBetween = s.spaceBetween;
- var slidePosition = -s.slidesOffsetBefore;
- var i;
- var prevSlideSize = 0;
- var index = 0;
- if (typeof s._renderedSize === 'undefined')
- return;
- if (typeof spaceBetween === 'string' && spaceBetween.indexOf('%') >= 0) {
- spaceBetween = parseFloat(spaceBetween.replace('%', '')) / 100 * s._renderedSize;
- }
- s._virtualSize = -spaceBetween;
- // reset margins
- if (s._rtl) {
- inlineStyle(s._slides, { marginLeft: '', marginTop: '' });
- }
- else {
- inlineStyle(s._slides, { marginRight: '', marginBottom: '' });
- }
- var slidesNumberEvenToRows;
- if (s.slidesPerColumn > 1) {
- if (Math.floor(s._slides.length / s.slidesPerColumn) === s._slides.length / s.slidesPerColumn) {
- slidesNumberEvenToRows = s._slides.length;
- }
- else {
- slidesNumberEvenToRows = Math.ceil(s._slides.length / s.slidesPerColumn) * s.slidesPerColumn;
- }
- if (s.slidesPerView !== 'auto' && s.slidesPerColumnFill === 'row') {
- slidesNumberEvenToRows = Math.max(slidesNumberEvenToRows, s.slidesPerView * s.slidesPerColumn);
- }
- }
- // Calc slides
- var slideSize;
- var slidesPerColumn = s.slidesPerColumn;
- var slidesPerRow = slidesNumberEvenToRows / slidesPerColumn;
- var numFullColumns = slidesPerRow - (s.slidesPerColumn * slidesPerRow - s._slides.length);
- for (i = 0; i < s._slides.length; i++) {
- slideSize = 0;
- var slide = s._slides[i];
- if (s.slidesPerColumn > 1) {
- // Set slides order
- var newSlideOrderIndex;
- var column;
- var row;
- if (s.slidesPerColumnFill === 'column') {
- column = Math.floor(i / slidesPerColumn);
- row = i - column * slidesPerColumn;
- if (column > numFullColumns || (column === numFullColumns && row === slidesPerColumn - 1)) {
- if (++row >= slidesPerColumn) {
- row = 0;
- column++;
- }
- }
- newSlideOrderIndex = column + row * slidesNumberEvenToRows / slidesPerColumn;
- inlineStyle(slide, {
- '-webkit-box-ordinal-group': newSlideOrderIndex,
- '-moz-box-ordinal-group': newSlideOrderIndex,
- '-ms-flex-order': newSlideOrderIndex,
- '-webkit-order': newSlideOrderIndex,
- 'order': newSlideOrderIndex
- });
- }
- else {
- row = Math.floor(i / slidesPerRow);
- column = i - row * slidesPerRow;
- }
- var cssVal = (row !== 0 && s.spaceBetween) && (s.spaceBetween + 'px');
- var cssObj = {};
- if (isHorizontal(s)) {
- cssObj['marginTop'] = cssVal;
- }
- else {
- cssObj['marginLeft'] = cssVal;
- }
- inlineStyle(slide, cssObj);
- slide.setAttribute('data-swiper-column', column);
- slide.setAttribute('data-swiper-row', row);
- }
- if (slide.style.display === 'none') {
- continue;
- }
- if (s.slidesPerView === 'auto') {
- var styles = plt.getElementComputedStyle(slide);
- if (isHorizontal(s)) {
- slideSize = slide.offsetWidth + parseFloat(styles.marginRight) + parseFloat(styles.marginLeft);
- }
- else {
- slideSize = slide.offsetHeight + parseFloat(styles.marginTop) + parseFloat(styles.marginBottom);
- }
- if (s.roundLengths)
- slideSize = round(slideSize);
- }
- else {
- slideSize = (s._renderedSize - (s.slidesPerView - 1) * spaceBetween) / s.slidesPerView;
- if (s.roundLengths)
- slideSize = round(slideSize);
- if (isHorizontal(s)) {
- s._slides[i].style.width = slideSize + 'px';
- }
- else {
- s._slides[i].style.height = slideSize + 'px';
- }
- }
- s._slides[i].swiperSlideSize = slideSize;
- s._slidesSizesGrid.push(slideSize);
- if (s.centeredSlides) {
- slidePosition = slidePosition + slideSize / 2 + prevSlideSize / 2 + spaceBetween;
- if (i === 0)
- slidePosition = slidePosition - s._renderedSize / 2 - spaceBetween;
- if (Math.abs(slidePosition) < 1 / 1000)
- slidePosition = 0;
- if ((index) % s.slidesPerGroup === 0)
- s._snapGrid.push(slidePosition);
- s._slidesGrid.push(slidePosition);
- }
- else {
- if ((index) % s.slidesPerGroup === 0)
- s._snapGrid.push(slidePosition);
- s._slidesGrid.push(slidePosition);
- slidePosition = slidePosition + slideSize + spaceBetween;
- }
- s._virtualSize += slideSize + spaceBetween;
- prevSlideSize = slideSize;
- index++;
- }
- s._virtualSize = Math.max(s._virtualSize, s._renderedSize) + s.slidesOffsetAfter;
- var newSlidesGrid;
- if (s._rtl && (s.effect === 'slide' || s.effect === 'coverflow')) {
- inlineStyle(s._wrapper, { width: s._virtualSize + s.spaceBetween + 'px' });
- }
- if (s.setWrapperSize) {
- if (isHorizontal(s)) {
- inlineStyle(s._wrapper, { width: s._virtualSize + s.spaceBetween + 'px' });
- }
- else {
- inlineStyle(s._wrapper, { height: s._virtualSize + s.spaceBetween + 'px' });
- }
- }
- if (s.slidesPerColumn > 1) {
- s._virtualSize = (slideSize + s.spaceBetween) * slidesNumberEvenToRows;
- s._virtualSize = Math.ceil(s._virtualSize / s.slidesPerColumn) - s.spaceBetween;
- if (isHorizontal(s)) {
- inlineStyle(s._wrapper, { width: s._virtualSize + s.spaceBetween + 'px' });
- }
- else {
- inlineStyle(s._wrapper, { height: s._virtualSize + s.spaceBetween + 'px' });
- }
- if (s.centeredSlides) {
- newSlidesGrid = [];
- for (i = 0; i < s._snapGrid.length; i++) {
- if (s._snapGrid[i] < s._virtualSize + s._snapGrid[0])
- newSlidesGrid.push(s._snapGrid[i]);
- }
- s._snapGrid = newSlidesGrid;
- }
- }
- // Remove last grid elements depending on width
- if (!s.centeredSlides) {
- newSlidesGrid = [];
- for (i = 0; i < s._snapGrid.length; i++) {
- if (s._snapGrid[i] <= s._virtualSize - s._renderedSize) {
- newSlidesGrid.push(s._snapGrid[i]);
- }
- }
- s._snapGrid = newSlidesGrid;
- if (Math.floor(s._virtualSize - s._renderedSize) - Math.floor(s._snapGrid[s._snapGrid.length - 1]) > 1) {
- s._snapGrid.push(s._virtualSize - s._renderedSize);
- }
- }
- if (s._snapGrid.length === 0)
- s._snapGrid = [0];
- if (s.spaceBetween !== 0) {
- if (isHorizontal(s)) {
- if (s._rtl) {
- inlineStyle(s._slides, { marginLeft: spaceBetween + 'px' });
- }
- else {
- inlineStyle(s._slides, { marginRight: spaceBetween + 'px' });
- }
- }
- else {
- inlineStyle(s._slides, { marginBottom: spaceBetween + 'px' });
- }
- }
- if (s.watchSlidesProgress) {
- updateSlidesOffset(s);
- }
- }
- /*=========================
- Dynamic Slides Per View
- ===========================*/
- function currentSlidesPerView(s) {
- var spv = 1;
- var i;
- var j;
- if (s.centeredSlides) {
- var size = s._slides[s._activeIndex].swiperSlideSize;
- var breakLoop;
- for (i = s._activeIndex + 1; i < s._slides.length; i++) {
- if (s._slides[i] && !breakLoop) {
- size += s._slides[i].swiperSlideSize;
- spv++;
- if (size > s._renderedSize)
- breakLoop = true;
- }
- }
- for (j = s._activeIndex - 1; j >= 0; j--) {
- if (s._slides[j] && !breakLoop) {
- size += s._slides[j].swiperSlideSize;
- spv++;
- if (size > s._renderedSize)
- breakLoop = true;
- }
- }
- }
- else {
- for (i = s._activeIndex + 1; i < s._slides.length; i++) {
- if (s._slidesGrid[i] - s._slidesGrid[s._activeIndex] < s._renderedSize) {
- spv++;
- }
- }
- }
- return spv;
- }
- /*=========================
- Common update method
- ===========================*/
- function update(s, plt, updateTranslate) {
- if (!s)
- return;
- updateContainerSize(s, plt);
- updateSlidesSize(s, plt);
- updateProgress(s);
- updatePagination(s);
- updateClasses(s);
- if (s.zoom) {
- resetZoomEvents(s, plt);
- }
- var translated;
- var newTranslate;
- function forceSetTranslate() {
- newTranslate = Math.min(Math.max(s._translate, maxTranslate(s)), minTranslate(s));
- setWrapperTranslate(s, plt, newTranslate);
- updateActiveIndex(s);
- updateClasses(s);
- }
- if (updateTranslate) {
- if (s._spline) {
- s._spline = undefined;
- }
- if (s.freeMode) {
- forceSetTranslate();
- if (s.autoHeight) {
- updateAutoHeight(s);
- }
- }
- else {
- if ((s.slidesPerView === 'auto' || s.slidesPerView > 1) && s._isEnd && !s.centeredSlides) {
- translated = slideTo(s, plt, s._slides.length - 1, 0, false, true);
- }
- else {
- translated = slideTo(s, plt, s._activeIndex, 0, false, true);
- }
- if (!translated) {
- forceSetTranslate();
- }
- }
- }
- else if (s.autoHeight) {
- updateAutoHeight(s);
- }
- }
- /*=========================
- Loop
- ===========================*/
- // Create looped slides
- function createLoop(s) {
- // Remove duplicated slides
- eachChild(s._wrapper, '.' + CLS.slide + '.' + CLS.slideDuplicate, function (ele) {
- ele.parentElement.removeChild(ele);
- });
- var slides = s._wrapper.querySelectorAll('.' + CLS.slide);
- if (s.slidesPerView === 'auto' && !s.loopedSlides) {
- s.loopedSlides = slides.length;
- }
- s.loopedSlides = parseInt((s.loopedSlides || s.slidesPerView), 10);
- s.loopedSlides = s.loopedSlides + s.loopAdditionalSlides;
- if (s.loopedSlides > slides.length) {
- s.loopedSlides = slides.length;
- }
- var prependSlides = [];
- var appendSlides = [];
- for (var i = 0; i < slides.length; i++) {
- var slide = slides[i];
- if (i < s.loopedSlides)
- appendSlides.push(slide);
- if (i < slides.length && i >= slides.length - s.loopedSlides)
- prependSlides.push(slide);
- slide.setAttribute('data-swiper-slide-index', i);
- }
- for (i = 0; i < appendSlides.length; i++) {
- var appendClone = appendSlides[i].cloneNode(true);
- addClass(appendClone, CLS.slideDuplicate);
- s._wrapper.appendChild(appendClone);
- }
- for (i = prependSlides.length - 1; i >= 0; i--) {
- var prependClone = prependSlides[i].cloneNode(true);
- addClass(prependClone, CLS.slideDuplicate);
- s._wrapper.insertBefore(prependClone, s._wrapper.firstElementChild);
- }
- }
- function destroyLoop(s) {
- eachChild(s._wrapper, '.' + CLS.slide + '.' + CLS.slideDuplicate, function (ele) {
- ele.parentElement.removeChild(ele);
- });
- if (s._slides) {
- for (var i = 0; i < s._slides.length; i++) {
- s._slides[i].removeAttribute('data-swiper-slide-index');
- }
- }
- }
- function fixLoop(s, plt) {
- var newIndex;
- if (s._activeIndex < s.loopedSlides) {
- // Fix For Negative Oversliding
- newIndex = s._slides.length - s.loopedSlides * 3 + s._activeIndex;
- newIndex = newIndex + s.loopedSlides;
- slideTo(s, plt, newIndex, 0, false, true);
- }
- else if ((s.slidesPerView === 'auto' && s._activeIndex >= s.loopedSlides * 2) || (s._activeIndex > s._slides.length - s.slidesPerView * 2)) {
- // Fix For Positive Oversliding
- newIndex = -s._slides.length + s._activeIndex + s.loopedSlides;
- newIndex = newIndex + s.loopedSlides;
- slideTo(s, plt, newIndex, 0, false, true);
- }
- }
- /*=========================
- Transitions
- ===========================*/
- function slideTo(s, plt, slideIndex, speed, runCallbacks, internal) {
- if (runCallbacks === void 0) { runCallbacks = true; }
- if (typeof slideIndex === 'undefined')
- slideIndex = 0;
- if (slideIndex < 0)
- slideIndex = 0;
- s._snapIndex = Math.floor(slideIndex / s.slidesPerGroup);
- if (s._snapIndex >= s._snapGrid.length)
- s._snapIndex = s._snapGrid.length - 1;
- var translate = -s._snapGrid[s._snapIndex];
- // Stop autoplay
- if (s.autoplay && s._autoplaying) {
- if (internal || !s.autoplayDisableOnInteraction) {
- pauseAutoplay(s, plt, speed);
- }
- else {
- stopAutoplay(s);
- }
- }
- // Update progress
- updateProgress(s, translate);
- // Directions locks
- if (!s._allowSwipeToNext && translate < s._translate && translate < minTranslate(s)) {
- return false;
- }
- if (!s._allowSwipeToPrev && translate > s._translate && translate > maxTranslate(s)) {
- if ((s._activeIndex || 0) !== slideIndex)
- return false;
- }
- // Update Index
- if (typeof speed === 'undefined')
- speed = s.speed;
- s._previousIndex = s._activeIndex || 0;
- s._activeIndex = slideIndex;
- updateRealIndex(s);
- if ((s._rtl && -translate === s._translate) || (!s._rtl && translate === s._translate)) {
- // Update Height
- if (s.autoHeight) {
- updateAutoHeight(s);
- }
- updateClasses(s);
- if (s.effect !== 'slide') {
- setWrapperTranslate(s, plt, translate);
- }
- return false;
- }
- updateClasses(s);
- onTransitionStart(s, runCallbacks);
- if (speed === 0) {
- setWrapperTranslate(s, plt, translate);
- setWrapperTransition(s, plt, 0);
- onTransitionEnd(s, plt, runCallbacks);
- }
- else {
- setWrapperTranslate(s, plt, translate);
- setWrapperTransition(s, plt, speed);
- if (!s._animating) {
- s._animating = true;
- plt.transitionEnd(s._wrapper, function () {
- if (!s)
- return;
- onTransitionEnd(s, plt, runCallbacks);
- });
- }
- }
- return true;
- }
- function onTransitionStart(s, runCallbacks) {
- if (runCallbacks === void 0) { runCallbacks = true; }
- if (s.autoHeight) {
- updateAutoHeight(s);
- }
- if (runCallbacks) {
- s._zone.run(function () {
- s.ionSlideTransitionStart.emit(s);
- if (s._activeIndex !== s._previousIndex) {
- s.ionSlideWillChange.emit(s);
- if (s._activeIndex > s._previousIndex) {
- s.ionSlideNextStart.emit(s);
- }
- else {
- s.ionSlidePrevStart.emit(s);
- }
- }
- });
- }
- }
- function onTransitionEnd(s, plt, runCallbacks) {
- if (runCallbacks === void 0) { runCallbacks = true; }
- s._animating = false;
- setWrapperTransition(s, plt, 0);
- if (runCallbacks) {
- s._zone.run(function () {
- s.ionSlideTransitionEnd.emit(s);
- if (s._activeIndex !== s._previousIndex) {
- s.ionSlideDidChange.emit(s);
- if (s._activeIndex > s._previousIndex) {
- s.ionSlideNextEnd.emit(s);
- }
- else {
- s.ionSlidePrevEnd.emit(s);
- }
- }
- });
- }
- }
- function slideNext(s, plt, runCallbacks, speed, internal) {
- if (s.loop) {
- if (s._animating)
- return false;
- fixLoop(s, plt);
- s.container.clientLeft;
- return slideTo(s, plt, s._activeIndex + s.slidesPerGroup, speed, runCallbacks, internal);
- }
- var nextSlide = s._activeIndex + s.slidesPerGroup;
- if (nextSlide < s._slides.length) {
- return slideTo(s, plt, nextSlide, speed, runCallbacks, internal);
- }
- return false;
- }
- function slidePrev(s, plt, runCallbacks, speed, internal) {
- if (s.loop) {
- if (s._animating)
- return false;
- fixLoop(s, plt);
- s.container.clientLeft;
- return slideTo(s, plt, s._activeIndex - 1, speed, runCallbacks, internal);
- }
- var previousSlide = s._activeIndex - 1;
- if (previousSlide >= 0) {
- return slideTo(s, plt, s._activeIndex - 1, speed, runCallbacks, internal);
- }
- return false;
- }
- function slideReset(s, plt, runCallbacks, speed) {
- return slideTo(s, plt, s._activeIndex, speed, runCallbacks, true);
- }
-
-
- /*=========================
- Translate/transition helpers
- ===========================*/
- // Cleanup dynamic styles
- function cleanupStyles(s) {
- if (!s.container || !s._wrapper) {
- // fix #10830
- return;
- }
- // Container
- if (s.container) {
- removeClass(s.container, s._classNames);
- s.container.removeAttribute('style');
- }
- // Wrapper
- s._wrapper.removeAttribute('style');
- // Slides
- if (s._slides && s._slides.length) {
- removeClass(s._slides, [
- CLS.slideVisible,
- CLS.slideActive,
- CLS.slideNext,
- CLS.slidePrev
- ]);
- for (var i = 0; i < s._slides.length; i++) {
- var slide = s._slides[i];
- slide.removeAttribute('style');
- slide.removeAttribute('data-swiper-column');
- slide.removeAttribute('data-swiper-row');
- }
- }
- // Pagination/Bullets
- removeClass(s._bullets, CLS.bulletActive);
- // Buttons
- removeClass(s.prevButton, CLS.buttonDisabled);
- removeClass(s.nextButton, CLS.buttonDisabled);
- }
- // Destroy
- function destroySwiper(s) {
- // Stop autoplay
- stopAutoplay(s);
- // Destroy loop
- if (s.loop) {
- destroyLoop(s);
- }
- // Cleanup styles
- cleanupStyles(s);
- }
-
- /*=========================
- Keyboard Control
- ===========================*/
- function handleKeyboard(s, plt, e) {
- var win = plt.win();
- var kc = e.keyCode || e.charCode;
- // Directions locks
- if (!s._allowSwipeToNext && (isHorizontal(s) && kc === 39 || !isHorizontal(s) && kc === 40)) {
- return false;
- }
- if (!s._allowSwipeToPrev && (isHorizontal(s) && kc === 37 || !isHorizontal(s) && kc === 38)) {
- return false;
- }
- if (e.shiftKey || e.altKey || e.ctrlKey || e.metaKey) {
- return;
- }
- var activeEle = plt.getActiveElement();
- if (activeEle && activeEle.nodeName && (activeEle.nodeName.toLowerCase() === 'input' || activeEle.nodeName.toLowerCase() === 'textarea')) {
- return;
- }
- if (kc === 37 || kc === 39 || kc === 38 || kc === 40) {
- var inView = false;
- // Check that swiper should be inside of visible area of window
- if (s.container.closest('.' + CLS.slide) && !s.container.closest('.' + CLS.slideActive)) {
- return;
- }
- var windowScroll = {
- left: win.pageXOffset,
- top: win.pageYOffset
- };
- var windowWidth = plt.width();
- var windowHeight = plt.height();
- var swiperOffset = offset(s.container, plt);
- if (s._rtl) {
- swiperOffset.left = swiperOffset.left - s.container.scrollLeft;
- }
- var swiperCoord = [
- [swiperOffset.left, swiperOffset.top],
- [swiperOffset.left + s.renderedWidth, swiperOffset.top],
- [swiperOffset.left, swiperOffset.top + s.renderedHeight],
- [swiperOffset.left + s.renderedWidth, swiperOffset.top + s.renderedHeight]
- ];
- for (var i = 0; i < swiperCoord.length; i++) {
- var point = swiperCoord[i];
- if (point[0] >= windowScroll.left && point[0] <= windowScroll.left + windowWidth &&
- point[1] >= windowScroll.top && point[1] <= windowScroll.top + windowHeight) {
- inView = true;
- }
- }
- if (!inView)
- return;
- }
- if (isHorizontal(s)) {
- if (kc === 37 || kc === 39) {
- if (e.preventDefault) {
- e.preventDefault();
- }
- else {
- e.returnValue = false;
- }
- }
- if ((kc === 39 && !s._rtl) || (kc === 37 && s._rtl)) {
- slideNext(s, plt);
- }
- if ((kc === 37 && !s._rtl) || (kc === 39 && s._rtl)) {
- slidePrev(s, plt);
- }
- }
- else {
- if (kc === 38 || kc === 40) {
- if (e.preventDefault) {
- e.preventDefault();
- }
- else {
- e.returnValue = false;
- }
- }
- if (kc === 40) {
- slideNext(s, plt);
- }
- if (kc === 38) {
- slidePrev(s, plt);
- }
- }
- }
- function enableKeyboardControl(s, plt, shouldEnable) {
- if (shouldEnable && !s._keyboardUnReg) {
- s._keyboardUnReg = plt.registerListener(plt.doc(), 'keydown', function (ev) {
- handleKeyboard(s, plt, ev);
- }, { zone: false });
- }
- else if (!shouldEnable && s._keyboardUnReg) {
- s._keyboardUnReg();
- }
- }
-
- /*=========================
- Events
- ===========================*/
- // Attach/detach events
- function initEvents(s, plt) {
- var win = plt.win();
- var doc = plt.doc();
- s._supportTouch = (function () {
- return !!(('ontouchstart' in win) || win.DocumentTouch && doc instanceof win.DocumentTouch);
- })();
- // Define Touch Events
- s._touchEventsDesktop = { start: 'mousedown', move: 'mousemove', end: 'mouseup' };
- if (win.navigator.pointerEnabled) {
- s._touchEventsDesktop = { start: 'pointerdown', move: 'pointermove', end: 'pointerup' };
- }
- else if (win.navigator.msPointerEnabled) {
- s._touchEventsDesktop = { start: 'MSPointerDown', move: 'MSPointerMove', end: 'MSPointerUp' };
- }
- s._touchEvents = {
- start: s._supportTouch || !s.simulateTouch ? 'touchstart' : s._touchEventsDesktop.start,
- move: s._supportTouch || !s.simulateTouch ? 'touchmove' : s._touchEventsDesktop.move,
- end: s._supportTouch || !s.simulateTouch ? 'touchend' : s._touchEventsDesktop.end
- };
- // WP8 Touch Events Fix
- if (win.navigator.pointerEnabled || win.navigator.msPointerEnabled) {
- (s.touchEventsTarget === 'container' ? s.container : s._wrapper).classList.add('swiper-wp8-' + s.direction);
- }
- var unregs = [];
- var touchEventsTarget = s.touchEventsTarget === 'container' ? s.container : s._wrapper;
- // Touch Events
- if (s._supportTouch) {
- // touchstart
- plt.registerListener(touchEventsTarget, s._touchEvents.start, function (ev) {
- onTouchStart$1(s, plt, ev);
- }, { passive: true, zone: false }, unregs);
- // touchmove
- plt.registerListener(touchEventsTarget, s._touchEvents.move, function (ev) {
- onTouchMove$1(s, plt, ev);
- }, { zone: false }, unregs);
- // touchend
- plt.registerListener(touchEventsTarget, s._touchEvents.end, function (ev) {
- onTouchEnd$1(s, plt, ev);
- }, { passive: true, zone: false }, unregs);
- }
- if ((s.simulateTouch && !plt.is('ios') && !plt.is('android')) || (s.simulateTouch && !s._supportTouch && plt.is('ios')) || plt.getQueryParam('ionicPlatform')) {
- // mousedown
- plt.registerListener(touchEventsTarget, 'mousedown', function (ev) {
- onTouchStart$1(s, plt, ev);
- }, { zone: false }, unregs);
- // mousemove
- plt.registerListener(touchEventsTarget, 'mousemove', function (ev) {
- onTouchMove$1(s, plt, ev);
- }, { zone: false }, unregs);
- // mouseup
- plt.registerListener(touchEventsTarget, 'mouseup', function (ev) {
- onTouchEnd$1(s, plt, ev);
- }, { zone: false }, unregs);
- }
- // onresize
- var resizeObs = plt.resize.subscribe(function () { return onResize(s, plt, false); });
- // Next, Prev, Index
- if (s.nextButton) {
- plt.registerListener(s.nextButton, 'click', function (ev) {
- onClickNext(s, plt, ev);
- }, { zone: false }, unregs);
- }
- if (s.prevButton) {
- plt.registerListener(s.prevButton, 'click', function (ev) {
- onClickPrev(s, plt, ev);
- }, { zone: false }, unregs);
- }
- if (s.paginationType) {
- plt.registerListener(s._paginationContainer, 'click', function (ev) {
- onClickIndex(s, plt, ev);
- }, { zone: false }, unregs);
- }
- // Prevent Links Clicks
- if (s.preventClicks || s.preventClicksPropagation) {
- plt.registerListener(touchEventsTarget, 'click', function (ev) {
- preventClicks(s, ev);
- }, { zone: false, capture: true }, unregs);
- }
- // return a function that removes all of the added listeners
- return function () {
- resizeObs.unsubscribe();
- unregs.forEach(function (unreg) {
- unreg();
- });
- unregs = null;
- };
- }
- /*=========================
- Handle Clicks
- ===========================*/
- // Prevent Clicks
- function preventClicks(s, e) {
- if (!s._allowClick) {
- if (s.preventClicks) {
- e.preventDefault();
- }
- if (s.preventClicksPropagation && s._animating) {
- e.stopPropagation();
- e.stopImmediatePropagation();
- }
- }
- }
- // Clicks
- function onClickNext(s, plt, e) {
- e.preventDefault();
- if (s._isEnd && !s.loop) {
- return;
- }
- slideNext(s, plt);
- }
- function onClickPrev(s, plt, e) {
- e.preventDefault();
- if (s._isBeginning && !s.loop) {
- return;
- }
- slidePrev(s, plt);
- }
- function onClickIndex(s, plt, e) {
- var indexStr = e.target.getAttribute('data-slide-index');
- if (indexStr) {
- var index = parseInt(indexStr, 10);
- e.preventDefault();
- if (s.loop) {
- index = index + s.loopedSlides;
- }
- slideTo(s, plt, index);
- }
- }
- /*=========================
- Handle Touches
- ===========================*/
- function findElementInEvent(e, selector) {
- var el = e.target;
- if (!el.matches(selector)) {
- if (typeof selector === 'string') {
- el = el.closest(selector);
- }
- else if (selector.nodeType) {
- var parentEl = el.parentElement;
- while (parentEl) {
- if (parentEl === selector) {
- return selector;
- }
- }
- return undefined;
- }
- }
- return el;
- }
- function updateClickedSlide(s, plt, e) {
- var slide = findElementInEvent(e, '.' + CLS.slide);
- var slideIndex = -1;
- if (slide) {
- for (var i = 0; i < s._slides.length; i++) {
- if (s._slides[i] === slide) {
- slideIndex = i;
- break;
- }
- }
- }
- if (slide && slideIndex > -1) {
- s.clickedSlide = slide;
- s.clickedIndex = slideIndex;
- }
- else {
- s.clickedSlide = undefined;
- s.clickedIndex = undefined;
- return;
- }
- if (s.slideToClickedSlide && s.clickedIndex !== undefined && s.clickedIndex !== s._activeIndex) {
- var slideToIndex = s.clickedIndex;
- var realIndex;
- var slidesPerView = s.slidesPerView === 'auto' ? currentSlidesPerView(s) : s.slidesPerView;
- if (s.loop) {
- if (s._animating)
- return;
- realIndex = parseInt(s.clickedSlide.getAttribute('data-swiper-slide-index'), 10);
- if (s.centeredSlides) {
- if ((slideToIndex < s.loopedSlides - slidesPerView / 2) || (slideToIndex > s._slides.length - s.loopedSlides + slidesPerView / 2)) {
- fixLoop(s, plt);
- slideToIndex = getElementIndex(s._wrapper.querySelector('.' + CLS.slide + '[data-swiper-slide-index="' + realIndex + '"]:not(.' + CLS.slideDuplicate + ')'));
- plt.timeout(function () {
- slideTo(s, plt, slideToIndex);
- });
- }
- else {
- slideTo(s, plt, slideToIndex);
- }
- }
- else {
- if (slideToIndex > s._slides.length - slidesPerView) {
- fixLoop(s, plt);
- slideToIndex = getElementIndex(s._wrapper.querySelector('.' + CLS.slide + '[data-swiper-slide-index="' + realIndex + '"]:not(.' + CLS.slideDuplicate + ')'));
- plt.timeout(function () {
- slideTo(s, plt, slideToIndex);
- });
- }
- else {
- slideTo(s, plt, slideToIndex);
- }
- }
- }
- else {
- slideTo(s, plt, slideToIndex);
- }
- }
- }
- var isTouched;
- var isMoved;
- var allowTouchCallbacks;
- var touchStartTime;
- var isScrolling;
- var currentTranslate;
- var startTranslate;
- var allowThresholdMove;
- // Last click time
- var lastClickTime = Date.now();
- var clickTimeout;
- // Velocities
- var velocities = [];
- var allowMomentumBounce;
- // Touch handlers
- var isTouchEvent;
- var startMoving;
- function onTouchStart$1(s, plt, ev) {
- (void 0) /* console.debug */;
- if (ev.originalEvent) {
- ev = ev.originalEvent;
- }
- s.originalEvent = ev;
- isTouchEvent = ev.type === 'touchstart';
- if (!isTouchEvent && 'which' in ev && ev.which === 3) {
- return;
- }
- if (s.noSwiping && findElementInEvent(ev, '.' + CLS.noSwiping)) {
- s._allowClick = true;
- return;
- }
- if (s.swipeHandler) {
- if (!findElementInEvent(ev, s.swipeHandler))
- return;
- }
- var startX = s._touches.currentX = ev.type === 'touchstart' ? ev.targetTouches[0].pageX : ev.pageX;
- var startY = s._touches.currentY = ev.type === 'touchstart' ? ev.targetTouches[0].pageY : ev.pageY;
- // Do NOT start if iOS edge swipe is detected. Otherwise iOS app (UIWebView) cannot swipe-to-go-back anymore
- if (plt.is('ios') && s.iOSEdgeSwipeDetection && startX <= s.iOSEdgeSwipeThreshold) {
- return;
- }
- isTouched = true;
- isMoved = false;
- allowTouchCallbacks = true;
- isScrolling = undefined;
- startMoving = undefined;
- s._touches.startX = startX;
- s._touches.startY = startY;
- touchStartTime = Date.now();
- s._allowClick = true;
- updateContainerSize(s, plt);
- s.swipeDirection = undefined;
- if (s.threshold > 0) {
- allowThresholdMove = false;
- }
- if (ev.type !== 'touchstart') {
- var preventDefault = true;
- if (isFormElement(ev.target)) {
- preventDefault = false;
- }
- plt.focusOutActiveElement();
- if (preventDefault) {
- ev.preventDefault();
- }
- }
- s.ionSlideTouchStart.emit(ev);
- }
- function onTouchMove$1(s, plt, ev) {
- (void 0) /* console.debug */;
- if (ev.originalEvent) {
- ev = ev.originalEvent;
- }
- s.originalEvent = ev;
- if (isTouchEvent && ev.type === 'mousemove')
- return;
- if (ev.preventedByNestedSwiper) {
- s._touches.startX = ev.type === 'touchmove' ? ev.targetTouches[0].pageX : ev.pageX;
- s._touches.startY = ev.type === 'touchmove' ? ev.targetTouches[0].pageY : ev.pageY;
- return;
- }
- if (s.onlyExternal) {
- // isMoved = true;
- s._allowClick = false;
- if (isTouched) {
- s._touches.startX = s._touches.currentX = ev.type === 'touchmove' ? ev.targetTouches[0].pageX : ev.pageX;
- s._touches.startY = s._touches.currentY = ev.type === 'touchmove' ? ev.targetTouches[0].pageY : ev.pageY;
- touchStartTime = Date.now();
- }
- return;
- }
- if (isTouchEvent && s.touchReleaseOnEdges && !s.loop) {
- if (!isHorizontal(s)) {
- // Vertical
- if ((s._touches.currentY < s._touches.startY && s._translate <= maxTranslate(s)) ||
- (s._touches.currentY > s._touches.startY && s._translate >= minTranslate(s))) {
- return;
- }
- }
- else {
- if ((s._touches.currentX < s._touches.startX && s._translate <= maxTranslate(s)) ||
- (s._touches.currentX > s._touches.startX && s._translate >= minTranslate(s))) {
- return;
- }
- }
- }
- var activeEle = plt.getActiveElement();
- if (isTouchEvent && activeEle) {
- if (ev.target === activeEle && isFormElement(ev.target)) {
- isMoved = true;
- s._allowClick = false;
- return;
- }
- }
- if (ev.targetTouches && ev.targetTouches.length > 1)
- return;
- s._touches.currentX = ev.type === 'touchmove' ? ev.targetTouches[0].pageX : ev.pageX;
- s._touches.currentY = ev.type === 'touchmove' ? ev.targetTouches[0].pageY : ev.pageY;
- if (typeof isScrolling === 'undefined') {
- var touchAngle;
- if (isHorizontal(s) && s._touches.currentY === s._touches.startY || !isHorizontal(s) && s._touches.currentX === s._touches.startX) {
- isScrolling = false;
- }
- else {
- touchAngle = Math.atan2(Math.abs(s._touches.currentY - s._touches.startY), Math.abs(s._touches.currentX - s._touches.startX)) * 180 / Math.PI;
- isScrolling = isHorizontal(s) ? touchAngle > s.touchAngle : (90 - touchAngle > s.touchAngle);
- }
- }
- if (!isTouched)
- return;
- if (isScrolling) {
- isTouched = false;
- return;
- }
- s._allowClick = false;
- s.ionSlideDrag.emit(s);
- ev.preventDefault();
- if (s.touchMoveStopPropagation) {
- ev.stopPropagation();
- }
- if (!isMoved) {
- if (s.loop) {
- fixLoop(s, plt);
- }
- startTranslate = getWrapperTranslate(s, plt);
- setWrapperTransition(s, plt, 0);
- if (s._animating) {
- triggerTransitionEnd(plt, s._wrapper);
- }
- if (s.autoplay && s._autoplaying) {
- if (s.autoplayDisableOnInteraction) {
- stopAutoplay(s);
- }
- else {
- pauseAutoplay(s, plt);
- }
- }
- allowMomentumBounce = false;
- }
- isMoved = true;
- var diff = s._touches.diff = isHorizontal(s) ? s._touches.currentX - s._touches.startX : s._touches.currentY - s._touches.startY;
- diff = diff * s.touchRatio;
- if (s._rtl)
- diff = -diff;
- s.swipeDirection = diff > 0 ? 'prev' : 'next';
- currentTranslate = diff + startTranslate;
- var disableParentSwiper = true;
- if ((diff > 0 && currentTranslate > minTranslate(s))) {
- disableParentSwiper = false;
- if (s.resistance) {
- currentTranslate = minTranslate(s) - 1 + Math.pow(-minTranslate(s) + startTranslate + diff, s.resistanceRatio);
- }
- }
- else if (diff < 0 && currentTranslate < maxTranslate(s)) {
- disableParentSwiper = false;
- if (s.resistance)
- currentTranslate = maxTranslate(s) + 1 - Math.pow(maxTranslate(s) - startTranslate - diff, s.resistanceRatio);
- }
- if (disableParentSwiper) {
- ev.preventedByNestedSwiper = true;
- }
- // Directions locks
- if (!s._allowSwipeToNext && s.swipeDirection === 'next' && currentTranslate < startTranslate) {
- currentTranslate = startTranslate;
- }
- if (!s._allowSwipeToPrev && s.swipeDirection === 'prev' && currentTranslate > startTranslate) {
- currentTranslate = startTranslate;
- }
- // Threshold
- if (s.threshold > 0) {
- if (Math.abs(diff) > s.threshold || allowThresholdMove) {
- if (!allowThresholdMove) {
- allowThresholdMove = true;
- s._touches.startX = s._touches.currentX;
- s._touches.startY = s._touches.currentY;
- currentTranslate = startTranslate;
- s._touches.diff = isHorizontal(s) ? s._touches.currentX - s._touches.startX : s._touches.currentY - s._touches.startY;
- return;
- }
- }
- else {
- currentTranslate = startTranslate;
- return;
- }
- }
- if (!s.followFinger)
- return;
- // Update active index in free mode
- if (s.freeMode || s.watchSlidesProgress) {
- updateActiveIndex(s);
- }
- if (s.freeMode) {
- // Velocity
- if (velocities.length === 0) {
- velocities.push({
- position: s._touches[isHorizontal(s) ? 'startX' : 'startY'],
- time: touchStartTime
- });
- }
- velocities.push({
- position: s._touches[isHorizontal(s) ? 'currentX' : 'currentY'],
- time: (new Date()).getTime()
- });
- }
- // Update progress
- updateProgress(s, currentTranslate);
- // Update translate
- setWrapperTranslate(s, plt, currentTranslate);
- }
- function onTouchEnd$1(s, plt, ev) {
- (void 0) /* console.debug */;
- if (ev.originalEvent) {
- ev = ev.originalEvent;
- }
- s.originalEvent = ev;
- if (allowTouchCallbacks) {
- s.ionSlideTouchEnd.emit(ev);
- }
- allowTouchCallbacks = false;
- if (!isTouched)
- return;
- // Time diff
- var touchEndTime = Date.now();
- var timeDiff = touchEndTime - touchStartTime;
- // Tap, doubleTap, Click
- if (s._allowClick) {
- updateClickedSlide(s, plt, ev);
- s._zone.run(function () {
- s.ionSlideTap.emit(s);
- if (timeDiff < 300 && (touchEndTime - lastClickTime) > 300) {
- if (clickTimeout) {
- plt.cancelTimeout(clickTimeout);
- }
- clickTimeout = plt.timeout(function () {
- if (!s)
- return;
- if (s.paginationHide && s._paginationContainer && !ev.target.classList.contains(CLS.bullet)) {
- s._paginationContainer.classList.toggle(CLS.paginationHidden);
- }
- }, 300);
- }
- if (timeDiff < 300 && (touchEndTime - lastClickTime) < 300) {
- if (clickTimeout)
- clearTimeout(clickTimeout);
- s.ionSlideDoubleTap.emit(s);
- }
- });
- }
- lastClickTime = Date.now();
- plt.timeout(function () {
- if (s) {
- s._allowClick = true;
- }
- });
- if (!isTouched || !isMoved || !s.swipeDirection || s._touches.diff === 0 || currentTranslate === startTranslate) {
- isTouched = isMoved = false;
- return;
- }
- isTouched = isMoved = false;
- var currentPos;
- if (s.followFinger) {
- currentPos = s._rtl ? s._translate : -s._translate;
- }
- else {
- currentPos = -currentTranslate;
- }
- if (s.freeMode) {
- if (currentPos < -minTranslate(s)) {
- slideTo(s, plt, s._activeIndex);
- return;
- }
- else if (currentPos > -maxTranslate(s)) {
- if (s._slides.length < s._snapGrid.length) {
- slideTo(s, plt, s._snapGrid.length - 1);
- }
- else {
- slideTo(s, plt, s._slides.length - 1);
- }
- return;
- }
- if (s.freeModeMomentum) {
- if (velocities.length > 1) {
- var lastMoveEvent = velocities.pop(), velocityEvent = velocities.pop();
- var distance = lastMoveEvent.position - velocityEvent.position;
- var time = lastMoveEvent.time - velocityEvent.time;
- s.velocity = distance / time;
- s.velocity = s.velocity / 2;
- if (Math.abs(s.velocity) < s.freeModeMinimumVelocity) {
- s.velocity = 0;
- }
- // this implies that the user stopped moving a finger then released.
- // There would be no events with distance zero, so the last event is stale.
- if (time > 150 || (new Date().getTime() - lastMoveEvent.time) > 300) {
- s.velocity = 0;
- }
- }
- else {
- s.velocity = 0;
- }
- s.velocity = s.velocity * s.freeModeMomentumVelocityRatio;
- velocities.length = 0;
- var momentumDuration = 1000 * s.freeModeMomentumRatio;
- var momentumDistance = s.velocity * momentumDuration;
- var newPosition = s._translate + momentumDistance;
- if (s._rtl)
- newPosition = -newPosition;
- var doBounce = false;
- var afterBouncePosition;
- var bounceAmount = Math.abs(s.velocity) * 20 * s.freeModeMomentumBounceRatio;
- if (newPosition < maxTranslate(s)) {
- if (s.freeModeMomentumBounce) {
- if (newPosition + maxTranslate(s) < -bounceAmount) {
- newPosition = maxTranslate(s) - bounceAmount;
- }
- afterBouncePosition = maxTranslate(s);
- doBounce = true;
- allowMomentumBounce = true;
- }
- else {
- newPosition = maxTranslate(s);
- }
- }
- else if (newPosition > minTranslate(s)) {
- if (s.freeModeMomentumBounce) {
- if (newPosition - minTranslate(s) > bounceAmount) {
- newPosition = minTranslate(s) + bounceAmount;
- }
- afterBouncePosition = minTranslate(s);
- doBounce = true;
- allowMomentumBounce = true;
- }
- else {
- newPosition = minTranslate(s);
- }
- }
- else if (s.freeModeSticky) {
- var j = 0;
- var nextSlide;
- for (j = 0; j < s._snapGrid.length; j += 1) {
- if (s._snapGrid[j] > -newPosition) {
- nextSlide = j;
- break;
- }
- }
- if (Math.abs(s._snapGrid[nextSlide] - newPosition) < Math.abs(s._snapGrid[nextSlide - 1] - newPosition) || s.swipeDirection === 'next') {
- newPosition = s._snapGrid[nextSlide];
- }
- else {
- newPosition = s._snapGrid[nextSlide - 1];
- }
- if (!s._rtl)
- newPosition = -newPosition;
- }
- // Fix duration
- if (s.velocity !== 0) {
- if (s._rtl) {
- momentumDuration = Math.abs((-newPosition - s._translate) / s.velocity);
- }
- else {
- momentumDuration = Math.abs((newPosition - s._translate) / s.velocity);
- }
- }
- else if (s.freeModeSticky) {
- slideReset(s, plt);
- return;
- }
- if (s.freeModeMomentumBounce && doBounce) {
- updateProgress(s, afterBouncePosition);
- setWrapperTransition(s, plt, momentumDuration);
- setWrapperTranslate(s, plt, newPosition);
- onTransitionStart(s);
- s._animating = true;
- plt.transitionEnd(s._wrapper, function () {
- if (!s || !allowMomentumBounce)
- return;
- setWrapperTransition(s, plt, s.speed);
- setWrapperTranslate(s, plt, afterBouncePosition);
- plt.transitionEnd(s._wrapper, function () {
- if (!s)
- return;
- onTransitionEnd(s, plt);
- });
- });
- }
- else if (s.velocity) {
- updateProgress(s, newPosition);
- setWrapperTransition(s, plt, momentumDuration);
- setWrapperTranslate(s, plt, newPosition);
- onTransitionStart(s);
- if (!s._animating) {
- s._animating = true;
- plt.transitionEnd(s._wrapper, function () {
- if (!s)
- return;
- onTransitionEnd(s, plt);
- });
- }
- }
- else {
- updateProgress(s, newPosition);
- }
- updateActiveIndex(s);
- }
- if (!s.freeModeMomentum || timeDiff >= s.longSwipesMs) {
- updateProgress(s);
- updateActiveIndex(s);
- }
- return;
- }
- // Find current slide
- var stopIndex = 0;
- var groupSize = s._slidesSizesGrid[0];
- for (var i = 0; i < s._slidesGrid.length; i += s.slidesPerGroup) {
- if (typeof s._slidesGrid[i + s.slidesPerGroup] !== 'undefined') {
- if (currentPos >= s._slidesGrid[i] && currentPos < s._slidesGrid[i + s.slidesPerGroup]) {
- stopIndex = i;
- groupSize = s._slidesGrid[i + s.slidesPerGroup] - s._slidesGrid[i];
- }
- }
- else {
- if (currentPos >= s._slidesGrid[i]) {
- stopIndex = i;
- groupSize = s._slidesGrid[s._slidesGrid.length - 1] - s._slidesGrid[s._slidesGrid.length - 2];
- }
- }
- }
- // Find current slide size
- var ratio = (currentPos - s._slidesGrid[stopIndex]) / groupSize;
- if (timeDiff > s.longSwipesMs) {
- // Long touches
- if (!s.longSwipes) {
- slideTo(s, plt, s._activeIndex);
- return;
- }
- if (s.swipeDirection === 'next') {
- if (ratio >= s.longSwipesRatio) {
- slideTo(s, plt, stopIndex + s.slidesPerGroup);
- }
- else {
- slideTo(s, plt, stopIndex);
- }
- }
- if (s.swipeDirection === 'prev') {
- if (ratio > (1 - s.longSwipesRatio)) {
- slideTo(s, plt, stopIndex + s.slidesPerGroup);
- }
- else {
- slideTo(s, plt, stopIndex);
- }
- }
- }
- else {
- // Short swipes
- if (!s.shortSwipes) {
- slideTo(s, plt, s._activeIndex);
- return;
- }
- if (s.swipeDirection === 'next') {
- slideTo(s, plt, stopIndex + s.slidesPerGroup);
- }
- if (s.swipeDirection === 'prev') {
- slideTo(s, plt, stopIndex);
- }
- }
- }
- /*=========================
- Resize Handler
- ===========================*/
- var resizeId;
- function onResize(s, plt, forceUpdatePagination) {
- // TODO: hacky, we should use Resize Observer in the future
- if (resizeId) {
- plt.cancelTimeout(resizeId);
- resizeId = null;
- }
- resizeId = plt.timeout(function () { return doResize(s, plt, forceUpdatePagination); }, 200);
- }
- function doResize(s, plt, forceUpdatePagination) {
- resizeId = null;
- // Disable locks on resize
- var allowSwipeToPrev = s._allowSwipeToPrev;
- var allowSwipeToNext = s._allowSwipeToNext;
- s._allowSwipeToPrev = s._allowSwipeToNext = true;
- updateContainerSize(s, plt);
- updateSlidesSize(s, plt);
- if (s.slidesPerView === 'auto' || s.freeMode || forceUpdatePagination) {
- updatePagination(s);
- }
- if (s._spline) {
- s._spline = undefined;
- }
- var slideChangedBySlideTo = false;
- if (s.freeMode) {
- var newTranslate = Math.min(Math.max(s._translate, maxTranslate(s)), minTranslate(s));
- setWrapperTranslate(s, plt, newTranslate);
- updateActiveIndex(s);
- updateClasses(s);
- if (s.autoHeight) {
- updateAutoHeight(s);
- }
- }
- else {
- updateClasses(s);
- if ((s.slidesPerView === 'auto' || s.slidesPerView > 1) && s._isEnd && !s.centeredSlides) {
- slideChangedBySlideTo = slideTo(s, plt, s._slides.length - 1, 0, false, true);
- }
- else {
- slideChangedBySlideTo = slideTo(s, plt, s._activeIndex, 0, false, true);
- }
- }
- // Return locks after resize
- s._allowSwipeToPrev = allowSwipeToPrev;
- s._allowSwipeToNext = allowSwipeToNext;
- }
-
- var __extends$76 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @name Slides
- * @description
- * The Slides component is a multi-section container. Each section can be swiped
- * or dragged between. It contains any number of [Slide](../Slide) components.
- *
- *
- * ### Creating
- * You should use a template to create slides and listen to slide events. The template
- * should contain the slide container, an `<ion-slides>` element, and any number of
- * [Slide](../Slide) components, written as `<ion-slide>`. Basic configuration
- * values can be set as input properties, which are listed below. Slides events
- * can also be listened to such as the slide changing by placing the event on the
- * `<ion-slides>` element. See [Usage](#usage) below for more information.
- *
- *
- * ### Navigating
- * After creating and configuring the slides, you can navigate between them
- * by swiping or calling methods on the `Slides` instance. You can call `slideTo()` to
- * navigate to a specific slide, or `slideNext()` to change to the slide that follows
- * the active slide. All of the [methods](#instance-members) provided by the `Slides`
- * instance are listed below. See [Usage](#usage) below for more information on
- * navigating between slides.
- *
- *
- * @usage
- *
- * You can add slides to a `@Component` using the following template:
- *
- * ```html
- * <ion-slides>
- * <ion-slide>
- * <h1>Slide 1</h1>
- * </ion-slide>
- * <ion-slide>
- * <h1>Slide 2</h1>
- * </ion-slide>
- * <ion-slide>
- * <h1>Slide 3</h1>
- * </ion-slide>
- * </ion-slides>
- * ```
- *
- * Next, we can use `ViewChild` to assign the Slides instance to
- * your `slides` property. Now we can call any of the `Slides`
- * [methods](#instance-members), for example we can use the Slide's
- * `slideTo()` method in order to navigate to a specific slide on
- * a button click. Below we call the `goToSlide()` method and it
- * navigates to the 3rd slide:
- *
- * ```ts
- * import { ViewChild } from '@angular/core';
- * import { Slides } from 'ionic-angular';
- *
- * class MyPage {
- * @ViewChild(Slides) slides: Slides;
- *
- * goToSlide() {
- * this.slides.slideTo(2, 500);
- * }
- * }
- * ```
- *
- * We can also add events to listen to on the `<ion-slides>` element.
- * Let's add the `ionSlideDidChange` event and call a method when the slide changes:
- *
- * ```html
- * <ion-slides (ionSlideDidChange)="slideChanged()">
- * ```
- *
- * In our class, we add the `slideChanged()` method which gets the active
- * index and prints it:
- *
- * ```ts
- * class MyPage {
- * ...
- *
- * slideChanged() {
- * let currentIndex = this.slides.getActiveIndex();
- * console.log('Current index is', currentIndex);
- * }
- * }
- * ```
- *
- * ### Zooming
- * If your slides contain images, you can enable zooming on them by setting `zoom="true" and
- * wrapping each image in a `div` with the class `swiper-zoom-container`. Zoom supports
- * `img`, `svg`, `canvas`, and `ion-img`.
- *
- * ```html
- * <ion-slides zoom="true">
- * <ion-slide>
- * <div class="swiper-zoom-container">
- * <img src="assets/img/dog.jpg">
- * </div>
- * <ion-label>Woof</ion-label>
- * </ion-slide>
- * <ion-slide>
- * <div class="swiper-zoom-container">
- * <img src="assets/img/cat.jpg">
- * </div>
- * <ion-label>Meow</ion-label>
- * </ion-slide>
- * <ion-slide>
- * <div class="swiper-zoom-container">
- * <img src="assets/img/fish.jpg">
- * </div>
- * <ion-label>Just keep swimming</ion-label>
- * </ion-slide>
- * </ion-slides>
- * ```
- *
- * @advanced
- *
- * There are several options available to create customized slides. Ionic exposes
- * the most commonly used options as [inputs](http://learnangular2.com/inputs/).
- * In order to use an option that isn't exposed as an input the following code
- * should be used, where `freeMode` is the option to change:
- *
- * ```ts
- * import { ViewChild } from '@angular/core';
- * import { Slides } from 'ionic-angular';
-
- * class MyPage {
- * @ViewChild(Slides) slides: Slides;
- *
- * ngAfterViewInit() {
- * this.slides.freeMode = true;
- * }
- * }
- *
- * ```
- *
- * To see all of the available options, take a look at the
- * [source for slides](https://github.com/ionic-team/ionic/blob/master/src/components/slides/slides.ts).
- *
- * @demo /docs/demos/src/slides/
- * @see {@link /docs/components#slides Slides Component Docs}
- *
- * Adopted from Swiper.js:
- * The most modern mobile touch slider and framework with
- * hardware accelerated transitions.
- *
- * http://www.idangero.us/swiper/
- *
- * Copyright 2016, Vladimir Kharlampidi
- * The iDangero.us
- * http://www.idangero.us/
- *
- * Licensed under MIT
- */
- var Slides = (function (_super) {
- __extends$76(Slides, _super);
- function Slides(config, _plt, zone, viewCtrl, elementRef, renderer) {
- var _this = _super.call(this, config, elementRef, renderer, 'slides') || this;
- _this._plt = _plt;
- _this._control = null;
- _this._effectName = 'slide';
- _this._direction = 'horizontal';
- _this._initialSlide = 0;
- _this._isLoop = false;
- _this._pager = false;
- _this._paginationType = 'bullets';
- /** @hidden */
- _this.paginationBulletRender = null;
- _this._isParallax = false;
- _this._speedMs = 300;
- _this._isZoom = false;
- /**
- * @hidden
- * Enabled this option and swiper will be operated as usual except it will
- * not move, real translate values on wrapper will not be set. Useful when
- * you may need to create custom slide transition.
- */
- _this.virtualTranslate = false;
- /**
- * @hidden
- * Set to true to round values of slides width and height to prevent blurry
- * texts on usual resolution screens (if you have such)
- */
- _this.roundLengths = false;
- _this._spaceBetween = 0;
- _this._slidesPerView = 1;
- _this._centeredSlides = false;
- /**
- * @hidden
- */
- _this.slidesPerColumn = 1;
- /**
- * @hidden
- */
- _this.slidesPerColumnFill = 'column';
- /**
- * @hidden
- */
- _this.slidesPerGroup = 1;
- /**
- * @hidden
- */
- _this.slidesOffsetBefore = 0;
- /**
- * @hidden
- */
- _this.slidesOffsetAfter = 0;
- // autoplay
- /**
- * @hidden
- */
- _this.autoplayDisableOnInteraction = true;
- /**
- * @hidden
- */
- _this.autoplayStopOnLast = false;
- // Free mode
- /**
- * @hidden
- */
- _this.freeMode = false;
- /**
- * @hidden
- */
- _this.freeModeMomentum = true;
- /**
- * @hidden
- */
- _this.freeModeMomentumRatio = 1;
- /**
- * @hidden
- */
- _this.freeModeMomentumBounce = true;
- /**
- * @hidden
- */
- _this.freeModeMomentumBounceRatio = 1;
- /**
- * @hidden
- */
- _this.freeModeMomentumVelocityRatio = 1;
- /**
- * @hidden
- */
- _this.freeModeSticky = false;
- /**
- * @hidden
- */
- _this.freeModeMinimumVelocity = 0.02;
- // Autoheight
- /**
- * @hidden
- */
- _this.autoHeight = false;
- // Set wrapper width
- /**
- * @hidden
- */
- _this.setWrapperSize = false;
- // Zoom
- /**
- * @hidden
- */
- _this.zoomMax = 3;
- /**
- * @hidden
- */
- _this.zoomMin = 1;
- /**
- * @hidden
- */
- _this.zoomToggle = true;
- // Touches
- /**
- * @hidden
- */
- _this.touchRatio = 1;
- /**
- * @hidden
- */
- _this.touchAngle = 45;
- /**
- * @hidden
- */
- _this.simulateTouch = true;
- /**
- * @hidden
- */
- _this.shortSwipes = true;
- /**
- * @hidden
- */
- _this.longSwipes = true;
- /**
- * @hidden
- */
- _this.longSwipesRatio = 0.5;
- /**
- * @hidden
- */
- _this.longSwipesMs = 300;
- /**
- * @hidden
- */
- _this.followFinger = true;
- /**
- * @hidden
- */
- _this.onlyExternal = false;
- /**
- * @hidden
- */
- _this.threshold = 0;
- /**
- * @hidden
- */
- _this.touchMoveStopPropagation = true;
- /**
- * @hidden
- */
- _this.touchReleaseOnEdges = false;
- // To support iOS's swipe-to-go-back gesture (when being used in-app, with UIWebView).
- /**
- * @hidden
- */
- _this.iOSEdgeSwipeDetection = false;
- /**
- * @hidden
- */
- _this.iOSEdgeSwipeThreshold = 20;
- // Pagination
- /**
- * @hidden
- */
- _this.paginationClickable = false;
- /**
- * @hidden
- */
- _this.paginationHide = false;
- // Resistance
- /** @hidden */
- _this.resistance = true;
- /** @hidden */
- _this.resistanceRatio = 0.85;
- // Progress
- /** @hidden */
- _this.watchSlidesProgress = false;
- /** @hidden */
- _this.watchSlidesVisibility = false;
- // Clicks
- /**
- * @hidden
- */
- _this.preventClicks = true;
- /**
- * @hidden
- */
- _this.preventClicksPropagation = true;
- /**
- * @hidden
- */
- _this.slideToClickedSlide = false;
- // loop
- /**
- * @hidden
- */
- _this.loopAdditionalSlides = 0;
- /**
- * @hidden
- */
- _this.loopedSlides = null;
- // Swiping/no swiping
- /**
- * @hidden
- */
- _this.swipeHandler = null;
- /**
- * @hidden
- */
- _this.noSwiping = true;
- // Callbacks
- /** @hidden */
- _this.runCallbacksOnInit = true;
- // Controller
- _this.controlBy = 'slide';
- _this.controlInverse = false;
- // Keyboard
- /**
- * @hidden
- */
- _this.keyboardControl = true;
- // Effects
- /**
- * @hidden
- */
- _this.coverflow = {
- rotate: 50,
- stretch: 0,
- depth: 100,
- modifier: 1,
- slideShadows: true
- };
- /**
- * @hidden
- */
- _this.flip = {
- slideShadows: true,
- limitRotation: true
- };
- /**
- * @hidden
- */
- _this.cube = {
- slideShadows: true,
- shadow: true,
- shadowOffset: 20,
- shadowScale: 0.94
- };
- /**
- * @hidden
- */
- _this.fade = {
- crossFade: false
- };
- // Accessibility
- /**
- * @hidden
- */
- _this.prevSlideMessage = 'Previous slide';
- /**
- * @hidden
- */
- _this.nextSlideMessage = 'Next slide';
- /**
- * @hidden
- */
- _this.firstSlideMessage = 'This is the first slide';
- /**
- * @hidden
- */
- _this.lastSlideMessage = 'This is the last slide';
- /**
- * @output {Slides} Emitted when a slide change starts.
- */
- _this.ionSlideWillChange = new EventEmitter();
- /**
- * @output {Slides} Emitted when a slide change ends.
- */
- _this.ionSlideDidChange = new EventEmitter();
- /**
- * @output {Slides} Emitted when a slide moves.
- */
- _this.ionSlideDrag = new EventEmitter();
- /**
- * @output {Slides} Emitted when slides reaches its beginning (initial position).
- */
- _this.ionSlideReachStart = new EventEmitter();
- /**
- * @output {Slides} Emitted when slides reaches its last slide.
- */
- _this.ionSlideReachEnd = new EventEmitter();
- /**
- * @output {Slides} Emitted when a slide moves.
- */
- _this.ionSlideAutoplay = new EventEmitter();
- /**
- * @output {Slides} Emitted when a autoplay starts.
- */
- _this.ionSlideAutoplayStart = new EventEmitter();
- /**
- * @output {Slides} Emitted when a autoplay stops.
- */
- _this.ionSlideAutoplayStop = new EventEmitter();
- /**
- * @output {Slides} Emitted when a slide change starts with the "forward" direction.
- */
- _this.ionSlideNextStart = new EventEmitter();
- /**
- * @output {Slides} Emitted when a slide change starts with the "backward" direction.
- */
- _this.ionSlidePrevStart = new EventEmitter();
- /**
- * @output {Slides} Emitted when a slide change ends with the "forward" direction.
- */
- _this.ionSlideNextEnd = new EventEmitter();
- /**
- * @output {Slides} Emitted when a slide change ends with the "backward" direction.
- */
- _this.ionSlidePrevEnd = new EventEmitter();
- /**
- * @output {Slides} Emitted when the user taps/clicks on the slide's container.
- */
- _this.ionSlideTap = new EventEmitter();
- /**
- * @output {Slides} Emitted when the user double taps on the slide's container.
- */
- _this.ionSlideDoubleTap = new EventEmitter();
- /** @hidden */
- _this.ionSlideProgress = new EventEmitter();
- /** @hidden */
- _this.ionSlideTransitionStart = new EventEmitter();
- /** @hidden */
- _this.ionSlideTransitionEnd = new EventEmitter();
- /** @hidden */
- _this.ionSlideTouchStart = new EventEmitter();
- /** @hidden */
- _this.ionSlideTouchEnd = new EventEmitter();
- _this._unregs = [];
- /** @internal */
- _this._allowSwipeToNext = true;
- /** @internal */
- _this._allowSwipeToPrev = true;
- _this._zone = zone;
- _this.id = ++slidesId;
- _this.slideId = 'slides-' + _this.id;
- _this.setElementClass(_this.slideId, true);
- // only initialize the slides whent the content is ready
- if (viewCtrl) {
- var subscription = viewCtrl.readReady.subscribe(function () {
- subscription.unsubscribe();
- _this._initSlides();
- });
- }
- return _this;
- }
- Object.defineProperty(Slides.prototype, "autoplay", {
- /**
- * @input {number} Delay between transitions (in milliseconds). If this
- * parameter is not passed, autoplay is disabled. Default does
- * not have a value and does not autoplay.
- * Default: `null`.
- */
- get: function () {
- return this._autoplayMs;
- },
- set: function (val) {
- this._autoplayMs = parseInt(val, 10);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Slides.prototype, "control", {
- /**
- * @input {Slides} Pass another Slides instance or array of Slides instances
- * that should be controlled by this Slides instance.
- * Default: `null`.
- */
- get: function () {
- return this._control;
- },
- set: function (val) {
- if (val instanceof Slides || Array.isArray(val)) {
- this._control = val;
- }
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Slides.prototype, "effect", {
- /**
- * @input {string} The animation effect of the slides.
- * Possible values are: `slide`, `fade`, `cube`, `coverflow` or `flip`.
- * Default: `slide`.
- */
- get: function () {
- return this._effectName;
- },
- set: function (effectName) {
- if (SWIPER_EFFECTS[effectName]) {
- this._effectName = effectName;
- }
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Slides.prototype, "direction", {
- /**
- * @input {string} Swipe direction: 'horizontal' or 'vertical'.
- * Default: `horizontal`.
- */
- get: function () {
- return this._direction;
- },
- set: function (val) {
- if (val === 'horizontal' || val === 'vertical') {
- this._direction = val;
- }
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Slides.prototype, "initialSlide", {
- /**
- * @input {number} Index number of initial slide. Default: `0`.
- */
- get: function () {
- return this._initialSlide;
- },
- set: function (val) {
- this._initialSlide = parseInt(val, 10);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Slides.prototype, "loop", {
- /**
- * @input {boolean} If true, continuously loop from the last slide to the
- * first slide.
- */
- get: function () {
- return this._isLoop;
- },
- set: function (val) {
- this._isLoop = isTrueProperty(val);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Slides.prototype, "pager", {
- /**
- * @input {boolean} If true, show the pager.
- */
- get: function () {
- return this._pager;
- },
- set: function (val) {
- this._pager = isTrueProperty(val);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Slides.prototype, "dir", {
- /**
- * @input {string} If dir attribute is equal to rtl, set interal _rtl to true;
- */
- set: function (val) {
- this._rtl = (val.toLowerCase() === 'rtl');
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Slides.prototype, "paginationType", {
- /**
- * @input {string} Type of pagination. Possible values are:
- * `bullets`, `fraction`, `progress`. Default: `bullets`.
- * (Note that the pager will not show unless `pager` input
- * is set to true).
- */
- get: function () {
- return this._paginationType;
- },
- set: function (val) {
- if (val === 'bullets' || val === 'fraction' || val === 'progress') {
- this._paginationType = val;
- }
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Slides.prototype, "parallax", {
- /**
- * @input {boolean} If true, allows you to use "parallaxed" elements inside of
- * slider.
- */
- get: function () {
- return this._isParallax;
- },
- set: function (val) {
- this._isParallax = isTrueProperty(val);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Slides.prototype, "speed", {
- /**
- * @input {number} Duration of transition between slides
- * (in milliseconds). Default: `300`.
- */
- get: function () {
- return this._speedMs;
- },
- set: function (val) {
- this._speedMs = parseInt(val, 10);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Slides.prototype, "zoom", {
- /**
- * @input {boolean} If true, enables zooming functionality.
- */
- get: function () {
- return this._isZoom;
- },
- set: function (val) {
- this._isZoom = isTrueProperty(val);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Slides.prototype, "spaceBetween", {
- // Slides grid
- /**
- * @input {number} Distance between slides in px. Default: `0`.
- */
- get: function () {
- return this._spaceBetween;
- },
- set: function (val) {
- this._spaceBetween = parseInt(val, 10);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Slides.prototype, "slidesPerView", {
- /**
- * @input {number} Slides per view. Slides visible at the same time. Default: `1`.
- */
- get: function () {
- return this._slidesPerView;
- },
- set: function (val) {
- this._slidesPerView = val === 'auto' ? 'auto' : parseFloat(val);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Slides.prototype, "centeredSlides", {
- /**
- * @input {boolean} Center a slide in the middle of the screen.
- */
- get: function () {
- return this._centeredSlides;
- },
- set: function (val) {
- this._centeredSlides = isTrueProperty(val);
- },
- enumerable: true,
- configurable: true
- });
- Slides.prototype._initSlides = function () {
- if (!this._init) {
- (void 0) /* console.debug */;
- var s = this;
- var plt = s._plt;
- s.container = this.getNativeElement().children[0];
- // init swiper core
- initSwiper(s, plt);
- // init core event listeners
- this._unregs.push(initEvents(s, plt));
- if (this.zoom) {
- // init zoom event listeners
- this._unregs.push(initZoom(s, plt));
- }
- if (this.keyboardControl) {
- // init keyboard event listeners
- s.enableKeyboardControl(true);
- }
- this._init = true;
- }
- };
- /**
- * @hidden
- */
- Slides.prototype.ngAfterContentInit = function () {
- var _this = this;
- this._plt.timeout(function () {
- _this._initSlides();
- }, 300);
- };
- /**
- * Update the underlying slider implementation. Call this if you've added or removed
- * child slides.
- */
- Slides.prototype.update = function (debounce$$1) {
- var _this = this;
- if (debounce$$1 === void 0) { debounce$$1 = 300; }
- if (this._init) {
- this._plt.cancelTimeout(this._tmr);
- this._tmr = this._plt.timeout(function () {
- update(_this, _this._plt);
- // Don't allow pager to show with > 10 slides
- if (_this.length() > 10) {
- _this.paginationType = undefined;
- }
- }, debounce$$1);
- }
- };
- Slides.prototype.resize = function () {
- if (this._init) {
- }
- };
- /**
- * Transition to the specified slide.
- *
- * @param {number} index The index number of the slide.
- * @param {number} [speed] Transition duration (in ms).
- * @param {boolean} [runCallbacks] Whether or not to emit the `ionSlideWillChange`/`ionSlideDidChange` events. Default true.
- */
- Slides.prototype.slideTo = function (index, speed, runCallbacks) {
- slideTo(this, this._plt, index, speed, runCallbacks);
- };
- /**
- * Transition to the next slide.
- *
- * @param {number} [speed] Transition duration (in ms).
- * @param {boolean} [runCallbacks] Whether or not to emit the `ionSlideWillChange`/`ionSlideDidChange` events. Default true.
- */
- Slides.prototype.slideNext = function (speed, runCallbacks) {
- slideNext(this, this._plt, runCallbacks, speed, true);
- };
- /**
- * Transition to the previous slide.
- *
- * @param {number} [speed] Transition duration (in ms).
- * @param {boolean} [runCallbacks] Whether or not to emit the `ionSlideWillChange`/`ionSlideDidChange` events. Default true.
- */
- Slides.prototype.slidePrev = function (speed, runCallbacks) {
- slidePrev(this, this._plt, runCallbacks, speed, true);
- };
- /**
- * Get the index of the active slide.
- *
- * @returns {number} The index number of the current slide.
- */
- Slides.prototype.getActiveIndex = function () {
- return this._activeIndex;
- };
- /**
- * Get the index of the previous slide.
- *
- * @returns {number} The index number of the previous slide.
- */
- Slides.prototype.getPreviousIndex = function () {
- return this._previousIndex;
- };
- /**
- * Get the total number of slides.
- *
- * @returns {number} The total number of slides.
- */
- Slides.prototype.length = function () {
- return this._slides.length;
- };
- /**
- * Get whether or not the current slide is the last slide.
- *
- * @returns {boolean} If the slide is the last slide or not.
- */
- Slides.prototype.isEnd = function () {
- return this._isEnd;
- };
- /**
- * Get whether or not the current slide is the first slide.
- *
- * @returns {boolean} If the slide is the first slide or not.
- */
- Slides.prototype.isBeginning = function () {
- return this._isBeginning;
- };
- /**
- * Start auto play.
- */
- Slides.prototype.startAutoplay = function () {
- startAutoplay(this, this._plt);
- };
- /**
- * Stop auto play.
- */
- Slides.prototype.stopAutoplay = function () {
- stopAutoplay(this);
- };
- /**
- * Lock or unlock the ability to slide to the next slides.
- * @param {boolean} shouldLockSwipeToNext If set to true the user will not be able to swipe to the next slide.
- * Set to false to unlock this behaviour.
- */
- Slides.prototype.lockSwipeToNext = function (shouldLockSwipeToNext) {
- this._allowSwipeToNext = !shouldLockSwipeToNext;
- };
- /**
- * Lock or unlock the ability to slide to the previous slides.
- * @param {boolean} shouldLockSwipeToPrev If set to true the user will not be able to swipe to the previous slide.
- * Set to false to unlock this behaviour.
- */
- Slides.prototype.lockSwipeToPrev = function (shouldLockSwipeToPrev) {
- this._allowSwipeToPrev = !shouldLockSwipeToPrev;
- };
- /**
- * Lock or unlock the ability to slide to change slides.
- * @param {boolean} shouldLockSwipes If set to true user can not swipe in either direction on slide.
- * False allows swiping in both directions.
- */
- Slides.prototype.lockSwipes = function (shouldLockSwipes) {
- this._allowSwipeToNext = this._allowSwipeToPrev = !shouldLockSwipes;
- };
- /**
- * Enable or disable keyboard control.
- * @param {boolean} shouldEnableKeyboard If set to true the slider can be controled by a keyboard.
- */
- Slides.prototype.enableKeyboardControl = function (shouldEnableKeyboard) {
- enableKeyboardControl(this, this._plt, shouldEnableKeyboard);
- };
- /**
- * @hidden
- */
- Slides.prototype.ngOnDestroy = function () {
- this._init = false;
- this._unregs.forEach(function (unReg) {
- unReg();
- });
- this._unregs.length = 0;
- destroySwiper(this);
- this.enableKeyboardControl(false);
- };
- Slides.decorators = [
- { type: Component, args: [{
- selector: 'ion-slides',
- template: '<div class="swiper-container" [attr.dir]="_rtl? \'rtl\' : null">' +
- '<div class="swiper-wrapper">' +
- '<ng-content></ng-content>' +
- '</div>' +
- '<div [class.hide]="!pager" class="swiper-pagination"></div>' +
- '</div>',
- changeDetection: ChangeDetectionStrategy.OnPush,
- encapsulation: ViewEncapsulation.None,
- },] },
- ];
- /** @nocollapse */
- Slides.ctorParameters = function () { return [
- { type: Config, },
- { type: Platform, },
- { type: NgZone, },
- { type: ViewController, decorators: [{ type: Optional },] },
- { type: ElementRef, },
- { type: Renderer, },
- ]; };
- Slides.propDecorators = {
- 'autoplay': [{ type: Input },],
- 'control': [{ type: Input },],
- 'effect': [{ type: Input },],
- 'direction': [{ type: Input },],
- 'initialSlide': [{ type: Input },],
- 'loop': [{ type: Input },],
- 'pager': [{ type: Input },],
- 'dir': [{ type: Input },],
- 'paginationType': [{ type: Input },],
- 'parallax': [{ type: Input },],
- 'speed': [{ type: Input },],
- 'zoom': [{ type: Input },],
- 'spaceBetween': [{ type: Input },],
- 'slidesPerView': [{ type: Input },],
- 'centeredSlides': [{ type: Input },],
- 'ionSlideWillChange': [{ type: Output },],
- 'ionSlideDidChange': [{ type: Output },],
- 'ionSlideDrag': [{ type: Output },],
- 'ionSlideReachStart': [{ type: Output },],
- 'ionSlideReachEnd': [{ type: Output },],
- 'ionSlideAutoplay': [{ type: Output },],
- 'ionSlideAutoplayStart': [{ type: Output },],
- 'ionSlideAutoplayStop': [{ type: Output },],
- 'ionSlideNextStart': [{ type: Output },],
- 'ionSlidePrevStart': [{ type: Output },],
- 'ionSlideNextEnd': [{ type: Output },],
- 'ionSlidePrevEnd': [{ type: Output },],
- 'ionSlideTap': [{ type: Output },],
- 'ionSlideDoubleTap': [{ type: Output },],
- };
- return Slides;
- }(Ion));
- var slidesId = -1;
-
- /**
- * @name Slide
- * @description
- * The Slide component is a child component of [Slides](../Slides). The template
- * should be written as `ion-slide`. Any slide content should be written
- * in this component and it should be used in conjunction with [Slides](../Slides).
- *
- * See the [Slides API Docs](../Slides) for more usage information.
- *
- * @demo /docs/demos/src/slides/
- * @see {@link /docs/api/components/slides/Slides/ Slides API Docs}
- */
- var Slide = (function () {
- function Slide(elementRef, renderer, _slides) {
- this._slides = _slides;
- renderer.setElementClass(elementRef.nativeElement, 'swiper-slide', true);
- _slides.update(10);
- }
- /**
- * @hidden
- */
- Slide.prototype.ngOnDestroy = function () {
- this._slides.update(10);
- };
- Slide.decorators = [
- { type: Component, args: [{
- selector: 'ion-slide',
- template: '<div class="slide-zoom">' +
- '<ng-content></ng-content>' +
- '</div>',
- changeDetection: ChangeDetectionStrategy.OnPush,
- encapsulation: ViewEncapsulation.None,
- },] },
- ];
- /** @nocollapse */
- Slide.ctorParameters = function () { return [
- { type: ElementRef, },
- { type: Renderer, },
- { type: Slides, },
- ]; };
- return Slide;
- }());
-
- var __extends$77 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @name Spinner
- * @description
- * The `ion-spinner` component provides a variety of animated SVG spinners.
- * Spinners enables you to give users feedback that the app is actively
- * processing/thinking/waiting/chillin’ out, or whatever you’d like it to indicate.
- * By default, the `ion-refresher` feature uses this spinner component while it's
- * the refresher is in the `refreshing` state.
- *
- * Ionic offers a handful of spinners out of the box, and by default, it will use
- * the appropriate spinner for the platform on which it’s running.
- *
- * <table class="table spinner-table">
- * <tr>
- * <th>
- * <code>ios</code>
- * </th>
- * <td>
- * <ion-spinner name="ios"></ion-spinner>
- * </td>
- * </tr>
- * <tr>
- * <th>
- * <code>ios-small</code>
- * </th>
- * <td>
- * <ion-spinner name="ios-small"></ion-spinner>
- * </td>
- * </tr>
- * <tr>
- * <th>
- * <code>bubbles</code>
- * </th>
- * <td>
- * <ion-spinner name="bubbles"></ion-spinner>
- * </td>
- * </tr>
- * <tr>
- * <th>
- * <code>circles</code>
- * </th>
- * <td>
- * <ion-spinner name="circles"></ion-spinner>
- * </td>
- * </tr>
- * <tr>
- * <th>
- * <code>crescent</code>
- * </th>
- * <td>
- * <ion-spinner name="crescent"></ion-spinner>
- * </td>
- * </tr>
- * <tr>
- * <th>
- * <code>dots</code>
- * </th>
- * <td>
- * <ion-spinner name="dots"></ion-spinner>
- * </td>
- * </tr>
- * </table>
- *
- * @usage
- * The following code would use the default spinner for the platform it's
- * running from. If it's neither iOS or Android, it'll default to use `ios`.
- *
- * ```html
- * <ion-spinner></ion-spinner>
- * ```
- *
- * By setting the `name` property, you can specify which predefined spinner to
- * use, no matter what the platform is.
- *
- * ```html
- * <ion-spinner name="bubbles"></ion-spinner>
- * ```
- *
- * ## Styling SVG with CSS
- * One cool thing about SVG is its ability to be styled with CSS! One thing to note
- * is that some of the CSS properties on an SVG element have different names. For
- * example, SVG uses the term `stroke` instead of `border`, and `fill` instead
- * of `background-color`.
- *
- * ```css
- * ion-spinner * {
- * width: 28px;
- * height: 28px;
- * stroke: #444;
- * fill: #222;
- * }
- * ```
- */
- var Spinner = (function (_super) {
- __extends$77(Spinner, _super);
- function Spinner(config, elementRef, renderer) {
- var _this = _super.call(this, config, elementRef, renderer, 'spinner') || this;
- _this._dur = null;
- _this._paused = false;
- return _this;
- }
- Object.defineProperty(Spinner.prototype, "name", {
- /**
- * @input {string} SVG spinner name.
- */
- get: function () {
- return this._name;
- },
- set: function (val) {
- this._name = val;
- this.load();
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Spinner.prototype, "duration", {
- /**
- * @input {string} How long it takes it to do one loop.
- */
- get: function () {
- return this._dur;
- },
- set: function (val) {
- this._dur = val;
- this.load();
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Spinner.prototype, "paused", {
- /**
- * @input {boolean} If true, pause the animation.
- */
- get: function () {
- return this._paused;
- },
- set: function (val) {
- this._paused = isTrueProperty(val);
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @hidden
- */
- Spinner.prototype.ngOnInit = function () {
- this._init = true;
- this.load();
- };
- /**
- * @hidden
- */
- Spinner.prototype.load = function () {
- if (this._init) {
- this._l = [];
- this._c = [];
- var name = this._name || this._config.get('spinner', 'ios');
- var spinner = SPINNERS[name];
- if (spinner) {
- if (spinner.lines) {
- for (var i = 0, l = spinner.lines; i < l; i++) {
- this._l.push(this._loadEle(spinner, i, l));
- }
- }
- else if (spinner.circles) {
- for (var i = 0, l = spinner.circles; i < l; i++) {
- this._c.push(this._loadEle(spinner, i, l));
- }
- }
- this.setElementClass("spinner-" + name, true);
- this.setElementClass("spinner-" + this._mode + "-" + name, true);
- }
- }
- };
- Spinner.prototype._loadEle = function (spinner, index, total) {
- var duration = this._dur || spinner.dur;
- var data = spinner.fn(duration, index, total);
- data.style.animationDuration = duration + 'ms';
- return data;
- };
- Spinner.decorators = [
- { type: Component, args: [{
- selector: 'ion-spinner',
- template: '<svg viewBox="0 0 64 64" *ngFor="let i of _c" [ngStyle]="i.style">' +
- '<circle [attr.r]="i.r" transform="translate(32,32)"></circle>' +
- '</svg>' +
- '<svg viewBox="0 0 64 64" *ngFor="let i of _l" [ngStyle]="i.style">' +
- '<line [attr.y1]="i.y1" [attr.y2]="i.y2" transform="translate(32,32)"></line>' +
- '</svg>',
- host: {
- '[class.spinner-paused]': '_paused'
- },
- changeDetection: ChangeDetectionStrategy.OnPush,
- encapsulation: ViewEncapsulation.None,
- },] },
- ];
- /** @nocollapse */
- Spinner.ctorParameters = function () { return [
- { type: Config, },
- { type: ElementRef, },
- { type: Renderer, },
- ]; };
- Spinner.propDecorators = {
- 'name': [{ type: Input },],
- 'duration': [{ type: Input },],
- 'paused': [{ type: Input },],
- };
- return Spinner;
- }(Ion));
- var SPINNERS = {
- ios: {
- dur: 1000,
- lines: 12,
- fn: function (dur, index, total) {
- var transform = 'rotate(' + (30 * index + (index < 6 ? 180 : -180)) + 'deg)';
- var animationDelay = -(dur - ((dur / total) * index)) + 'ms';
- return {
- y1: 17,
- y2: 29,
- style: {
- transform: transform,
- webkitTransform: transform,
- animationDelay: animationDelay,
- webkitAnimationDelay: animationDelay
- }
- };
- }
- },
- 'ios-small': {
- dur: 1000,
- lines: 12,
- fn: function (dur, index, total) {
- var transform = 'rotate(' + (30 * index + (index < 6 ? 180 : -180)) + 'deg)';
- var animationDelay = -(dur - ((dur / total) * index)) + 'ms';
- return {
- y1: 12,
- y2: 20,
- style: {
- transform: transform,
- webkitTransform: transform,
- animationDelay: animationDelay,
- webkitAnimationDelay: animationDelay
- }
- };
- }
- },
- bubbles: {
- dur: 1000,
- circles: 9,
- fn: function (dur, index, total) {
- var animationDelay = -(dur - ((dur / total) * index)) + 'ms';
- return {
- r: 5,
- style: {
- top: (9 * Math.sin(2 * Math.PI * index / total)) + 'px',
- left: (9 * Math.cos(2 * Math.PI * index / total)) + 'px',
- animationDelay: animationDelay,
- webkitAnimationDelay: animationDelay
- }
- };
- }
- },
- circles: {
- dur: 1000,
- circles: 8,
- fn: function (dur, index, total) {
- var animationDelay = -(dur - ((dur / total) * index)) + 'ms';
- return {
- r: 5,
- style: {
- top: (9 * Math.sin(2 * Math.PI * index / total)) + 'px',
- left: (9 * Math.cos(2 * Math.PI * index / total)) + 'px',
- animationDelay: animationDelay,
- webkitAnimationDelay: animationDelay
- }
- };
- }
- },
- crescent: {
- dur: 750,
- circles: 1,
- fn: function () {
- return {
- r: 26,
- style: {}
- };
- }
- },
- dots: {
- dur: 750,
- circles: 3,
- fn: function (_dur, index) {
- var animationDelay = -(110 * index) + 'ms';
- return {
- r: 6,
- style: {
- left: (9 - (9 * index)) + 'px',
- animationDelay: animationDelay,
- webkitAnimationDelay: animationDelay
- }
- };
- }
- }
- };
-
- /**
- * @hidden
- */
- var TabHighlight = (function () {
- function TabHighlight(_elementRef, _dom) {
- this._elementRef = _elementRef;
- this._dom = _dom;
- }
- TabHighlight.prototype.select = function (tab) {
- var _this = this;
- if (!tab) {
- return;
- }
- var dom = this._dom;
- dom.read(function () {
- var btnEle = tab.btn.getNativeElement();
- var transform = "translate3d(" + btnEle.offsetLeft + "px,0,0) scaleX(" + btnEle.offsetWidth + ")";
- dom.write(function () {
- var ele = _this._elementRef.nativeElement;
- ele.style[dom.plt.Css.transform] = transform;
- if (!_this._init) {
- _this._init = true;
- dom.write(function () {
- ele.classList.add('animate');
- }, 80);
- }
- });
- }, 32);
- };
- TabHighlight.decorators = [
- { type: Directive, args: [{
- selector: '.tab-highlight'
- },] },
- ];
- /** @nocollapse */
- TabHighlight.ctorParameters = function () { return [
- { type: ElementRef, },
- { type: DomController, },
- ]; };
- return TabHighlight;
- }());
-
- var __extends$79 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @name Tabs
- * @description
- * Tabs make it easy to navigate between different pages or functional
- * aspects of an app. The Tabs component, written as `<ion-tabs>`, is
- * a container of individual [Tab](../Tab/) components. Each individual `ion-tab`
- * is a declarative component for a [NavController](../../../navigation/NavController/)
- *
- * For more information on using nav controllers like Tab or [Nav](../../nav/Nav/),
- * take a look at the [NavController API Docs](../../../navigation/NavController/).
- *
- * ### Placement
- *
- * The position of the tabs relative to the content varies based on
- * the mode. The tabs are placed at the bottom of the screen
- * for iOS and Android, and at the top for Windows by default. The position can
- * be configured using the `tabsPlacement` attribute on the `<ion-tabs>` component,
- * or in an app's [config](../../config/Config/).
- * See the [Input Properties](#input-properties) below for the available
- * values of `tabsPlacement`.
- *
- * ### Layout
- *
- * The layout for all of the tabs can be defined using the `tabsLayout`
- * property. If the individual tab has a title and icon, the icons will
- * show on top of the title by default. All tabs can be changed by setting
- * the value of `tabsLayout` on the `<ion-tabs>` element, or in your
- * app's [config](../../config/Config/). For example, this is useful if
- * you want to show tabs with a title only on Android, but show icons
- * and a title for iOS. See the [Input Properties](#input-properties)
- * below for the available values of `tabsLayout`.
- *
- * ### Selecting a Tab
- *
- * There are different ways you can select a specific tab from the tabs
- * component. You can use the `selectedIndex` property to set the index
- * on the `<ion-tabs>` element, or you can call `select()` from the `Tabs`
- * instance after creation. See [usage](#usage) below for more information.
- *
- * @usage
- *
- * You can add a basic tabs template to a `@Component` using the following
- * template:
- *
- * ```html
- * <ion-tabs>
- * <ion-tab [root]="tab1Root"></ion-tab>
- * <ion-tab [root]="tab2Root"></ion-tab>
- * <ion-tab [root]="tab3Root"></ion-tab>
- * </ion-tabs>
- * ```
- *
- * Where `tab1Root`, `tab2Root`, and `tab3Root` are each a page:
- *
- *```ts
- * @Component({
- * templateUrl: 'build/pages/tabs/tabs.html'
- * })
- * export class TabsPage {
- * // this tells the tabs component which Pages
- * // should be each tab's root Page
- * tab1Root = Page1;
- * tab2Root = Page2;
- * tab3Root = Page3;
- *
- * constructor() {
- *
- * }
- * }
- *```
- *
- * By default, the first tab will be selected upon navigation to the
- * Tabs page. We can change the selected tab by using `selectedIndex`
- * on the `<ion-tabs>` element:
- *
- * ```html
- * <ion-tabs selectedIndex="2">
- * <ion-tab [root]="tab1Root"></ion-tab>
- * <ion-tab [root]="tab2Root"></ion-tab>
- * <ion-tab [root]="tab3Root"></ion-tab>
- * </ion-tabs>
- * ```
- *
- * Since the index starts at `0`, this will select the 3rd tab which has
- * root set to `tab3Root`. If you wanted to change it dynamically from
- * your class, you could use [property binding](https://angular.io/docs/ts/latest/guide/template-syntax.html#!#property-binding).
- *
- * Alternatively, you can grab the `Tabs` instance and call the `select()`
- * method. This requires the `<ion-tabs>` element to have an `id`. For
- * example, set the value of `id` to `myTabs`:
- *
- * ```html
- * <ion-tabs #myTabs>
- * <ion-tab [root]="tab1Root"></ion-tab>
- * <ion-tab [root]="tab2Root"></ion-tab>
- * <ion-tab [root]="tab3Root"></ion-tab>
- * </ion-tabs>
- * ```
- *
- * Then in your class you can grab the `Tabs` instance and call `select()`,
- * passing the index of the tab as the argument. Here we're grabbing the tabs
- * by using ViewChild.
- *
- *```ts
- * export class TabsPage {
- *
- * @ViewChild('myTabs') tabRef: Tabs;
- *
- * ionViewDidEnter() {
- * this.tabRef.select(2);
- * }
- *
- * }
- *```
- *
- * You can also switch tabs from a child component by calling `select()` on the
- * parent view using the `NavController` instance. For example, assuming you have
- * a `TabsPage` component, you could call the following from any of the child
- * components to switch to `TabsRoot3`:
- *
- *```ts
- * switchTabs() {
- * this.navCtrl.parent.select(2);
- * }
- *```
- * @demo /docs/demos/src/tabs/
- *
- * @see {@link /docs/components#tabs Tabs Component Docs}
- * @see {@link ../Tab Tab API Docs}
- * @see {@link ../../config/Config Config API Docs}
- *
- */
- var Tabs = (function (_super) {
- __extends$79(Tabs, _super);
- function Tabs(parent, viewCtrl, _app, config, elementRef, _plt, renderer, _linker, keyboard) {
- var _this = _super.call(this, config, elementRef, renderer, 'tabs') || this;
- _this.viewCtrl = viewCtrl;
- _this._app = _app;
- _this._plt = _plt;
- _this._linker = _linker;
- /** @internal */
- _this._ids = -1;
- /** @internal */
- _this._tabs = [];
- /** @internal */
- _this._selectHistory = [];
- /** @internal */
- _this._onDestroy = new Subject_2();
- /**
- * @output {any} Emitted when the tab changes.
- */
- _this.ionChange = new EventEmitter();
- _this.parent = parent;
- _this.id = 't' + (++tabIds);
- _this._sbPadding = config.getBoolean('statusbarPadding');
- _this.tabsHighlight = config.getBoolean('tabsHighlight');
- if (_this.parent) {
- // this Tabs has a parent Nav
- _this.parent.registerChildNav(_this);
- }
- else if (viewCtrl && viewCtrl.getNav()) {
- // this Nav was opened from a modal
- _this.parent = viewCtrl.getNav();
- _this.parent.registerChildNav(_this);
- }
- else if (_this._app) {
- // this is the root navcontroller for the entire app
- _this._app.registerRootNav(_this);
- }
- // Tabs may also be an actual ViewController which was navigated to
- // if Tabs is static and not navigated to within a NavController
- // then skip this and don't treat it as it's own ViewController
- if (viewCtrl) {
- viewCtrl._setContent(_this);
- viewCtrl._setContentRef(elementRef);
- }
- var keyboardResizes = config.getBoolean('keyboardResizes', false);
- if (keyboard && keyboardResizes) {
- keyboard.willHide
- .takeUntil(_this._onDestroy)
- .subscribe(function () {
- _this._plt.timeout(function () { return _this.setTabbarHidden(false); }, 50);
- });
- keyboard.willShow
- .takeUntil(_this._onDestroy)
- .subscribe(function () { return _this.setTabbarHidden(true); });
- }
- return _this;
- }
- /**
- * @internal
- */
- Tabs.prototype.setTabbarHidden = function (tabbarHidden) {
- this.setElementClass('tabbar-hidden', tabbarHidden);
- this.resize();
- };
- /**
- * @internal
- */
- Tabs.prototype.ngOnDestroy = function () {
- this._onDestroy.next();
- if (this.parent) {
- this.parent.unregisterChildNav(this);
- }
- else {
- this._app.unregisterRootNav(this);
- }
- };
- /**
- * @internal
- */
- Tabs.prototype.ngAfterViewInit = function () {
- var _this = this;
- this._setConfig('tabsPlacement', 'bottom');
- this._setConfig('tabsLayout', 'icon-top');
- this._setConfig('tabsHighlight', this.tabsHighlight);
- if (this.tabsHighlight) {
- this._plt.resize
- .takeUntil(this._onDestroy)
- .subscribe(function () { return _this._highlight.select(_this.getSelected()); });
- }
- this.initTabs();
- };
- /**
- * @internal
- */
- Tabs.prototype.initTabs = function () {
- var _this = this;
- // get the selected index from the input
- // otherwise default it to use the first index
- var selectedIndex = (isBlank$1(this.selectedIndex) ? 0 : parseInt(this.selectedIndex, 10));
- // now see if the deep linker can find a tab index
- var tabsSegment = this._linker.getSegmentByNavIdOrName(this.id, this.name);
- if (tabsSegment) {
- // we found a segment which probably represents which tab to select
- selectedIndex = this._getSelectedTabIndex(tabsSegment.secondaryId, selectedIndex);
- }
- // get the selectedIndex and ensure it isn't hidden or disabled
- var selectedTab = this._tabs.find(function (t, i) { return i === selectedIndex && t.enabled && t.show; });
- if (!selectedTab) {
- // wasn't able to select the tab they wanted
- // try to find the first tab that's available
- selectedTab = this._tabs.find(function (t) { return t.enabled && t.show; });
- }
- var promise = Promise.resolve();
- if (selectedTab) {
- selectedTab._segment = tabsSegment;
- promise = this.select(selectedTab);
- }
- return promise.then(function () {
- // set the initial href attribute values for each tab
- _this._tabs.forEach(function (t) {
- t.updateHref(t.root, t.rootParams);
- });
- });
- };
- /**
- * @internal
- */
- Tabs.prototype._setConfig = function (attrKey, fallback) {
- var val = this[attrKey];
- if (isBlank$1(val)) {
- val = this._config.get(attrKey, fallback);
- }
- this.setElementAttribute(attrKey, val);
- };
- /**
- * @hidden
- */
- Tabs.prototype.add = function (tab) {
- this._tabs.push(tab);
- return this.id + '-' + (++this._ids);
- };
- /**
- * @param {number|Tab} tabOrIndex Index, or the Tab instance, of the tab to select.
- */
- Tabs.prototype.select = function (tabOrIndex, opts, fromUrl) {
- var _this = this;
- if (opts === void 0) { opts = {}; }
- if (fromUrl === void 0) { fromUrl = false; }
- var selectedTab = (typeof tabOrIndex === 'number' ? this.getByIndex(tabOrIndex) : tabOrIndex);
- if (isBlank$1(selectedTab)) {
- return Promise.resolve();
- }
- // If the selected tab is the current selected tab, we do not switch
- var currentTab = this.getSelected();
- if (selectedTab === currentTab && currentTab.getActive()) {
- return this._updateCurrentTab(selectedTab, fromUrl);
- }
- // If the selected tab does not have a root, we do not switch (#9392)
- // it's possible the tab is only for opening modal's or signing out
- // and doesn't actually have content. In the case there's no content
- // for a tab then do nothing and leave the current view as is
- if (selectedTab.root) {
- // At this point we are going to perform a page switch
- // Let's fire willLeave in the current tab page
- var currentPage;
- if (currentTab) {
- currentPage = currentTab.getActive();
- currentPage && currentPage._willLeave(false);
- }
- // Fire willEnter in the new selected tab
- var selectedPage_1 = selectedTab.getActive();
- selectedPage_1 && selectedPage_1._willEnter();
- // Let's start the transition
- opts.animate = false;
- return selectedTab.load(opts).then(function () {
- _this._tabSwitchEnd(selectedTab, selectedPage_1, currentPage);
- if (opts.updateUrl !== false) {
- _this._linker.navChange(DIRECTION_SWITCH);
- }
- (void 0) /* assert */;
- _this._fireChangeEvent(selectedTab);
- });
- }
- else {
- this._fireChangeEvent(selectedTab);
- return Promise.resolve();
- }
- };
- Tabs.prototype._fireChangeEvent = function (selectedTab) {
- selectedTab.ionSelect.emit(selectedTab);
- this.ionChange.emit(selectedTab);
- };
- Tabs.prototype._tabSwitchEnd = function (selectedTab, selectedPage, currentPage) {
- (void 0) /* assert */;
- (void 0) /* assert */;
- // Update tabs selection state
- var tabs = this._tabs;
- var tab;
- for (var i = 0; i < tabs.length; i++) {
- tab = tabs[i];
- tab.setSelected(tab === selectedTab);
- }
- if (this.tabsHighlight) {
- this._highlight.select(selectedTab);
- }
- // Fire didEnter/didLeave lifecycle events
- if (selectedPage) {
- selectedPage._didEnter();
- this._app.viewDidEnter.emit(selectedPage);
- }
- if (currentPage) {
- currentPage && currentPage._didLeave();
- this._app.viewDidLeave.emit(currentPage);
- }
- // track the order of which tabs have been selected, by their index
- // do not track if the tab index is the same as the previous
- if (this._selectHistory[this._selectHistory.length - 1] !== selectedTab.id) {
- this._selectHistory.push(selectedTab.id);
- }
- };
- /**
- * Get the previously selected Tab which is currently not disabled or hidden.
- * @param {boolean} trimHistory If the selection history should be trimmed up to the previous tab selection or not.
- * @returns {Tab}
- */
- Tabs.prototype.previousTab = function (trimHistory) {
- var _this = this;
- if (trimHistory === void 0) { trimHistory = true; }
- // walk backwards through the tab selection history
- // and find the first previous tab that is enabled and shown
- (void 0) /* console.debug */;
- for (var i = this._selectHistory.length - 2; i >= 0; i--) {
- var tab = this._tabs.find(function (t) { return t.id === _this._selectHistory[i]; });
- if (tab && tab.enabled && tab.show) {
- if (trimHistory) {
- this._selectHistory.splice(i + 1);
- }
- return tab;
- }
- }
- return null;
- };
- /**
- * @param {number} index Index of the tab you want to get
- * @returns {Tab} Returns the tab who's index matches the one passed
- */
- Tabs.prototype.getByIndex = function (index) {
- return this._tabs[index];
- };
- /**
- * @return {Tab} Returns the currently selected tab
- */
- Tabs.prototype.getSelected = function () {
- var tabs = this._tabs;
- for (var i = 0; i < tabs.length; i++) {
- if (tabs[i].isSelected) {
- return tabs[i];
- }
- }
- return null;
- };
- /**
- * @internal
- */
- Tabs.prototype.getActiveChildNavs = function () {
- var selected = this.getSelected();
- return selected ? [selected] : [];
- };
- /**
- * @internal
- */
- Tabs.prototype.getAllChildNavs = function () {
- return this._tabs;
- };
- /**
- * @internal
- */
- Tabs.prototype.getIndex = function (tab) {
- return this._tabs.indexOf(tab);
- };
- /**
- * @internal
- */
- Tabs.prototype.length = function () {
- return this._tabs.length;
- };
- /**
- * "Touch" the active tab, going back to the root view of the tab
- * or optionally letting the tab handle the event
- */
- Tabs.prototype._updateCurrentTab = function (tab, fromUrl) {
- var active = tab.getActive();
- if (active) {
- if (fromUrl && tab._segment) {
- // see if the view controller exists
- var vc = tab.getViewById(tab._segment.name);
- if (vc) {
- // the view is already in the stack
- return tab.popTo(vc, {
- animate: false,
- updateUrl: false,
- });
- }
- else if (tab._views.length === 0 && tab._segment.defaultHistory && tab._segment.defaultHistory.length) {
- return this._linker.initViews(tab._segment).then(function (views) {
- return tab.setPages(views, {
- animate: false, updateUrl: false
- });
- }).then(function () {
- tab._segment = null;
- });
- }
- else {
- return tab.setRoot(tab._segment.name, tab._segment.data, {
- animate: false, updateUrl: false
- }).then(function () {
- tab._segment = null;
- });
- }
- }
- else if (active._cmp && active._cmp.instance.ionSelected) {
- // if they have a custom tab selected handler, call it
- active._cmp.instance.ionSelected();
- return Promise.resolve();
- }
- else if (tab.length() > 1) {
- // if we're a few pages deep, pop to root
- return tab.popToRoot();
- }
- else {
- return getComponent(this._linker, tab.root).then(function (viewController) {
- if (viewController.component !== active.component) {
- // Otherwise, if the page we're on is not our real root
- // reset it to our default root type
- return tab.setRoot(tab.root);
- }
- }).catch(function () {
- (void 0) /* console.debug */;
- });
- }
- }
- };
- /**
- * @internal
- * DOM WRITE
- */
- Tabs.prototype.setTabbarPosition = function (top, bottom) {
- if (this._top !== top || this._bottom !== bottom) {
- var tabbarEle = this._tabbar.nativeElement;
- tabbarEle.style.top = (top > -1 ? top + 'px' : '');
- tabbarEle.style.bottom = (bottom > -1 ? bottom + 'px' : '');
- tabbarEle.classList.add('show-tabbar');
- this._top = top;
- this._bottom = bottom;
- }
- };
- /**
- * @internal
- */
- Tabs.prototype.resize = function () {
- var tab = this.getSelected();
- tab && tab.resize();
- };
- /**
- * @internal
- */
- Tabs.prototype.initPane = function () {
- var isMain = this._elementRef.nativeElement.hasAttribute('main');
- return isMain;
- };
- /**
- * @internal
- */
- Tabs.prototype.paneChanged = function (isPane) {
- if (isPane) {
- this.resize();
- }
- };
- Tabs.prototype.goToRoot = function (opts) {
- if (this._tabs.length) {
- return this.select(this._tabs[0], opts);
- }
- };
- /*
- * @private
- */
- Tabs.prototype.getType = function () {
- return 'tabs';
- };
- /*
- * @private
- */
- Tabs.prototype.getSecondaryIdentifier = function () {
- var tabs = this.getActiveChildNavs();
- if (tabs && tabs.length) {
- return this._linker._getTabSelector(tabs[0]);
- }
- return '';
- };
- /**
- * @private
- */
- Tabs.prototype._getSelectedTabIndex = function (secondaryId, fallbackIndex) {
- if (secondaryId === void 0) { secondaryId = ''; }
- if (fallbackIndex === void 0) { fallbackIndex = 0; }
- // we found a segment which probably represents which tab to select
- var indexMatch = secondaryId.match(/tab-(\d+)/);
- if (indexMatch) {
- // awesome, the segment name was something "tab-0", and
- // the numbe represents which tab to select
- return parseInt(indexMatch[1], 10);
- }
- // wasn't in the "tab-0" format so maybe it's using a word
- var tab = this._tabs.find(function (t) {
- return (isPresent(t.tabUrlPath) && t.tabUrlPath === secondaryId) ||
- (isPresent(t.tabTitle) && formatUrlPart(t.tabTitle) === secondaryId);
- });
- return isPresent(tab) ? tab.index : fallbackIndex;
- };
- Tabs.decorators = [
- { type: Component, args: [{
- selector: 'ion-tabs',
- template: '<div class="tabbar" role="tablist" #tabbar>' +
- '<a *ngFor="let t of _tabs" [tab]="t" class="tab-button" role="tab" href="#" (ionSelect)="select(t)"></a>' +
- '<div class="tab-highlight"></div>' +
- '</div>' +
- '<ng-content></ng-content>' +
- '<div #portal tab-portal></div>',
- encapsulation: ViewEncapsulation.None,
- providers: [{ provide: RootNode, useExisting: forwardRef(function () { return Tabs; }) }]
- },] },
- ];
- /** @nocollapse */
- Tabs.ctorParameters = function () { return [
- { type: NavController, decorators: [{ type: Optional },] },
- { type: ViewController, decorators: [{ type: Optional },] },
- { type: App, },
- { type: Config, },
- { type: ElementRef, },
- { type: Platform, },
- { type: Renderer, },
- { type: DeepLinker, },
- { type: Keyboard, },
- ]; };
- Tabs.propDecorators = {
- 'name': [{ type: Input },],
- 'selectedIndex': [{ type: Input },],
- 'tabsLayout': [{ type: Input },],
- 'tabsPlacement': [{ type: Input },],
- 'tabsHighlight': [{ type: Input },],
- 'ionChange': [{ type: Output },],
- '_highlight': [{ type: ViewChild, args: [TabHighlight,] },],
- '_tabbar': [{ type: ViewChild, args: ['tabbar',] },],
- 'portal': [{ type: ViewChild, args: ['portal', { read: ViewContainerRef },] },],
- };
- return Tabs;
- }(Ion));
- var tabIds = -1;
-
- var __extends$78 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @name Tab
- * @description
- * The Tab component, written `<ion-tab>`, is styled based on the mode and should
- * be used in conjunction with the [Tabs](../Tabs/) component.
- *
- * Each `ion-tab` is a declarative component for a [NavController](../../../navigation/NavController/).
- * Basically, each tab is a `NavController`. For more information on using
- * navigation controllers take a look at the [NavController API Docs](../../../navigation/NavController/).
- *
- * See the [Tabs API Docs](../Tabs/) for more details on configuring Tabs.
- *
- * @usage
- *
- * To add a basic tab, you can use the following markup where the `root` property
- * is the page you want to load for that tab, `tabTitle` is the optional text to
- * display on the tab, and `tabIcon` is the optional [icon](../../icon/Icon/).
- *
- * ```html
- * <ion-tabs>
- * <ion-tab [root]="chatRoot" tabTitle="Chat" tabIcon="chat"></ion-tab>
- * </ion-tabs>
- * ```
- *
- * Then, in your class you can set `chatRoot` to an imported class:
- *
- * ```ts
- * import { ChatPage } from '../chat/chat';
- *
- * export class Tabs {
- * // here we'll set the property of chatRoot to
- * // the imported class of ChatPage
- * chatRoot = ChatPage;
- *
- * constructor() {
- *
- * }
- * }
- * ```
- *
- * You can also pass some parameters to the root page of the tab through
- * `rootParams`. Below we pass `chatParams` to the Chat tab:
- *
- * ```html
- * <ion-tabs>
- * <ion-tab [root]="chatRoot" [rootParams]="chatParams" tabTitle="Chat" tabIcon="chat"></ion-tab>
- * </ion-tabs>
- * ```
- *
- * ```ts
- * export class Tabs {
- * chatRoot = ChatPage;
- *
- * // set some user information on chatParams
- * chatParams = {
- * user1: 'admin',
- * user2: 'ionic'
- * };
- *
- * constructor() {
- *
- * }
- * }
- * ```
- *
- * And in `ChatPage` you can get the data from `NavParams`:
- *
- * ```ts
- * export class ChatPage {
- * constructor(navParams: NavParams) {
- * console.log('Passed params', navParams.data);
- * }
- * }
- * ```
- *
- * Sometimes you may want to call a method instead of navigating to a new
- * page. You can use the `(ionSelect)` event to call a method on your class when
- * the tab is selected. Below is an example of presenting a modal from one of
- * the tabs.
- *
- * ```html
- * <ion-tabs>
- * <ion-tab (ionSelect)="chat()" tabTitle="Show Modal"></ion-tab>
- * </ion-tabs>pop
- * ```
- *
- * ```ts
- * export class Tabs {
- * constructor(public modalCtrl: ModalController) {
- *
- * }
- *
- * chat() {
- * let modal = this.modalCtrl.create(ChatPage);
- * modal.present();
- * }
- * }
- * ```
- *
- *
- * @demo /docs/demos/src/tabs/
- * @see {@link /docs/components#tabs Tabs Component Docs}
- * @see {@link ../../tabs/Tabs Tabs API Docs}
- * @see {@link ../../nav/Nav Nav API Docs}
- * @see {@link ../../nav/NavController NavController API Docs}
- */
- var Tab = (function (_super) {
- __extends$78(Tab, _super);
- function Tab(parent, app, config, plt, elementRef, zone, renderer, cfr, _cd, gestureCtrl, transCtrl, linker, _dom, errHandler) {
- var _this =
- // A Tab is a NavController for its child pages
- _super.call(this, parent, app, config, plt, elementRef, zone, renderer, cfr, gestureCtrl, transCtrl, linker, _dom, errHandler) || this;
- _this._cd = _cd;
- _this.linker = linker;
- _this._dom = _dom;
- /**
- * @hidden
- */
- _this._isEnabled = true;
- /**
- * @hidden
- */
- _this._isShown = true;
- /**
- * @output {Tab} Emitted when the current tab is selected.
- */
- _this.ionSelect = new EventEmitter();
- _this.id = parent.add(_this);
- _this._tabsHideOnSubPages = config.getBoolean('tabsHideOnSubPages');
- _this._tabId = 'tabpanel-' + _this.id;
- _this._btnId = 'tab-' + _this.id;
- return _this;
- }
- Object.defineProperty(Tab.prototype, "enabled", {
- /**
- * @input {boolean} If true, enable the tab. If false,
- * the user cannot interact with this element.
- * Default: `true`.
- */
- get: function () {
- return this._isEnabled;
- },
- set: function (val) {
- this._isEnabled = isTrueProperty(val);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Tab.prototype, "show", {
- /**
- * @input {boolean} If true, the tab button is visible within the
- * tabbar. Default: `true`.
- */
- get: function () {
- return this._isShown;
- },
- set: function (val) {
- this._isShown = isTrueProperty(val);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Tab.prototype, "tabsHideOnSubPages", {
- /**
- * @input {boolean} If true, hide the tabs on child pages.
- */
- get: function () {
- return this._tabsHideOnSubPages;
- },
- set: function (val) {
- this._tabsHideOnSubPages = isTrueProperty(val);
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(Tab.prototype, "_vp", {
- /**
- * @hidden
- */
- set: function (val) {
- this.setViewport(val);
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @hidden
- */
- Tab.prototype.ngOnInit = function () {
- this.tabBadgeStyle = this.tabBadgeStyle ? this.tabBadgeStyle : 'default';
- };
- /**
- * @hidden
- */
- Tab.prototype.load = function (opts) {
- var _this = this;
- var segment = this._segment;
- if (segment || (!this._loaded && this.root)) {
- this.setElementClass('show-tab', true);
- // okay, first thing we need to do if check if the view already exists
- var nameToUse = segment && segment.name ? segment.name : this.root;
- var dataToUse = segment ? segment.data : this.rootParams;
- var numViews = this.length() - 1;
- for (var i = numViews; i >= 0; i--) {
- var viewController = this.getByIndex(i);
- if (viewController && (viewController.id === nameToUse || viewController.component === nameToUse)) {
- if (i === numViews) {
- // this is the last view in the stack and it's the same
- // as the segment so there's no change needed
- return Promise.resolve();
- }
- else {
- // it's not the exact view as the end
- // let's have this nav go back to this exact view
- return this.popTo(viewController, {
- animate: false,
- updateUrl: false,
- });
- }
- }
- }
- var promise = null;
- if (segment && segment.defaultHistory && segment.defaultHistory.length && this._views.length === 0) {
- promise = this.linker.initViews(segment).then(function (views) {
- return _this.setPages(views, opts);
- });
- }
- else {
- promise = this.push(nameToUse, dataToUse, opts);
- }
- return promise.then(function () {
- _this._segment = null;
- _this._loaded = true;
- });
- }
- else {
- // if this is not the Tab's initial load then we need
- // to refresh the tabbar and content dimensions to be sure
- // they're lined up correctly
- this._dom.read(function () {
- _this.resize();
- });
- return Promise.resolve();
- }
- };
- /**
- * @hidden
- */
- Tab.prototype.resize = function () {
- var active = this.getActive();
- if (!active) {
- return;
- }
- var content = active.getIONContent();
- content && content.resize();
- };
- /**
- * @hidden
- */
- Tab.prototype._viewAttachToDOM = function (viewCtrl, componentRef, viewport) {
- var isTabSubPage = (this._tabsHideOnSubPages && viewCtrl.index > 0);
- if (isTabSubPage) {
- viewport = this.parent.portal;
- }
- _super.prototype._viewAttachToDOM.call(this, viewCtrl, componentRef, viewport);
- if (isTabSubPage) {
- // add the .tab-subpage css class to tabs pages that should act like subpages
- var pageEleRef = viewCtrl.pageRef();
- if (pageEleRef) {
- this._renderer.setElementClass(pageEleRef.nativeElement, 'tab-subpage', true);
- }
- }
- };
- /**
- * @hidden
- */
- Tab.prototype.setSelected = function (isSelected) {
- this.isSelected = isSelected;
- this.setElementClass('show-tab', isSelected);
- this.setElementAttribute('aria-hidden', (!isSelected).toString());
- if (isSelected) {
- // this is the selected tab, detect changes
- this._cd.reattach();
- }
- else {
- // this tab is not selected, do not detect changes
- this._cd.detach();
- }
- };
- Object.defineProperty(Tab.prototype, "index", {
- /**
- * @hidden
- */
- get: function () {
- return this.parent.getIndex(this);
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @hidden
- */
- Tab.prototype.updateHref = function (component, data) {
- if (this.btn && this.linker) {
- var href = this.linker.createUrl(this.parent, component, data) || '#';
- this.btn.updateHref(href);
- }
- };
- /**
- * @hidden
- */
- Tab.prototype.ngOnDestroy = function () {
- this.destroy();
- };
- /**
- * @hidden
- */
- Tab.prototype.getType = function () {
- return 'tab';
- };
- Tab.prototype.goToRoot = function (opts) {
- return this.setRoot(this.root, this.rootParams, opts, null);
- };
- Tab.decorators = [
- { type: Component, args: [{
- selector: 'ion-tab',
- template: '<div #viewport></div><div class="nav-decor"></div>',
- host: {
- '[attr.id]': '_tabId',
- '[attr.aria-labelledby]': '_btnId',
- 'role': 'tabpanel'
- },
- encapsulation: ViewEncapsulation.None,
- },] },
- ];
- /** @nocollapse */
- Tab.ctorParameters = function () { return [
- { type: Tabs, },
- { type: App, },
- { type: Config, },
- { type: Platform, },
- { type: ElementRef, },
- { type: NgZone, },
- { type: Renderer, },
- { type: ComponentFactoryResolver, },
- { type: ChangeDetectorRef, },
- { type: GestureController, },
- { type: TransitionController, },
- { type: DeepLinker, decorators: [{ type: Optional },] },
- { type: DomController, },
- { type: ErrorHandler, },
- ]; };
- Tab.propDecorators = {
- 'root': [{ type: Input },],
- 'rootParams': [{ type: Input },],
- 'tabUrlPath': [{ type: Input },],
- 'tabTitle': [{ type: Input },],
- 'tabIcon': [{ type: Input },],
- 'tabBadge': [{ type: Input },],
- 'tabBadgeStyle': [{ type: Input },],
- 'enabled': [{ type: Input },],
- 'show': [{ type: Input },],
- 'tabsHideOnSubPages': [{ type: Input },],
- 'ionSelect': [{ type: Output },],
- '_vp': [{ type: ViewChild, args: ['viewport', { read: ViewContainerRef },] },],
- };
- return Tab;
- }(NavControllerBase));
-
- var __extends$80 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @hidden
- */
- var TabButton = (function (_super) {
- __extends$80(TabButton, _super);
- function TabButton(config, elementRef, renderer) {
- var _this = _super.call(this, config, elementRef, renderer) || this;
- _this.ionSelect = new EventEmitter();
- _this.disHover = (config.get('hoverCSS') === false);
- _this.layout = config.get('tabsLayout');
- return _this;
- }
- TabButton.prototype.ngOnInit = function () {
- this.tab.btn = this;
- this.layout = this.tab.parent.tabsLayout || this.layout;
- this.hasTitle = !!this.tab.tabTitle;
- this.hasIcon = !!this.tab.tabIcon && this.layout !== 'icon-hide';
- this.hasTitleOnly = (this.hasTitle && !this.hasIcon);
- this.hasIconOnly = (this.hasIcon && !this.hasTitle);
- this.hasBadge = !!this.tab.tabBadge;
- };
- TabButton.prototype.onClick = function () {
- this.ionSelect.emit(this.tab);
- return false;
- };
- TabButton.prototype.updateHref = function (href) {
- this.setElementAttribute('href', href);
- };
- TabButton.decorators = [
- { type: Component, args: [{
- selector: '.tab-button',
- template: '<ion-icon *ngIf="tab.tabIcon" [name]="tab.tabIcon" [isActive]="tab.isSelected" class="tab-button-icon"></ion-icon>' +
- '<span *ngIf="tab.tabTitle" class="tab-button-text">{{tab.tabTitle}}</span>' +
- '<ion-badge *ngIf="tab.tabBadge" class="tab-badge" [color]="tab.tabBadgeStyle">{{tab.tabBadge}}</ion-badge>' +
- '<div class="button-effect"></div>',
- host: {
- '[attr.id]': 'tab._btnId',
- '[attr.aria-controls]': 'tab._tabId',
- '[attr.aria-selected]': 'tab.isSelected',
- '[class.has-title]': 'hasTitle',
- '[class.has-icon]': 'hasIcon',
- '[class.has-title-only]': 'hasTitleOnly',
- '[class.icon-only]': 'hasIconOnly',
- '[class.has-badge]': 'hasBadge',
- '[class.disable-hover]': 'disHover',
- '[class.tab-disabled]': '!tab.enabled',
- '[class.tab-hidden]': '!tab.show',
- }
- },] },
- ];
- /** @nocollapse */
- TabButton.ctorParameters = function () { return [
- { type: Config, },
- { type: ElementRef, },
- { type: Renderer, },
- ]; };
- TabButton.propDecorators = {
- 'tab': [{ type: Input },],
- 'ionSelect': [{ type: Output },],
- 'onClick': [{ type: HostListener, args: ['click',] },],
- };
- return TabButton;
- }(Ion));
-
- /**
- * @hidden
- */
- var ToastCmp = (function () {
- function ToastCmp(_viewCtrl, _config, _elementRef, params, renderer) {
- this._viewCtrl = _viewCtrl;
- this._config = _config;
- this._elementRef = _elementRef;
- this.dismissTimeout = undefined;
- renderer.setElementClass(_elementRef.nativeElement, "toast-" + _config.get('mode'), true);
- this.d = params.data;
- if (this.d.cssClass) {
- this.d.cssClass.split(' ').forEach(function (cssClass) {
- // Make sure the class isn't whitespace, otherwise it throws exceptions
- if (cssClass.trim() !== '')
- renderer.setElementClass(_elementRef.nativeElement, cssClass, true);
- });
- }
- this.id = (++toastIds);
- if (this.d.message) {
- this.hdrId = 'toast-hdr-' + this.id;
- }
- }
- ToastCmp.prototype.ngAfterViewInit = function () {
- var _this = this;
- // if there's a `duration` set, automatically dismiss.
- if (this.d.duration) {
- this.dismissTimeout = setTimeout(function () {
- _this.dismiss('backdrop');
- }, this.d.duration);
- }
- this.enabled = true;
- };
- ToastCmp.prototype.ionViewDidEnter = function () {
- var activeElement = document.activeElement;
- if (activeElement) {
- activeElement.blur();
- }
- var focusableEle = this._elementRef.nativeElement.querySelector('button');
- if (focusableEle) {
- focusableEle.focus();
- }
- };
- ToastCmp.prototype.cbClick = function () {
- if (this.enabled) {
- this.dismiss('close');
- }
- };
- ToastCmp.prototype.dismiss = function (role) {
- clearTimeout(this.dismissTimeout);
- this.dismissTimeout = undefined;
- return this._viewCtrl.dismiss(null, role, { disableApp: false });
- };
- ToastCmp.decorators = [
- { type: Component, args: [{
- selector: 'ion-toast',
- template: '<div class="toast-wrapper" ' +
- '[class.toast-bottom]="d.position === \'bottom\'" ' +
- '[class.toast-middle]="d.position === \'middle\'" ' +
- '[class.toast-top]="d.position === \'top\'"> ' +
- '<div class="toast-container"> ' +
- '<div class="toast-message" id="{{hdrId}}" *ngIf="d.message">{{d.message}}</div> ' +
- '<button ion-button clear class="toast-button" *ngIf="d.showCloseButton" (click)="cbClick()"> ' +
- '{{ d.closeButtonText || \'Close\' }} ' +
- '</button> ' +
- '</div> ' +
- '</div>',
- host: {
- 'role': 'dialog',
- '[attr.aria-labelledby]': 'hdrId',
- '[attr.aria-describedby]': 'descId',
- },
- },] },
- ];
- /** @nocollapse */
- ToastCmp.ctorParameters = function () { return [
- { type: ViewController, },
- { type: Config, },
- { type: ElementRef, },
- { type: NavParams, },
- { type: Renderer, },
- ]; };
- return ToastCmp;
- }());
- var toastIds = -1;
-
- var __extends$82 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- var ToastSlideIn = (function (_super) {
- __extends$82(ToastSlideIn, _super);
- function ToastSlideIn() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- ToastSlideIn.prototype.init = function () {
- // DOM READS
- var ele = this.enteringView.pageRef().nativeElement;
- var wrapperEle = ele.querySelector('.toast-wrapper');
- var wrapper = new Animation(this.plt, wrapperEle);
- if (this.enteringView.data && this.enteringView.data.position === TOAST_POSITION_TOP$1) {
- // top
- // by default, it is -100% hidden (above the screen)
- // so move from that to 10px below top: 0px;
- wrapper.fromTo('translateY', '-100%', 10 + "px");
- }
- else if (this.enteringView.data && this.enteringView.data.position === TOAST_POSITION_MIDDLE$1) {
- // Middle
- // just center it and fade it in
- var topPosition = Math.floor(ele.clientHeight / 2 - wrapperEle.clientHeight / 2);
- // DOM WRITE
- wrapperEle.style.top = topPosition + "px";
- wrapper.fromTo('opacity', 0.01, 1);
- }
- else {
- // bottom
- // by default, it is 100% hidden (below the screen),
- // so move from that to 10 px above bottom: 0px
- wrapper.fromTo('translateY', '100%', 0 - 10 + "px");
- }
- this.easing('cubic-bezier(.36,.66,.04,1)').duration(400).add(wrapper);
- };
- return ToastSlideIn;
- }(Transition));
- var ToastSlideOut = (function (_super) {
- __extends$82(ToastSlideOut, _super);
- function ToastSlideOut() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- ToastSlideOut.prototype.init = function () {
- var ele = this.leavingView.pageRef().nativeElement;
- var wrapperEle = ele.querySelector('.toast-wrapper');
- var wrapper = new Animation(this.plt, wrapperEle);
- if (this.leavingView.data && this.leavingView.data.position === TOAST_POSITION_TOP$1) {
- // top
- // reverse arguments from enter transition
- wrapper.fromTo('translateY', 10 + "px", '-100%');
- }
- else if (this.leavingView.data && this.leavingView.data.position === TOAST_POSITION_MIDDLE$1) {
- // Middle
- // just fade it out
- wrapper.fromTo('opacity', 0.99, 0);
- }
- else {
- // bottom
- // reverse arguments from enter transition
- wrapper.fromTo('translateY', 0 - 10 + "px", '100%');
- }
- this.easing('cubic-bezier(.36,.66,.04,1)').duration(300).add(wrapper);
- };
- return ToastSlideOut;
- }(Transition));
- var ToastMdSlideIn = (function (_super) {
- __extends$82(ToastMdSlideIn, _super);
- function ToastMdSlideIn() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- ToastMdSlideIn.prototype.init = function () {
- // DOM reads
- var ele = this.enteringView.pageRef().nativeElement;
- var wrapperEle = ele.querySelector('.toast-wrapper');
- var wrapper = new Animation(this.plt, wrapperEle);
- if (this.enteringView.data && this.enteringView.data.position === TOAST_POSITION_TOP$1) {
- // top
- // by default, it is -100% hidden (above the screen)
- // so move from that to top: 0px;
- wrapper.fromTo('translateY', '-100%', "0%");
- }
- else if (this.enteringView.data && this.enteringView.data.position === TOAST_POSITION_MIDDLE$1) {
- // Middle
- // just center it and fade it in
- var topPosition = Math.floor(ele.clientHeight / 2 - wrapperEle.clientHeight / 2);
- // DOM WRITE
- wrapperEle.style.top = topPosition + "px";
- wrapper.fromTo('opacity', 0.01, 1);
- }
- else {
- // bottom
- // by default, it is 100% hidden (below the screen),
- // so move from that to bottom: 0px
- wrapper.fromTo('translateY', '100%', "0%");
- }
- this.easing('cubic-bezier(.36,.66,.04,1)').duration(400).add(wrapper);
- };
- return ToastMdSlideIn;
- }(Transition));
- var ToastMdSlideOut = (function (_super) {
- __extends$82(ToastMdSlideOut, _super);
- function ToastMdSlideOut() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- ToastMdSlideOut.prototype.init = function () {
- var ele = this.leavingView.pageRef().nativeElement;
- var wrapperEle = ele.querySelector('.toast-wrapper');
- var wrapper = new Animation(this.plt, wrapperEle);
- if (this.leavingView.data && this.leavingView.data.position === TOAST_POSITION_TOP$1) {
- // top
- // reverse arguments from enter transition
- wrapper.fromTo('translateY', 0 + "%", '-100%');
- }
- else if (this.leavingView.data && this.leavingView.data.position === TOAST_POSITION_MIDDLE$1) {
- // Middle
- // just fade it out
- wrapper.fromTo('opacity', 0.99, 0);
- }
- else {
- // bottom
- // reverse arguments from enter transition
- wrapper.fromTo('translateY', 0 + "%", '100%');
- }
- this.easing('cubic-bezier(.36,.66,.04,1)').duration(450).add(wrapper);
- };
- return ToastMdSlideOut;
- }(Transition));
- var ToastWpPopIn = (function (_super) {
- __extends$82(ToastWpPopIn, _super);
- function ToastWpPopIn() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- ToastWpPopIn.prototype.init = function () {
- var ele = this.enteringView.pageRef().nativeElement;
- var wrapperEle = ele.querySelector('.toast-wrapper');
- var wrapper = new Animation(this.plt, wrapperEle);
- if (this.enteringView.data && this.enteringView.data.position === TOAST_POSITION_TOP$1) {
- // top
- wrapper.fromTo('opacity', 0.01, 1);
- wrapper.fromTo('scale', 1.3, 1);
- }
- else if (this.enteringView.data && this.enteringView.data.position === TOAST_POSITION_MIDDLE$1) {
- // Middle
- // just center it and fade it in
- var topPosition = Math.floor(ele.clientHeight / 2 - wrapperEle.clientHeight / 2);
- // DOM WRITE
- wrapperEle.style.top = topPosition + "px";
- wrapper.fromTo('opacity', 0.01, 1);
- wrapper.fromTo('scale', 1.3, 1);
- }
- else {
- // bottom
- wrapper.fromTo('opacity', 0.01, 1);
- wrapper.fromTo('scale', 1.3, 1);
- }
- this.easing('cubic-bezier(0,0,0.05,1)').duration(200).add(wrapper);
- };
- return ToastWpPopIn;
- }(Transition));
- var ToastWpPopOut = (function (_super) {
- __extends$82(ToastWpPopOut, _super);
- function ToastWpPopOut() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- ToastWpPopOut.prototype.init = function () {
- // DOM reads
- var ele = this.leavingView.pageRef().nativeElement;
- var wrapperEle = ele.querySelector('.toast-wrapper');
- var wrapper = new Animation(this.plt, wrapperEle);
- if (this.leavingView.data && this.leavingView.data.position === TOAST_POSITION_TOP$1) {
- // top
- // reverse arguments from enter transition
- wrapper.fromTo('opacity', 0.99, 0);
- wrapper.fromTo('scale', 1, 1.3);
- }
- else if (this.leavingView.data && this.leavingView.data.position === TOAST_POSITION_MIDDLE$1) {
- // Middle
- // just fade it out
- wrapper.fromTo('opacity', 0.99, 0);
- wrapper.fromTo('scale', 1, 1.3);
- }
- else {
- // bottom
- // reverse arguments from enter transition
- wrapper.fromTo('opacity', 0.99, 0);
- wrapper.fromTo('scale', 1, 1.3);
- }
- // DOM writes
- var EASE = 'ease-out';
- var DURATION = 150;
- this.easing(EASE).duration(DURATION).add(wrapper);
- };
- return ToastWpPopOut;
- }(Transition));
- var TOAST_POSITION_TOP$1 = 'top';
- var TOAST_POSITION_MIDDLE$1 = 'middle';
-
- var __extends$81 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @hidden
- */
- var Toast = (function (_super) {
- __extends$81(Toast, _super);
- function Toast(app, opts, config) {
- if (opts === void 0) { opts = {}; }
- var _this = this;
- opts.dismissOnPageChange = isPresent(opts.dismissOnPageChange) ? !!opts.dismissOnPageChange : false;
- _this = _super.call(this, ToastCmp, opts, null) || this;
- _this._app = app;
- // set the position to the bottom if not provided
- if (!opts.position || !_this.isValidPosition(opts.position)) {
- opts.position = TOAST_POSITION_BOTTOM;
- }
- _this.isOverlay = true;
- config.setTransition('toast-slide-in', ToastSlideIn);
- config.setTransition('toast-slide-out', ToastSlideOut);
- config.setTransition('toast-md-slide-in', ToastMdSlideIn);
- config.setTransition('toast-md-slide-out', ToastMdSlideOut);
- config.setTransition('toast-wp-slide-out', ToastWpPopOut);
- config.setTransition('toast-wp-slide-in', ToastWpPopIn);
- return _this;
- }
- /**
- * @hidden
- */
- Toast.prototype.getTransitionName = function (direction) {
- var key = 'toast' + (direction === 'back' ? 'Leave' : 'Enter');
- return this._nav && this._nav.config.get(key);
- };
- /**
- * @hidden
- */
- Toast.prototype.isValidPosition = function (position) {
- return position === TOAST_POSITION_TOP || position === TOAST_POSITION_MIDDLE || position === TOAST_POSITION_BOTTOM;
- };
- /**
- * @param {string} message Toast message content
- */
- Toast.prototype.setMessage = function (message) {
- this.data.message = message;
- return this;
- };
- /**
- * @param {number} dur Toast message duration
- */
- Toast.prototype.setDuration = function (dur) {
- this.data.duration = dur;
- return this;
- };
- /**
- * @param {'top'|'middle'|'bottom'} pos Toast message position
- */
- Toast.prototype.setPosition = function (pos) {
- this.data.position = pos;
- return this;
- };
- /**
- * @param {string} cssClass Toast message CSS class
- */
- Toast.prototype.setCssClass = function (cssClass) {
- this.data.cssClass = cssClass;
- return this;
- };
- /**
- * @param {boolean} closeButton Toast message close button
- */
- Toast.prototype.setShowCloseButton = function (closeButton) {
- this.data.showCloseButton = closeButton;
- return this;
- };
- /**
- * Present the toast instance.
- *
- * @param {NavOptions} [navOptions={}] Nav options to go with this transition.
- * @returns {Promise} Returns a promise which is resolved when the transition has completed.
- */
- Toast.prototype.present = function (navOptions) {
- if (navOptions === void 0) { navOptions = {}; }
- navOptions.disableApp = false;
- navOptions.keyboardClose = false;
- return this._app.present(this, navOptions, PORTAL_TOAST);
- };
- /**
- * Dismiss all toast components which have been presented.
- */
- Toast.prototype.dismissAll = function () {
- this._nav && this._nav.popAll();
- };
- return Toast;
- }(ViewController));
- var TOAST_POSITION_TOP = 'top';
- var TOAST_POSITION_MIDDLE = 'middle';
- var TOAST_POSITION_BOTTOM = 'bottom';
-
- /**
- * @name ToastController
- * @description
- * A Toast is a subtle notification commonly used in modern applications.
- * It can be used to provide feedback about an operation or to
- * display a system message. The toast appears on top of the app's content,
- * and can be dismissed by the app to resume user interaction with
- * the app.
- *
- * ### Creating
- * All of the toast options should be passed in the first argument of
- * the create method: `create(opts)`. The message to display should be
- * passed in the `message` property. The `showCloseButton` option can be set to
- * true in order to display a close button on the toast. See the [create](#create)
- * method below for all available options.
- *
- * ### Positioning
- * Toasts can be positioned at the top, bottom or middle of the
- * view port. The position can be passed to the `Toast.create(opts)` method.
- * The position option is a string, and the values accepted are `top`, `bottom` and `middle`.
- * If the position is not specified, the toast will be displayed at the bottom of the view port.
- *
- * ### Dismissing
- * The toast can be dismissed automatically after a specific amount of time
- * by passing the number of milliseconds to display it in the `duration` of
- * the toast options. If `showCloseButton` is set to true, then the close button
- * will dismiss the toast. To dismiss the toast after creation, call the `dismiss()`
- * method on the Toast instance. The `onDidDismiss` function can be called to perform an action after the toast
- * is dismissed.
- *
- * @usage
- * ```ts
- * import { ToastController } from 'ionic-angular';
- *
- * constructor(public toastCtrl: ToastController) { }
- *
- * presentToast() {
- * const toast = this.toastCtrl.create({
- * message: 'User was added successfully',
- * duration: 3000,
- * position: 'top'
- * });
- *
- * toast.onDidDismiss(() => {
- * console.log('Dismissed toast');
- * });
- *
- * toast.present();
- * }
- * ```
- * @advanced
- * | Property | Type | Default | Description |
- * |-----------------------|-----------|-----------------|---------------------------------------------------------------------------------------------------------------|
- * | message | `string` | - | The message for the toast. Long strings will wrap and the toast container will expand. |
- * | duration | `number` | - | How many milliseconds to wait before hiding the toast. By default, it will show until `dismiss()` is called. |
- * | position | `string` | "bottom" | The position of the toast on the screen. Accepted values: "top", "middle", "bottom". |
- * | cssClass | `string` | - | Additional classes for custom styles, separated by spaces. |
- * | showCloseButton | `boolean` | false | Whether or not to show a button to close the toast. |
- * | closeButtonText | `string` | "Close" | Text to display in the close button. |
- * | dismissOnPageChange | `boolean` | false | Whether to dismiss the toast when navigating to a new page. |
- *
- * @demo /docs/demos/src/toast/
- */
- var ToastController = (function () {
- function ToastController(_app, config) {
- this._app = _app;
- this.config = config;
- }
- /**
- * Create a new toast component. See options below
- * @param {ToastOptions} opts Toast options. See the below table for available options.
- */
- ToastController.prototype.create = function (opts) {
- if (opts === void 0) { opts = {}; }
- return new Toast(this._app, opts, this.config);
- };
- ToastController.decorators = [
- { type: Injectable },
- ];
- /** @nocollapse */
- ToastController.ctorParameters = function () { return [
- { type: App, },
- { type: Config, },
- ]; };
- return ToastController;
- }());
-
- var __extends$84 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @hidden
- */
- var ToggleGesture = (function (_super) {
- __extends$84(ToggleGesture, _super);
- function ToggleGesture(plt, toggle, gestureCtrl, domCtrl) {
- var _this = _super.call(this, plt, toggle.getNativeElement(), {
- threshold: 0,
- zone: false,
- domController: domCtrl,
- gesture: gestureCtrl.createGesture({
- name: GESTURE_TOGGLE,
- priority: GESTURE_PRIORITY_TOGGLE
- })
- }) || this;
- _this.toggle = toggle;
- return _this;
- }
- ToggleGesture.prototype.canStart = function () {
- return true;
- };
- ToggleGesture.prototype.onDragStart = function (ev) {
- ev.preventDefault();
- this.toggle._onDragStart(pointerCoord(ev).x);
- };
- ToggleGesture.prototype.onDragMove = function (ev) {
- ev.preventDefault();
- this.toggle._onDragMove(pointerCoord(ev).x);
- };
- ToggleGesture.prototype.onDragEnd = function (ev) {
- ev.preventDefault();
- this.toggle._onDragEnd(pointerCoord(ev).x);
- };
- return ToggleGesture;
- }(PanGesture));
-
- var __extends$83 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @name Toggle
- * @description
- * A toggle technically is the same thing as an HTML checkbox input,
- * except it looks different and is easier to use on a touch device.
- * Toggles can also have colors assigned to them, by adding any color
- * attribute.
- *
- * See the [Angular Docs](https://angular.io/docs/ts/latest/guide/forms.html)
- * for more info on forms and inputs.
- *
- * @usage
- * ```html
- *
- * <ion-list>
- *
- * <ion-item>
- * <ion-label>Pepperoni</ion-label>
- * <ion-toggle [(ngModel)]="pepperoni"></ion-toggle>
- * </ion-item>
- *
- * <ion-item>
- * <ion-label>Sausage</ion-label>
- * <ion-toggle [(ngModel)]="sausage" disabled="true"></ion-toggle>
- * </ion-item>
- *
- * <ion-item>
- * <ion-label>Mushrooms</ion-label>
- * <ion-toggle [(ngModel)]="mushrooms"></ion-toggle>
- * </ion-item>
- *
- * </ion-list>
- * ```
- *
- * @demo /docs/demos/src/toggle/
- * @see {@link /docs/components#toggle Toggle Component Docs}
- */
- var Toggle = (function (_super) {
- __extends$83(Toggle, _super);
- function Toggle(form, config, _plt, elementRef, renderer, _haptic, item, _gestureCtrl, _domCtrl, _zone) {
- var _this = _super.call(this, config, elementRef, renderer, 'toggle', false, form, item, null) || this;
- _this._plt = _plt;
- _this._haptic = _haptic;
- _this._gestureCtrl = _gestureCtrl;
- _this._domCtrl = _domCtrl;
- _this._zone = _zone;
- _this._activated = false;
- return _this;
- }
- Object.defineProperty(Toggle.prototype, "checked", {
- /**
- * @input {boolean} If true, the element is selected.
- */
- get: function () {
- return this.value;
- },
- set: function (val) {
- this.value = val;
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @hidden
- */
- Toggle.prototype.ngAfterContentInit = function () {
- this._initialize();
- this._gesture = new ToggleGesture(this._plt, this, this._gestureCtrl, this._domCtrl);
- this._gesture.listen();
- };
- /**
- * @hidden
- */
- Toggle.prototype._inputUpdated = function () { };
- /**
- * @hidden
- */
- Toggle.prototype._inputNormalize = function (val) {
- return isTrueProperty(val);
- };
- /**
- * @hidden
- */
- Toggle.prototype._onDragStart = function (startX) {
- var _this = this;
- (void 0) /* assert */;
- (void 0) /* console.debug */;
- this._zone.run(function () {
- _this._startX = startX;
- _this._fireFocus();
- _this._activated = true;
- });
- };
- /**
- * @hidden
- */
- Toggle.prototype._onDragMove = function (currentX) {
- var _this = this;
- if (!this._startX) {
- (void 0) /* assert */;
- return;
- }
- if (this._shouldToggle(currentX, -15)) {
- this._zone.run(function () {
- _this.value = !_this.value;
- _this._startX = currentX;
- _this._haptic.selection();
- });
- }
- };
- /**
- * @hidden
- */
- Toggle.prototype._onDragEnd = function (endX) {
- var _this = this;
- if (!this._startX) {
- (void 0) /* assert */;
- return;
- }
- (void 0) /* console.debug */;
- this._zone.run(function () {
- if (_this._shouldToggle(endX, 4)) {
- _this.value = !_this.value;
- _this._haptic.selection();
- }
- _this._activated = false;
- _this._fireBlur();
- _this._startX = null;
- });
- };
- /**
- * @hidden
- */
- Toggle.prototype._shouldToggle = function (currentX, margin) {
- var isLTR = !this._plt.isRTL;
- var startX = this._startX;
- if (this._value) {
- return (isLTR && (startX + margin > currentX)) ||
- (!isLTR && (startX - margin < currentX));
- }
- else {
- return (isLTR && (startX - margin < currentX)) ||
- (!isLTR && (startX + margin > currentX));
- }
- };
- /**
- * @hidden
- */
- Toggle.prototype._keyup = function (ev) {
- if (ev.keyCode === KEY_SPACE || ev.keyCode === KEY_ENTER) {
- (void 0) /* console.debug */;
- ev.preventDefault();
- ev.stopPropagation();
- this.value = !this.value;
- }
- };
- /**
- * @hidden
- */
- Toggle.prototype.ngOnDestroy = function () {
- _super.prototype.ngOnDestroy.call(this);
- this._gesture && this._gesture.destroy();
- };
- Toggle.decorators = [
- { type: Component, args: [{
- selector: 'ion-toggle',
- template: '<div class="toggle-icon">' +
- '<div class="toggle-inner"></div>' +
- '</div>' +
- '<button role="checkbox" ' +
- 'type="button" ' +
- 'ion-button="item-cover" ' +
- '[id]="id" ' +
- '[attr.aria-checked]="_value" ' +
- '[attr.aria-labelledby]="_labelId" ' +
- '[attr.aria-disabled]="_disabled" ' +
- 'class="item-cover" disable-activated>' +
- '</button>',
- host: {
- '[class.toggle-disabled]': '_disabled',
- '[class.toggle-checked]': '_value',
- '[class.toggle-activated]': '_activated',
- },
- providers: [{ provide: NG_VALUE_ACCESSOR, useExisting: Toggle, multi: true }],
- encapsulation: ViewEncapsulation.None,
- },] },
- ];
- /** @nocollapse */
- Toggle.ctorParameters = function () { return [
- { type: Form, },
- { type: Config, },
- { type: Platform, },
- { type: ElementRef, },
- { type: Renderer, },
- { type: Haptic, },
- { type: Item, decorators: [{ type: Optional },] },
- { type: GestureController, },
- { type: DomController, },
- { type: NgZone, },
- ]; };
- Toggle.propDecorators = {
- 'checked': [{ type: Input },],
- '_keyup': [{ type: HostListener, args: ['keyup', ['$event'],] },],
- };
- return Toggle;
- }(BaseInput));
-
- var __extends$85 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @name Footer
- * @description
- * Footer is a root component of a page that sits at the bottom of the page.
- * Footer can be a wrapper for `ion-toolbar` to make sure the content area is sized correctly.
- *
- * @usage
- *
- * ```html
- * <ion-content></ion-content>
- *
- * <ion-footer>
- * <ion-toolbar>
- * <ion-title>Footer</ion-title>
- * </ion-toolbar>
- * </ion-footer>
- * ```
- *
- */
- var Footer = (function (_super) {
- __extends$85(Footer, _super);
- function Footer(config, elementRef, renderer, viewCtrl) {
- var _this = _super.call(this, config, elementRef, renderer, 'footer') || this;
- viewCtrl && viewCtrl._setFooter(_this);
- return _this;
- }
- Footer.decorators = [
- { type: Directive, args: [{
- selector: 'ion-footer'
- },] },
- ];
- /** @nocollapse */
- Footer.ctorParameters = function () { return [
- { type: Config, },
- { type: ElementRef, },
- { type: Renderer, },
- { type: ViewController, decorators: [{ type: Optional },] },
- ]; };
- return Footer;
- }(Ion));
-
- var __extends$86 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @name Header
- * @description
- * Header is a parent component that holds the navbar and toolbar component.
- * It's important to note that `ion-header` needs to be one of the three root elements of a page
- *
- * @usage
- *
- * ```html
- * <ion-header>
- * <ion-navbar>
- * <ion-title>Page1</ion-title>
- * </ion-navbar>
- *
- * <ion-toolbar>
- * <ion-title>Subheader</ion-title>
- * </ion-toolbar>
- * </ion-header>
- *
- * <ion-content></ion-content>
- * ```
- *
- */
- var Header = (function (_super) {
- __extends$86(Header, _super);
- function Header(config, elementRef, renderer, viewCtrl) {
- var _this = _super.call(this, config, elementRef, renderer, 'header') || this;
- viewCtrl && viewCtrl._setHeader(_this);
- return _this;
- }
- Header.decorators = [
- { type: Directive, args: [{
- selector: 'ion-header'
- },] },
- ];
- /** @nocollapse */
- Header.ctorParameters = function () { return [
- { type: Config, },
- { type: ElementRef, },
- { type: Renderer, },
- { type: ViewController, decorators: [{ type: Optional },] },
- ]; };
- return Header;
- }(Ion));
-
- var __extends$87 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @name Toolbar
- * @description
- * A Toolbar is a generic bar that is positioned above or below content.
- * Unlike a [Navbar](../Navbar/), a toolbar can be used as a subheader.
- * When toolbars are placed within an `<ion-header>` or `<ion-footer>`,
- * the toolbars stay fixed in their respective location. When placed within
- * `<ion-content>`, toolbars will scroll with the content.
- *
- *
- * ### Buttons in a Toolbar
- * Buttons placed in a toolbar should be placed inside of the `<ion-buttons>`
- * element. An exception to this is a [menuToggle](../../menu/MenuToggle) button.
- * It should not be placed inside of the `<ion-buttons>` element. Both the
- * `<ion-buttons>` element and the `menuToggle` can be positioned inside of the
- * toolbar using different properties. The below chart has a description of each
- * property.
- *
- * | Property | Description |
- * |-------------|-----------------------------------------------------------------------------------------------------------------------|
- * | `start` | Positions element to the left of the content in `ios` mode, and directly to the right in `md` and `wp` mode. |
- * | `end` | Positions element to the right of the content in `ios` mode, and to the far right in `md` and `wp` mode. |
- * | `left` | Positions element to the left of all other elements. |
- * | `right` | Positions element to the right of all other elements. |
- *
- *
- * ### Header / Footer Box Shadow and Border
- * In `md` mode, the `<ion-header>` will receive a box-shadow on the bottom, and the
- * `<ion-footer>` will receive a box-shadow on the top. In `ios` mode, the `<ion-header>`
- * will receive a border on the bottom, and the `<ion-footer>` will receive a border on the
- * top. Both the `md` box-shadow and the `ios` border can be removed by adding the `no-border`
- * attribute to the element.
- *
- * ```html
- * <ion-header no-border>
- * <ion-toolbar>
- * <ion-title>Header</ion-title>
- * </ion-toolbar>
- * </ion-header>
- *
- * <ion-content>
- * </ion-content>
- *
- * <ion-footer no-border>
- * <ion-toolbar>
- * <ion-title>Footer</ion-title>
- * </ion-toolbar>
- * </ion-footer>
- * ```
- *
- * @usage
- *
- * ```html
- *
- * <ion-header no-border>
- *
- * <ion-toolbar>
- * <ion-title>My Toolbar Title</ion-title>
- * </ion-toolbar>
- *
- * <ion-toolbar>
- * <ion-title>I'm a subheader</ion-title>
- * </ion-toolbar>
- *
- * <ion-header>
- *
- *
- * <ion-content>
- *
- * <ion-toolbar>
- * <ion-title>Scrolls with the content</ion-title>
- * </ion-toolbar>
- *
- * </ion-content>
- *
- *
- * <ion-footer no-border>
- *
- * <ion-toolbar>
- * <ion-title>I'm a footer</ion-title>
- * </ion-toolbar>
- *
- * </ion-footer>
- * ```
- *
- * @demo /docs/demos/src/toolbar/
- * @see {@link ../Navbar/ Navbar API Docs}
- */
- var Toolbar = (function (_super) {
- __extends$87(Toolbar, _super);
- function Toolbar(config, elementRef, renderer) {
- var _this = _super.call(this, config, elementRef, renderer) || this;
- _this._sbPadding = config.getBoolean('statusbarPadding');
- return _this;
- }
- Toolbar.decorators = [
- { type: Component, args: [{
- selector: 'ion-toolbar',
- template: '<div class="toolbar-background" [ngClass]="\'toolbar-background-\' + _mode"></div>' +
- '<ng-content select="[menuToggle],ion-buttons[left]"></ng-content>' +
- '<ng-content select="ion-buttons[start]"></ng-content>' +
- '<ng-content select="ion-buttons[end],ion-buttons[right]"></ng-content>' +
- '<div class="toolbar-content" [ngClass]="\'toolbar-content-\' + _mode">' +
- '<ng-content></ng-content>' +
- '</div>',
- host: {
- 'class': 'toolbar',
- '[class.statusbar-padding]': '_sbPadding'
- },
- changeDetection: ChangeDetectionStrategy.OnPush,
- },] },
- ];
- /** @nocollapse */
- Toolbar.ctorParameters = function () { return [
- { type: Config, },
- { type: ElementRef, },
- { type: Renderer, },
- ]; };
- return Toolbar;
- }(ToolbarBase));
-
- var __extends$88 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @hidden
- */
- var ToolbarItem = (function (_super) {
- __extends$88(ToolbarItem, _super);
- function ToolbarItem(config, elementRef, renderer, toolbar, navbar) {
- var _this = _super.call(this, config, elementRef, renderer, 'bar-buttons') || this;
- _this.inToolbar = !!(toolbar || navbar);
- return _this;
- }
- Object.defineProperty(ToolbarItem.prototype, "_buttons", {
- set: function (buttons) {
- if (this.inToolbar) {
- buttons.forEach(function (button) {
- button.setRole('bar-button');
- });
- }
- },
- enumerable: true,
- configurable: true
- });
- ToolbarItem.decorators = [
- { type: Directive, args: [{
- selector: 'ion-buttons,[menuToggle]'
- },] },
- ];
- /** @nocollapse */
- ToolbarItem.ctorParameters = function () { return [
- { type: Config, },
- { type: ElementRef, },
- { type: Renderer, },
- { type: Toolbar, decorators: [{ type: Optional },] },
- { type: Navbar, decorators: [{ type: Optional }, { type: Inject, args: [forwardRef(function () { return Navbar; }),] },] },
- ]; };
- ToolbarItem.propDecorators = {
- '_buttons': [{ type: ContentChildren, args: [Button,] },],
- };
- return ToolbarItem;
- }(Ion));
-
- var __extends$89 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @name Title
- * @description
- * `ion-title` is a component that sets the title of the `Toolbar` or `Navbar`
- *
- * @usage
- *
- * ```html
- * <ion-header>
- *
- * <ion-navbar>
- * <ion-title>Settings</ion-title>
- * </ion-navbar>
- *
- * </ion-header>
- * ```
- *
- * Or to create a navbar with a toolbar as a subheader:
- *
- * ```html
- * <ion-header>
- *
- * <ion-navbar>
- * <ion-title>Main Header</ion-title>
- * </ion-navbar>
- *
- * <ion-toolbar>
- * <ion-title>Subheader</ion-title>
- * </ion-toolbar>
- *
- * </ion-header>
- * ```
- *
- * @demo /docs/demos/src/title/
- */
- var ToolbarTitle = (function (_super) {
- __extends$89(ToolbarTitle, _super);
- function ToolbarTitle(config, elementRef, renderer, toolbar, navbar) {
- var _this = _super.call(this, config, elementRef, renderer, 'title') || this;
- toolbar && toolbar._setTitle(_this);
- navbar && navbar._setTitle(_this);
- return _this;
- }
- /**
- * @hidden
- */
- ToolbarTitle.prototype.getTitleText = function () {
- return this._elementRef.nativeElement.textContent;
- };
- ToolbarTitle.decorators = [
- { type: Component, args: [{
- selector: 'ion-title',
- template: '<div class="toolbar-title" [ngClass]="\'toolbar-title-\' + _mode">' +
- '<ng-content></ng-content>' +
- '</div>',
- changeDetection: ChangeDetectionStrategy.OnPush,
- encapsulation: ViewEncapsulation.None,
- },] },
- ];
- /** @nocollapse */
- ToolbarTitle.ctorParameters = function () { return [
- { type: Config, },
- { type: ElementRef, },
- { type: Renderer, },
- { type: Toolbar, decorators: [{ type: Optional },] },
- { type: Navbar, decorators: [{ type: Optional }, { type: Inject, args: [forwardRef(function () { return Navbar; }),] },] },
- ]; };
- return ToolbarTitle;
- }(Ion));
-
- /**
- * @name Thumbnail
- * @module ionic
- * @description
- * A Thumbnail is a component that creates a squared image for an item.
- * Thumbnails can be place on the left or right side of an item with the `item-start` or `item-end` directive.
- * @see {@link /docs/components/#thumbnail-list Thumbnail Component Docs}
- */
- var Thumbnail = (function () {
- function Thumbnail() {
- }
- Thumbnail.decorators = [
- { type: Directive, args: [{
- selector: 'ion-thumbnail'
- },] },
- ];
- /** @nocollapse */
- Thumbnail.ctorParameters = function () { return []; };
- return Thumbnail;
- }());
-
- var __extends$90 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @name Typography
- * @module ionic
- * @description
- *
- * The Typography component is a simple component that can be used to style the text color of any element.
- * The `ion-text` attribute should be added to the element in order to pass a color from the Sass `$colors`
- * map and change the text color of that element.
- *
- * @usage
- *
- * ```html
- * <h1 ion-text color="secondary">H1: The quick brown fox jumps over the lazy dog</h1>
- *
- * <h2 ion-text color="primary">H2: The quick brown fox jumps over the lazy dog</h2>
- *
- * <h3 ion-text color="light">H3: The quick brown fox jumps over the lazy dog</h3>
- *
- * <h4 ion-text color="danger">H4: The quick brown fox jumps over the lazy dog</h4>
- *
- * <h5 ion-text color="dark">H5: The quick brown fox jumps over the lazy dog</h5>
- *
- * <h6 ion-text [color]="dynamicColor">H6: The quick brown fox jumps over the lazy dog</h6>
- *
- * <p>
- * I saw a werewolf with a Chinese menu in his hand.
- * Walking through the <sub ion-text color="danger">streets</sub> of Soho in the rain.
- * He <i ion-text color="primary">was</i> looking for a place called Lee Ho Fook's.
- * Gonna get a <a ion-text color="secondary">big dish of beef chow mein.</a>
- * </p>
- *
- * <p>
- * He's the hairy-handed gent who ran amuck in Kent.
- * Lately he's <sup ion-text color="primary">been</sup> overheard in Mayfair.
- * Better stay away from him.
- * He'll rip your lungs out, Jim.
- * I'd like to meet his tailor.
- * </p>
- * ```
- *
- */
- var Typography = (function (_super) {
- __extends$90(Typography, _super);
- function Typography(config, elementRef, renderer) {
- return _super.call(this, config, elementRef, renderer, 'text') || this;
- }
- Typography.decorators = [
- { type: Directive, args: [{
- selector: '[ion-text]'
- },] },
- ];
- /** @nocollapse */
- Typography.ctorParameters = function () { return [
- { type: Config, },
- { type: ElementRef, },
- { type: Renderer, },
- ]; };
- return Typography;
- }(Ion));
-
- /**
- * @hidden
- */
- var VirtualFooter = (function () {
- function VirtualFooter(templateRef) {
- this.templateRef = templateRef;
- }
- VirtualFooter.decorators = [
- { type: Directive, args: [{ selector: '[virtualFooter]' },] },
- ];
- /** @nocollapse */
- VirtualFooter.ctorParameters = function () { return [
- { type: TemplateRef, },
- ]; };
- return VirtualFooter;
- }());
-
- /**
- * @hidden
- */
- var VirtualHeader = (function () {
- function VirtualHeader(templateRef) {
- this.templateRef = templateRef;
- }
- VirtualHeader.decorators = [
- { type: Directive, args: [{ selector: '[virtualHeader]' },] },
- ];
- /** @nocollapse */
- VirtualHeader.ctorParameters = function () { return [
- { type: TemplateRef, },
- ]; };
- return VirtualHeader;
- }());
-
- /**
- * @hidden
- */
- var VirtualItem = (function () {
- function VirtualItem(templateRef, viewContainer) {
- this.templateRef = templateRef;
- this.viewContainer = viewContainer;
- }
- VirtualItem.decorators = [
- { type: Directive, args: [{ selector: '[virtualItem]' },] },
- ];
- /** @nocollapse */
- VirtualItem.ctorParameters = function () { return [
- { type: TemplateRef, },
- { type: ViewContainerRef, },
- ]; };
- return VirtualItem;
- }());
-
- var PREVIOUS_CELL = {
- row: 0,
- width: 0,
- height: 0,
- top: 0,
- left: 0,
- tmpl: -1
- };
- /**
- * NO DOM
- */
- function processRecords(stopAtHeight, records, cells, headerFn, footerFn, data) {
- var record;
- var startRecordIndex;
- var previousCell;
- var tmpData;
- var lastRecordIndex = records ? (records.length - 1) : -1;
- if (cells.length) {
- // we already have cells
- previousCell = cells[cells.length - 1];
- if (previousCell.top + previousCell.height > stopAtHeight) {
- return;
- }
- startRecordIndex = (previousCell.record + 1);
- }
- else {
- // no cells have been created yet
- previousCell = PREVIOUS_CELL;
- startRecordIndex = 0;
- }
- var processedTotal = 0;
- for (var recordIndex = startRecordIndex; recordIndex <= lastRecordIndex; recordIndex++) {
- record = records[recordIndex];
- if (headerFn) {
- tmpData = headerFn(record, recordIndex, records);
- if (tmpData !== null) {
- // add header data
- previousCell = addCell(previousCell, recordIndex, 1 /* Header */, tmpData, data.hdrWidth, data.hdrHeight, data.viewWidth);
- cells.push(previousCell);
- }
- }
- // add item data
- previousCell = addCell(previousCell, recordIndex, 0 /* Item */, null, data.itmWidth, data.itmHeight, data.viewWidth);
- cells.push(previousCell);
- if (footerFn) {
- tmpData = footerFn(record, recordIndex, records);
- if (tmpData !== null) {
- // add footer data
- previousCell = addCell(previousCell, recordIndex, 2 /* Footer */, tmpData, data.ftrWidth, data.ftrHeight, data.viewWidth);
- cells.push(previousCell);
- }
- }
- if (previousCell.record === lastRecordIndex) {
- previousCell.isLast = true;
- }
- // should always process at least 3 records
- processedTotal++;
- if (previousCell.top + previousCell.height + data.itmHeight > stopAtHeight && processedTotal > 3) {
- return;
- }
- }
- }
- function addCell(previousCell, recordIndex, tmpl, tmplData, cellWidth, cellHeight, viewportWidth) {
- var newCell = {
- record: recordIndex,
- tmpl: tmpl,
- width: cellWidth,
- height: cellHeight,
- reads: 0
- };
- if (previousCell.left + previousCell.width + cellWidth > viewportWidth) {
- // add a new cell in a new row
- newCell.row = (previousCell.row + 1);
- newCell.top = (previousCell.top + previousCell.height);
- newCell.left = 0;
- }
- else {
- // add a new cell in the same row
- newCell.row = previousCell.row;
- newCell.top = previousCell.top;
- newCell.left = (previousCell.left + previousCell.width);
- }
- if (tmplData) {
- newCell.data = tmplData;
- }
- return newCell;
- }
- /**
- * NO DOM
- */
- function populateNodeData(startCellIndex, endCellIndex, scrollingDown, cells, records, nodes, viewContainer, itmTmp, hdrTmp, ftrTmp) {
- if (!records || records.length === 0) {
- nodes.length = 0;
- viewContainer.clear();
- return true;
- }
- var recordsLength = records.length;
- var hasChanges = false;
- // let node: VirtualNode;
- var availableNode;
- var cell;
- var viewInsertIndex = null;
- var totalNodes = nodes.length;
- var templateRef;
- startCellIndex = Math.max(startCellIndex, 0);
- endCellIndex = Math.min(endCellIndex, cells.length - 1);
- var usedNodes = [];
- for (var cellIndex = startCellIndex; cellIndex <= endCellIndex; cellIndex++) {
- cell = cells[cellIndex];
- availableNode = null;
- // find the first one that's available
- var existingNode = nodes.find(function (n) { return n.cell === cellIndex && n.tmpl === cell.tmpl; });
- if (existingNode) {
- if (existingNode.view.context.$implicit === records[cell.record]) {
- usedNodes.push(existingNode);
- continue; // optimization: node data is the same no need to update
- }
- (void 0) /* console.debug */;
- availableNode = existingNode; // update existing node
- }
- else {
- (void 0) /* console.debug */;
- for (var i = 0; i < totalNodes; i++) {
- var node = nodes[i];
- if (cell.tmpl !== node.tmpl || i === 0 && cellIndex !== 0) {
- // the cell must use the correct template
- // first node can only be used by the first cell (css :first-child reasons)
- // this node is never available to be reused
- continue;
- }
- if (node.cell < startCellIndex || node.cell > endCellIndex) {
- if (!availableNode) {
- // havent gotten an available node yet
- availableNode = node;
- (void 0) /* console.debug */;
- }
- else if (scrollingDown) {
- // scrolling down
- if (node.cell < availableNode.cell) {
- availableNode = node;
- (void 0) /* console.debug */;
- }
- }
- else {
- // scrolling up
- if (node.cell > availableNode.cell) {
- availableNode = node;
- (void 0) /* console.debug */;
- }
- }
- }
- }
- }
- if (!availableNode) {
- // did not find an available node to put the cell data into
- // insert a new node after existing ones
- if (viewInsertIndex === null) {
- viewInsertIndex = -1;
- for (var j = totalNodes - 1; j >= 0; j--) {
- var node = nodes[j];
- if (node) {
- viewInsertIndex = viewContainer.indexOf(node.view);
- break;
- }
- }
- }
- // select which templateRef should be used for this cell
- templateRef = cell.tmpl === 1 /* Header */ ? hdrTmp : cell.tmpl === 2 /* Footer */ ? ftrTmp : itmTmp;
- if (!templateRef) {
- console.error("virtual" + (cell.tmpl === 1 /* Header */ ? 'Header' : cell.tmpl === 2 /* Footer */ ? 'Footer' : 'Item') + " template required");
- continue;
- }
- availableNode = {
- tmpl: cell.tmpl,
- view: viewContainer.createEmbeddedView(templateRef, new VirtualContext(null, null, null), viewInsertIndex)
- };
- totalNodes = nodes.push(availableNode);
- }
- // assign who's the new cell index for this node
- availableNode.cell = cellIndex;
- // apply the cell's data to this node
- var context = availableNode.view.context;
- context.$implicit = cell.data || records[cell.record];
- context.index = cellIndex;
- context.count = recordsLength;
- availableNode.hasChanges = true;
- availableNode.lastTransform = null;
- hasChanges = true;
- usedNodes.push(availableNode);
- }
- var unusedNodes = nodes.filter(function (n) { return usedNodes.indexOf(n) < 0; });
- unusedNodes.forEach(function (node) {
- var index = viewContainer.indexOf(node.view);
- viewContainer.remove(index);
- var removeIndex = nodes.findIndex(function (n) { return n === node; });
- nodes.splice(removeIndex, 1);
- });
- usedNodes.length = 0;
- unusedNodes.length = 0;
- return hasChanges;
- }
- /**
- * DOM READ
- */
- function initReadNodes(plt, nodes, cells, data) {
- if (nodes.length && cells.length) {
- // first node
- // ******** DOM READ ****************
- var ele = getElement(nodes[0]);
- var firstCell = cells[0];
- firstCell.top = ele.clientTop;
- firstCell.left = ele.clientLeft;
- firstCell.row = 0;
- // ******** DOM READ ****************
- updateDimensions(plt, nodes, cells, data, true);
- }
- }
- /**
- * DOM READ
- */
- function updateDimensions(plt, nodes, cells, data, initialUpdate) {
- var node;
- var element;
- var cell;
- var previousCell;
- var totalCells = cells.length;
- for (var i = 0; i < nodes.length; i++) {
- node = nodes[i];
- cell = cells[node.cell];
- // read element dimensions if they haven't been checked enough times
- if (cell && cell.reads < REQUIRED_DOM_READS) {
- element = getElement(node);
- // ******** DOM READ ****************
- readElements(plt, cell, element);
- if (initialUpdate) {
- // update estimated dimensions with more accurate dimensions
- if (cell.tmpl === 1 /* Header */) {
- data.hdrHeight = cell.height;
- if (cell.left === 0) {
- data.hdrWidth = cell.width;
- }
- }
- else if (cell.tmpl === 2 /* Footer */) {
- data.ftrHeight = cell.height;
- if (cell.left === 0) {
- data.ftrWidth = cell.width;
- }
- }
- else {
- data.itmHeight = cell.height;
- if (cell.left === 0) {
- data.itmWidth = cell.width;
- }
- }
- }
- cell.reads++;
- }
- }
- // figure out which cells are currently viewable within the viewport
- var viewableBottom = (data.scrollTop + data.viewHeight);
- data.topViewCell = totalCells;
- data.bottomViewCell = 0;
- if (totalCells > 0) {
- // completely realign position to ensure they're all accurately placed
- cell = cells[0];
- previousCell = {
- row: 0,
- width: 0,
- height: 0,
- top: cell.top,
- left: 0,
- tmpl: -1
- };
- for (var i_1 = 0; i_1 < totalCells; i_1++) {
- cell = cells[i_1];
- if (previousCell.left + previousCell.width + cell.width > data.viewWidth) {
- // new row
- cell.row++;
- cell.top = (previousCell.top + previousCell.height);
- cell.left = 0;
- }
- else {
- // same row
- cell.row = previousCell.row;
- cell.top = previousCell.top;
- cell.left = (previousCell.left + previousCell.width);
- }
- // figure out which cells are viewable within the viewport
- if (cell.top + cell.height > data.scrollTop && i_1 < data.topViewCell) {
- data.topViewCell = i_1;
- }
- else if (cell.top < viewableBottom && i_1 > data.bottomViewCell) {
- data.bottomViewCell = i_1;
- }
- previousCell = cell;
- }
- }
- }
- function updateNodeContext(nodes, cells, data) {
- // ensure each node has the correct bounds in its context
- var node;
- var cell;
- var bounds;
- for (var i = 0, ilen = nodes.length; i < ilen; i++) {
- node = nodes[i];
- cell = cells[node.cell];
- if (node && cell) {
- bounds = node.view.context.bounds;
- bounds.top = cell.top + data.viewTop;
- bounds.bottom = bounds.top + cell.height;
- bounds.left = cell.left + data.viewLeft;
- bounds.right = bounds.left + cell.width;
- bounds.width = cell.width;
- bounds.height = cell.height;
- }
- }
- }
- /**
- * DOM READ
- */
- function readElements(plt, cell, element) {
- // ******** DOM READ ****************
- var styles = plt.getElementComputedStyle(element);
- // ******** DOM READ ****************
- cell.left = (element.clientLeft - parseFloat(styles.marginLeft));
- // ******** DOM READ ****************
- cell.width = (element.offsetWidth + parseFloat(styles.marginLeft) + parseFloat(styles.marginRight));
- // ******** DOM READ ****************
- cell.height = (element.offsetHeight + parseFloat(styles.marginTop) + parseFloat(styles.marginBottom));
- }
- /**
- * DOM WRITE
- */
- function writeToNodes(plt, nodes, cells, totalRecords) {
- var node;
- var element;
- var cell;
- var transform;
- var totalCells = Math.max(totalRecords, cells.length);
- for (var i = 0, ilen = nodes.length; i < ilen; i++) {
- node = nodes[i];
- cell = cells[node.cell];
- transform = "translate3d(" + cell.left + "px," + cell.top + "px,0px)";
- if (node.lastTransform !== transform) {
- element = getElement(node);
- if (element) {
- // ******** DOM WRITE ****************
- element.style[plt.Css.transform] = node.lastTransform = transform;
- // ******** DOM WRITE ****************
- element.classList.add('virtual-position');
- // https://www.w3.org/TR/wai-aria/states_and_properties#aria-posinset
- // ******** DOM WRITE ****************
- element.setAttribute('aria-posinset', node.cell + 1);
- // https://www.w3.org/TR/wai-aria/states_and_properties#aria-setsize
- // ******** DOM WRITE ****************
- element.setAttribute('aria-setsize', totalCells);
- }
- }
- }
- }
- /**
- * NO DOM
- */
- function adjustRendered(cells, data) {
- var maxRenderHeight = (data.renderHeight - data.itmHeight);
- var totalCells = cells.length;
- var viewableRenderedPadding = (data.itmHeight < 90 ? VIEWABLE_RENDERED_PADDING : 0);
- if (data.scrollDiff > 0) {
- // scrolling down
- data.topCell = Math.max(data.topViewCell - viewableRenderedPadding, 0);
- data.bottomCell = data.topCell;
- var cellsRenderHeight = 0;
- for (var i = data.topCell; i < totalCells; i++) {
- cellsRenderHeight += cells[i].height;
- if (i > data.bottomCell)
- data.bottomCell = i;
- if (cellsRenderHeight >= maxRenderHeight)
- break;
- }
- if (cellsRenderHeight < maxRenderHeight) {
- // there are no more cells at the bottom, so move topCell to a smaller index
- for (var i = data.topCell - 1; i >= 0; i--) {
- cellsRenderHeight += cells[i].height;
- data.topCell = i;
- if (cellsRenderHeight >= maxRenderHeight)
- break;
- }
- }
- }
- else {
- // scroll up
- data.bottomCell = Math.min(data.bottomViewCell + viewableRenderedPadding, totalCells - 1);
- data.topCell = data.bottomCell;
- var cellsRenderHeight = 0;
- (void 0) /* assert */;
- for (var i = data.bottomCell; i >= 0; i--) {
- cellsRenderHeight += cells[i].height;
- if (i < data.topCell)
- data.topCell = i;
- if (cellsRenderHeight >= maxRenderHeight)
- break;
- }
- if (cellsRenderHeight < maxRenderHeight) {
- // there are no more cells at the top, so move bottomCell to a higher index
- for (var i = data.bottomCell; i < totalCells; i++) {
- cellsRenderHeight += cells[i].height;
- data.bottomCell = i;
- if (cellsRenderHeight >= maxRenderHeight)
- break;
- }
- }
- }
- }
- /**
- * NO DOM
- */
- function getVirtualHeight(totalRecords, lastCell) {
- if (lastCell.record >= totalRecords - 1) {
- return (lastCell.top + lastCell.height);
- }
- var unknownRecords = (totalRecords - lastCell.record - 1);
- var knownHeight = (lastCell.top + lastCell.height);
- return Math.ceil(knownHeight + ((knownHeight / (totalRecords - unknownRecords)) * unknownRecords));
- }
- /**
- * NO DOM
- */
- function estimateHeight(totalRecords, lastCell, existingHeight, difference) {
- if (!totalRecords || !lastCell) {
- return 0;
- }
- var newHeight = getVirtualHeight(totalRecords, lastCell);
- var percentToBottom = (lastCell.record / (totalRecords - 1));
- var diff = Math.abs(existingHeight - newHeight);
- if ((diff > (newHeight * difference)) ||
- (percentToBottom > .995)) {
- return newHeight;
- }
- return existingHeight;
- }
- /**
- * DOM READ
- */
- function calcDimensions(data, virtualScrollElement, approxItemWidth, approxItemHeight, appoxHeaderWidth, approxHeaderHeight, approxFooterWidth, approxFooterHeight, bufferRatio) {
- // get the parent container's viewport bounds
- var viewportElement = virtualScrollElement.parentElement;
- // ******** DOM READ ****************
- data.viewWidth = viewportElement.offsetWidth;
- // ******** DOM READ ****************
- data.viewHeight = viewportElement.offsetHeight;
- // get the virtual scroll element's offset data
- // ******** DOM READ ****************
- data.viewTop = virtualScrollElement.offsetTop;
- // ******** DOM READ ****************
- data.viewLeft = virtualScrollElement.offsetLeft;
- // the height we'd like to render, which is larger than viewable
- data.renderHeight = (data.viewHeight * bufferRatio);
- if (data.viewWidth > 0 && data.viewHeight > 0) {
- data.itmWidth = calcWidth(data.viewWidth, approxItemWidth);
- data.itmHeight = calcHeight(data.viewHeight, approxItemHeight);
- data.hdrWidth = calcWidth(data.viewWidth, appoxHeaderWidth);
- data.hdrHeight = calcHeight(data.viewHeight, approxHeaderHeight);
- data.ftrWidth = calcWidth(data.viewWidth, approxFooterWidth);
- data.ftrHeight = calcHeight(data.viewHeight, approxFooterHeight);
- data.valid = true;
- }
- }
- /**
- * NO DOM
- */
- function calcWidth(viewportWidth, approxWidth) {
- if (approxWidth.indexOf('%') > 0) {
- return (viewportWidth * (parseFloat(approxWidth) / 100));
- }
- else if (approxWidth.indexOf('px') > 0) {
- return parseFloat(approxWidth);
- }
- throw new Error('virtual scroll width can only use "%" or "px" units');
- }
- /**
- * NO DOM
- */
- function calcHeight(_viewportHeight, approxHeight) {
- if (approxHeight.indexOf('px') > 0) {
- return parseFloat(approxHeight);
- }
- throw new Error('virtual scroll height must use "px" units');
- }
- /**
- * NO DOM
- */
- function getElement(node) {
- var rootNodes = node.view.rootNodes;
- for (var i = 0; i < rootNodes.length; i++) {
- if (rootNodes[i].nodeType === 1) {
- return rootNodes[i];
- }
- }
- return null;
- }
- var VirtualContext = (function () {
- function VirtualContext($implicit, index, count) {
- this.$implicit = $implicit;
- this.index = index;
- this.count = count;
- this.bounds = {};
- }
- Object.defineProperty(VirtualContext.prototype, "first", {
- get: function () { return this.index === 0; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(VirtualContext.prototype, "last", {
- get: function () { return this.index === this.count - 1; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(VirtualContext.prototype, "even", {
- get: function () { return this.index % 2 === 0; },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(VirtualContext.prototype, "odd", {
- get: function () { return !this.even; },
- enumerable: true,
- configurable: true
- });
- return VirtualContext;
- }());
- var VIEWABLE_RENDERED_PADDING = 3;
- var REQUIRED_DOM_READS = 2;
-
- /**
- * @name VirtualScroll
- * @description
- * Virtual Scroll displays a virtual, "infinite" list. An array of records
- * is passed to the virtual scroll containing the data to create templates
- * for. The template created for each record, referred to as a cell, can
- * consist of items, headers, and footers.
- *
- * For performance reasons, not every record in the list is rendered at once;
- * instead a small subset of records (enough to fill the viewport) are rendered
- * and reused as the user scrolls.
- *
- * ### The Basics
- *
- * The array of records should be passed to the `virtualScroll` property.
- * The data given to the `virtualScroll` property must be an array. An item
- * template with the `*virtualItem` property is required in the `virtualScroll`.
- * The `virtualScroll` and `*virtualItem` properties can be added to any element.
- *
- * ```html
- * <ion-list [virtualScroll]="items">
- *
- * <ion-item *virtualItem="let item">
- * {% raw %}{{ item }}{% endraw %}
- * </ion-item>
- *
- * </ion-list>
- * ```
- *
- *
- * ### Section Headers and Footers
- *
- * Section headers and footers are optional. They can be dynamically created
- * from developer-defined functions. For example, a large list of contacts
- * usually has a divider for each letter in the alphabet. Developers provide
- * their own custom function to be called on each record. The logic in the
- * custom function should determine whether to create the section template
- * and what data to provide to the template. The custom function should
- * return `null` if a template shouldn't be created.
- *
- * ```html
- * <ion-list [virtualScroll]="items" [headerFn]="myHeaderFn">
- *
- * <ion-item-divider *virtualHeader="let header">
- * Header: {% raw %}{{ header }}{% endraw %}
- * </ion-item-divider>
- *
- * <ion-item *virtualItem="let item">
- * Item: {% raw %}{{ item }}{% endraw %}
- * </ion-item>
- *
- * </ion-list>
- * ```
- *
- * Below is an example of a custom function called on every record. It
- * gets passed the individual record, the record's index number,
- * and the entire array of records. In this example, after every 20
- * records a header will be inserted. So between the 19th and 20th records,
- * between the 39th and 40th, and so on, a `<ion-item-divider>` will
- * be created and the template's data will come from the function's
- * returned data.
- *
- * ```ts
- * myHeaderFn(record, recordIndex, records) {
- * if (recordIndex % 20 === 0) {
- * return 'Header ' + recordIndex;
- * }
- * return null;
- * }
- * ```
- *
- *
- * ### Approximate Widths and Heights
- *
- * If the height of items in the virtual scroll are not close to the
- * default size of 40px, it is extremely important to provide a value for
- * approxItemHeight height. An exact pixel-perfect size is not necessary,
- * but without an estimate the virtual scroll will not render correctly.
- *
- * The approximate width and height of each template is used to help
- * determine how many cells should be created, and to help calculate
- * the height of the scrollable area. Note that the actual rendered size
- * of each cell comes from the app's CSS, whereas this approximation
- * is only used to help calculate initial dimensions.
- *
- * It's also important to know that Ionic's default item sizes have
- * slightly different heights between platforms, which is perfectly fine.
- *
- *
- * ### Images Within Virtual Scroll
- *
- * HTTP requests, image decoding, and image rendering can cause jank while
- * scrolling. In order to better control images, Ionic provides `<ion-img>`
- * to manage HTTP requests and image rendering. While scrolling through items
- * quickly, `<ion-img>` knows when and when not to make requests, when and
- * when not to render images, and only loads the images that are viewable
- * after scrolling. [Read more about `ion-img`.](../../img/Img/)
- *
- * It's also important for app developers to ensure image sizes are locked in,
- * and after images have fully loaded they do not change size and affect any
- * other element sizes. Simply put, to ensure rendering bugs are not introduced,
- * it's vital that elements within a virtual item does not dynamically change.
- *
- * For virtual scrolling, the natural effects of the `<img>` are not desirable
- * features. We recommend using the `<ion-img>` component over the native
- * `<img>` element because when an `<img>` element is added to the DOM, it
- * immediately makes a HTTP request for the image file. Additionally, `<img>`
- * renders whenever it wants which could be while the user is scrolling. However,
- * `<ion-img>` is governed by the containing `ion-content` and does not render
- * images while scrolling quickly.
- *
- * ```html
- * <ion-list [virtualScroll]="items">
- *
- * <ion-item *virtualItem="let item">
- * <ion-avatar item-start>
- * <ion-img [src]="item.avatarUrl"></ion-img>
- * </ion-avatar>
- * {% raw %} {{ item.firstName }} {{ item.lastName }}{% endraw %}
- * </ion-item>
- *
- * </ion-list>
- * ```
- *
- *
- * ### Custom Components
- *
- * If a custom component is going to be used within Virtual Scroll, it's best
- * to wrap it with a good old `<div>` to ensure the component is rendered
- * correctly. Since each custom component's implementation and internals can be
- * quite different, wrapping within a `<div>` is a safe way to make sure
- * dimensions are measured correctly.
- *
- * ```html
- * <ion-list [virtualScroll]="items">
- *
- * <div *virtualItem="let item">
- * <my-custom-item [item]="item">
- * {% raw %} {{ item }}{% endraw %}
- * </my-custom-item>
- * </div>
- *
- * </ion-list>
- * ```
- *
- *
- * ## Virtual Scroll Performance Tips
- *
- * #### iOS Cordova WKWebView
- *
- * When deploying to iOS with Cordova, it's highly recommended to use the
- * [WKWebView plugin](http://blog.ionic.io/cordova-ios-performance-improvements-drop-in-speed-with-wkwebview/)
- * in order to take advantage of iOS's higher performimg webview. Additionally,
- * WKWebView is superior at scrolling efficiently in comparision to the older
- * UIWebView.
- *
- * #### Lock in element dimensions and locations
- *
- * In order for virtual scroll to efficiently size and locate every item, it's
- * very important every element within each virtual item does not dynamically
- * change its dimensions or location. The best way to ensure size and location
- * does not change, it's recommended each virtual item has locked in its size
- * via CSS.
- *
- * #### Use `ion-img` for images
- *
- * When including images within Virtual Scroll, be sure to use
- * [`ion-img`](../img/Img/) rather than the standard `<img>` HTML element.
- * With `ion-img`, images are lazy loaded so only the viewable ones are
- * rendered, and HTTP requests are efficiently controlled while scrolling.
- *
- * #### Set Approximate Widths and Heights
- *
- * As mentioned above, all elements should lock in their dimensions. However,
- * virtual scroll isn't aware of the dimensions until after they have been
- * rendered. For the initial render, virtual scroll still needs to set
- * how many items should be built. With "approx" property inputs, such as
- * `approxItemHeight`, we're able to give virtual scroll an approximate size,
- * therefore allowing virtual scroll to decide how many items should be
- * created.
- *
- * #### Changing dataset should use `virtualTrackBy`
- *
- * It is possible for the identities of elements in the iterator to change
- * while the data does not. This can happen, for example, if the iterator
- * produced from an RPC to the server, and that RPC is re-run. Even if the
- * "data" hasn't changed, the second response will produce objects with
- * different identities, and Ionic will tear down the entire DOM and rebuild
- * it. This is an expensive operation and should be avoided if possible.
- *
- * #### Efficient headers and footer functions
- *
- * Each virtual item must stay extremely efficient, but one way to really
- * kill its performance is to perform any DOM operations within section header
- * and footer functions. These functions are called for every record in the
- * dataset, so please make sure they're performant.
- *
- */
- var VirtualScroll = (function () {
- function VirtualScroll(_iterableDiffers, _elementRef, _renderer, _zone, _cd, _content, _plt, _ctrl, _config, _dom) {
- var _this = this;
- this._iterableDiffers = _iterableDiffers;
- this._elementRef = _elementRef;
- this._renderer = _renderer;
- this._zone = _zone;
- this._cd = _cd;
- this._content = _content;
- this._plt = _plt;
- this._ctrl = _ctrl;
- this._config = _config;
- this._dom = _dom;
- this._init = false;
- this._lastEle = false;
- this._records = [];
- this._cells = [];
- this._nodes = [];
- this._vHeight = 0;
- this._lastCheck = 0;
- this._recordSize = 0;
- this._data = {
- scrollTop: 0,
- };
- this._queue = 1 /* NoChanges */;
- /**
- * @input {number} The buffer ratio is used to decide how many cells
- * should get created when initially rendered. The number is a
- * multiplier against the viewable area's height. For example, if it
- * takes `20` cells to fill up the height of the viewable area, then
- * with a buffer ratio of `3` it will create `60` cells that are
- * available for reuse while scrolling. For better performance, it's
- * better to have more cells than what are required to fill the
- * viewable area. Default is `3`.
- */
- this.bufferRatio = 3;
- /**
- * @input {string} The approximate width of each item template's cell.
- * This dimension is used to help determine how many cells should
- * be created when initialized, and to help calculate the height of
- * the scrollable area. This value can use either `px` or `%` units.
- * Note that the actual rendered size of each cell comes from the
- * app's CSS, whereas this approximation is used to help calculate
- * initial dimensions before the item has been rendered. Default is
- * `100%`.
- */
- this.approxItemWidth = '100%';
- /**
- * @input {string} The approximate width of each header template's cell.
- * This dimension is used to help determine how many cells should
- * be created when initialized, and to help calculate the height of
- * the scrollable area. This value can use either `px` or `%` units.
- * Note that the actual rendered size of each cell comes from the
- * app's CSS, whereas this approximation is used to help calculate
- * initial dimensions. Default is `100%`.
- */
- this.approxHeaderWidth = '100%';
- /**
- * @input {string} The approximate height of each header template's cell.
- * This dimension is used to help determine how many cells should
- * be created when initialized, and to help calculate the height of
- * the scrollable area. This height value can only use `px` units.
- * Note that the actual rendered size of each cell comes from the
- * app's CSS, whereas this approximation is used to help calculate
- * initial dimensions before the item has been rendered. Default is `40px`.
- */
- this.approxHeaderHeight = '40px';
- /**
- * @input {string} The approximate width of each footer template's cell.
- * This dimension is used to help determine how many cells should
- * be created when initialized, and to help calculate the height of
- * the scrollable area. This value can use either `px` or `%` units.
- * Note that the actual rendered size of each cell comes from the
- * app's CSS, whereas this approximation is used to help calculate
- * initial dimensions before the item has been rendered. Default is `100%`.
- */
- this.approxFooterWidth = '100%';
- /**
- * @input {string} The approximate height of each footer template's cell.
- * This dimension is used to help determine how many cells should
- * be created when initialized, and to help calculate the height of
- * the scrollable area. This height value can only use `px` units.
- * Note that the actual rendered size of each cell comes from the
- * app's CSS, whereas this approximation is used to help calculate
- * initial dimensions before the item has been rendered. Default is `40px`.
- */
- this.approxFooterHeight = '40px';
- // hide the virtual scroll element with opacity so we don't
- // see jank as it loads up, but we're still able to read
- // dimensions because it's still rendered and only opacity hidden
- this.setElementClass('virtual-loading', true);
- // wait for the content to be rendered and has readable dimensions
- var readSub = _ctrl.readReady.subscribe(function () {
- readSub.unsubscribe();
- _this.readUpdate(true);
- });
- // wait for the content to be writable
- var writeSub = _ctrl.writeReady.subscribe(function () {
- writeSub.unsubscribe();
- _this._init = true;
- _this.writeUpdate(true);
- _this._listeners();
- });
- }
- Object.defineProperty(VirtualScroll.prototype, "virtualScroll", {
- get: function () {
- return this._records;
- },
- /**
- * @input {array} The data that builds the templates within the virtual scroll.
- * This is the same data that you'd pass to `*ngFor`. It's important to note
- * that when this data has changed, then the entire virtual scroll is reset,
- * which is an expensive operation and should be avoided if possible.
- */
- set: function (val) {
- this._records = val;
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(VirtualScroll.prototype, "headerFn", {
- /**
- * @input {function} Section headers and the data used within its given
- * template can be dynamically created by passing a function to `headerFn`.
- * For example, a large list of contacts usually has dividers between each
- * letter in the alphabet. App's can provide their own custom `headerFn`
- * which is called with each record within the dataset. The logic within
- * the header function can decide if the header template should be used,
- * and what data to give to the header template. The function must return
- * `null` if a header cell shouldn't be created.
- */
- set: function (val) {
- if (isFunction$1(val)) {
- this._hdrFn = val.bind((this._ctrl._cmp) || this);
- }
- },
- enumerable: true,
- configurable: true
- });
- Object.defineProperty(VirtualScroll.prototype, "footerFn", {
- /**
- * @input {function} Section footers and the data used within its given
- * template can be dynamically created by passing a function to `footerFn`.
- * The logic within the footer function can decide if the footer template
- * should be used, and what data to give to the footer template. The function
- * must return `null` if a footer cell shouldn't be created.
- */
- set: function (val) {
- if (isFunction$1(val)) {
- this._ftrFn = val.bind((this._ctrl._cmp) || this);
- }
- },
- enumerable: true,
- configurable: true
- });
- /**
- * @hidden
- */
- VirtualScroll.prototype.firstRecord = function () {
- var cells = this._cells;
- return (cells.length > 0) ? cells[0].record : 0;
- };
- /**
- * @hidden
- */
- VirtualScroll.prototype.lastRecord = function () {
- var cells = this._cells;
- return (cells.length > 0) ? cells[cells.length - 1].record : 0;
- };
- /**
- * @hidden
- */
- VirtualScroll.prototype.ngOnChanges = function (changes) {
- if ('virtualScroll' in changes) {
- // React on virtualScroll changes only once all inputs have been initialized
- var value = changes['virtualScroll'].currentValue;
- if (!isPresent(this._differ) && isPresent(value)) {
- try {
- this._differ = this._iterableDiffers.find(value).create(this.virtualTrackBy);
- }
- catch (e) {
- throw new Error("Cannot find a differ supporting object '" + value + "'. VirtualScroll only supports binding to Iterables such as Arrays.");
- }
- }
- }
- };
- /**
- * @hidden
- */
- VirtualScroll.prototype.ngDoCheck = function () {
- // only continue if we've already initialized
- if (!this._init) {
- return;
- }
- // and if there actually are changes
- var changes = isPresent(this._differ) ? this._differ.diff(this.virtualScroll) : null;
- if (!isPresent(changes)) {
- return;
- }
- var needClean = false;
- var lastRecord = this._recordSize;
- changes.forEachOperation(function (_, pindex, cindex) {
- // add new record after current position
- if (pindex === null && (cindex < lastRecord)) {
- (void 0) /* console.debug */;
- needClean = true;
- return;
- }
- // remove record after current position
- if (pindex < lastRecord && cindex === null) {
- (void 0) /* console.debug */;
- needClean = true;
- return;
- }
- });
- this._recordSize = this._records ? this._records.length : 0;
- this.readUpdate(needClean);
- this.writeUpdate(needClean);
- };
- /**
- * @hidden
- */
- VirtualScroll.prototype.readUpdate = function (needClean) {
- if (needClean) {
- // reset everything
- (void 0) /* console.debug */;
- this._cells.length = 0;
- // this._nodes.length = 0;
- // this._itmTmp.viewContainer.clear();
- // ******** DOM READ ****************
- this.calcDimensions();
- }
- else {
- (void 0) /* console.debug */;
- }
- };
- /**
- * @hidden
- */
- VirtualScroll.prototype.writeUpdate = function (needClean) {
- (void 0) /* console.debug */;
- var data = this._data;
- var stopAtHeight = (data.scrollTop + data.renderHeight);
- data.scrollDiff = SCROLL_DIFFERENCE_MINIMUM + 1;
- processRecords(stopAtHeight, this._records, this._cells, this._hdrFn, this._ftrFn, this._data);
- // ******** DOM WRITE ****************
- this.renderVirtual(needClean);
- };
- /**
- * @hidden
- */
- VirtualScroll.prototype.calcDimensions = function () {
- calcDimensions(this._data, this._elementRef.nativeElement, this.approxItemWidth, this.approxItemHeight, this.approxHeaderWidth, this.approxHeaderHeight, this.approxFooterWidth, this.approxFooterHeight, this.bufferRatio);
- };
- /**
- * @hidden
- * DOM WRITE
- */
- VirtualScroll.prototype.renderVirtual = function (needClean) {
- var _this = this;
- this._plt.raf(function () {
- var nodes = _this._nodes;
- var cells = _this._cells;
- var data = _this._data;
- var records = _this._records;
- if (needClean) {
- // ******** DOM WRITE ****************
- updateDimensions(_this._plt, nodes, cells, data, true);
- data.topCell = 0;
- data.bottomCell = (cells.length - 1);
- }
- adjustRendered(cells, data);
- _this._zone.run(function () {
- populateNodeData(data.topCell, data.bottomCell, true, cells, records, nodes, _this._itmTmp.viewContainer, _this._itmTmp.templateRef, _this._hdrTmp && _this._hdrTmp.templateRef, _this._ftrTmp && _this._ftrTmp.templateRef);
- });
- if (needClean) {
- _this._cd.detectChanges();
- }
- // at this point, this fn was called from within another
- // requestAnimationFrame, so the next dom reads/writes within the next frame
- // wait a frame before trying to read and calculate the dimensions
- // ******** DOM READ ****************
- _this._dom.read(function () { return initReadNodes(_this._plt, nodes, cells, data); });
- _this._dom.write(function () {
- // update the bound context for each node
- updateNodeContext(nodes, cells, data);
- // ******** DOM WRITE ****************
- _this._stepChangeDetection();
- // ******** DOM WRITE ****************
- _this._stepDOMWrite();
- // ******** DOM WRITE ****************
- _this._content.imgsUpdate();
- // First time load
- if (!_this._lastEle) {
- // add an element at the end so :last-child css doesn't get messed up
- // ******** DOM WRITE ****************
- var ele = _this._elementRef.nativeElement;
- var lastEle = _this._renderer.createElement(ele, 'div');
- lastEle.className = 'virtual-last';
- _this._lastEle = true;
- // ******** DOM WRITE ****************
- _this.setElementClass('virtual-scroll', true);
- // ******** DOM WRITE ****************
- _this.setElementClass('virtual-loading', false);
- }
- (void 0) /* assert */;
- });
- });
- };
- /**
- * @hidden
- */
- VirtualScroll.prototype.resize = function () {
- // only continue if we've already initialized
- if (!this._init) {
- return;
- }
- // check if component is rendered in the dom currently
- if (this._elementRef.nativeElement.offsetParent === null) {
- return;
- }
- (void 0) /* console.debug */;
- this.calcDimensions();
- this.writeUpdate(false);
- };
- /**
- * @hidden
- */
- VirtualScroll.prototype._stepDOMWrite = function () {
- var cells = this._cells;
- var nodes = this._nodes;
- // ******** DOM WRITE ****************
- writeToNodes(this._plt, nodes, cells, this._recordSize);
- // ******** DOM WRITE ****************
- this._setHeight(estimateHeight(this._recordSize, cells[cells.length - 1], this._vHeight, 0.25));
- // we're done here, good work
- this._queue = 1 /* NoChanges */;
- };
- /**
- * @hidden
- */
- VirtualScroll.prototype._stepChangeDetection = function () {
- // we need to do some change detection in this frame
- // we've got work painting do, let's throw it in the
- // domWrite callback so everyone plays nice
- // ******** DOM WRITE ****************
- var nodes = this._nodes;
- for (var i = 0; i < nodes.length; i++) {
- if (nodes[i].hasChanges) {
- nodes[i].view.detectChanges();
- }
- }
- // on the next frame we need write to the dom nodes manually
- this._queue = 3 /* DomWrite */;
- };
- /**
- * @hidden
- */
- VirtualScroll.prototype._stepNoChanges = function () {
- var data = this._data;
- // let's see if we've scroll far enough to require another check
- var diff = data.scrollDiff = (data.scrollTop - this._lastCheck);
- if (Math.abs(diff) < SCROLL_DIFFERENCE_MINIMUM) {
- return;
- }
- var cells = this._cells;
- var nodes = this._nodes;
- var records = this._records;
- // don't bother updating if the scrollTop hasn't changed much
- this._lastCheck = data.scrollTop;
- if (diff > 0) {
- // load data we may not have processed yet
- var stopAtHeight = (data.scrollTop + data.renderHeight);
- processRecords(stopAtHeight, records, cells, this._hdrFn, this._ftrFn, data);
- }
- // ******** DOM READ ****************
- updateDimensions(this._plt, nodes, cells, data, false);
- adjustRendered(cells, data);
- var hasChanges = populateNodeData(data.topCell, data.bottomCell, diff > 0, cells, records, nodes, this._itmTmp.viewContainer, this._itmTmp.templateRef, this._hdrTmp && this._hdrTmp.templateRef, this._ftrTmp && this._ftrTmp.templateRef);
- if (hasChanges) {
- // queue making updates in the next frame
- this._queue = 2 /* ChangeDetection */;
- // update the bound context for each node
- updateNodeContext(nodes, cells, data);
- }
- };
- /**
- * @hidden
- */
- VirtualScroll.prototype.scrollUpdate = function (ev) {
- var _this = this;
- // set the scroll top from the scroll event
- this._data.scrollTop = ev.scrollTop;
- // there is a queue system so that we can
- // spread out the work over multiple frames
- var queue = this._queue;
- if (queue === 1 /* NoChanges */) {
- // no dom writes or change detection to take care of
- this._stepNoChanges();
- }
- else if (queue === 2 /* ChangeDetection */) {
- this._dom.write(function () { return _this._stepChangeDetection(); });
- }
- else {
- (void 0) /* assert */;
- // there are DOM writes we need to take care of in this frame
- this._dom.write(function () { return _this._stepDOMWrite(); });
- }
- };
- /**
- * @hidden
- * DOM WRITE
- */
- VirtualScroll.prototype.scrollEnd = function () {
- var _this = this;
- // ******** DOM READ ****************
- updateDimensions(this._plt, this._nodes, this._cells, this._data, false);
- adjustRendered(this._cells, this._data);
- populateNodeData(this._data.topCell, this._data.bottomCell, true, this._cells, this._records, this._nodes, this._itmTmp.viewContainer, this._itmTmp.templateRef, this._hdrTmp && this._hdrTmp.templateRef, this._ftrTmp && this._ftrTmp.templateRef);
- // ******** DOM WRITE ***************
- this._dom.write(function () {
- // update the bound context for each node
- updateNodeContext(_this._nodes, _this._cells, _this._data);
- // ******** DOM WRITE ***************
- _this._stepChangeDetection();
- // ******** DOM WRITE ****************
- _this._stepDOMWrite();
- });
- };
- /**
- * @hidden
- * NO DOM
- */
- VirtualScroll.prototype._listeners = function () {
- (void 0) /* assert */;
- if (!this._scrollSub) {
- if (this._config.getBoolean('virtualScrollEventAssist')) {
- // use JS scrolling for iOS UIWebView
- // goal is to completely remove this when iOS
- // fully supports scroll events
- // listen to JS scroll events
- this._content.enableJsScroll();
- }
- this._resizeSub = this._plt.resize.subscribe(this.resize.bind(this));
- this._scrollSub = this._content.ionScroll.subscribe(this.scrollUpdate.bind(this));
- this._scrollEndSub = this._content.ionScrollEnd.subscribe(this.scrollEnd.bind(this));
- }
- };
- /**
- * @hidden
- * DOM WRITE
- */
- VirtualScroll.prototype._setHeight = function (newVirtualHeight) {
- if (newVirtualHeight !== this._vHeight) {
- // ******** DOM WRITE ****************
- this._renderer.setElementStyle(this._elementRef.nativeElement, 'height', newVirtualHeight > 0 ? newVirtualHeight + 'px' : '');
- this._vHeight = newVirtualHeight;
- (void 0) /* console.debug */;
- }
- };
- /**
- * @hidden
- */
- VirtualScroll.prototype.ngAfterContentInit = function () {
- (void 0) /* assert */;
- if (!this.approxItemHeight) {
- this.approxItemHeight = '40px';
- console.warn('Virtual Scroll: Please provide an "approxItemHeight" input to ensure proper virtual scroll rendering');
- }
- };
- /**
- * @hidden
- */
- VirtualScroll.prototype.setElementClass = function (className, add) {
- this._renderer.setElementClass(this._elementRef.nativeElement, className, add);
- };
- /**
- * @hidden
- */
- VirtualScroll.prototype.ngOnDestroy = function () {
- this._resizeSub && this._resizeSub.unsubscribe();
- this._scrollSub && this._scrollSub.unsubscribe();
- this._scrollEndSub && this._scrollEndSub.unsubscribe();
- this._resizeSub = this._scrollEndSub = this._scrollSub = null;
- this._hdrFn = this._ftrFn = this._records = this._cells = this._nodes = this._data = null;
- };
- VirtualScroll.decorators = [
- { type: Directive, args: [{
- selector: '[virtualScroll]'
- },] },
- ];
- /** @nocollapse */
- VirtualScroll.ctorParameters = function () { return [
- { type: IterableDiffers, },
- { type: ElementRef, },
- { type: Renderer, },
- { type: NgZone, },
- { type: ChangeDetectorRef, },
- { type: Content, },
- { type: Platform, },
- { type: ViewController, },
- { type: Config, },
- { type: DomController, },
- ]; };
- VirtualScroll.propDecorators = {
- '_itmTmp': [{ type: ContentChild, args: [VirtualItem,] },],
- '_hdrTmp': [{ type: ContentChild, args: [VirtualHeader,] },],
- '_ftrTmp': [{ type: ContentChild, args: [VirtualFooter,] },],
- 'virtualScroll': [{ type: Input },],
- 'bufferRatio': [{ type: Input },],
- 'approxItemWidth': [{ type: Input },],
- 'approxItemHeight': [{ type: Input },],
- 'approxHeaderWidth': [{ type: Input },],
- 'approxHeaderHeight': [{ type: Input },],
- 'approxFooterWidth': [{ type: Input },],
- 'approxFooterHeight': [{ type: Input },],
- 'headerFn': [{ type: Input },],
- 'footerFn': [{ type: Input },],
- 'virtualTrackBy': [{ type: Input },],
- };
- return VirtualScroll;
- }());
- var SCROLL_DIFFERENCE_MINIMUM = 40;
-
- /**
- * @name IonicPage
- * @description
- * The Ionic Page handles registering and displaying specific pages based on URLs. It's used
- * underneath `NavController` so it will never have to be interacted with directly. When a new
- * page is pushed with `NavController`, the URL is updated to match the path to this page.
- *
- * Unlike traditional web apps, URLs don't dictate navigation in Ionic apps.
- * Instead, URLs help us link to specific pieces of content as a breadcrumb.
- * The current URL gets updated as we navigate, but we use the `NavController`
- * push and pop, or `NavPush` and `NavPop` to move around. This makes it much easier
- * to handle complicated nested navigation.
- *
- * We refer to our URL system as a deep link system instead of a router to encourage
- * Ionic developers to think of URLs as a breadcrumb rather than as the source of
- * truth in navigation. This encourages flexible navigation design and happy apps all
- * over the world.
- *
- *
- * @usage
- *
- * The first step to setting up deep links is to add the page that should be
- * a deep link in the `IonicPageModule.forChild` import of the page's module.
- * For our examples, this will be `MyPage`:
- *
- * ```ts
- * @NgModule({
- * declarations: [
- * MyPage
- * ],
- * imports: [
- * IonicPageModule.forChild(MyPage)
- * ],
- * entryComponents: [
- * MyPage
- * ]
- * })
- * export class MyPageModule {}
- * ```
- *
- * Then, add the `@IonicPage` decorator to the component. The most simple usage is adding an
- * empty decorator:
- *
- * ```ts
- * @IonicPage()
- * @Component({
- * templateUrl: 'main.html'
- * })
- * export class MyPage {}
- * ```
- *
- * This will automatically create a link to the `MyPage` component using the same name as the class,
- * `name`: `'MyPage'`. The page can now be navigated to by using this name. For example:
- *
- * ```ts
- * @Component({
- * templateUrl: 'another-page.html'
- * })
- * export class AnotherPage {
- * constructor(public navCtrl: NavController) {}
- *
- * goToMyPage() {
- * // go to the MyPage component
- * this.navCtrl.push('MyPage');
- * }
- * }
- * ```
- *
- * The `@IonicPage` decorator accepts a `DeepLinkMetadataType` object. This object accepts
- * the following properties: `name`, `segment`, `defaultHistory`, and `priority`. All of them
- * are optional but can be used to create complex navigation links.
- *
- *
- * ### Changing Name
- *
- * As mentioned previously, the `name` property will be set to the class name if it isn't provided.
- * Changing the name of the link is extremely simple. To change the name used to link to the
- * component, simply pass it in the decorator like so:
- *
- * ```ts
- * @IonicPage({
- * name: 'my-page'
- * })
- * ```
- *
- * This will create a link to the `MyPage` component using the name `'my-page'`. Similar to the previous
- * example, the page can be navigated to by using the name:
- *
- * ```ts
- * goToMyPage() {
- * // go to the MyPage component
- * this.navCtrl.push('my-page');
- * }
- * ```
- *
- *
- * ### Setting URL Path
- *
- * The `segment` property is used to set the URL to the page. If this property isn't provided, the
- * `segment` will use the value of `name`. Since components can be loaded anywhere in the app, the
- * `segment` doesn't require a full URL path. When a page becomes the active page, the `segment` is
- * appended to the URL.
- *
- * The `segment` can be changed to anything and doesn't have to match the `name`. For example, passing
- * a value for `name` and `segment`:
- *
- * ```ts
- * @IonicPage({
- * name: 'my-page',
- * segment: 'some-path'
- * })
- * ```
- *
- * When navigating to this page as the first page in the app, the URL will look something like:
- *
- * ```
- * http://localhost:8101/#/some-path
- * ```
- *
- * However, navigating to the page will still use the `name` like the previous examples do.
- *
- *
- * ### Dynamic Links
- *
- * The `segment` property is useful for creating dynamic links. Sometimes the URL isn't known ahead
- * of time, so it can be passed as a variable.
- *
- * Since passing data around is common practice in an app, it can be reflected in the app's URL by
- * using the `:param` syntax. For example, set the `segment` in the `@IonicPage` decorator:
- *
- * ```ts
- * @IonicPage({
- * name: 'detail-page',
- * segment: 'detail/:id'
- * })
- * ```
- *
- * In this case, when we `push` to a new instance of `'detail-page'`, the value of `id` will
- * in the `detailInfo` data being passed to `push` will replace `:id` in the URL.
- *
- * Important: The property needs to be something that can be converted into a string, objects
- * are not supported.
- *
- * For example, to push the `'detail-page'` in the `ListPage` component, the following code could
- * be used:
- *
- * ```ts
- * @IonicPage({
- * name: 'list'
- * })
- * export class ListPage {
- * constructor(public navCtrl: NavController) {}
- *
- * pushPage(detailInfo) {
- * // Push an `id` to the `'detail-page'`
- * this.navCtrl.push('detail-page', {
- * 'id': detailInfo.id
- * })
- * }
- * }
- * ```
- *
- * If the value of `detailInfo.id` is `12`, for example, the URL would end up looking like this:
- *
- * ```
- * http://localhost:8101/#/list/detail/12
- * ```
- *
- * Since this `id` will be used to pull in the data of the specific detail page, it's Important
- * that the `id` is unique.
- *
- * Note: Even though the `name` is `detail-page`, the `segment` uses `detail/:id`, and the URL
- * will use the `segment`.
- *
- *
- * ### Default History
- *
- * Pages can be navigated to using deep links from anywhere in the app, but sometimes the app is
- * launched from a URL and the page needs to have the same history as if it were navigated to from
- * inside of the app.
- *
- * By default, the page would be navigated to as the first page in the stack with no prior history.
- * A good example is the App Store on iOS. Clicking on a URL to an application in the App Store will
- * load the details of the application with no back button, as if it were the first page ever viewed.
- *
- * The default history of any page can be set in the `defaultHistory` property. This history will only
- * be used if the history doesn't already exist, meaning if you navigate to the page the history will
- * be the pages that were navigated from.
- *
- * The `defaultHistory` property takes an array of page names. The page names are specified as statically
- * analyzable strings (which means you must use strings and not variables or delared constants). If the
- * parent page does not have a `name` specified in its `IonicPage` decorator its name is its class name.
- *
- * For example, setting the history of the detail page to the list page where the `name` is `list`:
- *
- * ```ts
- * @IonicPage({
- * name: 'detail-page',
- * segment: 'detail/:id',
- * defaultHistory: ['list']
- * })
- * ```
- *
- * In this example, if the app is launched at `http://localhost:8101/#/detail/my-detail` the displayed page
- * will be the `'detail-page'` with an id of `my-detail` and it will show a back button that goes back to
- * the `'list'` page.
- *
- * For a deeper example:
- *
- * ```ts
- * @IonicPage({
- * segment: 'contact-more-info',
- * defaultHistory: ['ContactDetailPage', 'Contact']
- * })
- * ...
- * export class ContactMoreInfoPage {
- * ...
- * }
- * ```
- *
- * In this example, if the app is launched at `http://localhost:8101/#/contact/contact-more-info` the displayed page
- * will be the `'ContactMoreInfoPage'`. It will show a back button that will go to the `'ContactDetailPage'` which
- * will also show a back button which will go to the `'Constact'` page.
- *
- * An example of an application with a set history stack is the Instagram application. Opening a link
- * to an image on Instagram will show the details for that image with a back button to the user's profile
- * page. There is no "right" way of setting the history for a page, it is up to the application.
- *
- * ### Priority
- *
- * The `priority` property is only used during preloading. By default, preloading is turned off so setting
- * this property would do nothing. Preloading eagerly loads all deep links after the application boots
- * instead of on demand as needed. To enable preloading, set `preloadModules` in the main application module
- * config to `true`:
- *
- * ```ts
- * @NgModule({
- * declarations: [
- * MyApp
- * ],
- * imports: [
- * BrowserModule,
- * IonicModule.forRoot(MyApp, {
- * preloadModules: true
- * })
- * ],
- * bootstrap: [IonicApp],
- * entryComponents: [
- * MyApp
- * ]
- * })
- * export class AppModule { }
- * ```
- *
- * If preloading is turned on, it will load the modules based on the value of `priority`. The following
- * values are possible for `priority`: `"high"`, `"low"`, and `"off"`. When there is no `priority`, it
- * will be set to `"low"`.
- *
- * All deep links with their priority set to `"high"` will be loaded first. Upon completion of loading the
- * `"high"` priority modules, all deep links with a priority of `"low"` (or no priority) will be loaded. If
- * the priority is set to `"off"` the link will not be preloaded. Setting the `priority` is as simple as
- * passing it to the `@IonicPage` decorator:
- *
- * ```ts
- * @IonicPage({
- * name: 'my-page',
- * priority: 'high'
- * })
- * ```
- *
- * We recommend setting the `priority` to `"high"` on the pages that will be viewed first when launching
- * the application.
- *
- */
- function IonicPage(_config) {
- return function (clazz) {
- return clazz;
- };
- }
-
- function isActivatedDisabled(ev, activatableEle) {
- if (!activatableEle || !activatableEle.parentNode) {
- return true;
- }
- if (!ev) {
- return false;
- }
- if (ev.defaultPrevented) {
- return true;
- }
- var targetEle = ev.target;
- for (var i = 0; i < 4; i++) {
- if (!targetEle) {
- break;
- }
- if (targetEle.hasAttribute('disable-activated')) {
- return true;
- }
- targetEle = targetEle.parentElement;
- }
- return false;
- }
-
- var Activator = (function () {
- function Activator(app, config, dom) {
- this.app = app;
- this.dom = dom;
- this._queue = [];
- this._active = [];
- this.activatedDelay = ADD_ACTIVATED_DEFERS;
- this.clearDelay = CLEAR_STATE_DEFERS;
- this._css = config.get('activatedClass', 'activated');
- }
- Activator.prototype.clickAction = function (ev, activatableEle, _startCoord) {
- if (isActivatedDisabled(ev, activatableEle)) {
- return;
- }
- // a click happened, so immediately deactive all activated elements
- this._scheduleClear();
- this._queue.length = 0;
- for (var i = 0; i < this._active.length; i++) {
- this._active[i].classList.remove(this._css);
- }
- this._active.length = 0;
- // then immediately activate this element
- if (activatableEle && activatableEle.parentNode) {
- this._active.push(activatableEle);
- activatableEle.classList.add(this._css);
- }
- };
- Activator.prototype.downAction = function (ev, activatableEle, _startCoord) {
- var _this = this;
- // the user just pressed down
- if (isActivatedDisabled(ev, activatableEle)) {
- return;
- }
- this.unscheduleClear();
- this.deactivate(true);
- // queue to have this element activated
- this._queue.push(activatableEle);
- this._activeDefer = this.dom.write(function () {
- _this._activeDefer = null;
- var activatableEle;
- for (var i = 0; i < _this._queue.length; i++) {
- activatableEle = _this._queue[i];
- _this._active.push(activatableEle);
- activatableEle.classList.add(_this._css);
- }
- _this._queue.length = 0;
- }, this.activatedDelay);
- };
- // the user was pressing down, then just let up
- Activator.prototype.upAction = function (_ev, _activatableEle, _startCoord) {
- this._scheduleClear();
- };
- Activator.prototype._scheduleClear = function () {
- var _this = this;
- if (this._clearDefer) {
- return;
- }
- this._clearDefer = this.dom.write(function () {
- _this.clearState(true);
- _this._clearDefer = null;
- }, this.clearDelay);
- };
- Activator.prototype.unscheduleClear = function () {
- if (this._clearDefer) {
- this._clearDefer();
- this._clearDefer = null;
- }
- };
- // all states should return to normal
- Activator.prototype.clearState = function (animated) {
- var _this = this;
- if (!this.app.isEnabled()) {
- // the app is actively disabled, so don't bother deactivating anything.
- // this makes it easier on the GPU so it doesn't have to redraw any
- // buttons during a transition. This will retry in XX milliseconds.
- this.dom.write(function () {
- _this.clearState(animated);
- }, 600);
- }
- else {
- // not actively transitioning, good to deactivate any elements
- this.deactivate(animated);
- }
- };
- // remove the active class from all active elements
- Activator.prototype.deactivate = function (animated) {
- this._clearDeferred();
- this._queue.length = 0;
- var ele;
- for (var i = 0; i < this._active.length; i++) {
- ele = this._active[i];
- ele.style[this.dom.plt.Css.transition] = animated ? '' : 'none';
- ele.classList.remove(this._css);
- }
- this._active.length = 0;
- };
- Activator.prototype._clearDeferred = function () {
- // Clear any active deferral
- if (this._activeDefer) {
- this._activeDefer();
- this._activeDefer = null;
- }
- };
- return Activator;
- }());
- var ADD_ACTIVATED_DEFERS = 80;
- var CLEAR_STATE_DEFERS = 80;
-
- /**
- * @hidden
- */
- var RippleActivator = (function () {
- function RippleActivator(app, config, dom) {
- this.dom = dom;
- this.highlight = new Activator(app, config, dom);
- }
- RippleActivator.prototype.clickAction = function (ev, activatableEle, startCoord) {
- // Highlight
- this.highlight && this.highlight.clickAction(ev, activatableEle, startCoord);
- // Ripple
- this._clickAction(ev, activatableEle, startCoord);
- };
- RippleActivator.prototype.downAction = function (ev, activatableEle, startCoord) {
- // Highlight
- this.highlight && this.highlight.downAction(ev, activatableEle, startCoord);
- // Ripple
- this._downAction(ev, activatableEle, startCoord);
- };
- RippleActivator.prototype.upAction = function (ev, activatableEle, startCoord) {
- // Highlight
- this.highlight && this.highlight.upAction(ev, activatableEle, startCoord);
- // Ripple
- this._upAction(ev, activatableEle, startCoord);
- };
- RippleActivator.prototype.clearState = function (animated) {
- // Highlight
- this.highlight && this.highlight.clearState(animated);
- };
- RippleActivator.prototype._downAction = function (ev, activatableEle, _startCoord) {
- if (isActivatedDisabled(ev, activatableEle)) {
- return;
- }
- var j = activatableEle.childElementCount;
- while (j--) {
- var rippleEle = activatableEle.children[j];
- if (rippleEle.classList.contains('button-effect')) {
- // DOM READ
- var clientRect = activatableEle.getBoundingClientRect();
- rippleEle.$top = clientRect.top;
- rippleEle.$left = clientRect.left;
- rippleEle.$width = clientRect.width;
- rippleEle.$height = clientRect.height;
- break;
- }
- }
- };
- RippleActivator.prototype._upAction = function (ev, activatableEle, startCoord) {
- if (!hasPointerMoved(6, startCoord, pointerCoord(ev))) {
- var i = activatableEle.childElementCount;
- while (i--) {
- var rippleEle = activatableEle.children[i];
- if (rippleEle.classList.contains('button-effect')) {
- // DOM WRITE
- this.startRippleEffect(rippleEle, activatableEle, startCoord);
- break;
- }
- }
- }
- };
- RippleActivator.prototype._clickAction = function (_ev, _activatableEle, _startCoord) {
- // NOTHING
- };
- RippleActivator.prototype.startRippleEffect = function (rippleEle, activatableEle, startCoord) {
- if (!startCoord) {
- return;
- }
- var clientPointerX = (startCoord.x - rippleEle.$left);
- var clientPointerY = (startCoord.y - rippleEle.$top);
- var x = Math.max(Math.abs(rippleEle.$width - clientPointerX), clientPointerX) * 2;
- var y = Math.max(Math.abs(rippleEle.$height - clientPointerY), clientPointerY) * 2;
- var diameter = Math.min(Math.max(Math.hypot(x, y), 64), 240);
- if (activatableEle.hasAttribute('ion-item')) {
- diameter = Math.min(diameter, 140);
- }
- clientPointerX -= diameter / 2;
- clientPointerY -= diameter / 2;
- clientPointerX = Math.round(clientPointerX);
- clientPointerY = Math.round(clientPointerY);
- diameter = Math.round(diameter);
- // Reset ripple
- // DOM WRITE
- var Css = this.dom.plt.Css;
- rippleEle.style.opacity = '';
- rippleEle.style[Css.transform] = "translate3d(" + clientPointerX + "px, " + clientPointerY + "px, 0px) scale(0.001)";
- rippleEle.style[Css.transition] = '';
- // Start ripple animation
- var radius = Math.sqrt(rippleEle.$width + rippleEle.$height);
- var scaleTransitionDuration = Math.max(1600 * Math.sqrt(radius / TOUCH_DOWN_ACCEL) + 0.5, 260);
- var opacityTransitionDuration = Math.round(scaleTransitionDuration * 0.7);
- var opacityTransitionDelay = Math.round(scaleTransitionDuration - opacityTransitionDuration);
- scaleTransitionDuration = Math.round(scaleTransitionDuration);
- var transform = "translate3d(" + clientPointerX + "px, " + clientPointerY + "px, 0px) scale(1)";
- var transition = "transform " + scaleTransitionDuration + "ms,opacity " + opacityTransitionDuration + "ms " + opacityTransitionDelay + "ms";
- this.dom.write(function () {
- // DOM WRITE
- rippleEle.style.width = rippleEle.style.height = diameter + 'px';
- rippleEle.style.opacity = '0';
- rippleEle.style[Css.transform] = transform;
- rippleEle.style[Css.transition] = transition;
- }, 16);
- };
- return RippleActivator;
- }());
- var TOUCH_DOWN_ACCEL = 300;
-
- /**
- * @hidden
- */
- var TapClick = (function () {
- function TapClick(config, plt, dom, app, gestureCtrl) {
- this.plt = plt;
- this.app = app;
- this.gestureCtrl = gestureCtrl;
- this.disableClick = 0;
- this.events = new UIEventManager(plt);
- var activator = config.get('activator');
- if (activator === 'ripple') {
- this.activator = new RippleActivator(app, config, dom);
- }
- else if (activator === 'highlight') {
- this.activator = new Activator(app, config, dom);
- }
- this.usePolyfill = config.getBoolean('tapPolyfill');
- (void 0) /* console.debug */;
- var doc = plt.doc();
- this.events.listen(doc, 'click', this.click.bind(this), { passive: false, capture: true });
- this.pointerEvents = this.events.pointerEvents({
- element: doc,
- pointerDown: this.pointerStart.bind(this),
- pointerMove: this.pointerMove.bind(this),
- pointerUp: this.pointerEnd.bind(this),
- passive: true
- });
- this.pointerEvents.mouseWait = DISABLE_NATIVE_CLICK_AMOUNT;
- }
- TapClick.prototype.pointerStart = function (ev) {
- if (this.startCoord) {
- return false;
- }
- if (!this.app.isEnabled()) {
- return false;
- }
- this.lastTouchEnd = 0;
- this.dispatchClick = true;
- if (this.plt.doc() === ev.target) {
- this.startCoord = pointerCoord(ev);
- return true;
- }
- this.activatableEle = getActivatableTarget(ev.target);
- if (!this.activatableEle) {
- this.startCoord = null;
- return false;
- }
- this.startCoord = pointerCoord(ev);
- this.activator && this.activator.downAction(ev, this.activatableEle, this.startCoord);
- return true;
- };
- TapClick.prototype.pointerMove = function (ev) {
- if (this.startCoord && this.shouldCancelEvent(ev)) {
- this.pointerCancel(ev);
- }
- };
- TapClick.prototype.pointerEnd = function (ev, pointerEventType) {
- if (!this.dispatchClick)
- return;
- (void 0) /* runInDev */;
- if (!this.startCoord) {
- return;
- }
- if (this.activator && ev.target !== this.plt.doc()) {
- var activatableEle = getActivatableTarget(ev.target) || this.activatableEle;
- if (activatableEle) {
- this.activator.upAction(ev, activatableEle, this.startCoord);
- }
- }
- if (this.usePolyfill && pointerEventType === POINTER_EVENT_TYPE_TOUCH && this.app.isEnabled()) {
- this.handleTapPolyfill(ev);
- }
- this.startCoord = null;
- this.activatableEle = null;
- };
- TapClick.prototype.pointerCancel = function (ev) {
- (void 0) /* console.debug */;
- this.startCoord = null;
- this.activatableEle = null;
- this.dispatchClick = false;
- this.activator && this.activator.clearState(false);
- this.pointerEvents.stop();
- };
- TapClick.prototype.shouldCancelEvent = function (ev) {
- return (this.app.isScrolling() ||
- this.gestureCtrl.isCaptured() ||
- hasPointerMoved(POINTER_TOLERANCE, this.startCoord, pointerCoord(ev)));
- };
- TapClick.prototype.click = function (ev) {
- if (this.shouldCancelClick(ev)) {
- ev.preventDefault();
- ev.stopPropagation();
- return;
- }
- if (this.activator && this.plt.doc() !== ev.target) {
- // cool, a click is gonna happen, let's tell the activator
- // so the element can get the given "active" style
- var activatableEle = getActivatableTarget(ev.target);
- if (activatableEle) {
- this.activator.clickAction(ev, activatableEle, this.startCoord);
- }
- }
- (void 0) /* runInDev */;
- };
- TapClick.prototype.shouldCancelClick = function (ev) {
- if (this.usePolyfill) {
- if (!ev.isIonicTap && this.isDisabledNativeClick()) {
- (void 0) /* console.debug */;
- return true;
- }
- }
- else if (!this.dispatchClick) {
- (void 0) /* console.debug */;
- return true;
- }
- if (!this.app.isEnabled()) {
- (void 0) /* console.debug */;
- return true;
- }
- if (this.gestureCtrl.isCaptured()) {
- (void 0) /* console.debug */;
- return true;
- }
- return false;
- };
- TapClick.prototype.profileClickDelay = function (ev) {
- if (this.lastTouchEnd) {
- var diff = Date.now() - this.lastTouchEnd;
- if (diff < 100) {
- (void 0) /* console.debug */;
- }
- else {
- console.warn("SLOW click dispatched. Delay(ms):", diff, ev);
- }
- this.lastTouchEnd = null;
- }
- else {
- (void 0) /* console.debug */;
- }
- };
- TapClick.prototype.handleTapPolyfill = function (ev) {
- (void 0) /* assert */;
- // only dispatch mouse click events from a touchend event
- // when tapPolyfill config is true, and the startCoordand endCoord
- // are not too far off from each other
- var endCoord = pointerCoord(ev);
- if (hasPointerMoved(POINTER_TOLERANCE, this.startCoord, endCoord)) {
- (void 0) /* console.debug */;
- return;
- }
- // prevent native mouse click events for XX amount of time
- this.disableClick = Date.now() + DISABLE_NATIVE_CLICK_AMOUNT;
- if (this.app.isScrolling()) {
- // do not fire off a click event while the app was scrolling
- (void 0) /* console.debug */;
- }
- else {
- // dispatch a mouse click event
- (void 0) /* console.debug */;
- var clickEvent = this.plt.doc().createEvent('MouseEvents');
- clickEvent.initMouseEvent('click', true, true, this.plt.win(), 1, 0, 0, endCoord.x, endCoord.y, false, false, false, false, 0, null);
- clickEvent.isIonicTap = true;
- ev.target.dispatchEvent(clickEvent);
- }
- };
- TapClick.prototype.isDisabledNativeClick = function () {
- return this.disableClick > Date.now();
- };
- TapClick.decorators = [
- { type: Injectable },
- ];
- /** @nocollapse */
- TapClick.ctorParameters = function () { return [
- { type: Config, },
- { type: Platform, },
- { type: DomController, },
- { type: App, },
- { type: GestureController, },
- ]; };
- return TapClick;
- }());
- function getActivatableTarget(ele) {
- var targetEle = ele;
- for (var x = 0; x < 10; x++) {
- if (!targetEle)
- break;
- if (isActivatable(targetEle)) {
- return targetEle;
- }
- targetEle = targetEle.parentElement;
- }
- return null;
- }
- /**
- * @hidden
- */
- function isActivatable(ele) {
- if (ACTIVATABLE_ELEMENTS.indexOf(ele.tagName) > -1) {
- return true;
- }
- for (var i = 0, l = ACTIVATABLE_ATTRIBUTES.length; i < l; i++) {
- if (ele.hasAttribute && ele.hasAttribute(ACTIVATABLE_ATTRIBUTES[i])) {
- return true;
- }
- }
- return false;
- }
- var ACTIVATABLE_ELEMENTS = ['A', 'BUTTON'];
- var ACTIVATABLE_ATTRIBUTES = ['tappable', 'ion-button'];
- var POINTER_TOLERANCE = 100;
- var DISABLE_NATIVE_CLICK_AMOUNT = 2500;
- /**
- * @hidden
- */
- function setupTapClick(config, plt, dom, app, gestureCtrl) {
- return function () {
- return new TapClick(config, plt, dom, app, gestureCtrl);
- };
- }
-
- /* tslint:disable */
- var win$1 = window;
- var doc = document;
- /*! Hammer.JS - v2.0.6 - 2015-12-23
- * http://hammerjs.github.io/
- *
- * Copyright (c) 2015 Jorik Tangelder;
- * Licensed under the license */
- var VENDOR_PREFIXES = ['', 'webkit', 'Moz', 'MS', 'ms', 'o'];
- var TEST_ELEMENT = doc.createElement('div');
- var TYPE_FUNCTION = 'function';
- var round$1 = Math.round;
- var abs = Math.abs;
- var now = Date.now;
- /**
- * set a timeout with a given scope
- * @param {Function} fn
- * @param {Number} timeout
- * @param {Object} context
- * @returns {number}
- */
- function setTimeoutContext(fn, timeout, context) {
- return setTimeout(bindFn(fn, context), timeout);
- }
- /**
- * if the argument is an array, we want to execute the fn on each entry
- * if it aint an array we don't want to do a thing.
- * this is used by all the methods that accept a single and array argument.
- * @param {*|Array} arg
- * @param {String} fn
- * @param {Object} [context]
- * @returns {Boolean}
- */
- function invokeArrayArg(arg, fn, context) {
- if (Array.isArray(arg)) {
- each(arg, context[fn], context);
- return true;
- }
- return false;
- }
- /**
- * walk objects and arrays
- * @param {Object} obj
- * @param {Function} iterator
- * @param {Object} context
- */
- function each(obj, iterator, context) {
- var i;
- if (!obj) {
- return;
- }
- if (obj.forEach) {
- obj.forEach(iterator, context);
- }
- else if (obj.length !== undefined) {
- i = 0;
- while (i < obj.length) {
- iterator.call(context, obj[i], i, obj);
- i++;
- }
- }
- else {
- for (i in obj) {
- obj.hasOwnProperty(i) && iterator.call(context, obj[i], i, obj);
- }
- }
- }
- /**
- * simple class inheritance
- * @param {Function} child
- * @param {Function} base
- * @param {Object} [properties]
- */
- function inherit(child, base, properties) {
- var baseP = base.prototype, childP;
- childP = child.prototype = Object.create(baseP);
- childP.constructor = child;
- childP._super = baseP;
- if (properties) {
- Object.assign(childP, properties);
- }
- }
- /**
- * simple function bind
- * @param {Function} fn
- * @param {Object} context
- * @returns {Function}
- */
- function bindFn(fn, context) {
- return function boundFn() {
- return fn.apply(context, arguments);
- };
- }
- /**
- * let a boolean value also be a function that must return a boolean
- * this first item in args will be used as the context
- * @param {Boolean|Function} val
- * @param {Array} [args]
- * @returns {Boolean}
- */
- function boolOrFn(val, args) {
- if (typeof val == TYPE_FUNCTION) {
- return val.apply(args ? args[0] || undefined : undefined, args);
- }
- return val;
- }
- /**
- * use the val2 when val1 is undefined
- * @param {*} val1
- * @param {*} val2
- * @returns {*}
- */
- function ifUndefined(val1, val2) {
- return (val1 === undefined) ? val2 : val1;
- }
- /**
- * addEventListener with multiple events at once
- * @param {EventTarget} target
- * @param {String} types
- * @param {Function} handler
- */
- function addEventListeners(target, types, handler) {
- each(splitStr(types), function (type) {
- target.addEventListener(type, handler, false);
- });
- }
- /**
- * removeEventListener with multiple events at once
- * @param {EventTarget} target
- * @param {String} types
- * @param {Function} handler
- */
- function removeEventListeners(target, types, handler) {
- each(splitStr(types), function (type) {
- target.removeEventListener(type, handler, false);
- });
- }
- /**
- * find if a node is in the given parent
- * @method hasParent
- * @param {HTMLElement} node
- * @param {HTMLElement} parent
- * @return {Boolean} found
- */
- function hasParent(node, parent) {
- while (node) {
- if (node == parent) {
- return true;
- }
- node = node.parentNode;
- }
- return false;
- }
- /**
- * small indexOf wrapper
- * @param {String} str
- * @param {String} find
- * @returns {Boolean} found
- */
- function inStr(str, find) {
- return str.indexOf(find) > -1;
- }
- /**
- * split string on whitespace
- * @param {String} str
- * @returns {Array} words
- */
- function splitStr(str) {
- return str.trim().split(/\s+/g);
- }
- /**
- * find if a array contains the object using indexOf or a simple polyFill
- * @param {Array} src
- * @param {String} find
- * @param {String} [findByKey]
- * @return {Boolean|Number} false when not found, or the index
- */
- function inArray(src, find, findByKey) {
- if (src.indexOf && !findByKey) {
- return src.indexOf(find);
- }
- else {
- var i = 0;
- while (i < src.length) {
- if ((findByKey && src[i][findByKey] == find) || (!findByKey && src[i] === find)) {
- return i;
- }
- i++;
- }
- return -1;
- }
- }
- /**
- * convert array-like objects to real arrays
- * @param {Object} obj
- * @returns {Array}
- */
- function toArray(obj) {
- return Array.prototype.slice.call(obj, 0);
- }
- /**
- * unique array with objects based on a key (like 'id') or just by the array's value
- * @param {Array} src [{id:1},{id:2},{id:1}]
- * @param {String} [key]
- * @param {Boolean} [sort=False]
- * @returns {Array} [{id:1},{id:2}]
- */
- function uniqueArray(src, key, sort) {
- var results = [];
- var values = [];
- var i = 0;
- while (i < src.length) {
- var val = key ? src[i][key] : src[i];
- if (inArray(values, val) < 0) {
- results.push(src[i]);
- }
- values[i] = val;
- i++;
- }
- if (sort) {
- if (!key) {
- results = results.sort();
- }
- else {
- results = results.sort(function sortUniqueArray(a, b) {
- return a[key] > b[key] ? 1 : 0;
- });
- }
- }
- return results;
- }
- /**
- * get the prefixed property
- * @param {Object} obj
- * @param {String} property
- * @returns {String|Undefined} prefixed
- */
- function prefixed(obj, property) {
- var prefix, prop;
- var camelProp = property[0].toUpperCase() + property.slice(1);
- var i = 0;
- while (i < VENDOR_PREFIXES.length) {
- prefix = VENDOR_PREFIXES[i];
- prop = (prefix) ? prefix + camelProp : property;
- if (prop in obj) {
- return prop;
- }
- i++;
- }
- return undefined;
- }
- /**
- * get a unique id
- * @returns {number} uniqueId
- */
- var _uniqueId = 1;
- function uniqueId() {
- return _uniqueId++;
- }
- /**
- * get the window object of an element
- * @param {HTMLElement} element
- * @returns {DocumentView|Window}
- */
- function getWindowForElement(element) {
- var doc = element.ownerDocument || element;
- return (doc.defaultView || doc.parentWindow || window);
- }
- var MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android/i;
- var SUPPORT_TOUCH = ('ontouchstart' in window);
- var SUPPORT_POINTER_EVENTS = prefixed(window, 'PointerEvent') !== undefined;
- var SUPPORT_ONLY_TOUCH = SUPPORT_TOUCH && MOBILE_REGEX.test(navigator.userAgent);
- var INPUT_TYPE_TOUCH = 'touch';
- var INPUT_TYPE_PEN = 'pen';
- var INPUT_TYPE_MOUSE = 'mouse';
- var INPUT_TYPE_KINECT = 'kinect';
- var COMPUTE_INTERVAL = 25;
- var INPUT_START = 1;
- var INPUT_MOVE = 2;
- var INPUT_END = 4;
- var INPUT_CANCEL = 8;
- var DIRECTION_NONE = 1;
- var DIRECTION_LEFT = 2;
- var DIRECTION_RIGHT = 4;
- var DIRECTION_UP = 8;
- var DIRECTION_DOWN = 16;
- var DIRECTION_HORIZONTAL = DIRECTION_LEFT | DIRECTION_RIGHT;
- var DIRECTION_VERTICAL = DIRECTION_UP | DIRECTION_DOWN;
- var DIRECTION_ALL = DIRECTION_HORIZONTAL | DIRECTION_VERTICAL;
- var PROPS_XY = ['x', 'y'];
- var PROPS_CLIENT_XY = ['clientX', 'clientY'];
- /**
- * create new input type manager
- * @param {Manager} manager
- * @param {Function} callback
- * @returns {Input}
- * @constructor
- */
- function Input$1(manager, callback) {
- var self = this;
- this.manager = manager;
- this.callback = callback;
- this.element = manager.element;
- this.target = manager.options.inputTarget;
- // smaller wrapper around the handler, for the scope and the enabled state of the manager,
- // so when disabled the input events are completely bypassed.
- this.domHandler = function (ev) {
- if (boolOrFn(manager.options.enable, [manager])) {
- self.handler(ev);
- }
- };
- this.init();
- }
- Input$1.prototype = {
- /**
- * should handle the inputEvent data and trigger the callback
- * @virtual
- */
- handler: function () { },
- /**
- * bind the events
- */
- init: function () {
- this.evEl && addEventListeners(this.element, this.evEl, this.domHandler);
- this.evTarget && addEventListeners(this.target, this.evTarget, this.domHandler);
- this.evWin && addEventListeners(getWindowForElement(this.element), this.evWin, this.domHandler);
- },
- /**
- * unbind the events
- */
- destroy: function () {
- this.evEl && removeEventListeners(this.element, this.evEl, this.domHandler);
- this.evTarget && removeEventListeners(this.target, this.evTarget, this.domHandler);
- this.evWin && removeEventListeners(getWindowForElement(this.element), this.evWin, this.domHandler);
- }
- };
- /**
- * create new input type manager
- * called by the Manager constructor
- * @param {Hammer} manager
- * @returns {Input}
- */
- function createInputInstance(manager) {
- var Type;
- var inputClass = manager.options.inputClass;
- if (inputClass) {
- Type = inputClass;
- }
- else if (SUPPORT_POINTER_EVENTS) {
- Type = PointerEventInput;
- }
- else if (SUPPORT_ONLY_TOUCH) {
- Type = TouchInput;
- }
- else if (!SUPPORT_TOUCH) {
- Type = MouseInput;
- }
- else {
- Type = TouchMouseInput;
- }
- return new (Type)(manager, inputHandler);
- }
- /**
- * handle input events
- * @param {Manager} manager
- * @param {String} eventType
- * @param {Object} input
- */
- function inputHandler(manager, eventType, input) {
- var pointersLen = input.pointers.length;
- var changedPointersLen = input.changedPointers.length;
- var isFirst = (eventType & INPUT_START && (pointersLen - changedPointersLen === 0));
- var isFinal = (eventType & (INPUT_END | INPUT_CANCEL) && (pointersLen - changedPointersLen === 0));
- input.isFirst = !!isFirst;
- input.isFinal = !!isFinal;
- if (isFirst) {
- manager.session = {};
- }
- // source event is the normalized value of the domEvents
- // like 'touchstart, mouseup, pointerdown'
- input.eventType = eventType;
- // compute scale, rotation etc
- computeInputData(manager, input);
- // emit secret event
- manager.emit('hammer.input', input);
- manager.recognize(input);
- manager.session.prevInput = input;
- }
- /**
- * extend the data with some usable properties like scale, rotate, velocity etc
- * @param {Object} manager
- * @param {Object} input
- */
- function computeInputData(manager, input) {
- var session = manager.session;
- var pointers = input.pointers;
- var pointersLength = pointers.length;
- // store the first input to calculate the distance and direction
- if (!session.firstInput) {
- session.firstInput = simpleCloneInputData(input);
- }
- // to compute scale and rotation we need to store the multiple touches
- if (pointersLength > 1 && !session.firstMultiple) {
- session.firstMultiple = simpleCloneInputData(input);
- }
- else if (pointersLength === 1) {
- session.firstMultiple = false;
- }
- var firstInput = session.firstInput;
- var firstMultiple = session.firstMultiple;
- var offsetCenter = firstMultiple ? firstMultiple.center : firstInput.center;
- var center = input.center = getCenter(pointers);
- input.timeStamp = now();
- input.deltaTime = input.timeStamp - firstInput.timeStamp;
- input.angle = getAngle(offsetCenter, center);
- input.distance = getDistance(offsetCenter, center);
- computeDeltaXY(session, input);
- input.offsetDirection = getDirection(input.deltaX, input.deltaY);
- var overallVelocity = getVelocity(input.deltaTime, input.deltaX, input.deltaY);
- input.overallVelocityX = overallVelocity.x;
- input.overallVelocityY = overallVelocity.y;
- input.overallVelocity = (abs(overallVelocity.x) > abs(overallVelocity.y)) ? overallVelocity.x : overallVelocity.y;
- input.scale = firstMultiple ? getScale(firstMultiple.pointers, pointers) : 1;
- input.rotation = firstMultiple ? getRotation(firstMultiple.pointers, pointers) : 0;
- input.maxPointers = !session.prevInput ? input.pointers.length : ((input.pointers.length >
- session.prevInput.maxPointers) ? input.pointers.length : session.prevInput.maxPointers);
- computeIntervalInputData(session, input);
- // find the correct target
- var target = manager.element;
- if (hasParent(input.srcEvent.target, target)) {
- target = input.srcEvent.target;
- }
- input.target = target;
- }
- function computeDeltaXY(session, input) {
- var center = input.center;
- var offset = session.offsetDelta || {};
- var prevDelta = session.prevDelta || {};
- var prevInput = session.prevInput || {};
- if (input.eventType === INPUT_START || prevInput.eventType === INPUT_END) {
- prevDelta = session.prevDelta = {
- x: prevInput.deltaX || 0,
- y: prevInput.deltaY || 0
- };
- offset = session.offsetDelta = {
- x: center.x,
- y: center.y
- };
- }
- input.deltaX = prevDelta.x + (center.x - offset.x);
- input.deltaY = prevDelta.y + (center.y - offset.y);
- }
- /**
- * velocity is calculated every x ms
- * @param {Object} session
- * @param {Object} input
- */
- function computeIntervalInputData(session, input) {
- var last = session.lastInterval || input, deltaTime = input.timeStamp - last.timeStamp, velocity, velocityX, velocityY, direction;
- if (input.eventType != INPUT_CANCEL && (deltaTime > COMPUTE_INTERVAL || last.velocity === undefined)) {
- var deltaX = input.deltaX - last.deltaX;
- var deltaY = input.deltaY - last.deltaY;
- var v = getVelocity(deltaTime, deltaX, deltaY);
- velocityX = v.x;
- velocityY = v.y;
- velocity = (abs(v.x) > abs(v.y)) ? v.x : v.y;
- direction = getDirection(deltaX, deltaY);
- session.lastInterval = input;
- }
- else {
- // use latest velocity info if it doesn't overtake a minimum period
- velocity = last.velocity;
- velocityX = last.velocityX;
- velocityY = last.velocityY;
- direction = last.direction;
- }
- input.velocity = velocity;
- input.velocityX = velocityX;
- input.velocityY = velocityY;
- input.direction = direction;
- }
- /**
- * create a simple clone from the input used for storage of firstInput and firstMultiple
- * @param {Object} input
- * @returns {Object} clonedInputData
- */
- function simpleCloneInputData(input) {
- // make a simple copy of the pointers because we will get a reference if we don't
- // we only need clientXY for the calculations
- var pointers = [];
- var i = 0;
- while (i < input.pointers.length) {
- pointers[i] = {
- clientX: round$1(input.pointers[i].clientX),
- clientY: round$1(input.pointers[i].clientY)
- };
- i++;
- }
- return {
- timeStamp: now(),
- pointers: pointers,
- center: getCenter(pointers),
- deltaX: input.deltaX,
- deltaY: input.deltaY
- };
- }
- /**
- * get the center of all the pointers
- * @param {Array} pointers
- * @return {Object} center contains `x` and `y` properties
- */
- function getCenter(pointers) {
- var pointersLength = pointers.length;
- // no need to loop when only one touch
- if (pointersLength === 1) {
- return {
- x: round$1(pointers[0].clientX),
- y: round$1(pointers[0].clientY)
- };
- }
- var x = 0, y = 0, i = 0;
- while (i < pointersLength) {
- x += pointers[i].clientX;
- y += pointers[i].clientY;
- i++;
- }
- return {
- x: round$1(x / pointersLength),
- y: round$1(y / pointersLength)
- };
- }
- /**
- * calculate the velocity between two points. unit is in px per ms.
- * @param {Number} deltaTime
- * @param {Number} x
- * @param {Number} y
- * @return {Object} velocity `x` and `y`
- */
- function getVelocity(deltaTime, x, y) {
- return {
- x: x / deltaTime || 0,
- y: y / deltaTime || 0
- };
- }
- /**
- * get the direction between two points
- * @param {Number} x
- * @param {Number} y
- * @return {Number} direction
- */
- function getDirection(x, y) {
- if (x === y) {
- return DIRECTION_NONE;
- }
- if (abs(x) >= abs(y)) {
- return x < 0 ? DIRECTION_LEFT : DIRECTION_RIGHT;
- }
- return y < 0 ? DIRECTION_UP : DIRECTION_DOWN;
- }
- /**
- * calculate the absolute distance between two points
- * @param {Object} p1 {x, y}
- * @param {Object} p2 {x, y}
- * @param {Array} [props] containing x and y keys
- * @return {Number} distance
- */
- function getDistance(p1, p2, props) {
- if (!props) {
- props = PROPS_XY;
- }
- var x = p2[props[0]] - p1[props[0]], y = p2[props[1]] - p1[props[1]];
- return Math.sqrt((x * x) + (y * y));
- }
- /**
- * calculate the angle between two coordinates
- * @param {Object} p1
- * @param {Object} p2
- * @param {Array} [props] containing x and y keys
- * @return {Number} angle
- */
- function getAngle(p1, p2, props) {
- if (!props) {
- props = PROPS_XY;
- }
- var x = p2[props[0]] - p1[props[0]], y = p2[props[1]] - p1[props[1]];
- return Math.atan2(y, x) * 180 / Math.PI;
- }
- /**
- * calculate the rotation degrees between two pointersets
- * @param {Array} start array of pointers
- * @param {Array} end array of pointers
- * @return {Number} rotation
- */
- function getRotation(start, end) {
- return getAngle(end[1], end[0], PROPS_CLIENT_XY) + getAngle(start[1], start[0], PROPS_CLIENT_XY);
- }
- /**
- * calculate the scale factor between two pointersets
- * no scale is 1, and goes down to 0 when pinched together, and bigger when pinched out
- * @param {Array} start array of pointers
- * @param {Array} end array of pointers
- * @return {Number} scale
- */
- function getScale(start, end) {
- return getDistance(end[0], end[1], PROPS_CLIENT_XY) / getDistance(start[0], start[1], PROPS_CLIENT_XY);
- }
- var MOUSE_INPUT_MAP = {
- mousedown: INPUT_START,
- mousemove: INPUT_MOVE,
- mouseup: INPUT_END
- };
- var MOUSE_ELEMENT_EVENTS = 'mousedown';
- var MOUSE_WINDOW_EVENTS = 'mousemove mouseup';
- /**
- * Mouse events input
- * @constructor
- * @extends Input
- */
- function MouseInput(_manager, _handler) {
- this.evEl = MOUSE_ELEMENT_EVENTS;
- this.evWin = MOUSE_WINDOW_EVENTS;
- this.allow = true; // used by Input.TouchMouse to disable mouse events
- this.pressed = false; // mousedown state
- Input$1.apply(this, arguments);
- }
- inherit(MouseInput, Input$1, {
- /**
- * handle mouse events
- * @param {Object} ev
- */
- handler: function MEhandler(ev) {
- var eventType = MOUSE_INPUT_MAP[ev.type];
- // on start we want to have the left mouse button down
- if (eventType & INPUT_START && ev.button === 0) {
- this.pressed = true;
- }
- if (eventType & INPUT_MOVE && ev.which !== 1) {
- eventType = INPUT_END;
- }
- // mouse must be down, and mouse events are allowed (see the TouchMouse input)
- if (!this.pressed || !this.allow) {
- return;
- }
- if (eventType & INPUT_END) {
- this.pressed = false;
- }
- this.callback(this.manager, eventType, {
- pointers: [ev],
- changedPointers: [ev],
- pointerType: INPUT_TYPE_MOUSE,
- srcEvent: ev
- });
- }
- });
- var POINTER_INPUT_MAP = {
- pointerdown: INPUT_START,
- pointermove: INPUT_MOVE,
- pointerup: INPUT_END,
- pointercancel: INPUT_CANCEL,
- pointerout: INPUT_CANCEL
- };
- // in IE10 the pointer types is defined as an enum
- var IE10_POINTER_TYPE_ENUM = {
- 2: INPUT_TYPE_TOUCH,
- 3: INPUT_TYPE_PEN,
- 4: INPUT_TYPE_MOUSE,
- 5: INPUT_TYPE_KINECT // see https://twitter.com/jacobrossi/status/480596438489890816
- };
- var POINTER_ELEMENT_EVENTS = 'pointerdown';
- var POINTER_WINDOW_EVENTS = 'pointermove pointerup pointercancel';
- // IE10 has prefixed support, and case-sensitive
- if (win$1.MSPointerEvent && !win$1.PointerEvent) {
- POINTER_ELEMENT_EVENTS = 'MSPointerDown';
- POINTER_WINDOW_EVENTS = 'MSPointerMove MSPointerUp MSPointerCancel';
- }
- /**
- * Pointer events input
- * @constructor
- * @extends Input
- */
- function PointerEventInput() {
- this.evEl = POINTER_ELEMENT_EVENTS;
- this.evWin = POINTER_WINDOW_EVENTS;
- Input$1.apply(this, arguments);
- this.store = (this.manager.session.pointerEvents = []);
- }
- inherit(PointerEventInput, Input$1, {
- /**
- * handle mouse events
- * @param {Object} ev
- */
- handler: function PEhandler(ev) {
- var store = this.store;
- var removePointer = false;
- var eventTypeNormalized = ev.type.toLowerCase().replace('ms', '');
- var eventType = POINTER_INPUT_MAP[eventTypeNormalized];
- var pointerType = IE10_POINTER_TYPE_ENUM[ev.pointerType] || ev.pointerType;
- var isTouch = (pointerType == INPUT_TYPE_TOUCH);
- // get index of the event in the store
- var storeIndex = inArray(store, ev.pointerId, 'pointerId');
- // start and mouse must be down
- if (eventType & INPUT_START && (ev.button === 0 || isTouch)) {
- if (storeIndex < 0) {
- store.push(ev);
- storeIndex = store.length - 1;
- }
- }
- else if (eventType & (INPUT_END | INPUT_CANCEL)) {
- removePointer = true;
- }
- // it not found, so the pointer hasn't been down (so it's probably a hover)
- if (storeIndex < 0) {
- return;
- }
- // update the event in the store
- store[storeIndex] = ev;
- this.callback(this.manager, eventType, {
- pointers: store,
- changedPointers: [ev],
- pointerType: pointerType,
- srcEvent: ev
- });
- if (removePointer) {
- // remove from the store
- store.splice(storeIndex, 1);
- }
- }
- });
- var SINGLE_TOUCH_INPUT_MAP = {
- touchstart: INPUT_START,
- touchmove: INPUT_MOVE,
- touchend: INPUT_END,
- touchcancel: INPUT_CANCEL
- };
- var SINGLE_TOUCH_TARGET_EVENTS = 'touchstart';
- var SINGLE_TOUCH_WINDOW_EVENTS = 'touchstart touchmove touchend touchcancel';
- /**
- * Touch events input
- * @constructor
- * @extends Input
- */
- function SingleTouchInput() {
- this.evTarget = SINGLE_TOUCH_TARGET_EVENTS;
- this.evWin = SINGLE_TOUCH_WINDOW_EVENTS;
- this.started = false;
- Input$1.apply(this, arguments);
- }
- inherit(SingleTouchInput, Input$1, {
- handler: function TEhandler(ev) {
- var type = SINGLE_TOUCH_INPUT_MAP[ev.type];
- // should we handle the touch events?
- if (type === INPUT_START) {
- this.started = true;
- }
- if (!this.started) {
- return;
- }
- var touches = normalizeSingleTouches.call(this, ev, type);
- // when done, reset the started state
- if (type & (INPUT_END | INPUT_CANCEL) && touches[0].length - touches[1].length === 0) {
- this.started = false;
- }
- this.callback(this.manager, type, {
- pointers: touches[0],
- changedPointers: touches[1],
- pointerType: INPUT_TYPE_TOUCH,
- srcEvent: ev
- });
- }
- });
- /**
- * @this {TouchInput}
- * @param {Object} ev
- * @param {Number} type flag
- * @returns {undefined|Array} [all, changed]
- */
- function normalizeSingleTouches(ev, type) {
- var all = toArray(ev.touches);
- var changed = toArray(ev.changedTouches);
- if (type & (INPUT_END | INPUT_CANCEL)) {
- all = uniqueArray(all.concat(changed), 'identifier', true);
- }
- return [all, changed];
- }
- var TOUCH_INPUT_MAP = {
- touchstart: INPUT_START,
- touchmove: INPUT_MOVE,
- touchend: INPUT_END,
- touchcancel: INPUT_CANCEL
- };
- var TOUCH_TARGET_EVENTS = 'touchstart touchmove touchend touchcancel';
- /**
- * Multi-user touch events input
- * @constructor
- * @extends Input
- */
- function TouchInput(_manager, _handler) {
- this.evTarget = TOUCH_TARGET_EVENTS;
- this.targetIds = {};
- Input$1.apply(this, arguments);
- }
- inherit(TouchInput, Input$1, {
- handler: function MTEhandler(ev) {
- var type = TOUCH_INPUT_MAP[ev.type];
- var touches = getTouches.call(this, ev, type);
- if (!touches) {
- return;
- }
- this.callback(this.manager, type, {
- pointers: touches[0],
- changedPointers: touches[1],
- pointerType: INPUT_TYPE_TOUCH,
- srcEvent: ev
- });
- }
- });
- /**
- * @this {TouchInput}
- * @param {Object} ev
- * @param {Number} type flag
- * @returns {undefined|Array} [all, changed]
- */
- function getTouches(ev, type) {
- var allTouches = toArray(ev.touches);
- var targetIds = this.targetIds;
- // when there is only one touch, the process can be simplified
- if (type & (INPUT_START | INPUT_MOVE) && allTouches.length === 1) {
- targetIds[allTouches[0].identifier] = true;
- return [allTouches, allTouches];
- }
- var i, targetTouches, changedTouches = toArray(ev.changedTouches), changedTargetTouches = [], target = this.target;
- // get target touches from touches
- targetTouches = allTouches.filter(function (touch) {
- return hasParent(touch.target, target);
- });
- // collect touches
- if (type === INPUT_START) {
- i = 0;
- while (i < targetTouches.length) {
- targetIds[targetTouches[i].identifier] = true;
- i++;
- }
- }
- // filter changed touches to only contain touches that exist in the collected target ids
- i = 0;
- while (i < changedTouches.length) {
- if (targetIds[changedTouches[i].identifier]) {
- changedTargetTouches.push(changedTouches[i]);
- }
- // cleanup removed touches
- if (type & (INPUT_END | INPUT_CANCEL)) {
- delete targetIds[changedTouches[i].identifier];
- }
- i++;
- }
- if (!changedTargetTouches.length) {
- return;
- }
- return [
- // merge targetTouches with changedTargetTouches so it contains ALL touches, including 'end' and 'cancel'
- uniqueArray(targetTouches.concat(changedTargetTouches), 'identifier', true),
- changedTargetTouches
- ];
- }
- /**
- * Combined touch and mouse input
- *
- * Touch has a higher priority then mouse, and while touching no mouse events are allowed.
- * This because touch devices also emit mouse events while doing a touch.
- *
- * @constructor
- * @extends Input
- */
- function TouchMouseInput() {
- Input$1.apply(this, arguments);
- var handler = bindFn(this.handler, this);
- this.touch = new TouchInput(this.manager, handler);
- this.mouse = new MouseInput(this.manager, handler);
- }
- inherit(TouchMouseInput, Input$1, {
- /**
- * handle mouse and touch events
- * @param {Hammer} manager
- * @param {String} inputEvent
- * @param {Object} inputData
- */
- handler: function TMEhandler(manager, inputEvent, inputData) {
- var isTouch = (inputData.pointerType == INPUT_TYPE_TOUCH), isMouse = (inputData.pointerType == INPUT_TYPE_MOUSE);
- // when we're in a touch event, so block all upcoming mouse events
- // most mobile browser also emit mouseevents, right after touchstart
- if (isTouch) {
- this.mouse.allow = false;
- }
- else if (isMouse && !this.mouse.allow) {
- return;
- }
- // reset the allowMouse when we're done
- if (inputEvent & (INPUT_END | INPUT_CANCEL)) {
- this.mouse.allow = true;
- }
- this.callback(manager, inputEvent, inputData);
- },
- /**
- * remove the event listeners
- */
- destroy: function destroy() {
- this.touch.destroy();
- this.mouse.destroy();
- }
- });
- var PREFIXED_TOUCH_ACTION = prefixed(TEST_ELEMENT.style, 'touchAction');
- var NATIVE_TOUCH_ACTION = PREFIXED_TOUCH_ACTION !== undefined;
- // magical touchAction value
- var TOUCH_ACTION_COMPUTE = 'compute';
- var TOUCH_ACTION_AUTO = 'auto';
- var TOUCH_ACTION_MANIPULATION = 'manipulation'; // not implemented
- var TOUCH_ACTION_NONE = 'none';
- var TOUCH_ACTION_PAN_X = 'pan-x';
- var TOUCH_ACTION_PAN_Y = 'pan-y';
- /**
- * Touch Action
- * sets the touchAction property or uses the js alternative
- * @param {Manager} manager
- * @param {String} value
- * @constructor
- */
- function TouchAction(manager, value) {
- this.manager = manager;
- this.set(value);
- }
- TouchAction.prototype = {
- /**
- * set the touchAction value on the element or enable the polyfill
- * @param {String} value
- */
- set: function (value) {
- // find out the touch-action by the event handlers
- if (value == TOUCH_ACTION_COMPUTE) {
- value = this.compute();
- }
- if (NATIVE_TOUCH_ACTION && this.manager.element.style) {
- this.manager.element.style[PREFIXED_TOUCH_ACTION] = value;
- }
- this.actions = value.toLowerCase().trim();
- },
- /**
- * just re-set the touchAction value
- */
- update: function () {
- this.set(this.manager.options.touchAction);
- },
- /**
- * compute the value for the touchAction property based on the recognizer's settings
- * @returns {String} value
- */
- compute: function () {
- var actions = [];
- each(this.manager.recognizers, function (recognizer) {
- if (boolOrFn(recognizer.options.enable, [recognizer])) {
- actions = actions.concat(recognizer.getTouchAction());
- }
- });
- return cleanTouchActions(actions.join(' '));
- },
- /**
- * this method is called on each input cycle and provides the preventing of the browser behavior
- * @param {Object} input
- */
- preventDefaults: function (input) {
- // not needed with native support for the touchAction property
- if (NATIVE_TOUCH_ACTION) {
- return;
- }
- var srcEvent = input.srcEvent;
- var direction = input.offsetDirection;
- // if the touch action did prevented once this session
- if (this.manager.session.prevented) {
- srcEvent.preventDefault();
- return;
- }
- var actions = this.actions;
- var hasNone = inStr(actions, TOUCH_ACTION_NONE);
- var hasPanY = inStr(actions, TOUCH_ACTION_PAN_Y);
- var hasPanX = inStr(actions, TOUCH_ACTION_PAN_X);
- if (hasNone) {
- //do not prevent defaults if this is a tap gesture
- var isTapPointer = input.pointers.length === 1;
- var isTapMovement = input.distance < 2;
- var isTapTouchTime = input.deltaTime < 250;
- if (isTapPointer && isTapMovement && isTapTouchTime) {
- return;
- }
- }
- if (hasPanX && hasPanY) {
- // `pan-x pan-y` means browser handles all scrolling/panning, do not prevent
- return;
- }
- if (hasNone ||
- (hasPanY && direction & DIRECTION_HORIZONTAL) ||
- (hasPanX && direction & DIRECTION_VERTICAL)) {
- return this.preventSrc(srcEvent);
- }
- },
- /**
- * call preventDefault to prevent the browser's default behavior (scrolling in most cases)
- * @param {Object} srcEvent
- */
- preventSrc: function (srcEvent) {
- this.manager.session.prevented = true;
- srcEvent.preventDefault();
- }
- };
- /**
- * when the touchActions are collected they are not a valid value, so we need to clean things up. *
- * @param {String} actions
- * @returns {*}
- */
- function cleanTouchActions(actions) {
- // none
- if (inStr(actions, TOUCH_ACTION_NONE)) {
- return TOUCH_ACTION_NONE;
- }
- var hasPanX = inStr(actions, TOUCH_ACTION_PAN_X);
- var hasPanY = inStr(actions, TOUCH_ACTION_PAN_Y);
- // if both pan-x and pan-y are set (different recognizers
- // for different directions, e.g. horizontal pan but vertical swipe?)
- // we need none (as otherwise with pan-x pan-y combined none of these
- // recognizers will work, since the browser would handle all panning
- if (hasPanX && hasPanY) {
- return TOUCH_ACTION_NONE;
- }
- // pan-x OR pan-y
- if (hasPanX || hasPanY) {
- return hasPanX ? TOUCH_ACTION_PAN_X : TOUCH_ACTION_PAN_Y;
- }
- // manipulation
- if (inStr(actions, TOUCH_ACTION_MANIPULATION)) {
- return TOUCH_ACTION_MANIPULATION;
- }
- return TOUCH_ACTION_AUTO;
- }
- /**
- * Recognizer flow explained; *
- * All recognizers have the initial state of POSSIBLE when a input session starts.
- * The definition of a input session is from the first input until the last input, with all it's movement in it. *
- * Example session for mouse-input: mousedown -> mousemove -> mouseup
- *
- * On each recognizing cycle (see Manager.recognize) the .recognize() method is executed
- * which determines with state it should be.
- *
- * If the recognizer has the state FAILED, CANCELLED or RECOGNIZED (equals ENDED), it is reset to
- * POSSIBLE to give it another change on the next cycle.
- *
- * Possible
- * |
- * +-----+---------------+
- * | |
- * +-----+-----+ |
- * | | |
- * Failed Cancelled |
- * +-------+------+
- * | |
- * Recognized Began
- * |
- * Changed
- * |
- * Ended/Recognized
- */
- var STATE_POSSIBLE = 1;
- var STATE_BEGAN = 2;
- var STATE_CHANGED = 4;
- var STATE_ENDED = 8;
- var STATE_RECOGNIZED = STATE_ENDED;
- var STATE_CANCELLED = 16;
- var STATE_FAILED = 32;
- /**
- * Recognizer
- * Every recognizer needs to extend from this class.
- * @constructor
- * @param {Object} options
- */
- function Recognizer(options) {
- this.options = Object.assign({}, this.defaults, options || {});
- this.id = uniqueId();
- this.manager = null;
- // default is enable true
- this.options.enable = ifUndefined(this.options.enable, true);
- this.state = STATE_POSSIBLE;
- this.simultaneous = {};
- this.requireFail = [];
- }
- Recognizer.prototype = {
- /**
- * @virtual
- * @type {Object}
- */
- defaults: {},
- /**
- * set options
- * @param {Object} options
- * @return {Recognizer}
- */
- set: function (options) {
- Object.assign(this.options, options);
- // also update the touchAction, in case something changed about the directions/enabled state
- this.manager && this.manager.touchAction.update();
- return this;
- },
- /**
- * recognize simultaneous with an other recognizer.
- * @param {Recognizer} otherRecognizer
- * @returns {Recognizer} this
- */
- recognizeWith: function (otherRecognizer) {
- if (invokeArrayArg(otherRecognizer, 'recognizeWith', this)) {
- return this;
- }
- var simultaneous = this.simultaneous;
- otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
- if (!simultaneous[otherRecognizer.id]) {
- simultaneous[otherRecognizer.id] = otherRecognizer;
- otherRecognizer.recognizeWith(this);
- }
- return this;
- },
- /**
- * drop the simultaneous link. it doesnt remove the link on the other recognizer.
- * @param {Recognizer} otherRecognizer
- * @returns {Recognizer} this
- */
- dropRecognizeWith: function (otherRecognizer) {
- if (invokeArrayArg(otherRecognizer, 'dropRecognizeWith', this)) {
- return this;
- }
- otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
- delete this.simultaneous[otherRecognizer.id];
- return this;
- },
- /**
- * recognizer can only run when an other is failing
- * @param {Recognizer} otherRecognizer
- * @returns {Recognizer} this
- */
- requireFailure: function (otherRecognizer) {
- if (invokeArrayArg(otherRecognizer, 'requireFailure', this)) {
- return this;
- }
- var requireFail = this.requireFail;
- otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
- if (inArray(requireFail, otherRecognizer) === -1) {
- requireFail.push(otherRecognizer);
- otherRecognizer.requireFailure(this);
- }
- return this;
- },
- /**
- * drop the requireFailure link. it does not remove the link on the other recognizer.
- * @param {Recognizer} otherRecognizer
- * @returns {Recognizer} this
- */
- dropRequireFailure: function (otherRecognizer) {
- if (invokeArrayArg(otherRecognizer, 'dropRequireFailure', this)) {
- return this;
- }
- otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
- var index = inArray(this.requireFail, otherRecognizer);
- if (index > -1) {
- this.requireFail.splice(index, 1);
- }
- return this;
- },
- /**
- * has require failures boolean
- * @returns {boolean}
- */
- hasRequireFailures: function () {
- return this.requireFail.length > 0;
- },
- /**
- * if the recognizer can recognize simultaneous with an other recognizer
- * @param {Recognizer} otherRecognizer
- * @returns {Boolean}
- */
- canRecognizeWith: function (otherRecognizer) {
- return !!this.simultaneous[otherRecognizer.id];
- },
- /**
- * You should use `tryEmit` instead of `emit` directly to check
- * that all the needed recognizers has failed before emitting.
- * @param {Object} input
- */
- emit: function (input) {
- var self = this;
- var state = this.state;
- function emit(event) {
- self.manager.emit(event, input);
- }
- // 'panstart' and 'panmove'
- if (state < STATE_ENDED) {
- emit(self.options.event + stateStr(state));
- }
- emit(self.options.event); // simple 'eventName' events
- if (input.additionalEvent) {
- emit(input.additionalEvent);
- }
- // panend and pancancel
- if (state >= STATE_ENDED) {
- emit(self.options.event + stateStr(state));
- }
- },
- /**
- * Check that all the require failure recognizers has failed,
- * if true, it emits a gesture event,
- * otherwise, setup the state to FAILED.
- * @param {Object} input
- */
- tryEmit: function (input) {
- if (this.canEmit()) {
- return this.emit(input);
- }
- // it's failing anyway
- this.state = STATE_FAILED;
- },
- /**
- * can we emit?
- * @returns {boolean}
- */
- canEmit: function () {
- var i = 0;
- while (i < this.requireFail.length) {
- if (!(this.requireFail[i].state & (STATE_FAILED | STATE_POSSIBLE))) {
- return false;
- }
- i++;
- }
- return true;
- },
- /**
- * update the recognizer
- * @param {Object} inputData
- */
- recognize: function (inputData) {
- // make a new copy of the inputData
- // so we can change the inputData without messing up the other recognizers
- var inputDataClone = Object.assign({}, inputData);
- // is is enabled and allow recognizing?
- if (!boolOrFn(this.options.enable, [this, inputDataClone])) {
- this.reset();
- this.state = STATE_FAILED;
- return;
- }
- // reset when we've reached the end
- if (this.state & (STATE_RECOGNIZED | STATE_CANCELLED | STATE_FAILED)) {
- this.state = STATE_POSSIBLE;
- }
- this.state = this.process(inputDataClone);
- // the recognizer has recognized a gesture
- // so trigger an event
- if (this.state & (STATE_BEGAN | STATE_CHANGED | STATE_ENDED | STATE_CANCELLED)) {
- this.tryEmit(inputDataClone);
- }
- },
- /**
- * return the state of the recognizer
- * the actual recognizing happens in this method
- * @virtual
- * @param {Object} inputData
- * @returns {Const} STATE
- */
- process: function (_inputData) { },
- /**
- * return the preferred touch-action
- * @virtual
- * @returns {Array}
- */
- getTouchAction: function () { },
- /**
- * called when the gesture isn't allowed to recognize
- * like when another is being recognized or it is disabled
- * @virtual
- */
- reset: function () { }
- };
- /**
- * get a usable string, used as event postfix
- * @param {Const} state
- * @returns {String} state
- */
- function stateStr(state) {
- if (state & STATE_CANCELLED) {
- return 'cancel';
- }
- else if (state & STATE_ENDED) {
- return 'end';
- }
- else if (state & STATE_CHANGED) {
- return 'move';
- }
- else if (state & STATE_BEGAN) {
- return 'start';
- }
- return '';
- }
- /**
- * direction cons to string
- * @param {Const} direction
- * @returns {String}
- */
- function directionStr(direction) {
- if (direction == DIRECTION_DOWN) {
- return 'down';
- }
- else if (direction == DIRECTION_UP) {
- return 'up';
- }
- else if (direction == DIRECTION_LEFT) {
- return 'left';
- }
- else if (direction == DIRECTION_RIGHT) {
- return 'right';
- }
- return '';
- }
- /**
- * get a recognizer by name if it is bound to a manager
- * @param {Recognizer|String} otherRecognizer
- * @param {Recognizer} recognizer
- * @returns {Recognizer}
- */
- function getRecognizerByNameIfManager(otherRecognizer, recognizer) {
- var manager = recognizer.manager;
- if (manager) {
- return manager.get(otherRecognizer);
- }
- return otherRecognizer;
- }
- /**
- * This recognizer is just used as a base for the simple attribute recognizers.
- * @constructor
- * @extends Recognizer
- */
- function AttrRecognizer() {
- Recognizer.apply(this, arguments);
- }
- inherit(AttrRecognizer, Recognizer, {
- /**
- * @namespace
- * @memberof AttrRecognizer
- */
- defaults: {
- /**
- * @type {Number}
- * @default 1
- */
- pointers: 1
- },
- /**
- * Used to check if it the recognizer receives valid input, like input.distance > 10.
- * @memberof AttrRecognizer
- * @param {Object} input
- * @returns {Boolean} recognized
- */
- attrTest: function (input) {
- var optionPointers = this.options.pointers;
- return optionPointers === 0 || input.pointers.length === optionPointers;
- },
- /**
- * Process the input and return the state for the recognizer
- * @memberof AttrRecognizer
- * @param {Object} input
- * @returns {*} State
- */
- process: function (input) {
- var state = this.state;
- var eventType = input.eventType;
- var isRecognized = state & (STATE_BEGAN | STATE_CHANGED);
- var isValid = this.attrTest(input);
- // on cancel input and we've recognized before, return STATE_CANCELLED
- if (isRecognized && (eventType & INPUT_CANCEL || !isValid)) {
- return state | STATE_CANCELLED;
- }
- else if (isRecognized || isValid) {
- if (eventType & INPUT_END) {
- return state | STATE_ENDED;
- }
- else if (!(state & STATE_BEGAN)) {
- return STATE_BEGAN;
- }
- return state | STATE_CHANGED;
- }
- return STATE_FAILED;
- }
- });
- /**
- * Pan
- * Recognized when the pointer is down and moved in the allowed direction.
- * @constructor
- * @extends AttrRecognizer
- */
- function PanRecognizer$1() {
- AttrRecognizer.apply(this, arguments);
- this.pX = null;
- this.pY = null;
- }
- inherit(PanRecognizer$1, AttrRecognizer, {
- /**
- * @namespace
- * @memberof PanRecognizer
- */
- defaults: {
- event: 'pan',
- threshold: 10,
- pointers: 1,
- direction: DIRECTION_ALL
- },
- getTouchAction: function () {
- var direction = this.options.direction;
- var actions = [];
- if (direction & DIRECTION_HORIZONTAL) {
- actions.push(TOUCH_ACTION_PAN_Y);
- }
- if (direction & DIRECTION_VERTICAL) {
- actions.push(TOUCH_ACTION_PAN_X);
- }
- return actions;
- },
- directionTest: function (input) {
- var options = this.options;
- var hasMoved = true;
- var distance = input.distance;
- var direction = input.direction;
- var x = input.deltaX;
- var y = input.deltaY;
- // lock to axis?
- if (!(direction & options.direction)) {
- if (options.direction & DIRECTION_HORIZONTAL) {
- direction = (x === 0) ? DIRECTION_NONE : (x < 0) ? DIRECTION_LEFT : DIRECTION_RIGHT;
- hasMoved = x != this.pX;
- distance = Math.abs(input.deltaX);
- }
- else {
- direction = (y === 0) ? DIRECTION_NONE : (y < 0) ? DIRECTION_UP : DIRECTION_DOWN;
- hasMoved = y != this.pY;
- distance = Math.abs(input.deltaY);
- }
- }
- input.direction = direction;
- return hasMoved && distance > options.threshold && direction & options.direction;
- },
- attrTest: function (input) {
- return AttrRecognizer.prototype.attrTest.call(this, input) &&
- (this.state & STATE_BEGAN || (!(this.state & STATE_BEGAN) && this.directionTest(input)));
- },
- emit: function (input) {
- this.pX = input.deltaX;
- this.pY = input.deltaY;
- var direction = directionStr(input.direction);
- if (direction) {
- input.additionalEvent = this.options.event + direction;
- }
- this._super.emit.call(this, input);
- }
- });
- /**
- * Pinch
- * Recognized when two or more pointers are moving toward (zoom-in) or away from each other (zoom-out).
- * @constructor
- * @extends AttrRecognizer
- */
- function PinchRecognizer() {
- AttrRecognizer.apply(this, arguments);
- }
- inherit(PinchRecognizer, AttrRecognizer, {
- /**
- * @namespace
- * @memberof PinchRecognizer
- */
- defaults: {
- event: 'pinch',
- threshold: 0,
- pointers: 2
- },
- getTouchAction: function () {
- return [TOUCH_ACTION_NONE];
- },
- attrTest: function (input) {
- return this._super.attrTest.call(this, input) &&
- (Math.abs(input.scale - 1) > this.options.threshold || this.state & STATE_BEGAN);
- },
- emit: function (input) {
- if (input.scale !== 1) {
- var inOut = input.scale < 1 ? 'in' : 'out';
- input.additionalEvent = this.options.event + inOut;
- }
- this._super.emit.call(this, input);
- }
- });
- /**
- * Press
- * Recognized when the pointer is down for x ms without any movement.
- * @constructor
- * @extends Recognizer
- */
- function PressRecognizer() {
- Recognizer.apply(this, arguments);
- this._timer = null;
- this._input = null;
- }
- inherit(PressRecognizer, Recognizer, {
- /**
- * @namespace
- * @memberof PressRecognizer
- */
- defaults: {
- event: 'press',
- pointers: 1,
- time: 251,
- threshold: 9 // a minimal movement is ok, but keep it low
- },
- getTouchAction: function () {
- return [TOUCH_ACTION_AUTO];
- },
- process: function (input) {
- var options = this.options;
- var validPointers = input.pointers.length === options.pointers;
- var validMovement = input.distance < options.threshold;
- var validTime = input.deltaTime > options.time;
- this._input = input;
- // we only allow little movement
- // and we've reached an end event, so a tap is possible
- if (!validMovement || !validPointers || (input.eventType & (INPUT_END | INPUT_CANCEL) && !validTime)) {
- this.reset();
- }
- else if (input.eventType & INPUT_START) {
- this.reset();
- this._timer = setTimeoutContext(function () {
- this.state = STATE_RECOGNIZED;
- this.tryEmit();
- }, options.time, this);
- }
- else if (input.eventType & INPUT_END) {
- return STATE_RECOGNIZED;
- }
- return STATE_FAILED;
- },
- reset: function () {
- clearTimeout(this._timer);
- },
- emit: function (input) {
- if (this.state !== STATE_RECOGNIZED) {
- return;
- }
- if (input && (input.eventType & INPUT_END)) {
- this.manager.emit(this.options.event + 'up', input);
- }
- else {
- this._input.timeStamp = now();
- this.manager.emit(this.options.event, this._input);
- }
- }
- });
- /**
- * Rotate
- * Recognized when two or more pointer are moving in a circular motion.
- * @constructor
- * @extends AttrRecognizer
- */
- function RotateRecognizer() {
- AttrRecognizer.apply(this, arguments);
- }
- inherit(RotateRecognizer, AttrRecognizer, {
- /**
- * @namespace
- * @memberof RotateRecognizer
- */
- defaults: {
- event: 'rotate',
- threshold: 0,
- pointers: 2
- },
- getTouchAction: function () {
- return [TOUCH_ACTION_NONE];
- },
- attrTest: function (input) {
- return this._super.attrTest.call(this, input) &&
- (Math.abs(input.rotation) > this.options.threshold || this.state & STATE_BEGAN);
- }
- });
- /**
- * Swipe
- * Recognized when the pointer is moving fast (velocity), with enough distance in the allowed direction.
- * @constructor
- * @extends AttrRecognizer
- */
- function SwipeRecognizer() {
- AttrRecognizer.apply(this, arguments);
- }
- inherit(SwipeRecognizer, AttrRecognizer, {
- /**
- * @namespace
- * @memberof SwipeRecognizer
- */
- defaults: {
- event: 'swipe',
- threshold: 10,
- velocity: 0.3,
- direction: DIRECTION_HORIZONTAL | DIRECTION_VERTICAL,
- pointers: 1
- },
- getTouchAction: function () {
- return PanRecognizer$1.prototype.getTouchAction.call(this);
- },
- attrTest: function (input) {
- var direction = this.options.direction;
- var velocity;
- if (direction & (DIRECTION_HORIZONTAL | DIRECTION_VERTICAL)) {
- velocity = input.overallVelocity;
- }
- else if (direction & DIRECTION_HORIZONTAL) {
- velocity = input.overallVelocityX;
- }
- else if (direction & DIRECTION_VERTICAL) {
- velocity = input.overallVelocityY;
- }
- return this._super.attrTest.call(this, input) &&
- direction & input.offsetDirection &&
- input.distance > this.options.threshold &&
- input.maxPointers == this.options.pointers &&
- abs(velocity) > this.options.velocity && input.eventType & INPUT_END;
- },
- emit: function (input) {
- var direction = directionStr(input.offsetDirection);
- if (direction) {
- this.manager.emit(this.options.event + direction, input);
- }
- this.manager.emit(this.options.event, input);
- }
- });
- /**
- * A tap is ecognized when the pointer is doing a small tap/click. Multiple taps are recognized if they occur
- * between the given interval and position. The delay option can be used to recognize multi-taps without firing
- * a single tap.
- *
- * The eventData from the emitted event contains the property `tapCount`, which contains the amount of
- * multi-taps being recognized.
- * @constructor
- * @extends Recognizer
- */
- function TapRecognizer() {
- Recognizer.apply(this, arguments);
- // previous time and center,
- // used for tap counting
- this.pTime = false;
- this.pCenter = false;
- this._timer = null;
- this._input = null;
- this.count = 0;
- }
- inherit(TapRecognizer, Recognizer, {
- /**
- * @namespace
- * @memberof PinchRecognizer
- */
- defaults: {
- event: 'tap',
- pointers: 1,
- taps: 1,
- interval: 300,
- time: 250,
- threshold: 9,
- posThreshold: 10 // a multi-tap can be a bit off the initial position
- },
- getTouchAction: function () {
- return [TOUCH_ACTION_MANIPULATION];
- },
- process: function (input) {
- var options = this.options;
- var validPointers = input.pointers.length === options.pointers;
- var validMovement = input.distance < options.threshold;
- var validTouchTime = input.deltaTime < options.time;
- this.reset();
- if ((input.eventType & INPUT_START) && (this.count === 0)) {
- return this.failTimeout();
- }
- // we only allow little movement
- // and we've reached an end event, so a tap is possible
- if (validMovement && validTouchTime && validPointers) {
- if (input.eventType != INPUT_END) {
- return this.failTimeout();
- }
- var validInterval = this.pTime ? (input.timeStamp - this.pTime < options.interval) : true;
- var validMultiTap = !this.pCenter || getDistance(this.pCenter, input.center) < options.posThreshold;
- this.pTime = input.timeStamp;
- this.pCenter = input.center;
- if (!validMultiTap || !validInterval) {
- this.count = 1;
- }
- else {
- this.count += 1;
- }
- this._input = input;
- // if tap count matches we have recognized it,
- // else it has began recognizing...
- var tapCount = this.count % options.taps;
- if (tapCount === 0) {
- // no failing requirements, immediately trigger the tap event
- // or wait as long as the multitap interval to trigger
- if (!this.hasRequireFailures()) {
- return STATE_RECOGNIZED;
- }
- else {
- this._timer = setTimeoutContext(function () {
- this.state = STATE_RECOGNIZED;
- this.tryEmit();
- }, options.interval, this);
- return STATE_BEGAN;
- }
- }
- }
- return STATE_FAILED;
- },
- failTimeout: function () {
- this._timer = setTimeoutContext(function () {
- this.state = STATE_FAILED;
- }, this.options.interval, this);
- return STATE_FAILED;
- },
- reset: function () {
- clearTimeout(this._timer);
- },
- emit: function () {
- if (this.state == STATE_RECOGNIZED) {
- this._input.tapCount = this.count;
- this.manager.emit(this.options.event, this._input);
- }
- }
- });
- /**
- * Simple way to create a manager with a default set of recognizers.
- * @param {HTMLElement} element
- * @param {Object} [options]
- * @constructor
- */
- function Hammer$1(element, options) {
- options = options || {};
- options.recognizers = ifUndefined(options.recognizers, _defaults.preset);
- return new Manager(element, options);
- }
- /**
- * default settings
- * @namespace
- */
- var _defaults = {
- /**
- * set if DOM events are being triggered.
- * But this is slower and unused by simple implementations, so disabled by default.
- * @type {Boolean}
- * @default false
- */
- domEvents: false,
- /**
- * The value for the touchAction property/fallback.
- * When set to `compute` it will magically set the correct value based on the added recognizers.
- * @type {String}
- * @default compute
- */
- touchAction: TOUCH_ACTION_COMPUTE,
- /**
- * @type {Boolean}
- * @default true
- */
- enable: true,
- /**
- * EXPERIMENTAL FEATURE -- can be removed/changed
- * Change the parent input target element.
- * If Null, then it is being set the to main element.
- * @type {Null|EventTarget}
- * @default null
- */
- inputTarget: null,
- /**
- * force an input class
- * @type {Null|Function}
- * @default null
- */
- inputClass: null,
- /**
- * Default recognizer setup when calling `Hammer()`
- * When creating a new Manager these will be skipped.
- * @type {Array}
- */
- preset: [
- // RecognizerClass, options, [recognizeWith, ...], [requireFailure, ...]
- [RotateRecognizer, { enable: false }],
- [PinchRecognizer, { enable: false }, ['rotate']],
- [SwipeRecognizer, { direction: DIRECTION_HORIZONTAL }],
- [PanRecognizer$1, { direction: DIRECTION_HORIZONTAL }, ['swipe']],
- [TapRecognizer],
- [TapRecognizer, { event: 'doubletap', taps: 2 }, ['tap']],
- [PressRecognizer]
- ],
- /**
- * Some CSS properties can be used to improve the working of Hammer.
- * Add them to this method and they will be set when creating a new Manager.
- * @namespace
- */
- cssProps: {
- /**
- * Disables text selection to improve the dragging gesture. Mainly for desktop browsers.
- * @type {String}
- * @default 'none'
- */
- userSelect: 'none',
- /**
- * Disable the Windows Phone grippers when pressing an element.
- * @type {String}
- * @default 'none'
- */
- touchSelect: 'none',
- /**
- * Disables the default callout shown when you touch and hold a touch target.
- * On iOS, when you touch and hold a touch target such as a link, Safari displays
- * a callout containing information about the link. This property allows you to disable that callout.
- * @type {String}
- * @default 'none'
- */
- touchCallout: 'none',
- /**
- * Specifies whether zooming is enabled. Used by IE10>
- * @type {String}
- * @default 'none'
- */
- contentZooming: 'none',
- /**
- * Specifies that an entire element should be draggable instead of its contents. Mainly for desktop browsers.
- * @type {String}
- * @default 'none'
- */
- userDrag: 'none',
- /**
- * Overrides the highlight color shown when the user taps a link or a JavaScript
- * clickable element in iOS. This property obeys the alpha value, if specified.
- * @type {String}
- * @default 'rgba(0,0,0,0)'
- */
- tapHighlightColor: 'rgba(0,0,0,0)'
- }
- };
- var STOP = 1;
- var FORCED_STOP = 2;
- /**
- * Manager
- * @param {HTMLElement} element
- * @param {Object} [options]
- * @constructor
- */
- function Manager(element, options) {
- this.options = Object.assign({}, _defaults, options || {});
- this.options.inputTarget = this.options.inputTarget || element;
- this.handlers = {};
- this.session = {};
- this.recognizers = [];
- this.element = element;
- this.input = createInputInstance(this);
- this.touchAction = new TouchAction(this, this.options.touchAction);
- toggleCssProps(this, true);
- each(this.options.recognizers, function (item) {
- var recognizer = this.add(new (item[0])(item[1]));
- item[2] && recognizer.recognizeWith(item[2]);
- item[3] && recognizer.requireFailure(item[3]);
- }, this);
- }
- Manager.prototype = {
- /**
- * set options
- * @param {Object} options
- * @returns {Manager}
- */
- set: function (options) {
- Object.assign(this.options, options);
- // Options that need a little more setup
- if (options.touchAction) {
- this.touchAction.update();
- }
- if (options.inputTarget) {
- // Clean up existing event listeners and reinitialize
- this.input.destroy();
- this.input.target = options.inputTarget;
- this.input.init();
- }
- return this;
- },
- /**
- * stop recognizing for this session.
- * This session will be discarded, when a new [input]start event is fired.
- * When forced, the recognizer cycle is stopped immediately.
- * @param {Boolean} [force]
- */
- stop: function (force) {
- this.session.stopped = force ? FORCED_STOP : STOP;
- },
- /**
- * run the recognizers!
- * called by the inputHandler function on every movement of the pointers (touches)
- * it walks through all the recognizers and tries to detect the gesture that is being made
- * @param {Object} inputData
- */
- recognize: function (inputData) {
- var session = this.session;
- if (session.stopped) {
- return;
- }
- // run the touch-action polyfill
- this.touchAction.preventDefaults(inputData);
- var recognizer;
- var recognizers = this.recognizers;
- // this holds the recognizer that is being recognized.
- // so the recognizer's state needs to be BEGAN, CHANGED, ENDED or RECOGNIZED
- // if no recognizer is detecting a thing, it is set to `null`
- var curRecognizer = session.curRecognizer;
- // reset when the last recognizer is recognized
- // or when we're in a new session
- if (!curRecognizer || (curRecognizer && curRecognizer.state & STATE_RECOGNIZED)) {
- curRecognizer = session.curRecognizer = null;
- }
- var i = 0;
- while (i < recognizers.length) {
- recognizer = recognizers[i];
- // find out if we are allowed try to recognize the input for this one.
- // 1. allow if the session is NOT forced stopped (see the .stop() method)
- // 2. allow if we still haven't recognized a gesture in this session, or the this recognizer is the one
- // that is being recognized.
- // 3. allow if the recognizer is allowed to run simultaneous with the current recognized recognizer.
- // this can be setup with the `recognizeWith()` method on the recognizer.
- if (session.stopped !== FORCED_STOP && (!curRecognizer || recognizer == curRecognizer ||
- recognizer.canRecognizeWith(curRecognizer))) {
- recognizer.recognize(inputData);
- }
- else {
- recognizer.reset();
- }
- // if the recognizer has been recognizing the input as a valid gesture, we want to store this one as the
- // current active recognizer. but only if we don't already have an active recognizer
- if (!curRecognizer && recognizer.state & (STATE_BEGAN | STATE_CHANGED | STATE_ENDED)) {
- curRecognizer = session.curRecognizer = recognizer;
- }
- i++;
- }
- },
- /**
- * get a recognizer by its event name.
- * @param {Recognizer|String} recognizer
- * @returns {Recognizer|Null}
- */
- get: function (recognizer) {
- if (recognizer instanceof Recognizer) {
- return recognizer;
- }
- var recognizers = this.recognizers;
- for (var i = 0; i < recognizers.length; i++) {
- if (recognizers[i].options.event == recognizer) {
- return recognizers[i];
- }
- }
- return null;
- },
- /**
- * add a recognizer to the manager
- * existing recognizers with the same event name will be removed
- * @param {Recognizer} recognizer
- * @returns {Recognizer|Manager}
- */
- add: function (recognizer) {
- if (invokeArrayArg(recognizer, 'add', this)) {
- return this;
- }
- // remove existing
- var existing = this.get(recognizer.options.event);
- if (existing) {
- this.remove(existing);
- }
- this.recognizers.push(recognizer);
- recognizer.manager = this;
- this.touchAction.update();
- return recognizer;
- },
- /**
- * remove a recognizer by name or instance
- * @param {Recognizer|String} recognizer
- * @returns {Manager}
- */
- remove: function (recognizer) {
- if (invokeArrayArg(recognizer, 'remove', this)) {
- return this;
- }
- recognizer = this.get(recognizer);
- // let's make sure this recognizer exists
- if (recognizer) {
- var recognizers = this.recognizers;
- var index = inArray(recognizers, recognizer);
- if (index !== -1) {
- recognizers.splice(index, 1);
- this.touchAction.update();
- }
- }
- return this;
- },
- /**
- * bind event
- * @param {String} events
- * @param {Function} handler
- * @returns {EventEmitter} this
- */
- on: function (events, handler) {
- var handlers = this.handlers;
- each(splitStr(events), function (event) {
- handlers[event] = handlers[event] || [];
- handlers[event].push(handler);
- });
- return this;
- },
- /**
- * unbind event, leave emit blank to remove all handlers
- * @param {String} events
- * @param {Function} [handler]
- * @returns {EventEmitter} this
- */
- off: function (events, handler) {
- var handlers = this.handlers;
- each(splitStr(events), function (event) {
- if (!handler) {
- delete handlers[event];
- }
- else {
- handlers[event] && handlers[event].splice(inArray(handlers[event], handler), 1);
- }
- });
- return this;
- },
- /**
- * emit event to the listeners
- * @param {String} event
- * @param {Object} data
- */
- emit: function (event, data) {
- // we also want to trigger dom events
- if (this.options.domEvents) {
- triggerDomEvent(event, data);
- }
- // no handlers, so skip it all
- var handlers = this.handlers[event] && this.handlers[event].slice();
- if (!handlers || !handlers.length) {
- return;
- }
- data.type = event;
- data.preventDefault = function () {
- data.srcEvent.preventDefault();
- };
- var i = 0;
- while (i < handlers.length) {
- handlers[i](data);
- i++;
- }
- },
- /**
- * destroy the manager and unbinds all events
- * it doesn't unbind dom events, that is the user own responsibility
- */
- destroy: function () {
- this.element && toggleCssProps(this, false);
- this.handlers = {};
- this.session = {};
- this.input.destroy();
- this.element = null;
- }
- };
- /**
- * add/remove the css properties as defined in manager.options.cssProps
- * @param {Manager} manager
- * @param {Boolean} add
- */
- function toggleCssProps(manager, add) {
- var element = manager.element;
- if (!element.style) {
- return;
- }
- each(manager.options.cssProps, function (value, name) {
- element.style[prefixed(element.style, name)] = add ? value : '';
- });
- }
- /**
- * trigger dom event
- * @param {String} event
- * @param {Object} data
- */
- function triggerDomEvent(event, data) {
- var gestureEvent = doc.createEvent('Event');
- gestureEvent.initEvent(event, true, true);
- gestureEvent.gesture = data;
- data.target.dispatchEvent(gestureEvent);
- }
- Object.assign(Hammer$1, {
- INPUT_START: INPUT_START,
- INPUT_MOVE: INPUT_MOVE,
- INPUT_END: INPUT_END,
- INPUT_CANCEL: INPUT_CANCEL,
- STATE_POSSIBLE: STATE_POSSIBLE,
- STATE_BEGAN: STATE_BEGAN,
- STATE_CHANGED: STATE_CHANGED,
- STATE_ENDED: STATE_ENDED,
- STATE_RECOGNIZED: STATE_RECOGNIZED,
- STATE_CANCELLED: STATE_CANCELLED,
- STATE_FAILED: STATE_FAILED,
- DIRECTION_NONE: DIRECTION_NONE,
- DIRECTION_LEFT: DIRECTION_LEFT,
- DIRECTION_RIGHT: DIRECTION_RIGHT,
- DIRECTION_UP: DIRECTION_UP,
- DIRECTION_DOWN: DIRECTION_DOWN,
- DIRECTION_HORIZONTAL: DIRECTION_HORIZONTAL,
- DIRECTION_VERTICAL: DIRECTION_VERTICAL,
- DIRECTION_ALL: DIRECTION_ALL,
- Manager: Manager,
- Input: Input$1,
- TouchAction: TouchAction,
- TouchInput: TouchInput,
- MouseInput: MouseInput,
- PointerEventInput: PointerEventInput,
- TouchMouseInput: TouchMouseInput,
- SingleTouchInput: SingleTouchInput,
- Recognizer: Recognizer,
- AttrRecognizer: AttrRecognizer,
- Tap: TapRecognizer,
- Pan: PanRecognizer$1,
- Swipe: SwipeRecognizer,
- Pinch: PinchRecognizer,
- Rotate: RotateRecognizer,
- Press: PressRecognizer,
- on: addEventListeners,
- off: removeEventListeners,
- each: each,
- inherit: inherit,
- bindFn: bindFn,
- prefixed: prefixed
- });
- win$1.Hammer = Hammer$1;
-
- /**
- * @hidden
- * A gesture recognizer class.
- *
- * TODO(mlynch): Re-enable the DOM event simulation that was causing issues (or verify hammer does this already, it might);
- */
- var Gesture = (function () {
- function Gesture(element, opts) {
- if (opts === void 0) { opts = {}; }
- this._callbacks = {};
- this.isListening = false;
- defaults(opts, {
- domEvents: true
- });
- this.element = element;
- // Map 'x' or 'y' string to hammerjs opts
- this.direction = opts.direction || 'x';
- opts.direction = this.direction === 'x' ?
- DIRECTION_HORIZONTAL :
- DIRECTION_VERTICAL;
- this._options = opts;
- }
- Gesture.prototype.options = function (opts) {
- Object.assign(this._options, opts);
- };
- Gesture.prototype.on = function (type, cb) {
- if (type === 'pinch' || type === 'rotate') {
- this._hammer.get(type).set({ enable: true });
- }
- this._hammer.on(type, cb);
- (this._callbacks[type] || (this._callbacks[type] = [])).push(cb);
- };
- Gesture.prototype.off = function (type, cb) {
- this._hammer.off(type, this._callbacks[type] ? cb : null);
- };
- Gesture.prototype.listen = function () {
- if (!this.isListening) {
- this._hammer = Hammer$1(this.element, this._options);
- }
- this.isListening = true;
- };
- Gesture.prototype.unlisten = function () {
- var eventType;
- var i;
- if (this._hammer && this.isListening) {
- for (eventType in this._callbacks) {
- for (i = 0; i < this._callbacks[eventType].length; i++) {
- this._hammer.off(eventType, this._callbacks[eventType]);
- }
- }
- this._hammer.destroy();
- }
- this._callbacks = {};
- this._hammer = null;
- this.isListening = false;
- };
- Gesture.prototype.destroy = function () {
- this.unlisten();
- this.element = this._options = null;
- };
- return Gesture;
- }());
-
- /**
- * @name Events
- * @description
- * Events is a publish-subscribe style event system for sending and responding to application-level
- * events across your app.
- *
- * @usage
- * ```ts
- * import { Events } from 'ionic-angular';
- *
- * // first page (publish an event when a user is created)
- * constructor(public events: Events) { }
- *
- * createUser(user) {
- * console.log('User created!')
- * this.events.publish('user:created', user, Date.now());
- * }
- *
- *
- * // second page (listen for the user created event after function is called)
- * constructor(public events: Events) {
- * events.subscribe('user:created', (user, time) => {
- * // user and time are the same arguments passed in `events.publish(user, time)`
- * console.log('Welcome', user, 'at', time);
- * });
- * }
- *
- * ```
- * @demo /docs/demos/src/events/
- */
- var Events = (function () {
- function Events() {
- this._channels = [];
- }
- /**
- * Subscribe to an event topic. Events that get posted to that topic will trigger the provided handler.
- *
- * @param {string} topic the topic to subscribe to
- * @param {function} handler the event handler
- */
- Events.prototype.subscribe = function (topic) {
- var _this = this;
- var handlers = [];
- for (var _i = 1; _i < arguments.length; _i++) {
- handlers[_i - 1] = arguments[_i];
- }
- if (!this._channels[topic]) {
- this._channels[topic] = [];
- }
- handlers.forEach(function (handler) {
- _this._channels[topic].push(handler);
- });
- };
- /**
- * Unsubscribe from the given topic. Your handler will no longer receive events published to this topic.
- *
- * @param {string} topic the topic to unsubscribe from
- * @param {function} handler the event handler
- *
- * @return true if a handler was removed
- */
- Events.prototype.unsubscribe = function (topic, handler) {
- if (handler === void 0) { handler = null; }
- var t = this._channels[topic];
- if (!t) {
- // Wasn't found, wasn't removed
- return false;
- }
- if (!handler) {
- // Remove all handlers for this topic
- delete this._channels[topic];
- return true;
- }
- // We need to find and remove a specific handler
- var i = t.indexOf(handler);
- if (i < 0) {
- // Wasn't found, wasn't removed
- return false;
- }
- t.splice(i, 1);
- // If the channel is empty now, remove it from the channel map
- if (!t.length) {
- delete this._channels[topic];
- }
- return true;
- };
- /**
- * Publish an event to the given topic.
- *
- * @param {string} topic the topic to publish to
- * @param {any} eventData the data to send as the event
- */
- Events.prototype.publish = function (topic) {
- var args = [];
- for (var _i = 1; _i < arguments.length; _i++) {
- args[_i - 1] = arguments[_i];
- }
- var t = this._channels[topic];
- if (!t) {
- return null;
- }
- var responses = [];
- t.forEach(function (handler) {
- responses.push(handler.apply(void 0, args));
- });
- return responses;
- };
- return Events;
- }());
- /**
- * @hidden
- */
- function setupEvents(plt, dom) {
- var events = new Events();
- var win = plt.win();
- var doc = plt.doc();
- // start listening for resizes XXms after the app starts
- plt.timeout(function () {
- win.addEventListener('online', function (ev) {
- events.publish('app:online', ev);
- }, false);
- win.addEventListener('offline', function (ev) {
- events.publish('app:offline', ev);
- }, false);
- win.addEventListener('orientationchange', function (ev) {
- events.publish('app:rotated', ev);
- });
- // When that status taps, we respond
- win.addEventListener('statusTap', function () {
- // TODO: Make this more better
- var el = doc.elementFromPoint(plt.width() / 2, plt.height() / 2);
- if (!el) {
- return;
- }
- var contentEle = el.closest('.scroll-content');
- if (contentEle) {
- var style = contentEle.style;
- var scroll = new ScrollView(null, plt, dom);
- scroll._el = contentEle;
- // We need to stop scrolling if it's happening and scroll up
- style['WebkitBackfaceVisibility'] = 'hidden';
- style['WebkitTransform'] = 'translate3d(0,0,0)';
- dom.write(function () {
- style.overflow = 'hidden';
- function finish() {
- style.overflow = '';
- style['WebkitBackfaceVisibility'] = '';
- style['WebkitTransform'] = '';
- }
- var didScrollTimeout = plt.timeout(function () {
- finish();
- }, 400);
- scroll.scrollTo(0, 0, 300).then(function () {
- plt.cancelTimeout(didScrollTimeout);
- finish();
- });
- });
- }
- });
- }, 2000);
- return events;
- }
- /**
- * @hidden
- */
- function setupProvideEvents(plt, dom) {
- return function () {
- return setupEvents(plt, dom);
- };
- }
-
- var __extends$91 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @name IonicErrorHandler
- * @description
- * The `IonicErrorHandler` intercepts the default `Console` error handling
- * and displays runtime errors as an overlay when using Ionic's Dev Build Server.
- *
- *
- * ### IonicErrorHandler Example
- *
- * ```typescript
- * import { ErrorHandler, NgModule } from '@angular/core';
- * import { IonicErrorHandler } from 'ionic-angular';
- *
- * @NgModule({
- * providers: [{ provide: ErrorHandler, useClass: IonicErrorHandler }]
- * })
- * class AppModule { }
- * ```
- *
- *
- * ### Custom Error Handlers
- *
- * Custom error handlers can be built to replace the default, or extend Ionic's
- * error handler.
- *
- * ```typescript
- * class MyErrorHandler implements ErrorHandler {
- * handleError(err: any): void {
- * // do something with the error
- * }
- * }
- *
- * @NgModule({
- * providers: [{ provide: ErrorHandler, useClass: MyErrorHandler }]
- * })
- * class AppModule { }
- * ```
- *
- * More information about Angular's [`ErrorHandler`](https://angular.io/docs/ts/latest/api/core/index/ErrorHandler-class.html).
- */
- var IonicErrorHandler = (function (_super) {
- __extends$91(IonicErrorHandler, _super);
- function IonicErrorHandler() {
- return _super.call(this) || this;
- }
- /**
- * @internal
- */
- IonicErrorHandler.prototype.handleError = function (err) {
- _super.prototype.handleError.call(this, err);
- try {
- var win = window;
- var monitor = void 0;
- monitor = win['IonicDevServer'];
- monitor && monitor.handleError && monitor.handleError(err);
- monitor = (win['Ionic'] = win['Ionic'] || {}).Monitor;
- monitor && monitor.handleError && monitor.handleError(err);
- }
- catch (e) { }
- };
- return IonicErrorHandler;
- }(ErrorHandler));
-
- var PLATFORM_CONFIGS = {
- /**
- * core
- */
- 'core': {
- settings: {
- mode: 'md',
- keyboardHeight: 290
- }
- },
- /**
- * mobile
- */
- 'mobile': {},
- /**
- * phablet
- */
- 'phablet': {
- isMatch: function (plt) {
- var smallest = Math.min(plt.width(), plt.height());
- var largest = Math.max(plt.width(), plt.height());
- return (smallest > 390 && smallest < 520) &&
- (largest > 620 && largest < 800);
- }
- },
- /**
- * tablet
- */
- 'tablet': {
- isMatch: function (plt) {
- var smallest = Math.min(plt.width(), plt.height());
- var largest = Math.max(plt.width(), plt.height());
- return (smallest > 460 && smallest < 820) &&
- (largest > 780 && largest < 1400);
- }
- },
- /**
- * android
- */
- 'android': {
- superset: 'mobile',
- subsets: [
- 'phablet',
- 'tablet'
- ],
- settings: {
- activator: function (plt) {
- // md mode defaults to use ripple activator
- // however, under-powered devices shouldn't use ripple
- // if this a linux device, and is using Android Chrome v36 (Android 5.0)
- // or above then use ripple, otherwise do not use a ripple effect
- if (plt.testNavigatorPlatform('linux')) {
- var chromeVersion = plt.matchUserAgentVersion(/Chrome\/(\d+).(\d+)?/);
- if (chromeVersion) {
- // linux android device using modern android chrome browser gets ripple
- if (parseInt(chromeVersion.major, 10) < 36 || plt.version().major < 5) {
- return 'none';
- }
- else {
- return 'ripple';
- }
- }
- // linux android device not using chrome browser checks just android's version
- if (plt.version().major < 5) {
- return 'none';
- }
- }
- // fallback to always use ripple
- return 'ripple';
- },
- autoFocusAssist: 'immediate',
- inputCloning: true,
- scrollAssist: true,
- hoverCSS: false,
- keyboardHeight: 300,
- mode: 'md',
- },
- isMatch: function (plt) {
- return plt.isPlatformMatch('android', ['android', 'silk'], ['windows phone']);
- },
- versionParser: function (plt) {
- return plt.matchUserAgentVersion(/Android (\d+).(\d+)?/);
- }
- },
- /**
- * ios
- */
- 'ios': {
- superset: 'mobile',
- subsets: [
- 'ipad',
- 'iphone'
- ],
- settings: {
- autoFocusAssist: 'delay',
- hideCaretOnScroll: true,
- hoverCSS: false,
- inputBlurring: isIos,
- inputCloning: isIos,
- keyboardHeight: 250,
- mode: 'ios',
- statusbarPadding: isCordova,
- swipeBackEnabled: isIos,
- tapPolyfill: isIosUIWebView,
- virtualScrollEventAssist: isIosUIWebView,
- disableScrollAssist: isIos,
- scrollAssist: isIos,
- keyboardResizes: keyboardResizes,
- },
- isMatch: function (plt) {
- return plt.isPlatformMatch('ios', ['iphone', 'ipad', 'ipod'], ['windows phone']);
- },
- versionParser: function (plt) {
- return plt.matchUserAgentVersion(/OS (\d+)_(\d+)?/);
- }
- },
- /**
- * ipad
- */
- 'ipad': {
- superset: 'tablet',
- settings: {
- keyboardHeight: 500,
- },
- isMatch: function (plt) {
- return plt.isPlatformMatch('ipad');
- }
- },
- /**
- * iphone
- */
- 'iphone': {
- subsets: [
- 'phablet'
- ],
- isMatch: function (plt) {
- return plt.isPlatformMatch('iphone');
- }
- },
- /**
- * Windows
- */
- 'windows': {
- superset: 'mobile',
- subsets: [
- 'phablet',
- 'tablet'
- ],
- settings: {
- mode: 'wp',
- autoFocusAssist: 'immediate',
- hoverCSS: false
- },
- isMatch: function (plt) {
- return plt.isPlatformMatch('windows', ['windows phone']);
- },
- versionParser: function (plt) {
- return plt.matchUserAgentVersion(/Windows Phone (\d+).(\d+)?/);
- }
- },
- /**
- * cordova
- */
- 'cordova': {
- isEngine: true,
- initialize: function (plt) {
- // prepare a custom "ready" for cordova "deviceready"
- plt.prepareReady = function () {
- // 1) ionic bootstrapped
- plt.windowLoad(function (win, doc) {
- // 2) window onload triggered or completed
- doc.addEventListener('deviceready', function () {
- // 3) cordova deviceready event triggered
- // add cordova listeners to emit platform events
- doc.addEventListener('backbutton', function (ev) {
- plt.zone.run(function () {
- plt.backButton.emit(ev);
- });
- });
- doc.addEventListener('pause', function (ev) {
- plt.zone.run(function () {
- plt.pause.emit(ev);
- });
- });
- doc.addEventListener('resume', function (ev) {
- plt.zone.run(function () {
- plt.resume.emit(ev);
- });
- });
- // cordova has its own exitApp method
- plt.exitApp = function () {
- win['navigator']['app'].exitApp();
- };
- // cordova has fully loaded and we've added listeners
- plt.triggerReady('cordova');
- });
- });
- };
- },
- isMatch: function (plt) {
- return isCordova(plt);
- }
- },
- /**
- * electron
- */
- 'electron': {
- superset: 'core',
- initialize: function (plt) {
- plt.prepareReady = function () {
- // 1) ionic bootstrapped
- plt.windowLoad(function () {
- plt.triggerReady('electron');
- });
- };
- },
- isMatch: function (plt) {
- return isElectron(plt);
- }
- }
- };
- function keyboardResizes(plt) {
- var win = plt.win();
- if (win.Ionic && win.Ionic.keyboardResizes === true) {
- return true;
- }
- return false;
- }
- var PlatformConfigToken = new InjectionToken('PLTCONFIG');
- function providePlatformConfigs() {
- return PLATFORM_CONFIGS;
- }
-
- var MODE_IOS = {
- activator: 'highlight',
- actionSheetEnter: 'action-sheet-slide-in',
- actionSheetLeave: 'action-sheet-slide-out',
- alertEnter: 'alert-pop-in',
- alertLeave: 'alert-pop-out',
- backButtonText: 'Back',
- backButtonIcon: 'ios-arrow-back',
- iconMode: 'ios',
- loadingEnter: 'loading-pop-in',
- loadingLeave: 'loading-pop-out',
- menuType: 'reveal',
- modalEnter: 'modal-slide-in',
- modalLeave: 'modal-slide-out',
- pageTransition: 'ios-transition',
- pickerEnter: 'picker-slide-in',
- pickerLeave: 'picker-slide-out',
- pickerRotateFactor: -0.46,
- pickerScaleFactor: 1,
- popoverEnter: 'popover-pop-in',
- popoverLeave: 'popover-pop-out',
- spinner: 'ios',
- tabsHighlight: false,
- tabsPlacement: 'bottom',
- tabsHideOnSubPages: false,
- toastEnter: 'toast-slide-in',
- toastLeave: 'toast-slide-out',
- };
- var MODE_MD = {
- activator: 'ripple',
- actionSheetEnter: 'action-sheet-md-slide-in',
- actionSheetLeave: 'action-sheet-md-slide-out',
- alertEnter: 'alert-md-pop-in',
- alertLeave: 'alert-md-pop-out',
- backButtonText: '',
- backButtonIcon: 'md-arrow-back',
- iconMode: 'md',
- loadingEnter: 'loading-md-pop-in',
- loadingLeave: 'loading-md-pop-out',
- menuType: 'overlay',
- modalEnter: 'modal-md-slide-in',
- modalLeave: 'modal-md-slide-out',
- pageTransition: 'md-transition',
- pickerEnter: 'picker-slide-in',
- pickerLeave: 'picker-slide-out',
- pickerRotateFactor: 0,
- pickerScaleFactor: 0.81,
- popoverEnter: 'popover-md-pop-in',
- popoverLeave: 'popover-md-pop-out',
- spinner: 'crescent',
- tabsHighlight: false,
- tabsPlacement: 'bottom',
- tabsHideOnSubPages: false,
- toastEnter: 'toast-md-slide-in',
- toastLeave: 'toast-md-slide-out',
- };
- var MODE_WP = {
- activator: 'highlight',
- actionSheetEnter: 'action-sheet-wp-slide-in',
- actionSheetLeave: 'action-sheet-wp-slide-out',
- alertEnter: 'alert-wp-pop-in',
- alertLeave: 'alert-wp-pop-out',
- backButtonText: '',
- backButtonIcon: 'ios-arrow-back',
- iconMode: 'ios',
- loadingEnter: 'loading-wp-pop-in',
- loadingLeave: 'loading-wp-pop-out',
- menuType: 'overlay',
- modalEnter: 'modal-md-slide-in',
- modalLeave: 'modal-md-slide-out',
- pageTransition: 'wp-transition',
- pickerEnter: 'picker-slide-in',
- pickerLeave: 'picker-slide-out',
- pickerRotateFactor: 0,
- pickerScaleFactor: 0.81,
- popoverEnter: 'popover-md-pop-in',
- popoverLeave: 'popover-md-pop-out',
- spinner: 'circles',
- tabsHighlight: false,
- tabsPlacement: 'top',
- tabsHideOnSubPages: true,
- toastEnter: 'toast-wp-slide-in',
- toastLeave: 'toast-wp-slide-out',
- };
- function registerModeConfigs(config) {
- return function () {
- // iOS Mode Settings
- config.setModeConfig('ios', MODE_IOS);
- // Material Design Mode Settings
- config.setModeConfig('md', MODE_MD);
- // Windows Mode Settings
- config.setModeConfig('wp', MODE_WP);
- };
- }
-
- var __extends$92 = (undefined && undefined.__extends) || (function () {
- var extendStatics = Object.setPrototypeOf ||
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
- function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
- return function (d, b) {
- extendStatics(d, b);
- function __() { this.constructor = d; }
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
- };
- })();
- /**
- * @hidden
- * This class overrides the default Angular gesture config.
- */
- var IonicGestureConfig = (function (_super) {
- __extends$92(IonicGestureConfig, _super);
- function IonicGestureConfig() {
- return _super !== null && _super.apply(this, arguments) || this;
- }
- IonicGestureConfig.prototype.buildHammer = function (element) {
- var mc = new window.Hammer(element);
- for (var eventName in this.overrides) {
- mc.get(eventName).set(this.overrides[eventName]);
- }
- return mc;
- };
- IonicGestureConfig.decorators = [
- { type: Injectable },
- ];
- /** @nocollapse */
- IonicGestureConfig.ctorParameters = function () { return []; };
- return IonicGestureConfig;
- }(HammerGestureConfig));
-
- /**
- * @hidden
- */
- var ClickBlock = (function () {
- function ClickBlock(app, config, plt, elementRef, renderer) {
- this.plt = plt;
- this.elementRef = elementRef;
- this.renderer = renderer;
- this._showing = false;
- app._clickBlock = this;
- var enabled = this.isEnabled = config.getBoolean('clickBlock', true);
- if (enabled) {
- this._setElementClass('click-block-enabled', true);
- }
- }
- ClickBlock.prototype.activate = function (shouldShow, expire, minDuration) {
- if (expire === void 0) { expire = 100; }
- if (minDuration === void 0) { minDuration = 0; }
- if (this.isEnabled) {
- this.plt.cancelTimeout(this._tmr);
- if (shouldShow) {
- // remember when we started the click block
- this._start = Date.now();
- // figure out the minimum time it should be showing until
- // this is useful for transitions that are less than 300ms
- this._minEnd = this._start + (minDuration || 0);
- this._activate(true);
- }
- this._tmr = this.plt.timeout(this._activate.bind(this, false), expire);
- }
- };
- /** @internal */
- ClickBlock.prototype._activate = function (shouldShow) {
- if (this._showing !== shouldShow) {
- if (!shouldShow) {
- // check if it was enabled before the minimum duration
- // this is useful for transitions that are less than 300ms
- var now = Date.now();
- if (now < this._minEnd) {
- this._tmr = this.plt.timeout(this._activate.bind(this, false), this._minEnd - now);
- return;
- }
- }
- this._setElementClass('click-block-active', shouldShow);
- this._showing = shouldShow;
- }
- };
- ClickBlock.prototype._setElementClass = function (className, add) {
- this.renderer.setElementClass(this.elementRef.nativeElement, className, add);
- };
- ClickBlock.decorators = [
- { type: Directive, args: [{
- selector: '.click-block'
- },] },
- ];
- /** @nocollapse */
- ClickBlock.ctorParameters = function () { return [
- { type: App, decorators: [{ type: Inject, args: [forwardRef(function () { return App; }),] },] },
- { type: Config, },
- { type: Platform, },
- { type: ElementRef, },
- { type: Renderer, },
- ]; };
- return ClickBlock;
- }());
-
- /**
- * Import Angular
- */
- /**
- * Global Providers
- */
- /**
- * Import Components/Directives/Etc
- */
- /**
- * @name IonicModule
- * @description
- * IonicModule is an [NgModule](https://angular.io/docs/ts/latest/guide/ngmodule.html) that bootstraps
- * an Ionic App. By passing a root component, IonicModule will make sure that all of the components,
- * directives, and providers from the framework are imported.
- *
- * Any configuration for the app can be passed as the second argument to `forRoot`. This can be any
- * valid property from the [Config](/docs/api/config/Config/).
- *
- * @usage
- * ```ts
- * import { NgModule } from '@angular/core';
- *
- * import { IonicApp, IonicModule } from 'ionic-angular';
- *
- * import { MyApp } from './app.component';
- * import { HomePage } from '../pages/home/home';
- *
- * @NgModule({
- * declarations: [
- * MyApp,
- * HomePage
- * ],
- * imports: [
- * BrowserModule,
- * IonicModule.forRoot(MyApp, {
- *
- * })
- * ],
- * bootstrap: [IonicApp],
- * entryComponents: [
- * MyApp,
- * HomePage
- * ],
- * providers: []
- * })
- * export class AppModule {}
- * ```
- */
- var IonicModule = (function () {
- function IonicModule() {
- }
- /**
- * Set the root app component for you IonicModule
- * @param {any} appRoot The root AppComponent for this app.
- * @param {any} config Config Options for the app. Accepts any config property.
- * @param {any} deepLinkConfig Any configuration needed for the Ionic Deeplinker.
- */
- IonicModule.forRoot = function (appRoot, config, deepLinkConfig) {
- if (config === void 0) { config = null; }
- if (deepLinkConfig === void 0) { deepLinkConfig = null; }
- return {
- ngModule: IonicModule,
- providers: [
- // useValue: bootstrap values
- { provide: AppRootToken, useValue: appRoot },
- { provide: ConfigToken, useValue: config },
- { provide: DeepLinkConfigToken, useValue: deepLinkConfig },
- { provide: APP_BASE_HREF, useValue: '/' },
- // useFactory: user values
- { provide: PlatformConfigToken, useFactory: providePlatformConfigs },
- // useFactory: ionic core providers
- { provide: Platform, useFactory: setupPlatform, deps: [DOCUMENT$1, PlatformConfigToken, NgZone] },
- { provide: Config, useFactory: setupConfig, deps: [ConfigToken, Platform] },
- // useFactory: ionic app initializers
- { provide: APP_INITIALIZER, useFactory: registerModeConfigs, deps: [Config], multi: true },
- { provide: APP_INITIALIZER, useFactory: setupProvideEvents, deps: [Platform, DomController], multi: true },
- { provide: APP_INITIALIZER, useFactory: setupTapClick, deps: [Config, Platform, DomController, App, GestureController], multi: true },
- { provide: APP_INITIALIZER, useFactory: setupPreloading, deps: [Config, DeepLinkConfigToken, ModuleLoader, NgZone], multi: true },
- // useClass
- { provide: HAMMER_GESTURE_CONFIG, useClass: IonicGestureConfig },
- // useValue
- { provide: ANALYZE_FOR_ENTRY_COMPONENTS, useValue: appRoot, multi: true },
- // ionic providers
- ActionSheetController,
- AlertController,
- App,
- DomController,
- Events,
- Form,
- GestureController,
- Haptic,
- Keyboard,
- LoadingController,
- Location,
- MenuController,
- ModalController,
- NgModuleLoader,
- PickerController,
- PopoverController,
- TapClick,
- ToastController,
- TransitionController,
- { provide: ModuleLoader, useFactory: provideModuleLoader, deps: [NgModuleLoader, Injector] },
- { provide: LocationStrategy, useFactory: provideLocationStrategy, deps: [PlatformLocation, [new Inject(APP_BASE_HREF), new Optional()], Config] },
- { provide: UrlSerializer, useFactory: setupUrlSerializer, deps: [App, DeepLinkConfigToken] },
- { provide: DeepLinker, useFactory: setupDeepLinker, deps: [App, UrlSerializer, Location, ModuleLoader, ComponentFactoryResolver] },
- ]
- };
- };
- IonicModule.decorators = [
- { type: NgModule, args: [{
- declarations: [
- ActionSheetCmp,
- AlertCmp,
- ClickBlock,
- IonicApp,
- OverlayPortal,
- Avatar,
- Backdrop,
- Badge,
- Button,
- Card,
- CardContent,
- CardHeader,
- CardTitle,
- Checkbox,
- Chip,
- Col,
- Content,
- DateTime,
- FabButton,
- FabContainer,
- FabList,
- Grid,
- Img,
- Icon,
- InfiniteScroll,
- InfiniteScrollContent,
- Item,
- ItemContent,
- ItemDivider,
- ItemGroup,
- ItemOptions,
- ItemReorder,
- ItemSliding,
- Label,
- List,
- ListHeader,
- Reorder,
- LoadingCmp,
- Menu,
- MenuClose,
- MenuToggle,
- ModalCmp,
- Nav,
- NavPop,
- NavPopAnchor,
- NavPush,
- NavPushAnchor,
- Note,
- Option,
- PickerCmp,
- PickerColumnCmp,
- PopoverCmp,
- RadioButton,
- RadioGroup,
- Range,
- RangeKnob,
- Refresher,
- RefresherContent,
- Row,
- Scroll,
- Searchbar,
- Segment,
- SegmentButton,
- Select,
- SelectPopover,
- ShowWhen,
- HideWhen,
- Slide,
- Slides,
- Spinner,
- SplitPane,
- Tab,
- TabButton,
- TabHighlight,
- Tabs,
- TextInput,
- Thumbnail,
- ToastCmp,
- Toggle,
- Footer,
- Header,
- Toolbar,
- ToolbarItem,
- ToolbarTitle,
- Navbar,
- Typography,
- VirtualFooter,
- VirtualHeader,
- VirtualItem,
- VirtualScroll
- ],
- imports: [
- CommonModule,
- FormsModule,
- ReactiveFormsModule,
- ],
- exports: [
- CommonModule,
- FormsModule,
- ReactiveFormsModule,
- ActionSheetCmp,
- AlertCmp,
- ClickBlock,
- IonicApp,
- OverlayPortal,
- Avatar,
- Backdrop,
- Badge,
- Button,
- Card,
- CardContent,
- CardHeader,
- CardTitle,
- Checkbox,
- Chip,
- Col,
- Content,
- DateTime,
- FabButton,
- FabContainer,
- FabList,
- Grid,
- Img,
- Icon,
- InfiniteScroll,
- InfiniteScrollContent,
- Item,
- ItemContent,
- ItemDivider,
- ItemGroup,
- ItemOptions,
- ItemReorder,
- ItemSliding,
- Label,
- List,
- ListHeader,
- Reorder,
- LoadingCmp,
- Menu,
- MenuClose,
- MenuToggle,
- ModalCmp,
- Nav,
- NavPop,
- NavPopAnchor,
- NavPush,
- NavPushAnchor,
- Note,
- Option,
- PickerCmp,
- PickerColumnCmp,
- PopoverCmp,
- RadioButton,
- RadioGroup,
- Range,
- RangeKnob,
- Refresher,
- RefresherContent,
- Row,
- Scroll,
- Searchbar,
- Segment,
- SegmentButton,
- Select,
- SelectPopover,
- ShowWhen,
- HideWhen,
- Slide,
- Slides,
- Spinner,
- SplitPane,
- Tab,
- TabButton,
- TabHighlight,
- Tabs,
- TextInput,
- Thumbnail,
- ToastCmp,
- Toggle,
- Footer,
- Header,
- Toolbar,
- ToolbarItem,
- ToolbarTitle,
- Navbar,
- Typography,
- VirtualFooter,
- VirtualHeader,
- VirtualItem,
- VirtualScroll
- ],
- entryComponents: [
- ActionSheetCmp,
- AlertCmp,
- IonicApp,
- LoadingCmp,
- ModalCmp,
- PickerCmp,
- PopoverCmp,
- SelectPopover,
- ToastCmp
- ]
- },] },
- ];
- /** @nocollapse */
- IonicModule.ctorParameters = function () { return []; };
- return IonicModule;
- }());
- /**
- * @name IonicPageModule
- * @description
- * IonicPageModule is an [NgModule](https://angular.io/docs/ts/latest/guide/ngmodule.html) that
- * bootstraps a child [IonicPage](../navigation/IonicPage/) in order to set up routing.
- *
- * @usage
- * ```ts
- * import { NgModule } from '@angular/core';
- *
- * import { IonicPageModule } from 'ionic-angular';
- *
- * import { HomePage } from './home';
- *
- * @NgModule({
- * declarations: [
- * HomePage
- * ],
- * imports: [
- * IonicPageModule.forChild(HomePage)
- * ],
- * entryComponents: [
- * HomePage
- * ]
- * })
- * export class HomePageModule { }
- * ```
- */
- var IonicPageModule = (function () {
- function IonicPageModule() {
- }
- IonicPageModule.forChild = function (page) {
- return {
- ngModule: IonicPageModule,
- providers: [
- { provide: LAZY_LOADED_TOKEN, useValue: page },
- { provide: ANALYZE_FOR_ENTRY_COMPONENTS, useValue: page, multi: true },
- ]
- };
- };
- IonicPageModule.decorators = [
- { type: NgModule, args: [{
- imports: [IonicModule],
- exports: [IonicModule]
- },] },
- ];
- /** @nocollapse */
- IonicPageModule.ctorParameters = function () { return []; };
- return IonicPageModule;
- }());
- /**
- * @hidden
- */
- function provideLocationStrategy(platformLocationStrategy, baseHref, config) {
- return config.get('locationStrategy') === 'path' ?
- new PathLocationStrategy(platformLocationStrategy, baseHref) :
- new HashLocationStrategy(platformLocationStrategy, baseHref);
- }
-
- exports.IonicApp = IonicApp;
- exports.MenuController = MenuController;
- exports.ActionSheet = ActionSheet;
- exports.ActionSheetController = ActionSheetController;
- exports.ActionSheetCmp = ActionSheetCmp;
- exports.Alert = Alert;
- exports.AlertController = AlertController;
- exports.AlertCmp = AlertCmp;
- exports.App = App;
- exports.Avatar = Avatar;
- exports.Backdrop = Backdrop;
- exports.Badge = Badge;
- exports.Button = Button;
- exports.Card = Card;
- exports.CardContent = CardContent;
- exports.CardHeader = CardHeader;
- exports.CardTitle = CardTitle;
- exports.Checkbox = Checkbox;
- exports.Chip = Chip;
- exports.Content = Content;
- exports.DateTime = DateTime;
- exports.FabButton = FabButton;
- exports.FabContainer = FabContainer;
- exports.FabList = FabList;
- exports.Col = Col;
- exports.Grid = Grid;
- exports.Row = Row;
- exports.Ion = Ion;
- exports.Icon = Icon;
- exports.Img = Img;
- exports.InfiniteScroll = InfiniteScroll;
- exports.InfiniteScrollContent = InfiniteScrollContent;
- exports.TextInput = TextInput;
- exports.Item = Item;
- exports.ItemContent = ItemContent;
- exports.ItemDivider = ItemDivider;
- exports.ItemGroup = ItemGroup;
- exports.ItemOptions = ItemOptions;
- exports.ItemReorder = ItemReorder;
- exports.ItemSliding = ItemSliding;
- exports.Reorder = Reorder;
- exports.Label = Label;
- exports.List = List;
- exports.ListHeader = ListHeader;
- exports.Loading = Loading;
- exports.LoadingController = LoadingController;
- exports.LoadingCmp = LoadingCmp;
- exports.Menu = Menu;
- exports.MenuClose = MenuClose;
- exports.MenuToggle = MenuToggle;
- exports.MenuType = MenuType;
- exports.Modal = Modal;
- exports.ModalCmp = ModalCmp;
- exports.ModalController = ModalController;
- exports.Nav = Nav;
- exports.NavPop = NavPop;
- exports.NavPopAnchor = NavPopAnchor;
- exports.NavPush = NavPush;
- exports.NavPushAnchor = NavPushAnchor;
- exports.Note = Note;
- exports.Option = Option;
- exports.Picker = Picker;
- exports.PickerCmp = PickerCmp;
- exports.PickerColumnCmp = PickerColumnCmp;
- exports.PickerController = PickerController;
- exports.Popover = Popover;
- exports.PopoverCmp = PopoverCmp;
- exports.PopoverController = PopoverController;
- exports.RadioButton = RadioButton;
- exports.RadioGroup = RadioGroup;
- exports.Range = Range;
- exports.RangeKnob = RangeKnob;
- exports.Refresher = Refresher;
- exports.RefresherContent = RefresherContent;
- exports.Scroll = Scroll;
- exports.Searchbar = Searchbar;
- exports.Segment = Segment;
- exports.SegmentButton = SegmentButton;
- exports.Select = Select;
- exports.SelectPopover = SelectPopover;
- exports.ShowWhen = ShowWhen;
- exports.DisplayWhen = DisplayWhen;
- exports.HideWhen = HideWhen;
- exports.Slide = Slide;
- exports.Slides = Slides;
- exports.Spinner = Spinner;
- exports.SplitPane = SplitPane;
- exports.RootNode = RootNode;
- exports.Tab = Tab;
- exports.TabButton = TabButton;
- exports.TabHighlight = TabHighlight;
- exports.Tabs = Tabs;
- exports.Toast = Toast;
- exports.ToastCmp = ToastCmp;
- exports.ToastController = ToastController;
- exports.Toggle = Toggle;
- exports.Footer = Footer;
- exports.Header = Header;
- exports.Toolbar = Toolbar;
- exports.ToolbarItem = ToolbarItem;
- exports.ToolbarTitle = ToolbarTitle;
- exports.Navbar = Navbar;
- exports.Thumbnail = Thumbnail;
- exports.Typography = Typography;
- exports.VirtualFooter = VirtualFooter;
- exports.VirtualHeader = VirtualHeader;
- exports.VirtualItem = VirtualItem;
- exports.VirtualScroll = VirtualScroll;
- exports.Config = Config;
- exports.setupConfig = setupConfig;
- exports.ConfigToken = ConfigToken;
- exports.DomController = DomController;
- exports.Platform = Platform;
- exports.setupPlatform = setupPlatform;
- exports.Haptic = Haptic;
- exports.DeepLinker = DeepLinker;
- exports.IonicPage = IonicPage;
- exports.NavController = NavController;
- exports.NavControllerBase = NavControllerBase;
- exports.NavParams = NavParams;
- exports.DeepLinkMetadata = DeepLinkMetadata;
- exports.DeepLinkMetadataFactory = DeepLinkMetadataFactory;
- exports.TapClick = TapClick;
- exports.setupTapClick = setupTapClick;
- exports.isActivatable = isActivatable;
- exports.UrlSerializer = UrlSerializer;
- exports.DeepLinkConfigToken = DeepLinkConfigToken;
- exports.ViewController = ViewController;
- exports.PanGesture = PanGesture;
- exports.Gesture = Gesture;
- exports.SlideEdgeGesture = SlideEdgeGesture;
- exports.SlideGesture = SlideGesture;
- exports.BLOCK_ALL = BLOCK_ALL;
- exports.GESTURE_GO_BACK_SWIPE = GESTURE_GO_BACK_SWIPE;
- exports.GESTURE_MENU_SWIPE = GESTURE_MENU_SWIPE;
- exports.GESTURE_ITEM_SWIPE = GESTURE_ITEM_SWIPE;
- exports.GESTURE_REFRESHER = GESTURE_REFRESHER;
- exports.GESTURE_TOGGLE = GESTURE_TOGGLE;
- exports.GestureController = GestureController;
- exports.GestureDelegate = GestureDelegate;
- exports.BlockerDelegate = BlockerDelegate;
- exports.Events = Events;
- exports.setupEvents = setupEvents;
- exports.setupProvideEvents = setupProvideEvents;
- exports.IonicErrorHandler = IonicErrorHandler;
- exports.Keyboard = Keyboard;
- exports.Form = Form;
- exports.IonicFormInput = IonicFormInput;
- exports.IonicTapInput = IonicTapInput;
- exports.reorderArray = reorderArray;
- exports.normalizeURL = normalizeURL;
- exports.Animation = Animation;
- exports.PageTransition = PageTransition;
- exports.Transition = Transition;
- exports.PlatformConfigToken = PlatformConfigToken;
- exports.registerModeConfigs = registerModeConfigs;
- exports.IonicGestureConfig = IonicGestureConfig;
- exports.IonicModule = IonicModule;
- exports.IonicPageModule = IonicPageModule;
- exports.provideLocationStrategy = provideLocationStrategy;
-
- Object.defineProperty(exports, '__esModule', { value: true });
-
- })));
|