ui-bootstrap-tpls-0.14.3.js 279 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503
  1. /*
  2. * angular-ui-bootstrap
  3. * http://angular-ui.github.io/bootstrap/
  4. * Version: 0.14.3 - 2015-10-23
  5. * License: MIT
  6. */
  7. angular.module("ui.bootstrap", ["ui.bootstrap.tpls", "ui.bootstrap.collapse","ui.bootstrap.accordion","ui.bootstrap.alert","ui.bootstrap.buttons","ui.bootstrap.carousel","ui.bootstrap.dateparser","ui.bootstrap.position","ui.bootstrap.datepicker","ui.bootstrap.dropdown","ui.bootstrap.stackedMap","ui.bootstrap.modal","ui.bootstrap.pagination","ui.bootstrap.tooltip","ui.bootstrap.popover","ui.bootstrap.progressbar","ui.bootstrap.rating","ui.bootstrap.tabs","ui.bootstrap.timepicker","ui.bootstrap.typeahead"]);
  8. angular.module("ui.bootstrap.tpls", ["template/accordion/accordion-group.html","template/accordion/accordion.html","template/alert/alert.html","template/carousel/carousel.html","template/carousel/slide.html","template/datepicker/datepicker.html","template/datepicker/day.html","template/datepicker/month.html","template/datepicker/popup.html","template/datepicker/year.html","template/modal/backdrop.html","template/modal/window.html","template/pagination/pager.html","template/pagination/pagination.html","template/tooltip/tooltip-html-popup.html","template/tooltip/tooltip-popup.html","template/tooltip/tooltip-template-popup.html","template/popover/popover-html.html","template/popover/popover-template.html","template/popover/popover.html","template/progressbar/bar.html","template/progressbar/progress.html","template/progressbar/progressbar.html","template/rating/rating.html","template/tabs/tab.html","template/tabs/tabset.html","template/timepicker/timepicker.html","template/typeahead/typeahead-match.html","template/typeahead/typeahead-popup.html"]);
  9. angular.module('ui.bootstrap.collapse', [])
  10. .directive('uibCollapse', ['$animate', '$injector', function($animate, $injector) {
  11. var $animateCss = $injector.has('$animateCss') ? $injector.get('$animateCss') : null;
  12. return {
  13. link: function(scope, element, attrs) {
  14. function expand() {
  15. element.removeClass('collapse')
  16. .addClass('collapsing')
  17. .attr('aria-expanded', true)
  18. .attr('aria-hidden', false);
  19. if ($animateCss) {
  20. $animateCss(element, {
  21. addClass: 'in',
  22. easing: 'ease',
  23. to: { height: element[0].scrollHeight + 'px' }
  24. }).start().finally(expandDone);
  25. } else {
  26. $animate.addClass(element, 'in', {
  27. to: { height: element[0].scrollHeight + 'px' }
  28. }).then(expandDone);
  29. }
  30. }
  31. function expandDone() {
  32. element.removeClass('collapsing')
  33. .addClass('collapse')
  34. .css({height: 'auto'});
  35. }
  36. function collapse() {
  37. if (!element.hasClass('collapse') && !element.hasClass('in')) {
  38. return collapseDone();
  39. }
  40. element
  41. // IMPORTANT: The height must be set before adding "collapsing" class.
  42. // Otherwise, the browser attempts to animate from height 0 (in
  43. // collapsing class) to the given height here.
  44. .css({height: element[0].scrollHeight + 'px'})
  45. // initially all panel collapse have the collapse class, this removal
  46. // prevents the animation from jumping to collapsed state
  47. .removeClass('collapse')
  48. .addClass('collapsing')
  49. .attr('aria-expanded', false)
  50. .attr('aria-hidden', true);
  51. if ($animateCss) {
  52. $animateCss(element, {
  53. removeClass: 'in',
  54. to: {height: '0'}
  55. }).start().finally(collapseDone);
  56. } else {
  57. $animate.removeClass(element, 'in', {
  58. to: {height: '0'}
  59. }).then(collapseDone);
  60. }
  61. }
  62. function collapseDone() {
  63. element.css({height: '0'}); // Required so that collapse works when animation is disabled
  64. element.removeClass('collapsing')
  65. .addClass('collapse');
  66. }
  67. scope.$watch(attrs.uibCollapse, function(shouldCollapse) {
  68. if (shouldCollapse) {
  69. collapse();
  70. } else {
  71. expand();
  72. }
  73. });
  74. }
  75. };
  76. }]);
  77. /* Deprecated collapse below */
  78. angular.module('ui.bootstrap.collapse')
  79. .value('$collapseSuppressWarning', false)
  80. .directive('collapse', ['$animate', '$injector', '$log', '$collapseSuppressWarning', function($animate, $injector, $log, $collapseSuppressWarning) {
  81. var $animateCss = $injector.has('$animateCss') ? $injector.get('$animateCss') : null;
  82. return {
  83. link: function(scope, element, attrs) {
  84. if (!$collapseSuppressWarning) {
  85. $log.warn('collapse is now deprecated. Use uib-collapse instead.');
  86. }
  87. function expand() {
  88. element.removeClass('collapse')
  89. .addClass('collapsing')
  90. .attr('aria-expanded', true)
  91. .attr('aria-hidden', false);
  92. if ($animateCss) {
  93. $animateCss(element, {
  94. easing: 'ease',
  95. to: { height: element[0].scrollHeight + 'px' }
  96. }).start().done(expandDone);
  97. } else {
  98. $animate.animate(element, {}, {
  99. height: element[0].scrollHeight + 'px'
  100. }).then(expandDone);
  101. }
  102. }
  103. function expandDone() {
  104. element.removeClass('collapsing')
  105. .addClass('collapse in')
  106. .css({height: 'auto'});
  107. }
  108. function collapse() {
  109. if (!element.hasClass('collapse') && !element.hasClass('in')) {
  110. return collapseDone();
  111. }
  112. element
  113. // IMPORTANT: The height must be set before adding "collapsing" class.
  114. // Otherwise, the browser attempts to animate from height 0 (in
  115. // collapsing class) to the given height here.
  116. .css({height: element[0].scrollHeight + 'px'})
  117. // initially all panel collapse have the collapse class, this removal
  118. // prevents the animation from jumping to collapsed state
  119. .removeClass('collapse in')
  120. .addClass('collapsing')
  121. .attr('aria-expanded', false)
  122. .attr('aria-hidden', true);
  123. if ($animateCss) {
  124. $animateCss(element, {
  125. to: {height: '0'}
  126. }).start().done(collapseDone);
  127. } else {
  128. $animate.animate(element, {}, {
  129. height: '0'
  130. }).then(collapseDone);
  131. }
  132. }
  133. function collapseDone() {
  134. element.css({height: '0'}); // Required so that collapse works when animation is disabled
  135. element.removeClass('collapsing')
  136. .addClass('collapse');
  137. }
  138. scope.$watch(attrs.collapse, function(shouldCollapse) {
  139. if (shouldCollapse) {
  140. collapse();
  141. } else {
  142. expand();
  143. }
  144. });
  145. }
  146. };
  147. }]);
  148. angular.module('ui.bootstrap.accordion', ['ui.bootstrap.collapse'])
  149. .constant('uibAccordionConfig', {
  150. closeOthers: true
  151. })
  152. .controller('UibAccordionController', ['$scope', '$attrs', 'uibAccordionConfig', function($scope, $attrs, accordionConfig) {
  153. // This array keeps track of the accordion groups
  154. this.groups = [];
  155. // Ensure that all the groups in this accordion are closed, unless close-others explicitly says not to
  156. this.closeOthers = function(openGroup) {
  157. var closeOthers = angular.isDefined($attrs.closeOthers) ?
  158. $scope.$eval($attrs.closeOthers) : accordionConfig.closeOthers;
  159. if (closeOthers) {
  160. angular.forEach(this.groups, function(group) {
  161. if (group !== openGroup) {
  162. group.isOpen = false;
  163. }
  164. });
  165. }
  166. };
  167. // This is called from the accordion-group directive to add itself to the accordion
  168. this.addGroup = function(groupScope) {
  169. var that = this;
  170. this.groups.push(groupScope);
  171. groupScope.$on('$destroy', function(event) {
  172. that.removeGroup(groupScope);
  173. });
  174. };
  175. // This is called from the accordion-group directive when to remove itself
  176. this.removeGroup = function(group) {
  177. var index = this.groups.indexOf(group);
  178. if (index !== -1) {
  179. this.groups.splice(index, 1);
  180. }
  181. };
  182. }])
  183. // The accordion directive simply sets up the directive controller
  184. // and adds an accordion CSS class to itself element.
  185. .directive('uibAccordion', function() {
  186. return {
  187. controller: 'UibAccordionController',
  188. controllerAs: 'accordion',
  189. transclude: true,
  190. templateUrl: function(element, attrs) {
  191. return attrs.templateUrl || 'template/accordion/accordion.html';
  192. }
  193. };
  194. })
  195. // The accordion-group directive indicates a block of html that will expand and collapse in an accordion
  196. .directive('uibAccordionGroup', function() {
  197. return {
  198. require: '^uibAccordion', // We need this directive to be inside an accordion
  199. transclude: true, // It transcludes the contents of the directive into the template
  200. replace: true, // The element containing the directive will be replaced with the template
  201. templateUrl: function(element, attrs) {
  202. return attrs.templateUrl || 'template/accordion/accordion-group.html';
  203. },
  204. scope: {
  205. heading: '@', // Interpolate the heading attribute onto this scope
  206. isOpen: '=?',
  207. isDisabled: '=?'
  208. },
  209. controller: function() {
  210. this.setHeading = function(element) {
  211. this.heading = element;
  212. };
  213. },
  214. link: function(scope, element, attrs, accordionCtrl) {
  215. accordionCtrl.addGroup(scope);
  216. scope.openClass = attrs.openClass || 'panel-open';
  217. scope.panelClass = attrs.panelClass;
  218. scope.$watch('isOpen', function(value) {
  219. element.toggleClass(scope.openClass, !!value);
  220. if (value) {
  221. accordionCtrl.closeOthers(scope);
  222. }
  223. });
  224. scope.toggleOpen = function($event) {
  225. if (!scope.isDisabled) {
  226. if (!$event || $event.which === 32) {
  227. scope.isOpen = !scope.isOpen;
  228. }
  229. }
  230. };
  231. }
  232. };
  233. })
  234. // Use accordion-heading below an accordion-group to provide a heading containing HTML
  235. .directive('uibAccordionHeading', function() {
  236. return {
  237. transclude: true, // Grab the contents to be used as the heading
  238. template: '', // In effect remove this element!
  239. replace: true,
  240. require: '^uibAccordionGroup',
  241. link: function(scope, element, attrs, accordionGroupCtrl, transclude) {
  242. // Pass the heading to the accordion-group controller
  243. // so that it can be transcluded into the right place in the template
  244. // [The second parameter to transclude causes the elements to be cloned so that they work in ng-repeat]
  245. accordionGroupCtrl.setHeading(transclude(scope, angular.noop));
  246. }
  247. };
  248. })
  249. // Use in the accordion-group template to indicate where you want the heading to be transcluded
  250. // You must provide the property on the accordion-group controller that will hold the transcluded element
  251. .directive('uibAccordionTransclude', function() {
  252. return {
  253. require: ['?^uibAccordionGroup', '?^accordionGroup'],
  254. link: function(scope, element, attrs, controller) {
  255. controller = controller[0] ? controller[0] : controller[1]; // Delete after we remove deprecation
  256. scope.$watch(function() { return controller[attrs.uibAccordionTransclude]; }, function(heading) {
  257. if (heading) {
  258. element.find('span').html('');
  259. element.find('span').append(heading);
  260. }
  261. });
  262. }
  263. };
  264. });
  265. /* Deprecated accordion below */
  266. angular.module('ui.bootstrap.accordion')
  267. .value('$accordionSuppressWarning', false)
  268. .controller('AccordionController', ['$scope', '$attrs', '$controller', '$log', '$accordionSuppressWarning', function($scope, $attrs, $controller, $log, $accordionSuppressWarning) {
  269. if (!$accordionSuppressWarning) {
  270. $log.warn('AccordionController is now deprecated. Use UibAccordionController instead.');
  271. }
  272. angular.extend(this, $controller('UibAccordionController', {
  273. $scope: $scope,
  274. $attrs: $attrs
  275. }));
  276. }])
  277. .directive('accordion', ['$log', '$accordionSuppressWarning', function($log, $accordionSuppressWarning) {
  278. return {
  279. restrict: 'EA',
  280. controller: 'AccordionController',
  281. controllerAs: 'accordion',
  282. transclude: true,
  283. replace: false,
  284. templateUrl: function(element, attrs) {
  285. return attrs.templateUrl || 'template/accordion/accordion.html';
  286. },
  287. link: function() {
  288. if (!$accordionSuppressWarning) {
  289. $log.warn('accordion is now deprecated. Use uib-accordion instead.');
  290. }
  291. }
  292. };
  293. }])
  294. .directive('accordionGroup', ['$log', '$accordionSuppressWarning', function($log, $accordionSuppressWarning) {
  295. return {
  296. require: '^accordion', // We need this directive to be inside an accordion
  297. restrict: 'EA',
  298. transclude: true, // It transcludes the contents of the directive into the template
  299. replace: true, // The element containing the directive will be replaced with the template
  300. templateUrl: function(element, attrs) {
  301. return attrs.templateUrl || 'template/accordion/accordion-group.html';
  302. },
  303. scope: {
  304. heading: '@', // Interpolate the heading attribute onto this scope
  305. isOpen: '=?',
  306. isDisabled: '=?'
  307. },
  308. controller: function() {
  309. this.setHeading = function(element) {
  310. this.heading = element;
  311. };
  312. },
  313. link: function(scope, element, attrs, accordionCtrl) {
  314. if (!$accordionSuppressWarning) {
  315. $log.warn('accordion-group is now deprecated. Use uib-accordion-group instead.');
  316. }
  317. accordionCtrl.addGroup(scope);
  318. scope.openClass = attrs.openClass || 'panel-open';
  319. scope.panelClass = attrs.panelClass;
  320. scope.$watch('isOpen', function(value) {
  321. element.toggleClass(scope.openClass, !!value);
  322. if (value) {
  323. accordionCtrl.closeOthers(scope);
  324. }
  325. });
  326. scope.toggleOpen = function($event) {
  327. if (!scope.isDisabled) {
  328. if (!$event || $event.which === 32) {
  329. scope.isOpen = !scope.isOpen;
  330. }
  331. }
  332. };
  333. }
  334. };
  335. }])
  336. .directive('accordionHeading', ['$log', '$accordionSuppressWarning', function($log, $accordionSuppressWarning) {
  337. return {
  338. restrict: 'EA',
  339. transclude: true, // Grab the contents to be used as the heading
  340. template: '', // In effect remove this element!
  341. replace: true,
  342. require: '^accordionGroup',
  343. link: function(scope, element, attr, accordionGroupCtrl, transclude) {
  344. if (!$accordionSuppressWarning) {
  345. $log.warn('accordion-heading is now deprecated. Use uib-accordion-heading instead.');
  346. }
  347. // Pass the heading to the accordion-group controller
  348. // so that it can be transcluded into the right place in the template
  349. // [The second parameter to transclude causes the elements to be cloned so that they work in ng-repeat]
  350. accordionGroupCtrl.setHeading(transclude(scope, angular.noop));
  351. }
  352. };
  353. }])
  354. .directive('accordionTransclude', ['$log', '$accordionSuppressWarning', function($log, $accordionSuppressWarning) {
  355. return {
  356. require: '^accordionGroup',
  357. link: function(scope, element, attr, controller) {
  358. if (!$accordionSuppressWarning) {
  359. $log.warn('accordion-transclude is now deprecated. Use uib-accordion-transclude instead.');
  360. }
  361. scope.$watch(function() { return controller[attr.accordionTransclude]; }, function(heading) {
  362. if (heading) {
  363. element.find('span').html('');
  364. element.find('span').append(heading);
  365. }
  366. });
  367. }
  368. };
  369. }]);
  370. angular.module('ui.bootstrap.alert', [])
  371. .controller('UibAlertController', ['$scope', '$attrs', '$interpolate', '$timeout', function($scope, $attrs, $interpolate, $timeout) {
  372. $scope.closeable = !!$attrs.close;
  373. var dismissOnTimeout = angular.isDefined($attrs.dismissOnTimeout) ?
  374. $interpolate($attrs.dismissOnTimeout)($scope.$parent) : null;
  375. if (dismissOnTimeout) {
  376. $timeout(function() {
  377. $scope.close();
  378. }, parseInt(dismissOnTimeout, 10));
  379. }
  380. }])
  381. .directive('uibAlert', function() {
  382. return {
  383. controller: 'UibAlertController',
  384. controllerAs: 'alert',
  385. templateUrl: function(element, attrs) {
  386. return attrs.templateUrl || 'template/alert/alert.html';
  387. },
  388. transclude: true,
  389. replace: true,
  390. scope: {
  391. type: '@',
  392. close: '&'
  393. }
  394. };
  395. });
  396. /* Deprecated alert below */
  397. angular.module('ui.bootstrap.alert')
  398. .value('$alertSuppressWarning', false)
  399. .controller('AlertController', ['$scope', '$attrs', '$controller', '$log', '$alertSuppressWarning', function($scope, $attrs, $controller, $log, $alertSuppressWarning) {
  400. if (!$alertSuppressWarning) {
  401. $log.warn('AlertController is now deprecated. Use UibAlertController instead.');
  402. }
  403. angular.extend(this, $controller('UibAlertController', {
  404. $scope: $scope,
  405. $attrs: $attrs
  406. }));
  407. }])
  408. .directive('alert', ['$log', '$alertSuppressWarning', function($log, $alertSuppressWarning) {
  409. return {
  410. controller: 'AlertController',
  411. controllerAs: 'alert',
  412. templateUrl: function(element, attrs) {
  413. return attrs.templateUrl || 'template/alert/alert.html';
  414. },
  415. transclude: true,
  416. replace: true,
  417. scope: {
  418. type: '@',
  419. close: '&'
  420. },
  421. link: function() {
  422. if (!$alertSuppressWarning) {
  423. $log.warn('alert is now deprecated. Use uib-alert instead.');
  424. }
  425. }
  426. };
  427. }]);
  428. angular.module('ui.bootstrap.buttons', [])
  429. .constant('uibButtonConfig', {
  430. activeClass: 'active',
  431. toggleEvent: 'click'
  432. })
  433. .controller('UibButtonsController', ['uibButtonConfig', function(buttonConfig) {
  434. this.activeClass = buttonConfig.activeClass || 'active';
  435. this.toggleEvent = buttonConfig.toggleEvent || 'click';
  436. }])
  437. .directive('uibBtnRadio', function() {
  438. return {
  439. require: ['uibBtnRadio', 'ngModel'],
  440. controller: 'UibButtonsController',
  441. controllerAs: 'buttons',
  442. link: function(scope, element, attrs, ctrls) {
  443. var buttonsCtrl = ctrls[0], ngModelCtrl = ctrls[1];
  444. element.find('input').css({display: 'none'});
  445. //model -> UI
  446. ngModelCtrl.$render = function() {
  447. element.toggleClass(buttonsCtrl.activeClass, angular.equals(ngModelCtrl.$modelValue, scope.$eval(attrs.uibBtnRadio)));
  448. };
  449. //ui->model
  450. element.on(buttonsCtrl.toggleEvent, function() {
  451. if (attrs.disabled) {
  452. return;
  453. }
  454. var isActive = element.hasClass(buttonsCtrl.activeClass);
  455. if (!isActive || angular.isDefined(attrs.uncheckable)) {
  456. scope.$apply(function() {
  457. ngModelCtrl.$setViewValue(isActive ? null : scope.$eval(attrs.uibBtnRadio));
  458. ngModelCtrl.$render();
  459. });
  460. }
  461. });
  462. }
  463. };
  464. })
  465. .directive('uibBtnCheckbox', function() {
  466. return {
  467. require: ['uibBtnCheckbox', 'ngModel'],
  468. controller: 'UibButtonsController',
  469. controllerAs: 'button',
  470. link: function(scope, element, attrs, ctrls) {
  471. var buttonsCtrl = ctrls[0], ngModelCtrl = ctrls[1];
  472. element.find('input').css({display: 'none'});
  473. function getTrueValue() {
  474. return getCheckboxValue(attrs.btnCheckboxTrue, true);
  475. }
  476. function getFalseValue() {
  477. return getCheckboxValue(attrs.btnCheckboxFalse, false);
  478. }
  479. function getCheckboxValue(attribute, defaultValue) {
  480. return angular.isDefined(attribute) ? scope.$eval(attribute) : defaultValue;
  481. }
  482. //model -> UI
  483. ngModelCtrl.$render = function() {
  484. element.toggleClass(buttonsCtrl.activeClass, angular.equals(ngModelCtrl.$modelValue, getTrueValue()));
  485. };
  486. //ui->model
  487. element.on(buttonsCtrl.toggleEvent, function() {
  488. if (attrs.disabled) {
  489. return;
  490. }
  491. scope.$apply(function() {
  492. ngModelCtrl.$setViewValue(element.hasClass(buttonsCtrl.activeClass) ? getFalseValue() : getTrueValue());
  493. ngModelCtrl.$render();
  494. });
  495. });
  496. }
  497. };
  498. });
  499. /* Deprecated buttons below */
  500. angular.module('ui.bootstrap.buttons')
  501. .value('$buttonsSuppressWarning', false)
  502. .controller('ButtonsController', ['$controller', '$log', '$buttonsSuppressWarning', function($controller, $log, $buttonsSuppressWarning) {
  503. if (!$buttonsSuppressWarning) {
  504. $log.warn('ButtonsController is now deprecated. Use UibButtonsController instead.');
  505. }
  506. angular.extend(this, $controller('UibButtonsController'));
  507. }])
  508. .directive('btnRadio', ['$log', '$buttonsSuppressWarning', function($log, $buttonsSuppressWarning) {
  509. return {
  510. require: ['btnRadio', 'ngModel'],
  511. controller: 'ButtonsController',
  512. controllerAs: 'buttons',
  513. link: function(scope, element, attrs, ctrls) {
  514. if (!$buttonsSuppressWarning) {
  515. $log.warn('btn-radio is now deprecated. Use uib-btn-radio instead.');
  516. }
  517. var buttonsCtrl = ctrls[0], ngModelCtrl = ctrls[1];
  518. element.find('input').css({display: 'none'});
  519. //model -> UI
  520. ngModelCtrl.$render = function() {
  521. element.toggleClass(buttonsCtrl.activeClass, angular.equals(ngModelCtrl.$modelValue, scope.$eval(attrs.btnRadio)));
  522. };
  523. //ui->model
  524. element.bind(buttonsCtrl.toggleEvent, function() {
  525. if (attrs.disabled) {
  526. return;
  527. }
  528. var isActive = element.hasClass(buttonsCtrl.activeClass);
  529. if (!isActive || angular.isDefined(attrs.uncheckable)) {
  530. scope.$apply(function() {
  531. ngModelCtrl.$setViewValue(isActive ? null : scope.$eval(attrs.btnRadio));
  532. ngModelCtrl.$render();
  533. });
  534. }
  535. });
  536. }
  537. };
  538. }])
  539. .directive('btnCheckbox', ['$document', '$log', '$buttonsSuppressWarning', function($document, $log, $buttonsSuppressWarning) {
  540. return {
  541. require: ['btnCheckbox', 'ngModel'],
  542. controller: 'ButtonsController',
  543. controllerAs: 'button',
  544. link: function(scope, element, attrs, ctrls) {
  545. if (!$buttonsSuppressWarning) {
  546. $log.warn('btn-checkbox is now deprecated. Use uib-btn-checkbox instead.');
  547. }
  548. var buttonsCtrl = ctrls[0], ngModelCtrl = ctrls[1];
  549. element.find('input').css({display: 'none'});
  550. function getTrueValue() {
  551. return getCheckboxValue(attrs.btnCheckboxTrue, true);
  552. }
  553. function getFalseValue() {
  554. return getCheckboxValue(attrs.btnCheckboxFalse, false);
  555. }
  556. function getCheckboxValue(attributeValue, defaultValue) {
  557. var val = scope.$eval(attributeValue);
  558. return angular.isDefined(val) ? val : defaultValue;
  559. }
  560. //model -> UI
  561. ngModelCtrl.$render = function() {
  562. element.toggleClass(buttonsCtrl.activeClass, angular.equals(ngModelCtrl.$modelValue, getTrueValue()));
  563. };
  564. //ui->model
  565. element.bind(buttonsCtrl.toggleEvent, function() {
  566. if (attrs.disabled) {
  567. return;
  568. }
  569. scope.$apply(function() {
  570. ngModelCtrl.$setViewValue(element.hasClass(buttonsCtrl.activeClass) ? getFalseValue() : getTrueValue());
  571. ngModelCtrl.$render();
  572. });
  573. });
  574. //accessibility
  575. element.on('keypress', function(e) {
  576. if (attrs.disabled || e.which !== 32 || $document[0].activeElement !== element[0]) {
  577. return;
  578. }
  579. scope.$apply(function() {
  580. ngModelCtrl.$setViewValue(element.hasClass(buttonsCtrl.activeClass) ? getFalseValue() : getTrueValue());
  581. ngModelCtrl.$render();
  582. });
  583. });
  584. }
  585. };
  586. }]);
  587. /**
  588. * @ngdoc overview
  589. * @name ui.bootstrap.carousel
  590. *
  591. * @description
  592. * AngularJS version of an image carousel.
  593. *
  594. */
  595. angular.module('ui.bootstrap.carousel', [])
  596. .controller('UibCarouselController', ['$scope', '$element', '$interval', '$animate', function($scope, $element, $interval, $animate) {
  597. var self = this,
  598. slides = self.slides = $scope.slides = [],
  599. NEW_ANIMATE = angular.version.minor >= 4,
  600. NO_TRANSITION = 'uib-noTransition',
  601. SLIDE_DIRECTION = 'uib-slideDirection',
  602. currentIndex = -1,
  603. currentInterval, isPlaying;
  604. self.currentSlide = null;
  605. var destroyed = false;
  606. /* direction: "prev" or "next" */
  607. self.select = $scope.select = function(nextSlide, direction) {
  608. var nextIndex = $scope.indexOfSlide(nextSlide);
  609. //Decide direction if it's not given
  610. if (direction === undefined) {
  611. direction = nextIndex > self.getCurrentIndex() ? 'next' : 'prev';
  612. }
  613. //Prevent this user-triggered transition from occurring if there is already one in progress
  614. if (nextSlide && nextSlide !== self.currentSlide && !$scope.$currentTransition) {
  615. goNext(nextSlide, nextIndex, direction);
  616. }
  617. };
  618. function goNext(slide, index, direction) {
  619. // Scope has been destroyed, stop here.
  620. if (destroyed) { return; }
  621. angular.extend(slide, {direction: direction, active: true});
  622. angular.extend(self.currentSlide || {}, {direction: direction, active: false});
  623. if ($animate.enabled() && !$scope.noTransition && !$scope.$currentTransition &&
  624. slide.$element && self.slides.length > 1) {
  625. slide.$element.data(SLIDE_DIRECTION, slide.direction);
  626. if (self.currentSlide && self.currentSlide.$element) {
  627. self.currentSlide.$element.data(SLIDE_DIRECTION, slide.direction);
  628. }
  629. $scope.$currentTransition = true;
  630. if (NEW_ANIMATE) {
  631. $animate.on('addClass', slide.$element, function(element, phase) {
  632. if (phase === 'close') {
  633. $scope.$currentTransition = null;
  634. $animate.off('addClass', element);
  635. }
  636. });
  637. } else {
  638. slide.$element.one('$animate:close', function closeFn() {
  639. $scope.$currentTransition = null;
  640. });
  641. }
  642. }
  643. self.currentSlide = slide;
  644. currentIndex = index;
  645. //every time you change slides, reset the timer
  646. restartTimer();
  647. }
  648. $scope.$on('$destroy', function() {
  649. destroyed = true;
  650. });
  651. function getSlideByIndex(index) {
  652. if (angular.isUndefined(slides[index].index)) {
  653. return slides[index];
  654. }
  655. var i, len = slides.length;
  656. for (i = 0; i < slides.length; ++i) {
  657. if (slides[i].index == index) {
  658. return slides[i];
  659. }
  660. }
  661. }
  662. self.getCurrentIndex = function() {
  663. if (self.currentSlide && angular.isDefined(self.currentSlide.index)) {
  664. return +self.currentSlide.index;
  665. }
  666. return currentIndex;
  667. };
  668. /* Allow outside people to call indexOf on slides array */
  669. $scope.indexOfSlide = function(slide) {
  670. return angular.isDefined(slide.index) ? +slide.index : slides.indexOf(slide);
  671. };
  672. $scope.next = function() {
  673. var newIndex = (self.getCurrentIndex() + 1) % slides.length;
  674. if (newIndex === 0 && $scope.noWrap()) {
  675. $scope.pause();
  676. return;
  677. }
  678. return self.select(getSlideByIndex(newIndex), 'next');
  679. };
  680. $scope.prev = function() {
  681. var newIndex = self.getCurrentIndex() - 1 < 0 ? slides.length - 1 : self.getCurrentIndex() - 1;
  682. if ($scope.noWrap() && newIndex === slides.length - 1) {
  683. $scope.pause();
  684. return;
  685. }
  686. return self.select(getSlideByIndex(newIndex), 'prev');
  687. };
  688. $scope.isActive = function(slide) {
  689. return self.currentSlide === slide;
  690. };
  691. $scope.$watch('interval', restartTimer);
  692. $scope.$watchCollection('slides', resetTransition);
  693. $scope.$on('$destroy', resetTimer);
  694. function restartTimer() {
  695. resetTimer();
  696. var interval = +$scope.interval;
  697. if (!isNaN(interval) && interval > 0) {
  698. currentInterval = $interval(timerFn, interval);
  699. }
  700. }
  701. function resetTimer() {
  702. if (currentInterval) {
  703. $interval.cancel(currentInterval);
  704. currentInterval = null;
  705. }
  706. }
  707. function timerFn() {
  708. var interval = +$scope.interval;
  709. if (isPlaying && !isNaN(interval) && interval > 0 && slides.length) {
  710. $scope.next();
  711. } else {
  712. $scope.pause();
  713. }
  714. }
  715. function resetTransition(slides) {
  716. if (!slides.length) {
  717. $scope.$currentTransition = null;
  718. }
  719. }
  720. $scope.play = function() {
  721. if (!isPlaying) {
  722. isPlaying = true;
  723. restartTimer();
  724. }
  725. };
  726. $scope.pause = function() {
  727. if (!$scope.noPause) {
  728. isPlaying = false;
  729. resetTimer();
  730. }
  731. };
  732. self.addSlide = function(slide, element) {
  733. slide.$element = element;
  734. slides.push(slide);
  735. //if this is the first slide or the slide is set to active, select it
  736. if (slides.length === 1 || slide.active) {
  737. self.select(slides[slides.length - 1]);
  738. if (slides.length === 1) {
  739. $scope.play();
  740. }
  741. } else {
  742. slide.active = false;
  743. }
  744. };
  745. self.removeSlide = function(slide) {
  746. if (angular.isDefined(slide.index)) {
  747. slides.sort(function(a, b) {
  748. return +a.index > +b.index;
  749. });
  750. }
  751. //get the index of the slide inside the carousel
  752. var index = slides.indexOf(slide);
  753. slides.splice(index, 1);
  754. if (slides.length > 0 && slide.active) {
  755. if (index >= slides.length) {
  756. self.select(slides[index - 1]);
  757. } else {
  758. self.select(slides[index]);
  759. }
  760. } else if (currentIndex > index) {
  761. currentIndex--;
  762. }
  763. //clean the currentSlide when no more slide
  764. if (slides.length === 0) {
  765. self.currentSlide = null;
  766. }
  767. };
  768. $scope.$watch('noTransition', function(noTransition) {
  769. $element.data(NO_TRANSITION, noTransition);
  770. });
  771. }])
  772. /**
  773. * @ngdoc directive
  774. * @name ui.bootstrap.carousel.directive:carousel
  775. * @restrict EA
  776. *
  777. * @description
  778. * Carousel is the outer container for a set of image 'slides' to showcase.
  779. *
  780. * @param {number=} interval The time, in milliseconds, that it will take the carousel to go to the next slide.
  781. * @param {boolean=} noTransition Whether to disable transitions on the carousel.
  782. * @param {boolean=} noPause Whether to disable pausing on the carousel (by default, the carousel interval pauses on hover).
  783. *
  784. * @example
  785. <example module="ui.bootstrap">
  786. <file name="index.html">
  787. <uib-carousel>
  788. <uib-slide>
  789. <img src="http://placekitten.com/150/150" style="margin:auto;">
  790. <div class="carousel-caption">
  791. <p>Beautiful!</p>
  792. </div>
  793. </uib-slide>
  794. <uib-slide>
  795. <img src="http://placekitten.com/100/150" style="margin:auto;">
  796. <div class="carousel-caption">
  797. <p>D'aww!</p>
  798. </div>
  799. </uib-slide>
  800. </uib-carousel>
  801. </file>
  802. <file name="demo.css">
  803. .carousel-indicators {
  804. top: auto;
  805. bottom: 15px;
  806. }
  807. </file>
  808. </example>
  809. */
  810. .directive('uibCarousel', [function() {
  811. return {
  812. transclude: true,
  813. replace: true,
  814. controller: 'UibCarouselController',
  815. controllerAs: 'carousel',
  816. require: 'carousel',
  817. templateUrl: function(element, attrs) {
  818. return attrs.templateUrl || 'template/carousel/carousel.html';
  819. },
  820. scope: {
  821. interval: '=',
  822. noTransition: '=',
  823. noPause: '=',
  824. noWrap: '&'
  825. }
  826. };
  827. }])
  828. /**
  829. * @ngdoc directive
  830. * @name ui.bootstrap.carousel.directive:slide
  831. * @restrict EA
  832. *
  833. * @description
  834. * Creates a slide inside a {@link ui.bootstrap.carousel.directive:carousel carousel}. Must be placed as a child of a carousel element.
  835. *
  836. * @param {boolean=} active Model binding, whether or not this slide is currently active.
  837. * @param {number=} index The index of the slide. The slides will be sorted by this parameter.
  838. *
  839. * @example
  840. <example module="ui.bootstrap">
  841. <file name="index.html">
  842. <div ng-controller="CarouselDemoCtrl">
  843. <uib-carousel>
  844. <uib-slide ng-repeat="slide in slides" active="slide.active" index="$index">
  845. <img ng-src="{{slide.image}}" style="margin:auto;">
  846. <div class="carousel-caption">
  847. <h4>Slide {{$index}}</h4>
  848. <p>{{slide.text}}</p>
  849. </div>
  850. </uib-slide>
  851. </uib-carousel>
  852. Interval, in milliseconds: <input type="number" ng-model="myInterval">
  853. <br />Enter a negative number to stop the interval.
  854. </div>
  855. </file>
  856. <file name="script.js">
  857. function CarouselDemoCtrl($scope) {
  858. $scope.myInterval = 5000;
  859. }
  860. </file>
  861. <file name="demo.css">
  862. .carousel-indicators {
  863. top: auto;
  864. bottom: 15px;
  865. }
  866. </file>
  867. </example>
  868. */
  869. .directive('uibSlide', function() {
  870. return {
  871. require: '^uibCarousel',
  872. restrict: 'EA',
  873. transclude: true,
  874. replace: true,
  875. templateUrl: function(element, attrs) {
  876. return attrs.templateUrl || 'template/carousel/slide.html';
  877. },
  878. scope: {
  879. active: '=?',
  880. actual: '=?',
  881. index: '=?'
  882. },
  883. link: function (scope, element, attrs, carouselCtrl) {
  884. carouselCtrl.addSlide(scope, element);
  885. //when the scope is destroyed then remove the slide from the current slides array
  886. scope.$on('$destroy', function() {
  887. carouselCtrl.removeSlide(scope);
  888. });
  889. scope.$watch('active', function(active) {
  890. if (active) {
  891. carouselCtrl.select(scope);
  892. }
  893. });
  894. }
  895. };
  896. })
  897. .animation('.item', [
  898. '$injector', '$animate',
  899. function ($injector, $animate) {
  900. var NO_TRANSITION = 'uib-noTransition',
  901. SLIDE_DIRECTION = 'uib-slideDirection',
  902. $animateCss = null;
  903. if ($injector.has('$animateCss')) {
  904. $animateCss = $injector.get('$animateCss');
  905. }
  906. function removeClass(element, className, callback) {
  907. element.removeClass(className);
  908. if (callback) {
  909. callback();
  910. }
  911. }
  912. return {
  913. beforeAddClass: function(element, className, done) {
  914. // Due to transclusion, noTransition property is on parent's scope
  915. if (className == 'active' && element.parent() && element.parent().parent() &&
  916. !element.parent().parent().data(NO_TRANSITION)) {
  917. var stopped = false;
  918. var direction = element.data(SLIDE_DIRECTION);
  919. var directionClass = direction == 'next' ? 'left' : 'right';
  920. var removeClassFn = removeClass.bind(this, element,
  921. directionClass + ' ' + direction, done);
  922. element.addClass(direction);
  923. if ($animateCss) {
  924. $animateCss(element, {addClass: directionClass})
  925. .start()
  926. .done(removeClassFn);
  927. } else {
  928. $animate.addClass(element, directionClass).then(function () {
  929. if (!stopped) {
  930. removeClassFn();
  931. }
  932. done();
  933. });
  934. }
  935. return function () {
  936. stopped = true;
  937. };
  938. }
  939. done();
  940. },
  941. beforeRemoveClass: function (element, className, done) {
  942. // Due to transclusion, noTransition property is on parent's scope
  943. if (className === 'active' && element.parent() && element.parent().parent() &&
  944. !element.parent().parent().data(NO_TRANSITION)) {
  945. var stopped = false;
  946. var direction = element.data(SLIDE_DIRECTION);
  947. var directionClass = direction == 'next' ? 'left' : 'right';
  948. var removeClassFn = removeClass.bind(this, element, directionClass, done);
  949. if ($animateCss) {
  950. $animateCss(element, {addClass: directionClass})
  951. .start()
  952. .done(removeClassFn);
  953. } else {
  954. $animate.addClass(element, directionClass).then(function() {
  955. if (!stopped) {
  956. removeClassFn();
  957. }
  958. done();
  959. });
  960. }
  961. return function() {
  962. stopped = true;
  963. };
  964. }
  965. done();
  966. }
  967. };
  968. }]);
  969. /* deprecated carousel below */
  970. angular.module('ui.bootstrap.carousel')
  971. .value('$carouselSuppressWarning', false)
  972. .controller('CarouselController', ['$scope', '$element', '$controller', '$log', '$carouselSuppressWarning', function($scope, $element, $controller, $log, $carouselSuppressWarning) {
  973. if (!$carouselSuppressWarning) {
  974. $log.warn('CarouselController is now deprecated. Use UibCarouselController instead.');
  975. }
  976. angular.extend(this, $controller('UibCarouselController', {
  977. $scope: $scope,
  978. $element: $element
  979. }));
  980. }])
  981. .directive('carousel', ['$log', '$carouselSuppressWarning', function($log, $carouselSuppressWarning) {
  982. return {
  983. transclude: true,
  984. replace: true,
  985. controller: 'CarouselController',
  986. controllerAs: 'carousel',
  987. require: 'carousel',
  988. templateUrl: function(element, attrs) {
  989. return attrs.templateUrl || 'template/carousel/carousel.html';
  990. },
  991. scope: {
  992. interval: '=',
  993. noTransition: '=',
  994. noPause: '=',
  995. noWrap: '&'
  996. },
  997. link: function() {
  998. if (!$carouselSuppressWarning) {
  999. $log.warn('carousel is now deprecated. Use uib-carousel instead.');
  1000. }
  1001. }
  1002. };
  1003. }])
  1004. .directive('slide', ['$log', '$carouselSuppressWarning', function($log, $carouselSuppressWarning) {
  1005. return {
  1006. require: '^carousel',
  1007. transclude: true,
  1008. replace: true,
  1009. templateUrl: function(element, attrs) {
  1010. return attrs.templateUrl || 'template/carousel/slide.html';
  1011. },
  1012. scope: {
  1013. active: '=?',
  1014. actual: '=?',
  1015. index: '=?'
  1016. },
  1017. link: function (scope, element, attrs, carouselCtrl) {
  1018. if (!$carouselSuppressWarning) {
  1019. $log.warn('slide is now deprecated. Use uib-slide instead.');
  1020. }
  1021. carouselCtrl.addSlide(scope, element);
  1022. //when the scope is destroyed then remove the slide from the current slides array
  1023. scope.$on('$destroy', function() {
  1024. carouselCtrl.removeSlide(scope);
  1025. });
  1026. scope.$watch('active', function(active) {
  1027. if (active) {
  1028. carouselCtrl.select(scope);
  1029. }
  1030. });
  1031. }
  1032. };
  1033. }]);
  1034. angular.module('ui.bootstrap.dateparser', [])
  1035. .service('uibDateParser', ['$log', '$locale', 'orderByFilter', function($log, $locale, orderByFilter) {
  1036. // Pulled from https://github.com/mbostock/d3/blob/master/src/format/requote.js
  1037. var SPECIAL_CHARACTERS_REGEXP = /[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g;
  1038. var localeId;
  1039. var formatCodeToRegex;
  1040. this.init = function() {
  1041. localeId = $locale.id;
  1042. this.parsers = {};
  1043. formatCodeToRegex = {
  1044. 'yyyy': {
  1045. regex: '\\d{4}',
  1046. apply: function(value) { this.year = +value; }
  1047. },
  1048. 'yy': {
  1049. regex: '\\d{2}',
  1050. apply: function(value) { this.year = +value + 2000; }
  1051. },
  1052. 'y': {
  1053. regex: '\\d{1,4}',
  1054. apply: function(value) { this.year = +value; }
  1055. },
  1056. 'MMMM': {
  1057. regex: $locale.DATETIME_FORMATS.MONTH.join('|'),
  1058. apply: function(value) { this.month = $locale.DATETIME_FORMATS.MONTH.indexOf(value); }
  1059. },
  1060. 'MMM': {
  1061. regex: $locale.DATETIME_FORMATS.SHORTMONTH.join('|'),
  1062. apply: function(value) { this.month = $locale.DATETIME_FORMATS.SHORTMONTH.indexOf(value); }
  1063. },
  1064. 'MM': {
  1065. regex: '0[1-9]|1[0-2]',
  1066. apply: function(value) { this.month = value - 1; }
  1067. },
  1068. 'M': {
  1069. regex: '[1-9]|1[0-2]',
  1070. apply: function(value) { this.month = value - 1; }
  1071. },
  1072. 'dd': {
  1073. regex: '[0-2][0-9]{1}|3[0-1]{1}',
  1074. apply: function(value) { this.date = +value; }
  1075. },
  1076. 'd': {
  1077. regex: '[1-2]?[0-9]{1}|3[0-1]{1}',
  1078. apply: function(value) { this.date = +value; }
  1079. },
  1080. 'EEEE': {
  1081. regex: $locale.DATETIME_FORMATS.DAY.join('|')
  1082. },
  1083. 'EEE': {
  1084. regex: $locale.DATETIME_FORMATS.SHORTDAY.join('|')
  1085. },
  1086. 'HH': {
  1087. regex: '(?:0|1)[0-9]|2[0-3]',
  1088. apply: function(value) { this.hours = +value; }
  1089. },
  1090. 'hh': {
  1091. regex: '0[0-9]|1[0-2]',
  1092. apply: function(value) { this.hours = +value; }
  1093. },
  1094. 'H': {
  1095. regex: '1?[0-9]|2[0-3]',
  1096. apply: function(value) { this.hours = +value; }
  1097. },
  1098. 'h': {
  1099. regex: '[0-9]|1[0-2]',
  1100. apply: function(value) { this.hours = +value; }
  1101. },
  1102. 'mm': {
  1103. regex: '[0-5][0-9]',
  1104. apply: function(value) { this.minutes = +value; }
  1105. },
  1106. 'm': {
  1107. regex: '[0-9]|[1-5][0-9]',
  1108. apply: function(value) { this.minutes = +value; }
  1109. },
  1110. 'sss': {
  1111. regex: '[0-9][0-9][0-9]',
  1112. apply: function(value) { this.milliseconds = +value; }
  1113. },
  1114. 'ss': {
  1115. regex: '[0-5][0-9]',
  1116. apply: function(value) { this.seconds = +value; }
  1117. },
  1118. 's': {
  1119. regex: '[0-9]|[1-5][0-9]',
  1120. apply: function(value) { this.seconds = +value; }
  1121. },
  1122. 'a': {
  1123. regex: $locale.DATETIME_FORMATS.AMPMS.join('|'),
  1124. apply: function(value) {
  1125. if (this.hours === 12) {
  1126. this.hours = 0;
  1127. }
  1128. if (value === 'PM') {
  1129. this.hours += 12;
  1130. }
  1131. }
  1132. }
  1133. };
  1134. };
  1135. this.init();
  1136. function createParser(format) {
  1137. var map = [], regex = format.split('');
  1138. angular.forEach(formatCodeToRegex, function(data, code) {
  1139. var index = format.indexOf(code);
  1140. if (index > -1) {
  1141. format = format.split('');
  1142. regex[index] = '(' + data.regex + ')';
  1143. format[index] = '$'; // Custom symbol to define consumed part of format
  1144. for (var i = index + 1, n = index + code.length; i < n; i++) {
  1145. regex[i] = '';
  1146. format[i] = '$';
  1147. }
  1148. format = format.join('');
  1149. map.push({ index: index, apply: data.apply });
  1150. }
  1151. });
  1152. return {
  1153. regex: new RegExp('^' + regex.join('') + '$'),
  1154. map: orderByFilter(map, 'index')
  1155. };
  1156. }
  1157. this.parse = function(input, format, baseDate) {
  1158. if (!angular.isString(input) || !format) {
  1159. return input;
  1160. }
  1161. format = $locale.DATETIME_FORMATS[format] || format;
  1162. format = format.replace(SPECIAL_CHARACTERS_REGEXP, '\\$&');
  1163. if ($locale.id !== localeId) {
  1164. this.init();
  1165. }
  1166. if (!this.parsers[format]) {
  1167. this.parsers[format] = createParser(format);
  1168. }
  1169. var parser = this.parsers[format],
  1170. regex = parser.regex,
  1171. map = parser.map,
  1172. results = input.match(regex);
  1173. if (results && results.length) {
  1174. var fields, dt;
  1175. if (angular.isDate(baseDate) && !isNaN(baseDate.getTime())) {
  1176. fields = {
  1177. year: baseDate.getFullYear(),
  1178. month: baseDate.getMonth(),
  1179. date: baseDate.getDate(),
  1180. hours: baseDate.getHours(),
  1181. minutes: baseDate.getMinutes(),
  1182. seconds: baseDate.getSeconds(),
  1183. milliseconds: baseDate.getMilliseconds()
  1184. };
  1185. } else {
  1186. if (baseDate) {
  1187. $log.warn('dateparser:', 'baseDate is not a valid date');
  1188. }
  1189. fields = { year: 1900, month: 0, date: 1, hours: 0, minutes: 0, seconds: 0, milliseconds: 0 };
  1190. }
  1191. for (var i = 1, n = results.length; i < n; i++) {
  1192. var mapper = map[i-1];
  1193. if (mapper.apply) {
  1194. mapper.apply.call(fields, results[i]);
  1195. }
  1196. }
  1197. if (isValid(fields.year, fields.month, fields.date)) {
  1198. if (angular.isDate(baseDate) && !isNaN(baseDate.getTime())) {
  1199. dt = new Date(baseDate);
  1200. dt.setFullYear(fields.year, fields.month, fields.date,
  1201. fields.hours, fields.minutes, fields.seconds,
  1202. fields.milliseconds || 0);
  1203. } else {
  1204. dt = new Date(fields.year, fields.month, fields.date,
  1205. fields.hours, fields.minutes, fields.seconds,
  1206. fields.milliseconds || 0);
  1207. }
  1208. }
  1209. return dt;
  1210. }
  1211. };
  1212. // Check if date is valid for specific month (and year for February).
  1213. // Month: 0 = Jan, 1 = Feb, etc
  1214. function isValid(year, month, date) {
  1215. if (date < 1) {
  1216. return false;
  1217. }
  1218. if (month === 1 && date > 28) {
  1219. return date === 29 && ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0);
  1220. }
  1221. if (month === 3 || month === 5 || month === 8 || month === 10) {
  1222. return date < 31;
  1223. }
  1224. return true;
  1225. }
  1226. }]);
  1227. /* Deprecated dateparser below */
  1228. angular.module('ui.bootstrap.dateparser')
  1229. .value('$dateParserSuppressWarning', false)
  1230. .service('dateParser', ['$log', '$dateParserSuppressWarning', 'uibDateParser', function($log, $dateParserSuppressWarning, uibDateParser) {
  1231. if (!$dateParserSuppressWarning) {
  1232. $log.warn('dateParser is now deprecated. Use uibDateParser instead.');
  1233. }
  1234. angular.extend(this, uibDateParser);
  1235. }]);
  1236. angular.module('ui.bootstrap.position', [])
  1237. /**
  1238. * A set of utility methods that can be use to retrieve position of DOM elements.
  1239. * It is meant to be used where we need to absolute-position DOM elements in
  1240. * relation to other, existing elements (this is the case for tooltips, popovers,
  1241. * typeahead suggestions etc.).
  1242. */
  1243. .factory('$uibPosition', ['$document', '$window', function($document, $window) {
  1244. function getStyle(el, cssprop) {
  1245. if (el.currentStyle) { //IE
  1246. return el.currentStyle[cssprop];
  1247. } else if ($window.getComputedStyle) {
  1248. return $window.getComputedStyle(el)[cssprop];
  1249. }
  1250. // finally try and get inline style
  1251. return el.style[cssprop];
  1252. }
  1253. /**
  1254. * Checks if a given element is statically positioned
  1255. * @param element - raw DOM element
  1256. */
  1257. function isStaticPositioned(element) {
  1258. return (getStyle(element, 'position') || 'static' ) === 'static';
  1259. }
  1260. /**
  1261. * returns the closest, non-statically positioned parentOffset of a given element
  1262. * @param element
  1263. */
  1264. var parentOffsetEl = function(element) {
  1265. var docDomEl = $document[0];
  1266. var offsetParent = element.offsetParent || docDomEl;
  1267. while (offsetParent && offsetParent !== docDomEl && isStaticPositioned(offsetParent) ) {
  1268. offsetParent = offsetParent.offsetParent;
  1269. }
  1270. return offsetParent || docDomEl;
  1271. };
  1272. return {
  1273. /**
  1274. * Provides read-only equivalent of jQuery's position function:
  1275. * http://api.jquery.com/position/
  1276. */
  1277. position: function(element) {
  1278. var elBCR = this.offset(element);
  1279. var offsetParentBCR = { top: 0, left: 0 };
  1280. var offsetParentEl = parentOffsetEl(element[0]);
  1281. if (offsetParentEl != $document[0]) {
  1282. offsetParentBCR = this.offset(angular.element(offsetParentEl));
  1283. offsetParentBCR.top += offsetParentEl.clientTop - offsetParentEl.scrollTop;
  1284. offsetParentBCR.left += offsetParentEl.clientLeft - offsetParentEl.scrollLeft;
  1285. }
  1286. var boundingClientRect = element[0].getBoundingClientRect();
  1287. return {
  1288. width: boundingClientRect.width || element.prop('offsetWidth'),
  1289. height: boundingClientRect.height || element.prop('offsetHeight'),
  1290. top: elBCR.top - offsetParentBCR.top,
  1291. left: elBCR.left - offsetParentBCR.left
  1292. };
  1293. },
  1294. /**
  1295. * Provides read-only equivalent of jQuery's offset function:
  1296. * http://api.jquery.com/offset/
  1297. */
  1298. offset: function(element) {
  1299. var boundingClientRect = element[0].getBoundingClientRect();
  1300. return {
  1301. width: boundingClientRect.width || element.prop('offsetWidth'),
  1302. height: boundingClientRect.height || element.prop('offsetHeight'),
  1303. top: boundingClientRect.top + ($window.pageYOffset || $document[0].documentElement.scrollTop),
  1304. left: boundingClientRect.left + ($window.pageXOffset || $document[0].documentElement.scrollLeft)
  1305. };
  1306. },
  1307. /**
  1308. * Provides coordinates for the targetEl in relation to hostEl
  1309. */
  1310. positionElements: function(hostEl, targetEl, positionStr, appendToBody) {
  1311. var positionStrParts = positionStr.split('-');
  1312. var pos0 = positionStrParts[0], pos1 = positionStrParts[1] || 'center';
  1313. var hostElPos,
  1314. targetElWidth,
  1315. targetElHeight,
  1316. targetElPos;
  1317. hostElPos = appendToBody ? this.offset(hostEl) : this.position(hostEl);
  1318. targetElWidth = targetEl.prop('offsetWidth');
  1319. targetElHeight = targetEl.prop('offsetHeight');
  1320. var shiftWidth = {
  1321. center: function() {
  1322. return hostElPos.left + hostElPos.width / 2 - targetElWidth / 2;
  1323. },
  1324. left: function() {
  1325. return hostElPos.left;
  1326. },
  1327. right: function() {
  1328. return hostElPos.left + hostElPos.width;
  1329. }
  1330. };
  1331. var shiftHeight = {
  1332. center: function() {
  1333. return hostElPos.top + hostElPos.height / 2 - targetElHeight / 2;
  1334. },
  1335. top: function() {
  1336. return hostElPos.top;
  1337. },
  1338. bottom: function() {
  1339. return hostElPos.top + hostElPos.height;
  1340. }
  1341. };
  1342. switch (pos0) {
  1343. case 'right':
  1344. targetElPos = {
  1345. top: shiftHeight[pos1](),
  1346. left: shiftWidth[pos0]()
  1347. };
  1348. break;
  1349. case 'left':
  1350. targetElPos = {
  1351. top: shiftHeight[pos1](),
  1352. left: hostElPos.left - targetElWidth
  1353. };
  1354. break;
  1355. case 'bottom':
  1356. targetElPos = {
  1357. top: shiftHeight[pos0](),
  1358. left: shiftWidth[pos1]()
  1359. };
  1360. break;
  1361. default:
  1362. targetElPos = {
  1363. top: hostElPos.top - targetElHeight,
  1364. left: shiftWidth[pos1]()
  1365. };
  1366. break;
  1367. }
  1368. return targetElPos;
  1369. }
  1370. };
  1371. }]);
  1372. /* Deprecated position below */
  1373. angular.module('ui.bootstrap.position')
  1374. .value('$positionSuppressWarning', false)
  1375. .service('$position', ['$log', '$positionSuppressWarning', '$uibPosition', function($log, $positionSuppressWarning, $uibPosition) {
  1376. if (!$positionSuppressWarning) {
  1377. $log.warn('$position is now deprecated. Use $uibPosition instead.');
  1378. }
  1379. angular.extend(this, $uibPosition);
  1380. }]);
  1381. angular.module('ui.bootstrap.datepicker', ['ui.bootstrap.dateparser', 'ui.bootstrap.position'])
  1382. .value('$datepickerSuppressError', false)
  1383. .constant('uibDatepickerConfig', {
  1384. formatDay: 'dd',
  1385. formatMonth: 'MMMM',
  1386. formatYear: 'yyyy',
  1387. formatDayHeader: 'EEE',
  1388. formatDayTitle: 'MMMM yyyy',
  1389. formatMonthTitle: 'yyyy',
  1390. datepickerMode: 'day',
  1391. minMode: 'day',
  1392. maxMode: 'year',
  1393. showWeeks: true,
  1394. startingDay: 0,
  1395. yearRange: 20,
  1396. minDate: null,
  1397. maxDate: null,
  1398. shortcutPropagation: false
  1399. })
  1400. .controller('UibDatepickerController', ['$scope', '$attrs', '$parse', '$interpolate', '$log', 'dateFilter', 'uibDatepickerConfig', '$datepickerSuppressError', function($scope, $attrs, $parse, $interpolate, $log, dateFilter, datepickerConfig, $datepickerSuppressError) {
  1401. var self = this,
  1402. ngModelCtrl = { $setViewValue: angular.noop }; // nullModelCtrl;
  1403. // Modes chain
  1404. this.modes = ['day', 'month', 'year'];
  1405. // Configuration attributes
  1406. angular.forEach(['formatDay', 'formatMonth', 'formatYear', 'formatDayHeader', 'formatDayTitle', 'formatMonthTitle',
  1407. 'showWeeks', 'startingDay', 'yearRange', 'shortcutPropagation'], function(key, index) {
  1408. self[key] = angular.isDefined($attrs[key]) ? (index < 6 ? $interpolate($attrs[key])($scope.$parent) : $scope.$parent.$eval($attrs[key])) : datepickerConfig[key];
  1409. });
  1410. // Watchable date attributes
  1411. angular.forEach(['minDate', 'maxDate'], function(key) {
  1412. if ($attrs[key]) {
  1413. $scope.$parent.$watch($parse($attrs[key]), function(value) {
  1414. self[key] = value ? new Date(value) : null;
  1415. self.refreshView();
  1416. });
  1417. } else {
  1418. self[key] = datepickerConfig[key] ? new Date(datepickerConfig[key]) : null;
  1419. }
  1420. });
  1421. angular.forEach(['minMode', 'maxMode'], function(key) {
  1422. if ($attrs[key]) {
  1423. $scope.$parent.$watch($parse($attrs[key]), function(value) {
  1424. self[key] = angular.isDefined(value) ? value : $attrs[key];
  1425. $scope[key] = self[key];
  1426. if ((key == 'minMode' && self.modes.indexOf($scope.datepickerMode) < self.modes.indexOf(self[key])) || (key == 'maxMode' && self.modes.indexOf($scope.datepickerMode) > self.modes.indexOf(self[key]))) {
  1427. $scope.datepickerMode = self[key];
  1428. }
  1429. });
  1430. } else {
  1431. self[key] = datepickerConfig[key] || null;
  1432. $scope[key] = self[key];
  1433. }
  1434. });
  1435. $scope.datepickerMode = $scope.datepickerMode || datepickerConfig.datepickerMode;
  1436. $scope.uniqueId = 'datepicker-' + $scope.$id + '-' + Math.floor(Math.random() * 10000);
  1437. if (angular.isDefined($attrs.initDate)) {
  1438. this.activeDate = $scope.$parent.$eval($attrs.initDate) || new Date();
  1439. $scope.$parent.$watch($attrs.initDate, function(initDate) {
  1440. if (initDate && (ngModelCtrl.$isEmpty(ngModelCtrl.$modelValue) || ngModelCtrl.$invalid)) {
  1441. self.activeDate = initDate;
  1442. self.refreshView();
  1443. }
  1444. });
  1445. } else {
  1446. this.activeDate = new Date();
  1447. }
  1448. $scope.isActive = function(dateObject) {
  1449. if (self.compare(dateObject.date, self.activeDate) === 0) {
  1450. $scope.activeDateId = dateObject.uid;
  1451. return true;
  1452. }
  1453. return false;
  1454. };
  1455. this.init = function(ngModelCtrl_) {
  1456. ngModelCtrl = ngModelCtrl_;
  1457. ngModelCtrl.$render = function() {
  1458. self.render();
  1459. };
  1460. };
  1461. this.render = function() {
  1462. if (ngModelCtrl.$viewValue) {
  1463. var date = new Date(ngModelCtrl.$viewValue),
  1464. isValid = !isNaN(date);
  1465. if (isValid) {
  1466. this.activeDate = date;
  1467. } else if (!$datepickerSuppressError) {
  1468. $log.error('Datepicker directive: "ng-model" value must be a Date object, a number of milliseconds since 01.01.1970 or a string representing an RFC2822 or ISO 8601 date.');
  1469. }
  1470. }
  1471. this.refreshView();
  1472. };
  1473. this.refreshView = function() {
  1474. if (this.element) {
  1475. this._refreshView();
  1476. var date = ngModelCtrl.$viewValue ? new Date(ngModelCtrl.$viewValue) : null;
  1477. ngModelCtrl.$setValidity('dateDisabled', !date || (this.element && !this.isDisabled(date)));
  1478. }
  1479. };
  1480. this.createDateObject = function(date, format) {
  1481. var model = ngModelCtrl.$viewValue ? new Date(ngModelCtrl.$viewValue) : null;
  1482. return {
  1483. date: date,
  1484. label: dateFilter(date, format),
  1485. selected: model && this.compare(date, model) === 0,
  1486. disabled: this.isDisabled(date),
  1487. current: this.compare(date, new Date()) === 0,
  1488. customClass: this.customClass(date)
  1489. };
  1490. };
  1491. this.isDisabled = function(date) {
  1492. return ((this.minDate && this.compare(date, this.minDate) < 0) || (this.maxDate && this.compare(date, this.maxDate) > 0) || ($attrs.dateDisabled && $scope.dateDisabled({date: date, mode: $scope.datepickerMode})));
  1493. };
  1494. this.customClass = function(date) {
  1495. return $scope.customClass({date: date, mode: $scope.datepickerMode});
  1496. };
  1497. // Split array into smaller arrays
  1498. this.split = function(arr, size) {
  1499. var arrays = [];
  1500. while (arr.length > 0) {
  1501. arrays.push(arr.splice(0, size));
  1502. }
  1503. return arrays;
  1504. };
  1505. $scope.select = function(date) {
  1506. if ($scope.datepickerMode === self.minMode) {
  1507. var dt = ngModelCtrl.$viewValue ? new Date(ngModelCtrl.$viewValue) : new Date(0, 0, 0, 0, 0, 0, 0);
  1508. dt.setFullYear(date.getFullYear(), date.getMonth(), date.getDate());
  1509. ngModelCtrl.$setViewValue(dt);
  1510. ngModelCtrl.$render();
  1511. } else {
  1512. self.activeDate = date;
  1513. $scope.datepickerMode = self.modes[self.modes.indexOf($scope.datepickerMode) - 1];
  1514. }
  1515. };
  1516. $scope.move = function(direction) {
  1517. var year = self.activeDate.getFullYear() + direction * (self.step.years || 0),
  1518. month = self.activeDate.getMonth() + direction * (self.step.months || 0);
  1519. self.activeDate.setFullYear(year, month, 1);
  1520. self.refreshView();
  1521. };
  1522. $scope.toggleMode = function(direction) {
  1523. direction = direction || 1;
  1524. if (($scope.datepickerMode === self.maxMode && direction === 1) || ($scope.datepickerMode === self.minMode && direction === -1)) {
  1525. return;
  1526. }
  1527. $scope.datepickerMode = self.modes[self.modes.indexOf($scope.datepickerMode) + direction];
  1528. };
  1529. // Key event mapper
  1530. $scope.keys = { 13: 'enter', 32: 'space', 33: 'pageup', 34: 'pagedown', 35: 'end', 36: 'home', 37: 'left', 38: 'up', 39: 'right', 40: 'down' };
  1531. var focusElement = function() {
  1532. self.element[0].focus();
  1533. };
  1534. // Listen for focus requests from popup directive
  1535. $scope.$on('uib:datepicker.focus', focusElement);
  1536. $scope.keydown = function(evt) {
  1537. var key = $scope.keys[evt.which];
  1538. if (!key || evt.shiftKey || evt.altKey) {
  1539. return;
  1540. }
  1541. evt.preventDefault();
  1542. if (!self.shortcutPropagation) {
  1543. evt.stopPropagation();
  1544. }
  1545. if (key === 'enter' || key === 'space') {
  1546. if (self.isDisabled(self.activeDate)) {
  1547. return; // do nothing
  1548. }
  1549. $scope.select(self.activeDate);
  1550. } else if (evt.ctrlKey && (key === 'up' || key === 'down')) {
  1551. $scope.toggleMode(key === 'up' ? 1 : -1);
  1552. } else {
  1553. self.handleKeyDown(key, evt);
  1554. self.refreshView();
  1555. }
  1556. };
  1557. }])
  1558. .controller('UibDaypickerController', ['$scope', '$element', 'dateFilter', function(scope, $element, dateFilter) {
  1559. var DAYS_IN_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
  1560. this.step = { months: 1 };
  1561. this.element = $element;
  1562. function getDaysInMonth(year, month) {
  1563. return ((month === 1) && (year % 4 === 0) && ((year % 100 !== 0) || (year % 400 === 0))) ? 29 : DAYS_IN_MONTH[month];
  1564. }
  1565. this.init = function(ctrl) {
  1566. angular.extend(ctrl, this);
  1567. scope.showWeeks = ctrl.showWeeks;
  1568. ctrl.refreshView();
  1569. };
  1570. this.getDates = function(startDate, n) {
  1571. var dates = new Array(n), current = new Date(startDate), i = 0, date;
  1572. while (i < n) {
  1573. date = new Date(current);
  1574. dates[i++] = date;
  1575. current.setDate(current.getDate() + 1);
  1576. }
  1577. return dates;
  1578. };
  1579. this._refreshView = function() {
  1580. var year = this.activeDate.getFullYear(),
  1581. month = this.activeDate.getMonth(),
  1582. firstDayOfMonth = new Date(this.activeDate);
  1583. firstDayOfMonth.setFullYear(year, month, 1);
  1584. var difference = this.startingDay - firstDayOfMonth.getDay(),
  1585. numDisplayedFromPreviousMonth = (difference > 0) ? 7 - difference : - difference,
  1586. firstDate = new Date(firstDayOfMonth);
  1587. if (numDisplayedFromPreviousMonth > 0) {
  1588. firstDate.setDate(-numDisplayedFromPreviousMonth + 1);
  1589. }
  1590. // 42 is the number of days on a six-month calendar
  1591. var days = this.getDates(firstDate, 42);
  1592. for (var i = 0; i < 42; i ++) {
  1593. days[i] = angular.extend(this.createDateObject(days[i], this.formatDay), {
  1594. secondary: days[i].getMonth() !== month,
  1595. uid: scope.uniqueId + '-' + i
  1596. });
  1597. }
  1598. scope.labels = new Array(7);
  1599. for (var j = 0; j < 7; j++) {
  1600. scope.labels[j] = {
  1601. abbr: dateFilter(days[j].date, this.formatDayHeader),
  1602. full: dateFilter(days[j].date, 'EEEE')
  1603. };
  1604. }
  1605. scope.title = dateFilter(this.activeDate, this.formatDayTitle);
  1606. scope.rows = this.split(days, 7);
  1607. if (scope.showWeeks) {
  1608. scope.weekNumbers = [];
  1609. var thursdayIndex = (4 + 7 - this.startingDay) % 7,
  1610. numWeeks = scope.rows.length;
  1611. for (var curWeek = 0; curWeek < numWeeks; curWeek++) {
  1612. scope.weekNumbers.push(
  1613. getISO8601WeekNumber(scope.rows[curWeek][thursdayIndex].date));
  1614. }
  1615. }
  1616. };
  1617. this.compare = function(date1, date2) {
  1618. return (new Date(date1.getFullYear(), date1.getMonth(), date1.getDate()) - new Date(date2.getFullYear(), date2.getMonth(), date2.getDate()));
  1619. };
  1620. function getISO8601WeekNumber(date) {
  1621. var checkDate = new Date(date);
  1622. checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7)); // Thursday
  1623. var time = checkDate.getTime();
  1624. checkDate.setMonth(0); // Compare with Jan 1
  1625. checkDate.setDate(1);
  1626. return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
  1627. }
  1628. this.handleKeyDown = function(key, evt) {
  1629. var date = this.activeDate.getDate();
  1630. if (key === 'left') {
  1631. date = date - 1; // up
  1632. } else if (key === 'up') {
  1633. date = date - 7; // down
  1634. } else if (key === 'right') {
  1635. date = date + 1; // down
  1636. } else if (key === 'down') {
  1637. date = date + 7;
  1638. } else if (key === 'pageup' || key === 'pagedown') {
  1639. var month = this.activeDate.getMonth() + (key === 'pageup' ? - 1 : 1);
  1640. this.activeDate.setMonth(month, 1);
  1641. date = Math.min(getDaysInMonth(this.activeDate.getFullYear(), this.activeDate.getMonth()), date);
  1642. } else if (key === 'home') {
  1643. date = 1;
  1644. } else if (key === 'end') {
  1645. date = getDaysInMonth(this.activeDate.getFullYear(), this.activeDate.getMonth());
  1646. }
  1647. this.activeDate.setDate(date);
  1648. };
  1649. }])
  1650. .controller('UibMonthpickerController', ['$scope', '$element', 'dateFilter', function(scope, $element, dateFilter) {
  1651. this.step = { years: 1 };
  1652. this.element = $element;
  1653. this.init = function(ctrl) {
  1654. angular.extend(ctrl, this);
  1655. ctrl.refreshView();
  1656. };
  1657. this._refreshView = function() {
  1658. var months = new Array(12),
  1659. year = this.activeDate.getFullYear(),
  1660. date;
  1661. for (var i = 0; i < 12; i++) {
  1662. date = new Date(this.activeDate);
  1663. date.setFullYear(year, i, 1);
  1664. months[i] = angular.extend(this.createDateObject(date, this.formatMonth), {
  1665. uid: scope.uniqueId + '-' + i
  1666. });
  1667. }
  1668. scope.title = dateFilter(this.activeDate, this.formatMonthTitle);
  1669. scope.rows = this.split(months, 3);
  1670. };
  1671. this.compare = function(date1, date2) {
  1672. return new Date(date1.getFullYear(), date1.getMonth()) - new Date(date2.getFullYear(), date2.getMonth());
  1673. };
  1674. this.handleKeyDown = function(key, evt) {
  1675. var date = this.activeDate.getMonth();
  1676. if (key === 'left') {
  1677. date = date - 1; // up
  1678. } else if (key === 'up') {
  1679. date = date - 3; // down
  1680. } else if (key === 'right') {
  1681. date = date + 1; // down
  1682. } else if (key === 'down') {
  1683. date = date + 3;
  1684. } else if (key === 'pageup' || key === 'pagedown') {
  1685. var year = this.activeDate.getFullYear() + (key === 'pageup' ? - 1 : 1);
  1686. this.activeDate.setFullYear(year);
  1687. } else if (key === 'home') {
  1688. date = 0;
  1689. } else if (key === 'end') {
  1690. date = 11;
  1691. }
  1692. this.activeDate.setMonth(date);
  1693. };
  1694. }])
  1695. .controller('UibYearpickerController', ['$scope', '$element', 'dateFilter', function(scope, $element, dateFilter) {
  1696. var range;
  1697. this.element = $element;
  1698. function getStartingYear(year) {
  1699. return parseInt((year - 1) / range, 10) * range + 1;
  1700. }
  1701. this.yearpickerInit = function() {
  1702. range = this.yearRange;
  1703. this.step = { years: range };
  1704. };
  1705. this._refreshView = function() {
  1706. var years = new Array(range), date;
  1707. for (var i = 0, start = getStartingYear(this.activeDate.getFullYear()); i < range; i++) {
  1708. date = new Date(this.activeDate);
  1709. date.setFullYear(start + i, 0, 1);
  1710. years[i] = angular.extend(this.createDateObject(date, this.formatYear), {
  1711. uid: scope.uniqueId + '-' + i
  1712. });
  1713. }
  1714. scope.title = [years[0].label, years[range - 1].label].join(' - ');
  1715. scope.rows = this.split(years, 5);
  1716. };
  1717. this.compare = function(date1, date2) {
  1718. return date1.getFullYear() - date2.getFullYear();
  1719. };
  1720. this.handleKeyDown = function(key, evt) {
  1721. var date = this.activeDate.getFullYear();
  1722. if (key === 'left') {
  1723. date = date - 1; // up
  1724. } else if (key === 'up') {
  1725. date = date - 5; // down
  1726. } else if (key === 'right') {
  1727. date = date + 1; // down
  1728. } else if (key === 'down') {
  1729. date = date + 5;
  1730. } else if (key === 'pageup' || key === 'pagedown') {
  1731. date += (key === 'pageup' ? - 1 : 1) * this.step.years;
  1732. } else if (key === 'home') {
  1733. date = getStartingYear(this.activeDate.getFullYear());
  1734. } else if (key === 'end') {
  1735. date = getStartingYear(this.activeDate.getFullYear()) + range - 1;
  1736. }
  1737. this.activeDate.setFullYear(date);
  1738. };
  1739. }])
  1740. .directive('uibDatepicker', function() {
  1741. return {
  1742. replace: true,
  1743. templateUrl: function(element, attrs) {
  1744. return attrs.templateUrl || 'template/datepicker/datepicker.html';
  1745. },
  1746. scope: {
  1747. datepickerMode: '=?',
  1748. dateDisabled: '&',
  1749. customClass: '&',
  1750. shortcutPropagation: '&?'
  1751. },
  1752. require: ['uibDatepicker', '^ngModel'],
  1753. controller: 'UibDatepickerController',
  1754. controllerAs: 'datepicker',
  1755. link: function(scope, element, attrs, ctrls) {
  1756. var datepickerCtrl = ctrls[0], ngModelCtrl = ctrls[1];
  1757. datepickerCtrl.init(ngModelCtrl);
  1758. }
  1759. };
  1760. })
  1761. .directive('uibDaypicker', function() {
  1762. return {
  1763. replace: true,
  1764. templateUrl: function(element, attrs) {
  1765. return attrs.templateUrl || 'template/datepicker/day.html';
  1766. },
  1767. require: ['^?uibDatepicker', 'uibDaypicker', '^?datepicker'],
  1768. controller: 'UibDaypickerController',
  1769. link: function(scope, element, attrs, ctrls) {
  1770. var datepickerCtrl = ctrls[0] || ctrls[2],
  1771. daypickerCtrl = ctrls[1];
  1772. daypickerCtrl.init(datepickerCtrl);
  1773. }
  1774. };
  1775. })
  1776. .directive('uibMonthpicker', function() {
  1777. return {
  1778. replace: true,
  1779. templateUrl: function(element, attrs) {
  1780. return attrs.templateUrl || 'template/datepicker/month.html';
  1781. },
  1782. require: ['^?uibDatepicker', 'uibMonthpicker', '^?datepicker'],
  1783. controller: 'UibMonthpickerController',
  1784. link: function(scope, element, attrs, ctrls) {
  1785. var datepickerCtrl = ctrls[0] || ctrls[2],
  1786. monthpickerCtrl = ctrls[1];
  1787. monthpickerCtrl.init(datepickerCtrl);
  1788. }
  1789. };
  1790. })
  1791. .directive('uibYearpicker', function() {
  1792. return {
  1793. replace: true,
  1794. templateUrl: function(element, attrs) {
  1795. return attrs.templateUrl || 'template/datepicker/year.html';
  1796. },
  1797. require: ['^?uibDatepicker', 'uibYearpicker', '^?datepicker'],
  1798. controller: 'UibYearpickerController',
  1799. link: function(scope, element, attrs, ctrls) {
  1800. var ctrl = ctrls[0] || ctrls[2];
  1801. angular.extend(ctrl, ctrls[1]);
  1802. ctrl.yearpickerInit();
  1803. ctrl.refreshView();
  1804. }
  1805. };
  1806. })
  1807. .constant('uibDatepickerPopupConfig', {
  1808. datepickerPopup: 'yyyy-MM-dd',
  1809. datepickerPopupTemplateUrl: 'template/datepicker/popup.html',
  1810. datepickerTemplateUrl: 'template/datepicker/datepicker.html',
  1811. html5Types: {
  1812. date: 'yyyy-MM-dd',
  1813. 'datetime-local': 'yyyy-MM-ddTHH:mm:ss.sss',
  1814. 'month': 'yyyy-MM'
  1815. },
  1816. currentText: 'Today',
  1817. clearText: 'Clear',
  1818. closeText: 'Done',
  1819. closeOnDateSelection: true,
  1820. appendToBody: false,
  1821. showButtonBar: true,
  1822. onOpenFocus: true
  1823. })
  1824. .controller('UibDatepickerPopupController', ['$scope', '$element', '$attrs', '$compile', '$parse', '$document', '$rootScope', '$uibPosition', 'dateFilter', 'uibDateParser', 'uibDatepickerPopupConfig', '$timeout',
  1825. function(scope, element, attrs, $compile, $parse, $document, $rootScope, $position, dateFilter, dateParser, datepickerPopupConfig, $timeout) {
  1826. var self = this;
  1827. var cache = {},
  1828. isHtml5DateInput = false;
  1829. var dateFormat, closeOnDateSelection, appendToBody, onOpenFocus,
  1830. datepickerPopupTemplateUrl, datepickerTemplateUrl, popupEl, datepickerEl,
  1831. ngModel, $popup;
  1832. scope.watchData = {};
  1833. this.init = function(_ngModel_) {
  1834. ngModel = _ngModel_;
  1835. closeOnDateSelection = angular.isDefined(attrs.closeOnDateSelection) ? scope.$parent.$eval(attrs.closeOnDateSelection) : datepickerPopupConfig.closeOnDateSelection;
  1836. appendToBody = angular.isDefined(attrs.datepickerAppendToBody) ? scope.$parent.$eval(attrs.datepickerAppendToBody) : datepickerPopupConfig.appendToBody;
  1837. onOpenFocus = angular.isDefined(attrs.onOpenFocus) ? scope.$parent.$eval(attrs.onOpenFocus) : datepickerPopupConfig.onOpenFocus;
  1838. datepickerPopupTemplateUrl = angular.isDefined(attrs.datepickerPopupTemplateUrl) ? attrs.datepickerPopupTemplateUrl : datepickerPopupConfig.datepickerPopupTemplateUrl;
  1839. datepickerTemplateUrl = angular.isDefined(attrs.datepickerTemplateUrl) ? attrs.datepickerTemplateUrl : datepickerPopupConfig.datepickerTemplateUrl;
  1840. scope.showButtonBar = angular.isDefined(attrs.showButtonBar) ? scope.$parent.$eval(attrs.showButtonBar) : datepickerPopupConfig.showButtonBar;
  1841. if (datepickerPopupConfig.html5Types[attrs.type]) {
  1842. dateFormat = datepickerPopupConfig.html5Types[attrs.type];
  1843. isHtml5DateInput = true;
  1844. } else {
  1845. dateFormat = attrs.datepickerPopup || attrs.uibDatepickerPopup || datepickerPopupConfig.datepickerPopup;
  1846. attrs.$observe('uibDatepickerPopup', function(value, oldValue) {
  1847. var newDateFormat = value || datepickerPopupConfig.datepickerPopup;
  1848. // Invalidate the $modelValue to ensure that formatters re-run
  1849. // FIXME: Refactor when PR is merged: https://github.com/angular/angular.js/pull/10764
  1850. if (newDateFormat !== dateFormat) {
  1851. dateFormat = newDateFormat;
  1852. ngModel.$modelValue = null;
  1853. if (!dateFormat) {
  1854. throw new Error('uibDatepickerPopup must have a date format specified.');
  1855. }
  1856. }
  1857. });
  1858. }
  1859. if (!dateFormat) {
  1860. throw new Error('uibDatepickerPopup must have a date format specified.');
  1861. }
  1862. if (isHtml5DateInput && attrs.datepickerPopup) {
  1863. throw new Error('HTML5 date input types do not support custom formats.');
  1864. }
  1865. // popup element used to display calendar
  1866. popupEl = angular.element('<div uib-datepicker-popup-wrap><div uib-datepicker></div></div>');
  1867. popupEl.attr({
  1868. 'ng-model': 'date',
  1869. 'ng-change': 'dateSelection(date)',
  1870. 'template-url': datepickerPopupTemplateUrl
  1871. });
  1872. // datepicker element
  1873. datepickerEl = angular.element(popupEl.children()[0]);
  1874. datepickerEl.attr('template-url', datepickerTemplateUrl);
  1875. if (isHtml5DateInput) {
  1876. if (attrs.type === 'month') {
  1877. datepickerEl.attr('datepicker-mode', '"month"');
  1878. datepickerEl.attr('min-mode', 'month');
  1879. }
  1880. }
  1881. if (attrs.datepickerOptions) {
  1882. var options = scope.$parent.$eval(attrs.datepickerOptions);
  1883. if (options && options.initDate) {
  1884. scope.initDate = options.initDate;
  1885. datepickerEl.attr('init-date', 'initDate');
  1886. delete options.initDate;
  1887. }
  1888. angular.forEach(options, function(value, option) {
  1889. datepickerEl.attr(cameltoDash(option), value);
  1890. });
  1891. }
  1892. angular.forEach(['minMode', 'maxMode', 'minDate', 'maxDate', 'datepickerMode', 'initDate', 'shortcutPropagation'], function(key) {
  1893. if (attrs[key]) {
  1894. var getAttribute = $parse(attrs[key]);
  1895. scope.$parent.$watch(getAttribute, function(value) {
  1896. scope.watchData[key] = value;
  1897. if (key === 'minDate' || key === 'maxDate') {
  1898. cache[key] = new Date(value);
  1899. }
  1900. });
  1901. datepickerEl.attr(cameltoDash(key), 'watchData.' + key);
  1902. // Propagate changes from datepicker to outside
  1903. if (key === 'datepickerMode') {
  1904. var setAttribute = getAttribute.assign;
  1905. scope.$watch('watchData.' + key, function(value, oldvalue) {
  1906. if (angular.isFunction(setAttribute) && value !== oldvalue) {
  1907. setAttribute(scope.$parent, value);
  1908. }
  1909. });
  1910. }
  1911. }
  1912. });
  1913. if (attrs.dateDisabled) {
  1914. datepickerEl.attr('date-disabled', 'dateDisabled({ date: date, mode: mode })');
  1915. }
  1916. if (attrs.showWeeks) {
  1917. datepickerEl.attr('show-weeks', attrs.showWeeks);
  1918. }
  1919. if (attrs.customClass) {
  1920. datepickerEl.attr('custom-class', 'customClass({ date: date, mode: mode })');
  1921. }
  1922. if (!isHtml5DateInput) {
  1923. // Internal API to maintain the correct ng-invalid-[key] class
  1924. ngModel.$$parserName = 'date';
  1925. ngModel.$validators.date = validator;
  1926. ngModel.$parsers.unshift(parseDate);
  1927. ngModel.$formatters.push(function(value) {
  1928. scope.date = value;
  1929. return ngModel.$isEmpty(value) ? value : dateFilter(value, dateFormat);
  1930. });
  1931. } else {
  1932. ngModel.$formatters.push(function(value) {
  1933. scope.date = value;
  1934. return value;
  1935. });
  1936. }
  1937. // Detect changes in the view from the text box
  1938. ngModel.$viewChangeListeners.push(function() {
  1939. scope.date = dateParser.parse(ngModel.$viewValue, dateFormat, scope.date);
  1940. });
  1941. element.bind('keydown', inputKeydownBind);
  1942. $popup = $compile(popupEl)(scope);
  1943. // Prevent jQuery cache memory leak (template is now redundant after linking)
  1944. popupEl.remove();
  1945. if (appendToBody) {
  1946. $document.find('body').append($popup);
  1947. } else {
  1948. element.after($popup);
  1949. }
  1950. scope.$on('$destroy', function() {
  1951. if (scope.isOpen === true) {
  1952. if (!$rootScope.$$phase) {
  1953. scope.$apply(function() {
  1954. scope.isOpen = false;
  1955. });
  1956. }
  1957. }
  1958. $popup.remove();
  1959. element.unbind('keydown', inputKeydownBind);
  1960. $document.unbind('click', documentClickBind);
  1961. });
  1962. };
  1963. scope.getText = function(key) {
  1964. return scope[key + 'Text'] || datepickerPopupConfig[key + 'Text'];
  1965. };
  1966. scope.isDisabled = function(date) {
  1967. if (date === 'today') {
  1968. date = new Date();
  1969. }
  1970. return ((scope.watchData.minDate && scope.compare(date, cache.minDate) < 0) ||
  1971. (scope.watchData.maxDate && scope.compare(date, cache.maxDate) > 0));
  1972. };
  1973. scope.compare = function(date1, date2) {
  1974. return (new Date(date1.getFullYear(), date1.getMonth(), date1.getDate()) - new Date(date2.getFullYear(), date2.getMonth(), date2.getDate()));
  1975. };
  1976. // Inner change
  1977. scope.dateSelection = function(dt) {
  1978. if (angular.isDefined(dt)) {
  1979. scope.date = dt;
  1980. }
  1981. var date = scope.date ? dateFilter(scope.date, dateFormat) : null; // Setting to NULL is necessary for form validators to function
  1982. element.val(date);
  1983. ngModel.$setViewValue(date);
  1984. if (closeOnDateSelection) {
  1985. scope.isOpen = false;
  1986. element[0].focus();
  1987. }
  1988. };
  1989. scope.keydown = function(evt) {
  1990. if (evt.which === 27) {
  1991. scope.isOpen = false;
  1992. element[0].focus();
  1993. }
  1994. };
  1995. scope.select = function(date) {
  1996. if (date === 'today') {
  1997. var today = new Date();
  1998. if (angular.isDate(scope.date)) {
  1999. date = new Date(scope.date);
  2000. date.setFullYear(today.getFullYear(), today.getMonth(), today.getDate());
  2001. } else {
  2002. date = new Date(today.setHours(0, 0, 0, 0));
  2003. }
  2004. }
  2005. scope.dateSelection(date);
  2006. };
  2007. scope.close = function() {
  2008. scope.isOpen = false;
  2009. element[0].focus();
  2010. };
  2011. scope.$watch('isOpen', function(value) {
  2012. if (value) {
  2013. scope.position = appendToBody ? $position.offset(element) : $position.position(element);
  2014. scope.position.top = scope.position.top + element.prop('offsetHeight');
  2015. $timeout(function() {
  2016. if (onOpenFocus) {
  2017. scope.$broadcast('uib:datepicker.focus');
  2018. }
  2019. $document.bind('click', documentClickBind);
  2020. }, 0, false);
  2021. } else {
  2022. $document.unbind('click', documentClickBind);
  2023. }
  2024. });
  2025. function cameltoDash(string) {
  2026. return string.replace(/([A-Z])/g, function($1) { return '-' + $1.toLowerCase(); });
  2027. }
  2028. function parseDate(viewValue) {
  2029. if (angular.isNumber(viewValue)) {
  2030. // presumably timestamp to date object
  2031. viewValue = new Date(viewValue);
  2032. }
  2033. if (!viewValue) {
  2034. return null;
  2035. } else if (angular.isDate(viewValue) && !isNaN(viewValue)) {
  2036. return viewValue;
  2037. } else if (angular.isString(viewValue)) {
  2038. var date = dateParser.parse(viewValue, dateFormat, scope.date);
  2039. if (isNaN(date)) {
  2040. return undefined;
  2041. } else {
  2042. return date;
  2043. }
  2044. } else {
  2045. return undefined;
  2046. }
  2047. }
  2048. function validator(modelValue, viewValue) {
  2049. var value = modelValue || viewValue;
  2050. if (!attrs.ngRequired && !value) {
  2051. return true;
  2052. }
  2053. if (angular.isNumber(value)) {
  2054. value = new Date(value);
  2055. }
  2056. if (!value) {
  2057. return true;
  2058. } else if (angular.isDate(value) && !isNaN(value)) {
  2059. return true;
  2060. } else if (angular.isString(value)) {
  2061. var date = dateParser.parse(value, dateFormat);
  2062. return !isNaN(date);
  2063. } else {
  2064. return false;
  2065. }
  2066. }
  2067. function documentClickBind(event) {
  2068. var popup = $popup[0];
  2069. var dpContainsTarget = element[0].contains(event.target);
  2070. // The popup node may not be an element node
  2071. // In some browsers (IE) only element nodes have the 'contains' function
  2072. var popupContainsTarget = popup.contains !== undefined && popup.contains(event.target);
  2073. if (scope.isOpen && !(dpContainsTarget || popupContainsTarget)) {
  2074. scope.$apply(function() {
  2075. scope.isOpen = false;
  2076. });
  2077. }
  2078. }
  2079. function inputKeydownBind(evt) {
  2080. if (evt.which === 27 && scope.isOpen) {
  2081. evt.preventDefault();
  2082. evt.stopPropagation();
  2083. scope.$apply(function() {
  2084. scope.isOpen = false;
  2085. });
  2086. element[0].focus();
  2087. } else if (evt.which === 40 && !scope.isOpen) {
  2088. evt.preventDefault();
  2089. evt.stopPropagation();
  2090. scope.$apply(function() {
  2091. scope.isOpen = true;
  2092. });
  2093. }
  2094. }
  2095. }])
  2096. .directive('uibDatepickerPopup', function() {
  2097. return {
  2098. require: ['ngModel', 'uibDatepickerPopup'],
  2099. controller: 'UibDatepickerPopupController',
  2100. scope: {
  2101. isOpen: '=?',
  2102. currentText: '@',
  2103. clearText: '@',
  2104. closeText: '@',
  2105. dateDisabled: '&',
  2106. customClass: '&'
  2107. },
  2108. link: function(scope, element, attrs, ctrls) {
  2109. var ngModel = ctrls[0],
  2110. ctrl = ctrls[1];
  2111. ctrl.init(ngModel);
  2112. }
  2113. };
  2114. })
  2115. .directive('uibDatepickerPopupWrap', function() {
  2116. return {
  2117. replace: true,
  2118. transclude: true,
  2119. templateUrl: function(element, attrs) {
  2120. return attrs.templateUrl || 'template/datepicker/popup.html';
  2121. }
  2122. };
  2123. });
  2124. /* Deprecated datepicker below */
  2125. angular.module('ui.bootstrap.datepicker')
  2126. .value('$datepickerSuppressWarning', false)
  2127. .controller('DatepickerController', ['$scope', '$attrs', '$parse', '$interpolate', '$log', 'dateFilter', 'uibDatepickerConfig', '$datepickerSuppressError', '$datepickerSuppressWarning', function($scope, $attrs, $parse, $interpolate, $log, dateFilter, datepickerConfig, $datepickerSuppressError, $datepickerSuppressWarning) {
  2128. if (!$datepickerSuppressWarning) {
  2129. $log.warn('DatepickerController is now deprecated. Use UibDatepickerController instead.');
  2130. }
  2131. var self = this,
  2132. ngModelCtrl = { $setViewValue: angular.noop }; // nullModelCtrl;
  2133. this.modes = ['day', 'month', 'year'];
  2134. angular.forEach(['formatDay', 'formatMonth', 'formatYear', 'formatDayHeader', 'formatDayTitle', 'formatMonthTitle',
  2135. 'showWeeks', 'startingDay', 'yearRange', 'shortcutPropagation'], function(key, index) {
  2136. self[key] = angular.isDefined($attrs[key]) ? (index < 6 ? $interpolate($attrs[key])($scope.$parent) : $scope.$parent.$eval($attrs[key])) : datepickerConfig[key];
  2137. });
  2138. angular.forEach(['minDate', 'maxDate'], function(key) {
  2139. if ($attrs[key]) {
  2140. $scope.$parent.$watch($parse($attrs[key]), function(value) {
  2141. self[key] = value ? new Date(value) : null;
  2142. self.refreshView();
  2143. });
  2144. } else {
  2145. self[key] = datepickerConfig[key] ? new Date(datepickerConfig[key]) : null;
  2146. }
  2147. });
  2148. angular.forEach(['minMode', 'maxMode'], function(key) {
  2149. if ($attrs[key]) {
  2150. $scope.$parent.$watch($parse($attrs[key]), function(value) {
  2151. self[key] = angular.isDefined(value) ? value : $attrs[key];
  2152. $scope[key] = self[key];
  2153. if ((key == 'minMode' && self.modes.indexOf($scope.datepickerMode) < self.modes.indexOf(self[key])) || (key == 'maxMode' && self.modes.indexOf($scope.datepickerMode) > self.modes.indexOf(self[key]))) {
  2154. $scope.datepickerMode = self[key];
  2155. }
  2156. });
  2157. } else {
  2158. self[key] = datepickerConfig[key] || null;
  2159. $scope[key] = self[key];
  2160. }
  2161. });
  2162. $scope.datepickerMode = $scope.datepickerMode || datepickerConfig.datepickerMode;
  2163. $scope.uniqueId = 'datepicker-' + $scope.$id + '-' + Math.floor(Math.random() * 10000);
  2164. if (angular.isDefined($attrs.initDate)) {
  2165. this.activeDate = $scope.$parent.$eval($attrs.initDate) || new Date();
  2166. $scope.$parent.$watch($attrs.initDate, function(initDate) {
  2167. if (initDate && (ngModelCtrl.$isEmpty(ngModelCtrl.$modelValue) || ngModelCtrl.$invalid)) {
  2168. self.activeDate = initDate;
  2169. self.refreshView();
  2170. }
  2171. });
  2172. } else {
  2173. this.activeDate = new Date();
  2174. }
  2175. $scope.isActive = function(dateObject) {
  2176. if (self.compare(dateObject.date, self.activeDate) === 0) {
  2177. $scope.activeDateId = dateObject.uid;
  2178. return true;
  2179. }
  2180. return false;
  2181. };
  2182. this.init = function(ngModelCtrl_) {
  2183. ngModelCtrl = ngModelCtrl_;
  2184. ngModelCtrl.$render = function() {
  2185. self.render();
  2186. };
  2187. };
  2188. this.render = function() {
  2189. if (ngModelCtrl.$viewValue) {
  2190. var date = new Date(ngModelCtrl.$viewValue),
  2191. isValid = !isNaN(date);
  2192. if (isValid) {
  2193. this.activeDate = date;
  2194. } else if (!$datepickerSuppressError) {
  2195. $log.error('Datepicker directive: "ng-model" value must be a Date object, a number of milliseconds since 01.01.1970 or a string representing an RFC2822 or ISO 8601 date.');
  2196. }
  2197. }
  2198. this.refreshView();
  2199. };
  2200. this.refreshView = function() {
  2201. if (this.element) {
  2202. this._refreshView();
  2203. var date = ngModelCtrl.$viewValue ? new Date(ngModelCtrl.$viewValue) : null;
  2204. ngModelCtrl.$setValidity('dateDisabled', !date || (this.element && !this.isDisabled(date)));
  2205. }
  2206. };
  2207. this.createDateObject = function(date, format) {
  2208. var model = ngModelCtrl.$viewValue ? new Date(ngModelCtrl.$viewValue) : null;
  2209. return {
  2210. date: date,
  2211. label: dateFilter(date, format),
  2212. selected: model && this.compare(date, model) === 0,
  2213. disabled: this.isDisabled(date),
  2214. current: this.compare(date, new Date()) === 0,
  2215. customClass: this.customClass(date)
  2216. };
  2217. };
  2218. this.isDisabled = function(date) {
  2219. return ((this.minDate && this.compare(date, this.minDate) < 0) || (this.maxDate && this.compare(date, this.maxDate) > 0) || ($attrs.dateDisabled && $scope.dateDisabled({date: date, mode: $scope.datepickerMode})));
  2220. };
  2221. this.customClass = function(date) {
  2222. return $scope.customClass({date: date, mode: $scope.datepickerMode});
  2223. };
  2224. // Split array into smaller arrays
  2225. this.split = function(arr, size) {
  2226. var arrays = [];
  2227. while (arr.length > 0) {
  2228. arrays.push(arr.splice(0, size));
  2229. }
  2230. return arrays;
  2231. };
  2232. this.fixTimeZone = function(date) {
  2233. var hours = date.getHours();
  2234. date.setHours(hours === 23 ? hours + 2 : 0);
  2235. };
  2236. $scope.select = function(date) {
  2237. if ($scope.datepickerMode === self.minMode) {
  2238. var dt = ngModelCtrl.$viewValue ? new Date(ngModelCtrl.$viewValue) : new Date(0, 0, 0, 0, 0, 0, 0);
  2239. dt.setFullYear(date.getFullYear(), date.getMonth(), date.getDate());
  2240. ngModelCtrl.$setViewValue(dt);
  2241. ngModelCtrl.$render();
  2242. } else {
  2243. self.activeDate = date;
  2244. $scope.datepickerMode = self.modes[self.modes.indexOf($scope.datepickerMode) - 1];
  2245. }
  2246. };
  2247. $scope.move = function(direction) {
  2248. var year = self.activeDate.getFullYear() + direction * (self.step.years || 0),
  2249. month = self.activeDate.getMonth() + direction * (self.step.months || 0);
  2250. self.activeDate.setFullYear(year, month, 1);
  2251. self.refreshView();
  2252. };
  2253. $scope.toggleMode = function(direction) {
  2254. direction = direction || 1;
  2255. if (($scope.datepickerMode === self.maxMode && direction === 1) || ($scope.datepickerMode === self.minMode && direction === -1)) {
  2256. return;
  2257. }
  2258. $scope.datepickerMode = self.modes[self.modes.indexOf($scope.datepickerMode) + direction];
  2259. };
  2260. // Key event mapper
  2261. $scope.keys = { 13: 'enter', 32: 'space', 33: 'pageup', 34: 'pagedown', 35: 'end', 36: 'home', 37: 'left', 38: 'up', 39: 'right', 40: 'down' };
  2262. var focusElement = function() {
  2263. self.element[0].focus();
  2264. };
  2265. $scope.$on('uib:datepicker.focus', focusElement);
  2266. $scope.keydown = function(evt) {
  2267. var key = $scope.keys[evt.which];
  2268. if (!key || evt.shiftKey || evt.altKey) {
  2269. return;
  2270. }
  2271. evt.preventDefault();
  2272. if (!self.shortcutPropagation) {
  2273. evt.stopPropagation();
  2274. }
  2275. if (key === 'enter' || key === 'space') {
  2276. if (self.isDisabled(self.activeDate)) {
  2277. return; // do nothing
  2278. }
  2279. $scope.select(self.activeDate);
  2280. } else if (evt.ctrlKey && (key === 'up' || key === 'down')) {
  2281. $scope.toggleMode(key === 'up' ? 1 : -1);
  2282. } else {
  2283. self.handleKeyDown(key, evt);
  2284. self.refreshView();
  2285. }
  2286. };
  2287. }])
  2288. .directive('datepicker', ['$log', '$datepickerSuppressWarning', function($log, $datepickerSuppressWarning) {
  2289. return {
  2290. replace: true,
  2291. templateUrl: function(element, attrs) {
  2292. return attrs.templateUrl || 'template/datepicker/datepicker.html';
  2293. },
  2294. scope: {
  2295. datepickerMode: '=?',
  2296. dateDisabled: '&',
  2297. customClass: '&',
  2298. shortcutPropagation: '&?'
  2299. },
  2300. require: ['datepicker', '^ngModel'],
  2301. controller: 'DatepickerController',
  2302. controllerAs: 'datepicker',
  2303. link: function(scope, element, attrs, ctrls) {
  2304. if (!$datepickerSuppressWarning) {
  2305. $log.warn('datepicker is now deprecated. Use uib-datepicker instead.');
  2306. }
  2307. var datepickerCtrl = ctrls[0], ngModelCtrl = ctrls[1];
  2308. datepickerCtrl.init(ngModelCtrl);
  2309. }
  2310. };
  2311. }])
  2312. .directive('daypicker', ['$log', '$datepickerSuppressWarning', function($log, $datepickerSuppressWarning) {
  2313. return {
  2314. replace: true,
  2315. templateUrl: 'template/datepicker/day.html',
  2316. require: ['^datepicker', 'daypicker'],
  2317. controller: 'UibDaypickerController',
  2318. link: function(scope, element, attrs, ctrls) {
  2319. if (!$datepickerSuppressWarning) {
  2320. $log.warn('daypicker is now deprecated. Use uib-daypicker instead.');
  2321. }
  2322. var datepickerCtrl = ctrls[0],
  2323. daypickerCtrl = ctrls[1];
  2324. daypickerCtrl.init(datepickerCtrl);
  2325. }
  2326. };
  2327. }])
  2328. .directive('monthpicker', ['$log', '$datepickerSuppressWarning', function($log, $datepickerSuppressWarning) {
  2329. return {
  2330. replace: true,
  2331. templateUrl: 'template/datepicker/month.html',
  2332. require: ['^datepicker', 'monthpicker'],
  2333. controller: 'UibMonthpickerController',
  2334. link: function(scope, element, attrs, ctrls) {
  2335. if (!$datepickerSuppressWarning) {
  2336. $log.warn('monthpicker is now deprecated. Use uib-monthpicker instead.');
  2337. }
  2338. var datepickerCtrl = ctrls[0],
  2339. monthpickerCtrl = ctrls[1];
  2340. monthpickerCtrl.init(datepickerCtrl);
  2341. }
  2342. };
  2343. }])
  2344. .directive('yearpicker', ['$log', '$datepickerSuppressWarning', function($log, $datepickerSuppressWarning) {
  2345. return {
  2346. replace: true,
  2347. templateUrl: 'template/datepicker/year.html',
  2348. require: ['^datepicker', 'yearpicker'],
  2349. controller: 'UibYearpickerController',
  2350. link: function(scope, element, attrs, ctrls) {
  2351. if (!$datepickerSuppressWarning) {
  2352. $log.warn('yearpicker is now deprecated. Use uib-yearpicker instead.');
  2353. }
  2354. var ctrl = ctrls[0];
  2355. angular.extend(ctrl, ctrls[1]);
  2356. ctrl.yearpickerInit();
  2357. ctrl.refreshView();
  2358. }
  2359. };
  2360. }])
  2361. .directive('datepickerPopup', ['$log', '$datepickerSuppressWarning', function($log, $datepickerSuppressWarning) {
  2362. return {
  2363. require: ['ngModel', 'datepickerPopup'],
  2364. controller: 'UibDatepickerPopupController',
  2365. scope: {
  2366. isOpen: '=?',
  2367. currentText: '@',
  2368. clearText: '@',
  2369. closeText: '@',
  2370. dateDisabled: '&',
  2371. customClass: '&'
  2372. },
  2373. link: function(scope, element, attrs, ctrls) {
  2374. if (!$datepickerSuppressWarning) {
  2375. $log.warn('datepicker-popup is now deprecated. Use uib-datepicker-popup instead.');
  2376. }
  2377. var ngModel = ctrls[0],
  2378. ctrl = ctrls[1];
  2379. ctrl.init(ngModel);
  2380. }
  2381. };
  2382. }])
  2383. .directive('datepickerPopupWrap', ['$log', '$datepickerSuppressWarning', function($log, $datepickerSuppressWarning) {
  2384. return {
  2385. replace: true,
  2386. transclude: true,
  2387. templateUrl: function(element, attrs) {
  2388. return attrs.templateUrl || 'template/datepicker/popup.html';
  2389. },
  2390. link: function() {
  2391. if (!$datepickerSuppressWarning) {
  2392. $log.warn('datepicker-popup-wrap is now deprecated. Use uib-datepicker-popup-wrap instead.');
  2393. }
  2394. }
  2395. };
  2396. }]);
  2397. angular.module('ui.bootstrap.dropdown', ['ui.bootstrap.position'])
  2398. .constant('uibDropdownConfig', {
  2399. openClass: 'open'
  2400. })
  2401. .service('uibDropdownService', ['$document', '$rootScope', function($document, $rootScope) {
  2402. var openScope = null;
  2403. this.open = function(dropdownScope) {
  2404. if (!openScope) {
  2405. $document.bind('click', closeDropdown);
  2406. $document.bind('keydown', keybindFilter);
  2407. }
  2408. if (openScope && openScope !== dropdownScope) {
  2409. openScope.isOpen = false;
  2410. }
  2411. openScope = dropdownScope;
  2412. };
  2413. this.close = function(dropdownScope) {
  2414. if (openScope === dropdownScope) {
  2415. openScope = null;
  2416. $document.unbind('click', closeDropdown);
  2417. $document.unbind('keydown', keybindFilter);
  2418. }
  2419. };
  2420. var closeDropdown = function(evt) {
  2421. // This method may still be called during the same mouse event that
  2422. // unbound this event handler. So check openScope before proceeding.
  2423. if (!openScope) { return; }
  2424. if (evt && openScope.getAutoClose() === 'disabled') { return ; }
  2425. var toggleElement = openScope.getToggleElement();
  2426. if (evt && toggleElement && toggleElement[0].contains(evt.target)) {
  2427. return;
  2428. }
  2429. var dropdownElement = openScope.getDropdownElement();
  2430. if (evt && openScope.getAutoClose() === 'outsideClick' &&
  2431. dropdownElement && dropdownElement[0].contains(evt.target)) {
  2432. return;
  2433. }
  2434. openScope.isOpen = false;
  2435. if (!$rootScope.$$phase) {
  2436. openScope.$apply();
  2437. }
  2438. };
  2439. var keybindFilter = function(evt) {
  2440. if (evt.which === 27) {
  2441. openScope.focusToggleElement();
  2442. closeDropdown();
  2443. } else if (openScope.isKeynavEnabled() && /(38|40)/.test(evt.which) && openScope.isOpen) {
  2444. evt.preventDefault();
  2445. evt.stopPropagation();
  2446. openScope.focusDropdownEntry(evt.which);
  2447. }
  2448. };
  2449. }])
  2450. .controller('UibDropdownController', ['$scope', '$element', '$attrs', '$parse', 'uibDropdownConfig', 'uibDropdownService', '$animate', '$uibPosition', '$document', '$compile', '$templateRequest', function($scope, $element, $attrs, $parse, dropdownConfig, uibDropdownService, $animate, $position, $document, $compile, $templateRequest) {
  2451. var self = this,
  2452. scope = $scope.$new(), // create a child scope so we are not polluting original one
  2453. templateScope,
  2454. openClass = dropdownConfig.openClass,
  2455. getIsOpen,
  2456. setIsOpen = angular.noop,
  2457. toggleInvoker = $attrs.onToggle ? $parse($attrs.onToggle) : angular.noop,
  2458. appendToBody = false,
  2459. keynavEnabled =false,
  2460. selectedOption = null;
  2461. $element.addClass('dropdown');
  2462. this.init = function() {
  2463. if ($attrs.isOpen) {
  2464. getIsOpen = $parse($attrs.isOpen);
  2465. setIsOpen = getIsOpen.assign;
  2466. $scope.$watch(getIsOpen, function(value) {
  2467. scope.isOpen = !!value;
  2468. });
  2469. }
  2470. appendToBody = angular.isDefined($attrs.dropdownAppendToBody);
  2471. keynavEnabled = angular.isDefined($attrs.uibKeyboardNav);
  2472. if (appendToBody && self.dropdownMenu) {
  2473. $document.find('body').append(self.dropdownMenu);
  2474. $element.on('$destroy', function handleDestroyEvent() {
  2475. self.dropdownMenu.remove();
  2476. });
  2477. }
  2478. };
  2479. this.toggle = function(open) {
  2480. return scope.isOpen = arguments.length ? !!open : !scope.isOpen;
  2481. };
  2482. // Allow other directives to watch status
  2483. this.isOpen = function() {
  2484. return scope.isOpen;
  2485. };
  2486. scope.getToggleElement = function() {
  2487. return self.toggleElement;
  2488. };
  2489. scope.getAutoClose = function() {
  2490. return $attrs.autoClose || 'always'; //or 'outsideClick' or 'disabled'
  2491. };
  2492. scope.getElement = function() {
  2493. return $element;
  2494. };
  2495. scope.isKeynavEnabled = function() {
  2496. return keynavEnabled;
  2497. };
  2498. scope.focusDropdownEntry = function(keyCode) {
  2499. var elems = self.dropdownMenu ? //If append to body is used.
  2500. (angular.element(self.dropdownMenu).find('a')) :
  2501. (angular.element($element).find('ul').eq(0).find('a'));
  2502. switch (keyCode) {
  2503. case (40): {
  2504. if (!angular.isNumber(self.selectedOption)) {
  2505. self.selectedOption = 0;
  2506. } else {
  2507. self.selectedOption = (self.selectedOption === elems.length - 1 ?
  2508. self.selectedOption :
  2509. self.selectedOption + 1);
  2510. }
  2511. break;
  2512. }
  2513. case (38): {
  2514. if (!angular.isNumber(self.selectedOption)) {
  2515. self.selectedOption = elems.length - 1;
  2516. } else {
  2517. self.selectedOption = self.selectedOption === 0 ?
  2518. 0 : self.selectedOption - 1;
  2519. }
  2520. break;
  2521. }
  2522. }
  2523. elems[self.selectedOption].focus();
  2524. };
  2525. scope.getDropdownElement = function() {
  2526. return self.dropdownMenu;
  2527. };
  2528. scope.focusToggleElement = function() {
  2529. if (self.toggleElement) {
  2530. self.toggleElement[0].focus();
  2531. }
  2532. };
  2533. scope.$watch('isOpen', function(isOpen, wasOpen) {
  2534. if (appendToBody && self.dropdownMenu) {
  2535. var pos = $position.positionElements($element, self.dropdownMenu, 'bottom-left', true);
  2536. var css = {
  2537. top: pos.top + 'px',
  2538. display: isOpen ? 'block' : 'none'
  2539. };
  2540. var rightalign = self.dropdownMenu.hasClass('dropdown-menu-right');
  2541. if (!rightalign) {
  2542. css.left = pos.left + 'px';
  2543. css.right = 'auto';
  2544. } else {
  2545. css.left = 'auto';
  2546. css.right = (window.innerWidth - (pos.left + $element.prop('offsetWidth'))) + 'px';
  2547. }
  2548. self.dropdownMenu.css(css);
  2549. }
  2550. $animate[isOpen ? 'addClass' : 'removeClass']($element, openClass).then(function() {
  2551. if (angular.isDefined(isOpen) && isOpen !== wasOpen) {
  2552. toggleInvoker($scope, { open: !!isOpen });
  2553. }
  2554. });
  2555. if (isOpen) {
  2556. if (self.dropdownMenuTemplateUrl) {
  2557. $templateRequest(self.dropdownMenuTemplateUrl).then(function(tplContent) {
  2558. templateScope = scope.$new();
  2559. $compile(tplContent.trim())(templateScope, function(dropdownElement) {
  2560. var newEl = dropdownElement;
  2561. self.dropdownMenu.replaceWith(newEl);
  2562. self.dropdownMenu = newEl;
  2563. });
  2564. });
  2565. }
  2566. scope.focusToggleElement();
  2567. uibDropdownService.open(scope);
  2568. } else {
  2569. if (self.dropdownMenuTemplateUrl) {
  2570. if (templateScope) {
  2571. templateScope.$destroy();
  2572. }
  2573. var newEl = angular.element('<ul class="dropdown-menu"></ul>');
  2574. self.dropdownMenu.replaceWith(newEl);
  2575. self.dropdownMenu = newEl;
  2576. }
  2577. uibDropdownService.close(scope);
  2578. self.selectedOption = null;
  2579. }
  2580. if (angular.isFunction(setIsOpen)) {
  2581. setIsOpen($scope, isOpen);
  2582. }
  2583. });
  2584. $scope.$on('$locationChangeSuccess', function() {
  2585. if (scope.getAutoClose() !== 'disabled') {
  2586. scope.isOpen = false;
  2587. }
  2588. });
  2589. var offDestroy = $scope.$on('$destroy', function() {
  2590. scope.$destroy();
  2591. });
  2592. scope.$on('$destroy', offDestroy);
  2593. }])
  2594. .directive('uibDropdown', function() {
  2595. return {
  2596. controller: 'UibDropdownController',
  2597. link: function(scope, element, attrs, dropdownCtrl) {
  2598. dropdownCtrl.init();
  2599. }
  2600. };
  2601. })
  2602. .directive('uibDropdownMenu', function() {
  2603. return {
  2604. restrict: 'AC',
  2605. require: '?^uibDropdown',
  2606. link: function(scope, element, attrs, dropdownCtrl) {
  2607. if (!dropdownCtrl || angular.isDefined(attrs.dropdownNested)) {
  2608. return;
  2609. }
  2610. element.addClass('dropdown-menu');
  2611. var tplUrl = attrs.templateUrl;
  2612. if (tplUrl) {
  2613. dropdownCtrl.dropdownMenuTemplateUrl = tplUrl;
  2614. }
  2615. if (!dropdownCtrl.dropdownMenu) {
  2616. dropdownCtrl.dropdownMenu = element;
  2617. }
  2618. }
  2619. };
  2620. })
  2621. .directive('uibKeyboardNav', function() {
  2622. return {
  2623. restrict: 'A',
  2624. require: '?^uibDropdown',
  2625. link: function(scope, element, attrs, dropdownCtrl) {
  2626. element.bind('keydown', function(e) {
  2627. if ([38, 40].indexOf(e.which) !== -1) {
  2628. e.preventDefault();
  2629. e.stopPropagation();
  2630. var elems = dropdownCtrl.dropdownMenu.find('a');
  2631. switch (e.which) {
  2632. case (40): { // Down
  2633. if (!angular.isNumber(dropdownCtrl.selectedOption)) {
  2634. dropdownCtrl.selectedOption = 0;
  2635. } else {
  2636. dropdownCtrl.selectedOption = dropdownCtrl.selectedOption === elems.length -1 ?
  2637. dropdownCtrl.selectedOption : dropdownCtrl.selectedOption + 1;
  2638. }
  2639. break;
  2640. }
  2641. case (38): { // Up
  2642. if (!angular.isNumber(dropdownCtrl.selectedOption)) {
  2643. dropdownCtrl.selectedOption = elems.length - 1;
  2644. } else {
  2645. dropdownCtrl.selectedOption = dropdownCtrl.selectedOption === 0 ?
  2646. 0 : dropdownCtrl.selectedOption - 1;
  2647. }
  2648. break;
  2649. }
  2650. }
  2651. elems[dropdownCtrl.selectedOption].focus();
  2652. }
  2653. });
  2654. }
  2655. };
  2656. })
  2657. .directive('uibDropdownToggle', function() {
  2658. return {
  2659. require: '?^uibDropdown',
  2660. link: function(scope, element, attrs, dropdownCtrl) {
  2661. if (!dropdownCtrl) {
  2662. return;
  2663. }
  2664. element.addClass('dropdown-toggle');
  2665. dropdownCtrl.toggleElement = element;
  2666. var toggleDropdown = function(event) {
  2667. event.preventDefault();
  2668. if (!element.hasClass('disabled') && !attrs.disabled) {
  2669. scope.$apply(function() {
  2670. dropdownCtrl.toggle();
  2671. });
  2672. }
  2673. };
  2674. element.bind('click', toggleDropdown);
  2675. // WAI-ARIA
  2676. element.attr({ 'aria-haspopup': true, 'aria-expanded': false });
  2677. scope.$watch(dropdownCtrl.isOpen, function(isOpen) {
  2678. element.attr('aria-expanded', !!isOpen);
  2679. });
  2680. scope.$on('$destroy', function() {
  2681. element.unbind('click', toggleDropdown);
  2682. });
  2683. }
  2684. };
  2685. });
  2686. /* Deprecated dropdown below */
  2687. angular.module('ui.bootstrap.dropdown')
  2688. .value('$dropdownSuppressWarning', false)
  2689. .service('dropdownService', ['$log', '$dropdownSuppressWarning', 'uibDropdownService', function($log, $dropdownSuppressWarning, uibDropdownService) {
  2690. if (!$dropdownSuppressWarning) {
  2691. $log.warn('dropdownService is now deprecated. Use uibDropdownService instead.');
  2692. }
  2693. angular.extend(this, uibDropdownService);
  2694. }])
  2695. .controller('DropdownController', ['$scope', '$element', '$attrs', '$parse', 'uibDropdownConfig', 'uibDropdownService', '$animate', '$uibPosition', '$document', '$compile', '$templateRequest', '$log', '$dropdownSuppressWarning', function($scope, $element, $attrs, $parse, dropdownConfig, uibDropdownService, $animate, $position, $document, $compile, $templateRequest, $log, $dropdownSuppressWarning) {
  2696. if (!$dropdownSuppressWarning) {
  2697. $log.warn('DropdownController is now deprecated. Use UibDropdownController instead.');
  2698. }
  2699. var self = this,
  2700. scope = $scope.$new(), // create a child scope so we are not polluting original one
  2701. templateScope,
  2702. openClass = dropdownConfig.openClass,
  2703. getIsOpen,
  2704. setIsOpen = angular.noop,
  2705. toggleInvoker = $attrs.onToggle ? $parse($attrs.onToggle) : angular.noop,
  2706. appendToBody = false,
  2707. keynavEnabled =false,
  2708. selectedOption = null;
  2709. $element.addClass('dropdown');
  2710. this.init = function() {
  2711. if ($attrs.isOpen) {
  2712. getIsOpen = $parse($attrs.isOpen);
  2713. setIsOpen = getIsOpen.assign;
  2714. $scope.$watch(getIsOpen, function(value) {
  2715. scope.isOpen = !!value;
  2716. });
  2717. }
  2718. appendToBody = angular.isDefined($attrs.dropdownAppendToBody);
  2719. keynavEnabled = angular.isDefined($attrs.uibKeyboardNav);
  2720. if (appendToBody && self.dropdownMenu) {
  2721. $document.find('body').append(self.dropdownMenu);
  2722. $element.on('$destroy', function handleDestroyEvent() {
  2723. self.dropdownMenu.remove();
  2724. });
  2725. }
  2726. };
  2727. this.toggle = function(open) {
  2728. return scope.isOpen = arguments.length ? !!open : !scope.isOpen;
  2729. };
  2730. // Allow other directives to watch status
  2731. this.isOpen = function() {
  2732. return scope.isOpen;
  2733. };
  2734. scope.getToggleElement = function() {
  2735. return self.toggleElement;
  2736. };
  2737. scope.getAutoClose = function() {
  2738. return $attrs.autoClose || 'always'; //or 'outsideClick' or 'disabled'
  2739. };
  2740. scope.getElement = function() {
  2741. return $element;
  2742. };
  2743. scope.isKeynavEnabled = function() {
  2744. return keynavEnabled;
  2745. };
  2746. scope.focusDropdownEntry = function(keyCode) {
  2747. var elems = self.dropdownMenu ? //If append to body is used.
  2748. (angular.element(self.dropdownMenu).find('a')) :
  2749. (angular.element($element).find('ul').eq(0).find('a'));
  2750. switch (keyCode) {
  2751. case (40): {
  2752. if (!angular.isNumber(self.selectedOption)) {
  2753. self.selectedOption = 0;
  2754. } else {
  2755. self.selectedOption = (self.selectedOption === elems.length -1 ?
  2756. self.selectedOption :
  2757. self.selectedOption + 1);
  2758. }
  2759. break;
  2760. }
  2761. case (38): {
  2762. if (!angular.isNumber(self.selectedOption)) {
  2763. self.selectedOption = elems.length - 1;
  2764. } else {
  2765. self.selectedOption = self.selectedOption === 0 ?
  2766. 0 : self.selectedOption - 1;
  2767. }
  2768. break;
  2769. }
  2770. }
  2771. elems[self.selectedOption].focus();
  2772. };
  2773. scope.getDropdownElement = function() {
  2774. return self.dropdownMenu;
  2775. };
  2776. scope.focusToggleElement = function() {
  2777. if (self.toggleElement) {
  2778. self.toggleElement[0].focus();
  2779. }
  2780. };
  2781. scope.$watch('isOpen', function(isOpen, wasOpen) {
  2782. if (appendToBody && self.dropdownMenu) {
  2783. var pos = $position.positionElements($element, self.dropdownMenu, 'bottom-left', true);
  2784. var css = {
  2785. top: pos.top + 'px',
  2786. display: isOpen ? 'block' : 'none'
  2787. };
  2788. var rightalign = self.dropdownMenu.hasClass('dropdown-menu-right');
  2789. if (!rightalign) {
  2790. css.left = pos.left + 'px';
  2791. css.right = 'auto';
  2792. } else {
  2793. css.left = 'auto';
  2794. css.right = (window.innerWidth - (pos.left + $element.prop('offsetWidth'))) + 'px';
  2795. }
  2796. self.dropdownMenu.css(css);
  2797. }
  2798. $animate[isOpen ? 'addClass' : 'removeClass']($element, openClass).then(function() {
  2799. if (angular.isDefined(isOpen) && isOpen !== wasOpen) {
  2800. toggleInvoker($scope, { open: !!isOpen });
  2801. }
  2802. });
  2803. if (isOpen) {
  2804. if (self.dropdownMenuTemplateUrl) {
  2805. $templateRequest(self.dropdownMenuTemplateUrl).then(function(tplContent) {
  2806. templateScope = scope.$new();
  2807. $compile(tplContent.trim())(templateScope, function(dropdownElement) {
  2808. var newEl = dropdownElement;
  2809. self.dropdownMenu.replaceWith(newEl);
  2810. self.dropdownMenu = newEl;
  2811. });
  2812. });
  2813. }
  2814. scope.focusToggleElement();
  2815. uibDropdownService.open(scope);
  2816. } else {
  2817. if (self.dropdownMenuTemplateUrl) {
  2818. if (templateScope) {
  2819. templateScope.$destroy();
  2820. }
  2821. var newEl = angular.element('<ul class="dropdown-menu"></ul>');
  2822. self.dropdownMenu.replaceWith(newEl);
  2823. self.dropdownMenu = newEl;
  2824. }
  2825. uibDropdownService.close(scope);
  2826. self.selectedOption = null;
  2827. }
  2828. if (angular.isFunction(setIsOpen)) {
  2829. setIsOpen($scope, isOpen);
  2830. }
  2831. });
  2832. $scope.$on('$locationChangeSuccess', function() {
  2833. if (scope.getAutoClose() !== 'disabled') {
  2834. scope.isOpen = false;
  2835. }
  2836. });
  2837. var offDestroy = $scope.$on('$destroy', function() {
  2838. scope.$destroy();
  2839. });
  2840. scope.$on('$destroy', offDestroy);
  2841. }])
  2842. .directive('dropdown', ['$log', '$dropdownSuppressWarning', function($log, $dropdownSuppressWarning) {
  2843. return {
  2844. controller: 'DropdownController',
  2845. link: function(scope, element, attrs, dropdownCtrl) {
  2846. if (!$dropdownSuppressWarning) {
  2847. $log.warn('dropdown is now deprecated. Use uib-dropdown instead.');
  2848. }
  2849. dropdownCtrl.init();
  2850. }
  2851. };
  2852. }])
  2853. .directive('dropdownMenu', ['$log', '$dropdownSuppressWarning', function($log, $dropdownSuppressWarning) {
  2854. return {
  2855. restrict: 'AC',
  2856. require: '?^dropdown',
  2857. link: function(scope, element, attrs, dropdownCtrl) {
  2858. if (!dropdownCtrl || angular.isDefined(attrs.dropdownNested)) {
  2859. return;
  2860. }
  2861. if (!$dropdownSuppressWarning) {
  2862. $log.warn('dropdown-menu is now deprecated. Use uib-dropdown-menu instead.');
  2863. }
  2864. element.addClass('dropdown-menu');
  2865. var tplUrl = attrs.templateUrl;
  2866. if (tplUrl) {
  2867. dropdownCtrl.dropdownMenuTemplateUrl = tplUrl;
  2868. }
  2869. if (!dropdownCtrl.dropdownMenu) {
  2870. dropdownCtrl.dropdownMenu = element;
  2871. }
  2872. }
  2873. };
  2874. }])
  2875. .directive('keyboardNav', ['$log', '$dropdownSuppressWarning', function($log, $dropdownSuppressWarning) {
  2876. return {
  2877. restrict: 'A',
  2878. require: '?^dropdown',
  2879. link: function(scope, element, attrs, dropdownCtrl) {
  2880. if (!$dropdownSuppressWarning) {
  2881. $log.warn('keyboard-nav is now deprecated. Use uib-keyboard-nav instead.');
  2882. }
  2883. element.bind('keydown', function(e) {
  2884. if ([38, 40].indexOf(e.which) !== -1) {
  2885. e.preventDefault();
  2886. e.stopPropagation();
  2887. var elems = dropdownCtrl.dropdownMenu.find('a');
  2888. switch (e.which) {
  2889. case (40): { // Down
  2890. if (!angular.isNumber(dropdownCtrl.selectedOption)) {
  2891. dropdownCtrl.selectedOption = 0;
  2892. } else {
  2893. dropdownCtrl.selectedOption = dropdownCtrl.selectedOption === elems.length -1 ?
  2894. dropdownCtrl.selectedOption : dropdownCtrl.selectedOption + 1;
  2895. }
  2896. break;
  2897. }
  2898. case (38): { // Up
  2899. if (!angular.isNumber(dropdownCtrl.selectedOption)) {
  2900. dropdownCtrl.selectedOption = elems.length - 1;
  2901. } else {
  2902. dropdownCtrl.selectedOption = dropdownCtrl.selectedOption === 0 ?
  2903. 0 : dropdownCtrl.selectedOption - 1;
  2904. }
  2905. break;
  2906. }
  2907. }
  2908. elems[dropdownCtrl.selectedOption].focus();
  2909. }
  2910. });
  2911. }
  2912. };
  2913. }])
  2914. .directive('dropdownToggle', ['$log', '$dropdownSuppressWarning', function($log, $dropdownSuppressWarning) {
  2915. return {
  2916. require: '?^dropdown',
  2917. link: function(scope, element, attrs, dropdownCtrl) {
  2918. if (!$dropdownSuppressWarning) {
  2919. $log.warn('dropdown-toggle is now deprecated. Use uib-dropdown-toggle instead.');
  2920. }
  2921. if (!dropdownCtrl) {
  2922. return;
  2923. }
  2924. element.addClass('dropdown-toggle');
  2925. dropdownCtrl.toggleElement = element;
  2926. var toggleDropdown = function(event) {
  2927. event.preventDefault();
  2928. if (!element.hasClass('disabled') && !attrs.disabled) {
  2929. scope.$apply(function() {
  2930. dropdownCtrl.toggle();
  2931. });
  2932. }
  2933. };
  2934. element.bind('click', toggleDropdown);
  2935. // WAI-ARIA
  2936. element.attr({ 'aria-haspopup': true, 'aria-expanded': false });
  2937. scope.$watch(dropdownCtrl.isOpen, function(isOpen) {
  2938. element.attr('aria-expanded', !!isOpen);
  2939. });
  2940. scope.$on('$destroy', function() {
  2941. element.unbind('click', toggleDropdown);
  2942. });
  2943. }
  2944. };
  2945. }]);
  2946. angular.module('ui.bootstrap.stackedMap', [])
  2947. /**
  2948. * A helper, internal data structure that acts as a map but also allows getting / removing
  2949. * elements in the LIFO order
  2950. */
  2951. .factory('$$stackedMap', function() {
  2952. return {
  2953. createNew: function() {
  2954. var stack = [];
  2955. return {
  2956. add: function(key, value) {
  2957. stack.push({
  2958. key: key,
  2959. value: value
  2960. });
  2961. },
  2962. get: function(key) {
  2963. for (var i = 0; i < stack.length; i++) {
  2964. if (key == stack[i].key) {
  2965. return stack[i];
  2966. }
  2967. }
  2968. },
  2969. keys: function() {
  2970. var keys = [];
  2971. for (var i = 0; i < stack.length; i++) {
  2972. keys.push(stack[i].key);
  2973. }
  2974. return keys;
  2975. },
  2976. top: function() {
  2977. return stack[stack.length - 1];
  2978. },
  2979. remove: function(key) {
  2980. var idx = -1;
  2981. for (var i = 0; i < stack.length; i++) {
  2982. if (key == stack[i].key) {
  2983. idx = i;
  2984. break;
  2985. }
  2986. }
  2987. return stack.splice(idx, 1)[0];
  2988. },
  2989. removeTop: function() {
  2990. return stack.splice(stack.length - 1, 1)[0];
  2991. },
  2992. length: function() {
  2993. return stack.length;
  2994. }
  2995. };
  2996. }
  2997. };
  2998. });
  2999. angular.module('ui.bootstrap.modal', ['ui.bootstrap.stackedMap'])
  3000. /**
  3001. * A helper, internal data structure that stores all references attached to key
  3002. */
  3003. .factory('$$multiMap', function() {
  3004. return {
  3005. createNew: function() {
  3006. var map = {};
  3007. return {
  3008. entries: function() {
  3009. return Object.keys(map).map(function(key) {
  3010. return {
  3011. key: key,
  3012. value: map[key]
  3013. };
  3014. });
  3015. },
  3016. get: function(key) {
  3017. return map[key];
  3018. },
  3019. hasKey: function(key) {
  3020. return !!map[key];
  3021. },
  3022. keys: function() {
  3023. return Object.keys(map);
  3024. },
  3025. put: function(key, value) {
  3026. if (!map[key]) {
  3027. map[key] = [];
  3028. }
  3029. map[key].push(value);
  3030. },
  3031. remove: function(key, value) {
  3032. var values = map[key];
  3033. if (!values) {
  3034. return;
  3035. }
  3036. var idx = values.indexOf(value);
  3037. if (idx !== -1) {
  3038. values.splice(idx, 1);
  3039. }
  3040. if (!values.length) {
  3041. delete map[key];
  3042. }
  3043. }
  3044. };
  3045. }
  3046. };
  3047. })
  3048. /**
  3049. * A helper directive for the $modal service. It creates a backdrop element.
  3050. */
  3051. .directive('uibModalBackdrop', [
  3052. '$animate', '$injector', '$uibModalStack',
  3053. function($animate , $injector, $modalStack) {
  3054. var $animateCss = null;
  3055. if ($injector.has('$animateCss')) {
  3056. $animateCss = $injector.get('$animateCss');
  3057. }
  3058. return {
  3059. replace: true,
  3060. templateUrl: 'template/modal/backdrop.html',
  3061. compile: function(tElement, tAttrs) {
  3062. tElement.addClass(tAttrs.backdropClass);
  3063. return linkFn;
  3064. }
  3065. };
  3066. function linkFn(scope, element, attrs) {
  3067. // Temporary fix for prefixing
  3068. element.addClass('modal-backdrop');
  3069. if (attrs.modalInClass) {
  3070. if ($animateCss) {
  3071. $animateCss(element, {
  3072. addClass: attrs.modalInClass
  3073. }).start();
  3074. } else {
  3075. $animate.addClass(element, attrs.modalInClass);
  3076. }
  3077. scope.$on($modalStack.NOW_CLOSING_EVENT, function(e, setIsAsync) {
  3078. var done = setIsAsync();
  3079. if ($animateCss) {
  3080. $animateCss(element, {
  3081. removeClass: attrs.modalInClass
  3082. }).start().then(done);
  3083. } else {
  3084. $animate.removeClass(element, attrs.modalInClass).then(done);
  3085. }
  3086. });
  3087. }
  3088. }
  3089. }])
  3090. .directive('uibModalWindow', [
  3091. '$uibModalStack', '$q', '$animate', '$injector',
  3092. function($modalStack , $q , $animate, $injector) {
  3093. var $animateCss = null;
  3094. if ($injector.has('$animateCss')) {
  3095. $animateCss = $injector.get('$animateCss');
  3096. }
  3097. return {
  3098. scope: {
  3099. index: '@'
  3100. },
  3101. replace: true,
  3102. transclude: true,
  3103. templateUrl: function(tElement, tAttrs) {
  3104. return tAttrs.templateUrl || 'template/modal/window.html';
  3105. },
  3106. link: function(scope, element, attrs) {
  3107. element.addClass(attrs.windowClass || '');
  3108. element.addClass(attrs.windowTopClass || '');
  3109. scope.size = attrs.size;
  3110. scope.close = function(evt) {
  3111. var modal = $modalStack.getTop();
  3112. if (modal && modal.value.backdrop && modal.value.backdrop !== 'static' && (evt.target === evt.currentTarget)) {
  3113. evt.preventDefault();
  3114. evt.stopPropagation();
  3115. $modalStack.dismiss(modal.key, 'backdrop click');
  3116. }
  3117. };
  3118. // moved from template to fix issue #2280
  3119. element.on('click', scope.close);
  3120. // This property is only added to the scope for the purpose of detecting when this directive is rendered.
  3121. // We can detect that by using this property in the template associated with this directive and then use
  3122. // {@link Attribute#$observe} on it. For more details please see {@link TableColumnResize}.
  3123. scope.$isRendered = true;
  3124. // Deferred object that will be resolved when this modal is render.
  3125. var modalRenderDeferObj = $q.defer();
  3126. // Observe function will be called on next digest cycle after compilation, ensuring that the DOM is ready.
  3127. // In order to use this way of finding whether DOM is ready, we need to observe a scope property used in modal's template.
  3128. attrs.$observe('modalRender', function(value) {
  3129. if (value == 'true') {
  3130. modalRenderDeferObj.resolve();
  3131. }
  3132. });
  3133. modalRenderDeferObj.promise.then(function() {
  3134. var animationPromise = null;
  3135. if (attrs.modalInClass) {
  3136. if ($animateCss) {
  3137. animationPromise = $animateCss(element, {
  3138. addClass: attrs.modalInClass
  3139. }).start();
  3140. } else {
  3141. animationPromise = $animate.addClass(element, attrs.modalInClass);
  3142. }
  3143. scope.$on($modalStack.NOW_CLOSING_EVENT, function(e, setIsAsync) {
  3144. var done = setIsAsync();
  3145. if ($animateCss) {
  3146. $animateCss(element, {
  3147. removeClass: attrs.modalInClass
  3148. }).start().then(done);
  3149. } else {
  3150. $animate.removeClass(element, attrs.modalInClass).then(done);
  3151. }
  3152. });
  3153. }
  3154. $q.when(animationPromise).then(function() {
  3155. var inputWithAutofocus = element[0].querySelector('[autofocus]');
  3156. /**
  3157. * Auto-focusing of a freshly-opened modal element causes any child elements
  3158. * with the autofocus attribute to lose focus. This is an issue on touch
  3159. * based devices which will show and then hide the onscreen keyboard.
  3160. * Attempts to refocus the autofocus element via JavaScript will not reopen
  3161. * the onscreen keyboard. Fixed by updated the focusing logic to only autofocus
  3162. * the modal element if the modal does not contain an autofocus element.
  3163. */
  3164. if (inputWithAutofocus) {
  3165. inputWithAutofocus.focus();
  3166. } else {
  3167. element[0].focus();
  3168. }
  3169. });
  3170. // Notify {@link $modalStack} that modal is rendered.
  3171. var modal = $modalStack.getTop();
  3172. if (modal) {
  3173. $modalStack.modalRendered(modal.key);
  3174. }
  3175. });
  3176. }
  3177. };
  3178. }])
  3179. .directive('uibModalAnimationClass', function() {
  3180. return {
  3181. compile: function(tElement, tAttrs) {
  3182. if (tAttrs.modalAnimation) {
  3183. tElement.addClass(tAttrs.uibModalAnimationClass);
  3184. }
  3185. }
  3186. };
  3187. })
  3188. .directive('uibModalTransclude', function() {
  3189. return {
  3190. link: function($scope, $element, $attrs, controller, $transclude) {
  3191. $transclude($scope.$parent, function(clone) {
  3192. $element.empty();
  3193. $element.append(clone);
  3194. });
  3195. }
  3196. };
  3197. })
  3198. .factory('$uibModalStack', [
  3199. '$animate', '$timeout', '$document', '$compile', '$rootScope',
  3200. '$q',
  3201. '$injector',
  3202. '$$multiMap',
  3203. '$$stackedMap',
  3204. function($animate , $timeout , $document , $compile , $rootScope ,
  3205. $q,
  3206. $injector,
  3207. $$multiMap,
  3208. $$stackedMap) {
  3209. var $animateCss = null;
  3210. if ($injector.has('$animateCss')) {
  3211. $animateCss = $injector.get('$animateCss');
  3212. }
  3213. var OPENED_MODAL_CLASS = 'modal-open';
  3214. var backdropDomEl, backdropScope;
  3215. var openedWindows = $$stackedMap.createNew();
  3216. var openedClasses = $$multiMap.createNew();
  3217. var $modalStack = {
  3218. NOW_CLOSING_EVENT: 'modal.stack.now-closing'
  3219. };
  3220. //Modal focus behavior
  3221. var focusableElementList;
  3222. var focusIndex = 0;
  3223. var tababbleSelector = 'a[href], area[href], input:not([disabled]), ' +
  3224. 'button:not([disabled]),select:not([disabled]), textarea:not([disabled]), ' +
  3225. 'iframe, object, embed, *[tabindex], *[contenteditable=true]';
  3226. function backdropIndex() {
  3227. var topBackdropIndex = -1;
  3228. var opened = openedWindows.keys();
  3229. for (var i = 0; i < opened.length; i++) {
  3230. if (openedWindows.get(opened[i]).value.backdrop) {
  3231. topBackdropIndex = i;
  3232. }
  3233. }
  3234. return topBackdropIndex;
  3235. }
  3236. $rootScope.$watch(backdropIndex, function(newBackdropIndex) {
  3237. if (backdropScope) {
  3238. backdropScope.index = newBackdropIndex;
  3239. }
  3240. });
  3241. function removeModalWindow(modalInstance, elementToReceiveFocus) {
  3242. var body = $document.find('body').eq(0);
  3243. var modalWindow = openedWindows.get(modalInstance).value;
  3244. //clean up the stack
  3245. openedWindows.remove(modalInstance);
  3246. removeAfterAnimate(modalWindow.modalDomEl, modalWindow.modalScope, function() {
  3247. var modalBodyClass = modalWindow.openedClass || OPENED_MODAL_CLASS;
  3248. openedClasses.remove(modalBodyClass, modalInstance);
  3249. body.toggleClass(modalBodyClass, openedClasses.hasKey(modalBodyClass));
  3250. toggleTopWindowClass(true);
  3251. });
  3252. checkRemoveBackdrop();
  3253. //move focus to specified element if available, or else to body
  3254. if (elementToReceiveFocus && elementToReceiveFocus.focus) {
  3255. elementToReceiveFocus.focus();
  3256. } else {
  3257. body.focus();
  3258. }
  3259. }
  3260. // Add or remove "windowTopClass" from the top window in the stack
  3261. function toggleTopWindowClass(toggleSwitch) {
  3262. var modalWindow;
  3263. if (openedWindows.length() > 0) {
  3264. modalWindow = openedWindows.top().value;
  3265. modalWindow.modalDomEl.toggleClass(modalWindow.windowTopClass || '', toggleSwitch);
  3266. }
  3267. }
  3268. function checkRemoveBackdrop() {
  3269. //remove backdrop if no longer needed
  3270. if (backdropDomEl && backdropIndex() == -1) {
  3271. var backdropScopeRef = backdropScope;
  3272. removeAfterAnimate(backdropDomEl, backdropScope, function() {
  3273. backdropScopeRef = null;
  3274. });
  3275. backdropDomEl = undefined;
  3276. backdropScope = undefined;
  3277. }
  3278. }
  3279. function removeAfterAnimate(domEl, scope, done) {
  3280. var asyncDeferred;
  3281. var asyncPromise = null;
  3282. var setIsAsync = function() {
  3283. if (!asyncDeferred) {
  3284. asyncDeferred = $q.defer();
  3285. asyncPromise = asyncDeferred.promise;
  3286. }
  3287. return function asyncDone() {
  3288. asyncDeferred.resolve();
  3289. };
  3290. };
  3291. scope.$broadcast($modalStack.NOW_CLOSING_EVENT, setIsAsync);
  3292. // Note that it's intentional that asyncPromise might be null.
  3293. // That's when setIsAsync has not been called during the
  3294. // NOW_CLOSING_EVENT broadcast.
  3295. return $q.when(asyncPromise).then(afterAnimating);
  3296. function afterAnimating() {
  3297. if (afterAnimating.done) {
  3298. return;
  3299. }
  3300. afterAnimating.done = true;
  3301. if ($animateCss) {
  3302. $animateCss(domEl, {
  3303. event: 'leave'
  3304. }).start().then(function() {
  3305. domEl.remove();
  3306. });
  3307. } else {
  3308. $animate.leave(domEl);
  3309. }
  3310. scope.$destroy();
  3311. if (done) {
  3312. done();
  3313. }
  3314. }
  3315. }
  3316. $document.bind('keydown', function(evt) {
  3317. if (evt.isDefaultPrevented()) {
  3318. return evt;
  3319. }
  3320. var modal = openedWindows.top();
  3321. if (modal && modal.value.keyboard) {
  3322. switch (evt.which) {
  3323. case 27: {
  3324. evt.preventDefault();
  3325. $rootScope.$apply(function() {
  3326. $modalStack.dismiss(modal.key, 'escape key press');
  3327. });
  3328. break;
  3329. }
  3330. case 9: {
  3331. $modalStack.loadFocusElementList(modal);
  3332. var focusChanged = false;
  3333. if (evt.shiftKey) {
  3334. if ($modalStack.isFocusInFirstItem(evt)) {
  3335. focusChanged = $modalStack.focusLastFocusableElement();
  3336. }
  3337. } else {
  3338. if ($modalStack.isFocusInLastItem(evt)) {
  3339. focusChanged = $modalStack.focusFirstFocusableElement();
  3340. }
  3341. }
  3342. if (focusChanged) {
  3343. evt.preventDefault();
  3344. evt.stopPropagation();
  3345. }
  3346. break;
  3347. }
  3348. }
  3349. }
  3350. });
  3351. $modalStack.open = function(modalInstance, modal) {
  3352. var modalOpener = $document[0].activeElement,
  3353. modalBodyClass = modal.openedClass || OPENED_MODAL_CLASS;
  3354. toggleTopWindowClass(false);
  3355. openedWindows.add(modalInstance, {
  3356. deferred: modal.deferred,
  3357. renderDeferred: modal.renderDeferred,
  3358. modalScope: modal.scope,
  3359. backdrop: modal.backdrop,
  3360. keyboard: modal.keyboard,
  3361. openedClass: modal.openedClass,
  3362. windowTopClass: modal.windowTopClass
  3363. });
  3364. openedClasses.put(modalBodyClass, modalInstance);
  3365. var body = $document.find('body').eq(0),
  3366. currBackdropIndex = backdropIndex();
  3367. if (currBackdropIndex >= 0 && !backdropDomEl) {
  3368. backdropScope = $rootScope.$new(true);
  3369. backdropScope.index = currBackdropIndex;
  3370. var angularBackgroundDomEl = angular.element('<div uib-modal-backdrop="modal-backdrop"></div>');
  3371. angularBackgroundDomEl.attr('backdrop-class', modal.backdropClass);
  3372. if (modal.animation) {
  3373. angularBackgroundDomEl.attr('modal-animation', 'true');
  3374. }
  3375. backdropDomEl = $compile(angularBackgroundDomEl)(backdropScope);
  3376. body.append(backdropDomEl);
  3377. }
  3378. var angularDomEl = angular.element('<div uib-modal-window="modal-window"></div>');
  3379. angularDomEl.attr({
  3380. 'template-url': modal.windowTemplateUrl,
  3381. 'window-class': modal.windowClass,
  3382. 'window-top-class': modal.windowTopClass,
  3383. 'size': modal.size,
  3384. 'index': openedWindows.length() - 1,
  3385. 'animate': 'animate'
  3386. }).html(modal.content);
  3387. if (modal.animation) {
  3388. angularDomEl.attr('modal-animation', 'true');
  3389. }
  3390. var modalDomEl = $compile(angularDomEl)(modal.scope);
  3391. openedWindows.top().value.modalDomEl = modalDomEl;
  3392. openedWindows.top().value.modalOpener = modalOpener;
  3393. body.append(modalDomEl);
  3394. body.addClass(modalBodyClass);
  3395. $modalStack.clearFocusListCache();
  3396. };
  3397. function broadcastClosing(modalWindow, resultOrReason, closing) {
  3398. return !modalWindow.value.modalScope.$broadcast('modal.closing', resultOrReason, closing).defaultPrevented;
  3399. }
  3400. $modalStack.close = function(modalInstance, result) {
  3401. var modalWindow = openedWindows.get(modalInstance);
  3402. if (modalWindow && broadcastClosing(modalWindow, result, true)) {
  3403. modalWindow.value.modalScope.$$uibDestructionScheduled = true;
  3404. modalWindow.value.deferred.resolve(result);
  3405. removeModalWindow(modalInstance, modalWindow.value.modalOpener);
  3406. return true;
  3407. }
  3408. return !modalWindow;
  3409. };
  3410. $modalStack.dismiss = function(modalInstance, reason) {
  3411. var modalWindow = openedWindows.get(modalInstance);
  3412. if (modalWindow && broadcastClosing(modalWindow, reason, false)) {
  3413. modalWindow.value.modalScope.$$uibDestructionScheduled = true;
  3414. modalWindow.value.deferred.reject(reason);
  3415. removeModalWindow(modalInstance, modalWindow.value.modalOpener);
  3416. return true;
  3417. }
  3418. return !modalWindow;
  3419. };
  3420. $modalStack.dismissAll = function(reason) {
  3421. var topModal = this.getTop();
  3422. while (topModal && this.dismiss(topModal.key, reason)) {
  3423. topModal = this.getTop();
  3424. }
  3425. };
  3426. $modalStack.getTop = function() {
  3427. return openedWindows.top();
  3428. };
  3429. $modalStack.modalRendered = function(modalInstance) {
  3430. var modalWindow = openedWindows.get(modalInstance);
  3431. if (modalWindow) {
  3432. modalWindow.value.renderDeferred.resolve();
  3433. }
  3434. };
  3435. $modalStack.focusFirstFocusableElement = function() {
  3436. if (focusableElementList.length > 0) {
  3437. focusableElementList[0].focus();
  3438. return true;
  3439. }
  3440. return false;
  3441. };
  3442. $modalStack.focusLastFocusableElement = function() {
  3443. if (focusableElementList.length > 0) {
  3444. focusableElementList[focusableElementList.length - 1].focus();
  3445. return true;
  3446. }
  3447. return false;
  3448. };
  3449. $modalStack.isFocusInFirstItem = function(evt) {
  3450. if (focusableElementList.length > 0) {
  3451. return (evt.target || evt.srcElement) == focusableElementList[0];
  3452. }
  3453. return false;
  3454. };
  3455. $modalStack.isFocusInLastItem = function(evt) {
  3456. if (focusableElementList.length > 0) {
  3457. return (evt.target || evt.srcElement) == focusableElementList[focusableElementList.length - 1];
  3458. }
  3459. return false;
  3460. };
  3461. $modalStack.clearFocusListCache = function() {
  3462. focusableElementList = [];
  3463. focusIndex = 0;
  3464. };
  3465. $modalStack.loadFocusElementList = function(modalWindow) {
  3466. if (focusableElementList === undefined || !focusableElementList.length) {
  3467. if (modalWindow) {
  3468. var modalDomE1 = modalWindow.value.modalDomEl;
  3469. if (modalDomE1 && modalDomE1.length) {
  3470. focusableElementList = modalDomE1[0].querySelectorAll(tababbleSelector);
  3471. }
  3472. }
  3473. }
  3474. };
  3475. return $modalStack;
  3476. }])
  3477. .provider('$uibModal', function() {
  3478. var $modalProvider = {
  3479. options: {
  3480. animation: true,
  3481. backdrop: true, //can also be false or 'static'
  3482. keyboard: true
  3483. },
  3484. $get: ['$injector', '$rootScope', '$q', '$templateRequest', '$controller', '$uibModalStack', '$modalSuppressWarning', '$log',
  3485. function ($injector, $rootScope, $q, $templateRequest, $controller, $modalStack, $modalSuppressWarning, $log) {
  3486. var $modal = {};
  3487. function getTemplatePromise(options) {
  3488. return options.template ? $q.when(options.template) :
  3489. $templateRequest(angular.isFunction(options.templateUrl) ? (options.templateUrl)() : options.templateUrl);
  3490. }
  3491. function getResolvePromises(resolves) {
  3492. var promisesArr = [];
  3493. angular.forEach(resolves, function(value) {
  3494. if (angular.isFunction(value) || angular.isArray(value)) {
  3495. promisesArr.push($q.when($injector.invoke(value)));
  3496. } else if (angular.isString(value)) {
  3497. promisesArr.push($q.when($injector.get(value)));
  3498. } else {
  3499. promisesArr.push($q.when(value));
  3500. }
  3501. });
  3502. return promisesArr;
  3503. }
  3504. var promiseChain = null;
  3505. $modal.getPromiseChain = function() {
  3506. return promiseChain;
  3507. };
  3508. $modal.open = function(modalOptions) {
  3509. var modalResultDeferred = $q.defer();
  3510. var modalOpenedDeferred = $q.defer();
  3511. var modalRenderDeferred = $q.defer();
  3512. //prepare an instance of a modal to be injected into controllers and returned to a caller
  3513. var modalInstance = {
  3514. result: modalResultDeferred.promise,
  3515. opened: modalOpenedDeferred.promise,
  3516. rendered: modalRenderDeferred.promise,
  3517. close: function (result) {
  3518. return $modalStack.close(modalInstance, result);
  3519. },
  3520. dismiss: function (reason) {
  3521. return $modalStack.dismiss(modalInstance, reason);
  3522. }
  3523. };
  3524. //merge and clean up options
  3525. modalOptions = angular.extend({}, $modalProvider.options, modalOptions);
  3526. modalOptions.resolve = modalOptions.resolve || {};
  3527. //verify options
  3528. if (!modalOptions.template && !modalOptions.templateUrl) {
  3529. throw new Error('One of template or templateUrl options is required.');
  3530. }
  3531. var templateAndResolvePromise =
  3532. $q.all([getTemplatePromise(modalOptions)].concat(getResolvePromises(modalOptions.resolve)));
  3533. function resolveWithTemplate() {
  3534. return templateAndResolvePromise;
  3535. }
  3536. // Wait for the resolution of the existing promise chain.
  3537. // Then switch to our own combined promise dependency (regardless of how the previous modal fared).
  3538. // Then add to $modalStack and resolve opened.
  3539. // Finally clean up the chain variable if no subsequent modal has overwritten it.
  3540. var samePromise;
  3541. samePromise = promiseChain = $q.all([promiseChain])
  3542. .then(resolveWithTemplate, resolveWithTemplate)
  3543. .then(function resolveSuccess(tplAndVars) {
  3544. var modalScope = (modalOptions.scope || $rootScope).$new();
  3545. modalScope.$close = modalInstance.close;
  3546. modalScope.$dismiss = modalInstance.dismiss;
  3547. modalScope.$on('$destroy', function() {
  3548. if (!modalScope.$$uibDestructionScheduled) {
  3549. modalScope.$dismiss('$uibUnscheduledDestruction');
  3550. }
  3551. });
  3552. var ctrlInstance, ctrlLocals = {};
  3553. var resolveIter = 1;
  3554. //controllers
  3555. if (modalOptions.controller) {
  3556. ctrlLocals.$scope = modalScope;
  3557. ctrlLocals.$uibModalInstance = modalInstance;
  3558. Object.defineProperty(ctrlLocals, '$modalInstance', {
  3559. get: function() {
  3560. if (!$modalSuppressWarning) {
  3561. $log.warn('$modalInstance is now deprecated. Use $uibModalInstance instead.');
  3562. }
  3563. return modalInstance;
  3564. }
  3565. });
  3566. angular.forEach(modalOptions.resolve, function(value, key) {
  3567. ctrlLocals[key] = tplAndVars[resolveIter++];
  3568. });
  3569. ctrlInstance = $controller(modalOptions.controller, ctrlLocals);
  3570. if (modalOptions.controllerAs) {
  3571. if (modalOptions.bindToController) {
  3572. angular.extend(ctrlInstance, modalScope);
  3573. }
  3574. modalScope[modalOptions.controllerAs] = ctrlInstance;
  3575. }
  3576. }
  3577. $modalStack.open(modalInstance, {
  3578. scope: modalScope,
  3579. deferred: modalResultDeferred,
  3580. renderDeferred: modalRenderDeferred,
  3581. content: tplAndVars[0],
  3582. animation: modalOptions.animation,
  3583. backdrop: modalOptions.backdrop,
  3584. keyboard: modalOptions.keyboard,
  3585. backdropClass: modalOptions.backdropClass,
  3586. windowTopClass: modalOptions.windowTopClass,
  3587. windowClass: modalOptions.windowClass,
  3588. windowTemplateUrl: modalOptions.windowTemplateUrl,
  3589. size: modalOptions.size,
  3590. openedClass: modalOptions.openedClass
  3591. });
  3592. modalOpenedDeferred.resolve(true);
  3593. }, function resolveError(reason) {
  3594. modalOpenedDeferred.reject(reason);
  3595. modalResultDeferred.reject(reason);
  3596. })
  3597. .finally(function() {
  3598. if (promiseChain === samePromise) {
  3599. promiseChain = null;
  3600. }
  3601. });
  3602. return modalInstance;
  3603. };
  3604. return $modal;
  3605. }
  3606. ]
  3607. };
  3608. return $modalProvider;
  3609. });
  3610. /* deprecated modal below */
  3611. angular.module('ui.bootstrap.modal')
  3612. .value('$modalSuppressWarning', false)
  3613. /**
  3614. * A helper directive for the $modal service. It creates a backdrop element.
  3615. */
  3616. .directive('modalBackdrop', [
  3617. '$animate', '$injector', '$modalStack', '$log', '$modalSuppressWarning',
  3618. function($animate , $injector, $modalStack, $log, $modalSuppressWarning) {
  3619. var $animateCss = null;
  3620. if ($injector.has('$animateCss')) {
  3621. $animateCss = $injector.get('$animateCss');
  3622. }
  3623. return {
  3624. replace: true,
  3625. templateUrl: 'template/modal/backdrop.html',
  3626. compile: function(tElement, tAttrs) {
  3627. tElement.addClass(tAttrs.backdropClass);
  3628. return linkFn;
  3629. }
  3630. };
  3631. function linkFn(scope, element, attrs) {
  3632. if (!$modalSuppressWarning) {
  3633. $log.warn('modal-backdrop is now deprecated. Use uib-modal-backdrop instead.');
  3634. }
  3635. element.addClass('modal-backdrop');
  3636. if (attrs.modalInClass) {
  3637. if ($animateCss) {
  3638. $animateCss(element, {
  3639. addClass: attrs.modalInClass
  3640. }).start();
  3641. } else {
  3642. $animate.addClass(element, attrs.modalInClass);
  3643. }
  3644. scope.$on($modalStack.NOW_CLOSING_EVENT, function(e, setIsAsync) {
  3645. var done = setIsAsync();
  3646. if ($animateCss) {
  3647. $animateCss(element, {
  3648. removeClass: attrs.modalInClass
  3649. }).start().then(done);
  3650. } else {
  3651. $animate.removeClass(element, attrs.modalInClass).then(done);
  3652. }
  3653. });
  3654. }
  3655. }
  3656. }])
  3657. .directive('modalWindow', [
  3658. '$modalStack', '$q', '$animate', '$injector', '$log', '$modalSuppressWarning',
  3659. function($modalStack , $q , $animate, $injector, $log, $modalSuppressWarning) {
  3660. var $animateCss = null;
  3661. if ($injector.has('$animateCss')) {
  3662. $animateCss = $injector.get('$animateCss');
  3663. }
  3664. return {
  3665. scope: {
  3666. index: '@'
  3667. },
  3668. replace: true,
  3669. transclude: true,
  3670. templateUrl: function(tElement, tAttrs) {
  3671. return tAttrs.templateUrl || 'template/modal/window.html';
  3672. },
  3673. link: function(scope, element, attrs) {
  3674. if (!$modalSuppressWarning) {
  3675. $log.warn('modal-window is now deprecated. Use uib-modal-window instead.');
  3676. }
  3677. element.addClass(attrs.windowClass || '');
  3678. element.addClass(attrs.windowTopClass || '');
  3679. scope.size = attrs.size;
  3680. scope.close = function(evt) {
  3681. var modal = $modalStack.getTop();
  3682. if (modal && modal.value.backdrop && modal.value.backdrop !== 'static' && (evt.target === evt.currentTarget)) {
  3683. evt.preventDefault();
  3684. evt.stopPropagation();
  3685. $modalStack.dismiss(modal.key, 'backdrop click');
  3686. }
  3687. };
  3688. // moved from template to fix issue #2280
  3689. element.on('click', scope.close);
  3690. // This property is only added to the scope for the purpose of detecting when this directive is rendered.
  3691. // We can detect that by using this property in the template associated with this directive and then use
  3692. // {@link Attribute#$observe} on it. For more details please see {@link TableColumnResize}.
  3693. scope.$isRendered = true;
  3694. // Deferred object that will be resolved when this modal is render.
  3695. var modalRenderDeferObj = $q.defer();
  3696. // Observe function will be called on next digest cycle after compilation, ensuring that the DOM is ready.
  3697. // In order to use this way of finding whether DOM is ready, we need to observe a scope property used in modal's template.
  3698. attrs.$observe('modalRender', function(value) {
  3699. if (value == 'true') {
  3700. modalRenderDeferObj.resolve();
  3701. }
  3702. });
  3703. modalRenderDeferObj.promise.then(function() {
  3704. var animationPromise = null;
  3705. if (attrs.modalInClass) {
  3706. if ($animateCss) {
  3707. animationPromise = $animateCss(element, {
  3708. addClass: attrs.modalInClass
  3709. }).start();
  3710. } else {
  3711. animationPromise = $animate.addClass(element, attrs.modalInClass);
  3712. }
  3713. scope.$on($modalStack.NOW_CLOSING_EVENT, function(e, setIsAsync) {
  3714. var done = setIsAsync();
  3715. if ($animateCss) {
  3716. $animateCss(element, {
  3717. removeClass: attrs.modalInClass
  3718. }).start().then(done);
  3719. } else {
  3720. $animate.removeClass(element, attrs.modalInClass).then(done);
  3721. }
  3722. });
  3723. }
  3724. $q.when(animationPromise).then(function() {
  3725. var inputWithAutofocus = element[0].querySelector('[autofocus]');
  3726. /**
  3727. * Auto-focusing of a freshly-opened modal element causes any child elements
  3728. * with the autofocus attribute to lose focus. This is an issue on touch
  3729. * based devices which will show and then hide the onscreen keyboard.
  3730. * Attempts to refocus the autofocus element via JavaScript will not reopen
  3731. * the onscreen keyboard. Fixed by updated the focusing logic to only autofocus
  3732. * the modal element if the modal does not contain an autofocus element.
  3733. */
  3734. if (inputWithAutofocus) {
  3735. inputWithAutofocus.focus();
  3736. } else {
  3737. element[0].focus();
  3738. }
  3739. });
  3740. // Notify {@link $modalStack} that modal is rendered.
  3741. var modal = $modalStack.getTop();
  3742. if (modal) {
  3743. $modalStack.modalRendered(modal.key);
  3744. }
  3745. });
  3746. }
  3747. };
  3748. }])
  3749. .directive('modalAnimationClass', [
  3750. '$log', '$modalSuppressWarning',
  3751. function ($log, $modalSuppressWarning) {
  3752. return {
  3753. compile: function(tElement, tAttrs) {
  3754. if (!$modalSuppressWarning) {
  3755. $log.warn('modal-animation-class is now deprecated. Use uib-modal-animation-class instead.');
  3756. }
  3757. if (tAttrs.modalAnimation) {
  3758. tElement.addClass(tAttrs.modalAnimationClass);
  3759. }
  3760. }
  3761. };
  3762. }])
  3763. .directive('modalTransclude', [
  3764. '$log', '$modalSuppressWarning',
  3765. function ($log, $modalSuppressWarning) {
  3766. return {
  3767. link: function($scope, $element, $attrs, controller, $transclude) {
  3768. if (!$modalSuppressWarning) {
  3769. $log.warn('modal-transclude is now deprecated. Use uib-modal-transclude instead.');
  3770. }
  3771. $transclude($scope.$parent, function(clone) {
  3772. $element.empty();
  3773. $element.append(clone);
  3774. });
  3775. }
  3776. };
  3777. }])
  3778. .service('$modalStack', [
  3779. '$animate', '$timeout', '$document', '$compile', '$rootScope',
  3780. '$q',
  3781. '$injector',
  3782. '$$multiMap',
  3783. '$$stackedMap',
  3784. '$uibModalStack',
  3785. '$log',
  3786. '$modalSuppressWarning',
  3787. function($animate , $timeout , $document , $compile , $rootScope ,
  3788. $q,
  3789. $injector,
  3790. $$multiMap,
  3791. $$stackedMap,
  3792. $uibModalStack,
  3793. $log,
  3794. $modalSuppressWarning) {
  3795. if (!$modalSuppressWarning) {
  3796. $log.warn('$modalStack is now deprecated. Use $uibModalStack instead.');
  3797. }
  3798. angular.extend(this, $uibModalStack);
  3799. }])
  3800. .provider('$modal', ['$uibModalProvider', function($uibModalProvider) {
  3801. angular.extend(this, $uibModalProvider);
  3802. this.$get = ['$injector', '$log', '$modalSuppressWarning',
  3803. function ($injector, $log, $modalSuppressWarning) {
  3804. if (!$modalSuppressWarning) {
  3805. $log.warn('$modal is now deprecated. Use $uibModal instead.');
  3806. }
  3807. return $injector.invoke($uibModalProvider.$get);
  3808. }];
  3809. }]);
  3810. angular.module('ui.bootstrap.pagination', [])
  3811. .controller('UibPaginationController', ['$scope', '$attrs', '$parse', function($scope, $attrs, $parse) {
  3812. var self = this,
  3813. ngModelCtrl = { $setViewValue: angular.noop }, // nullModelCtrl
  3814. setNumPages = $attrs.numPages ? $parse($attrs.numPages).assign : angular.noop;
  3815. this.init = function(ngModelCtrl_, config) {
  3816. ngModelCtrl = ngModelCtrl_;
  3817. this.config = config;
  3818. ngModelCtrl.$render = function() {
  3819. self.render();
  3820. };
  3821. if ($attrs.itemsPerPage) {
  3822. $scope.$parent.$watch($parse($attrs.itemsPerPage), function(value) {
  3823. self.itemsPerPage = parseInt(value, 10);
  3824. $scope.totalPages = self.calculateTotalPages();
  3825. });
  3826. } else {
  3827. this.itemsPerPage = config.itemsPerPage;
  3828. }
  3829. $scope.$watch('totalItems', function() {
  3830. $scope.totalPages = self.calculateTotalPages();
  3831. });
  3832. $scope.$watch('totalPages', function(value) {
  3833. setNumPages($scope.$parent, value); // Readonly variable
  3834. if ( $scope.page > value ) {
  3835. $scope.selectPage(value);
  3836. } else {
  3837. ngModelCtrl.$render();
  3838. }
  3839. });
  3840. };
  3841. this.calculateTotalPages = function() {
  3842. var totalPages = this.itemsPerPage < 1 ? 1 : Math.ceil($scope.totalItems / this.itemsPerPage);
  3843. return Math.max(totalPages || 0, 1);
  3844. };
  3845. this.render = function() {
  3846. $scope.page = parseInt(ngModelCtrl.$viewValue, 10) || 1;
  3847. };
  3848. $scope.selectPage = function(page, evt) {
  3849. if (evt) {
  3850. evt.preventDefault();
  3851. }
  3852. var clickAllowed = !$scope.ngDisabled || !evt;
  3853. if (clickAllowed && $scope.page !== page && page > 0 && page <= $scope.totalPages) {
  3854. if (evt && evt.target) {
  3855. evt.target.blur();
  3856. }
  3857. ngModelCtrl.$setViewValue(page);
  3858. ngModelCtrl.$render();
  3859. }
  3860. };
  3861. $scope.getText = function(key) {
  3862. return $scope[key + 'Text'] || self.config[key + 'Text'];
  3863. };
  3864. $scope.noPrevious = function() {
  3865. return $scope.page === 1;
  3866. };
  3867. $scope.noNext = function() {
  3868. return $scope.page === $scope.totalPages;
  3869. };
  3870. }])
  3871. .constant('uibPaginationConfig', {
  3872. itemsPerPage: 10,
  3873. boundaryLinks: false,
  3874. directionLinks: true,
  3875. firstText: 'First',
  3876. previousText: 'Previous',
  3877. nextText: 'Next',
  3878. lastText: 'Last',
  3879. rotate: true
  3880. })
  3881. .directive('uibPagination', ['$parse', 'uibPaginationConfig', function($parse, paginationConfig) {
  3882. return {
  3883. restrict: 'EA',
  3884. scope: {
  3885. totalItems: '=',
  3886. firstText: '@',
  3887. previousText: '@',
  3888. nextText: '@',
  3889. lastText: '@',
  3890. ngDisabled:'='
  3891. },
  3892. require: ['uibPagination', '?ngModel'],
  3893. controller: 'UibPaginationController',
  3894. controllerAs: 'pagination',
  3895. templateUrl: function(element, attrs) {
  3896. return attrs.templateUrl || 'template/pagination/pagination.html';
  3897. },
  3898. replace: true,
  3899. link: function(scope, element, attrs, ctrls) {
  3900. var paginationCtrl = ctrls[0], ngModelCtrl = ctrls[1];
  3901. if (!ngModelCtrl) {
  3902. return; // do nothing if no ng-model
  3903. }
  3904. // Setup configuration parameters
  3905. var maxSize = angular.isDefined(attrs.maxSize) ? scope.$parent.$eval(attrs.maxSize) : paginationConfig.maxSize,
  3906. rotate = angular.isDefined(attrs.rotate) ? scope.$parent.$eval(attrs.rotate) : paginationConfig.rotate;
  3907. scope.boundaryLinks = angular.isDefined(attrs.boundaryLinks) ? scope.$parent.$eval(attrs.boundaryLinks) : paginationConfig.boundaryLinks;
  3908. scope.directionLinks = angular.isDefined(attrs.directionLinks) ? scope.$parent.$eval(attrs.directionLinks) : paginationConfig.directionLinks;
  3909. paginationCtrl.init(ngModelCtrl, paginationConfig);
  3910. if (attrs.maxSize) {
  3911. scope.$parent.$watch($parse(attrs.maxSize), function(value) {
  3912. maxSize = parseInt(value, 10);
  3913. paginationCtrl.render();
  3914. });
  3915. }
  3916. // Create page object used in template
  3917. function makePage(number, text, isActive) {
  3918. return {
  3919. number: number,
  3920. text: text,
  3921. active: isActive
  3922. };
  3923. }
  3924. function getPages(currentPage, totalPages) {
  3925. var pages = [];
  3926. // Default page limits
  3927. var startPage = 1, endPage = totalPages;
  3928. var isMaxSized = angular.isDefined(maxSize) && maxSize < totalPages;
  3929. // recompute if maxSize
  3930. if (isMaxSized) {
  3931. if (rotate) {
  3932. // Current page is displayed in the middle of the visible ones
  3933. startPage = Math.max(currentPage - Math.floor(maxSize/2), 1);
  3934. endPage = startPage + maxSize - 1;
  3935. // Adjust if limit is exceeded
  3936. if (endPage > totalPages) {
  3937. endPage = totalPages;
  3938. startPage = endPage - maxSize + 1;
  3939. }
  3940. } else {
  3941. // Visible pages are paginated with maxSize
  3942. startPage = ((Math.ceil(currentPage / maxSize) - 1) * maxSize) + 1;
  3943. // Adjust last page if limit is exceeded
  3944. endPage = Math.min(startPage + maxSize - 1, totalPages);
  3945. }
  3946. }
  3947. // Add page number links
  3948. for (var number = startPage; number <= endPage; number++) {
  3949. var page = makePage(number, number, number === currentPage);
  3950. pages.push(page);
  3951. }
  3952. // Add links to move between page sets
  3953. if (isMaxSized && ! rotate) {
  3954. if (startPage > 1) {
  3955. var previousPageSet = makePage(startPage - 1, '...', false);
  3956. pages.unshift(previousPageSet);
  3957. }
  3958. if (endPage < totalPages) {
  3959. var nextPageSet = makePage(endPage + 1, '...', false);
  3960. pages.push(nextPageSet);
  3961. }
  3962. }
  3963. return pages;
  3964. }
  3965. var originalRender = paginationCtrl.render;
  3966. paginationCtrl.render = function() {
  3967. originalRender();
  3968. if (scope.page > 0 && scope.page <= scope.totalPages) {
  3969. scope.pages = getPages(scope.page, scope.totalPages);
  3970. }
  3971. };
  3972. }
  3973. };
  3974. }])
  3975. .constant('uibPagerConfig', {
  3976. itemsPerPage: 10,
  3977. previousText: '« Previous',
  3978. nextText: 'Next »',
  3979. align: true
  3980. })
  3981. .directive('uibPager', ['uibPagerConfig', function(pagerConfig) {
  3982. return {
  3983. restrict: 'EA',
  3984. scope: {
  3985. totalItems: '=',
  3986. previousText: '@',
  3987. nextText: '@',
  3988. ngDisabled: '='
  3989. },
  3990. require: ['uibPager', '?ngModel'],
  3991. controller: 'UibPaginationController',
  3992. controllerAs: 'pagination',
  3993. templateUrl: function(element, attrs) {
  3994. return attrs.templateUrl || 'template/pagination/pager.html';
  3995. },
  3996. replace: true,
  3997. link: function(scope, element, attrs, ctrls) {
  3998. var paginationCtrl = ctrls[0], ngModelCtrl = ctrls[1];
  3999. if (!ngModelCtrl) {
  4000. return; // do nothing if no ng-model
  4001. }
  4002. scope.align = angular.isDefined(attrs.align) ? scope.$parent.$eval(attrs.align) : pagerConfig.align;
  4003. paginationCtrl.init(ngModelCtrl, pagerConfig);
  4004. }
  4005. };
  4006. }]);
  4007. /* Deprecated Pagination Below */
  4008. angular.module('ui.bootstrap.pagination')
  4009. .value('$paginationSuppressWarning', false)
  4010. .controller('PaginationController', ['$scope', '$attrs', '$parse', '$log', '$paginationSuppressWarning', function($scope, $attrs, $parse, $log, $paginationSuppressWarning) {
  4011. if (!$paginationSuppressWarning) {
  4012. $log.warn('PaginationController is now deprecated. Use UibPaginationController instead.');
  4013. }
  4014. var self = this,
  4015. ngModelCtrl = { $setViewValue: angular.noop }, // nullModelCtrl
  4016. setNumPages = $attrs.numPages ? $parse($attrs.numPages).assign : angular.noop;
  4017. this.init = function(ngModelCtrl_, config) {
  4018. ngModelCtrl = ngModelCtrl_;
  4019. this.config = config;
  4020. ngModelCtrl.$render = function() {
  4021. self.render();
  4022. };
  4023. if ($attrs.itemsPerPage) {
  4024. $scope.$parent.$watch($parse($attrs.itemsPerPage), function(value) {
  4025. self.itemsPerPage = parseInt(value, 10);
  4026. $scope.totalPages = self.calculateTotalPages();
  4027. });
  4028. } else {
  4029. this.itemsPerPage = config.itemsPerPage;
  4030. }
  4031. $scope.$watch('totalItems', function() {
  4032. $scope.totalPages = self.calculateTotalPages();
  4033. });
  4034. $scope.$watch('totalPages', function(value) {
  4035. setNumPages($scope.$parent, value); // Readonly variable
  4036. if ( $scope.page > value ) {
  4037. $scope.selectPage(value);
  4038. } else {
  4039. ngModelCtrl.$render();
  4040. }
  4041. });
  4042. };
  4043. this.calculateTotalPages = function() {
  4044. var totalPages = this.itemsPerPage < 1 ? 1 : Math.ceil($scope.totalItems / this.itemsPerPage);
  4045. return Math.max(totalPages || 0, 1);
  4046. };
  4047. this.render = function() {
  4048. $scope.page = parseInt(ngModelCtrl.$viewValue, 10) || 1;
  4049. };
  4050. $scope.selectPage = function(page, evt) {
  4051. if (evt) {
  4052. evt.preventDefault();
  4053. }
  4054. var clickAllowed = !$scope.ngDisabled || !evt;
  4055. if (clickAllowed && $scope.page !== page && page > 0 && page <= $scope.totalPages) {
  4056. if (evt && evt.target) {
  4057. evt.target.blur();
  4058. }
  4059. ngModelCtrl.$setViewValue(page);
  4060. ngModelCtrl.$render();
  4061. }
  4062. };
  4063. $scope.getText = function(key) {
  4064. return $scope[key + 'Text'] || self.config[key + 'Text'];
  4065. };
  4066. $scope.noPrevious = function() {
  4067. return $scope.page === 1;
  4068. };
  4069. $scope.noNext = function() {
  4070. return $scope.page === $scope.totalPages;
  4071. };
  4072. }])
  4073. .directive('pagination', ['$parse', 'uibPaginationConfig', '$log', '$paginationSuppressWarning', function($parse, paginationConfig, $log, $paginationSuppressWarning) {
  4074. return {
  4075. restrict: 'EA',
  4076. scope: {
  4077. totalItems: '=',
  4078. firstText: '@',
  4079. previousText: '@',
  4080. nextText: '@',
  4081. lastText: '@',
  4082. ngDisabled:'='
  4083. },
  4084. require: ['pagination', '?ngModel'],
  4085. controller: 'PaginationController',
  4086. controllerAs: 'pagination',
  4087. templateUrl: function(element, attrs) {
  4088. return attrs.templateUrl || 'template/pagination/pagination.html';
  4089. },
  4090. replace: true,
  4091. link: function(scope, element, attrs, ctrls) {
  4092. if (!$paginationSuppressWarning) {
  4093. $log.warn('pagination is now deprecated. Use uib-pagination instead.');
  4094. }
  4095. var paginationCtrl = ctrls[0], ngModelCtrl = ctrls[1];
  4096. if (!ngModelCtrl) {
  4097. return; // do nothing if no ng-model
  4098. }
  4099. // Setup configuration parameters
  4100. var maxSize = angular.isDefined(attrs.maxSize) ? scope.$parent.$eval(attrs.maxSize) : paginationConfig.maxSize,
  4101. rotate = angular.isDefined(attrs.rotate) ? scope.$parent.$eval(attrs.rotate) : paginationConfig.rotate;
  4102. scope.boundaryLinks = angular.isDefined(attrs.boundaryLinks) ? scope.$parent.$eval(attrs.boundaryLinks) : paginationConfig.boundaryLinks;
  4103. scope.directionLinks = angular.isDefined(attrs.directionLinks) ? scope.$parent.$eval(attrs.directionLinks) : paginationConfig.directionLinks;
  4104. paginationCtrl.init(ngModelCtrl, paginationConfig);
  4105. if (attrs.maxSize) {
  4106. scope.$parent.$watch($parse(attrs.maxSize), function(value) {
  4107. maxSize = parseInt(value, 10);
  4108. paginationCtrl.render();
  4109. });
  4110. }
  4111. // Create page object used in template
  4112. function makePage(number, text, isActive) {
  4113. return {
  4114. number: number,
  4115. text: text,
  4116. active: isActive
  4117. };
  4118. }
  4119. function getPages(currentPage, totalPages) {
  4120. var pages = [];
  4121. // Default page limits
  4122. var startPage = 1, endPage = totalPages;
  4123. var isMaxSized = angular.isDefined(maxSize) && maxSize < totalPages;
  4124. // recompute if maxSize
  4125. if (isMaxSized) {
  4126. if (rotate) {
  4127. // Current page is displayed in the middle of the visible ones
  4128. startPage = Math.max(currentPage - Math.floor(maxSize/2), 1);
  4129. endPage = startPage + maxSize - 1;
  4130. // Adjust if limit is exceeded
  4131. if (endPage > totalPages) {
  4132. endPage = totalPages;
  4133. startPage = endPage - maxSize + 1;
  4134. }
  4135. } else {
  4136. // Visible pages are paginated with maxSize
  4137. startPage = ((Math.ceil(currentPage / maxSize) - 1) * maxSize) + 1;
  4138. // Adjust last page if limit is exceeded
  4139. endPage = Math.min(startPage + maxSize - 1, totalPages);
  4140. }
  4141. }
  4142. // Add page number links
  4143. for (var number = startPage; number <= endPage; number++) {
  4144. var page = makePage(number, number, number === currentPage);
  4145. pages.push(page);
  4146. }
  4147. // Add links to move between page sets
  4148. if (isMaxSized && ! rotate) {
  4149. if (startPage > 1) {
  4150. var previousPageSet = makePage(startPage - 1, '...', false);
  4151. pages.unshift(previousPageSet);
  4152. }
  4153. if (endPage < totalPages) {
  4154. var nextPageSet = makePage(endPage + 1, '...', false);
  4155. pages.push(nextPageSet);
  4156. }
  4157. }
  4158. return pages;
  4159. }
  4160. var originalRender = paginationCtrl.render;
  4161. paginationCtrl.render = function() {
  4162. originalRender();
  4163. if (scope.page > 0 && scope.page <= scope.totalPages) {
  4164. scope.pages = getPages(scope.page, scope.totalPages);
  4165. }
  4166. };
  4167. }
  4168. };
  4169. }])
  4170. .directive('pager', ['uibPagerConfig', '$log', '$paginationSuppressWarning', function(pagerConfig, $log, $paginationSuppressWarning) {
  4171. return {
  4172. restrict: 'EA',
  4173. scope: {
  4174. totalItems: '=',
  4175. previousText: '@',
  4176. nextText: '@',
  4177. ngDisabled: '='
  4178. },
  4179. require: ['pager', '?ngModel'],
  4180. controller: 'PaginationController',
  4181. controllerAs: 'pagination',
  4182. templateUrl: function(element, attrs) {
  4183. return attrs.templateUrl || 'template/pagination/pager.html';
  4184. },
  4185. replace: true,
  4186. link: function(scope, element, attrs, ctrls) {
  4187. if (!$paginationSuppressWarning) {
  4188. $log.warn('pager is now deprecated. Use uib-pager instead.');
  4189. }
  4190. var paginationCtrl = ctrls[0], ngModelCtrl = ctrls[1];
  4191. if (!ngModelCtrl) {
  4192. return; // do nothing if no ng-model
  4193. }
  4194. scope.align = angular.isDefined(attrs.align) ? scope.$parent.$eval(attrs.align) : pagerConfig.align;
  4195. paginationCtrl.init(ngModelCtrl, pagerConfig);
  4196. }
  4197. };
  4198. }]);
  4199. /**
  4200. * The following features are still outstanding: animation as a
  4201. * function, placement as a function, inside, support for more triggers than
  4202. * just mouse enter/leave, html tooltips, and selector delegation.
  4203. */
  4204. angular.module('ui.bootstrap.tooltip', ['ui.bootstrap.position', 'ui.bootstrap.stackedMap'])
  4205. /**
  4206. * The $tooltip service creates tooltip- and popover-like directives as well as
  4207. * houses global options for them.
  4208. */
  4209. .provider('$uibTooltip', function() {
  4210. // The default options tooltip and popover.
  4211. var defaultOptions = {
  4212. placement: 'top',
  4213. animation: true,
  4214. popupDelay: 0,
  4215. popupCloseDelay: 0,
  4216. useContentExp: false
  4217. };
  4218. // Default hide triggers for each show trigger
  4219. var triggerMap = {
  4220. 'mouseenter': 'mouseleave',
  4221. 'click': 'click',
  4222. 'focus': 'blur',
  4223. 'none': ''
  4224. };
  4225. // The options specified to the provider globally.
  4226. var globalOptions = {};
  4227. /**
  4228. * `options({})` allows global configuration of all tooltips in the
  4229. * application.
  4230. *
  4231. * var app = angular.module( 'App', ['ui.bootstrap.tooltip'], function( $tooltipProvider ) {
  4232. * // place tooltips left instead of top by default
  4233. * $tooltipProvider.options( { placement: 'left' } );
  4234. * });
  4235. */
  4236. this.options = function(value) {
  4237. angular.extend(globalOptions, value);
  4238. };
  4239. /**
  4240. * This allows you to extend the set of trigger mappings available. E.g.:
  4241. *
  4242. * $tooltipProvider.setTriggers( 'openTrigger': 'closeTrigger' );
  4243. */
  4244. this.setTriggers = function setTriggers(triggers) {
  4245. angular.extend(triggerMap, triggers);
  4246. };
  4247. /**
  4248. * This is a helper function for translating camel-case to snake-case.
  4249. */
  4250. function snake_case(name) {
  4251. var regexp = /[A-Z]/g;
  4252. var separator = '-';
  4253. return name.replace(regexp, function(letter, pos) {
  4254. return (pos ? separator : '') + letter.toLowerCase();
  4255. });
  4256. }
  4257. /**
  4258. * Returns the actual instance of the $tooltip service.
  4259. * TODO support multiple triggers
  4260. */
  4261. this.$get = ['$window', '$compile', '$timeout', '$document', '$uibPosition', '$interpolate', '$rootScope', '$parse', '$$stackedMap', function($window, $compile, $timeout, $document, $position, $interpolate, $rootScope, $parse, $$stackedMap) {
  4262. var openedTooltips = $$stackedMap.createNew();
  4263. $document.on('keypress', function(e) {
  4264. if (e.which === 27) {
  4265. var last = openedTooltips.top();
  4266. if (last) {
  4267. last.value.close();
  4268. openedTooltips.removeTop();
  4269. last = null;
  4270. }
  4271. }
  4272. });
  4273. return function $tooltip(ttType, prefix, defaultTriggerShow, options) {
  4274. options = angular.extend({}, defaultOptions, globalOptions, options);
  4275. /**
  4276. * Returns an object of show and hide triggers.
  4277. *
  4278. * If a trigger is supplied,
  4279. * it is used to show the tooltip; otherwise, it will use the `trigger`
  4280. * option passed to the `$tooltipProvider.options` method; else it will
  4281. * default to the trigger supplied to this directive factory.
  4282. *
  4283. * The hide trigger is based on the show trigger. If the `trigger` option
  4284. * was passed to the `$tooltipProvider.options` method, it will use the
  4285. * mapped trigger from `triggerMap` or the passed trigger if the map is
  4286. * undefined; otherwise, it uses the `triggerMap` value of the show
  4287. * trigger; else it will just use the show trigger.
  4288. */
  4289. function getTriggers(trigger) {
  4290. var show = (trigger || options.trigger || defaultTriggerShow).split(' ');
  4291. var hide = show.map(function(trigger) {
  4292. return triggerMap[trigger] || trigger;
  4293. });
  4294. return {
  4295. show: show,
  4296. hide: hide
  4297. };
  4298. }
  4299. var directiveName = snake_case(ttType);
  4300. var startSym = $interpolate.startSymbol();
  4301. var endSym = $interpolate.endSymbol();
  4302. var template =
  4303. '<div '+ directiveName + '-popup '+
  4304. 'title="' + startSym + 'title' + endSym + '" '+
  4305. (options.useContentExp ?
  4306. 'content-exp="contentExp()" ' :
  4307. 'content="' + startSym + 'content' + endSym + '" ') +
  4308. 'placement="' + startSym + 'placement' + endSym + '" '+
  4309. 'popup-class="' + startSym + 'popupClass' + endSym + '" '+
  4310. 'animation="animation" ' +
  4311. 'is-open="isOpen"' +
  4312. 'origin-scope="origScope" ' +
  4313. 'style="visibility: hidden; display: block; top: -9999px; left: -9999px;"' +
  4314. '>' +
  4315. '</div>';
  4316. return {
  4317. compile: function(tElem, tAttrs) {
  4318. var tooltipLinker = $compile(template);
  4319. return function link(scope, element, attrs, tooltipCtrl) {
  4320. var tooltip;
  4321. var tooltipLinkedScope;
  4322. var transitionTimeout;
  4323. var showTimeout;
  4324. var hideTimeout;
  4325. var positionTimeout;
  4326. var appendToBody = angular.isDefined(options.appendToBody) ? options.appendToBody : false;
  4327. var triggers = getTriggers(undefined);
  4328. var hasEnableExp = angular.isDefined(attrs[prefix + 'Enable']);
  4329. var ttScope = scope.$new(true);
  4330. var repositionScheduled = false;
  4331. var isOpenParse = angular.isDefined(attrs[prefix + 'IsOpen']) ? $parse(attrs[prefix + 'IsOpen']) : false;
  4332. var contentParse = options.useContentExp ? $parse(attrs[ttType]) : false;
  4333. var observers = [];
  4334. var positionTooltip = function() {
  4335. // check if tooltip exists and is not empty
  4336. if (!tooltip || !tooltip.html()) { return; }
  4337. if (!positionTimeout) {
  4338. positionTimeout = $timeout(function() {
  4339. // Reset the positioning.
  4340. tooltip.css({ top: 0, left: 0 });
  4341. // Now set the calculated positioning.
  4342. var ttCss = $position.positionElements(element, tooltip, ttScope.placement, appendToBody);
  4343. ttCss.top += 'px';
  4344. ttCss.left += 'px';
  4345. ttCss.visibility = 'visible';
  4346. tooltip.css(ttCss);
  4347. positionTimeout = null;
  4348. }, 0, false);
  4349. }
  4350. };
  4351. // Set up the correct scope to allow transclusion later
  4352. ttScope.origScope = scope;
  4353. // By default, the tooltip is not open.
  4354. // TODO add ability to start tooltip opened
  4355. ttScope.isOpen = false;
  4356. openedTooltips.add(ttScope, {
  4357. close: hide
  4358. });
  4359. function toggleTooltipBind() {
  4360. if (!ttScope.isOpen) {
  4361. showTooltipBind();
  4362. } else {
  4363. hideTooltipBind();
  4364. }
  4365. }
  4366. // Show the tooltip with delay if specified, otherwise show it immediately
  4367. function showTooltipBind() {
  4368. if (hasEnableExp && !scope.$eval(attrs[prefix + 'Enable'])) {
  4369. return;
  4370. }
  4371. cancelHide();
  4372. prepareTooltip();
  4373. if (ttScope.popupDelay) {
  4374. // Do nothing if the tooltip was already scheduled to pop-up.
  4375. // This happens if show is triggered multiple times before any hide is triggered.
  4376. if (!showTimeout) {
  4377. showTimeout = $timeout(show, ttScope.popupDelay, false);
  4378. }
  4379. } else {
  4380. show();
  4381. }
  4382. }
  4383. function hideTooltipBind() {
  4384. cancelShow();
  4385. if (ttScope.popupCloseDelay) {
  4386. if (!hideTimeout) {
  4387. hideTimeout = $timeout(hide, ttScope.popupCloseDelay, false);
  4388. }
  4389. } else {
  4390. hide();
  4391. }
  4392. }
  4393. // Show the tooltip popup element.
  4394. function show() {
  4395. cancelShow();
  4396. cancelHide();
  4397. // Don't show empty tooltips.
  4398. if (!ttScope.content) {
  4399. return angular.noop;
  4400. }
  4401. createTooltip();
  4402. // And show the tooltip.
  4403. ttScope.$evalAsync(function() {
  4404. ttScope.isOpen = true;
  4405. assignIsOpen(true);
  4406. positionTooltip();
  4407. });
  4408. }
  4409. function cancelShow() {
  4410. if (showTimeout) {
  4411. $timeout.cancel(showTimeout);
  4412. showTimeout = null;
  4413. }
  4414. if (positionTimeout) {
  4415. $timeout.cancel(positionTimeout);
  4416. positionTimeout = null;
  4417. }
  4418. }
  4419. // Hide the tooltip popup element.
  4420. function hide() {
  4421. cancelShow();
  4422. cancelHide();
  4423. if (!ttScope) {
  4424. return;
  4425. }
  4426. // First things first: we don't show it anymore.
  4427. ttScope.$evalAsync(function() {
  4428. ttScope.isOpen = false;
  4429. assignIsOpen(false);
  4430. // And now we remove it from the DOM. However, if we have animation, we
  4431. // need to wait for it to expire beforehand.
  4432. // FIXME: this is a placeholder for a port of the transitions library.
  4433. // The fade transition in TWBS is 150ms.
  4434. if (ttScope.animation) {
  4435. if (!transitionTimeout) {
  4436. transitionTimeout = $timeout(removeTooltip, 150, false);
  4437. }
  4438. } else {
  4439. removeTooltip();
  4440. }
  4441. });
  4442. }
  4443. function cancelHide() {
  4444. if (hideTimeout) {
  4445. $timeout.cancel(hideTimeout);
  4446. hideTimeout = null;
  4447. }
  4448. if (transitionTimeout) {
  4449. $timeout.cancel(transitionTimeout);
  4450. transitionTimeout = null;
  4451. }
  4452. }
  4453. function createTooltip() {
  4454. // There can only be one tooltip element per directive shown at once.
  4455. if (tooltip) {
  4456. return;
  4457. }
  4458. tooltipLinkedScope = ttScope.$new();
  4459. tooltip = tooltipLinker(tooltipLinkedScope, function(tooltip) {
  4460. if (appendToBody) {
  4461. $document.find('body').append(tooltip);
  4462. } else {
  4463. element.after(tooltip);
  4464. }
  4465. });
  4466. prepObservers();
  4467. }
  4468. function removeTooltip() {
  4469. unregisterObservers();
  4470. transitionTimeout = null;
  4471. if (tooltip) {
  4472. tooltip.remove();
  4473. tooltip = null;
  4474. }
  4475. if (tooltipLinkedScope) {
  4476. tooltipLinkedScope.$destroy();
  4477. tooltipLinkedScope = null;
  4478. }
  4479. }
  4480. /**
  4481. * Set the inital scope values. Once
  4482. * the tooltip is created, the observers
  4483. * will be added to keep things in synch.
  4484. */
  4485. function prepareTooltip() {
  4486. ttScope.title = attrs[prefix + 'Title'];
  4487. if (contentParse) {
  4488. ttScope.content = contentParse(scope);
  4489. } else {
  4490. ttScope.content = attrs[ttType];
  4491. }
  4492. ttScope.popupClass = attrs[prefix + 'Class'];
  4493. ttScope.placement = angular.isDefined(attrs[prefix + 'Placement']) ? attrs[prefix + 'Placement'] : options.placement;
  4494. var delay = parseInt(attrs[prefix + 'PopupDelay'], 10);
  4495. var closeDelay = parseInt(attrs[prefix + 'PopupCloseDelay'], 10);
  4496. ttScope.popupDelay = !isNaN(delay) ? delay : options.popupDelay;
  4497. ttScope.popupCloseDelay = !isNaN(closeDelay) ? closeDelay : options.popupCloseDelay;
  4498. }
  4499. function assignIsOpen(isOpen) {
  4500. if (isOpenParse && angular.isFunction(isOpenParse.assign)) {
  4501. isOpenParse.assign(scope, isOpen);
  4502. }
  4503. }
  4504. ttScope.contentExp = function() {
  4505. return ttScope.content;
  4506. };
  4507. /**
  4508. * Observe the relevant attributes.
  4509. */
  4510. attrs.$observe('disabled', function(val) {
  4511. if (val) {
  4512. cancelShow();
  4513. }
  4514. if (val && ttScope.isOpen) {
  4515. hide();
  4516. }
  4517. });
  4518. if (isOpenParse) {
  4519. scope.$watch(isOpenParse, function(val) {
  4520. /*jshint -W018 */
  4521. if (ttScope && !val === ttScope.isOpen) {
  4522. toggleTooltipBind();
  4523. }
  4524. /*jshint +W018 */
  4525. });
  4526. }
  4527. function prepObservers() {
  4528. observers.length = 0;
  4529. if (contentParse) {
  4530. observers.push(
  4531. scope.$watch(contentParse, function(val) {
  4532. ttScope.content = val;
  4533. if (!val && ttScope.isOpen) {
  4534. hide();
  4535. }
  4536. })
  4537. );
  4538. observers.push(
  4539. tooltipLinkedScope.$watch(function() {
  4540. if (!repositionScheduled) {
  4541. repositionScheduled = true;
  4542. tooltipLinkedScope.$$postDigest(function() {
  4543. repositionScheduled = false;
  4544. if (ttScope && ttScope.isOpen) {
  4545. positionTooltip();
  4546. }
  4547. });
  4548. }
  4549. })
  4550. );
  4551. } else {
  4552. observers.push(
  4553. attrs.$observe(ttType, function(val) {
  4554. ttScope.content = val;
  4555. if (!val && ttScope.isOpen) {
  4556. hide();
  4557. } else {
  4558. positionTooltip();
  4559. }
  4560. })
  4561. );
  4562. }
  4563. observers.push(
  4564. attrs.$observe(prefix + 'Title', function(val) {
  4565. ttScope.title = val;
  4566. if (ttScope.isOpen) {
  4567. positionTooltip();
  4568. }
  4569. })
  4570. );
  4571. observers.push(
  4572. attrs.$observe(prefix + 'Placement', function(val) {
  4573. ttScope.placement = val ? val : options.placement;
  4574. if (ttScope.isOpen) {
  4575. positionTooltip();
  4576. }
  4577. })
  4578. );
  4579. }
  4580. function unregisterObservers() {
  4581. if (observers.length) {
  4582. angular.forEach(observers, function(observer) {
  4583. observer();
  4584. });
  4585. observers.length = 0;
  4586. }
  4587. }
  4588. var unregisterTriggers = function() {
  4589. triggers.show.forEach(function(trigger) {
  4590. element.unbind(trigger, showTooltipBind);
  4591. });
  4592. triggers.hide.forEach(function(trigger) {
  4593. trigger.split(' ').forEach(function(hideTrigger) {
  4594. element[0].removeEventListener(hideTrigger, hideTooltipBind);
  4595. });
  4596. });
  4597. };
  4598. function prepTriggers() {
  4599. var val = attrs[prefix + 'Trigger'];
  4600. unregisterTriggers();
  4601. triggers = getTriggers(val);
  4602. if (triggers.show !== 'none') {
  4603. triggers.show.forEach(function(trigger, idx) {
  4604. // Using raw addEventListener due to jqLite/jQuery bug - #4060
  4605. if (trigger === triggers.hide[idx]) {
  4606. element[0].addEventListener(trigger, toggleTooltipBind);
  4607. } else if (trigger) {
  4608. element[0].addEventListener(trigger, showTooltipBind);
  4609. triggers.hide[idx].split(' ').forEach(function(trigger) {
  4610. element[0].addEventListener(trigger, hideTooltipBind);
  4611. });
  4612. }
  4613. element.on('keypress', function(e) {
  4614. if (e.which === 27) {
  4615. hideTooltipBind();
  4616. }
  4617. });
  4618. });
  4619. }
  4620. }
  4621. prepTriggers();
  4622. var animation = scope.$eval(attrs[prefix + 'Animation']);
  4623. ttScope.animation = angular.isDefined(animation) ? !!animation : options.animation;
  4624. var appendToBodyVal = scope.$eval(attrs[prefix + 'AppendToBody']);
  4625. appendToBody = angular.isDefined(appendToBodyVal) ? appendToBodyVal : appendToBody;
  4626. // if a tooltip is attached to <body> we need to remove it on
  4627. // location change as its parent scope will probably not be destroyed
  4628. // by the change.
  4629. if (appendToBody) {
  4630. scope.$on('$locationChangeSuccess', function closeTooltipOnLocationChangeSuccess() {
  4631. if (ttScope.isOpen) {
  4632. hide();
  4633. }
  4634. });
  4635. }
  4636. // Make sure tooltip is destroyed and removed.
  4637. scope.$on('$destroy', function onDestroyTooltip() {
  4638. cancelShow();
  4639. cancelHide();
  4640. unregisterTriggers();
  4641. removeTooltip();
  4642. openedTooltips.remove(ttScope);
  4643. ttScope = null;
  4644. });
  4645. };
  4646. }
  4647. };
  4648. };
  4649. }];
  4650. })
  4651. // This is mostly ngInclude code but with a custom scope
  4652. .directive('uibTooltipTemplateTransclude', [
  4653. '$animate', '$sce', '$compile', '$templateRequest',
  4654. function ($animate , $sce , $compile , $templateRequest) {
  4655. return {
  4656. link: function(scope, elem, attrs) {
  4657. var origScope = scope.$eval(attrs.tooltipTemplateTranscludeScope);
  4658. var changeCounter = 0,
  4659. currentScope,
  4660. previousElement,
  4661. currentElement;
  4662. var cleanupLastIncludeContent = function() {
  4663. if (previousElement) {
  4664. previousElement.remove();
  4665. previousElement = null;
  4666. }
  4667. if (currentScope) {
  4668. currentScope.$destroy();
  4669. currentScope = null;
  4670. }
  4671. if (currentElement) {
  4672. $animate.leave(currentElement).then(function() {
  4673. previousElement = null;
  4674. });
  4675. previousElement = currentElement;
  4676. currentElement = null;
  4677. }
  4678. };
  4679. scope.$watch($sce.parseAsResourceUrl(attrs.uibTooltipTemplateTransclude), function(src) {
  4680. var thisChangeId = ++changeCounter;
  4681. if (src) {
  4682. //set the 2nd param to true to ignore the template request error so that the inner
  4683. //contents and scope can be cleaned up.
  4684. $templateRequest(src, true).then(function(response) {
  4685. if (thisChangeId !== changeCounter) { return; }
  4686. var newScope = origScope.$new();
  4687. var template = response;
  4688. var clone = $compile(template)(newScope, function(clone) {
  4689. cleanupLastIncludeContent();
  4690. $animate.enter(clone, elem);
  4691. });
  4692. currentScope = newScope;
  4693. currentElement = clone;
  4694. currentScope.$emit('$includeContentLoaded', src);
  4695. }, function() {
  4696. if (thisChangeId === changeCounter) {
  4697. cleanupLastIncludeContent();
  4698. scope.$emit('$includeContentError', src);
  4699. }
  4700. });
  4701. scope.$emit('$includeContentRequested', src);
  4702. } else {
  4703. cleanupLastIncludeContent();
  4704. }
  4705. });
  4706. scope.$on('$destroy', cleanupLastIncludeContent);
  4707. }
  4708. };
  4709. }])
  4710. /**
  4711. * Note that it's intentional that these classes are *not* applied through $animate.
  4712. * They must not be animated as they're expected to be present on the tooltip on
  4713. * initialization.
  4714. */
  4715. .directive('uibTooltipClasses', function() {
  4716. return {
  4717. restrict: 'A',
  4718. link: function(scope, element, attrs) {
  4719. if (scope.placement) {
  4720. element.addClass(scope.placement);
  4721. }
  4722. if (scope.popupClass) {
  4723. element.addClass(scope.popupClass);
  4724. }
  4725. if (scope.animation()) {
  4726. element.addClass(attrs.tooltipAnimationClass);
  4727. }
  4728. }
  4729. };
  4730. })
  4731. .directive('uibTooltipPopup', function() {
  4732. return {
  4733. replace: true,
  4734. scope: { content: '@', placement: '@', popupClass: '@', animation: '&', isOpen: '&' },
  4735. templateUrl: 'template/tooltip/tooltip-popup.html',
  4736. link: function(scope, element) {
  4737. element.addClass('tooltip');
  4738. }
  4739. };
  4740. })
  4741. .directive('uibTooltip', [ '$uibTooltip', function($uibTooltip) {
  4742. return $uibTooltip('uibTooltip', 'tooltip', 'mouseenter');
  4743. }])
  4744. .directive('uibTooltipTemplatePopup', function() {
  4745. return {
  4746. replace: true,
  4747. scope: { contentExp: '&', placement: '@', popupClass: '@', animation: '&', isOpen: '&',
  4748. originScope: '&' },
  4749. templateUrl: 'template/tooltip/tooltip-template-popup.html',
  4750. link: function(scope, element) {
  4751. element.addClass('tooltip');
  4752. }
  4753. };
  4754. })
  4755. .directive('uibTooltipTemplate', ['$uibTooltip', function($uibTooltip) {
  4756. return $uibTooltip('uibTooltipTemplate', 'tooltip', 'mouseenter', {
  4757. useContentExp: true
  4758. });
  4759. }])
  4760. .directive('uibTooltipHtmlPopup', function() {
  4761. return {
  4762. replace: true,
  4763. scope: { contentExp: '&', placement: '@', popupClass: '@', animation: '&', isOpen: '&' },
  4764. templateUrl: 'template/tooltip/tooltip-html-popup.html',
  4765. link: function(scope, element) {
  4766. element.addClass('tooltip');
  4767. }
  4768. };
  4769. })
  4770. .directive('uibTooltipHtml', ['$uibTooltip', function($uibTooltip) {
  4771. return $uibTooltip('uibTooltipHtml', 'tooltip', 'mouseenter', {
  4772. useContentExp: true
  4773. });
  4774. }]);
  4775. /* Deprecated tooltip below */
  4776. angular.module('ui.bootstrap.tooltip')
  4777. .value('$tooltipSuppressWarning', false)
  4778. .provider('$tooltip', ['$uibTooltipProvider', function($uibTooltipProvider) {
  4779. angular.extend(this, $uibTooltipProvider);
  4780. this.$get = ['$log', '$tooltipSuppressWarning', '$injector', function($log, $tooltipSuppressWarning, $injector) {
  4781. if (!$tooltipSuppressWarning) {
  4782. $log.warn('$tooltip is now deprecated. Use $uibTooltip instead.');
  4783. }
  4784. return $injector.invoke($uibTooltipProvider.$get);
  4785. }];
  4786. }])
  4787. // This is mostly ngInclude code but with a custom scope
  4788. .directive('tooltipTemplateTransclude', [
  4789. '$animate', '$sce', '$compile', '$templateRequest', '$log', '$tooltipSuppressWarning',
  4790. function ($animate , $sce , $compile , $templateRequest, $log, $tooltipSuppressWarning) {
  4791. return {
  4792. link: function(scope, elem, attrs) {
  4793. if (!$tooltipSuppressWarning) {
  4794. $log.warn('tooltip-template-transclude is now deprecated. Use uib-tooltip-template-transclude instead.');
  4795. }
  4796. var origScope = scope.$eval(attrs.tooltipTemplateTranscludeScope);
  4797. var changeCounter = 0,
  4798. currentScope,
  4799. previousElement,
  4800. currentElement;
  4801. var cleanupLastIncludeContent = function() {
  4802. if (previousElement) {
  4803. previousElement.remove();
  4804. previousElement = null;
  4805. }
  4806. if (currentScope) {
  4807. currentScope.$destroy();
  4808. currentScope = null;
  4809. }
  4810. if (currentElement) {
  4811. $animate.leave(currentElement).then(function() {
  4812. previousElement = null;
  4813. });
  4814. previousElement = currentElement;
  4815. currentElement = null;
  4816. }
  4817. };
  4818. scope.$watch($sce.parseAsResourceUrl(attrs.tooltipTemplateTransclude), function(src) {
  4819. var thisChangeId = ++changeCounter;
  4820. if (src) {
  4821. //set the 2nd param to true to ignore the template request error so that the inner
  4822. //contents and scope can be cleaned up.
  4823. $templateRequest(src, true).then(function(response) {
  4824. if (thisChangeId !== changeCounter) { return; }
  4825. var newScope = origScope.$new();
  4826. var template = response;
  4827. var clone = $compile(template)(newScope, function(clone) {
  4828. cleanupLastIncludeContent();
  4829. $animate.enter(clone, elem);
  4830. });
  4831. currentScope = newScope;
  4832. currentElement = clone;
  4833. currentScope.$emit('$includeContentLoaded', src);
  4834. }, function() {
  4835. if (thisChangeId === changeCounter) {
  4836. cleanupLastIncludeContent();
  4837. scope.$emit('$includeContentError', src);
  4838. }
  4839. });
  4840. scope.$emit('$includeContentRequested', src);
  4841. } else {
  4842. cleanupLastIncludeContent();
  4843. }
  4844. });
  4845. scope.$on('$destroy', cleanupLastIncludeContent);
  4846. }
  4847. };
  4848. }])
  4849. .directive('tooltipClasses', ['$log', '$tooltipSuppressWarning', function($log, $tooltipSuppressWarning) {
  4850. return {
  4851. restrict: 'A',
  4852. link: function(scope, element, attrs) {
  4853. if (!$tooltipSuppressWarning) {
  4854. $log.warn('tooltip-classes is now deprecated. Use uib-tooltip-classes instead.');
  4855. }
  4856. if (scope.placement) {
  4857. element.addClass(scope.placement);
  4858. }
  4859. if (scope.popupClass) {
  4860. element.addClass(scope.popupClass);
  4861. }
  4862. if (scope.animation()) {
  4863. element.addClass(attrs.tooltipAnimationClass);
  4864. }
  4865. }
  4866. };
  4867. }])
  4868. .directive('tooltipPopup', ['$log', '$tooltipSuppressWarning', function($log, $tooltipSuppressWarning) {
  4869. return {
  4870. replace: true,
  4871. scope: { content: '@', placement: '@', popupClass: '@', animation: '&', isOpen: '&' },
  4872. templateUrl: 'template/tooltip/tooltip-popup.html',
  4873. link: function(scope, element) {
  4874. if (!$tooltipSuppressWarning) {
  4875. $log.warn('tooltip-popup is now deprecated. Use uib-tooltip-popup instead.');
  4876. }
  4877. element.addClass('tooltip');
  4878. }
  4879. };
  4880. }])
  4881. .directive('tooltip', ['$tooltip', function($tooltip) {
  4882. return $tooltip('tooltip', 'tooltip', 'mouseenter');
  4883. }])
  4884. .directive('tooltipTemplatePopup', ['$log', '$tooltipSuppressWarning', function($log, $tooltipSuppressWarning) {
  4885. return {
  4886. replace: true,
  4887. scope: { contentExp: '&', placement: '@', popupClass: '@', animation: '&', isOpen: '&',
  4888. originScope: '&' },
  4889. templateUrl: 'template/tooltip/tooltip-template-popup.html',
  4890. link: function(scope, element) {
  4891. if (!$tooltipSuppressWarning) {
  4892. $log.warn('tooltip-template-popup is now deprecated. Use uib-tooltip-template-popup instead.');
  4893. }
  4894. element.addClass('tooltip');
  4895. }
  4896. };
  4897. }])
  4898. .directive('tooltipTemplate', ['$tooltip', function($tooltip) {
  4899. return $tooltip('tooltipTemplate', 'tooltip', 'mouseenter', {
  4900. useContentExp: true
  4901. });
  4902. }])
  4903. .directive('tooltipHtmlPopup', ['$log', '$tooltipSuppressWarning', function($log, $tooltipSuppressWarning) {
  4904. return {
  4905. replace: true,
  4906. scope: { contentExp: '&', placement: '@', popupClass: '@', animation: '&', isOpen: '&' },
  4907. templateUrl: 'template/tooltip/tooltip-html-popup.html',
  4908. link: function(scope, element) {
  4909. if (!$tooltipSuppressWarning) {
  4910. $log.warn('tooltip-html-popup is now deprecated. Use uib-tooltip-html-popup instead.');
  4911. }
  4912. element.addClass('tooltip');
  4913. }
  4914. };
  4915. }])
  4916. .directive('tooltipHtml', ['$tooltip', function($tooltip) {
  4917. return $tooltip('tooltipHtml', 'tooltip', 'mouseenter', {
  4918. useContentExp: true
  4919. });
  4920. }]);
  4921. /**
  4922. * The following features are still outstanding: popup delay, animation as a
  4923. * function, placement as a function, inside, support for more triggers than
  4924. * just mouse enter/leave, and selector delegatation.
  4925. */
  4926. angular.module('ui.bootstrap.popover', ['ui.bootstrap.tooltip'])
  4927. .directive('uibPopoverTemplatePopup', function() {
  4928. return {
  4929. replace: true,
  4930. scope: { title: '@', contentExp: '&', placement: '@', popupClass: '@', animation: '&', isOpen: '&',
  4931. originScope: '&' },
  4932. templateUrl: 'template/popover/popover-template.html',
  4933. link: function(scope, element) {
  4934. element.addClass('popover');
  4935. }
  4936. };
  4937. })
  4938. .directive('uibPopoverTemplate', ['$uibTooltip', function($uibTooltip) {
  4939. return $uibTooltip('uibPopoverTemplate', 'popover', 'click', {
  4940. useContentExp: true
  4941. });
  4942. }])
  4943. .directive('uibPopoverHtmlPopup', function() {
  4944. return {
  4945. replace: true,
  4946. scope: { contentExp: '&', title: '@', placement: '@', popupClass: '@', animation: '&', isOpen: '&' },
  4947. templateUrl: 'template/popover/popover-html.html',
  4948. link: function(scope, element) {
  4949. element.addClass('popover');
  4950. }
  4951. };
  4952. })
  4953. .directive('uibPopoverHtml', ['$uibTooltip', function($uibTooltip) {
  4954. return $uibTooltip('uibPopoverHtml', 'popover', 'click', {
  4955. useContentExp: true
  4956. });
  4957. }])
  4958. .directive('uibPopoverPopup', function() {
  4959. return {
  4960. replace: true,
  4961. scope: { title: '@', content: '@', placement: '@', popupClass: '@', animation: '&', isOpen: '&' },
  4962. templateUrl: 'template/popover/popover.html',
  4963. link: function(scope, element) {
  4964. element.addClass('popover');
  4965. }
  4966. };
  4967. })
  4968. .directive('uibPopover', ['$uibTooltip', function($uibTooltip) {
  4969. return $uibTooltip('uibPopover', 'popover', 'click');
  4970. }]);
  4971. /* Deprecated popover below */
  4972. angular.module('ui.bootstrap.popover')
  4973. .value('$popoverSuppressWarning', false)
  4974. .directive('popoverTemplatePopup', ['$log', '$popoverSuppressWarning', function($log, $popoverSuppressWarning) {
  4975. return {
  4976. replace: true,
  4977. scope: { title: '@', contentExp: '&', placement: '@', popupClass: '@', animation: '&', isOpen: '&',
  4978. originScope: '&' },
  4979. templateUrl: 'template/popover/popover-template.html',
  4980. link: function(scope, element) {
  4981. if (!$popoverSuppressWarning) {
  4982. $log.warn('popover-template-popup is now deprecated. Use uib-popover-template-popup instead.');
  4983. }
  4984. element.addClass('popover');
  4985. }
  4986. };
  4987. }])
  4988. .directive('popoverTemplate', ['$tooltip', function($tooltip) {
  4989. return $tooltip('popoverTemplate', 'popover', 'click', {
  4990. useContentExp: true
  4991. });
  4992. }])
  4993. .directive('popoverHtmlPopup', ['$log', '$popoverSuppressWarning', function($log, $popoverSuppressWarning) {
  4994. return {
  4995. replace: true,
  4996. scope: { contentExp: '&', title: '@', placement: '@', popupClass: '@', animation: '&', isOpen: '&' },
  4997. templateUrl: 'template/popover/popover-html.html',
  4998. link: function(scope, element) {
  4999. if (!$popoverSuppressWarning) {
  5000. $log.warn('popover-html-popup is now deprecated. Use uib-popover-html-popup instead.');
  5001. }
  5002. element.addClass('popover');
  5003. }
  5004. };
  5005. }])
  5006. .directive('popoverHtml', ['$tooltip', function($tooltip) {
  5007. return $tooltip('popoverHtml', 'popover', 'click', {
  5008. useContentExp: true
  5009. });
  5010. }])
  5011. .directive('popoverPopup', ['$log', '$popoverSuppressWarning', function($log, $popoverSuppressWarning) {
  5012. return {
  5013. replace: true,
  5014. scope: { title: '@', content: '@', placement: '@', popupClass: '@', animation: '&', isOpen: '&' },
  5015. templateUrl: 'template/popover/popover.html',
  5016. link: function(scope, element) {
  5017. if (!$popoverSuppressWarning) {
  5018. $log.warn('popover-popup is now deprecated. Use uib-popover-popup instead.');
  5019. }
  5020. element.addClass('popover');
  5021. }
  5022. };
  5023. }])
  5024. .directive('popover', ['$tooltip', function($tooltip) {
  5025. return $tooltip('popover', 'popover', 'click');
  5026. }]);
  5027. angular.module('ui.bootstrap.progressbar', [])
  5028. .constant('uibProgressConfig', {
  5029. animate: true,
  5030. max: 100
  5031. })
  5032. .controller('UibProgressController', ['$scope', '$attrs', 'uibProgressConfig', function($scope, $attrs, progressConfig) {
  5033. var self = this,
  5034. animate = angular.isDefined($attrs.animate) ? $scope.$parent.$eval($attrs.animate) : progressConfig.animate;
  5035. this.bars = [];
  5036. $scope.max = angular.isDefined($scope.max) ? $scope.max : progressConfig.max;
  5037. this.addBar = function(bar, element, attrs) {
  5038. if (!animate) {
  5039. element.css({'transition': 'none'});
  5040. }
  5041. this.bars.push(bar);
  5042. bar.max = $scope.max;
  5043. bar.title = attrs && angular.isDefined(attrs.title) ? attrs.title : 'progressbar';
  5044. bar.$watch('value', function(value) {
  5045. bar.recalculatePercentage();
  5046. });
  5047. bar.recalculatePercentage = function() {
  5048. var totalPercentage = self.bars.reduce(function(total, bar) {
  5049. bar.percent = +(100 * bar.value / bar.max).toFixed(2);
  5050. return total + bar.percent;
  5051. }, 0);
  5052. if (totalPercentage > 100) {
  5053. bar.percent -= totalPercentage - 100;
  5054. }
  5055. };
  5056. bar.$on('$destroy', function() {
  5057. element = null;
  5058. self.removeBar(bar);
  5059. });
  5060. };
  5061. this.removeBar = function(bar) {
  5062. this.bars.splice(this.bars.indexOf(bar), 1);
  5063. this.bars.forEach(function (bar) {
  5064. bar.recalculatePercentage();
  5065. });
  5066. };
  5067. $scope.$watch('max', function(max) {
  5068. self.bars.forEach(function(bar) {
  5069. bar.max = $scope.max;
  5070. bar.recalculatePercentage();
  5071. });
  5072. });
  5073. }])
  5074. .directive('uibProgress', function() {
  5075. return {
  5076. replace: true,
  5077. transclude: true,
  5078. controller: 'UibProgressController',
  5079. require: 'uibProgress',
  5080. scope: {
  5081. max: '=?'
  5082. },
  5083. templateUrl: 'template/progressbar/progress.html'
  5084. };
  5085. })
  5086. .directive('uibBar', function() {
  5087. return {
  5088. replace: true,
  5089. transclude: true,
  5090. require: '^uibProgress',
  5091. scope: {
  5092. value: '=',
  5093. type: '@'
  5094. },
  5095. templateUrl: 'template/progressbar/bar.html',
  5096. link: function(scope, element, attrs, progressCtrl) {
  5097. progressCtrl.addBar(scope, element, attrs);
  5098. }
  5099. };
  5100. })
  5101. .directive('uibProgressbar', function() {
  5102. return {
  5103. replace: true,
  5104. transclude: true,
  5105. controller: 'UibProgressController',
  5106. scope: {
  5107. value: '=',
  5108. max: '=?',
  5109. type: '@'
  5110. },
  5111. templateUrl: 'template/progressbar/progressbar.html',
  5112. link: function(scope, element, attrs, progressCtrl) {
  5113. progressCtrl.addBar(scope, angular.element(element.children()[0]), {title: attrs.title});
  5114. }
  5115. };
  5116. });
  5117. /* Deprecated progressbar below */
  5118. angular.module('ui.bootstrap.progressbar')
  5119. .value('$progressSuppressWarning', false)
  5120. .controller('ProgressController', ['$scope', '$attrs', 'uibProgressConfig', '$log', '$progressSuppressWarning', function($scope, $attrs, progressConfig, $log, $progressSuppressWarning) {
  5121. if (!$progressSuppressWarning) {
  5122. $log.warn('ProgressController is now deprecated. Use UibProgressController instead.');
  5123. }
  5124. var self = this,
  5125. animate = angular.isDefined($attrs.animate) ? $scope.$parent.$eval($attrs.animate) : progressConfig.animate;
  5126. this.bars = [];
  5127. $scope.max = angular.isDefined($scope.max) ? $scope.max : progressConfig.max;
  5128. this.addBar = function(bar, element, attrs) {
  5129. if (!animate) {
  5130. element.css({'transition': 'none'});
  5131. }
  5132. this.bars.push(bar);
  5133. bar.max = $scope.max;
  5134. bar.title = attrs && angular.isDefined(attrs.title) ? attrs.title : 'progressbar';
  5135. bar.$watch('value', function(value) {
  5136. bar.recalculatePercentage();
  5137. });
  5138. bar.recalculatePercentage = function() {
  5139. bar.percent = +(100 * bar.value / bar.max).toFixed(2);
  5140. var totalPercentage = self.bars.reduce(function(total, bar) {
  5141. return total + bar.percent;
  5142. }, 0);
  5143. if (totalPercentage > 100) {
  5144. bar.percent -= totalPercentage - 100;
  5145. }
  5146. };
  5147. bar.$on('$destroy', function() {
  5148. element = null;
  5149. self.removeBar(bar);
  5150. });
  5151. };
  5152. this.removeBar = function(bar) {
  5153. this.bars.splice(this.bars.indexOf(bar), 1);
  5154. };
  5155. $scope.$watch('max', function(max) {
  5156. self.bars.forEach(function(bar) {
  5157. bar.max = $scope.max;
  5158. bar.recalculatePercentage();
  5159. });
  5160. });
  5161. }])
  5162. .directive('progress', ['$log', '$progressSuppressWarning', function($log, $progressSuppressWarning) {
  5163. return {
  5164. replace: true,
  5165. transclude: true,
  5166. controller: 'ProgressController',
  5167. require: 'progress',
  5168. scope: {
  5169. max: '=?',
  5170. title: '@?'
  5171. },
  5172. templateUrl: 'template/progressbar/progress.html',
  5173. link: function() {
  5174. if (!$progressSuppressWarning) {
  5175. $log.warn('progress is now deprecated. Use uib-progress instead.');
  5176. }
  5177. }
  5178. };
  5179. }])
  5180. .directive('bar', ['$log', '$progressSuppressWarning', function($log, $progressSuppressWarning) {
  5181. return {
  5182. replace: true,
  5183. transclude: true,
  5184. require: '^progress',
  5185. scope: {
  5186. value: '=',
  5187. type: '@'
  5188. },
  5189. templateUrl: 'template/progressbar/bar.html',
  5190. link: function(scope, element, attrs, progressCtrl) {
  5191. if (!$progressSuppressWarning) {
  5192. $log.warn('bar is now deprecated. Use uib-bar instead.');
  5193. }
  5194. progressCtrl.addBar(scope, element);
  5195. }
  5196. };
  5197. }])
  5198. .directive('progressbar', ['$log', '$progressSuppressWarning', function($log, $progressSuppressWarning) {
  5199. return {
  5200. replace: true,
  5201. transclude: true,
  5202. controller: 'ProgressController',
  5203. scope: {
  5204. value: '=',
  5205. max: '=?',
  5206. type: '@'
  5207. },
  5208. templateUrl: 'template/progressbar/progressbar.html',
  5209. link: function(scope, element, attrs, progressCtrl) {
  5210. if (!$progressSuppressWarning) {
  5211. $log.warn('progressbar is now deprecated. Use uib-progressbar instead.');
  5212. }
  5213. progressCtrl.addBar(scope, angular.element(element.children()[0]), {title: attrs.title});
  5214. }
  5215. };
  5216. }]);
  5217. angular.module('ui.bootstrap.rating', [])
  5218. .constant('uibRatingConfig', {
  5219. max: 5,
  5220. stateOn: null,
  5221. stateOff: null,
  5222. titles : ['one', 'two', 'three', 'four', 'five']
  5223. })
  5224. .controller('UibRatingController', ['$scope', '$attrs', 'uibRatingConfig', function($scope, $attrs, ratingConfig) {
  5225. var ngModelCtrl = { $setViewValue: angular.noop };
  5226. this.init = function(ngModelCtrl_) {
  5227. ngModelCtrl = ngModelCtrl_;
  5228. ngModelCtrl.$render = this.render;
  5229. ngModelCtrl.$formatters.push(function(value) {
  5230. if (angular.isNumber(value) && value << 0 !== value) {
  5231. value = Math.round(value);
  5232. }
  5233. return value;
  5234. });
  5235. this.stateOn = angular.isDefined($attrs.stateOn) ? $scope.$parent.$eval($attrs.stateOn) : ratingConfig.stateOn;
  5236. this.stateOff = angular.isDefined($attrs.stateOff) ? $scope.$parent.$eval($attrs.stateOff) : ratingConfig.stateOff;
  5237. var tmpTitles = angular.isDefined($attrs.titles) ? $scope.$parent.$eval($attrs.titles) : ratingConfig.titles ;
  5238. this.titles = angular.isArray(tmpTitles) && tmpTitles.length > 0 ?
  5239. tmpTitles : ratingConfig.titles;
  5240. var ratingStates = angular.isDefined($attrs.ratingStates) ?
  5241. $scope.$parent.$eval($attrs.ratingStates) :
  5242. new Array(angular.isDefined($attrs.max) ? $scope.$parent.$eval($attrs.max) : ratingConfig.max);
  5243. $scope.range = this.buildTemplateObjects(ratingStates);
  5244. };
  5245. this.buildTemplateObjects = function(states) {
  5246. for (var i = 0, n = states.length; i < n; i++) {
  5247. states[i] = angular.extend({ index: i }, { stateOn: this.stateOn, stateOff: this.stateOff, title: this.getTitle(i) }, states[i]);
  5248. }
  5249. return states;
  5250. };
  5251. this.getTitle = function(index) {
  5252. if (index >= this.titles.length) {
  5253. return index + 1;
  5254. } else {
  5255. return this.titles[index];
  5256. }
  5257. };
  5258. $scope.rate = function(value) {
  5259. if (!$scope.readonly && value >= 0 && value <= $scope.range.length) {
  5260. ngModelCtrl.$setViewValue(ngModelCtrl.$viewValue === value ? 0 : value);
  5261. ngModelCtrl.$render();
  5262. }
  5263. };
  5264. $scope.enter = function(value) {
  5265. if (!$scope.readonly) {
  5266. $scope.value = value;
  5267. }
  5268. $scope.onHover({value: value});
  5269. };
  5270. $scope.reset = function() {
  5271. $scope.value = ngModelCtrl.$viewValue;
  5272. $scope.onLeave();
  5273. };
  5274. $scope.onKeydown = function(evt) {
  5275. if (/(37|38|39|40)/.test(evt.which)) {
  5276. evt.preventDefault();
  5277. evt.stopPropagation();
  5278. $scope.rate($scope.value + (evt.which === 38 || evt.which === 39 ? 1 : -1));
  5279. }
  5280. };
  5281. this.render = function() {
  5282. $scope.value = ngModelCtrl.$viewValue;
  5283. };
  5284. }])
  5285. .directive('uibRating', function() {
  5286. return {
  5287. require: ['uibRating', 'ngModel'],
  5288. scope: {
  5289. readonly: '=?',
  5290. onHover: '&',
  5291. onLeave: '&'
  5292. },
  5293. controller: 'UibRatingController',
  5294. templateUrl: 'template/rating/rating.html',
  5295. replace: true,
  5296. link: function(scope, element, attrs, ctrls) {
  5297. var ratingCtrl = ctrls[0], ngModelCtrl = ctrls[1];
  5298. ratingCtrl.init(ngModelCtrl);
  5299. }
  5300. };
  5301. });
  5302. /* Deprecated rating below */
  5303. angular.module('ui.bootstrap.rating')
  5304. .value('$ratingSuppressWarning', false)
  5305. .controller('RatingController', ['$scope', '$attrs', '$controller', '$log', '$ratingSuppressWarning', function($scope, $attrs, $controller, $log, $ratingSuppressWarning) {
  5306. if (!$ratingSuppressWarning) {
  5307. $log.warn('RatingController is now deprecated. Use UibRatingController instead.');
  5308. }
  5309. angular.extend(this, $controller('UibRatingController', {
  5310. $scope: $scope,
  5311. $attrs: $attrs
  5312. }));
  5313. }])
  5314. .directive('rating', ['$log', '$ratingSuppressWarning', function($log, $ratingSuppressWarning) {
  5315. return {
  5316. require: ['rating', 'ngModel'],
  5317. scope: {
  5318. readonly: '=?',
  5319. onHover: '&',
  5320. onLeave: '&'
  5321. },
  5322. controller: 'RatingController',
  5323. templateUrl: 'template/rating/rating.html',
  5324. replace: true,
  5325. link: function(scope, element, attrs, ctrls) {
  5326. if (!$ratingSuppressWarning) {
  5327. $log.warn('rating is now deprecated. Use uib-rating instead.');
  5328. }
  5329. var ratingCtrl = ctrls[0], ngModelCtrl = ctrls[1];
  5330. ratingCtrl.init(ngModelCtrl);
  5331. }
  5332. };
  5333. }]);
  5334. /**
  5335. * @ngdoc overview
  5336. * @name ui.bootstrap.tabs
  5337. *
  5338. * @description
  5339. * AngularJS version of the tabs directive.
  5340. */
  5341. angular.module('ui.bootstrap.tabs', [])
  5342. .controller('UibTabsetController', ['$scope', function ($scope) {
  5343. var ctrl = this,
  5344. tabs = ctrl.tabs = $scope.tabs = [];
  5345. ctrl.select = function(selectedTab) {
  5346. angular.forEach(tabs, function(tab) {
  5347. if (tab.active && tab !== selectedTab) {
  5348. tab.active = false;
  5349. tab.onDeselect();
  5350. selectedTab.selectCalled = false;
  5351. }
  5352. });
  5353. selectedTab.active = true;
  5354. // only call select if it has not already been called
  5355. if (!selectedTab.selectCalled) {
  5356. selectedTab.onSelect();
  5357. selectedTab.selectCalled = true;
  5358. }
  5359. };
  5360. ctrl.addTab = function addTab(tab) {
  5361. tabs.push(tab);
  5362. // we can't run the select function on the first tab
  5363. // since that would select it twice
  5364. if (tabs.length === 1 && tab.active !== false) {
  5365. tab.active = true;
  5366. } else if (tab.active) {
  5367. ctrl.select(tab);
  5368. } else {
  5369. tab.active = false;
  5370. }
  5371. };
  5372. ctrl.removeTab = function removeTab(tab) {
  5373. var index = tabs.indexOf(tab);
  5374. //Select a new tab if the tab to be removed is selected and not destroyed
  5375. if (tab.active && tabs.length > 1 && !destroyed) {
  5376. //If this is the last tab, select the previous tab. else, the next tab.
  5377. var newActiveIndex = index == tabs.length - 1 ? index - 1 : index + 1;
  5378. ctrl.select(tabs[newActiveIndex]);
  5379. }
  5380. tabs.splice(index, 1);
  5381. };
  5382. var destroyed;
  5383. $scope.$on('$destroy', function() {
  5384. destroyed = true;
  5385. });
  5386. }])
  5387. /**
  5388. * @ngdoc directive
  5389. * @name ui.bootstrap.tabs.directive:tabset
  5390. * @restrict EA
  5391. *
  5392. * @description
  5393. * Tabset is the outer container for the tabs directive
  5394. *
  5395. * @param {boolean=} vertical Whether or not to use vertical styling for the tabs.
  5396. * @param {boolean=} justified Whether or not to use justified styling for the tabs.
  5397. *
  5398. * @example
  5399. <example module="ui.bootstrap">
  5400. <file name="index.html">
  5401. <uib-tabset>
  5402. <uib-tab heading="Tab 1"><b>First</b> Content!</uib-tab>
  5403. <uib-tab heading="Tab 2"><i>Second</i> Content!</uib-tab>
  5404. </uib-tabset>
  5405. <hr />
  5406. <uib-tabset vertical="true">
  5407. <uib-tab heading="Vertical Tab 1"><b>First</b> Vertical Content!</uib-tab>
  5408. <uib-tab heading="Vertical Tab 2"><i>Second</i> Vertical Content!</uib-tab>
  5409. </uib-tabset>
  5410. <uib-tabset justified="true">
  5411. <uib-tab heading="Justified Tab 1"><b>First</b> Justified Content!</uib-tab>
  5412. <uib-tab heading="Justified Tab 2"><i>Second</i> Justified Content!</uib-tab>
  5413. </uib-tabset>
  5414. </file>
  5415. </example>
  5416. */
  5417. .directive('uibTabset', function() {
  5418. return {
  5419. restrict: 'EA',
  5420. transclude: true,
  5421. replace: true,
  5422. scope: {
  5423. type: '@'
  5424. },
  5425. controller: 'UibTabsetController',
  5426. templateUrl: 'template/tabs/tabset.html',
  5427. link: function(scope, element, attrs) {
  5428. scope.vertical = angular.isDefined(attrs.vertical) ? scope.$parent.$eval(attrs.vertical) : false;
  5429. scope.justified = angular.isDefined(attrs.justified) ? scope.$parent.$eval(attrs.justified) : false;
  5430. }
  5431. };
  5432. })
  5433. /**
  5434. * @ngdoc directive
  5435. * @name ui.bootstrap.tabs.directive:tab
  5436. * @restrict EA
  5437. *
  5438. * @param {string=} heading The visible heading, or title, of the tab. Set HTML headings with {@link ui.bootstrap.tabs.directive:tabHeading tabHeading}.
  5439. * @param {string=} select An expression to evaluate when the tab is selected.
  5440. * @param {boolean=} active A binding, telling whether or not this tab is selected.
  5441. * @param {boolean=} disabled A binding, telling whether or not this tab is disabled.
  5442. *
  5443. * @description
  5444. * Creates a tab with a heading and content. Must be placed within a {@link ui.bootstrap.tabs.directive:tabset tabset}.
  5445. *
  5446. * @example
  5447. <example module="ui.bootstrap">
  5448. <file name="index.html">
  5449. <div ng-controller="TabsDemoCtrl">
  5450. <button class="btn btn-small" ng-click="items[0].active = true">
  5451. Select item 1, using active binding
  5452. </button>
  5453. <button class="btn btn-small" ng-click="items[1].disabled = !items[1].disabled">
  5454. Enable/disable item 2, using disabled binding
  5455. </button>
  5456. <br />
  5457. <uib-tabset>
  5458. <uib-tab heading="Tab 1">First Tab</uib-tab>
  5459. <uib-tab select="alertMe()">
  5460. <uib-tab-heading><i class="icon-bell"></i> Alert me!</tab-heading>
  5461. Second Tab, with alert callback and html heading!
  5462. </uib-tab>
  5463. <uib-tab ng-repeat="item in items"
  5464. heading="{{item.title}}"
  5465. disabled="item.disabled"
  5466. active="item.active">
  5467. {{item.content}}
  5468. </uib-tab>
  5469. </uib-tabset>
  5470. </div>
  5471. </file>
  5472. <file name="script.js">
  5473. function TabsDemoCtrl($scope) {
  5474. $scope.items = [
  5475. { title:"Dynamic Title 1", content:"Dynamic Item 0" },
  5476. { title:"Dynamic Title 2", content:"Dynamic Item 1", disabled: true }
  5477. ];
  5478. $scope.alertMe = function() {
  5479. setTimeout(function() {
  5480. alert("You've selected the alert tab!");
  5481. });
  5482. };
  5483. };
  5484. </file>
  5485. </example>
  5486. */
  5487. /**
  5488. * @ngdoc directive
  5489. * @name ui.bootstrap.tabs.directive:tabHeading
  5490. * @restrict EA
  5491. *
  5492. * @description
  5493. * Creates an HTML heading for a {@link ui.bootstrap.tabs.directive:tab tab}. Must be placed as a child of a tab element.
  5494. *
  5495. * @example
  5496. <example module="ui.bootstrap">
  5497. <file name="index.html">
  5498. <uib-tabset>
  5499. <uib-tab>
  5500. <uib-tab-heading><b>HTML</b> in my titles?!</tab-heading>
  5501. And some content, too!
  5502. </uib-tab>
  5503. <uib-tab>
  5504. <uib-tab-heading><i class="icon-heart"></i> Icon heading?!?</tab-heading>
  5505. That's right.
  5506. </uib-tab>
  5507. </uib-tabset>
  5508. </file>
  5509. </example>
  5510. */
  5511. .directive('uibTab', ['$parse', function($parse) {
  5512. return {
  5513. require: '^uibTabset',
  5514. restrict: 'EA',
  5515. replace: true,
  5516. templateUrl: 'template/tabs/tab.html',
  5517. transclude: true,
  5518. scope: {
  5519. active: '=?',
  5520. heading: '@',
  5521. onSelect: '&select', //This callback is called in contentHeadingTransclude
  5522. //once it inserts the tab's content into the dom
  5523. onDeselect: '&deselect'
  5524. },
  5525. controller: function() {
  5526. //Empty controller so other directives can require being 'under' a tab
  5527. },
  5528. link: function(scope, elm, attrs, tabsetCtrl, transclude) {
  5529. scope.$watch('active', function(active) {
  5530. if (active) {
  5531. tabsetCtrl.select(scope);
  5532. }
  5533. });
  5534. scope.disabled = false;
  5535. if (attrs.disable) {
  5536. scope.$parent.$watch($parse(attrs.disable), function(value) {
  5537. scope.disabled = !! value;
  5538. });
  5539. }
  5540. scope.select = function() {
  5541. if (!scope.disabled) {
  5542. scope.active = true;
  5543. }
  5544. };
  5545. tabsetCtrl.addTab(scope);
  5546. scope.$on('$destroy', function() {
  5547. tabsetCtrl.removeTab(scope);
  5548. });
  5549. //We need to transclude later, once the content container is ready.
  5550. //when this link happens, we're inside a tab heading.
  5551. scope.$transcludeFn = transclude;
  5552. }
  5553. };
  5554. }])
  5555. .directive('uibTabHeadingTransclude', function() {
  5556. return {
  5557. restrict: 'A',
  5558. require: ['?^uibTab', '?^tab'], // TODO: change to '^uibTab' after deprecation removal
  5559. link: function(scope, elm) {
  5560. scope.$watch('headingElement', function updateHeadingElement(heading) {
  5561. if (heading) {
  5562. elm.html('');
  5563. elm.append(heading);
  5564. }
  5565. });
  5566. }
  5567. };
  5568. })
  5569. .directive('uibTabContentTransclude', function() {
  5570. return {
  5571. restrict: 'A',
  5572. require: ['?^uibTabset', '?^tabset'], // TODO: change to '^uibTabset' after deprecation removal
  5573. link: function(scope, elm, attrs) {
  5574. var tab = scope.$eval(attrs.uibTabContentTransclude);
  5575. //Now our tab is ready to be transcluded: both the tab heading area
  5576. //and the tab content area are loaded. Transclude 'em both.
  5577. tab.$transcludeFn(tab.$parent, function(contents) {
  5578. angular.forEach(contents, function(node) {
  5579. if (isTabHeading(node)) {
  5580. //Let tabHeadingTransclude know.
  5581. tab.headingElement = node;
  5582. } else {
  5583. elm.append(node);
  5584. }
  5585. });
  5586. });
  5587. }
  5588. };
  5589. function isTabHeading(node) {
  5590. return node.tagName && (
  5591. node.hasAttribute('tab-heading') || // TODO: remove after deprecation removal
  5592. node.hasAttribute('data-tab-heading') || // TODO: remove after deprecation removal
  5593. node.hasAttribute('x-tab-heading') || // TODO: remove after deprecation removal
  5594. node.hasAttribute('uib-tab-heading') ||
  5595. node.hasAttribute('data-uib-tab-heading') ||
  5596. node.hasAttribute('x-uib-tab-heading') ||
  5597. node.tagName.toLowerCase() === 'tab-heading' || // TODO: remove after deprecation removal
  5598. node.tagName.toLowerCase() === 'data-tab-heading' || // TODO: remove after deprecation removal
  5599. node.tagName.toLowerCase() === 'x-tab-heading' || // TODO: remove after deprecation removal
  5600. node.tagName.toLowerCase() === 'uib-tab-heading' ||
  5601. node.tagName.toLowerCase() === 'data-uib-tab-heading' ||
  5602. node.tagName.toLowerCase() === 'x-uib-tab-heading'
  5603. );
  5604. }
  5605. });
  5606. /* deprecated tabs below */
  5607. angular.module('ui.bootstrap.tabs')
  5608. .value('$tabsSuppressWarning', false)
  5609. .controller('TabsetController', ['$scope', '$controller', '$log', '$tabsSuppressWarning', function($scope, $controller, $log, $tabsSuppressWarning) {
  5610. if (!$tabsSuppressWarning) {
  5611. $log.warn('TabsetController is now deprecated. Use UibTabsetController instead.');
  5612. }
  5613. angular.extend(this, $controller('UibTabsetController', {
  5614. $scope: $scope
  5615. }));
  5616. }])
  5617. .directive('tabset', ['$log', '$tabsSuppressWarning', function($log, $tabsSuppressWarning) {
  5618. return {
  5619. restrict: 'EA',
  5620. transclude: true,
  5621. replace: true,
  5622. scope: {
  5623. type: '@'
  5624. },
  5625. controller: 'TabsetController',
  5626. templateUrl: 'template/tabs/tabset.html',
  5627. link: function(scope, element, attrs) {
  5628. if (!$tabsSuppressWarning) {
  5629. $log.warn('tabset is now deprecated. Use uib-tabset instead.');
  5630. }
  5631. scope.vertical = angular.isDefined(attrs.vertical) ? scope.$parent.$eval(attrs.vertical) : false;
  5632. scope.justified = angular.isDefined(attrs.justified) ? scope.$parent.$eval(attrs.justified) : false;
  5633. }
  5634. };
  5635. }])
  5636. .directive('tab', ['$parse', '$log', '$tabsSuppressWarning', function($parse, $log, $tabsSuppressWarning) {
  5637. return {
  5638. require: '^tabset',
  5639. restrict: 'EA',
  5640. replace: true,
  5641. templateUrl: 'template/tabs/tab.html',
  5642. transclude: true,
  5643. scope: {
  5644. active: '=?',
  5645. heading: '@',
  5646. onSelect: '&select', //This callback is called in contentHeadingTransclude
  5647. //once it inserts the tab's content into the dom
  5648. onDeselect: '&deselect'
  5649. },
  5650. controller: function() {
  5651. //Empty controller so other directives can require being 'under' a tab
  5652. },
  5653. link: function(scope, elm, attrs, tabsetCtrl, transclude) {
  5654. if (!$tabsSuppressWarning) {
  5655. $log.warn('tab is now deprecated. Use uib-tab instead.');
  5656. }
  5657. scope.$watch('active', function(active) {
  5658. if (active) {
  5659. tabsetCtrl.select(scope);
  5660. }
  5661. });
  5662. scope.disabled = false;
  5663. if (attrs.disable) {
  5664. scope.$parent.$watch($parse(attrs.disable), function(value) {
  5665. scope.disabled = !!value;
  5666. });
  5667. }
  5668. scope.select = function() {
  5669. if (!scope.disabled) {
  5670. scope.active = true;
  5671. }
  5672. };
  5673. tabsetCtrl.addTab(scope);
  5674. scope.$on('$destroy', function() {
  5675. tabsetCtrl.removeTab(scope);
  5676. });
  5677. //We need to transclude later, once the content container is ready.
  5678. //when this link happens, we're inside a tab heading.
  5679. scope.$transcludeFn = transclude;
  5680. }
  5681. };
  5682. }])
  5683. .directive('tabHeadingTransclude', ['$log', '$tabsSuppressWarning', function($log, $tabsSuppressWarning) {
  5684. return {
  5685. restrict: 'A',
  5686. require: '^tab',
  5687. link: function(scope, elm) {
  5688. if (!$tabsSuppressWarning) {
  5689. $log.warn('tab-heading-transclude is now deprecated. Use uib-tab-heading-transclude instead.');
  5690. }
  5691. scope.$watch('headingElement', function updateHeadingElement(heading) {
  5692. if (heading) {
  5693. elm.html('');
  5694. elm.append(heading);
  5695. }
  5696. });
  5697. }
  5698. };
  5699. }])
  5700. .directive('tabContentTransclude', ['$log', '$tabsSuppressWarning', function($log, $tabsSuppressWarning) {
  5701. return {
  5702. restrict: 'A',
  5703. require: '^tabset',
  5704. link: function(scope, elm, attrs) {
  5705. if (!$tabsSuppressWarning) {
  5706. $log.warn('tab-content-transclude is now deprecated. Use uib-tab-content-transclude instead.');
  5707. }
  5708. var tab = scope.$eval(attrs.tabContentTransclude);
  5709. //Now our tab is ready to be transcluded: both the tab heading area
  5710. //and the tab content area are loaded. Transclude 'em both.
  5711. tab.$transcludeFn(tab.$parent, function(contents) {
  5712. angular.forEach(contents, function(node) {
  5713. if (isTabHeading(node)) {
  5714. //Let tabHeadingTransclude know.
  5715. tab.headingElement = node;
  5716. }
  5717. else {
  5718. elm.append(node);
  5719. }
  5720. });
  5721. });
  5722. }
  5723. };
  5724. function isTabHeading(node) {
  5725. return node.tagName && (
  5726. node.hasAttribute('tab-heading') ||
  5727. node.hasAttribute('data-tab-heading') ||
  5728. node.hasAttribute('x-tab-heading') ||
  5729. node.tagName.toLowerCase() === 'tab-heading' ||
  5730. node.tagName.toLowerCase() === 'data-tab-heading' ||
  5731. node.tagName.toLowerCase() === 'x-tab-heading'
  5732. );
  5733. }
  5734. }]);
  5735. angular.module('ui.bootstrap.timepicker', [])
  5736. .constant('uibTimepickerConfig', {
  5737. hourStep: 1,
  5738. minuteStep: 1,
  5739. showMeridian: true,
  5740. meridians: null,
  5741. readonlyInput: false,
  5742. mousewheel: true,
  5743. arrowkeys: true,
  5744. showSpinners: true
  5745. })
  5746. .controller('UibTimepickerController', ['$scope', '$element', '$attrs', '$parse', '$log', '$locale', 'uibTimepickerConfig', function($scope, $element, $attrs, $parse, $log, $locale, timepickerConfig) {
  5747. var selected = new Date(),
  5748. ngModelCtrl = { $setViewValue: angular.noop }, // nullModelCtrl
  5749. meridians = angular.isDefined($attrs.meridians) ? $scope.$parent.$eval($attrs.meridians) : timepickerConfig.meridians || $locale.DATETIME_FORMATS.AMPMS;
  5750. $scope.tabindex = angular.isDefined($attrs.tabindex) ? $attrs.tabindex : 0;
  5751. $element.removeAttr('tabindex');
  5752. this.init = function(ngModelCtrl_, inputs) {
  5753. ngModelCtrl = ngModelCtrl_;
  5754. ngModelCtrl.$render = this.render;
  5755. ngModelCtrl.$formatters.unshift(function(modelValue) {
  5756. return modelValue ? new Date(modelValue) : null;
  5757. });
  5758. var hoursInputEl = inputs.eq(0),
  5759. minutesInputEl = inputs.eq(1);
  5760. var mousewheel = angular.isDefined($attrs.mousewheel) ? $scope.$parent.$eval($attrs.mousewheel) : timepickerConfig.mousewheel;
  5761. if (mousewheel) {
  5762. this.setupMousewheelEvents(hoursInputEl, minutesInputEl);
  5763. }
  5764. var arrowkeys = angular.isDefined($attrs.arrowkeys) ? $scope.$parent.$eval($attrs.arrowkeys) : timepickerConfig.arrowkeys;
  5765. if (arrowkeys) {
  5766. this.setupArrowkeyEvents(hoursInputEl, minutesInputEl);
  5767. }
  5768. $scope.readonlyInput = angular.isDefined($attrs.readonlyInput) ? $scope.$parent.$eval($attrs.readonlyInput) : timepickerConfig.readonlyInput;
  5769. this.setupInputEvents(hoursInputEl, minutesInputEl);
  5770. };
  5771. var hourStep = timepickerConfig.hourStep;
  5772. if ($attrs.hourStep) {
  5773. $scope.$parent.$watch($parse($attrs.hourStep), function(value) {
  5774. hourStep = parseInt(value, 10);
  5775. });
  5776. }
  5777. var minuteStep = timepickerConfig.minuteStep;
  5778. if ($attrs.minuteStep) {
  5779. $scope.$parent.$watch($parse($attrs.minuteStep), function(value) {
  5780. minuteStep = parseInt(value, 10);
  5781. });
  5782. }
  5783. var min;
  5784. $scope.$parent.$watch($parse($attrs.min), function(value) {
  5785. var dt = new Date(value);
  5786. min = isNaN(dt) ? undefined : dt;
  5787. });
  5788. var max;
  5789. $scope.$parent.$watch($parse($attrs.max), function(value) {
  5790. var dt = new Date(value);
  5791. max = isNaN(dt) ? undefined : dt;
  5792. });
  5793. $scope.noIncrementHours = function() {
  5794. var incrementedSelected = addMinutes(selected, hourStep * 60);
  5795. return incrementedSelected > max ||
  5796. (incrementedSelected < selected && incrementedSelected < min);
  5797. };
  5798. $scope.noDecrementHours = function() {
  5799. var decrementedSelected = addMinutes(selected, -hourStep * 60);
  5800. return decrementedSelected < min ||
  5801. (decrementedSelected > selected && decrementedSelected > max);
  5802. };
  5803. $scope.noIncrementMinutes = function() {
  5804. var incrementedSelected = addMinutes(selected, minuteStep);
  5805. return incrementedSelected > max ||
  5806. (incrementedSelected < selected && incrementedSelected < min);
  5807. };
  5808. $scope.noDecrementMinutes = function() {
  5809. var decrementedSelected = addMinutes(selected, -minuteStep);
  5810. return decrementedSelected < min ||
  5811. (decrementedSelected > selected && decrementedSelected > max);
  5812. };
  5813. $scope.noToggleMeridian = function() {
  5814. if (selected.getHours() < 13) {
  5815. return addMinutes(selected, 12 * 60) > max;
  5816. } else {
  5817. return addMinutes(selected, -12 * 60) < min;
  5818. }
  5819. };
  5820. // 12H / 24H mode
  5821. $scope.showMeridian = timepickerConfig.showMeridian;
  5822. if ($attrs.showMeridian) {
  5823. $scope.$parent.$watch($parse($attrs.showMeridian), function(value) {
  5824. $scope.showMeridian = !!value;
  5825. if (ngModelCtrl.$error.time) {
  5826. // Evaluate from template
  5827. var hours = getHoursFromTemplate(), minutes = getMinutesFromTemplate();
  5828. if (angular.isDefined(hours) && angular.isDefined(minutes)) {
  5829. selected.setHours(hours);
  5830. refresh();
  5831. }
  5832. } else {
  5833. updateTemplate();
  5834. }
  5835. });
  5836. }
  5837. // Get $scope.hours in 24H mode if valid
  5838. function getHoursFromTemplate() {
  5839. var hours = parseInt($scope.hours, 10);
  5840. var valid = $scope.showMeridian ? (hours > 0 && hours < 13) : (hours >= 0 && hours < 24);
  5841. if (!valid) {
  5842. return undefined;
  5843. }
  5844. if ($scope.showMeridian) {
  5845. if (hours === 12) {
  5846. hours = 0;
  5847. }
  5848. if ($scope.meridian === meridians[1]) {
  5849. hours = hours + 12;
  5850. }
  5851. }
  5852. return hours;
  5853. }
  5854. function getMinutesFromTemplate() {
  5855. var minutes = parseInt($scope.minutes, 10);
  5856. return (minutes >= 0 && minutes < 60) ? minutes : undefined;
  5857. }
  5858. function pad(value) {
  5859. return (angular.isDefined(value) && value.toString().length < 2) ? '0' + value : value.toString();
  5860. }
  5861. // Respond on mousewheel spin
  5862. this.setupMousewheelEvents = function(hoursInputEl, minutesInputEl) {
  5863. var isScrollingUp = function(e) {
  5864. if (e.originalEvent) {
  5865. e = e.originalEvent;
  5866. }
  5867. //pick correct delta variable depending on event
  5868. var delta = (e.wheelDelta) ? e.wheelDelta : -e.deltaY;
  5869. return (e.detail || delta > 0);
  5870. };
  5871. hoursInputEl.bind('mousewheel wheel', function(e) {
  5872. $scope.$apply(isScrollingUp(e) ? $scope.incrementHours() : $scope.decrementHours());
  5873. e.preventDefault();
  5874. });
  5875. minutesInputEl.bind('mousewheel wheel', function(e) {
  5876. $scope.$apply(isScrollingUp(e) ? $scope.incrementMinutes() : $scope.decrementMinutes());
  5877. e.preventDefault();
  5878. });
  5879. };
  5880. // Respond on up/down arrowkeys
  5881. this.setupArrowkeyEvents = function(hoursInputEl, minutesInputEl) {
  5882. hoursInputEl.bind('keydown', function(e) {
  5883. if (e.which === 38) { // up
  5884. e.preventDefault();
  5885. $scope.incrementHours();
  5886. $scope.$apply();
  5887. } else if (e.which === 40) { // down
  5888. e.preventDefault();
  5889. $scope.decrementHours();
  5890. $scope.$apply();
  5891. }
  5892. });
  5893. minutesInputEl.bind('keydown', function(e) {
  5894. if (e.which === 38) { // up
  5895. e.preventDefault();
  5896. $scope.incrementMinutes();
  5897. $scope.$apply();
  5898. } else if (e.which === 40) { // down
  5899. e.preventDefault();
  5900. $scope.decrementMinutes();
  5901. $scope.$apply();
  5902. }
  5903. });
  5904. };
  5905. this.setupInputEvents = function(hoursInputEl, minutesInputEl) {
  5906. if ($scope.readonlyInput) {
  5907. $scope.updateHours = angular.noop;
  5908. $scope.updateMinutes = angular.noop;
  5909. return;
  5910. }
  5911. var invalidate = function(invalidHours, invalidMinutes) {
  5912. ngModelCtrl.$setViewValue(null);
  5913. ngModelCtrl.$setValidity('time', false);
  5914. if (angular.isDefined(invalidHours)) {
  5915. $scope.invalidHours = invalidHours;
  5916. }
  5917. if (angular.isDefined(invalidMinutes)) {
  5918. $scope.invalidMinutes = invalidMinutes;
  5919. }
  5920. };
  5921. $scope.updateHours = function() {
  5922. var hours = getHoursFromTemplate(),
  5923. minutes = getMinutesFromTemplate();
  5924. if (angular.isDefined(hours) && angular.isDefined(minutes)) {
  5925. selected.setHours(hours);
  5926. if (selected < min || selected > max) {
  5927. invalidate(true);
  5928. } else {
  5929. refresh('h');
  5930. }
  5931. } else {
  5932. invalidate(true);
  5933. }
  5934. };
  5935. hoursInputEl.bind('blur', function(e) {
  5936. if (!$scope.invalidHours && $scope.hours < 10) {
  5937. $scope.$apply(function() {
  5938. $scope.hours = pad($scope.hours);
  5939. });
  5940. }
  5941. });
  5942. $scope.updateMinutes = function() {
  5943. var minutes = getMinutesFromTemplate(),
  5944. hours = getHoursFromTemplate();
  5945. if (angular.isDefined(minutes) && angular.isDefined(hours)) {
  5946. selected.setMinutes(minutes);
  5947. if (selected < min || selected > max) {
  5948. invalidate(undefined, true);
  5949. } else {
  5950. refresh('m');
  5951. }
  5952. } else {
  5953. invalidate(undefined, true);
  5954. }
  5955. };
  5956. minutesInputEl.bind('blur', function(e) {
  5957. if (!$scope.invalidMinutes && $scope.minutes < 10) {
  5958. $scope.$apply(function() {
  5959. $scope.minutes = pad($scope.minutes);
  5960. });
  5961. }
  5962. });
  5963. };
  5964. this.render = function() {
  5965. var date = ngModelCtrl.$viewValue;
  5966. if (isNaN(date)) {
  5967. ngModelCtrl.$setValidity('time', false);
  5968. $log.error('Timepicker directive: "ng-model" value must be a Date object, a number of milliseconds since 01.01.1970 or a string representing an RFC2822 or ISO 8601 date.');
  5969. } else {
  5970. if (date) {
  5971. selected = date;
  5972. }
  5973. if (selected < min || selected > max) {
  5974. ngModelCtrl.$setValidity('time', false);
  5975. $scope.invalidHours = true;
  5976. $scope.invalidMinutes = true;
  5977. } else {
  5978. makeValid();
  5979. }
  5980. updateTemplate();
  5981. }
  5982. };
  5983. // Call internally when we know that model is valid.
  5984. function refresh(keyboardChange) {
  5985. makeValid();
  5986. ngModelCtrl.$setViewValue(new Date(selected));
  5987. updateTemplate(keyboardChange);
  5988. }
  5989. function makeValid() {
  5990. ngModelCtrl.$setValidity('time', true);
  5991. $scope.invalidHours = false;
  5992. $scope.invalidMinutes = false;
  5993. }
  5994. function updateTemplate(keyboardChange) {
  5995. var hours = selected.getHours(), minutes = selected.getMinutes();
  5996. if ($scope.showMeridian) {
  5997. hours = (hours === 0 || hours === 12) ? 12 : hours % 12; // Convert 24 to 12 hour system
  5998. }
  5999. $scope.hours = keyboardChange === 'h' ? hours : pad(hours);
  6000. if (keyboardChange !== 'm') {
  6001. $scope.minutes = pad(minutes);
  6002. }
  6003. $scope.meridian = selected.getHours() < 12 ? meridians[0] : meridians[1];
  6004. }
  6005. function addMinutes(date, minutes) {
  6006. var dt = new Date(date.getTime() + minutes * 60000);
  6007. var newDate = new Date(date);
  6008. newDate.setHours(dt.getHours(), dt.getMinutes());
  6009. return newDate;
  6010. }
  6011. function addMinutesToSelected(minutes) {
  6012. selected = addMinutes(selected, minutes);
  6013. refresh();
  6014. }
  6015. $scope.showSpinners = angular.isDefined($attrs.showSpinners) ?
  6016. $scope.$parent.$eval($attrs.showSpinners) : timepickerConfig.showSpinners;
  6017. $scope.incrementHours = function() {
  6018. if (!$scope.noIncrementHours()) {
  6019. addMinutesToSelected(hourStep * 60);
  6020. }
  6021. };
  6022. $scope.decrementHours = function() {
  6023. if (!$scope.noDecrementHours()) {
  6024. addMinutesToSelected(-hourStep * 60);
  6025. }
  6026. };
  6027. $scope.incrementMinutes = function() {
  6028. if (!$scope.noIncrementMinutes()) {
  6029. addMinutesToSelected(minuteStep);
  6030. }
  6031. };
  6032. $scope.decrementMinutes = function() {
  6033. if (!$scope.noDecrementMinutes()) {
  6034. addMinutesToSelected(-minuteStep);
  6035. }
  6036. };
  6037. $scope.toggleMeridian = function() {
  6038. if (!$scope.noToggleMeridian()) {
  6039. addMinutesToSelected(12 * 60 * (selected.getHours() < 12 ? 1 : -1));
  6040. }
  6041. };
  6042. }])
  6043. .directive('uibTimepicker', function() {
  6044. return {
  6045. restrict: 'EA',
  6046. require: ['uibTimepicker', '?^ngModel'],
  6047. controller: 'UibTimepickerController',
  6048. controllerAs: 'timepicker',
  6049. replace: true,
  6050. scope: {},
  6051. templateUrl: function(element, attrs) {
  6052. return attrs.templateUrl || 'template/timepicker/timepicker.html';
  6053. },
  6054. link: function(scope, element, attrs, ctrls) {
  6055. var timepickerCtrl = ctrls[0], ngModelCtrl = ctrls[1];
  6056. if (ngModelCtrl) {
  6057. timepickerCtrl.init(ngModelCtrl, element.find('input'));
  6058. }
  6059. }
  6060. };
  6061. });
  6062. /* Deprecated timepicker below */
  6063. angular.module('ui.bootstrap.timepicker')
  6064. .value('$timepickerSuppressWarning', false)
  6065. .controller('TimepickerController', ['$scope', '$element', '$attrs', '$controller', '$log', '$timepickerSuppressWarning', function($scope, $element, $attrs, $controller, $log, $timepickerSuppressWarning) {
  6066. if (!$timepickerSuppressWarning) {
  6067. $log.warn('TimepickerController is now deprecated. Use UibTimepickerController instead.');
  6068. }
  6069. angular.extend(this, $controller('UibTimepickerController', {
  6070. $scope: $scope,
  6071. $element: $element,
  6072. $attrs: $attrs
  6073. }));
  6074. }])
  6075. .directive('timepicker', ['$log', '$timepickerSuppressWarning', function($log, $timepickerSuppressWarning) {
  6076. return {
  6077. restrict: 'EA',
  6078. require: ['timepicker', '?^ngModel'],
  6079. controller: 'TimepickerController',
  6080. controllerAs: 'timepicker',
  6081. replace: true,
  6082. scope: {},
  6083. templateUrl: function(element, attrs) {
  6084. return attrs.templateUrl || 'template/timepicker/timepicker.html';
  6085. },
  6086. link: function(scope, element, attrs, ctrls) {
  6087. if (!$timepickerSuppressWarning) {
  6088. $log.warn('timepicker is now deprecated. Use uib-timepicker instead.');
  6089. }
  6090. var timepickerCtrl = ctrls[0], ngModelCtrl = ctrls[1];
  6091. if (ngModelCtrl) {
  6092. timepickerCtrl.init(ngModelCtrl, element.find('input'));
  6093. }
  6094. }
  6095. };
  6096. }]);
  6097. angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position'])
  6098. /**
  6099. * A helper service that can parse typeahead's syntax (string provided by users)
  6100. * Extracted to a separate service for ease of unit testing
  6101. */
  6102. .factory('uibTypeaheadParser', ['$parse', function($parse) {
  6103. // 00000111000000000000022200000000000000003333333333333330000000000044000
  6104. var TYPEAHEAD_REGEXP = /^\s*([\s\S]+?)(?:\s+as\s+([\s\S]+?))?\s+for\s+(?:([\$\w][\$\w\d]*))\s+in\s+([\s\S]+?)$/;
  6105. return {
  6106. parse: function(input) {
  6107. var match = input.match(TYPEAHEAD_REGEXP);
  6108. if (!match) {
  6109. throw new Error(
  6110. 'Expected typeahead specification in form of "_modelValue_ (as _label_)? for _item_ in _collection_"' +
  6111. ' but got "' + input + '".');
  6112. }
  6113. return {
  6114. itemName: match[3],
  6115. source: $parse(match[4]),
  6116. viewMapper: $parse(match[2] || match[1]),
  6117. modelMapper: $parse(match[1])
  6118. };
  6119. }
  6120. };
  6121. }])
  6122. .controller('UibTypeaheadController', ['$scope', '$element', '$attrs', '$compile', '$parse', '$q', '$timeout', '$document', '$window', '$rootScope', '$uibPosition', 'uibTypeaheadParser',
  6123. function(originalScope, element, attrs, $compile, $parse, $q, $timeout, $document, $window, $rootScope, $position, typeaheadParser) {
  6124. var HOT_KEYS = [9, 13, 27, 38, 40];
  6125. var eventDebounceTime = 200;
  6126. var modelCtrl, ngModelOptions;
  6127. //SUPPORTED ATTRIBUTES (OPTIONS)
  6128. //minimal no of characters that needs to be entered before typeahead kicks-in
  6129. var minLength = originalScope.$eval(attrs.typeaheadMinLength);
  6130. if (!minLength && minLength !== 0) {
  6131. minLength = 1;
  6132. }
  6133. //minimal wait time after last character typed before typeahead kicks-in
  6134. var waitTime = originalScope.$eval(attrs.typeaheadWaitMs) || 0;
  6135. //should it restrict model values to the ones selected from the popup only?
  6136. var isEditable = originalScope.$eval(attrs.typeaheadEditable) !== false;
  6137. //binding to a variable that indicates if matches are being retrieved asynchronously
  6138. var isLoadingSetter = $parse(attrs.typeaheadLoading).assign || angular.noop;
  6139. //a callback executed when a match is selected
  6140. var onSelectCallback = $parse(attrs.typeaheadOnSelect);
  6141. //should it select highlighted popup value when losing focus?
  6142. var isSelectOnBlur = angular.isDefined(attrs.typeaheadSelectOnBlur) ? originalScope.$eval(attrs.typeaheadSelectOnBlur) : false;
  6143. //binding to a variable that indicates if there were no results after the query is completed
  6144. var isNoResultsSetter = $parse(attrs.typeaheadNoResults).assign || angular.noop;
  6145. var inputFormatter = attrs.typeaheadInputFormatter ? $parse(attrs.typeaheadInputFormatter) : undefined;
  6146. var appendToBody = attrs.typeaheadAppendToBody ? originalScope.$eval(attrs.typeaheadAppendToBody) : false;
  6147. var appendToElementId = attrs.typeaheadAppendToElementId || false;
  6148. var focusFirst = originalScope.$eval(attrs.typeaheadFocusFirst) !== false;
  6149. //If input matches an item of the list exactly, select it automatically
  6150. var selectOnExact = attrs.typeaheadSelectOnExact ? originalScope.$eval(attrs.typeaheadSelectOnExact) : false;
  6151. //INTERNAL VARIABLES
  6152. //model setter executed upon match selection
  6153. var parsedModel = $parse(attrs.ngModel);
  6154. var invokeModelSetter = $parse(attrs.ngModel + '($$$p)');
  6155. var $setModelValue = function(scope, newValue) {
  6156. if (angular.isFunction(parsedModel(originalScope)) &&
  6157. ngModelOptions && ngModelOptions.$options && ngModelOptions.$options.getterSetter) {
  6158. return invokeModelSetter(scope, {$$$p: newValue});
  6159. } else {
  6160. return parsedModel.assign(scope, newValue);
  6161. }
  6162. };
  6163. //expressions used by typeahead
  6164. var parserResult = typeaheadParser.parse(attrs.uibTypeahead);
  6165. var hasFocus;
  6166. //Used to avoid bug in iOS webview where iOS keyboard does not fire
  6167. //mousedown & mouseup events
  6168. //Issue #3699
  6169. var selected;
  6170. //create a child scope for the typeahead directive so we are not polluting original scope
  6171. //with typeahead-specific data (matches, query etc.)
  6172. var scope = originalScope.$new();
  6173. var offDestroy = originalScope.$on('$destroy', function() {
  6174. scope.$destroy();
  6175. });
  6176. scope.$on('$destroy', offDestroy);
  6177. // WAI-ARIA
  6178. var popupId = 'typeahead-' + scope.$id + '-' + Math.floor(Math.random() * 10000);
  6179. element.attr({
  6180. 'aria-autocomplete': 'list',
  6181. 'aria-expanded': false,
  6182. 'aria-owns': popupId
  6183. });
  6184. //pop-up element used to display matches
  6185. var popUpEl = angular.element('<div uib-typeahead-popup></div>');
  6186. popUpEl.attr({
  6187. id: popupId,
  6188. matches: 'matches',
  6189. active: 'activeIdx',
  6190. select: 'select(activeIdx)',
  6191. 'move-in-progress': 'moveInProgress',
  6192. query: 'query',
  6193. position: 'position'
  6194. });
  6195. //custom item template
  6196. if (angular.isDefined(attrs.typeaheadTemplateUrl)) {
  6197. popUpEl.attr('template-url', attrs.typeaheadTemplateUrl);
  6198. }
  6199. if (angular.isDefined(attrs.typeaheadPopupTemplateUrl)) {
  6200. popUpEl.attr('popup-template-url', attrs.typeaheadPopupTemplateUrl);
  6201. }
  6202. var resetMatches = function() {
  6203. scope.matches = [];
  6204. scope.activeIdx = -1;
  6205. element.attr('aria-expanded', false);
  6206. };
  6207. var getMatchId = function(index) {
  6208. return popupId + '-option-' + index;
  6209. };
  6210. // Indicate that the specified match is the active (pre-selected) item in the list owned by this typeahead.
  6211. // This attribute is added or removed automatically when the `activeIdx` changes.
  6212. scope.$watch('activeIdx', function(index) {
  6213. if (index < 0) {
  6214. element.removeAttr('aria-activedescendant');
  6215. } else {
  6216. element.attr('aria-activedescendant', getMatchId(index));
  6217. }
  6218. });
  6219. var inputIsExactMatch = function(inputValue, index) {
  6220. if (scope.matches.length > index && inputValue) {
  6221. return inputValue.toUpperCase() === scope.matches[index].label.toUpperCase();
  6222. }
  6223. return false;
  6224. };
  6225. var getMatchesAsync = function(inputValue) {
  6226. var locals = {$viewValue: inputValue};
  6227. isLoadingSetter(originalScope, true);
  6228. isNoResultsSetter(originalScope, false);
  6229. $q.when(parserResult.source(originalScope, locals)).then(function(matches) {
  6230. //it might happen that several async queries were in progress if a user were typing fast
  6231. //but we are interested only in responses that correspond to the current view value
  6232. var onCurrentRequest = (inputValue === modelCtrl.$viewValue);
  6233. if (onCurrentRequest && hasFocus) {
  6234. if (matches && matches.length > 0) {
  6235. scope.activeIdx = focusFirst ? 0 : -1;
  6236. isNoResultsSetter(originalScope, false);
  6237. scope.matches.length = 0;
  6238. //transform labels
  6239. for (var i = 0; i < matches.length; i++) {
  6240. locals[parserResult.itemName] = matches[i];
  6241. scope.matches.push({
  6242. id: getMatchId(i),
  6243. label: parserResult.viewMapper(scope, locals),
  6244. model: matches[i]
  6245. });
  6246. }
  6247. scope.query = inputValue;
  6248. //position pop-up with matches - we need to re-calculate its position each time we are opening a window
  6249. //with matches as a pop-up might be absolute-positioned and position of an input might have changed on a page
  6250. //due to other elements being rendered
  6251. recalculatePosition();
  6252. element.attr('aria-expanded', true);
  6253. //Select the single remaining option if user input matches
  6254. if (selectOnExact && scope.matches.length === 1 && inputIsExactMatch(inputValue, 0)) {
  6255. scope.select(0);
  6256. }
  6257. } else {
  6258. resetMatches();
  6259. isNoResultsSetter(originalScope, true);
  6260. }
  6261. }
  6262. if (onCurrentRequest) {
  6263. isLoadingSetter(originalScope, false);
  6264. }
  6265. }, function() {
  6266. resetMatches();
  6267. isLoadingSetter(originalScope, false);
  6268. isNoResultsSetter(originalScope, true);
  6269. });
  6270. };
  6271. // bind events only if appendToBody params exist - performance feature
  6272. if (appendToBody) {
  6273. angular.element($window).bind('resize', fireRecalculating);
  6274. $document.find('body').bind('scroll', fireRecalculating);
  6275. }
  6276. // Declare the timeout promise var outside the function scope so that stacked calls can be cancelled later
  6277. var timeoutEventPromise;
  6278. // Default progress type
  6279. scope.moveInProgress = false;
  6280. function fireRecalculating() {
  6281. if (!scope.moveInProgress) {
  6282. scope.moveInProgress = true;
  6283. scope.$digest();
  6284. }
  6285. // Cancel previous timeout
  6286. if (timeoutEventPromise) {
  6287. $timeout.cancel(timeoutEventPromise);
  6288. }
  6289. // Debounced executing recalculate after events fired
  6290. timeoutEventPromise = $timeout(function() {
  6291. // if popup is visible
  6292. if (scope.matches.length) {
  6293. recalculatePosition();
  6294. }
  6295. scope.moveInProgress = false;
  6296. }, eventDebounceTime);
  6297. }
  6298. // recalculate actual position and set new values to scope
  6299. // after digest loop is popup in right position
  6300. function recalculatePosition() {
  6301. scope.position = appendToBody ? $position.offset(element) : $position.position(element);
  6302. scope.position.top += element.prop('offsetHeight');
  6303. }
  6304. //we need to propagate user's query so we can higlight matches
  6305. scope.query = undefined;
  6306. //Declare the timeout promise var outside the function scope so that stacked calls can be cancelled later
  6307. var timeoutPromise;
  6308. var scheduleSearchWithTimeout = function(inputValue) {
  6309. timeoutPromise = $timeout(function() {
  6310. getMatchesAsync(inputValue);
  6311. }, waitTime);
  6312. };
  6313. var cancelPreviousTimeout = function() {
  6314. if (timeoutPromise) {
  6315. $timeout.cancel(timeoutPromise);
  6316. }
  6317. };
  6318. resetMatches();
  6319. scope.select = function(activeIdx) {
  6320. //called from within the $digest() cycle
  6321. var locals = {};
  6322. var model, item;
  6323. selected = true;
  6324. locals[parserResult.itemName] = item = scope.matches[activeIdx].model;
  6325. model = parserResult.modelMapper(originalScope, locals);
  6326. $setModelValue(originalScope, model);
  6327. modelCtrl.$setValidity('editable', true);
  6328. modelCtrl.$setValidity('parse', true);
  6329. onSelectCallback(originalScope, {
  6330. $item: item,
  6331. $model: model,
  6332. $label: parserResult.viewMapper(originalScope, locals)
  6333. });
  6334. resetMatches();
  6335. //return focus to the input element if a match was selected via a mouse click event
  6336. // use timeout to avoid $rootScope:inprog error
  6337. if (scope.$eval(attrs.typeaheadFocusOnSelect) !== false) {
  6338. $timeout(function() { element[0].focus(); }, 0, false);
  6339. }
  6340. };
  6341. //bind keyboard events: arrows up(38) / down(40), enter(13) and tab(9), esc(27)
  6342. element.bind('keydown', function(evt) {
  6343. //typeahead is open and an "interesting" key was pressed
  6344. if (scope.matches.length === 0 || HOT_KEYS.indexOf(evt.which) === -1) {
  6345. return;
  6346. }
  6347. // if there's nothing selected (i.e. focusFirst) and enter or tab is hit, clear the results
  6348. if (scope.activeIdx === -1 && (evt.which === 9 || evt.which === 13)) {
  6349. resetMatches();
  6350. scope.$digest();
  6351. return;
  6352. }
  6353. evt.preventDefault();
  6354. if (evt.which === 40) {
  6355. scope.activeIdx = (scope.activeIdx + 1) % scope.matches.length;
  6356. scope.$digest();
  6357. } else if (evt.which === 38) {
  6358. scope.activeIdx = (scope.activeIdx > 0 ? scope.activeIdx : scope.matches.length) - 1;
  6359. scope.$digest();
  6360. } else if (evt.which === 13 || evt.which === 9) {
  6361. scope.$apply(function () {
  6362. scope.select(scope.activeIdx);
  6363. });
  6364. } else if (evt.which === 27) {
  6365. evt.stopPropagation();
  6366. resetMatches();
  6367. scope.$digest();
  6368. }
  6369. });
  6370. element.bind('blur', function() {
  6371. if (isSelectOnBlur && scope.matches.length && scope.activeIdx !== -1 && !selected) {
  6372. selected = true;
  6373. scope.$apply(function() {
  6374. scope.select(scope.activeIdx);
  6375. });
  6376. }
  6377. hasFocus = false;
  6378. selected = false;
  6379. });
  6380. // Keep reference to click handler to unbind it.
  6381. var dismissClickHandler = function(evt) {
  6382. // Issue #3973
  6383. // Firefox treats right click as a click on document
  6384. if (element[0] !== evt.target && evt.which !== 3 && scope.matches.length !== 0) {
  6385. resetMatches();
  6386. if (!$rootScope.$$phase) {
  6387. scope.$digest();
  6388. }
  6389. }
  6390. };
  6391. $document.bind('click', dismissClickHandler);
  6392. originalScope.$on('$destroy', function() {
  6393. $document.unbind('click', dismissClickHandler);
  6394. if (appendToBody || appendToElementId) {
  6395. $popup.remove();
  6396. }
  6397. if (appendToBody) {
  6398. angular.element($window).unbind('resize', fireRecalculating);
  6399. $document.find('body').unbind('scroll', fireRecalculating);
  6400. }
  6401. // Prevent jQuery cache memory leak
  6402. popUpEl.remove();
  6403. });
  6404. var $popup = $compile(popUpEl)(scope);
  6405. if (appendToBody) {
  6406. $document.find('body').append($popup);
  6407. } else if (appendToElementId !== false) {
  6408. angular.element($document[0].getElementById(appendToElementId)).append($popup);
  6409. } else {
  6410. element.after($popup);
  6411. }
  6412. this.init = function(_modelCtrl, _ngModelOptions) {
  6413. modelCtrl = _modelCtrl;
  6414. ngModelOptions = _ngModelOptions;
  6415. //plug into $parsers pipeline to open a typeahead on view changes initiated from DOM
  6416. //$parsers kick-in on all the changes coming from the view as well as manually triggered by $setViewValue
  6417. modelCtrl.$parsers.unshift(function(inputValue) {
  6418. hasFocus = true;
  6419. if (minLength === 0 || inputValue && inputValue.length >= minLength) {
  6420. if (waitTime > 0) {
  6421. cancelPreviousTimeout();
  6422. scheduleSearchWithTimeout(inputValue);
  6423. } else {
  6424. getMatchesAsync(inputValue);
  6425. }
  6426. } else {
  6427. isLoadingSetter(originalScope, false);
  6428. cancelPreviousTimeout();
  6429. resetMatches();
  6430. }
  6431. if (isEditable) {
  6432. return inputValue;
  6433. } else {
  6434. if (!inputValue) {
  6435. // Reset in case user had typed something previously.
  6436. modelCtrl.$setValidity('editable', true);
  6437. return null;
  6438. } else {
  6439. modelCtrl.$setValidity('editable', false);
  6440. return undefined;
  6441. }
  6442. }
  6443. });
  6444. modelCtrl.$formatters.push(function(modelValue) {
  6445. var candidateViewValue, emptyViewValue;
  6446. var locals = {};
  6447. // The validity may be set to false via $parsers (see above) if
  6448. // the model is restricted to selected values. If the model
  6449. // is set manually it is considered to be valid.
  6450. if (!isEditable) {
  6451. modelCtrl.$setValidity('editable', true);
  6452. }
  6453. if (inputFormatter) {
  6454. locals.$model = modelValue;
  6455. return inputFormatter(originalScope, locals);
  6456. } else {
  6457. //it might happen that we don't have enough info to properly render input value
  6458. //we need to check for this situation and simply return model value if we can't apply custom formatting
  6459. locals[parserResult.itemName] = modelValue;
  6460. candidateViewValue = parserResult.viewMapper(originalScope, locals);
  6461. locals[parserResult.itemName] = undefined;
  6462. emptyViewValue = parserResult.viewMapper(originalScope, locals);
  6463. return candidateViewValue !== emptyViewValue ? candidateViewValue : modelValue;
  6464. }
  6465. });
  6466. };
  6467. }])
  6468. .directive('uibTypeahead', function() {
  6469. return {
  6470. controller: 'UibTypeaheadController',
  6471. require: ['ngModel', '^?ngModelOptions', 'uibTypeahead'],
  6472. link: function(originalScope, element, attrs, ctrls) {
  6473. ctrls[2].init(ctrls[0], ctrls[1]);
  6474. }
  6475. };
  6476. })
  6477. .directive('uibTypeaheadPopup', function() {
  6478. return {
  6479. scope: {
  6480. matches: '=',
  6481. query: '=',
  6482. active: '=',
  6483. position: '&',
  6484. moveInProgress: '=',
  6485. select: '&'
  6486. },
  6487. replace: true,
  6488. templateUrl: function(element, attrs) {
  6489. return attrs.popupTemplateUrl || 'template/typeahead/typeahead-popup.html';
  6490. },
  6491. link: function(scope, element, attrs) {
  6492. scope.templateUrl = attrs.templateUrl;
  6493. scope.isOpen = function() {
  6494. return scope.matches.length > 0;
  6495. };
  6496. scope.isActive = function(matchIdx) {
  6497. return scope.active == matchIdx;
  6498. };
  6499. scope.selectActive = function(matchIdx) {
  6500. scope.active = matchIdx;
  6501. };
  6502. scope.selectMatch = function(activeIdx) {
  6503. scope.select({activeIdx:activeIdx});
  6504. };
  6505. }
  6506. };
  6507. })
  6508. .directive('uibTypeaheadMatch', ['$templateRequest', '$compile', '$parse', function($templateRequest, $compile, $parse) {
  6509. return {
  6510. scope: {
  6511. index: '=',
  6512. match: '=',
  6513. query: '='
  6514. },
  6515. link:function(scope, element, attrs) {
  6516. var tplUrl = $parse(attrs.templateUrl)(scope.$parent) || 'template/typeahead/typeahead-match.html';
  6517. $templateRequest(tplUrl).then(function(tplContent) {
  6518. $compile(tplContent.trim())(scope, function(clonedElement) {
  6519. element.replaceWith(clonedElement);
  6520. });
  6521. });
  6522. }
  6523. };
  6524. }])
  6525. .filter('uibTypeaheadHighlight', ['$sce', '$injector', '$log', function($sce, $injector, $log) {
  6526. var isSanitizePresent;
  6527. isSanitizePresent = $injector.has('$sanitize');
  6528. function escapeRegexp(queryToEscape) {
  6529. // Regex: capture the whole query string and replace it with the string that will be used to match
  6530. // the results, for example if the capture is "a" the result will be \a
  6531. return queryToEscape.replace(/([.?*+^$[\]\\(){}|-])/g, '\\$1');
  6532. }
  6533. function containsHtml(matchItem) {
  6534. return /<.*>/g.test(matchItem);
  6535. }
  6536. return function(matchItem, query) {
  6537. if (!isSanitizePresent && containsHtml(matchItem)) {
  6538. $log.warn('Unsafe use of typeahead please use ngSanitize'); // Warn the user about the danger
  6539. }
  6540. matchItem = query? ('' + matchItem).replace(new RegExp(escapeRegexp(query), 'gi'), '<strong>$&</strong>') : matchItem; // Replaces the capture string with a the same string inside of a "strong" tag
  6541. if (!isSanitizePresent) {
  6542. matchItem = $sce.trustAsHtml(matchItem); // If $sanitize is not present we pack the string in a $sce object for the ng-bind-html directive
  6543. }
  6544. return matchItem;
  6545. };
  6546. }]);
  6547. /* Deprecated typeahead below */
  6548. angular.module('ui.bootstrap.typeahead')
  6549. .value('$typeaheadSuppressWarning', false)
  6550. .service('typeaheadParser', ['$parse', 'uibTypeaheadParser', '$log', '$typeaheadSuppressWarning', function($parse, uibTypeaheadParser, $log, $typeaheadSuppressWarning) {
  6551. if (!$typeaheadSuppressWarning) {
  6552. $log.warn('typeaheadParser is now deprecated. Use uibTypeaheadParser instead.');
  6553. }
  6554. return uibTypeaheadParser;
  6555. }])
  6556. .directive('typeahead', ['$compile', '$parse', '$q', '$timeout', '$document', '$window', '$rootScope', '$uibPosition', 'typeaheadParser', '$log', '$typeaheadSuppressWarning',
  6557. function($compile, $parse, $q, $timeout, $document, $window, $rootScope, $position, typeaheadParser, $log, $typeaheadSuppressWarning) {
  6558. var HOT_KEYS = [9, 13, 27, 38, 40];
  6559. var eventDebounceTime = 200;
  6560. return {
  6561. require: ['ngModel', '^?ngModelOptions'],
  6562. link: function(originalScope, element, attrs, ctrls) {
  6563. if (!$typeaheadSuppressWarning) {
  6564. $log.warn('typeahead is now deprecated. Use uib-typeahead instead.');
  6565. }
  6566. var modelCtrl = ctrls[0];
  6567. var ngModelOptions = ctrls[1];
  6568. //SUPPORTED ATTRIBUTES (OPTIONS)
  6569. //minimal no of characters that needs to be entered before typeahead kicks-in
  6570. var minLength = originalScope.$eval(attrs.typeaheadMinLength);
  6571. if (!minLength && minLength !== 0) {
  6572. minLength = 1;
  6573. }
  6574. //minimal wait time after last character typed before typeahead kicks-in
  6575. var waitTime = originalScope.$eval(attrs.typeaheadWaitMs) || 0;
  6576. //should it restrict model values to the ones selected from the popup only?
  6577. var isEditable = originalScope.$eval(attrs.typeaheadEditable) !== false;
  6578. //binding to a variable that indicates if matches are being retrieved asynchronously
  6579. var isLoadingSetter = $parse(attrs.typeaheadLoading).assign || angular.noop;
  6580. //a callback executed when a match is selected
  6581. var onSelectCallback = $parse(attrs.typeaheadOnSelect);
  6582. //should it select highlighted popup value when losing focus?
  6583. var isSelectOnBlur = angular.isDefined(attrs.typeaheadSelectOnBlur) ? originalScope.$eval(attrs.typeaheadSelectOnBlur) : false;
  6584. //binding to a variable that indicates if there were no results after the query is completed
  6585. var isNoResultsSetter = $parse(attrs.typeaheadNoResults).assign || angular.noop;
  6586. var inputFormatter = attrs.typeaheadInputFormatter ? $parse(attrs.typeaheadInputFormatter) : undefined;
  6587. var appendToBody = attrs.typeaheadAppendToBody ? originalScope.$eval(attrs.typeaheadAppendToBody) : false;
  6588. var appendToElementId = attrs.typeaheadAppendToElementId || false;
  6589. var focusFirst = originalScope.$eval(attrs.typeaheadFocusFirst) !== false;
  6590. //If input matches an item of the list exactly, select it automatically
  6591. var selectOnExact = attrs.typeaheadSelectOnExact ? originalScope.$eval(attrs.typeaheadSelectOnExact) : false;
  6592. //INTERNAL VARIABLES
  6593. //model setter executed upon match selection
  6594. var parsedModel = $parse(attrs.ngModel);
  6595. var invokeModelSetter = $parse(attrs.ngModel + '($$$p)');
  6596. var $setModelValue = function(scope, newValue) {
  6597. if (angular.isFunction(parsedModel(originalScope)) &&
  6598. ngModelOptions && ngModelOptions.$options && ngModelOptions.$options.getterSetter) {
  6599. return invokeModelSetter(scope, {$$$p: newValue});
  6600. } else {
  6601. return parsedModel.assign(scope, newValue);
  6602. }
  6603. };
  6604. //expressions used by typeahead
  6605. var parserResult = typeaheadParser.parse(attrs.typeahead);
  6606. var hasFocus;
  6607. //Used to avoid bug in iOS webview where iOS keyboard does not fire
  6608. //mousedown & mouseup events
  6609. //Issue #3699
  6610. var selected;
  6611. //create a child scope for the typeahead directive so we are not polluting original scope
  6612. //with typeahead-specific data (matches, query etc.)
  6613. var scope = originalScope.$new();
  6614. var offDestroy = originalScope.$on('$destroy', function() {
  6615. scope.$destroy();
  6616. });
  6617. scope.$on('$destroy', offDestroy);
  6618. // WAI-ARIA
  6619. var popupId = 'typeahead-' + scope.$id + '-' + Math.floor(Math.random() * 10000);
  6620. element.attr({
  6621. 'aria-autocomplete': 'list',
  6622. 'aria-expanded': false,
  6623. 'aria-owns': popupId
  6624. });
  6625. //pop-up element used to display matches
  6626. var popUpEl = angular.element('<div typeahead-popup></div>');
  6627. popUpEl.attr({
  6628. id: popupId,
  6629. matches: 'matches',
  6630. active: 'activeIdx',
  6631. select: 'select(activeIdx)',
  6632. 'move-in-progress': 'moveInProgress',
  6633. query: 'query',
  6634. position: 'position'
  6635. });
  6636. //custom item template
  6637. if (angular.isDefined(attrs.typeaheadTemplateUrl)) {
  6638. popUpEl.attr('template-url', attrs.typeaheadTemplateUrl);
  6639. }
  6640. if (angular.isDefined(attrs.typeaheadPopupTemplateUrl)) {
  6641. popUpEl.attr('popup-template-url', attrs.typeaheadPopupTemplateUrl);
  6642. }
  6643. var resetMatches = function() {
  6644. scope.matches = [];
  6645. scope.activeIdx = -1;
  6646. element.attr('aria-expanded', false);
  6647. };
  6648. var getMatchId = function(index) {
  6649. return popupId + '-option-' + index;
  6650. };
  6651. // Indicate that the specified match is the active (pre-selected) item in the list owned by this typeahead.
  6652. // This attribute is added or removed automatically when the `activeIdx` changes.
  6653. scope.$watch('activeIdx', function(index) {
  6654. if (index < 0) {
  6655. element.removeAttr('aria-activedescendant');
  6656. } else {
  6657. element.attr('aria-activedescendant', getMatchId(index));
  6658. }
  6659. });
  6660. var inputIsExactMatch = function(inputValue, index) {
  6661. if (scope.matches.length > index && inputValue) {
  6662. return inputValue.toUpperCase() === scope.matches[index].label.toUpperCase();
  6663. }
  6664. return false;
  6665. };
  6666. var getMatchesAsync = function(inputValue) {
  6667. var locals = {$viewValue: inputValue};
  6668. isLoadingSetter(originalScope, true);
  6669. isNoResultsSetter(originalScope, false);
  6670. $q.when(parserResult.source(originalScope, locals)).then(function(matches) {
  6671. //it might happen that several async queries were in progress if a user were typing fast
  6672. //but we are interested only in responses that correspond to the current view value
  6673. var onCurrentRequest = (inputValue === modelCtrl.$viewValue);
  6674. if (onCurrentRequest && hasFocus) {
  6675. if (matches && matches.length > 0) {
  6676. scope.activeIdx = focusFirst ? 0 : -1;
  6677. isNoResultsSetter(originalScope, false);
  6678. scope.matches.length = 0;
  6679. //transform labels
  6680. for (var i = 0; i < matches.length; i++) {
  6681. locals[parserResult.itemName] = matches[i];
  6682. scope.matches.push({
  6683. id: getMatchId(i),
  6684. label: parserResult.viewMapper(scope, locals),
  6685. model: matches[i]
  6686. });
  6687. }
  6688. scope.query = inputValue;
  6689. //position pop-up with matches - we need to re-calculate its position each time we are opening a window
  6690. //with matches as a pop-up might be absolute-positioned and position of an input might have changed on a page
  6691. //due to other elements being rendered
  6692. recalculatePosition();
  6693. element.attr('aria-expanded', true);
  6694. //Select the single remaining option if user input matches
  6695. if (selectOnExact && scope.matches.length === 1 && inputIsExactMatch(inputValue, 0)) {
  6696. scope.select(0);
  6697. }
  6698. } else {
  6699. resetMatches();
  6700. isNoResultsSetter(originalScope, true);
  6701. }
  6702. }
  6703. if (onCurrentRequest) {
  6704. isLoadingSetter(originalScope, false);
  6705. }
  6706. }, function() {
  6707. resetMatches();
  6708. isLoadingSetter(originalScope, false);
  6709. isNoResultsSetter(originalScope, true);
  6710. });
  6711. };
  6712. // bind events only if appendToBody params exist - performance feature
  6713. if (appendToBody) {
  6714. angular.element($window).bind('resize', fireRecalculating);
  6715. $document.find('body').bind('scroll', fireRecalculating);
  6716. }
  6717. // Declare the timeout promise var outside the function scope so that stacked calls can be cancelled later
  6718. var timeoutEventPromise;
  6719. // Default progress type
  6720. scope.moveInProgress = false;
  6721. function fireRecalculating() {
  6722. if (!scope.moveInProgress) {
  6723. scope.moveInProgress = true;
  6724. scope.$digest();
  6725. }
  6726. // Cancel previous timeout
  6727. if (timeoutEventPromise) {
  6728. $timeout.cancel(timeoutEventPromise);
  6729. }
  6730. // Debounced executing recalculate after events fired
  6731. timeoutEventPromise = $timeout(function() {
  6732. // if popup is visible
  6733. if (scope.matches.length) {
  6734. recalculatePosition();
  6735. }
  6736. scope.moveInProgress = false;
  6737. }, eventDebounceTime);
  6738. }
  6739. // recalculate actual position and set new values to scope
  6740. // after digest loop is popup in right position
  6741. function recalculatePosition() {
  6742. scope.position = appendToBody ? $position.offset(element) : $position.position(element);
  6743. scope.position.top += element.prop('offsetHeight');
  6744. }
  6745. resetMatches();
  6746. //we need to propagate user's query so we can higlight matches
  6747. scope.query = undefined;
  6748. //Declare the timeout promise var outside the function scope so that stacked calls can be cancelled later
  6749. var timeoutPromise;
  6750. var scheduleSearchWithTimeout = function(inputValue) {
  6751. timeoutPromise = $timeout(function() {
  6752. getMatchesAsync(inputValue);
  6753. }, waitTime);
  6754. };
  6755. var cancelPreviousTimeout = function() {
  6756. if (timeoutPromise) {
  6757. $timeout.cancel(timeoutPromise);
  6758. }
  6759. };
  6760. //plug into $parsers pipeline to open a typeahead on view changes initiated from DOM
  6761. //$parsers kick-in on all the changes coming from the view as well as manually triggered by $setViewValue
  6762. modelCtrl.$parsers.unshift(function(inputValue) {
  6763. hasFocus = true;
  6764. if (minLength === 0 || inputValue && inputValue.length >= minLength) {
  6765. if (waitTime > 0) {
  6766. cancelPreviousTimeout();
  6767. scheduleSearchWithTimeout(inputValue);
  6768. } else {
  6769. getMatchesAsync(inputValue);
  6770. }
  6771. } else {
  6772. isLoadingSetter(originalScope, false);
  6773. cancelPreviousTimeout();
  6774. resetMatches();
  6775. }
  6776. if (isEditable) {
  6777. return inputValue;
  6778. } else {
  6779. if (!inputValue) {
  6780. // Reset in case user had typed something previously.
  6781. modelCtrl.$setValidity('editable', true);
  6782. return null;
  6783. } else {
  6784. modelCtrl.$setValidity('editable', false);
  6785. return undefined;
  6786. }
  6787. }
  6788. });
  6789. modelCtrl.$formatters.push(function(modelValue) {
  6790. var candidateViewValue, emptyViewValue;
  6791. var locals = {};
  6792. // The validity may be set to false via $parsers (see above) if
  6793. // the model is restricted to selected values. If the model
  6794. // is set manually it is considered to be valid.
  6795. if (!isEditable) {
  6796. modelCtrl.$setValidity('editable', true);
  6797. }
  6798. if (inputFormatter) {
  6799. locals.$model = modelValue;
  6800. return inputFormatter(originalScope, locals);
  6801. } else {
  6802. //it might happen that we don't have enough info to properly render input value
  6803. //we need to check for this situation and simply return model value if we can't apply custom formatting
  6804. locals[parserResult.itemName] = modelValue;
  6805. candidateViewValue = parserResult.viewMapper(originalScope, locals);
  6806. locals[parserResult.itemName] = undefined;
  6807. emptyViewValue = parserResult.viewMapper(originalScope, locals);
  6808. return candidateViewValue !== emptyViewValue ? candidateViewValue : modelValue;
  6809. }
  6810. });
  6811. scope.select = function(activeIdx) {
  6812. //called from within the $digest() cycle
  6813. var locals = {};
  6814. var model, item;
  6815. selected = true;
  6816. locals[parserResult.itemName] = item = scope.matches[activeIdx].model;
  6817. model = parserResult.modelMapper(originalScope, locals);
  6818. $setModelValue(originalScope, model);
  6819. modelCtrl.$setValidity('editable', true);
  6820. modelCtrl.$setValidity('parse', true);
  6821. onSelectCallback(originalScope, {
  6822. $item: item,
  6823. $model: model,
  6824. $label: parserResult.viewMapper(originalScope, locals)
  6825. });
  6826. resetMatches();
  6827. //return focus to the input element if a match was selected via a mouse click event
  6828. // use timeout to avoid $rootScope:inprog error
  6829. if (scope.$eval(attrs.typeaheadFocusOnSelect) !== false) {
  6830. $timeout(function() { element[0].focus(); }, 0, false);
  6831. }
  6832. };
  6833. //bind keyboard events: arrows up(38) / down(40), enter(13) and tab(9), esc(27)
  6834. element.bind('keydown', function(evt) {
  6835. //typeahead is open and an "interesting" key was pressed
  6836. if (scope.matches.length === 0 || HOT_KEYS.indexOf(evt.which) === -1) {
  6837. return;
  6838. }
  6839. // if there's nothing selected (i.e. focusFirst) and enter or tab is hit, clear the results
  6840. if (scope.activeIdx === -1 && (evt.which === 9 || evt.which === 13)) {
  6841. resetMatches();
  6842. scope.$digest();
  6843. return;
  6844. }
  6845. evt.preventDefault();
  6846. if (evt.which === 40) {
  6847. scope.activeIdx = (scope.activeIdx + 1) % scope.matches.length;
  6848. scope.$digest();
  6849. } else if (evt.which === 38) {
  6850. scope.activeIdx = (scope.activeIdx > 0 ? scope.activeIdx : scope.matches.length) - 1;
  6851. scope.$digest();
  6852. } else if (evt.which === 13 || evt.which === 9) {
  6853. scope.$apply(function () {
  6854. scope.select(scope.activeIdx);
  6855. });
  6856. } else if (evt.which === 27) {
  6857. evt.stopPropagation();
  6858. resetMatches();
  6859. scope.$digest();
  6860. }
  6861. });
  6862. element.bind('blur', function() {
  6863. if (isSelectOnBlur && scope.matches.length && scope.activeIdx !== -1 && !selected) {
  6864. selected = true;
  6865. scope.$apply(function() {
  6866. scope.select(scope.activeIdx);
  6867. });
  6868. }
  6869. hasFocus = false;
  6870. selected = false;
  6871. });
  6872. // Keep reference to click handler to unbind it.
  6873. var dismissClickHandler = function(evt) {
  6874. // Issue #3973
  6875. // Firefox treats right click as a click on document
  6876. if (element[0] !== evt.target && evt.which !== 3 && scope.matches.length !== 0) {
  6877. resetMatches();
  6878. if (!$rootScope.$$phase) {
  6879. scope.$digest();
  6880. }
  6881. }
  6882. };
  6883. $document.bind('click', dismissClickHandler);
  6884. originalScope.$on('$destroy', function() {
  6885. $document.unbind('click', dismissClickHandler);
  6886. if (appendToBody || appendToElementId) {
  6887. $popup.remove();
  6888. }
  6889. if (appendToBody) {
  6890. angular.element($window).unbind('resize', fireRecalculating);
  6891. $document.find('body').unbind('scroll', fireRecalculating);
  6892. }
  6893. // Prevent jQuery cache memory leak
  6894. popUpEl.remove();
  6895. });
  6896. var $popup = $compile(popUpEl)(scope);
  6897. if (appendToBody) {
  6898. $document.find('body').append($popup);
  6899. } else if (appendToElementId !== false) {
  6900. angular.element($document[0].getElementById(appendToElementId)).append($popup);
  6901. } else {
  6902. element.after($popup);
  6903. }
  6904. }
  6905. };
  6906. }])
  6907. .directive('typeaheadPopup', ['$typeaheadSuppressWarning', '$log', function($typeaheadSuppressWarning, $log) {
  6908. return {
  6909. scope: {
  6910. matches: '=',
  6911. query: '=',
  6912. active: '=',
  6913. position: '&',
  6914. moveInProgress: '=',
  6915. select: '&'
  6916. },
  6917. replace: true,
  6918. templateUrl: function(element, attrs) {
  6919. return attrs.popupTemplateUrl || 'template/typeahead/typeahead-popup.html';
  6920. },
  6921. link: function(scope, element, attrs) {
  6922. if (!$typeaheadSuppressWarning) {
  6923. $log.warn('typeahead-popup is now deprecated. Use uib-typeahead-popup instead.');
  6924. }
  6925. scope.templateUrl = attrs.templateUrl;
  6926. scope.isOpen = function() {
  6927. return scope.matches.length > 0;
  6928. };
  6929. scope.isActive = function(matchIdx) {
  6930. return scope.active == matchIdx;
  6931. };
  6932. scope.selectActive = function(matchIdx) {
  6933. scope.active = matchIdx;
  6934. };
  6935. scope.selectMatch = function(activeIdx) {
  6936. scope.select({activeIdx:activeIdx});
  6937. };
  6938. }
  6939. };
  6940. }])
  6941. .directive('typeaheadMatch', ['$templateRequest', '$compile', '$parse', '$typeaheadSuppressWarning', '$log', function($templateRequest, $compile, $parse, $typeaheadSuppressWarning, $log) {
  6942. return {
  6943. restrict: 'EA',
  6944. scope: {
  6945. index: '=',
  6946. match: '=',
  6947. query: '='
  6948. },
  6949. link:function(scope, element, attrs) {
  6950. if (!$typeaheadSuppressWarning) {
  6951. $log.warn('typeahead-match is now deprecated. Use uib-typeahead-match instead.');
  6952. }
  6953. var tplUrl = $parse(attrs.templateUrl)(scope.$parent) || 'template/typeahead/typeahead-match.html';
  6954. $templateRequest(tplUrl).then(function(tplContent) {
  6955. $compile(tplContent.trim())(scope, function(clonedElement) {
  6956. element.replaceWith(clonedElement);
  6957. });
  6958. });
  6959. }
  6960. };
  6961. }])
  6962. .filter('typeaheadHighlight', ['$sce', '$injector', '$log', '$typeaheadSuppressWarning', function($sce, $injector, $log, $typeaheadSuppressWarning) {
  6963. var isSanitizePresent;
  6964. isSanitizePresent = $injector.has('$sanitize');
  6965. function escapeRegexp(queryToEscape) {
  6966. // Regex: capture the whole query string and replace it with the string that will be used to match
  6967. // the results, for example if the capture is "a" the result will be \a
  6968. return queryToEscape.replace(/([.?*+^$[\]\\(){}|-])/g, '\\$1');
  6969. }
  6970. function containsHtml(matchItem) {
  6971. return /<.*>/g.test(matchItem);
  6972. }
  6973. return function(matchItem, query) {
  6974. if (!$typeaheadSuppressWarning) {
  6975. $log.warn('typeaheadHighlight is now deprecated. Use uibTypeaheadHighlight instead.');
  6976. }
  6977. if (!isSanitizePresent && containsHtml(matchItem)) {
  6978. $log.warn('Unsafe use of typeahead please use ngSanitize'); // Warn the user about the danger
  6979. }
  6980. matchItem = query? ('' + matchItem).replace(new RegExp(escapeRegexp(query), 'gi'), '<strong>$&</strong>') : matchItem; // Replaces the capture string with a the same string inside of a "strong" tag
  6981. if (!isSanitizePresent) {
  6982. matchItem = $sce.trustAsHtml(matchItem); // If $sanitize is not present we pack the string in a $sce object for the ng-bind-html directive
  6983. }
  6984. return matchItem;
  6985. };
  6986. }]);
  6987. angular.module("template/accordion/accordion-group.html", []).run(["$templateCache", function($templateCache) {
  6988. $templateCache.put("template/accordion/accordion-group.html",
  6989. "<div class=\"panel {{panelClass || 'panel-default'}}\">\n" +
  6990. " <div class=\"panel-heading\" ng-keypress=\"toggleOpen($event)\">\n" +
  6991. " <h4 class=\"panel-title\">\n" +
  6992. " <a href tabindex=\"0\" class=\"accordion-toggle\" ng-click=\"toggleOpen()\" uib-accordion-transclude=\"heading\"><span ng-class=\"{'text-muted': isDisabled}\">{{heading}}</span></a>\n" +
  6993. " </h4>\n" +
  6994. " </div>\n" +
  6995. " <div class=\"panel-collapse collapse\" uib-collapse=\"!isOpen\">\n" +
  6996. " <div class=\"panel-body\" ng-transclude></div>\n" +
  6997. " </div>\n" +
  6998. "</div>\n" +
  6999. "");
  7000. }]);
  7001. angular.module("template/accordion/accordion.html", []).run(["$templateCache", function($templateCache) {
  7002. $templateCache.put("template/accordion/accordion.html",
  7003. "<div class=\"panel-group\" ng-transclude></div>");
  7004. }]);
  7005. angular.module("template/alert/alert.html", []).run(["$templateCache", function($templateCache) {
  7006. $templateCache.put("template/alert/alert.html",
  7007. "<div class=\"alert\" ng-class=\"['alert-' + (type || 'warning'), closeable ? 'alert-dismissible' : null]\" role=\"alert\">\n" +
  7008. " <button ng-show=\"closeable\" type=\"button\" class=\"close\" ng-click=\"close({$event: $event})\">\n" +
  7009. " <span aria-hidden=\"true\">&times;</span>\n" +
  7010. " <span class=\"sr-only\">Close</span>\n" +
  7011. " </button>\n" +
  7012. " <div ng-transclude></div>\n" +
  7013. "</div>\n" +
  7014. "");
  7015. }]);
  7016. angular.module("template/carousel/carousel.html", []).run(["$templateCache", function($templateCache) {
  7017. $templateCache.put("template/carousel/carousel.html",
  7018. "<div ng-mouseenter=\"pause()\" ng-mouseleave=\"play()\" class=\"carousel\" ng-swipe-right=\"prev()\" ng-swipe-left=\"next()\">\n" +
  7019. " <div class=\"carousel-inner\" ng-transclude></div>\n" +
  7020. " <a role=\"button\" href class=\"left carousel-control\" ng-click=\"prev()\" ng-show=\"slides.length > 1\">\n" +
  7021. " <span aria-hidden=\"true\" class=\"glyphicon glyphicon-chevron-left\"></span>\n" +
  7022. " <span class=\"sr-only\">previous</span>\n" +
  7023. " </a>\n" +
  7024. " <a role=\"button\" href class=\"right carousel-control\" ng-click=\"next()\" ng-show=\"slides.length > 1\">\n" +
  7025. " <span aria-hidden=\"true\" class=\"glyphicon glyphicon-chevron-right\"></span>\n" +
  7026. " <span class=\"sr-only\">next</span>\n" +
  7027. " </a>\n" +
  7028. " <ol class=\"carousel-indicators\" ng-show=\"slides.length > 1\">\n" +
  7029. " <li ng-repeat=\"slide in slides | orderBy:indexOfSlide track by $index\" ng-class=\"{ active: isActive(slide) }\" ng-click=\"select(slide)\">\n" +
  7030. " <span class=\"sr-only\">slide {{ $index + 1 }} of {{ slides.length }}<span ng-if=\"isActive(slide)\">, currently active</span></span>\n" +
  7031. " </li>\n" +
  7032. " </ol>\n" +
  7033. "</div>");
  7034. }]);
  7035. angular.module("template/carousel/slide.html", []).run(["$templateCache", function($templateCache) {
  7036. $templateCache.put("template/carousel/slide.html",
  7037. "<div ng-class=\"{\n" +
  7038. " 'active': active\n" +
  7039. " }\" class=\"item text-center\" ng-transclude></div>\n" +
  7040. "");
  7041. }]);
  7042. angular.module("template/datepicker/datepicker.html", []).run(["$templateCache", function($templateCache) {
  7043. $templateCache.put("template/datepicker/datepicker.html",
  7044. "<div ng-switch=\"datepickerMode\" role=\"application\" ng-keydown=\"keydown($event)\">\n" +
  7045. " <uib-daypicker ng-switch-when=\"day\" tabindex=\"0\"></uib-daypicker>\n" +
  7046. " <uib-monthpicker ng-switch-when=\"month\" tabindex=\"0\"></uib-monthpicker>\n" +
  7047. " <uib-yearpicker ng-switch-when=\"year\" tabindex=\"0\"></uib-yearpicker>\n" +
  7048. "</div>");
  7049. }]);
  7050. angular.module("template/datepicker/day.html", []).run(["$templateCache", function($templateCache) {
  7051. $templateCache.put("template/datepicker/day.html",
  7052. "<table role=\"grid\" aria-labelledby=\"{{::uniqueId}}-title\" aria-activedescendant=\"{{activeDateId}}\">\n" +
  7053. " <thead>\n" +
  7054. " <tr>\n" +
  7055. " <th><button type=\"button\" class=\"btn btn-default btn-sm pull-left\" ng-click=\"move(-1)\" tabindex=\"-1\"><i class=\"glyphicon glyphicon-chevron-left\"></i></button></th>\n" +
  7056. " <th colspan=\"{{::5 + showWeeks}}\"><button id=\"{{::uniqueId}}-title\" role=\"heading\" aria-live=\"assertive\" aria-atomic=\"true\" type=\"button\" class=\"btn btn-default btn-sm\" ng-click=\"toggleMode()\" ng-disabled=\"datepickerMode === maxMode\" tabindex=\"-1\" style=\"width:100%;\"><strong>{{title}}</strong></button></th>\n" +
  7057. " <th><button type=\"button\" class=\"btn btn-default btn-sm pull-right\" ng-click=\"move(1)\" tabindex=\"-1\"><i class=\"glyphicon glyphicon-chevron-right\"></i></button></th>\n" +
  7058. " </tr>\n" +
  7059. " <tr>\n" +
  7060. " <th ng-if=\"showWeeks\" class=\"text-center\"></th>\n" +
  7061. " <th ng-repeat=\"label in ::labels track by $index\" class=\"text-center\"><small aria-label=\"{{::label.full}}\">{{::label.abbr}}</small></th>\n" +
  7062. " </tr>\n" +
  7063. " </thead>\n" +
  7064. " <tbody>\n" +
  7065. " <tr ng-repeat=\"row in rows track by $index\">\n" +
  7066. " <td ng-if=\"showWeeks\" class=\"text-center h6\"><em>{{ weekNumbers[$index] }}</em></td>\n" +
  7067. " <td ng-repeat=\"dt in row track by dt.date\" class=\"text-center\" role=\"gridcell\" id=\"{{::dt.uid}}\" ng-class=\"::dt.customClass\">\n" +
  7068. " <button type=\"button\" style=\"min-width:100%;\" class=\"btn btn-default btn-sm\" ng-class=\"{'btn-info': dt.selected, active: isActive(dt)}\" ng-click=\"select(dt.date)\" ng-disabled=\"dt.disabled\" tabindex=\"-1\"><span ng-class=\"::{'text-muted': dt.secondary, 'text-info': dt.current}\">{{::dt.label}}</span></button>\n" +
  7069. " </td>\n" +
  7070. " </tr>\n" +
  7071. " </tbody>\n" +
  7072. "</table>\n" +
  7073. "");
  7074. }]);
  7075. angular.module("template/datepicker/month.html", []).run(["$templateCache", function($templateCache) {
  7076. $templateCache.put("template/datepicker/month.html",
  7077. "<table role=\"grid\" aria-labelledby=\"{{::uniqueId}}-title\" aria-activedescendant=\"{{activeDateId}}\">\n" +
  7078. " <thead>\n" +
  7079. " <tr>\n" +
  7080. " <th><button type=\"button\" class=\"btn btn-default btn-sm pull-left\" ng-click=\"move(-1)\" tabindex=\"-1\"><i class=\"glyphicon glyphicon-chevron-left\"></i></button></th>\n" +
  7081. " <th><button id=\"{{::uniqueId}}-title\" role=\"heading\" aria-live=\"assertive\" aria-atomic=\"true\" type=\"button\" class=\"btn btn-default btn-sm\" ng-click=\"toggleMode()\" ng-disabled=\"datepickerMode === maxMode\" tabindex=\"-1\" style=\"width:100%;\"><strong>{{title}}</strong></button></th>\n" +
  7082. " <th><button type=\"button\" class=\"btn btn-default btn-sm pull-right\" ng-click=\"move(1)\" tabindex=\"-1\"><i class=\"glyphicon glyphicon-chevron-right\"></i></button></th>\n" +
  7083. " </tr>\n" +
  7084. " </thead>\n" +
  7085. " <tbody>\n" +
  7086. " <tr ng-repeat=\"row in rows track by $index\">\n" +
  7087. " <td ng-repeat=\"dt in row track by dt.date\" class=\"text-center\" role=\"gridcell\" id=\"{{::dt.uid}}\" ng-class=\"::dt.customClass\">\n" +
  7088. " <button type=\"button\" style=\"min-width:100%;\" class=\"btn btn-default\" ng-class=\"{'btn-info': dt.selected, active: isActive(dt)}\" ng-click=\"select(dt.date)\" ng-disabled=\"dt.disabled\" tabindex=\"-1\"><span ng-class=\"::{'text-info': dt.current}\">{{::dt.label}}</span></button>\n" +
  7089. " </td>\n" +
  7090. " </tr>\n" +
  7091. " </tbody>\n" +
  7092. "</table>\n" +
  7093. "");
  7094. }]);
  7095. angular.module("template/datepicker/popup.html", []).run(["$templateCache", function($templateCache) {
  7096. $templateCache.put("template/datepicker/popup.html",
  7097. "<ul class=\"dropdown-menu\" dropdown-nested ng-if=\"isOpen\" style=\"display: block\" ng-style=\"{top: position.top+'px', left: position.left+'px'}\" ng-keydown=\"keydown($event)\" ng-click=\"$event.stopPropagation()\">\n" +
  7098. " <li ng-transclude></li>\n" +
  7099. " <li ng-if=\"showButtonBar\" style=\"padding:10px 9px 2px\">\n" +
  7100. " <span class=\"btn-group pull-left\">\n" +
  7101. " <button type=\"button\" class=\"btn btn-sm btn-info\" ng-click=\"select('today')\" ng-disabled=\"isDisabled('today')\">{{ getText('current') }}</button>\n" +
  7102. " <button type=\"button\" class=\"btn btn-sm btn-danger\" ng-click=\"select(null)\">{{ getText('clear') }}</button>\n" +
  7103. " </span>\n" +
  7104. " <button type=\"button\" class=\"btn btn-sm btn-success pull-right\" ng-click=\"close()\">{{ getText('close') }}</button>\n" +
  7105. " </li>\n" +
  7106. "</ul>\n" +
  7107. "");
  7108. }]);
  7109. angular.module("template/datepicker/year.html", []).run(["$templateCache", function($templateCache) {
  7110. $templateCache.put("template/datepicker/year.html",
  7111. "<table role=\"grid\" aria-labelledby=\"{{::uniqueId}}-title\" aria-activedescendant=\"{{activeDateId}}\">\n" +
  7112. " <thead>\n" +
  7113. " <tr>\n" +
  7114. " <th><button type=\"button\" class=\"btn btn-default btn-sm pull-left\" ng-click=\"move(-1)\" tabindex=\"-1\"><i class=\"glyphicon glyphicon-chevron-left\"></i></button></th>\n" +
  7115. " <th colspan=\"3\"><button id=\"{{::uniqueId}}-title\" role=\"heading\" aria-live=\"assertive\" aria-atomic=\"true\" type=\"button\" class=\"btn btn-default btn-sm\" ng-click=\"toggleMode()\" ng-disabled=\"datepickerMode === maxMode\" tabindex=\"-1\" style=\"width:100%;\"><strong>{{title}}</strong></button></th>\n" +
  7116. " <th><button type=\"button\" class=\"btn btn-default btn-sm pull-right\" ng-click=\"move(1)\" tabindex=\"-1\"><i class=\"glyphicon glyphicon-chevron-right\"></i></button></th>\n" +
  7117. " </tr>\n" +
  7118. " </thead>\n" +
  7119. " <tbody>\n" +
  7120. " <tr ng-repeat=\"row in rows track by $index\">\n" +
  7121. " <td ng-repeat=\"dt in row track by dt.date\" class=\"text-center\" role=\"gridcell\" id=\"{{::dt.uid}}\" ng-class=\"::dt.customClass\">\n" +
  7122. " <button type=\"button\" style=\"min-width:100%;\" class=\"btn btn-default\" ng-class=\"{'btn-info': dt.selected, active: isActive(dt)}\" ng-click=\"select(dt.date)\" ng-disabled=\"dt.disabled\" tabindex=\"-1\"><span ng-class=\"::{'text-info': dt.current}\">{{::dt.label}}</span></button>\n" +
  7123. " </td>\n" +
  7124. " </tr>\n" +
  7125. " </tbody>\n" +
  7126. "</table>\n" +
  7127. "");
  7128. }]);
  7129. angular.module("template/modal/backdrop.html", []).run(["$templateCache", function($templateCache) {
  7130. $templateCache.put("template/modal/backdrop.html",
  7131. "<div uib-modal-animation-class=\"fade\"\n" +
  7132. " modal-in-class=\"in\"\n" +
  7133. " ng-style=\"{'z-index': 1040 + (index && 1 || 0) + index*10}\"\n" +
  7134. "></div>\n" +
  7135. "");
  7136. }]);
  7137. angular.module("template/modal/window.html", []).run(["$templateCache", function($templateCache) {
  7138. $templateCache.put("template/modal/window.html",
  7139. "<div modal-render=\"{{$isRendered}}\" tabindex=\"-1\" role=\"dialog\" class=\"modal\"\n" +
  7140. " uib-modal-animation-class=\"fade\"\n" +
  7141. " modal-in-class=\"in\"\n" +
  7142. " ng-style=\"{'z-index': 1050 + index*10, display: 'block'}\">\n" +
  7143. " <div class=\"modal-dialog\" ng-class=\"size ? 'modal-' + size : ''\"><div class=\"modal-content\" uib-modal-transclude></div></div>\n" +
  7144. "</div>\n" +
  7145. "");
  7146. }]);
  7147. angular.module("template/pagination/pager.html", []).run(["$templateCache", function($templateCache) {
  7148. $templateCache.put("template/pagination/pager.html",
  7149. "<ul class=\"pager\">\n" +
  7150. " <li ng-class=\"{disabled: noPrevious()||ngDisabled, previous: align}\"><a href ng-click=\"selectPage(page - 1, $event)\">{{::getText('previous')}}</a></li>\n" +
  7151. " <li ng-class=\"{disabled: noNext()||ngDisabled, next: align}\"><a href ng-click=\"selectPage(page + 1, $event)\">{{::getText('next')}}</a></li>\n" +
  7152. "</ul>\n" +
  7153. "");
  7154. }]);
  7155. angular.module("template/pagination/pagination.html", []).run(["$templateCache", function($templateCache) {
  7156. $templateCache.put("template/pagination/pagination.html",
  7157. "<ul class=\"pagination\">\n" +
  7158. " <li ng-if=\"::boundaryLinks\" ng-class=\"{disabled: noPrevious()||ngDisabled}\" class=\"pagination-first\"><a href ng-click=\"selectPage(1, $event)\">{{::getText('first')}}</a></li>\n" +
  7159. " <li ng-if=\"::directionLinks\" ng-class=\"{disabled: noPrevious()||ngDisabled}\" class=\"pagination-prev\"><a href ng-click=\"selectPage(page - 1, $event)\">{{::getText('previous')}}</a></li>\n" +
  7160. " <li ng-repeat=\"page in pages track by $index\" ng-class=\"{active: page.active,disabled: ngDisabled&&!page.active}\" class=\"pagination-page\"><a href ng-click=\"selectPage(page.number, $event)\">{{page.text}}</a></li>\n" +
  7161. " <li ng-if=\"::directionLinks\" ng-class=\"{disabled: noNext()||ngDisabled}\" class=\"pagination-next\"><a href ng-click=\"selectPage(page + 1, $event)\">{{::getText('next')}}</a></li>\n" +
  7162. " <li ng-if=\"::boundaryLinks\" ng-class=\"{disabled: noNext()||ngDisabled}\" class=\"pagination-last\"><a href ng-click=\"selectPage(totalPages, $event)\">{{::getText('last')}}</a></li>\n" +
  7163. "</ul>\n" +
  7164. "");
  7165. }]);
  7166. angular.module("template/tooltip/tooltip-html-popup.html", []).run(["$templateCache", function($templateCache) {
  7167. $templateCache.put("template/tooltip/tooltip-html-popup.html",
  7168. "<div\n" +
  7169. " tooltip-animation-class=\"fade\"\n" +
  7170. " uib-tooltip-classes\n" +
  7171. " ng-class=\"{ in: isOpen() }\">\n" +
  7172. " <div class=\"tooltip-arrow\"></div>\n" +
  7173. " <div class=\"tooltip-inner\" ng-bind-html=\"contentExp()\"></div>\n" +
  7174. "</div>\n" +
  7175. "");
  7176. }]);
  7177. angular.module("template/tooltip/tooltip-popup.html", []).run(["$templateCache", function($templateCache) {
  7178. $templateCache.put("template/tooltip/tooltip-popup.html",
  7179. "<div\n" +
  7180. " tooltip-animation-class=\"fade\"\n" +
  7181. " uib-tooltip-classes\n" +
  7182. " ng-class=\"{ in: isOpen() }\">\n" +
  7183. " <div class=\"tooltip-arrow\"></div>\n" +
  7184. " <div class=\"tooltip-inner\" ng-bind=\"content\"></div>\n" +
  7185. "</div>\n" +
  7186. "");
  7187. }]);
  7188. angular.module("template/tooltip/tooltip-template-popup.html", []).run(["$templateCache", function($templateCache) {
  7189. $templateCache.put("template/tooltip/tooltip-template-popup.html",
  7190. "<div\n" +
  7191. " tooltip-animation-class=\"fade\"\n" +
  7192. " uib-tooltip-classes\n" +
  7193. " ng-class=\"{ in: isOpen() }\">\n" +
  7194. " <div class=\"tooltip-arrow\"></div>\n" +
  7195. " <div class=\"tooltip-inner\"\n" +
  7196. " uib-tooltip-template-transclude=\"contentExp()\"\n" +
  7197. " tooltip-template-transclude-scope=\"originScope()\"></div>\n" +
  7198. "</div>\n" +
  7199. "");
  7200. }]);
  7201. angular.module("template/popover/popover-html.html", []).run(["$templateCache", function($templateCache) {
  7202. $templateCache.put("template/popover/popover-html.html",
  7203. "<div tooltip-animation-class=\"fade\"\n" +
  7204. " uib-tooltip-classes\n" +
  7205. " ng-class=\"{ in: isOpen() }\">\n" +
  7206. " <div class=\"arrow\"></div>\n" +
  7207. "\n" +
  7208. " <div class=\"popover-inner\">\n" +
  7209. " <h3 class=\"popover-title\" ng-bind=\"title\" ng-if=\"title\"></h3>\n" +
  7210. " <div class=\"popover-content\" ng-bind-html=\"contentExp()\"></div>\n" +
  7211. " </div>\n" +
  7212. "</div>\n" +
  7213. "");
  7214. }]);
  7215. angular.module("template/popover/popover-template.html", []).run(["$templateCache", function($templateCache) {
  7216. $templateCache.put("template/popover/popover-template.html",
  7217. "<div tooltip-animation-class=\"fade\"\n" +
  7218. " uib-tooltip-classes\n" +
  7219. " ng-class=\"{ in: isOpen() }\">\n" +
  7220. " <div class=\"arrow\"></div>\n" +
  7221. "\n" +
  7222. " <div class=\"popover-inner\">\n" +
  7223. " <h3 class=\"popover-title\" ng-bind=\"title\" ng-if=\"title\"></h3>\n" +
  7224. " <div class=\"popover-content\"\n" +
  7225. " uib-tooltip-template-transclude=\"contentExp()\"\n" +
  7226. " tooltip-template-transclude-scope=\"originScope()\"></div>\n" +
  7227. " </div>\n" +
  7228. "</div>\n" +
  7229. "");
  7230. }]);
  7231. angular.module("template/popover/popover.html", []).run(["$templateCache", function($templateCache) {
  7232. $templateCache.put("template/popover/popover.html",
  7233. "<div tooltip-animation-class=\"fade\"\n" +
  7234. " uib-tooltip-classes\n" +
  7235. " ng-class=\"{ in: isOpen() }\">\n" +
  7236. " <div class=\"arrow\"></div>\n" +
  7237. "\n" +
  7238. " <div class=\"popover-inner\">\n" +
  7239. " <h3 class=\"popover-title\" ng-bind=\"title\" ng-if=\"title\"></h3>\n" +
  7240. " <div class=\"popover-content\" ng-bind=\"content\"></div>\n" +
  7241. " </div>\n" +
  7242. "</div>\n" +
  7243. "");
  7244. }]);
  7245. angular.module("template/progressbar/bar.html", []).run(["$templateCache", function($templateCache) {
  7246. $templateCache.put("template/progressbar/bar.html",
  7247. "<div class=\"progress-bar\" ng-class=\"type && 'progress-bar-' + type\" role=\"progressbar\" aria-valuenow=\"{{value}}\" aria-valuemin=\"0\" aria-valuemax=\"{{max}}\" ng-style=\"{width: (percent < 100 ? percent : 100) + '%'}\" aria-valuetext=\"{{percent | number:0}}%\" aria-labelledby=\"{{::title}}\" style=\"min-width: 0;\" ng-transclude></div>\n" +
  7248. "");
  7249. }]);
  7250. angular.module("template/progressbar/progress.html", []).run(["$templateCache", function($templateCache) {
  7251. $templateCache.put("template/progressbar/progress.html",
  7252. "<div class=\"progress\" ng-transclude aria-labelledby=\"{{::title}}\"></div>");
  7253. }]);
  7254. angular.module("template/progressbar/progressbar.html", []).run(["$templateCache", function($templateCache) {
  7255. $templateCache.put("template/progressbar/progressbar.html",
  7256. "<div class=\"progress\">\n" +
  7257. " <div class=\"progress-bar\" ng-class=\"type && 'progress-bar-' + type\" role=\"progressbar\" aria-valuenow=\"{{value}}\" aria-valuemin=\"0\" aria-valuemax=\"{{max}}\" ng-style=\"{width: (percent < 100 ? percent : 100) + '%'}\" aria-valuetext=\"{{percent | number:0}}%\" aria-labelledby=\"{{::title}}\" style=\"min-width: 0;\" ng-transclude></div>\n" +
  7258. "</div>\n" +
  7259. "");
  7260. }]);
  7261. angular.module("template/rating/rating.html", []).run(["$templateCache", function($templateCache) {
  7262. $templateCache.put("template/rating/rating.html",
  7263. "<span ng-mouseleave=\"reset()\" ng-keydown=\"onKeydown($event)\" tabindex=\"0\" role=\"slider\" aria-valuemin=\"0\" aria-valuemax=\"{{range.length}}\" aria-valuenow=\"{{value}}\">\n" +
  7264. " <span ng-repeat-start=\"r in range track by $index\" class=\"sr-only\">({{ $index < value ? '*' : ' ' }})</span>\n" +
  7265. " <i ng-repeat-end ng-mouseenter=\"enter($index + 1)\" ng-click=\"rate($index + 1)\" class=\"glyphicon\" ng-class=\"$index < value && (r.stateOn || 'glyphicon-star') || (r.stateOff || 'glyphicon-star-empty')\" ng-attr-title=\"{{r.title}}\" aria-valuetext=\"{{r.title}}\"></i>\n" +
  7266. "</span>\n" +
  7267. "");
  7268. }]);
  7269. angular.module("template/tabs/tab.html", []).run(["$templateCache", function($templateCache) {
  7270. $templateCache.put("template/tabs/tab.html",
  7271. "<li ng-class=\"{active: active, disabled: disabled}\">\n" +
  7272. " <a href ng-click=\"select()\" uib-tab-heading-transclude>{{heading}}</a>\n" +
  7273. "</li>\n" +
  7274. "");
  7275. }]);
  7276. angular.module("template/tabs/tabset.html", []).run(["$templateCache", function($templateCache) {
  7277. $templateCache.put("template/tabs/tabset.html",
  7278. "<div>\n" +
  7279. " <ul class=\"nav nav-{{type || 'tabs'}}\" ng-class=\"{'nav-stacked': vertical, 'nav-justified': justified}\" ng-transclude></ul>\n" +
  7280. " <div class=\"tab-content\">\n" +
  7281. " <div class=\"tab-pane\" \n" +
  7282. " ng-repeat=\"tab in tabs\" \n" +
  7283. " ng-class=\"{active: tab.active}\"\n" +
  7284. " uib-tab-content-transclude=\"tab\">\n" +
  7285. " </div>\n" +
  7286. " </div>\n" +
  7287. "</div>\n" +
  7288. "");
  7289. }]);
  7290. angular.module("template/timepicker/timepicker.html", []).run(["$templateCache", function($templateCache) {
  7291. $templateCache.put("template/timepicker/timepicker.html",
  7292. "<table>\n" +
  7293. " <tbody>\n" +
  7294. " <tr class=\"text-center\" ng-show=\"::showSpinners\">\n" +
  7295. " <td><a ng-click=\"incrementHours()\" ng-class=\"{disabled: noIncrementHours()}\" class=\"btn btn-link\" ng-disabled=\"noIncrementHours()\" tabindex=\"{{::tabindex}}\"><span class=\"glyphicon glyphicon-chevron-up\"></span></a></td>\n" +
  7296. " <td>&nbsp;</td>\n" +
  7297. " <td><a ng-click=\"incrementMinutes()\" ng-class=\"{disabled: noIncrementMinutes()}\" class=\"btn btn-link\" ng-disabled=\"noIncrementMinutes()\" tabindex=\"{{::tabindex}}\"><span class=\"glyphicon glyphicon-chevron-up\"></span></a></td>\n" +
  7298. " <td ng-show=\"showMeridian\"></td>\n" +
  7299. " </tr>\n" +
  7300. " <tr>\n" +
  7301. " <td class=\"form-group\" ng-class=\"{'has-error': invalidHours}\">\n" +
  7302. " <input style=\"width:50px;\" type=\"text\" ng-model=\"hours\" ng-change=\"updateHours()\" class=\"form-control text-center\" ng-readonly=\"::readonlyInput\" maxlength=\"2\" tabindex=\"{{::tabindex}}\">\n" +
  7303. " </td>\n" +
  7304. " <td>:</td>\n" +
  7305. " <td class=\"form-group\" ng-class=\"{'has-error': invalidMinutes}\">\n" +
  7306. " <input style=\"width:50px;\" type=\"text\" ng-model=\"minutes\" ng-change=\"updateMinutes()\" class=\"form-control text-center\" ng-readonly=\"::readonlyInput\" maxlength=\"2\" tabindex=\"{{::tabindex}}\">\n" +
  7307. " </td>\n" +
  7308. " <td ng-show=\"showMeridian\"><button type=\"button\" ng-class=\"{disabled: noToggleMeridian()}\" class=\"btn btn-default text-center\" ng-click=\"toggleMeridian()\" ng-disabled=\"noToggleMeridian()\" tabindex=\"{{::tabindex}}\">{{meridian}}</button></td>\n" +
  7309. " </tr>\n" +
  7310. " <tr class=\"text-center\" ng-show=\"::showSpinners\">\n" +
  7311. " <td><a ng-click=\"decrementHours()\" ng-class=\"{disabled: noDecrementHours()}\" class=\"btn btn-link\" ng-disabled=\"noDecrementHours()\" tabindex=\"{{::tabindex}}\"><span class=\"glyphicon glyphicon-chevron-down\"></span></a></td>\n" +
  7312. " <td>&nbsp;</td>\n" +
  7313. " <td><a ng-click=\"decrementMinutes()\" ng-class=\"{disabled: noDecrementMinutes()}\" class=\"btn btn-link\" ng-disabled=\"noDecrementMinutes()\" tabindex=\"{{::tabindex}}\"><span class=\"glyphicon glyphicon-chevron-down\"></span></a></td>\n" +
  7314. " <td ng-show=\"showMeridian\"></td>\n" +
  7315. " </tr>\n" +
  7316. " </tbody>\n" +
  7317. "</table>\n" +
  7318. "");
  7319. }]);
  7320. angular.module("template/typeahead/typeahead-match.html", []).run(["$templateCache", function($templateCache) {
  7321. $templateCache.put("template/typeahead/typeahead-match.html",
  7322. "<a href tabindex=\"-1\" ng-bind-html=\"match.label | uibTypeaheadHighlight:query\"></a>\n" +
  7323. "");
  7324. }]);
  7325. angular.module("template/typeahead/typeahead-popup.html", []).run(["$templateCache", function($templateCache) {
  7326. $templateCache.put("template/typeahead/typeahead-popup.html",
  7327. "<ul class=\"dropdown-menu\" ng-show=\"isOpen() && !moveInProgress\" ng-style=\"{top: position().top+'px', left: position().left+'px'}\" style=\"display: block;\" role=\"listbox\" aria-hidden=\"{{!isOpen()}}\">\n" +
  7328. " <li ng-repeat=\"match in matches track by $index\" ng-class=\"{active: isActive($index) }\" ng-mouseenter=\"selectActive($index)\" ng-click=\"selectMatch($index)\" role=\"option\" id=\"{{::match.id}}\">\n" +
  7329. " <div uib-typeahead-match index=\"$index\" match=\"match\" query=\"query\" template-url=\"templateUrl\"></div>\n" +
  7330. " </li>\n" +
  7331. "</ul>\n" +
  7332. "");
  7333. }]);
  7334. !angular.$$csp() && angular.element(document).find('head').prepend('<style type="text/css">.ng-animate.item:not(.left):not(.right){-webkit-transition:0s ease-in-out left;transition:0s ease-in-out left}</style>');