ui-bootstrap-tpls.js 182 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680
  1. /*
  2. * angular-ui-bootstrap
  3. * http://angular-ui.github.io/bootstrap/
  4. * Version: 0.12.1 - 2015-02-20
  5. * License: MIT
  6. */
  7. angular.module("ui.bootstrap", ["ui.bootstrap.tpls", "ui.bootstrap.transition", "ui.bootstrap.collapse", "ui.bootstrap.accordion", "ui.bootstrap.alert", "ui.bootstrap.bindHtml", "ui.bootstrap.buttons", "ui.bootstrap.carousel", "ui.bootstrap.dateparser", "ui.bootstrap.position", "ui.bootstrap.datepicker", "ui.bootstrap.dropdown", "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/week.html", "template/datepicker/day.html", "template/datepicker/popup.html", "template/datepicker/popuptime.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-unsafe-popup.html", "template/tooltip/tooltip-popup.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.transition', [])
  10. /**
  11. * $transition service provides a consistent interface to trigger CSS 3 transitions and to be informed when they complete.
  12. * @param {DOMElement} element The DOMElement that will be animated.
  13. * @param {string|object|function} trigger The thing that will cause the transition to start:
  14. * - As a string, it represents the css class to be added to the element.
  15. * - As an object, it represents a hash of style attributes to be applied to the element.
  16. * - As a function, it represents a function to be called that will cause the transition to occur.
  17. * @return {Promise} A promise that is resolved when the transition finishes.
  18. */
  19. .factory('$transition', ['$q', '$timeout', '$rootScope', function($q, $timeout, $rootScope) {
  20. var $transition = function(element, trigger, options) {
  21. options = options || {};
  22. var deferred = $q.defer();
  23. var endEventName = $transition[options.animation ? 'animationEndEventName' : 'transitionEndEventName'];
  24. var transitionEndHandler = function(event) {
  25. $rootScope.$apply(function() {
  26. element.unbind(endEventName, transitionEndHandler);
  27. deferred.resolve(element);
  28. });
  29. };
  30. if (endEventName) {
  31. element.bind(endEventName, transitionEndHandler);
  32. }
  33. // Wrap in a timeout to allow the browser time to update the DOM before the transition is to occur
  34. $timeout(function() {
  35. if (angular.isString(trigger)) {
  36. element.addClass(trigger);
  37. } else if (angular.isFunction(trigger)) {
  38. trigger(element);
  39. } else if (angular.isObject(trigger)) {
  40. element.css(trigger);
  41. }
  42. //If browser does not support transitions, instantly resolve
  43. if (!endEventName) {
  44. deferred.resolve(element);
  45. }
  46. });
  47. // Add our custom cancel function to the promise that is returned
  48. // We can call this if we are about to run a new transition, which we know will prevent this transition from ending,
  49. // i.e. it will therefore never raise a transitionEnd event for that transition
  50. deferred.promise.cancel = function() {
  51. if (endEventName) {
  52. element.unbind(endEventName, transitionEndHandler);
  53. }
  54. deferred.reject('Transition cancelled');
  55. };
  56. return deferred.promise;
  57. };
  58. // Work out the name of the transitionEnd event
  59. var transElement = document.createElement('trans');
  60. var transitionEndEventNames = {
  61. 'WebkitTransition': 'webkitTransitionEnd',
  62. 'MozTransition': 'transitionend',
  63. 'OTransition': 'oTransitionEnd',
  64. 'transition': 'transitionend'
  65. };
  66. var animationEndEventNames = {
  67. 'WebkitTransition': 'webkitAnimationEnd',
  68. 'MozTransition': 'animationend',
  69. 'OTransition': 'oAnimationEnd',
  70. 'transition': 'animationend'
  71. };
  72. function findEndEventName(endEventNames) {
  73. for (var name in endEventNames) {
  74. if (transElement.style[name] !== undefined) {
  75. return endEventNames[name];
  76. }
  77. }
  78. }
  79. $transition.transitionEndEventName = findEndEventName(transitionEndEventNames);
  80. $transition.animationEndEventName = findEndEventName(animationEndEventNames);
  81. return $transition;
  82. }]);
  83. angular.module('ui.bootstrap.collapse', ['ui.bootstrap.transition'])
  84. .directive('collapse', ['$transition', function($transition) {
  85. return {
  86. link: function(scope, element, attrs) {
  87. var initialAnimSkip = true;
  88. var currentTransition;
  89. function doTransition(change) {
  90. var newTransition = $transition(element, change);
  91. if (currentTransition) {
  92. currentTransition.cancel();
  93. }
  94. currentTransition = newTransition;
  95. newTransition.then(newTransitionDone, newTransitionDone);
  96. return newTransition;
  97. function newTransitionDone() {
  98. // Make sure it's this transition, otherwise, leave it alone.
  99. if (currentTransition === newTransition) {
  100. currentTransition = undefined;
  101. }
  102. }
  103. }
  104. function expand() {
  105. if (initialAnimSkip) {
  106. initialAnimSkip = false;
  107. expandDone();
  108. } else {
  109. element.removeClass('collapse').addClass('collapsing');
  110. doTransition({ height: element[0].scrollHeight + 'px' }).then(expandDone);
  111. }
  112. }
  113. function expandDone() {
  114. element.removeClass('collapsing');
  115. element.addClass('collapse in');
  116. element.css({ height: 'auto' });
  117. }
  118. function collapse() {
  119. if (initialAnimSkip) {
  120. initialAnimSkip = false;
  121. collapseDone();
  122. element.css({ height: 0 });
  123. } else {
  124. // CSS transitions don't work with height: auto, so we have to manually change the height to a specific value
  125. element.css({ height: element[0].scrollHeight + 'px' });
  126. //trigger reflow so a browser realizes that height was updated from auto to a specific value
  127. var x = element[0].offsetWidth;
  128. element.removeClass('collapse in').addClass('collapsing');
  129. doTransition({ height: 0 }).then(collapseDone);
  130. }
  131. }
  132. function collapseDone() {
  133. element.removeClass('collapsing');
  134. element.addClass('collapse');
  135. }
  136. scope.$watch(attrs.collapse, function(shouldCollapse) {
  137. if (shouldCollapse) {
  138. collapse();
  139. } else {
  140. expand();
  141. }
  142. });
  143. }
  144. };
  145. }]);
  146. angular.module('ui.bootstrap.accordion', ['ui.bootstrap.collapse'])
  147. .constant('accordionConfig', {
  148. closeOthers: true
  149. })
  150. .controller('AccordionController', ['$scope', '$attrs', 'accordionConfig', function($scope, $attrs, accordionConfig) {
  151. // This array keeps track of the accordion groups
  152. this.groups = [];
  153. // Ensure that all the groups in this accordion are closed, unless close-others explicitly says not to
  154. this.closeOthers = function(openGroup) {
  155. var closeOthers = angular.isDefined($attrs.closeOthers) ? $scope.$eval($attrs.closeOthers) : accordionConfig.closeOthers;
  156. if (closeOthers) {
  157. angular.forEach(this.groups, function(group) {
  158. if (group !== openGroup) {
  159. group.isOpen = false;
  160. }
  161. });
  162. }
  163. };
  164. // This is called from the accordion-group directive to add itself to the accordion
  165. this.addGroup = function(groupScope) {
  166. var that = this;
  167. this.groups.push(groupScope);
  168. groupScope.$on('$destroy', function(event) {
  169. that.removeGroup(groupScope);
  170. });
  171. };
  172. // This is called from the accordion-group directive when to remove itself
  173. this.removeGroup = function(group) {
  174. var index = this.groups.indexOf(group);
  175. if (index !== -1) {
  176. this.groups.splice(index, 1);
  177. }
  178. };
  179. }])
  180. // The accordion directive simply sets up the directive controller
  181. // and adds an accordion CSS class to itself element.
  182. .directive('accordion', function() {
  183. return {
  184. restrict: 'EA',
  185. controller: 'AccordionController',
  186. transclude: true,
  187. replace: false,
  188. templateUrl: 'template/accordion/accordion.html'
  189. };
  190. })
  191. // The accordion-group directive indicates a block of html that will expand and collapse in an accordion
  192. .directive('accordionGroup', function() {
  193. return {
  194. require: '^accordion', // We need this directive to be inside an accordion
  195. restrict: 'EA',
  196. transclude: true, // It transcludes the contents of the directive into the template
  197. replace: true, // The element containing the directive will be replaced with the template
  198. templateUrl: 'template/accordion/accordion-group.html',
  199. scope: {
  200. heading: '@', // Interpolate the heading attribute onto this scope
  201. isOpen: '=?',
  202. isDisabled: '=?'
  203. },
  204. controller: function() {
  205. this.setHeading = function(element) {
  206. this.heading = element;
  207. };
  208. },
  209. link: function(scope, element, attrs, accordionCtrl) {
  210. accordionCtrl.addGroup(scope);
  211. scope.$watch('isOpen', function(value) {
  212. if (value) {
  213. accordionCtrl.closeOthers(scope);
  214. }
  215. });
  216. scope.toggleOpen = function() {
  217. if (!scope.isDisabled) {
  218. scope.isOpen = !scope.isOpen;
  219. }
  220. };
  221. }
  222. };
  223. })
  224. // Use accordion-heading below an accordion-group to provide a heading containing HTML
  225. // <accordion-group>
  226. // <accordion-heading>Heading containing HTML - <img src="..."></accordion-heading>
  227. // </accordion-group>
  228. .directive('accordionHeading', function() {
  229. return {
  230. restrict: 'EA',
  231. transclude: true, // Grab the contents to be used as the heading
  232. template: '', // In effect remove this element!
  233. replace: true,
  234. require: '^accordionGroup',
  235. link: function(scope, element, attr, accordionGroupCtrl, transclude) {
  236. // Pass the heading to the accordion-group controller
  237. // so that it can be transcluded into the right place in the template
  238. // [The second parameter to transclude causes the elements to be cloned so that they work in ng-repeat]
  239. accordionGroupCtrl.setHeading(transclude(scope, function() {}));
  240. }
  241. };
  242. })
  243. // Use in the accordion-group template to indicate where you want the heading to be transcluded
  244. // You must provide the property on the accordion-group controller that will hold the transcluded element
  245. // <div class="accordion-group">
  246. // <div class="accordion-heading" ><a ... accordion-transclude="heading">...</a></div>
  247. // ...
  248. // </div>
  249. .directive('accordionTransclude', function() {
  250. return {
  251. require: '^accordionGroup',
  252. link: function(scope, element, attr, controller) {
  253. scope.$watch(function() { return controller[attr.accordionTransclude]; }, function(heading) {
  254. if (heading) {
  255. element.html('');
  256. element.append(heading);
  257. }
  258. });
  259. }
  260. };
  261. });
  262. angular.module('ui.bootstrap.alert', [])
  263. .controller('AlertController', ['$scope', '$attrs', function($scope, $attrs) {
  264. $scope.closeable = 'close' in $attrs;
  265. this.close = $scope.close;
  266. }])
  267. .directive('alert', function() {
  268. return {
  269. restrict: 'EA',
  270. controller: 'AlertController',
  271. templateUrl: 'template/alert/alert.html',
  272. transclude: true,
  273. replace: true,
  274. scope: {
  275. type: '@',
  276. close: '&'
  277. }
  278. };
  279. })
  280. .directive('dismissOnTimeout', ['$timeout', function($timeout) {
  281. return {
  282. require: 'alert',
  283. link: function(scope, element, attrs, alertCtrl) {
  284. $timeout(function() {
  285. alertCtrl.close();
  286. }, parseInt(attrs.dismissOnTimeout, 10));
  287. }
  288. };
  289. }]);
  290. angular.module('ui.bootstrap.bindHtml', [])
  291. .directive('bindHtmlUnsafe', function() {
  292. return function(scope, element, attr) {
  293. element.addClass('ng-binding').data('$binding', attr.bindHtmlUnsafe);
  294. scope.$watch(attr.bindHtmlUnsafe, function bindHtmlUnsafeWatchAction(value) {
  295. element.html(value || '');
  296. });
  297. };
  298. });
  299. angular.module('ui.bootstrap.buttons', [])
  300. .constant('buttonConfig', {
  301. activeClass: 'active',
  302. toggleEvent: 'click'
  303. })
  304. .controller('ButtonsController', ['buttonConfig', function(buttonConfig) {
  305. this.activeClass = buttonConfig.activeClass || 'active';
  306. this.toggleEvent = buttonConfig.toggleEvent || 'click';
  307. }])
  308. .directive('btnRadio', function() {
  309. return {
  310. require: ['btnRadio', 'ngModel'],
  311. controller: 'ButtonsController',
  312. link: function(scope, element, attrs, ctrls) {
  313. var buttonsCtrl = ctrls[0],
  314. ngModelCtrl = ctrls[1];
  315. //model -> UI
  316. ngModelCtrl.$render = function() {
  317. element.toggleClass(buttonsCtrl.activeClass, angular.equals(ngModelCtrl.$modelValue, scope.$eval(attrs.btnRadio)));
  318. };
  319. //ui->model
  320. element.bind(buttonsCtrl.toggleEvent, function() {
  321. var isActive = element.hasClass(buttonsCtrl.activeClass);
  322. if (!isActive || angular.isDefined(attrs.uncheckable)) {
  323. scope.$apply(function() {
  324. ngModelCtrl.$setViewValue(isActive ? null : scope.$eval(attrs.btnRadio));
  325. ngModelCtrl.$render();
  326. });
  327. }
  328. });
  329. }
  330. };
  331. })
  332. .directive('btnCheckbox', function() {
  333. return {
  334. require: ['btnCheckbox', 'ngModel'],
  335. controller: 'ButtonsController',
  336. link: function(scope, element, attrs, ctrls) {
  337. var buttonsCtrl = ctrls[0],
  338. ngModelCtrl = ctrls[1];
  339. function getTrueValue() {
  340. return getCheckboxValue(attrs.btnCheckboxTrue, true);
  341. }
  342. function getFalseValue() {
  343. return getCheckboxValue(attrs.btnCheckboxFalse, false);
  344. }
  345. function getCheckboxValue(attributeValue, defaultValue) {
  346. var val = scope.$eval(attributeValue);
  347. return angular.isDefined(val) ? val : defaultValue;
  348. }
  349. //model -> UI
  350. ngModelCtrl.$render = function() {
  351. element.toggleClass(buttonsCtrl.activeClass, angular.equals(ngModelCtrl.$modelValue, getTrueValue()));
  352. };
  353. //ui->model
  354. element.bind(buttonsCtrl.toggleEvent, function() {
  355. scope.$apply(function() {
  356. ngModelCtrl.$setViewValue(element.hasClass(buttonsCtrl.activeClass) ? getFalseValue() : getTrueValue());
  357. ngModelCtrl.$render();
  358. });
  359. });
  360. }
  361. };
  362. });
  363. /**
  364. * @ngdoc overview
  365. * @name ui.bootstrap.carousel
  366. *
  367. * @description
  368. * AngularJS version of an image carousel.
  369. *
  370. */
  371. angular.module('ui.bootstrap.carousel', ['ui.bootstrap.transition'])
  372. .controller('CarouselController', ['$scope', '$timeout', '$interval', '$transition', function($scope, $timeout, $interval, $transition) {
  373. var self = this,
  374. slides = self.slides = $scope.slides = [],
  375. currentIndex = -1,
  376. currentInterval, isPlaying;
  377. self.currentSlide = null;
  378. var destroyed = false;
  379. /* direction: "prev" or "next" */
  380. self.select = $scope.select = function(nextSlide, direction) {
  381. var nextIndex = slides.indexOf(nextSlide);
  382. //Decide direction if it's not given
  383. if (direction === undefined) {
  384. direction = nextIndex > currentIndex ? 'next' : 'prev';
  385. }
  386. if (nextSlide && nextSlide !== self.currentSlide) {
  387. if ($scope.$currentTransition) {
  388. $scope.$currentTransition.cancel();
  389. //Timeout so ng-class in template has time to fix classes for finished slide
  390. $timeout(goNext);
  391. } else {
  392. goNext();
  393. }
  394. }
  395. function goNext() {
  396. // Scope has been destroyed, stop here.
  397. if (destroyed) { return; }
  398. //If we have a slide to transition from and we have a transition type and we're allowed, go
  399. if (self.currentSlide && angular.isString(direction) && !$scope.noTransition && nextSlide.$element) {
  400. //We shouldn't do class manip in here, but it's the same weird thing bootstrap does. need to fix sometime
  401. nextSlide.$element.addClass(direction);
  402. var reflow = nextSlide.$element[0].offsetWidth; //force reflow
  403. //Set all other slides to stop doing their stuff for the new transition
  404. angular.forEach(slides, function(slide) {
  405. angular.extend(slide, { direction: '', entering: false, leaving: false, active: false });
  406. });
  407. angular.extend(nextSlide, { direction: direction, active: true, entering: true });
  408. angular.extend(self.currentSlide || {}, { direction: direction, leaving: true });
  409. $scope.$currentTransition = $transition(nextSlide.$element, {});
  410. //We have to create new pointers inside a closure since next & current will change
  411. (function(next, current) {
  412. $scope.$currentTransition.then(
  413. function() { transitionDone(next, current); },
  414. function() { transitionDone(next, current); }
  415. );
  416. }(nextSlide, self.currentSlide));
  417. } else {
  418. transitionDone(nextSlide, self.currentSlide);
  419. }
  420. self.currentSlide = nextSlide;
  421. currentIndex = nextIndex;
  422. //every time you change slides, reset the timer
  423. restartTimer();
  424. }
  425. function transitionDone(next, current) {
  426. angular.extend(next, { direction: '', active: true, leaving: false, entering: false });
  427. angular.extend(current || {}, { direction: '', active: false, leaving: false, entering: false });
  428. $scope.$currentTransition = null;
  429. }
  430. };
  431. $scope.$on('$destroy', function() {
  432. destroyed = true;
  433. });
  434. /* Allow outside people to call indexOf on slides array */
  435. self.indexOfSlide = function(slide) {
  436. return slides.indexOf(slide);
  437. };
  438. $scope.next = function() {
  439. var newIndex = (currentIndex + 1) % slides.length;
  440. //Prevent this user-triggered transition from occurring if there is already one in progress
  441. if (!$scope.$currentTransition) {
  442. return self.select(slides[newIndex], 'next');
  443. }
  444. };
  445. $scope.prev = function() {
  446. var newIndex = currentIndex - 1 < 0 ? slides.length - 1 : currentIndex - 1;
  447. //Prevent this user-triggered transition from occurring if there is already one in progress
  448. if (!$scope.$currentTransition) {
  449. return self.select(slides[newIndex], 'prev');
  450. }
  451. };
  452. $scope.isActive = function(slide) {
  453. return self.currentSlide === slide;
  454. };
  455. $scope.$watch('interval', restartTimer);
  456. $scope.$on('$destroy', resetTimer);
  457. function restartTimer() {
  458. resetTimer();
  459. var interval = +$scope.interval;
  460. if (!isNaN(interval) && interval > 0) {
  461. currentInterval = $interval(timerFn, interval);
  462. }
  463. }
  464. function resetTimer() {
  465. if (currentInterval) {
  466. $interval.cancel(currentInterval);
  467. currentInterval = null;
  468. }
  469. }
  470. function timerFn() {
  471. var interval = +$scope.interval;
  472. if (isPlaying && !isNaN(interval) && interval > 0) {
  473. $scope.next();
  474. } else {
  475. $scope.pause();
  476. }
  477. }
  478. $scope.play = function() {
  479. if (!isPlaying) {
  480. isPlaying = true;
  481. restartTimer();
  482. }
  483. };
  484. $scope.pause = function() {
  485. if (!$scope.noPause) {
  486. isPlaying = false;
  487. resetTimer();
  488. }
  489. };
  490. self.addSlide = function(slide, element) {
  491. slide.$element = element;
  492. slides.push(slide);
  493. //if this is the first slide or the slide is set to active, select it
  494. if (slides.length === 1 || slide.active) {
  495. self.select(slides[slides.length - 1]);
  496. if (slides.length == 1) {
  497. $scope.play();
  498. }
  499. } else {
  500. slide.active = false;
  501. }
  502. };
  503. self.removeSlide = function(slide) {
  504. //get the index of the slide inside the carousel
  505. var index = slides.indexOf(slide);
  506. slides.splice(index, 1);
  507. if (slides.length > 0 && slide.active) {
  508. if (index >= slides.length) {
  509. self.select(slides[index - 1]);
  510. } else {
  511. self.select(slides[index]);
  512. }
  513. } else if (currentIndex > index) {
  514. currentIndex--;
  515. }
  516. };
  517. }])
  518. /**
  519. * @ngdoc directive
  520. * @name ui.bootstrap.carousel.directive:carousel
  521. * @restrict EA
  522. *
  523. * @description
  524. * Carousel is the outer container for a set of image 'slides' to showcase.
  525. *
  526. * @param {number=} interval The time, in milliseconds, that it will take the carousel to go to the next slide.
  527. * @param {boolean=} noTransition Whether to disable transitions on the carousel.
  528. * @param {boolean=} noPause Whether to disable pausing on the carousel (by default, the carousel interval pauses on hover).
  529. *
  530. * @example
  531. <example module="ui.bootstrap">
  532. <file name="index.html">
  533. <carousel>
  534. <slide>
  535. <img src="http://placekitten.com/150/150" style="margin:auto;">
  536. <div class="carousel-caption">
  537. <p>Beautiful!</p>
  538. </div>
  539. </slide>
  540. <slide>
  541. <img src="http://placekitten.com/100/150" style="margin:auto;">
  542. <div class="carousel-caption">
  543. <p>D'aww!</p>
  544. </div>
  545. </slide>
  546. </carousel>
  547. </file>
  548. <file name="demo.css">
  549. .carousel-indicators {
  550. top: auto;
  551. bottom: 15px;
  552. }
  553. </file>
  554. </example>
  555. */
  556. .directive('carousel', [function() {
  557. return {
  558. restrict: 'EA',
  559. transclude: true,
  560. replace: true,
  561. controller: 'CarouselController',
  562. require: 'carousel',
  563. templateUrl: 'template/carousel/carousel.html',
  564. scope: {
  565. interval: '=',
  566. noTransition: '=',
  567. noPause: '='
  568. }
  569. };
  570. }])
  571. /**
  572. * @ngdoc directive
  573. * @name ui.bootstrap.carousel.directive:slide
  574. * @restrict EA
  575. *
  576. * @description
  577. * Creates a slide inside a {@link ui.bootstrap.carousel.directive:carousel carousel}. Must be placed as a child of a carousel element.
  578. *
  579. * @param {boolean=} active Model binding, whether or not this slide is currently active.
  580. *
  581. * @example
  582. <example module="ui.bootstrap">
  583. <file name="index.html">
  584. <div ng-controller="CarouselDemoCtrl">
  585. <carousel>
  586. <slide ng-repeat="slide in slides" active="slide.active">
  587. <img ng-src="{{slide.image}}" style="margin:auto;">
  588. <div class="carousel-caption">
  589. <h4>Slide {{$index}}</h4>
  590. <p>{{slide.text}}</p>
  591. </div>
  592. </slide>
  593. </carousel>
  594. Interval, in milliseconds: <input type="number" ng-model="myInterval">
  595. <br />Enter a negative number to stop the interval.
  596. </div>
  597. </file>
  598. <file name="script.js">
  599. function CarouselDemoCtrl($scope) {
  600. $scope.myInterval = 5000;
  601. }
  602. </file>
  603. <file name="demo.css">
  604. .carousel-indicators {
  605. top: auto;
  606. bottom: 15px;
  607. }
  608. </file>
  609. </example>
  610. */
  611. .directive('slide', function() {
  612. return {
  613. require: '^carousel',
  614. restrict: 'EA',
  615. transclude: true,
  616. replace: true,
  617. templateUrl: 'template/carousel/slide.html',
  618. scope: {
  619. active: '=?'
  620. },
  621. link: function(scope, element, attrs, carouselCtrl) {
  622. carouselCtrl.addSlide(scope, element);
  623. //when the scope is destroyed then remove the slide from the current slides array
  624. scope.$on('$destroy', function() {
  625. carouselCtrl.removeSlide(scope);
  626. });
  627. scope.$watch('active', function(active) {
  628. if (active) {
  629. carouselCtrl.select(scope);
  630. }
  631. });
  632. }
  633. };
  634. });
  635. angular.module('ui.bootstrap.dateparser', [])
  636. .service('dateParser', ['$locale', 'orderByFilter', function($locale, orderByFilter) {
  637. this.parsers = {};
  638. var formatCodeToRegex = {
  639. 'yyyy': {
  640. regex: '\\d{4}',
  641. apply: function(value) { this.year = +value; }
  642. },
  643. 'yy': {
  644. regex: '\\d{2}',
  645. apply: function(value) { this.year = +value + 2000; }
  646. },
  647. 'y': {
  648. regex: '\\d{1,4}',
  649. apply: function(value) { this.year = +value; }
  650. },
  651. 'MMMM': {
  652. regex: $locale.DATETIME_FORMATS.MONTH.join('|'),
  653. apply: function(value) { this.month = $locale.DATETIME_FORMATS.MONTH.indexOf(value); }
  654. },
  655. 'MMM': {
  656. regex: $locale.DATETIME_FORMATS.SHORTMONTH.join('|'),
  657. apply: function(value) { this.month = $locale.DATETIME_FORMATS.SHORTMONTH.indexOf(value); }
  658. },
  659. 'MM': {
  660. regex: '0[1-9]|1[0-2]',
  661. apply: function(value) { this.month = value - 1; }
  662. },
  663. 'M': {
  664. regex: '[1-9]|1[0-2]',
  665. apply: function(value) { this.month = value - 1; }
  666. },
  667. 'dd': {
  668. regex: '[0-2][0-9]{1}|3[0-1]{1}',
  669. apply: function(value) { this.date = +value; }
  670. },
  671. 'd': {
  672. regex: '[1-2]?[0-9]{1}|3[0-1]{1}',
  673. apply: function(value) { this.date = +value; }
  674. },
  675. 'EEEE': {
  676. regex: $locale.DATETIME_FORMATS.DAY.join('|')
  677. },
  678. 'EEE': {
  679. regex: $locale.DATETIME_FORMATS.SHORTDAY.join('|')
  680. }
  681. };
  682. function createParser(format) {
  683. var map = [],
  684. regex = format.split('');
  685. angular.forEach(formatCodeToRegex, function(data, code) {
  686. var index = format.indexOf(code);
  687. if (index > -1) {
  688. format = format.split('');
  689. regex[index] = '(' + data.regex + ')';
  690. format[index] = '$'; // Custom symbol to define consumed part of format
  691. for (var i = index + 1, n = index + code.length; i < n; i++) {
  692. regex[i] = '';
  693. format[i] = '$';
  694. }
  695. format = format.join('');
  696. map.push({ index: index, apply: data.apply });
  697. }
  698. });
  699. return {
  700. regex: new RegExp('^' + regex.join('') + '$'),
  701. map: orderByFilter(map, 'index')
  702. };
  703. }
  704. this.parse = function(input, format) {
  705. if (!angular.isString(input) || !format) {
  706. return input;
  707. }
  708. format = $locale.DATETIME_FORMATS[format] || format;
  709. if (!this.parsers[format]) {
  710. this.parsers[format] = createParser(format);
  711. }
  712. var parser = this.parsers[format],
  713. regex = parser.regex,
  714. map = parser.map,
  715. results = input.match(regex);
  716. if (results && results.length) {
  717. var fields = { year: 1900, month: 0, date: 1, hours: 0 },
  718. dt;
  719. for (var i = 1, n = results.length; i < n; i++) {
  720. var mapper = map[i - 1];
  721. if (mapper.apply) {
  722. mapper.apply.call(fields, results[i]);
  723. }
  724. }
  725. if (isValid(fields.year, fields.month, fields.date)) {
  726. dt = new Date(fields.year, fields.month, fields.date, fields.hours);
  727. }
  728. return dt;
  729. }
  730. };
  731. // Check if date is valid for specific month (and year for February).
  732. // Month: 0 = Jan, 1 = Feb, etc
  733. function isValid(year, month, date) {
  734. if (month === 1 && date > 28) {
  735. return date === 29 && ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0);
  736. }
  737. if (month === 3 || month === 5 || month === 8 || month === 10) {
  738. return date < 31;
  739. }
  740. return true;
  741. }
  742. }]);
  743. angular.module('ui.bootstrap.position', [])
  744. /**
  745. * A set of utility methods that can be use to retrieve position of DOM elements.
  746. * It is meant to be used where we need to absolute-position DOM elements in
  747. * relation to other, existing elements (this is the case for tooltips, popovers,
  748. * typeahead suggestions etc.).
  749. */
  750. .factory('$position', ['$document', '$window', function($document, $window) {
  751. function getStyle(el, cssprop) {
  752. if (el.currentStyle) { //IE
  753. return el.currentStyle[cssprop];
  754. } else if ($window.getComputedStyle) {
  755. return $window.getComputedStyle(el)[cssprop];
  756. }
  757. // finally try and get inline style
  758. return el.style[cssprop];
  759. }
  760. /**
  761. * Checks if a given element is statically positioned
  762. * @param element - raw DOM element
  763. */
  764. function isStaticPositioned(element) {
  765. return (getStyle(element, 'position') || 'static') === 'static';
  766. }
  767. /**
  768. * returns the closest, non-statically positioned parentOffset of a given element
  769. * @param element
  770. */
  771. var parentOffsetEl = function(element) {
  772. var docDomEl = $document[0];
  773. var offsetParent = element.offsetParent || docDomEl;
  774. while (offsetParent && offsetParent !== docDomEl && isStaticPositioned(offsetParent)) {
  775. offsetParent = offsetParent.offsetParent;
  776. }
  777. return offsetParent || docDomEl;
  778. };
  779. return {
  780. /**
  781. * Provides read-only equivalent of jQuery's position function:
  782. * http://api.jquery.com/position/
  783. */
  784. position: function(element) {
  785. var elBCR = this.offset(element);
  786. var offsetParentBCR = { top: 0, left: 0 };
  787. var offsetParentEl = parentOffsetEl(element[0]);
  788. if (offsetParentEl != $document[0]) {
  789. offsetParentBCR = this.offset(angular.element(offsetParentEl));
  790. offsetParentBCR.top += offsetParentEl.clientTop - offsetParentEl.scrollTop;
  791. offsetParentBCR.left += offsetParentEl.clientLeft - offsetParentEl.scrollLeft;
  792. }
  793. var boundingClientRect = element[0].getBoundingClientRect();
  794. return {
  795. width: boundingClientRect.width || element.prop('offsetWidth'),
  796. height: boundingClientRect.height || element.prop('offsetHeight'),
  797. top: elBCR.top - offsetParentBCR.top,
  798. left: elBCR.left - offsetParentBCR.left
  799. };
  800. },
  801. /**
  802. * Provides read-only equivalent of jQuery's offset function:
  803. * http://api.jquery.com/offset/
  804. */
  805. offset: function(element) {
  806. var boundingClientRect = element[0].getBoundingClientRect();
  807. return {
  808. width: boundingClientRect.width || element.prop('offsetWidth'),
  809. height: boundingClientRect.height || element.prop('offsetHeight'),
  810. top: boundingClientRect.top + ($window.pageYOffset || $document[0].documentElement.scrollTop),
  811. left: boundingClientRect.left + ($window.pageXOffset || $document[0].documentElement.scrollLeft)
  812. };
  813. },
  814. /**
  815. * Provides coordinates for the targetEl in relation to hostEl
  816. */
  817. positionElements: function(hostEl, targetEl, positionStr, appendToBody) {
  818. var positionStrParts = positionStr.split('-');
  819. var pos0 = positionStrParts[0],
  820. pos1 = positionStrParts[1] || 'center';
  821. var hostElPos,
  822. targetElWidth,
  823. targetElHeight,
  824. targetElPos;
  825. hostElPos = appendToBody ? this.offset(hostEl) : this.position(hostEl);
  826. targetElWidth = targetEl.prop('offsetWidth');
  827. targetElHeight = targetEl.prop('offsetHeight');
  828. var shiftWidth = {
  829. center: function() {
  830. return hostElPos.left + hostElPos.width / 2 - targetElWidth / 2;
  831. },
  832. left: function() {
  833. return hostElPos.left;
  834. },
  835. right: function() {
  836. return hostElPos.left + hostElPos.width;
  837. }
  838. };
  839. var shiftHeight = {
  840. center: function() {
  841. return hostElPos.top + hostElPos.height / 2 - targetElHeight / 2;
  842. },
  843. top: function() {
  844. return hostElPos.top;
  845. },
  846. bottom: function() {
  847. return hostElPos.top + hostElPos.height;
  848. }
  849. };
  850. switch (pos0) {
  851. case 'right':
  852. targetElPos = {
  853. top: shiftHeight[pos1](),
  854. left: shiftWidth[pos0]()
  855. };
  856. break;
  857. case 'left':
  858. targetElPos = {
  859. top: shiftHeight[pos1](),
  860. left: hostElPos.left - targetElWidth
  861. };
  862. break;
  863. case 'bottom':
  864. targetElPos = {
  865. top: shiftHeight[pos0](),
  866. left: shiftWidth[pos1]()
  867. };
  868. break;
  869. default:
  870. targetElPos = {
  871. top: hostElPos.top - targetElHeight,
  872. left: shiftWidth[pos1]()
  873. };
  874. break;
  875. }
  876. return targetElPos;
  877. }
  878. };
  879. }]);
  880. angular.module('ui.bootstrap.datepicker', ['ui.bootstrap.dateparser', 'ui.bootstrap.position'])
  881. .constant('datepickerConfig', {
  882. formatDay: 'dd',
  883. formatMonth: 'MMMM',
  884. formatYear: 'yyyy',
  885. formatDayHeader: 'EEE',
  886. formatDayTitle: 'MMMM yyyy',
  887. formatMonthTitle: 'yyyy',
  888. datepickerMode: 'day',
  889. minMode: 'day',
  890. maxMode: 'year',
  891. showWeeks: true,
  892. startingDay: 0,
  893. yearRange: 20,
  894. minDate: null,
  895. maxDate: null
  896. })
  897. .controller('DatepickerController', ['$scope', '$attrs', '$parse', '$interpolate', '$timeout', '$log', 'dateFilter', 'datepickerConfig', function($scope, $attrs, $parse, $interpolate, $timeout, $log, dateFilter, datepickerConfig) {
  898. var self = this,
  899. ngModelCtrl = { $setViewValue: angular.noop }; // nullModelCtrl;
  900. // Modes chain
  901. this.modes = ['day', 'month', 'year'];
  902. // Configuration attributes
  903. angular.forEach(['formatDay', 'formatMonth', 'formatYear', 'formatDayHeader', 'formatDayTitle', 'formatMonthTitle',
  904. 'minMode', 'maxMode', 'showWeeks', 'startingDay', 'yearRange'
  905. ], function(key, index) {
  906. self[key] = angular.isDefined($attrs[key]) ? (index < 8 ? $interpolate($attrs[key])($scope.$parent) : $scope.$parent.$eval($attrs[key])) : datepickerConfig[key];
  907. });
  908. // Watchable date attributes
  909. angular.forEach(['minDate', 'maxDate'], function(key) {
  910. if ($attrs[key]) {
  911. $scope.$parent.$watch($parse($attrs[key]), function(value) {
  912. self[key] = value ? new Date(value) : null;
  913. self.refreshView();
  914. });
  915. } else {
  916. self[key] = datepickerConfig[key] ? new Date(datepickerConfig[key]) : null;
  917. }
  918. });
  919. $scope.datepickerMode = $scope.datepickerMode || datepickerConfig.datepickerMode;
  920. $scope.uniqueId = 'datepicker-' + $scope.$id + '-' + Math.floor(Math.random() * 10000);
  921. this.activeDate = angular.isDefined($attrs.initDate) ? $scope.$parent.$eval($attrs.initDate) : new Date();
  922. $scope.isActive = function(dateObject) {
  923. if (self.compare(dateObject.date, self.activeDate) === 0) {
  924. $scope.activeDateId = dateObject.uid;
  925. return true;
  926. }
  927. return false;
  928. };
  929. this.init = function(ngModelCtrl_) {
  930. ngModelCtrl = ngModelCtrl_;
  931. ngModelCtrl.$render = function() {
  932. self.render();
  933. };
  934. };
  935. this.render = function() {
  936. if (ngModelCtrl.$modelValue) {
  937. var date = new Date(ngModelCtrl.$modelValue),
  938. isValid = !isNaN(date);
  939. if (isValid) {
  940. this.activeDate = date;
  941. } else {
  942. $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.');
  943. }
  944. ngModelCtrl.$setValidity('date', isValid);
  945. }
  946. this.refreshView();
  947. };
  948. this.refreshView = function() {
  949. if (this.element) {
  950. this._refreshView();
  951. var date = ngModelCtrl.$modelValue ? new Date(ngModelCtrl.$modelValue) : null;
  952. ngModelCtrl.$setValidity('date-disabled', !date || (this.element && !this.isDisabled(date)));
  953. }
  954. };
  955. this.createDateObject = function(date, format) {
  956. var model = ngModelCtrl.$modelValue ? new Date(ngModelCtrl.$modelValue) : null;
  957. return {
  958. date: date,
  959. label: dateFilter(date, format),
  960. selected: model && this.compare(date, model) === 0,
  961. disabled: this.isDisabled(date),
  962. current: this.compare(date, new Date()) === 0
  963. };
  964. };
  965. this.isDisabled = function(date) {
  966. 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 })));
  967. };
  968. // Split array into smaller arrays
  969. this.split = function(arr, size) {
  970. var arrays = [];
  971. while (arr.length > 0) {
  972. arrays.push(arr.splice(0, size));
  973. }
  974. return arrays;
  975. };
  976. $scope.select = function(date) {
  977. if ($scope.datepickerMode === self.minMode) {
  978. var dt = ngModelCtrl.$modelValue ? new Date(ngModelCtrl.$modelValue) : new Date(0, 0, 0, 0, 0, 0, 0);
  979. dt.setFullYear(date.getFullYear(), date.getMonth(), date.getDate());
  980. ngModelCtrl.$setViewValue(dt);
  981. ngModelCtrl.$render();
  982. } else {
  983. self.activeDate = date;
  984. $scope.datepickerMode = self.modes[self.modes.indexOf($scope.datepickerMode) - 1];
  985. }
  986. };
  987. $scope.move = function(direction) {
  988. var year = self.activeDate.getFullYear() + direction * (self.step.years || 0),
  989. month = self.activeDate.getMonth() + direction * (self.step.months || 0);
  990. self.activeDate.setFullYear(year, month, 1);
  991. self.refreshView();
  992. };
  993. $scope.toggleMode = function(direction) {
  994. direction = direction || 1;
  995. if (($scope.datepickerMode === self.maxMode && direction === 1) || ($scope.datepickerMode === self.minMode && direction === -1)) {
  996. return;
  997. }
  998. $scope.datepickerMode = self.modes[self.modes.indexOf($scope.datepickerMode) + direction];
  999. };
  1000. // Key event mapper
  1001. $scope.keys = { 13: 'enter', 32: 'space', 33: 'pageup', 34: 'pagedown', 35: 'end', 36: 'home', 37: 'left', 38: 'up', 39: 'right', 40: 'down' };
  1002. var focusElement = function() {
  1003. $timeout(function() {
  1004. self.element[0].focus();
  1005. }, 0, false);
  1006. };
  1007. // Listen for focus requests from popup directive
  1008. $scope.$on('datepicker.focus', focusElement);
  1009. $scope.keydown = function(evt) {
  1010. var key = $scope.keys[evt.which];
  1011. if (!key || evt.shiftKey || evt.altKey) {
  1012. return;
  1013. }
  1014. evt.preventDefault();
  1015. evt.stopPropagation();
  1016. if (key === 'enter' || key === 'space') {
  1017. if (self.isDisabled(self.activeDate)) {
  1018. return; // do nothing
  1019. }
  1020. $scope.select(self.activeDate);
  1021. focusElement();
  1022. } else if (evt.ctrlKey && (key === 'up' || key === 'down')) {
  1023. $scope.toggleMode(key === 'up' ? 1 : -1);
  1024. focusElement();
  1025. } else {
  1026. self.handleKeyDown(key, evt);
  1027. self.refreshView();
  1028. }
  1029. };
  1030. }])
  1031. .directive('datepicker', function() {
  1032. return {
  1033. restrict: 'EA',
  1034. replace: true,
  1035. templateUrl: 'template/datepicker/datepicker.html',
  1036. scope: {
  1037. datepickerMode: '=?',
  1038. dateDisabled: '&'
  1039. },
  1040. require: ['datepicker', '?^ngModel'],
  1041. controller: 'DatepickerController',
  1042. link: function(scope, element, attrs, ctrls) {
  1043. var datepickerCtrl = ctrls[0],
  1044. ngModelCtrl = ctrls[1];
  1045. if (ngModelCtrl) {
  1046. datepickerCtrl.init(ngModelCtrl);
  1047. }
  1048. }
  1049. };
  1050. })
  1051. .directive('daypicker', ['dateFilter', function(dateFilter) {
  1052. return {
  1053. restrict: 'EA',
  1054. replace: true,
  1055. templateUrl: 'template/datepicker/day.html',
  1056. require: '^datepicker',
  1057. link: function(scope, element, attrs, ctrl) {
  1058. scope.showWeeks = ctrl.showWeeks;
  1059. ctrl.step = { months: 1 };
  1060. ctrl.element = element;
  1061. var DAYS_IN_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
  1062. function getDaysInMonth(year, month) {
  1063. return ((month === 1) && (year % 4 === 0) && ((year % 100 !== 0) || (year % 400 === 0))) ? 29 : DAYS_IN_MONTH[month];
  1064. }
  1065. function getDates(startDate, n) {
  1066. var dates = new Array(n),
  1067. current = new Date(startDate),
  1068. i = 0;
  1069. current.setHours(12); // Prevent repeated dates because of timezone bug
  1070. while (i < n) {
  1071. dates[i++] = new Date(current);
  1072. current.setDate(current.getDate() + 1);
  1073. }
  1074. return dates;
  1075. }
  1076. ctrl._refreshView = function() {
  1077. var year = ctrl.activeDate.getFullYear(),
  1078. month = ctrl.activeDate.getMonth(),
  1079. firstDayOfMonth = new Date(year, month, 1),
  1080. difference = ctrl.startingDay - firstDayOfMonth.getDay(),
  1081. numDisplayedFromPreviousMonth = (difference > 0) ? 7 - difference : -difference,
  1082. firstDate = new Date(firstDayOfMonth);
  1083. if (numDisplayedFromPreviousMonth > 0) {
  1084. firstDate.setDate(-numDisplayedFromPreviousMonth + 1);
  1085. }
  1086. // 42 is the number of days on a six-month calendar
  1087. var days = getDates(firstDate, 42);
  1088. for (var i = 0; i < 42; i++) {
  1089. days[i] = angular.extend(ctrl.createDateObject(days[i], ctrl.formatDay), {
  1090. secondary: days[i].getMonth() !== month,
  1091. uid: scope.uniqueId + '-' + i
  1092. });
  1093. }
  1094. scope.labels = new Array(7);
  1095. for (var j = 0; j < 7; j++) {
  1096. scope.labels[j] = {
  1097. abbr: dateFilter(days[j].date, ctrl.formatDayHeader),
  1098. full: dateFilter(days[j].date, 'EEEE')
  1099. };
  1100. }
  1101. scope.title = dateFilter(ctrl.activeDate, ctrl.formatDayTitle);
  1102. scope.rows = ctrl.split(days, 7);
  1103. if (scope.showWeeks) {
  1104. scope.weekNumbers = [];
  1105. var weekNumber = getISO8601WeekNumber(scope.rows[0][0].date),
  1106. numWeeks = scope.rows.length;
  1107. while (scope.weekNumbers.push(weekNumber++) < numWeeks) {}
  1108. }
  1109. };
  1110. ctrl.compare = function(date1, date2) {
  1111. return (new Date(date1.getFullYear(), date1.getMonth(), date1.getDate()) - new Date(date2.getFullYear(), date2.getMonth(), date2.getDate()));
  1112. };
  1113. function getISO8601WeekNumber(date) {
  1114. var checkDate = new Date(date);
  1115. checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7)); // Thursday
  1116. var time = checkDate.getTime();
  1117. checkDate.setMonth(0); // Compare with Jan 1
  1118. checkDate.setDate(1);
  1119. return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
  1120. }
  1121. ctrl.handleKeyDown = function(key, evt) {
  1122. var date = ctrl.activeDate.getDate();
  1123. if (key === 'left') {
  1124. date = date - 1; // up
  1125. } else if (key === 'up') {
  1126. date = date - 7; // down
  1127. } else if (key === 'right') {
  1128. date = date + 1; // down
  1129. } else if (key === 'down') {
  1130. date = date + 7;
  1131. } else if (key === 'pageup' || key === 'pagedown') {
  1132. var month = ctrl.activeDate.getMonth() + (key === 'pageup' ? -1 : 1);
  1133. ctrl.activeDate.setMonth(month, 1);
  1134. date = Math.min(getDaysInMonth(ctrl.activeDate.getFullYear(), ctrl.activeDate.getMonth()), date);
  1135. } else if (key === 'home') {
  1136. date = 1;
  1137. } else if (key === 'end') {
  1138. date = getDaysInMonth(ctrl.activeDate.getFullYear(), ctrl.activeDate.getMonth());
  1139. }
  1140. ctrl.activeDate.setDate(date);
  1141. };
  1142. ctrl.refreshView();
  1143. }
  1144. };
  1145. }])
  1146. .directive('weekpicker', ['dateFilter', function(dateFilter) {
  1147. return {
  1148. restrict: 'EA',
  1149. replace: true,
  1150. templateUrl: 'template/datepicker/week.html',
  1151. require: '^datepicker',
  1152. link: function(scope, element, attrs, ctrl) {
  1153. scope.showWeeks = ctrl.showWeeks;
  1154. var week = ['周一', '周二', '周三', '周四', '周五', '周六', '周日'],
  1155. months = ctrl.activeDate.getMonth();
  1156. ctrl.step = { months: 1 };
  1157. ctrl.element = element;
  1158. var DAYS_IN_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
  1159. function getDaysInMonth(year, month) {
  1160. return ((month === 1) && (year % 4 === 0) && ((year % 100 !== 0) || (year % 400 === 0))) ? 29 : DAYS_IN_MONTH[month];
  1161. }
  1162. function getDates(startDate, n) {
  1163. var dates = new Array(n),
  1164. current = new Date(startDate),
  1165. i = 0;
  1166. current.setHours(12); // Prevent repeated dates because of timezone bug
  1167. while (i < n) {
  1168. dates[i++] = new Date(current);
  1169. current.setDate(current.getDate() + 1);
  1170. }
  1171. return dates;
  1172. }
  1173. ctrl._refreshView = function() {
  1174. var year = ctrl.activeDate.getFullYear(),
  1175. month = ctrl.activeDate.getMonth(),
  1176. firstDayOfMonth = new Date(year, month, 1),
  1177. difference = ctrl.startingDay - firstDayOfMonth.getDay(),
  1178. numDisplayedFromPreviousMonth = (difference > 0) ? 7 - difference : -difference,
  1179. firstDate = new Date(firstDayOfMonth);
  1180. if (numDisplayedFromPreviousMonth > 0) {
  1181. firstDate.setDate(-numDisplayedFromPreviousMonth + 1);
  1182. }
  1183. for (var i = 0; i < 7; i++) {
  1184. week[i] = angular.extend(ctrl.createDateObject(new Date(months, i, 1), ctrl.formatMonth), {
  1185. uid: scope.uniqueId + '-' + i
  1186. });
  1187. }
  1188. scope.title = getISO8601WeekNumber(scope.rows[0][0].date);
  1189. scope.rows = ctrl.split(days, 7);
  1190. if (scope.showWeeks) {
  1191. scope.weekNumbers = [];
  1192. var weekNumber = getISO8601WeekNumber(scope.rows[0][0].date),
  1193. numWeeks = scope.rows.length;
  1194. while (scope.weekNumbers.push(weekNumber++) < numWeeks) {}
  1195. }
  1196. };
  1197. ctrl.compare = function(date1, date2) {
  1198. return (new Date(date1.getFullYear(), date1.getMonth(), date1.getDate()) - new Date(date2.getFullYear(), date2.getMonth(), date2.getDate()));
  1199. };
  1200. function getISO8601WeekNumber(date) {
  1201. var checkDate = new Date(date);
  1202. checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7)); // Thursday
  1203. var time = checkDate.getTime();
  1204. checkDate.setMonth(0); // Compare with Jan 1
  1205. checkDate.setDate(1);
  1206. return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
  1207. }
  1208. ctrl.handleKeyDown = function(key, evt) {
  1209. var date = ctrl.activeDate.getDate();
  1210. if (key === 'left') {
  1211. date = date - 1; // up
  1212. } else if (key === 'up') {
  1213. date = date - 7; // down
  1214. } else if (key === 'right') {
  1215. date = date + 1; // down
  1216. } else if (key === 'down') {
  1217. date = date + 7;
  1218. } else if (key === 'pageup' || key === 'pagedown') {
  1219. var month = ctrl.activeDate.getMonth() + (key === 'pageup' ? -1 : 1);
  1220. ctrl.activeDate.setMonth(month, 1);
  1221. date = Math.min(getDaysInMonth(ctrl.activeDate.getFullYear(), ctrl.activeDate.getMonth()), date);
  1222. } else if (key === 'home') {
  1223. date = 1;
  1224. } else if (key === 'end') {
  1225. date = getDaysInMonth(ctrl.activeDate.getFullYear(), ctrl.activeDate.getMonth());
  1226. }
  1227. ctrl.activeDate.setDate(date);
  1228. };
  1229. ctrl.refreshView();
  1230. }
  1231. };
  1232. }])
  1233. // .directive('weekpicker', ['dateFilter', function (dateFilter) {
  1234. // return {
  1235. // restrict: 'EA',
  1236. // replace: true,
  1237. // templateUrl: 'template/datepicker/week.html',
  1238. // require: '^datepicker',
  1239. // link: function(scope, element, attrs, ctrl) {
  1240. // ctrl.step = { years: 1 };
  1241. // ctrl.element = element;
  1242. // ctrl._refreshView = function() {
  1243. // var week=['周一','周二','周三','周四','周五','周六','周日'],
  1244. // // months = new Array(12),
  1245. // months = ctrl.activeDate.getMonth();
  1246. // for ( var i = 0; i < 7; i++ ) {
  1247. // week[i] = angular.extend(ctrl.createDateObject(new Date(months, i, 1), ctrl.formatMonth), {
  1248. // uid: scope.uniqueId + '-' + i
  1249. // });
  1250. // }
  1251. // if ( scope.showWeeks ) {
  1252. // scope.weekNumbers = [];
  1253. // var weekNumber = getISO8601WeekNumber( scope.rows[0][0].date ),
  1254. // numWeeks = scope.rows.length;
  1255. // while( scope.weekNumbers.push(weekNumber++) < numWeeks ) {}
  1256. // }
  1257. // scope.title = getISO8601WeekNumber( scope.rows[0][0].date );
  1258. // scope.rows = ctrl.split(months, 3);
  1259. // };
  1260. // ctrl.compare = function(date1, date2) {
  1261. // return new Date( date1.getFullYear(), date1.getMonth() ) - new Date( date2.getFullYear(), date2.getMonth() );
  1262. // };
  1263. // ctrl.handleKeyDown = function( key, evt ) {
  1264. // var date = ctrl.activeDate.getMonth();
  1265. // if (key === 'left') {
  1266. // date = date - 1; // up
  1267. // } else if (key === 'up') {
  1268. // date = date - 3; // down
  1269. // } else if (key === 'right') {
  1270. // date = date + 1; // down
  1271. // } else if (key === 'down') {
  1272. // date = date + 3;
  1273. // } else if (key === 'pageup' || key === 'pagedown') {
  1274. // var year = ctrl.activeDate.getFullYear() + (key === 'pageup' ? - 1 : 1);
  1275. // ctrl.activeDate.setFullYear(year);
  1276. // } else if (key === 'home') {
  1277. // date = 0;
  1278. // } else if (key === 'end') {
  1279. // date = 11;
  1280. // }
  1281. // ctrl.activeDate.setMonth(date);
  1282. // };
  1283. // ctrl.refreshView();
  1284. // }
  1285. // };
  1286. // }])
  1287. .directive('monthpicker', ['dateFilter', function(dateFilter) {
  1288. return {
  1289. restrict: 'EA',
  1290. replace: true,
  1291. templateUrl: 'template/datepicker/month.html',
  1292. require: '^datepicker',
  1293. link: function(scope, element, attrs, ctrl) {
  1294. ctrl.step = { years: 1 };
  1295. ctrl.element = element;
  1296. ctrl._refreshView = function() {
  1297. var months = new Array(12),
  1298. year = ctrl.activeDate.getFullYear();
  1299. for (var i = 0; i < 12; i++) {
  1300. months[i] = angular.extend(ctrl.createDateObject(new Date(year, i, 1), ctrl.formatMonth), {
  1301. uid: scope.uniqueId + '-' + i
  1302. });
  1303. }
  1304. scope.title = dateFilter(ctrl.activeDate, ctrl.formatMonthTitle);
  1305. scope.rows = ctrl.split(months, 3);
  1306. };
  1307. ctrl.compare = function(date1, date2) {
  1308. return new Date(date1.getFullYear(), date1.getMonth()) - new Date(date2.getFullYear(), date2.getMonth());
  1309. };
  1310. ctrl.handleKeyDown = function(key, evt) {
  1311. var date = ctrl.activeDate.getMonth();
  1312. if (key === 'left') {
  1313. date = date - 1; // up
  1314. } else if (key === 'up') {
  1315. date = date - 3; // down
  1316. } else if (key === 'right') {
  1317. date = date + 1; // down
  1318. } else if (key === 'down') {
  1319. date = date + 3;
  1320. } else if (key === 'pageup' || key === 'pagedown') {
  1321. var year = ctrl.activeDate.getFullYear() + (key === 'pageup' ? -1 : 1);
  1322. ctrl.activeDate.setFullYear(year);
  1323. } else if (key === 'home') {
  1324. date = 0;
  1325. } else if (key === 'end') {
  1326. date = 11;
  1327. }
  1328. ctrl.activeDate.setMonth(date);
  1329. };
  1330. ctrl.refreshView();
  1331. }
  1332. };
  1333. }])
  1334. .directive('yearpicker', ['dateFilter', function(dateFilter) {
  1335. return {
  1336. restrict: 'EA',
  1337. replace: true,
  1338. templateUrl: 'template/datepicker/year.html',
  1339. require: '^datepicker',
  1340. link: function(scope, element, attrs, ctrl) {
  1341. var range = ctrl.yearRange;
  1342. ctrl.step = { years: range };
  1343. ctrl.element = element;
  1344. function getStartingYear(year) {
  1345. return parseInt((year - 1) / range, 10) * range + 1;
  1346. }
  1347. ctrl._refreshView = function() {
  1348. var years = new Array(range);
  1349. for (var i = 0, start = getStartingYear(ctrl.activeDate.getFullYear()); i < range; i++) {
  1350. years[i] = angular.extend(ctrl.createDateObject(new Date(start + i, 0, 1), ctrl.formatYear), {
  1351. uid: scope.uniqueId + '-' + i
  1352. });
  1353. }
  1354. scope.title = [years[0].label, years[range - 1].label].join(' - ');
  1355. scope.rows = ctrl.split(years, 5);
  1356. };
  1357. ctrl.compare = function(date1, date2) {
  1358. return date1.getFullYear() - date2.getFullYear();
  1359. };
  1360. ctrl.handleKeyDown = function(key, evt) {
  1361. var date = ctrl.activeDate.getFullYear();
  1362. if (key === 'left') {
  1363. date = date - 1; // up
  1364. } else if (key === 'up') {
  1365. date = date - 5; // down
  1366. } else if (key === 'right') {
  1367. date = date + 1; // down
  1368. } else if (key === 'down') {
  1369. date = date + 5;
  1370. } else if (key === 'pageup' || key === 'pagedown') {
  1371. date += (key === 'pageup' ? -1 : 1) * ctrl.step.years;
  1372. } else if (key === 'home') {
  1373. date = getStartingYear(ctrl.activeDate.getFullYear());
  1374. } else if (key === 'end') {
  1375. date = getStartingYear(ctrl.activeDate.getFullYear()) + range - 1;
  1376. }
  1377. ctrl.activeDate.setFullYear(date);
  1378. };
  1379. ctrl.refreshView();
  1380. }
  1381. };
  1382. }])
  1383. .constant('datepickerPopupConfig', {
  1384. datepickerPopup: 'yyyy-MM-dd',
  1385. datepickerPopuptime: 'yyyy-MM-dd',
  1386. saveText: '确定',
  1387. currentText: '今天',
  1388. clearText: '清空',
  1389. closeText: '关闭',
  1390. closeOnDateSelection: true,
  1391. appendToBody: false,
  1392. showButtonBar: true
  1393. })
  1394. .directive('datepickerPopup', ['$compile', '$parse', '$document', '$position', 'dateFilter', 'dateParser', 'datepickerPopupConfig',
  1395. function($compile, $parse, $document, $position, dateFilter, dateParser, datepickerPopupConfig) {
  1396. return {
  1397. restrict: 'EA',
  1398. require: 'ngModel',
  1399. scope: {
  1400. isOpen: '=?',
  1401. saveText: '@',
  1402. currentText: '@',
  1403. clearText: '@',
  1404. closeText: '@',
  1405. dateDisabled: '&'
  1406. },
  1407. link: function(scope, element, attrs, ngModel) {
  1408. var dateFormat,
  1409. closeOnDateSelection = angular.isDefined(attrs.closeOnDateSelection) ? scope.$parent.$eval(attrs.closeOnDateSelection) : datepickerPopupConfig.closeOnDateSelection,
  1410. appendToBody = angular.isDefined(attrs.datepickerAppendToBody) ? scope.$parent.$eval(attrs.datepickerAppendToBody) : datepickerPopupConfig.appendToBody;
  1411. scope.showButtonBar = angular.isDefined(attrs.showButtonBar) ? scope.$parent.$eval(attrs.showButtonBar) : datepickerPopupConfig.showButtonBar;
  1412. scope.getText = function(key) {
  1413. return scope[key + 'Text'] || datepickerPopupConfig[key + 'Text'];
  1414. };
  1415. attrs.$observe('datepickerPopup', function(value) {
  1416. dateFormat = value || datepickerPopupConfig.datepickerPopup;
  1417. ngModel.$render();
  1418. });
  1419. // popup element used to display calendar
  1420. var popupEl = angular.element('<div datepicker-popup-wrap><div datepicker></div></div>');
  1421. popupEl.attr({
  1422. 'ng-model': 'date',
  1423. 'ng-change': 'dateSelection()'
  1424. });
  1425. function cameltoDash(string) {
  1426. return string.replace(/([A-Z])/g, function($1) { return '-' + $1.toLowerCase(); });
  1427. }
  1428. // datepicker element
  1429. var datepickerEl = angular.element(popupEl.children()[0]);
  1430. if (attrs.datepickerOptions) {
  1431. angular.forEach(scope.$parent.$eval(attrs.datepickerOptions), function(value, option) {
  1432. datepickerEl.attr(cameltoDash(option), value);
  1433. });
  1434. }
  1435. scope.watchData = {};
  1436. angular.forEach(['minDate', 'maxDate', 'datepickerMode'], function(key) {
  1437. if (attrs[key]) {
  1438. var getAttribute = $parse(attrs[key]);
  1439. scope.$parent.$watch(getAttribute, function(value) {
  1440. scope.watchData[key] = value;
  1441. });
  1442. datepickerEl.attr(cameltoDash(key), 'watchData.' + key);
  1443. // Propagate changes from datepicker to outside
  1444. if (key === 'datepickerMode') {
  1445. var setAttribute = getAttribute.assign;
  1446. scope.$watch('watchData.' + key, function(value, oldvalue) {
  1447. if (value !== oldvalue) {
  1448. setAttribute(scope.$parent, value);
  1449. }
  1450. });
  1451. }
  1452. }
  1453. });
  1454. if (attrs.dateDisabled) {
  1455. datepickerEl.attr('date-disabled', 'dateDisabled({ date: date, mode: mode })');
  1456. }
  1457. function parseDate(viewValue) {
  1458. if (!viewValue) {
  1459. ngModel.$setValidity('date', true);
  1460. return null;
  1461. } else if (angular.isDate(viewValue) && !isNaN(viewValue)) {
  1462. ngModel.$setValidity('date', true);
  1463. return viewValue;
  1464. } else if (angular.isString(viewValue)) {
  1465. var date = dateParser.parse(viewValue, dateFormat) || new Date(viewValue);
  1466. if (isNaN(date)) {
  1467. ngModel.$setValidity('date', false);
  1468. return undefined;
  1469. } else {
  1470. ngModel.$setValidity('date', true);
  1471. return date;
  1472. }
  1473. } else {
  1474. ngModel.$setValidity('date', false);
  1475. return undefined;
  1476. }
  1477. }
  1478. ngModel.$parsers.unshift(parseDate);
  1479. ngModel.$formatters.push(function(value) {
  1480. return ngModel.$isEmpty(value) ? value : dateFilter(value, dateFormat);
  1481. });
  1482. // Inner change
  1483. scope.dateSelection = function(dt) {
  1484. if (angular.isDefined(dt)) {
  1485. scope.date = dt;
  1486. }
  1487. ngModel.$setViewValue(scope.date);
  1488. ngModel.$render();
  1489. if (closeOnDateSelection) {
  1490. scope.isOpen = false;
  1491. element[0].focus();
  1492. }
  1493. };
  1494. element.bind('input change keyup', function() {
  1495. scope.$apply(function() {
  1496. scope.date = ngModel.$modelValue;
  1497. });
  1498. });
  1499. // Outter change
  1500. ngModel.$render = function() {
  1501. //var date = ngModel.$viewValue ? dateFilter(ngModel.$viewValue, dateFormat) : '';
  1502. var date = ngModel.$viewValue ? dateFilter(parseDate(ngModel.$modelValue), dateFormat) : '';
  1503. element.val(date);
  1504. scope.date = parseDate(ngModel.$modelValue);
  1505. };
  1506. var documentClickBind = function(event) {
  1507. if (scope.isOpen && event.target !== element[0]) {
  1508. scope.$apply(function() {
  1509. scope.isOpen = false;
  1510. });
  1511. }
  1512. };
  1513. var keydown = function(evt, noApply) {
  1514. scope.keydown(evt);
  1515. };
  1516. element.bind('keydown', keydown);
  1517. scope.keydown = function(evt) {
  1518. if (evt.which === 27) {
  1519. evt.preventDefault();
  1520. evt.stopPropagation();
  1521. scope.close();
  1522. } else if (evt.which === 40 && !scope.isOpen) {
  1523. scope.isOpen = true;
  1524. }
  1525. };
  1526. scope.$watch('isOpen', function(value) {
  1527. if (value) {
  1528. scope.$broadcast('datepicker.focus');
  1529. scope.position = appendToBody ? $position.offset(element) : $position.position(element);
  1530. scope.position.top = scope.position.top + element.prop('offsetHeight');
  1531. $document.bind('click', documentClickBind);
  1532. } else {
  1533. $document.unbind('click', documentClickBind);
  1534. }
  1535. });
  1536. scope.select = function(date) {
  1537. if (date === 'today') {
  1538. var today = new Date();
  1539. if (angular.isDate(ngModel.$modelValue)) {
  1540. date = new Date(ngModel.$modelValue);
  1541. date.setFullYear(today.getFullYear(), today.getMonth(), today.getDate());
  1542. } else {
  1543. date = new Date(today.setHours(0, 0, 0, 0));
  1544. }
  1545. }
  1546. scope.dateSelection(date);
  1547. };
  1548. scope.close = function() {
  1549. scope.isOpen = false;
  1550. element[0].focus();
  1551. };
  1552. var $popup = $compile(popupEl)(scope);
  1553. // Prevent jQuery cache memory leak (template is now redundant after linking)
  1554. popupEl.remove();
  1555. if (appendToBody) {
  1556. $document.find('body').append($popup);
  1557. } else {
  1558. element.after($popup);
  1559. }
  1560. scope.$on('$destroy', function() {
  1561. $popup.remove();
  1562. element.unbind('keydown', keydown);
  1563. $document.unbind('click', documentClickBind);
  1564. });
  1565. }
  1566. };
  1567. }
  1568. ])
  1569. .directive('datepickerPopuptime', ['$compile', '$parse', '$document', '$position', 'dateFilter', 'dateParser', 'datepickerPopupConfig',
  1570. function($compile, $parse, $document, $position, dateFilter, dateParser, datepickerPopupConfig) {
  1571. return {
  1572. restrict: 'EA',
  1573. require: 'ngModel',
  1574. scope: {
  1575. isOpen: '=?',
  1576. saveText: '@',
  1577. currentText: '@',
  1578. clearText: '@',
  1579. closeText: '@',
  1580. dateDisabled: '&'
  1581. },
  1582. link: function(scope, element, attrs, ngModel) {
  1583. var dateFormat,
  1584. closeOnDateSelection = angular.isDefined(attrs.closeOnDateSelection) ? scope.$parent.$eval(attrs.closeOnDateSelection) : datepickerPopupConfig.closeOnDateSelection,
  1585. appendToBody = angular.isDefined(attrs.datepickerAppendToBody) ? scope.$parent.$eval(attrs.datepickerAppendToBody) : datepickerPopupConfig.appendToBody;
  1586. scope.showButtonBar = angular.isDefined(attrs.showButtonBar) ? scope.$parent.$eval(attrs.showButtonBar) : datepickerPopupConfig.showButtonBar;
  1587. scope.getText = function(key) {
  1588. return scope[key + 'Text'] || datepickerPopupConfig[key + 'Text'];
  1589. };
  1590. attrs.$observe('datepickerPopuptime', function(value) {
  1591. dateFormat = value || datepickerPopupConfig.datepickerPopuptime;
  1592. ngModel.$render();
  1593. });
  1594. // popup element used to display calendar
  1595. var popupEl = angular.element('<div datepicker-popuptime-wrap><div datepicker></div></div>');
  1596. popupEl.attr({
  1597. 'ng-model': 'date',
  1598. 'ng-change': 'dateSelection()'
  1599. });
  1600. function cameltoDash(string) {
  1601. return string.replace(/([A-Z])/g, function($1) { return '-' + $1.toLowerCase(); });
  1602. }
  1603. // datepicker element
  1604. var datepickerEl = angular.element(popupEl.children()[0]);
  1605. if (attrs.datepickerOptions) {
  1606. angular.forEach(scope.$parent.$eval(attrs.datepickerOptions), function(value, option) {
  1607. datepickerEl.attr(cameltoDash(option), value);
  1608. });
  1609. }
  1610. scope.watchData = {};
  1611. angular.forEach(['minDate', 'maxDate', 'datepickerMode'], function(key) {
  1612. if (attrs[key]) {
  1613. var getAttribute = $parse(attrs[key]);
  1614. scope.$parent.$watch(getAttribute, function(value) {
  1615. scope.watchData[key] = value;
  1616. });
  1617. datepickerEl.attr(cameltoDash(key), 'watchData.' + key);
  1618. // Propagate changes from datepicker to outside
  1619. if (key === 'datepickerMode') {
  1620. var setAttribute = getAttribute.assign;
  1621. scope.$watch('watchData.' + key, function(value, oldvalue) {
  1622. if (value !== oldvalue) {
  1623. setAttribute(scope.$parent, value);
  1624. }
  1625. });
  1626. }
  1627. }
  1628. });
  1629. if (attrs.dateDisabled) {
  1630. datepickerEl.attr('date-disabled', 'dateDisabled({ date: date, mode: mode })');
  1631. }
  1632. function parseDate(viewValue) {
  1633. if (!viewValue) {
  1634. ngModel.$setValidity('date', true);
  1635. return null;
  1636. } else if (angular.isDate(viewValue) && !isNaN(viewValue)) {
  1637. ngModel.$setValidity('date', true);
  1638. return viewValue;
  1639. } else if (angular.isString(viewValue)) {
  1640. var date = dateParser.parse(viewValue, dateFormat) || new Date(viewValue);
  1641. if (isNaN(date)) {
  1642. ngModel.$setValidity('date', false);
  1643. return undefined;
  1644. } else {
  1645. ngModel.$setValidity('date', true);
  1646. return date;
  1647. }
  1648. } else {
  1649. ngModel.$setValidity('date', false);
  1650. return undefined;
  1651. }
  1652. }
  1653. ngModel.$parsers.unshift(parseDate);
  1654. ngModel.$formatters.push(function(value) {
  1655. return ngModel.$isEmpty(value) ? value : dateFilter(value, dateFormat);
  1656. });
  1657. // Inner change
  1658. scope.dateSelection = function(dt) {
  1659. if (angular.isDefined(dt)) {
  1660. scope.date = dt;
  1661. }
  1662. ngModel.$setViewValue(scope.date);
  1663. ngModel.$render();
  1664. if (closeOnDateSelection) {
  1665. scope.isOpen = false;
  1666. element[0].focus();
  1667. }
  1668. };
  1669. element.bind('input change keyup', function() {
  1670. scope.$apply(function() {
  1671. scope.date = ngModel.$modelValue;
  1672. });
  1673. });
  1674. // Outter change
  1675. ngModel.$render = function() {
  1676. //var date = ngModel.$viewValue ? dateFilter(ngModel.$viewValue, dateFormat) : '';
  1677. var date = ngModel.$viewValue ? dateFilter(parseDate(ngModel.$modelValue), dateFormat) : '';
  1678. element.val(date);
  1679. scope.date = parseDate(ngModel.$modelValue);
  1680. };
  1681. var documentClickBind = function(event) {
  1682. if (scope.isOpen && event.target !== element[0]) {
  1683. scope.$apply(function() {
  1684. scope.isOpen = false;
  1685. });
  1686. }
  1687. };
  1688. var keydown = function(evt, noApply) {
  1689. scope.keydown(evt);
  1690. };
  1691. element.bind('keydown', keydown);
  1692. scope.keydown = function(evt) {
  1693. if (evt.which === 27) {
  1694. evt.preventDefault();
  1695. evt.stopPropagation();
  1696. scope.close();
  1697. } else if (evt.which === 40 && !scope.isOpen) {
  1698. scope.isOpen = true;
  1699. }
  1700. };
  1701. scope.$watch('isOpen', function(value) {
  1702. if (value) {
  1703. scope.$broadcast('datepicker.focus');
  1704. scope.position = appendToBody ? $position.offset(element) : $position.position(element);
  1705. scope.position.top = scope.position.top + element.prop('offsetHeight');
  1706. $document.bind('click', documentClickBind);
  1707. } else {
  1708. $document.unbind('click', documentClickBind);
  1709. }
  1710. });
  1711. scope.select = function(date) {
  1712. if (date === 'today') {
  1713. var today = new Date();
  1714. if (angular.isDate(ngModel.$modelValue)) {
  1715. date = new Date(ngModel.$modelValue);
  1716. date.setFullYear(today.getFullYear(), today.getMonth(), today.getDate());
  1717. } else {
  1718. date = new Date(today.setHours(0, 0, 0, 0));
  1719. }
  1720. }
  1721. scope.dateSelection(date);
  1722. };
  1723. scope.close = function() {
  1724. scope.isOpen = false;
  1725. element[0].focus();
  1726. };
  1727. var $popup = $compile(popupEl)(scope);
  1728. // Prevent jQuery cache memory leak (template is now redundant after linking)
  1729. popupEl.remove();
  1730. if (appendToBody) {
  1731. $document.find('body').append($popup);
  1732. } else {
  1733. element.after($popup);
  1734. }
  1735. scope.$on('$destroy', function() {
  1736. $popup.remove();
  1737. element.unbind('keydown', keydown);
  1738. $document.unbind('click', documentClickBind);
  1739. });
  1740. }
  1741. };
  1742. }
  1743. ])
  1744. .directive('datepickerPopuptimeWrap', function() {
  1745. return {
  1746. restrict: 'EA',
  1747. replace: true,
  1748. transclude: true,
  1749. templateUrl: 'template/datepicker/popuptime.html',
  1750. link: function(scope, element, attrs) {
  1751. element.bind('click', function(event) {
  1752. event.preventDefault();
  1753. event.stopPropagation();
  1754. });
  1755. }
  1756. };
  1757. })
  1758. .directive('datepickerPopupWrap', function() {
  1759. return {
  1760. restrict: 'EA',
  1761. replace: true,
  1762. transclude: true,
  1763. templateUrl: 'template/datepicker/popup.html',
  1764. link: function(scope, element, attrs) {
  1765. element.bind('click', function(event) {
  1766. event.preventDefault();
  1767. event.stopPropagation();
  1768. });
  1769. if(scope.$parent.model){
  1770. scope.hours = (new Date(Date.parse(scope.$parent.model[scope.$parent.options.key]))).getHours();
  1771. scope.minutes = (new Date(Date.parse(scope.$parent.model[scope.$parent.options.key]))).getMinutes();
  1772. }else if(scope.$parent.incidentModel){
  1773. scope.hours = scope.$parent.incidentModel.yyTime.getHours();
  1774. scope.minutes = scope.$parent.incidentModel.yyTime.getMinutes();
  1775. }
  1776. scope.incrementHours = function() {
  1777. addMinutes(1 * 60);
  1778. };
  1779. scope.save = function(hours, minutes) {
  1780. if(scope.$parent.model){
  1781. scope.$parent.model[scope.$parent.options.key] = moment((new Date(Date.parse(scope.$parent.model[scope.$parent.options.key]))).setHours(hours, minutes)).format('YYYY-MM-DD HH:mm:ss');
  1782. }else if(scope.$parent.incidentModel){
  1783. scope.$parent.incidentModel.yyTime = moment((new Date(Date.parse(scope.$parent.model[scope.$parent.options.key]))).setHours(hours, minutes)).format('YYYY-MM-DD HH:mm:ss');
  1784. }
  1785. scope.isOpen = false;
  1786. };
  1787. scope.updateHours = function(dates) { //手动填写时
  1788. // scope.hours =(new Date(new Date(new Date(Date.parse(scope.$parent.model[scope.$parent.options.key]))).setHours( minutes))).getHours();
  1789. if(scope.$parent.model){
  1790. scope.$parent.model[scope.$parent.options.key] = moment(new Date(dates)).format('YYYY-MM-DD HH:mm:ss');
  1791. }else if(scope.$parent.incidentModel){
  1792. scope.$parent.incidentModel.yyTime = moment(new Date(dates)).format('YYYY-MM-DD HH:mm:ss');
  1793. }
  1794. }
  1795. }
  1796. };
  1797. });
  1798. angular.module('ui.bootstrap.dropdown', [])
  1799. .constant('dropdownConfig', {
  1800. openClass: 'open'
  1801. })
  1802. .service('dropdownService', ['$document', function($document) {
  1803. var openScope = null;
  1804. this.open = function(dropdownScope) {
  1805. if (!openScope) {
  1806. $document.bind('click', closeDropdown);
  1807. $document.bind('keydown', escapeKeyBind);
  1808. }
  1809. if (openScope && openScope !== dropdownScope) {
  1810. openScope.isOpen = false;
  1811. }
  1812. openScope = dropdownScope;
  1813. };
  1814. this.close = function(dropdownScope) {
  1815. if (openScope === dropdownScope) {
  1816. openScope = null;
  1817. $document.unbind('click', closeDropdown);
  1818. $document.unbind('keydown', escapeKeyBind);
  1819. }
  1820. };
  1821. var closeDropdown = function(evt) {
  1822. // This method may still be called during the same mouse event that
  1823. // unbound this event handler. So check openScope before proceeding.
  1824. if (!openScope) { return; }
  1825. var toggleElement = openScope.getToggleElement();
  1826. if (evt && toggleElement && toggleElement[0].contains(evt.target)) {
  1827. return;
  1828. }
  1829. openScope.$apply(function() {
  1830. openScope.isOpen = false;
  1831. });
  1832. };
  1833. var escapeKeyBind = function(evt) {
  1834. if (evt.which === 27) {
  1835. openScope.focusToggleElement();
  1836. closeDropdown();
  1837. }
  1838. };
  1839. }])
  1840. .controller('DropdownController', ['$scope', '$attrs', '$parse', 'dropdownConfig', 'dropdownService', '$animate', function($scope, $attrs, $parse, dropdownConfig, dropdownService, $animate) {
  1841. var self = this,
  1842. scope = $scope.$new(), // create a child scope so we are not polluting original one
  1843. openClass = dropdownConfig.openClass,
  1844. getIsOpen,
  1845. setIsOpen = angular.noop,
  1846. toggleInvoker = $attrs.onToggle ? $parse($attrs.onToggle) : angular.noop;
  1847. this.init = function(element) {
  1848. self.$element = element;
  1849. if ($attrs.isOpen) {
  1850. getIsOpen = $parse($attrs.isOpen);
  1851. setIsOpen = getIsOpen.assign;
  1852. $scope.$watch(getIsOpen, function(value) {
  1853. scope.isOpen = !!value;
  1854. });
  1855. }
  1856. };
  1857. this.toggle = function(open) {
  1858. return scope.isOpen = arguments.length ? !!open : !scope.isOpen;
  1859. };
  1860. // Allow other directives to watch status
  1861. this.isOpen = function() {
  1862. return scope.isOpen;
  1863. };
  1864. scope.getToggleElement = function() {
  1865. return self.toggleElement;
  1866. };
  1867. scope.focusToggleElement = function() {
  1868. if (self.toggleElement) {
  1869. self.toggleElement[0].focus();
  1870. }
  1871. };
  1872. scope.$watch('isOpen', function(isOpen, wasOpen) {
  1873. $animate[isOpen ? 'addClass' : 'removeClass'](self.$element, openClass);
  1874. if (isOpen) {
  1875. scope.focusToggleElement();
  1876. dropdownService.open(scope);
  1877. } else {
  1878. dropdownService.close(scope);
  1879. }
  1880. setIsOpen($scope, isOpen);
  1881. if (angular.isDefined(isOpen) && isOpen !== wasOpen) {
  1882. toggleInvoker($scope, { open: !!isOpen });
  1883. }
  1884. });
  1885. $scope.$on('$locationChangeSuccess', function() {
  1886. scope.isOpen = false;
  1887. });
  1888. $scope.$on('$destroy', function() {
  1889. scope.$destroy();
  1890. });
  1891. }])
  1892. .directive('dropdown', function() {
  1893. return {
  1894. controller: 'DropdownController',
  1895. link: function(scope, element, attrs, dropdownCtrl) {
  1896. dropdownCtrl.init(element);
  1897. }
  1898. };
  1899. })
  1900. .directive('dropdownToggle', function() {
  1901. return {
  1902. require: '?^dropdown',
  1903. link: function(scope, element, attrs, dropdownCtrl) {
  1904. if (!dropdownCtrl) {
  1905. return;
  1906. }
  1907. dropdownCtrl.toggleElement = element;
  1908. var toggleDropdown = function(event) {
  1909. event.preventDefault();
  1910. if (!element.hasClass('disabled') && !attrs.disabled) {
  1911. scope.$apply(function() {
  1912. dropdownCtrl.toggle();
  1913. });
  1914. }
  1915. };
  1916. element.bind('click', toggleDropdown);
  1917. // WAI-ARIA
  1918. element.attr({ 'aria-haspopup': true, 'aria-expanded': false });
  1919. scope.$watch(dropdownCtrl.isOpen, function(isOpen) {
  1920. element.attr('aria-expanded', !!isOpen);
  1921. });
  1922. scope.$on('$destroy', function() {
  1923. element.unbind('click', toggleDropdown);
  1924. });
  1925. }
  1926. };
  1927. });
  1928. angular.module('ui.bootstrap.modal', ['ui.bootstrap.transition'])
  1929. /**
  1930. * A helper, internal data structure that acts as a map but also allows getting / removing
  1931. * elements in the LIFO order
  1932. */
  1933. .factory('$$stackedMap', function() {
  1934. return {
  1935. createNew: function() {
  1936. var stack = [];
  1937. return {
  1938. add: function(key, value) {
  1939. stack.push({
  1940. key: key,
  1941. value: value
  1942. });
  1943. },
  1944. get: function(key) {
  1945. for (var i = 0; i < stack.length; i++) {
  1946. if (key == stack[i].key) {
  1947. return stack[i];
  1948. }
  1949. }
  1950. },
  1951. keys: function() {
  1952. var keys = [];
  1953. for (var i = 0; i < stack.length; i++) {
  1954. keys.push(stack[i].key);
  1955. }
  1956. return keys;
  1957. },
  1958. top: function() {
  1959. return stack[stack.length - 1];
  1960. },
  1961. remove: function(key) {
  1962. var idx = -1;
  1963. for (var i = 0; i < stack.length; i++) {
  1964. if (key == stack[i].key) {
  1965. idx = i;
  1966. break;
  1967. }
  1968. }
  1969. return stack.splice(idx, 1)[0];
  1970. },
  1971. removeTop: function() {
  1972. return stack.splice(stack.length - 1, 1)[0];
  1973. },
  1974. length: function() {
  1975. return stack.length;
  1976. }
  1977. };
  1978. }
  1979. };
  1980. })
  1981. /**
  1982. * A helper directive for the $modal service. It creates a backdrop element.
  1983. */
  1984. .directive('modalBackdrop', ['$timeout', function($timeout) {
  1985. return {
  1986. restrict: 'EA',
  1987. replace: true,
  1988. templateUrl: 'template/modal/backdrop.html',
  1989. link: function(scope, element, attrs) {
  1990. scope.backdropClass = attrs.backdropClass || '';
  1991. scope.animate = false;
  1992. //trigger CSS transitions
  1993. $timeout(function() {
  1994. scope.animate = true;
  1995. });
  1996. }
  1997. };
  1998. }])
  1999. .directive('modalWindow', ['$modalStack', '$timeout', function($modalStack, $timeout) {
  2000. return {
  2001. restrict: 'EA',
  2002. scope: {
  2003. index: '@',
  2004. animate: '='
  2005. },
  2006. replace: true,
  2007. transclude: true,
  2008. templateUrl: function(tElement, tAttrs) {
  2009. return tAttrs.templateUrl || 'template/modal/window.html';
  2010. },
  2011. link: function(scope, element, attrs) {
  2012. element.addClass(attrs.windowClass || '');
  2013. scope.size = attrs.size;
  2014. $timeout(function() {
  2015. // trigger CSS transitions
  2016. scope.animate = true;
  2017. /**
  2018. * Auto-focusing of a freshly-opened modal element causes any child elements
  2019. * with the autofocus attribute to lose focus. This is an issue on touch
  2020. * based devices which will show and then hide the onscreen keyboard.
  2021. * Attempts to refocus the autofocus element via JavaScript will not reopen
  2022. * the onscreen keyboard. Fixed by updated the focusing logic to only autofocus
  2023. * the modal element if the modal does not contain an autofocus element.
  2024. */
  2025. if (!element[0].querySelectorAll('[autofocus]').length) {
  2026. element[0].focus();
  2027. }
  2028. });
  2029. scope.close = function(evt) {
  2030. var modal = $modalStack.getTop();
  2031. if (modal && modal.value.backdrop && modal.value.backdrop != 'static' && (evt.target === evt.currentTarget)) {
  2032. evt.preventDefault();
  2033. evt.stopPropagation();
  2034. $modalStack.dismiss(modal.key, 'backdrop click');
  2035. }
  2036. };
  2037. }
  2038. };
  2039. }])
  2040. .directive('modalTransclude', function() {
  2041. return {
  2042. link: function($scope, $element, $attrs, controller, $transclude) {
  2043. $transclude($scope.$parent, function(clone) {
  2044. $element.empty();
  2045. $element.append(clone);
  2046. });
  2047. }
  2048. };
  2049. })
  2050. .factory('$modalStack', ['$transition', '$timeout', '$document', '$compile', '$rootScope', '$$stackedMap',
  2051. function($transition, $timeout, $document, $compile, $rootScope, $$stackedMap) {
  2052. var OPENED_MODAL_CLASS = 'modal-open';
  2053. var backdropDomEl, backdropScope;
  2054. var openedWindows = $$stackedMap.createNew();
  2055. var $modalStack = {};
  2056. function backdropIndex() {
  2057. var topBackdropIndex = -1;
  2058. var opened = openedWindows.keys();
  2059. for (var i = 0; i < opened.length; i++) {
  2060. if (openedWindows.get(opened[i]).value.backdrop) {
  2061. topBackdropIndex = i;
  2062. }
  2063. }
  2064. return topBackdropIndex;
  2065. }
  2066. $rootScope.$watch(backdropIndex, function(newBackdropIndex) {
  2067. if (backdropScope) {
  2068. backdropScope.index = newBackdropIndex;
  2069. }
  2070. });
  2071. function removeModalWindow(modalInstance) {
  2072. var body = $document.find('body').eq(0);
  2073. var modalWindow = openedWindows.get(modalInstance).value;
  2074. //clean up the stack
  2075. openedWindows.remove(modalInstance);
  2076. //remove window DOM element
  2077. removeAfterAnimate(modalWindow.modalDomEl, modalWindow.modalScope, 300, function() {
  2078. modalWindow.modalScope.$destroy();
  2079. body.toggleClass(OPENED_MODAL_CLASS, openedWindows.length() > 0);
  2080. checkRemoveBackdrop();
  2081. });
  2082. }
  2083. function checkRemoveBackdrop() {
  2084. //remove backdrop if no longer needed
  2085. if (backdropDomEl && backdropIndex() == -1) {
  2086. var backdropScopeRef = backdropScope;
  2087. removeAfterAnimate(backdropDomEl, backdropScope, 150, function() {
  2088. backdropScopeRef.$destroy();
  2089. backdropScopeRef = null;
  2090. });
  2091. backdropDomEl = undefined;
  2092. backdropScope = undefined;
  2093. }
  2094. }
  2095. function removeAfterAnimate(domEl, scope, emulateTime, done) {
  2096. // Closing animation
  2097. scope.animate = false;
  2098. var transitionEndEventName = $transition.transitionEndEventName;
  2099. if (transitionEndEventName) {
  2100. // transition out
  2101. var timeout = $timeout(afterAnimating, emulateTime);
  2102. domEl.bind(transitionEndEventName, function() {
  2103. $timeout.cancel(timeout);
  2104. afterAnimating();
  2105. scope.$apply();
  2106. });
  2107. } else {
  2108. // Ensure this call is async
  2109. $timeout(afterAnimating);
  2110. }
  2111. function afterAnimating() {
  2112. if (afterAnimating.done) {
  2113. return;
  2114. }
  2115. afterAnimating.done = true;
  2116. domEl.remove();
  2117. if (done) {
  2118. done();
  2119. }
  2120. }
  2121. }
  2122. $document.bind('keydown', function(evt) {
  2123. var modal;
  2124. if (evt.which === 27) {
  2125. modal = openedWindows.top();
  2126. if (modal && modal.value.keyboard) {
  2127. evt.preventDefault();
  2128. $rootScope.$apply(function() {
  2129. $modalStack.dismiss(modal.key, 'escape key press');
  2130. });
  2131. }
  2132. }
  2133. });
  2134. $modalStack.open = function(modalInstance, modal) {
  2135. openedWindows.add(modalInstance, {
  2136. deferred: modal.deferred,
  2137. modalScope: modal.scope,
  2138. backdrop: modal.backdrop,
  2139. keyboard: modal.keyboard
  2140. });
  2141. var body = $document.find('body').eq(0),
  2142. currBackdropIndex = backdropIndex();
  2143. if (currBackdropIndex >= 0 && !backdropDomEl) {
  2144. backdropScope = $rootScope.$new(true);
  2145. backdropScope.index = currBackdropIndex;
  2146. var angularBackgroundDomEl = angular.element('<div modal-backdrop></div>');
  2147. angularBackgroundDomEl.attr('backdrop-class', modal.backdropClass);
  2148. backdropDomEl = $compile(angularBackgroundDomEl)(backdropScope);
  2149. body.append(backdropDomEl);
  2150. }
  2151. var angularDomEl = angular.element('<div modal-window></div>');
  2152. angularDomEl.attr({
  2153. 'template-url': modal.windowTemplateUrl,
  2154. 'window-class': modal.windowClass,
  2155. 'size': modal.size,
  2156. 'index': openedWindows.length() - 1,
  2157. 'animate': 'animate'
  2158. }).html(modal.content);
  2159. var modalDomEl = $compile(angularDomEl)(modal.scope);
  2160. openedWindows.top().value.modalDomEl = modalDomEl;
  2161. body.append(modalDomEl);
  2162. body.addClass(OPENED_MODAL_CLASS);
  2163. };
  2164. $modalStack.close = function(modalInstance, result) {
  2165. var modalWindow = openedWindows.get(modalInstance);
  2166. if (modalWindow) {
  2167. modalWindow.value.deferred.resolve(result);
  2168. removeModalWindow(modalInstance);
  2169. }
  2170. };
  2171. $modalStack.dismiss = function(modalInstance, reason) {
  2172. var modalWindow = openedWindows.get(modalInstance);
  2173. if (modalWindow) {
  2174. modalWindow.value.deferred.reject(reason);
  2175. removeModalWindow(modalInstance);
  2176. }
  2177. };
  2178. $modalStack.dismissAll = function(reason) {
  2179. var topModal = this.getTop();
  2180. while (topModal) {
  2181. this.dismiss(topModal.key, reason);
  2182. topModal = this.getTop();
  2183. }
  2184. };
  2185. $modalStack.getTop = function() {
  2186. return openedWindows.top();
  2187. };
  2188. return $modalStack;
  2189. }
  2190. ])
  2191. .provider('$modal', function() {
  2192. var $modalProvider = {
  2193. options: {
  2194. backdrop: true, //can be also false or 'static'
  2195. keyboard: true
  2196. },
  2197. $get: ['$injector', '$rootScope', '$q', '$http', '$templateCache', '$controller', '$modalStack',
  2198. function($injector, $rootScope, $q, $http, $templateCache, $controller, $modalStack) {
  2199. var $modal = {};
  2200. function getTemplatePromise(options) {
  2201. return options.template ? $q.when(options.template) :
  2202. $http.get(angular.isFunction(options.templateUrl) ? (options.templateUrl)() : options.templateUrl, { cache: $templateCache }).then(function(result) {
  2203. return result.data;
  2204. });
  2205. }
  2206. function getResolvePromises(resolves) {
  2207. var promisesArr = [];
  2208. angular.forEach(resolves, function(value) {
  2209. if (angular.isFunction(value) || angular.isArray(value)) {
  2210. promisesArr.push($q.when($injector.invoke(value)));
  2211. }
  2212. });
  2213. return promisesArr;
  2214. }
  2215. $modal.open = function(modalOptions) {
  2216. var modalResultDeferred = $q.defer();
  2217. var modalOpenedDeferred = $q.defer();
  2218. //prepare an instance of a modal to be injected into controllers and returned to a caller
  2219. var modalInstance = {
  2220. result: modalResultDeferred.promise,
  2221. opened: modalOpenedDeferred.promise,
  2222. close: function(result) {
  2223. $modalStack.close(modalInstance, result);
  2224. },
  2225. dismiss: function(reason) {
  2226. $modalStack.dismiss(modalInstance, reason);
  2227. }
  2228. };
  2229. //merge and clean up options
  2230. modalOptions = angular.extend({}, $modalProvider.options, modalOptions);
  2231. modalOptions.resolve = modalOptions.resolve || {};
  2232. //verify options
  2233. if (!modalOptions.template && !modalOptions.templateUrl) {
  2234. throw new Error('One of template or templateUrl options is required.');
  2235. }
  2236. var templateAndResolvePromise =
  2237. $q.all([getTemplatePromise(modalOptions)].concat(getResolvePromises(modalOptions.resolve)));
  2238. templateAndResolvePromise.then(function resolveSuccess(tplAndVars) {
  2239. var modalScope = (modalOptions.scope || $rootScope).$new();
  2240. modalScope.$close = modalInstance.close;
  2241. modalScope.$dismiss = modalInstance.dismiss;
  2242. var ctrlInstance, ctrlLocals = {};
  2243. var resolveIter = 1;
  2244. //controllers
  2245. if (modalOptions.controller) {
  2246. ctrlLocals.$scope = modalScope;
  2247. ctrlLocals.$modalInstance = modalInstance;
  2248. angular.forEach(modalOptions.resolve, function(value, key) {
  2249. ctrlLocals[key] = tplAndVars[resolveIter++];
  2250. });
  2251. ctrlInstance = $controller(modalOptions.controller, ctrlLocals);
  2252. if (modalOptions.controllerAs) {
  2253. modalScope[modalOptions.controllerAs] = ctrlInstance;
  2254. }
  2255. }
  2256. $modalStack.open(modalInstance, {
  2257. scope: modalScope,
  2258. deferred: modalResultDeferred,
  2259. content: tplAndVars[0],
  2260. backdrop: modalOptions.backdrop,
  2261. keyboard: modalOptions.keyboard,
  2262. backdropClass: modalOptions.backdropClass,
  2263. windowClass: modalOptions.windowClass,
  2264. windowTemplateUrl: modalOptions.windowTemplateUrl,
  2265. size: modalOptions.size
  2266. });
  2267. }, function resolveError(reason) {
  2268. modalResultDeferred.reject(reason);
  2269. });
  2270. templateAndResolvePromise.then(function() {
  2271. modalOpenedDeferred.resolve(true);
  2272. }, function() {
  2273. modalOpenedDeferred.reject(false);
  2274. });
  2275. return modalInstance;
  2276. };
  2277. return $modal;
  2278. }
  2279. ]
  2280. };
  2281. return $modalProvider;
  2282. });
  2283. angular.module('ui.bootstrap.pagination', [])
  2284. .controller('PaginationController', ['$scope', '$attrs', '$parse', function($scope, $attrs, $parse) {
  2285. var self = this,
  2286. ngModelCtrl = { $setViewValue: angular.noop }, // nullModelCtrl
  2287. setNumPages = $attrs.numPages ? $parse($attrs.numPages).assign : angular.noop;
  2288. this.init = function(ngModelCtrl_, config) {
  2289. ngModelCtrl = ngModelCtrl_;
  2290. this.config = config;
  2291. ngModelCtrl.$render = function() {
  2292. self.render();
  2293. };
  2294. if ($attrs.itemsPerPage) {
  2295. $scope.$parent.$watch($parse($attrs.itemsPerPage), function(value) {
  2296. self.itemsPerPage = parseInt(value, 10);
  2297. $scope.totalPages = self.calculateTotalPages();
  2298. });
  2299. } else {
  2300. this.itemsPerPage = config.itemsPerPage;
  2301. }
  2302. };
  2303. this.calculateTotalPages = function() {
  2304. var totalPages = this.itemsPerPage < 1 ? 1 : Math.ceil($scope.totalItems / this.itemsPerPage);
  2305. return Math.max(totalPages || 0, 1);
  2306. };
  2307. this.render = function() {
  2308. $scope.page = parseInt(ngModelCtrl.$viewValue, 10) || 1;
  2309. };
  2310. $scope.selectPage = function(page) {
  2311. if ($scope.page !== page && page > 0 && page <= $scope.totalPages) {
  2312. ngModelCtrl.$setViewValue(page);
  2313. ngModelCtrl.$render();
  2314. }
  2315. };
  2316. $scope.getText = function(key) {
  2317. return $scope[key + 'Text'] || self.config[key + 'Text'];
  2318. };
  2319. $scope.noPrevious = function() {
  2320. return $scope.page === 1;
  2321. };
  2322. $scope.noNext = function() {
  2323. return $scope.page === $scope.totalPages;
  2324. };
  2325. $scope.$watch('totalItems', function() {
  2326. $scope.totalPages = self.calculateTotalPages();
  2327. });
  2328. $scope.$watch('totalPages', function(value) {
  2329. setNumPages($scope.$parent, value); // Readonly variable
  2330. if ($scope.page > value) {
  2331. $scope.selectPage(value);
  2332. } else {
  2333. ngModelCtrl.$render();
  2334. }
  2335. });
  2336. }])
  2337. .constant('paginationConfig', {
  2338. itemsPerPage: 10,
  2339. boundaryLinks: false,
  2340. directionLinks: true,
  2341. firstText: 'First',
  2342. previousText: 'Previous',
  2343. nextText: 'Next',
  2344. lastText: 'Last',
  2345. rotate: true
  2346. })
  2347. .directive('pagination', ['$parse', 'paginationConfig', function($parse, paginationConfig) {
  2348. return {
  2349. restrict: 'EA',
  2350. scope: {
  2351. totalItems: '=',
  2352. firstText: '@',
  2353. previousText: '@',
  2354. nextText: '@',
  2355. lastText: '@'
  2356. },
  2357. require: ['pagination', '?ngModel'],
  2358. controller: 'PaginationController',
  2359. templateUrl: 'template/pagination/pagination.html',
  2360. replace: true,
  2361. link: function(scope, element, attrs, ctrls) {
  2362. var paginationCtrl = ctrls[0],
  2363. ngModelCtrl = ctrls[1];
  2364. if (!ngModelCtrl) {
  2365. return; // do nothing if no ng-model
  2366. }
  2367. // Setup configuration parameters
  2368. var maxSize = angular.isDefined(attrs.maxSize) ? scope.$parent.$eval(attrs.maxSize) : paginationConfig.maxSize,
  2369. rotate = angular.isDefined(attrs.rotate) ? scope.$parent.$eval(attrs.rotate) : paginationConfig.rotate;
  2370. scope.boundaryLinks = angular.isDefined(attrs.boundaryLinks) ? scope.$parent.$eval(attrs.boundaryLinks) : paginationConfig.boundaryLinks;
  2371. scope.directionLinks = angular.isDefined(attrs.directionLinks) ? scope.$parent.$eval(attrs.directionLinks) : paginationConfig.directionLinks;
  2372. paginationCtrl.init(ngModelCtrl, paginationConfig);
  2373. if (attrs.maxSize) {
  2374. scope.$parent.$watch($parse(attrs.maxSize), function(value) {
  2375. maxSize = parseInt(value, 10);
  2376. paginationCtrl.render();
  2377. });
  2378. }
  2379. // Create page object used in template
  2380. function makePage(number, text, isActive) {
  2381. return {
  2382. number: number,
  2383. text: text,
  2384. active: isActive
  2385. };
  2386. }
  2387. function getPages(currentPage, totalPages) {
  2388. var pages = [];
  2389. // Default page limits
  2390. var startPage = 1,
  2391. endPage = totalPages;
  2392. var isMaxSized = (angular.isDefined(maxSize) && maxSize < totalPages);
  2393. // recompute if maxSize
  2394. if (isMaxSized) {
  2395. if (rotate) {
  2396. // Current page is displayed in the middle of the visible ones
  2397. startPage = Math.max(currentPage - Math.floor(maxSize / 2), 1);
  2398. endPage = startPage + maxSize - 1;
  2399. // Adjust if limit is exceeded
  2400. if (endPage > totalPages) {
  2401. endPage = totalPages;
  2402. startPage = endPage - maxSize + 1;
  2403. }
  2404. } else {
  2405. // Visible pages are paginated with maxSize
  2406. startPage = ((Math.ceil(currentPage / maxSize) - 1) * maxSize) + 1;
  2407. // Adjust last page if limit is exceeded
  2408. endPage = Math.min(startPage + maxSize - 1, totalPages);
  2409. }
  2410. }
  2411. // Add page number links
  2412. for (var number = startPage; number <= endPage; number++) {
  2413. var page = makePage(number, number, number === currentPage);
  2414. pages.push(page);
  2415. }
  2416. // Add links to move between page sets
  2417. if (isMaxSized && !rotate) {
  2418. if (startPage > 1) {
  2419. var previousPageSet = makePage(startPage - 1, '...', false);
  2420. pages.unshift(previousPageSet);
  2421. }
  2422. if (endPage < totalPages) {
  2423. var nextPageSet = makePage(endPage + 1, '...', false);
  2424. pages.push(nextPageSet);
  2425. }
  2426. }
  2427. return pages;
  2428. }
  2429. var originalRender = paginationCtrl.render;
  2430. paginationCtrl.render = function() {
  2431. originalRender();
  2432. if (scope.page > 0 && scope.page <= scope.totalPages) {
  2433. scope.pages = getPages(scope.page, scope.totalPages);
  2434. }
  2435. };
  2436. }
  2437. };
  2438. }])
  2439. .constant('pagerConfig', {
  2440. itemsPerPage: 10,
  2441. previousText: '« Previous',
  2442. nextText: 'Next »',
  2443. align: true
  2444. })
  2445. .directive('pager', ['pagerConfig', function(pagerConfig) {
  2446. return {
  2447. restrict: 'EA',
  2448. scope: {
  2449. totalItems: '=',
  2450. previousText: '@',
  2451. nextText: '@'
  2452. },
  2453. require: ['pager', '?ngModel'],
  2454. controller: 'PaginationController',
  2455. templateUrl: 'template/pagination/pager.html',
  2456. replace: true,
  2457. link: function(scope, element, attrs, ctrls) {
  2458. var paginationCtrl = ctrls[0],
  2459. ngModelCtrl = ctrls[1];
  2460. if (!ngModelCtrl) {
  2461. return; // do nothing if no ng-model
  2462. }
  2463. scope.align = angular.isDefined(attrs.align) ? scope.$parent.$eval(attrs.align) : pagerConfig.align;
  2464. paginationCtrl.init(ngModelCtrl, pagerConfig);
  2465. }
  2466. };
  2467. }]);
  2468. /**
  2469. * The following features are still outstanding: animation as a
  2470. * function, placement as a function, inside, support for more triggers than
  2471. * just mouse enter/leave, html tooltips, and selector delegation.
  2472. */
  2473. angular.module('ui.bootstrap.tooltip', ['ui.bootstrap.position', 'ui.bootstrap.bindHtml'])
  2474. /**
  2475. * The $tooltip service creates tooltip- and popover-like directives as well as
  2476. * houses global options for them.
  2477. */
  2478. .provider('$tooltip', function() {
  2479. // The default options tooltip and popover.
  2480. var defaultOptions = {
  2481. placement: 'top',
  2482. animation: true,
  2483. popupDelay: 0
  2484. };
  2485. // Default hide triggers for each show trigger
  2486. var triggerMap = {
  2487. 'mouseenter': 'mouseleave',
  2488. 'click': 'click',
  2489. 'focus': 'blur'
  2490. };
  2491. // The options specified to the provider globally.
  2492. var globalOptions = {};
  2493. /**
  2494. * `options({})` allows global configuration of all tooltips in the
  2495. * application.
  2496. *
  2497. * var app = angular.module( 'App', ['ui.bootstrap.tooltip'], function( $tooltipProvider ) {
  2498. * // place tooltips left instead of top by default
  2499. * $tooltipProvider.options( { placement: 'left' } );
  2500. * });
  2501. */
  2502. this.options = function(value) {
  2503. angular.extend(globalOptions, value);
  2504. };
  2505. /**
  2506. * This allows you to extend the set of trigger mappings available. E.g.:
  2507. *
  2508. * $tooltipProvider.setTriggers( 'openTrigger': 'closeTrigger' );
  2509. */
  2510. this.setTriggers = function setTriggers(triggers) {
  2511. angular.extend(triggerMap, triggers);
  2512. };
  2513. /**
  2514. * This is a helper function for translating camel-case to snake-case.
  2515. */
  2516. function snake_case(name) {
  2517. var regexp = /[A-Z]/g;
  2518. var separator = '-';
  2519. return name.replace(regexp, function(letter, pos) {
  2520. return (pos ? separator : '') + letter.toLowerCase();
  2521. });
  2522. }
  2523. /**
  2524. * Returns the actual instance of the $tooltip service.
  2525. * TODO support multiple triggers
  2526. */
  2527. this.$get = ['$window', '$compile', '$timeout', '$document', '$position', '$interpolate', function($window, $compile, $timeout, $document, $position, $interpolate) {
  2528. return function $tooltip(type, prefix, defaultTriggerShow) {
  2529. var options = angular.extend({}, defaultOptions, globalOptions);
  2530. /**
  2531. * Returns an object of show and hide triggers.
  2532. *
  2533. * If a trigger is supplied,
  2534. * it is used to show the tooltip; otherwise, it will use the `trigger`
  2535. * option passed to the `$tooltipProvider.options` method; else it will
  2536. * default to the trigger supplied to this directive factory.
  2537. *
  2538. * The hide trigger is based on the show trigger. If the `trigger` option
  2539. * was passed to the `$tooltipProvider.options` method, it will use the
  2540. * mapped trigger from `triggerMap` or the passed trigger if the map is
  2541. * undefined; otherwise, it uses the `triggerMap` value of the show
  2542. * trigger; else it will just use the show trigger.
  2543. */
  2544. function getTriggers(trigger) {
  2545. var show = trigger || options.trigger || defaultTriggerShow;
  2546. var hide = triggerMap[show] || show;
  2547. return {
  2548. show: show,
  2549. hide: hide
  2550. };
  2551. }
  2552. var directiveName = snake_case(type);
  2553. var startSym = $interpolate.startSymbol();
  2554. var endSym = $interpolate.endSymbol();
  2555. var template =
  2556. '<div ' + directiveName + '-popup ' +
  2557. 'title="' + startSym + 'title' + endSym + '" ' +
  2558. 'content="' + startSym + 'content' + endSym + '" ' +
  2559. 'placement="' + startSym + 'placement' + endSym + '" ' +
  2560. 'animation="animation" ' +
  2561. 'is-open="isOpen"' +
  2562. '>' +
  2563. '</div>';
  2564. return {
  2565. restrict: 'EA',
  2566. compile: function(tElem, tAttrs) {
  2567. var tooltipLinker = $compile(template);
  2568. return function link(scope, element, attrs) {
  2569. var tooltip;
  2570. var tooltipLinkedScope;
  2571. var transitionTimeout;
  2572. var popupTimeout;
  2573. var appendToBody = angular.isDefined(options.appendToBody) ? options.appendToBody : false;
  2574. var triggers = getTriggers(undefined);
  2575. var hasEnableExp = angular.isDefined(attrs[prefix + 'Enable']);
  2576. var ttScope = scope.$new(true);
  2577. var positionTooltip = function() {
  2578. var ttPosition = $position.positionElements(element, tooltip, ttScope.placement, appendToBody);
  2579. ttPosition.top += 'px';
  2580. ttPosition.left += 'px';
  2581. // Now set the calculated positioning.
  2582. tooltip.css(ttPosition);
  2583. };
  2584. // By default, the tooltip is not open.
  2585. // TODO add ability to start tooltip opened
  2586. ttScope.isOpen = false;
  2587. function toggleTooltipBind() {
  2588. if (!ttScope.isOpen) {
  2589. showTooltipBind();
  2590. } else {
  2591. hideTooltipBind();
  2592. }
  2593. }
  2594. // Show the tooltip with delay if specified, otherwise show it immediately
  2595. function showTooltipBind() {
  2596. if (hasEnableExp && !scope.$eval(attrs[prefix + 'Enable'])) {
  2597. return;
  2598. }
  2599. prepareTooltip();
  2600. if (ttScope.popupDelay) {
  2601. // Do nothing if the tooltip was already scheduled to pop-up.
  2602. // This happens if show is triggered multiple times before any hide is triggered.
  2603. if (!popupTimeout) {
  2604. popupTimeout = $timeout(show, ttScope.popupDelay, false);
  2605. popupTimeout.then(function(reposition) { reposition(); });
  2606. }
  2607. } else {
  2608. show()();
  2609. }
  2610. }
  2611. function hideTooltipBind() {
  2612. scope.$apply(function() {
  2613. hide();
  2614. });
  2615. }
  2616. // Show the tooltip popup element.
  2617. function show() {
  2618. popupTimeout = null;
  2619. // If there is a pending remove transition, we must cancel it, lest the
  2620. // tooltip be mysteriously removed.
  2621. if (transitionTimeout) {
  2622. $timeout.cancel(transitionTimeout);
  2623. transitionTimeout = null;
  2624. }
  2625. // Don't show empty tooltips.
  2626. if (!ttScope.content) {
  2627. return angular.noop;
  2628. }
  2629. createTooltip();
  2630. // Set the initial positioning.
  2631. tooltip.css({ top: 0, left: 0, display: 'block' });
  2632. ttScope.$digest();
  2633. positionTooltip();
  2634. // And show the tooltip.
  2635. ttScope.isOpen = true;
  2636. ttScope.$digest(); // digest required as $apply is not called
  2637. // Return positioning function as promise callback for correct
  2638. // positioning after draw.
  2639. return positionTooltip;
  2640. }
  2641. // Hide the tooltip popup element.
  2642. function hide() {
  2643. // First things first: we don't show it anymore.
  2644. ttScope.isOpen = false;
  2645. //if tooltip is going to be shown after delay, we must cancel this
  2646. $timeout.cancel(popupTimeout);
  2647. popupTimeout = null;
  2648. // And now we remove it from the DOM. However, if we have animation, we
  2649. // need to wait for it to expire beforehand.
  2650. // FIXME: this is a placeholder for a port of the transitions library.
  2651. if (ttScope.animation) {
  2652. if (!transitionTimeout) {
  2653. transitionTimeout = $timeout(removeTooltip, 500);
  2654. }
  2655. } else {
  2656. removeTooltip();
  2657. }
  2658. }
  2659. function createTooltip() {
  2660. // There can only be one tooltip element per directive shown at once.
  2661. if (tooltip) {
  2662. removeTooltip();
  2663. }
  2664. tooltipLinkedScope = ttScope.$new();
  2665. tooltip = tooltipLinker(tooltipLinkedScope, function(tooltip) {
  2666. if (appendToBody) {
  2667. $document.find('body').append(tooltip);
  2668. } else {
  2669. element.after(tooltip);
  2670. }
  2671. });
  2672. }
  2673. function removeTooltip() {
  2674. transitionTimeout = null;
  2675. if (tooltip) {
  2676. tooltip.remove();
  2677. tooltip = null;
  2678. }
  2679. if (tooltipLinkedScope) {
  2680. tooltipLinkedScope.$destroy();
  2681. tooltipLinkedScope = null;
  2682. }
  2683. }
  2684. function prepareTooltip() {
  2685. prepPlacement();
  2686. prepPopupDelay();
  2687. }
  2688. /**
  2689. * Observe the relevant attributes.
  2690. */
  2691. attrs.$observe(type, function(val) {
  2692. ttScope.content = val;
  2693. if (!val && ttScope.isOpen) {
  2694. hide();
  2695. }
  2696. });
  2697. attrs.$observe(prefix + 'Title', function(val) {
  2698. ttScope.title = val;
  2699. });
  2700. function prepPlacement() {
  2701. var val = attrs[prefix + 'Placement'];
  2702. ttScope.placement = angular.isDefined(val) ? val : options.placement;
  2703. }
  2704. function prepPopupDelay() {
  2705. var val = attrs[prefix + 'PopupDelay'];
  2706. var delay = parseInt(val, 10);
  2707. ttScope.popupDelay = !isNaN(delay) ? delay : options.popupDelay;
  2708. }
  2709. var unregisterTriggers = function() {
  2710. element.unbind(triggers.show, showTooltipBind);
  2711. element.unbind(triggers.hide, hideTooltipBind);
  2712. };
  2713. function prepTriggers() {
  2714. var val = attrs[prefix + 'Trigger'];
  2715. unregisterTriggers();
  2716. triggers = getTriggers(val);
  2717. if (triggers.show === triggers.hide) {
  2718. element.bind(triggers.show, toggleTooltipBind);
  2719. } else {
  2720. element.bind(triggers.show, showTooltipBind);
  2721. element.bind(triggers.hide, hideTooltipBind);
  2722. }
  2723. }
  2724. prepTriggers();
  2725. var animation = scope.$eval(attrs[prefix + 'Animation']);
  2726. ttScope.animation = angular.isDefined(animation) ? !!animation : options.animation;
  2727. var appendToBodyVal = scope.$eval(attrs[prefix + 'AppendToBody']);
  2728. appendToBody = angular.isDefined(appendToBodyVal) ? appendToBodyVal : appendToBody;
  2729. // if a tooltip is attached to <body> we need to remove it on
  2730. // location change as its parent scope will probably not be destroyed
  2731. // by the change.
  2732. if (appendToBody) {
  2733. scope.$on('$locationChangeSuccess', function closeTooltipOnLocationChangeSuccess() {
  2734. if (ttScope.isOpen) {
  2735. hide();
  2736. }
  2737. });
  2738. }
  2739. // Make sure tooltip is destroyed and removed.
  2740. scope.$on('$destroy', function onDestroyTooltip() {
  2741. $timeout.cancel(transitionTimeout);
  2742. $timeout.cancel(popupTimeout);
  2743. unregisterTriggers();
  2744. removeTooltip();
  2745. ttScope = null;
  2746. });
  2747. };
  2748. }
  2749. };
  2750. };
  2751. }];
  2752. })
  2753. .directive('tooltipPopup', function() {
  2754. return {
  2755. restrict: 'EA',
  2756. replace: true,
  2757. scope: { content: '@', placement: '@', animation: '&', isOpen: '&' },
  2758. templateUrl: 'template/tooltip/tooltip-popup.html'
  2759. };
  2760. })
  2761. .directive('tooltip', ['$tooltip', function($tooltip) {
  2762. return $tooltip('tooltip', 'tooltip', 'mouseenter');
  2763. }])
  2764. .directive('tooltipHtmlUnsafePopup', function() {
  2765. return {
  2766. restrict: 'EA',
  2767. replace: true,
  2768. scope: { content: '@', placement: '@', animation: '&', isOpen: '&' },
  2769. templateUrl: 'template/tooltip/tooltip-html-unsafe-popup.html'
  2770. };
  2771. })
  2772. .directive('tooltipHtmlUnsafe', ['$tooltip', function($tooltip) {
  2773. return $tooltip('tooltipHtmlUnsafe', 'tooltip', 'mouseenter');
  2774. }]);
  2775. /**
  2776. * The following features are still outstanding: popup delay, animation as a
  2777. * function, placement as a function, inside, support for more triggers than
  2778. * just mouse enter/leave, html popovers, and selector delegatation.
  2779. */
  2780. angular.module('ui.bootstrap.popover', ['ui.bootstrap.tooltip'])
  2781. .directive('popoverPopup', function() {
  2782. return {
  2783. restrict: 'EA',
  2784. replace: true,
  2785. scope: { title: '@', content: '@', placement: '@', animation: '&', isOpen: '&' },
  2786. templateUrl: 'template/popover/popover.html'
  2787. };
  2788. })
  2789. .directive('popover', ['$tooltip', function($tooltip) {
  2790. return $tooltip('popover', 'popover', 'click');
  2791. }]);
  2792. angular.module('ui.bootstrap.progressbar', [])
  2793. .constant('progressConfig', {
  2794. animate: true,
  2795. max: 100
  2796. })
  2797. .controller('ProgressController', ['$scope', '$attrs', 'progressConfig', function($scope, $attrs, progressConfig) {
  2798. var self = this,
  2799. animate = angular.isDefined($attrs.animate) ? $scope.$parent.$eval($attrs.animate) : progressConfig.animate;
  2800. this.bars = [];
  2801. $scope.max = angular.isDefined($attrs.max) ? $scope.$parent.$eval($attrs.max) : progressConfig.max;
  2802. this.addBar = function(bar, element) {
  2803. if (!animate) {
  2804. element.css({ 'transition': 'none' });
  2805. }
  2806. this.bars.push(bar);
  2807. bar.$watch('value', function(value) {
  2808. bar.percent = +(100 * value / $scope.max).toFixed(2);
  2809. });
  2810. bar.$on('$destroy', function() {
  2811. element = null;
  2812. self.removeBar(bar);
  2813. });
  2814. };
  2815. this.removeBar = function(bar) {
  2816. this.bars.splice(this.bars.indexOf(bar), 1);
  2817. };
  2818. }])
  2819. .directive('progress', function() {
  2820. return {
  2821. restrict: 'EA',
  2822. replace: true,
  2823. transclude: true,
  2824. controller: 'ProgressController',
  2825. require: 'progress',
  2826. scope: {},
  2827. templateUrl: 'template/progressbar/progress.html'
  2828. };
  2829. })
  2830. .directive('bar', function() {
  2831. return {
  2832. restrict: 'EA',
  2833. replace: true,
  2834. transclude: true,
  2835. require: '^progress',
  2836. scope: {
  2837. value: '=',
  2838. type: '@'
  2839. },
  2840. templateUrl: 'template/progressbar/bar.html',
  2841. link: function(scope, element, attrs, progressCtrl) {
  2842. progressCtrl.addBar(scope, element);
  2843. }
  2844. };
  2845. })
  2846. .directive('progressbar', function() {
  2847. return {
  2848. restrict: 'EA',
  2849. replace: true,
  2850. transclude: true,
  2851. controller: 'ProgressController',
  2852. scope: {
  2853. value: '=',
  2854. type: '@'
  2855. },
  2856. templateUrl: 'template/progressbar/progressbar.html',
  2857. link: function(scope, element, attrs, progressCtrl) {
  2858. progressCtrl.addBar(scope, angular.element(element.children()[0]));
  2859. }
  2860. };
  2861. });
  2862. angular.module('ui.bootstrap.rating', [])
  2863. .constant('ratingConfig', {
  2864. max: 5,
  2865. stateOn: null,
  2866. stateOff: null
  2867. })
  2868. .controller('RatingController', ['$scope', '$attrs', 'ratingConfig', function($scope, $attrs, ratingConfig) {
  2869. var ngModelCtrl = { $setViewValue: angular.noop };
  2870. this.init = function(ngModelCtrl_) {
  2871. ngModelCtrl = ngModelCtrl_;
  2872. ngModelCtrl.$render = this.render;
  2873. this.stateOn = angular.isDefined($attrs.stateOn) ? $scope.$parent.$eval($attrs.stateOn) : ratingConfig.stateOn;
  2874. this.stateOff = angular.isDefined($attrs.stateOff) ? $scope.$parent.$eval($attrs.stateOff) : ratingConfig.stateOff;
  2875. var ratingStates = angular.isDefined($attrs.ratingStates) ? $scope.$parent.$eval($attrs.ratingStates) :
  2876. new Array(angular.isDefined($attrs.max) ? $scope.$parent.$eval($attrs.max) : ratingConfig.max);
  2877. $scope.range = this.buildTemplateObjects(ratingStates);
  2878. };
  2879. this.buildTemplateObjects = function(states) {
  2880. for (var i = 0, n = states.length; i < n; i++) {
  2881. states[i] = angular.extend({ index: i }, { stateOn: this.stateOn, stateOff: this.stateOff }, states[i]);
  2882. }
  2883. return states;
  2884. };
  2885. $scope.rate = function(value) {
  2886. if (!$scope.readonly && value >= 0 && value <= $scope.range.length) {
  2887. ngModelCtrl.$setViewValue(value);
  2888. ngModelCtrl.$render();
  2889. }
  2890. };
  2891. $scope.enter = function(value) {
  2892. if (!$scope.readonly) {
  2893. $scope.value = value;
  2894. }
  2895. $scope.onHover({ value: value });
  2896. };
  2897. $scope.reset = function() {
  2898. $scope.value = ngModelCtrl.$viewValue;
  2899. $scope.onLeave();
  2900. };
  2901. $scope.onKeydown = function(evt) {
  2902. if (/(37|38|39|40)/.test(evt.which)) {
  2903. evt.preventDefault();
  2904. evt.stopPropagation();
  2905. $scope.rate($scope.value + (evt.which === 38 || evt.which === 39 ? 1 : -1));
  2906. }
  2907. };
  2908. this.render = function() {
  2909. $scope.value = ngModelCtrl.$viewValue;
  2910. };
  2911. }])
  2912. .directive('rating', function() {
  2913. return {
  2914. restrict: 'EA',
  2915. require: ['rating', 'ngModel'],
  2916. scope: {
  2917. readonly: '=?',
  2918. onHover: '&',
  2919. onLeave: '&'
  2920. },
  2921. controller: 'RatingController',
  2922. templateUrl: 'template/rating/rating.html',
  2923. replace: true,
  2924. link: function(scope, element, attrs, ctrls) {
  2925. var ratingCtrl = ctrls[0],
  2926. ngModelCtrl = ctrls[1];
  2927. if (ngModelCtrl) {
  2928. ratingCtrl.init(ngModelCtrl);
  2929. }
  2930. }
  2931. };
  2932. });
  2933. /**
  2934. * @ngdoc overview
  2935. * @name ui.bootstrap.tabs
  2936. *
  2937. * @description
  2938. * AngularJS version of the tabs directive.
  2939. */
  2940. angular.module('ui.bootstrap.tabs', [])
  2941. .controller('TabsetController', ['$scope', function TabsetCtrl($scope) {
  2942. var ctrl = this,
  2943. tabs = ctrl.tabs = $scope.tabs = [];
  2944. ctrl.select = function(selectedTab) {
  2945. angular.forEach(tabs, function(tab) {
  2946. if (tab.active && tab !== selectedTab) {
  2947. tab.active = false;
  2948. tab.onDeselect();
  2949. }
  2950. });
  2951. selectedTab.active = true;
  2952. selectedTab.onSelect();
  2953. };
  2954. ctrl.addTab = function addTab(tab) {
  2955. tabs.push(tab);
  2956. // we can't run the select function on the first tab
  2957. // since that would select it twice
  2958. if (tabs.length === 1) {
  2959. tab.active = true;
  2960. } else if (tab.active) {
  2961. ctrl.select(tab);
  2962. }
  2963. };
  2964. ctrl.removeTab = function removeTab(tab) {
  2965. var index = tabs.indexOf(tab);
  2966. //Select a new tab if the tab to be removed is selected and not destroyed
  2967. if (tab.active && tabs.length > 1 && !destroyed) {
  2968. //If this is the last tab, select the previous tab. else, the next tab.
  2969. var newActiveIndex = index == tabs.length - 1 ? index - 1 : index + 1;
  2970. ctrl.select(tabs[newActiveIndex]);
  2971. }
  2972. tabs.splice(index, 1);
  2973. };
  2974. var destroyed;
  2975. $scope.$on('$destroy', function() {
  2976. destroyed = true;
  2977. });
  2978. }])
  2979. /**
  2980. * @ngdoc directive
  2981. * @name ui.bootstrap.tabs.directive:tabset
  2982. * @restrict EA
  2983. *
  2984. * @description
  2985. * Tabset is the outer container for the tabs directive
  2986. *
  2987. * @param {boolean=} vertical Whether or not to use vertical styling for the tabs.
  2988. * @param {boolean=} justified Whether or not to use justified styling for the tabs.
  2989. *
  2990. * @example
  2991. <example module="ui.bootstrap">
  2992. <file name="index.html">
  2993. <tabset>
  2994. <tab heading="Tab 1"><b>First</b> Content!</tab>
  2995. <tab heading="Tab 2"><i>Second</i> Content!</tab>
  2996. </tabset>
  2997. <hr />
  2998. <tabset vertical="true">
  2999. <tab heading="Vertical Tab 1"><b>First</b> Vertical Content!</tab>
  3000. <tab heading="Vertical Tab 2"><i>Second</i> Vertical Content!</tab>
  3001. </tabset>
  3002. <tabset justified="true">
  3003. <tab heading="Justified Tab 1"><b>First</b> Justified Content!</tab>
  3004. <tab heading="Justified Tab 2"><i>Second</i> Justified Content!</tab>
  3005. </tabset>
  3006. </file>
  3007. </example>
  3008. */
  3009. .directive('tabset', function() {
  3010. return {
  3011. restrict: 'EA',
  3012. transclude: true,
  3013. replace: true,
  3014. scope: {
  3015. type: '@'
  3016. },
  3017. controller: 'TabsetController',
  3018. templateUrl: 'template/tabs/tabset.html',
  3019. link: function(scope, element, attrs) {
  3020. scope.vertical = angular.isDefined(attrs.vertical) ? scope.$parent.$eval(attrs.vertical) : false;
  3021. scope.justified = angular.isDefined(attrs.justified) ? scope.$parent.$eval(attrs.justified) : false;
  3022. }
  3023. };
  3024. })
  3025. /**
  3026. * @ngdoc directive
  3027. * @name ui.bootstrap.tabs.directive:tab
  3028. * @restrict EA
  3029. *
  3030. * @param {string=} heading The visible heading, or title, of the tab. Set HTML headings with {@link ui.bootstrap.tabs.directive:tabHeading tabHeading}.
  3031. * @param {string=} select An expression to evaluate when the tab is selected.
  3032. * @param {boolean=} active A binding, telling whether or not this tab is selected.
  3033. * @param {boolean=} disabled A binding, telling whether or not this tab is disabled.
  3034. *
  3035. * @description
  3036. * Creates a tab with a heading and content. Must be placed within a {@link ui.bootstrap.tabs.directive:tabset tabset}.
  3037. *
  3038. * @example
  3039. <example module="ui.bootstrap">
  3040. <file name="index.html">
  3041. <div ng-controller="TabsDemoCtrl">
  3042. <button class="btn btn-small" ng-click="items[0].active = true">
  3043. Select item 1, using active binding
  3044. </button>
  3045. <button class="btn btn-small" ng-click="items[1].disabled = !items[1].disabled">
  3046. Enable/disable item 2, using disabled binding
  3047. </button>
  3048. <br />
  3049. <tabset>
  3050. <tab heading="Tab 1">First Tab</tab>
  3051. <tab select="alertMe()">
  3052. <tab-heading><i class="icon-bell"></i> Alert me!</tab-heading>
  3053. Second Tab, with alert callback and html heading!
  3054. </tab>
  3055. <tab ng-repeat="item in items"
  3056. heading="{{item.title}}"
  3057. disabled="item.disabled"
  3058. active="item.active">
  3059. {{item.content}}
  3060. </tab>
  3061. </tabset>
  3062. </div>
  3063. </file>
  3064. <file name="script.js">
  3065. function TabsDemoCtrl($scope) {
  3066. $scope.items = [
  3067. { title:"Dynamic Title 1", content:"Dynamic Item 0" },
  3068. { title:"Dynamic Title 2", content:"Dynamic Item 1", disabled: true }
  3069. ];
  3070. $scope.alertMe = function() {
  3071. setTimeout(function() {
  3072. alert("You've selected the alert tab!");
  3073. });
  3074. };
  3075. };
  3076. </file>
  3077. </example>
  3078. */
  3079. /**
  3080. * @ngdoc directive
  3081. * @name ui.bootstrap.tabs.directive:tabHeading
  3082. * @restrict EA
  3083. *
  3084. * @description
  3085. * Creates an HTML heading for a {@link ui.bootstrap.tabs.directive:tab tab}. Must be placed as a child of a tab element.
  3086. *
  3087. * @example
  3088. <example module="ui.bootstrap">
  3089. <file name="index.html">
  3090. <tabset>
  3091. <tab>
  3092. <tab-heading><b>HTML</b> in my titles?!</tab-heading>
  3093. And some content, too!
  3094. </tab>
  3095. <tab>
  3096. <tab-heading><i class="icon-heart"></i> Icon heading?!?</tab-heading>
  3097. That's right.
  3098. </tab>
  3099. </tabset>
  3100. </file>
  3101. </example>
  3102. */
  3103. .directive('tab', ['$parse', function($parse) {
  3104. return {
  3105. require: '^tabset',
  3106. restrict: 'EA',
  3107. replace: true,
  3108. templateUrl: 'template/tabs/tab.html',
  3109. transclude: true,
  3110. scope: {
  3111. active: '=?',
  3112. heading: '@',
  3113. onSelect: '&select', //This callback is called in contentHeadingTransclude
  3114. //once it inserts the tab's content into the dom
  3115. onDeselect: '&deselect'
  3116. },
  3117. controller: function() {
  3118. //Empty controller so other directives can require being 'under' a tab
  3119. },
  3120. compile: function(elm, attrs, transclude) {
  3121. return function postLink(scope, elm, attrs, tabsetCtrl) {
  3122. scope.$watch('active', function(active) {
  3123. if (active) {
  3124. tabsetCtrl.select(scope);
  3125. }
  3126. });
  3127. scope.disabled = false;
  3128. if (attrs.disabled) {
  3129. scope.$parent.$watch($parse(attrs.disabled), function(value) {
  3130. scope.disabled = !!value;
  3131. });
  3132. }
  3133. scope.select = function() {
  3134. if (!scope.disabled) {
  3135. scope.active = true;
  3136. }
  3137. };
  3138. tabsetCtrl.addTab(scope);
  3139. scope.$on('$destroy', function() {
  3140. tabsetCtrl.removeTab(scope);
  3141. });
  3142. //We need to transclude later, once the content container is ready.
  3143. //when this link happens, we're inside a tab heading.
  3144. scope.$transcludeFn = transclude;
  3145. };
  3146. }
  3147. };
  3148. }])
  3149. .directive('tabHeadingTransclude', [function() {
  3150. return {
  3151. restrict: 'A',
  3152. require: '^tab',
  3153. link: function(scope, elm, attrs, tabCtrl) {
  3154. scope.$watch('headingElement', function updateHeadingElement(heading) {
  3155. if (heading) {
  3156. elm.html('');
  3157. elm.append(heading);
  3158. }
  3159. });
  3160. }
  3161. };
  3162. }])
  3163. .directive('tabContentTransclude', function() {
  3164. return {
  3165. restrict: 'A',
  3166. require: '^tabset',
  3167. link: function(scope, elm, attrs) {
  3168. var tab = scope.$eval(attrs.tabContentTransclude);
  3169. //Now our tab is ready to be transcluded: both the tab heading area
  3170. //and the tab content area are loaded. Transclude 'em both.
  3171. tab.$transcludeFn(tab.$parent, function(contents) {
  3172. angular.forEach(contents, function(node) {
  3173. if (isTabHeading(node)) {
  3174. //Let tabHeadingTransclude know.
  3175. tab.headingElement = node;
  3176. } else {
  3177. elm.append(node);
  3178. }
  3179. });
  3180. });
  3181. }
  3182. };
  3183. function isTabHeading(node) {
  3184. return node.tagName && (
  3185. node.hasAttribute('tab-heading') ||
  3186. node.hasAttribute('data-tab-heading') ||
  3187. node.tagName.toLowerCase() === 'tab-heading' ||
  3188. node.tagName.toLowerCase() === 'data-tab-heading'
  3189. );
  3190. }
  3191. })
  3192. ;
  3193. angular.module('ui.bootstrap.timepicker', [])
  3194. .constant('timepickerConfig', {
  3195. hourStep: 1,
  3196. minuteStep: 1,
  3197. showMeridian: true,
  3198. meridians: null,
  3199. readonlyInput: false,
  3200. mousewheel: true
  3201. })
  3202. .controller('TimepickerController', ['$scope', '$attrs', '$parse', '$log', '$locale', 'timepickerConfig', function($scope, $attrs, $parse, $log, $locale, timepickerConfig) {
  3203. var selected = new Date(),
  3204. ngModelCtrl = { $setViewValue: angular.noop }, // nullModelCtrl
  3205. meridians = angular.isDefined($attrs.meridians) ? $scope.$parent.$eval($attrs.meridians) : timepickerConfig.meridians || $locale.DATETIME_FORMATS.AMPMS;
  3206. this.init = function(ngModelCtrl_, inputs) {
  3207. ngModelCtrl = ngModelCtrl_;
  3208. ngModelCtrl.$render = this.render;
  3209. var hoursInputEl = inputs.eq(0),
  3210. minutesInputEl = inputs.eq(1);
  3211. var mousewheel = angular.isDefined($attrs.mousewheel) ? $scope.$parent.$eval($attrs.mousewheel) : timepickerConfig.mousewheel;
  3212. if (mousewheel) {
  3213. this.setupMousewheelEvents(hoursInputEl, minutesInputEl);
  3214. }
  3215. $scope.readonlyInput = angular.isDefined($attrs.readonlyInput) ? $scope.$parent.$eval($attrs.readonlyInput) : timepickerConfig.readonlyInput;
  3216. this.setupInputEvents(hoursInputEl, minutesInputEl);
  3217. };
  3218. var hourStep = timepickerConfig.hourStep;
  3219. if ($attrs.hourStep) {
  3220. $scope.$parent.$watch($parse($attrs.hourStep), function(value) {
  3221. hourStep = parseInt(value, 10);
  3222. });
  3223. }
  3224. var minuteStep = timepickerConfig.minuteStep;
  3225. if ($attrs.minuteStep) {
  3226. $scope.$parent.$watch($parse($attrs.minuteStep), function(value) {
  3227. minuteStep = parseInt(value, 10);
  3228. });
  3229. }
  3230. // 12H / 24H mode
  3231. $scope.showMeridian = timepickerConfig.showMeridian;
  3232. if ($attrs.showMeridian) {
  3233. $scope.$parent.$watch($parse($attrs.showMeridian), function(value) {
  3234. $scope.showMeridian = !!value;
  3235. if (ngModelCtrl.$error.time) {
  3236. // Evaluate from template
  3237. var hours = getHoursFromTemplate(),
  3238. minutes = getMinutesFromTemplate();
  3239. if (angular.isDefined(hours) && angular.isDefined(minutes)) {
  3240. selected.setHours(hours);
  3241. refresh();
  3242. }
  3243. } else {
  3244. updateTemplate();
  3245. }
  3246. });
  3247. }
  3248. // Get $scope.hours in 24H mode if valid
  3249. function getHoursFromTemplate() {
  3250. var hours = parseInt($scope.hours, 10);
  3251. var valid = ($scope.showMeridian) ? (hours > 0 && hours < 13) : (hours >= 0 && hours < 24);
  3252. if (!valid) {
  3253. return undefined;
  3254. }
  3255. if ($scope.showMeridian) {
  3256. if (hours === 12) {
  3257. hours = 0;
  3258. }
  3259. if ($scope.meridian === meridians[1]) {
  3260. hours = hours + 12;
  3261. }
  3262. }
  3263. return hours;
  3264. }
  3265. function getMinutesFromTemplate() {
  3266. var minutes = parseInt($scope.minutes, 10);
  3267. return (minutes >= 0 && minutes < 60) ? minutes : undefined;
  3268. }
  3269. function pad(value) {
  3270. return (angular.isDefined(value) && value.toString().length < 2) ? '0' + value : value;
  3271. }
  3272. // Respond on mousewheel spin
  3273. this.setupMousewheelEvents = function(hoursInputEl, minutesInputEl) {
  3274. var isScrollingUp = function(e) {
  3275. if (e.originalEvent) {
  3276. e = e.originalEvent;
  3277. }
  3278. //pick correct delta variable depending on event
  3279. var delta = (e.wheelDelta) ? e.wheelDelta : -e.deltaY;
  3280. return (e.detail || delta > 0);
  3281. };
  3282. hoursInputEl.bind('mousewheel wheel', function(e) {
  3283. $scope.$apply((isScrollingUp(e)) ? $scope.incrementHours() : $scope.decrementHours());
  3284. e.preventDefault();
  3285. });
  3286. minutesInputEl.bind('mousewheel wheel', function(e) {
  3287. $scope.$apply((isScrollingUp(e)) ? $scope.incrementMinutes() : $scope.decrementMinutes());
  3288. e.preventDefault();
  3289. });
  3290. };
  3291. this.setupInputEvents = function(hoursInputEl, minutesInputEl) {
  3292. if ($scope.readonlyInput) {
  3293. $scope.updateHours = angular.noop;
  3294. $scope.updateMinutes = angular.noop;
  3295. return;
  3296. }
  3297. var invalidate = function(invalidHours, invalidMinutes) {
  3298. ngModelCtrl.$setViewValue(null);
  3299. ngModelCtrl.$setValidity('time', false);
  3300. if (angular.isDefined(invalidHours)) {
  3301. $scope.invalidHours = invalidHours;
  3302. }
  3303. if (angular.isDefined(invalidMinutes)) {
  3304. $scope.invalidMinutes = invalidMinutes;
  3305. }
  3306. };
  3307. $scope.updateHours = function() {
  3308. var hours = getHoursFromTemplate();
  3309. if (angular.isDefined(hours)) {
  3310. selected.setHours(hours);
  3311. refresh('h');
  3312. } else {
  3313. invalidate(true);
  3314. }
  3315. };
  3316. hoursInputEl.bind('blur', function(e) {
  3317. if (!$scope.invalidHours && $scope.hours < 10) {
  3318. $scope.$apply(function() {
  3319. $scope.hours = pad($scope.hours);
  3320. });
  3321. }
  3322. });
  3323. $scope.updateMinutes = function() {
  3324. var minutes = getMinutesFromTemplate();
  3325. if (angular.isDefined(minutes)) {
  3326. selected.setMinutes(minutes);
  3327. refresh('m');
  3328. } else {
  3329. invalidate(undefined, true);
  3330. }
  3331. };
  3332. minutesInputEl.bind('blur', function(e) {
  3333. if (!$scope.invalidMinutes && $scope.minutes < 10) {
  3334. $scope.$apply(function() {
  3335. $scope.minutes = pad($scope.minutes);
  3336. });
  3337. }
  3338. });
  3339. };
  3340. this.render = function() {
  3341. var date = ngModelCtrl.$modelValue ? new Date(ngModelCtrl.$modelValue) : null;
  3342. if (isNaN(date)) {
  3343. ngModelCtrl.$setValidity('time', false);
  3344. $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.');
  3345. } else {
  3346. if (date) {
  3347. selected = date;
  3348. }
  3349. makeValid();
  3350. updateTemplate();
  3351. }
  3352. };
  3353. // Call internally when we know that model is valid.
  3354. function refresh(keyboardChange) {
  3355. makeValid();
  3356. ngModelCtrl.$setViewValue(new Date(selected));
  3357. updateTemplate(keyboardChange);
  3358. }
  3359. function makeValid() {
  3360. ngModelCtrl.$setValidity('time', true);
  3361. $scope.invalidHours = false;
  3362. $scope.invalidMinutes = false;
  3363. }
  3364. function updateTemplate(keyboardChange) {
  3365. var hours = selected.getHours(),
  3366. minutes = selected.getMinutes();
  3367. if ($scope.showMeridian) {
  3368. hours = (hours === 0 || hours === 12) ? 12 : hours % 12; // Convert 24 to 12 hour system
  3369. }
  3370. $scope.hours = keyboardChange === 'h' ? hours : pad(hours);
  3371. $scope.minutes = keyboardChange === 'm' ? minutes : pad(minutes);
  3372. $scope.meridian = selected.getHours() < 12 ? meridians[0] : meridians[1];
  3373. }
  3374. function addMinutes(minutes) {
  3375. var dt = new Date(selected.getTime() + minutes * 60000);
  3376. selected.setHours(dt.getHours(), dt.getMinutes());
  3377. refresh();
  3378. }
  3379. $scope.incrementHours = function() {
  3380. addMinutes(1 * 60);
  3381. };
  3382. $scope.decrementHours = function() {
  3383. addMinutes(-1 * 60);
  3384. };
  3385. $scope.incrementMinutes = function() {
  3386. addMinutes(1);
  3387. };
  3388. $scope.decrementMinutes = function() {
  3389. addMinutes(-1);
  3390. };
  3391. $scope.toggleMeridian = function() {
  3392. addMinutes(12 * 60 * ((selected.getHours() < 12) ? 1 : -1));
  3393. };
  3394. }])
  3395. .directive('timepicker', function() {
  3396. return {
  3397. restrict: 'EA',
  3398. require: ['timepicker', '?^ngModel'],
  3399. controller: 'TimepickerController',
  3400. replace: true,
  3401. scope: {},
  3402. templateUrl: 'template/timepicker/timepicker.html',
  3403. link: function(scope, element, attrs, ctrls) {
  3404. var timepickerCtrl = ctrls[0],
  3405. ngModelCtrl = ctrls[1];
  3406. if (ngModelCtrl) {
  3407. timepickerCtrl.init(ngModelCtrl, element.find('input'));
  3408. }
  3409. }
  3410. };
  3411. });
  3412. angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap.bindHtml'])
  3413. /**
  3414. * A helper service that can parse typeahead's syntax (string provided by users)
  3415. * Extracted to a separate service for ease of unit testing
  3416. */
  3417. .factory('typeaheadParser', ['$parse', function($parse) {
  3418. // 00000111000000000000022200000000000000003333333333333330000000000044000
  3419. var TYPEAHEAD_REGEXP = /^\s*([\s\S]+?)(?:\s+as\s+([\s\S]+?))?\s+for\s+(?:([\$\w][\$\w\d]*))\s+in\s+([\s\S]+?)$/;
  3420. return {
  3421. parse: function(input) {
  3422. var match = input.match(TYPEAHEAD_REGEXP);
  3423. if (!match) {
  3424. throw new Error(
  3425. 'Expected typeahead specification in form of "_modelValue_ (as _label_)? for _item_ in _collection_"' +
  3426. ' but got "' + input + '".');
  3427. }
  3428. return {
  3429. itemName: match[3],
  3430. source: $parse(match[4]),
  3431. viewMapper: $parse(match[2] || match[1]),
  3432. modelMapper: $parse(match[1])
  3433. };
  3434. }
  3435. };
  3436. }])
  3437. .directive('typeahead', ['$compile', '$parse', '$q', '$timeout', '$document', '$position', 'typeaheadParser',
  3438. function($compile, $parse, $q, $timeout, $document, $position, typeaheadParser) {
  3439. var HOT_KEYS = [9, 13, 27, 38, 40];
  3440. return {
  3441. require: 'ngModel',
  3442. link: function(originalScope, element, attrs, modelCtrl) {
  3443. //SUPPORTED ATTRIBUTES (OPTIONS)
  3444. //minimal no of characters that needs to be entered before typeahead kicks-in
  3445. var minSearch = originalScope.$eval(attrs.typeaheadMinLength) || 1;
  3446. //minimal wait time after last character typed before typehead kicks-in
  3447. var waitTime = originalScope.$eval(attrs.typeaheadWaitMs) || 0;
  3448. //should it restrict model values to the ones selected from the popup only?
  3449. var isEditable = originalScope.$eval(attrs.typeaheadEditable) !== false;
  3450. //binding to a variable that indicates if matches are being retrieved asynchronously
  3451. var isLoadingSetter = $parse(attrs.typeaheadLoading).assign || angular.noop;
  3452. //a callback executed when a match is selected
  3453. var onSelectCallback = $parse(attrs.typeaheadOnSelect);
  3454. var inputFormatter = attrs.typeaheadInputFormatter ? $parse(attrs.typeaheadInputFormatter) : undefined;
  3455. var appendToBody = attrs.typeaheadAppendToBody ? originalScope.$eval(attrs.typeaheadAppendToBody) : false;
  3456. var focusFirst = originalScope.$eval(attrs.typeaheadFocusFirst) !== false;
  3457. //INTERNAL VARIABLES
  3458. //model setter executed upon match selection
  3459. var $setModelValue = $parse(attrs.ngModel).assign;
  3460. //expressions used by typeahead
  3461. var parserResult = typeaheadParser.parse(attrs.typeahead);
  3462. var hasFocus;
  3463. //create a child scope for the typeahead directive so we are not polluting original scope
  3464. //with typeahead-specific data (matches, query etc.)
  3465. var scope = originalScope.$new();
  3466. originalScope.$on('$destroy', function() {
  3467. scope.$destroy();
  3468. });
  3469. // WAI-ARIA
  3470. var popupId = 'typeahead-' + scope.$id + '-' + Math.floor(Math.random() * 10000);
  3471. element.attr({
  3472. 'aria-autocomplete': 'list',
  3473. 'aria-expanded': false,
  3474. 'aria-owns': popupId
  3475. });
  3476. //pop-up element used to display matches
  3477. var popUpEl = angular.element('<div typeahead-popup></div>');
  3478. popUpEl.attr({
  3479. id: popupId,
  3480. matches: 'matches',
  3481. active: 'activeIdx',
  3482. select: 'select(activeIdx)',
  3483. query: 'query',
  3484. position: 'position'
  3485. });
  3486. //custom item template
  3487. if (angular.isDefined(attrs.typeaheadTemplateUrl)) {
  3488. popUpEl.attr('template-url', attrs.typeaheadTemplateUrl);
  3489. }
  3490. var resetMatches = function() {
  3491. scope.matches = [];
  3492. scope.activeIdx = -1;
  3493. element.attr('aria-expanded', false);
  3494. };
  3495. var getMatchId = function(index) {
  3496. return popupId + '-option-' + index;
  3497. };
  3498. // Indicate that the specified match is the active (pre-selected) item in the list owned by this typeahead.
  3499. // This attribute is added or removed automatically when the `activeIdx` changes.
  3500. scope.$watch('activeIdx', function(index) {
  3501. if (index < 0) {
  3502. element.removeAttr('aria-activedescendant');
  3503. } else {
  3504. element.attr('aria-activedescendant', getMatchId(index));
  3505. }
  3506. });
  3507. var getMatchesAsync = function(inputValue) {
  3508. var locals = { $viewValue: inputValue };
  3509. isLoadingSetter(originalScope, true);
  3510. $q.when(parserResult.source(originalScope, locals)).then(function(matches) {
  3511. //it might happen that several async queries were in progress if a user were typing fast
  3512. //but we are interested only in responses that correspond to the current view value
  3513. var onCurrentRequest = (inputValue === modelCtrl.$viewValue);
  3514. if (onCurrentRequest && hasFocus) {
  3515. if (matches.length > 0) {
  3516. scope.activeIdx = focusFirst ? 0 : -1;
  3517. scope.matches.length = 0;
  3518. //transform labels
  3519. for (var i = 0; i < matches.length; i++) {
  3520. locals[parserResult.itemName] = matches[i];
  3521. scope.matches.push({
  3522. id: getMatchId(i),
  3523. label: parserResult.viewMapper(scope, locals),
  3524. model: matches[i]
  3525. });
  3526. }
  3527. scope.query = inputValue;
  3528. //position pop-up with matches - we need to re-calculate its position each time we are opening a window
  3529. //with matches as a pop-up might be absolute-positioned and position of an input might have changed on a page
  3530. //due to other elements being rendered
  3531. scope.position = appendToBody ? $position.offset(element) : $position.position(element);
  3532. scope.position.top = scope.position.top + element.prop('offsetHeight');
  3533. element.attr('aria-expanded', true);
  3534. } else {
  3535. resetMatches();
  3536. }
  3537. }
  3538. if (onCurrentRequest) {
  3539. isLoadingSetter(originalScope, false);
  3540. }
  3541. }, function() {
  3542. resetMatches();
  3543. isLoadingSetter(originalScope, false);
  3544. });
  3545. };
  3546. resetMatches();
  3547. //we need to propagate user's query so we can higlight matches
  3548. scope.query = undefined;
  3549. //Declare the timeout promise var outside the function scope so that stacked calls can be cancelled later
  3550. var timeoutPromise;
  3551. var scheduleSearchWithTimeout = function(inputValue) {
  3552. timeoutPromise = $timeout(function() {
  3553. getMatchesAsync(inputValue);
  3554. }, waitTime);
  3555. };
  3556. var cancelPreviousTimeout = function() {
  3557. if (timeoutPromise) {
  3558. $timeout.cancel(timeoutPromise);
  3559. }
  3560. };
  3561. //plug into $parsers pipeline to open a typeahead on view changes initiated from DOM
  3562. //$parsers kick-in on all the changes coming from the view as well as manually triggered by $setViewValue
  3563. modelCtrl.$parsers.unshift(function(inputValue) {
  3564. hasFocus = true;
  3565. if (inputValue && inputValue.length >= minSearch) {
  3566. if (waitTime > 0) {
  3567. cancelPreviousTimeout();
  3568. scheduleSearchWithTimeout(inputValue);
  3569. } else {
  3570. getMatchesAsync(inputValue);
  3571. }
  3572. } else {
  3573. isLoadingSetter(originalScope, false);
  3574. cancelPreviousTimeout();
  3575. resetMatches();
  3576. }
  3577. if (isEditable) {
  3578. return inputValue;
  3579. } else {
  3580. if (!inputValue) {
  3581. // Reset in case user had typed something previously.
  3582. modelCtrl.$setValidity('editable', true);
  3583. return inputValue;
  3584. } else {
  3585. modelCtrl.$setValidity('editable', false);
  3586. return undefined;
  3587. }
  3588. }
  3589. });
  3590. modelCtrl.$formatters.push(function(modelValue) {
  3591. var candidateViewValue, emptyViewValue;
  3592. var locals = {};
  3593. if (inputFormatter) {
  3594. locals.$model = modelValue;
  3595. return inputFormatter(originalScope, locals);
  3596. } else {
  3597. //it might happen that we don't have enough info to properly render input value
  3598. //we need to check for this situation and simply return model value if we can't apply custom formatting
  3599. locals[parserResult.itemName] = modelValue;
  3600. candidateViewValue = parserResult.viewMapper(originalScope, locals);
  3601. locals[parserResult.itemName] = undefined;
  3602. emptyViewValue = parserResult.viewMapper(originalScope, locals);
  3603. return candidateViewValue !== emptyViewValue ? candidateViewValue : modelValue;
  3604. }
  3605. });
  3606. scope.select = function(activeIdx) {
  3607. //called from within the $digest() cycle
  3608. var locals = {};
  3609. var model, item;
  3610. locals[parserResult.itemName] = item = scope.matches[activeIdx].model;
  3611. model = parserResult.modelMapper(originalScope, locals);
  3612. $setModelValue(originalScope, model);
  3613. modelCtrl.$setValidity('editable', true);
  3614. onSelectCallback(originalScope, {
  3615. $item: item,
  3616. $model: model,
  3617. $label: parserResult.viewMapper(originalScope, locals)
  3618. });
  3619. resetMatches();
  3620. //return focus to the input element if a match was selected via a mouse click event
  3621. // use timeout to avoid $rootScope:inprog error
  3622. $timeout(function() { element[0].focus(); }, 0, false);
  3623. };
  3624. //bind keyboard events: arrows up(38) / down(40), enter(13) and tab(9), esc(27)
  3625. element.bind('keydown', function(evt) {
  3626. //typeahead is open and an "interesting" key was pressed
  3627. if (scope.matches.length === 0 || HOT_KEYS.indexOf(evt.which) === -1) {
  3628. return;
  3629. }
  3630. // if there's nothing selected (i.e. focusFirst) and enter is hit, don't do anything
  3631. if (scope.activeIdx == -1 && (evt.which === 13 || evt.which === 9)) {
  3632. return;
  3633. }
  3634. evt.preventDefault();
  3635. if (evt.which === 40) {
  3636. scope.activeIdx = (scope.activeIdx + 1) % scope.matches.length;
  3637. scope.$digest();
  3638. } else if (evt.which === 38) {
  3639. scope.activeIdx = (scope.activeIdx > 0 ? scope.activeIdx : scope.matches.length) - 1;
  3640. scope.$digest();
  3641. } else if (evt.which === 13 || evt.which === 9) {
  3642. scope.$apply(function() {
  3643. scope.select(scope.activeIdx);
  3644. });
  3645. } else if (evt.which === 27) {
  3646. evt.stopPropagation();
  3647. resetMatches();
  3648. scope.$digest();
  3649. }
  3650. });
  3651. element.bind('blur', function(evt) {
  3652. hasFocus = false;
  3653. });
  3654. // Keep reference to click handler to unbind it.
  3655. var dismissClickHandler = function(evt) {
  3656. if (element[0] !== evt.target) {
  3657. resetMatches();
  3658. scope.$digest();
  3659. }
  3660. };
  3661. $document.bind('click', dismissClickHandler);
  3662. originalScope.$on('$destroy', function() {
  3663. $document.unbind('click', dismissClickHandler);
  3664. if (appendToBody) {
  3665. $popup.remove();
  3666. }
  3667. });
  3668. var $popup = $compile(popUpEl)(scope);
  3669. if (appendToBody) {
  3670. $document.find('body').append($popup);
  3671. } else {
  3672. element.after($popup);
  3673. }
  3674. }
  3675. };
  3676. }
  3677. ])
  3678. .directive('typeaheadPopup', function() {
  3679. return {
  3680. restrict: 'EA',
  3681. scope: {
  3682. matches: '=',
  3683. query: '=',
  3684. active: '=',
  3685. position: '=',
  3686. select: '&'
  3687. },
  3688. replace: true,
  3689. templateUrl: 'template/typeahead/typeahead-popup.html',
  3690. link: function(scope, element, attrs) {
  3691. scope.templateUrl = attrs.templateUrl;
  3692. scope.isOpen = function() {
  3693. return scope.matches.length > 0;
  3694. };
  3695. scope.isActive = function(matchIdx) {
  3696. return scope.active == matchIdx;
  3697. };
  3698. scope.selectActive = function(matchIdx) {
  3699. scope.active = matchIdx;
  3700. };
  3701. scope.selectMatch = function(activeIdx) {
  3702. scope.select({ activeIdx: activeIdx });
  3703. };
  3704. }
  3705. };
  3706. })
  3707. .directive('typeaheadMatch', ['$http', '$templateCache', '$compile', '$parse', function($http, $templateCache, $compile, $parse) {
  3708. return {
  3709. restrict: 'EA',
  3710. scope: {
  3711. index: '=',
  3712. match: '=',
  3713. query: '='
  3714. },
  3715. link: function(scope, element, attrs) {
  3716. var tplUrl = $parse(attrs.templateUrl)(scope.$parent) || 'template/typeahead/typeahead-match.html';
  3717. $http.get(tplUrl, { cache: $templateCache }).success(function(tplContent) {
  3718. element.replaceWith($compile(tplContent.trim())(scope));
  3719. });
  3720. }
  3721. };
  3722. }])
  3723. .filter('typeaheadHighlight', function() {
  3724. function escapeRegexp(queryToEscape) {
  3725. return queryToEscape.replace(/([.?*+^$[\]\\(){}|-])/g, '\\$1');
  3726. }
  3727. return function(matchItem, query) {
  3728. return query ? ('' + matchItem).replace(new RegExp(escapeRegexp(query), 'gi'), '<strong>$&</strong>') : matchItem;
  3729. };
  3730. });
  3731. angular.module("template/accordion/accordion-group.html", []).run(["$templateCache", function($templateCache) {
  3732. $templateCache.put("template/accordion/accordion-group.html",
  3733. "<div class=\"panel panel-default\">\n" +
  3734. " <div class=\"panel-heading\">\n" +
  3735. " <h4 class=\"panel-title\">\n" +
  3736. " <a href class=\"accordion-toggle\" ng-click=\"toggleOpen()\" accordion-transclude=\"heading\"><span ng-class=\"{'text-muted': isDisabled}\">{{heading}}</span></a>\n" +
  3737. " </h4>\n" +
  3738. " </div>\n" +
  3739. " <div class=\"panel-collapse\" collapse=\"!isOpen\">\n" +
  3740. " <div class=\"panel-body\" ng-transclude></div>\n" +
  3741. " </div>\n" +
  3742. "</div>\n" +
  3743. "");
  3744. }]);
  3745. angular.module("template/accordion/accordion.html", []).run(["$templateCache", function($templateCache) {
  3746. $templateCache.put("template/accordion/accordion.html",
  3747. "<div class=\"panel-group\" ng-transclude></div>");
  3748. }]);
  3749. angular.module("template/alert/alert.html", []).run(["$templateCache", function($templateCache) {
  3750. $templateCache.put("template/alert/alert.html",
  3751. "<div class=\"alert\" ng-class=\"['alert-' + (type || 'warning'), closeable ? 'alert-dismissable' : null]\" role=\"alert\">\n" +
  3752. " <button ng-show=\"closeable\" type=\"button\" class=\"close\" ng-click=\"close()\">\n" +
  3753. " <span aria-hidden=\"true\">&times;</span>\n" +
  3754. " <span class=\"sr-only\">Close</span>\n" +
  3755. " </button>\n" +
  3756. " <div ng-transclude></div>\n" +
  3757. "</div>\n" +
  3758. "");
  3759. }]);
  3760. angular.module("template/carousel/carousel.html", []).run(["$templateCache", function($templateCache) {
  3761. $templateCache.put("template/carousel/carousel.html",
  3762. "<div ng-mouseenter=\"pause()\" ng-mouseleave=\"play()\" class=\"carousel\" ng-swipe-right=\"prev()\" ng-swipe-left=\"next()\">\n" +
  3763. " <ol class=\"carousel-indicators\" ng-show=\"slides.length > 1\">\n" +
  3764. " <li ng-repeat=\"slide in slides track by $index\" ng-class=\"{active: isActive(slide)}\" ng-click=\"select(slide)\"></li>\n" +
  3765. " </ol>\n" +
  3766. " <div class=\"carousel-inner\" ng-transclude></div>\n" +
  3767. " <a class=\"left carousel-control\" ng-click=\"prev()\" ng-show=\"slides.length > 1\"><span class=\"glyphicon glyphicon-chevron-left\"></span></a>\n" +
  3768. " <a class=\"right carousel-control\" ng-click=\"next()\" ng-show=\"slides.length > 1\"><span class=\"glyphicon glyphicon-chevron-right\"></span></a>\n" +
  3769. "</div>\n" +
  3770. "");
  3771. }]);
  3772. angular.module("template/carousel/slide.html", []).run(["$templateCache", function($templateCache) {
  3773. $templateCache.put("template/carousel/slide.html",
  3774. "<div ng-class=\"{\n" +
  3775. " 'active': leaving || (active && !entering),\n" +
  3776. " 'prev': (next || active) && direction=='prev',\n" +
  3777. " 'next': (next || active) && direction=='next',\n" +
  3778. " 'right': direction=='prev',\n" +
  3779. " 'left': direction=='next'\n" +
  3780. " }\" class=\"item text-center\" ng-transclude></div>\n" +
  3781. "");
  3782. }]);
  3783. angular.module("template/datepicker/datepicker.html", []).run(["$templateCache", function($templateCache) {
  3784. $templateCache.put("template/datepicker/datepicker.html",
  3785. "<div ng-switch=\"datepickerMode\" role=\"application\" ng-keydown=\"keydown($event)\">\n" +
  3786. " <daypicker ng-switch-when=\"day\" tabindex=\"0\"></daypicker>\n" +
  3787. " <weekpicker ng-switch-when=\"week\" tabindex=\"0\"></weekpicker>\n" +
  3788. " <monthpicker ng-switch-when=\"month\" tabindex=\"0\"></monthpicker>\n" +
  3789. " <yearpicker ng-switch-when=\"year\" tabindex=\"0\"></yearpicker>\n" +
  3790. "</div>");
  3791. }]);
  3792. angular.module("template/datepicker/day.html", []).run(["$templateCache", function($templateCache) {
  3793. $templateCache.put("template/datepicker/day.html",
  3794. "<table role=\"grid\" aria-labelledby=\"{{uniqueId}}-title\" aria-activedescendant=\"{{activeDateId}}\">\n" +
  3795. " <thead>\n" +
  3796. " <tr>\n" +
  3797. " <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" +
  3798. " <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()\" tabindex=\"-1\" style=\"width:100%;\"><strong>{{title}}</strong></button></th>\n" +
  3799. " <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" +
  3800. " </tr>\n" +
  3801. " <tr>\n" +
  3802. " <th ng-show=\"showWeeks\" class=\"text-center\"></th>\n" +
  3803. " <th ng-repeat=\"label in labels track by $index\" class=\"text-center\"><small aria-label=\"{{label.full}}\">{{label.abbr}}</small></th>\n" +
  3804. " </tr>\n" +
  3805. " </thead>\n" +
  3806. " <tbody>\n" +
  3807. " <tr ng-repeat=\"row in rows track by $index\">\n" +
  3808. " <td ng-show=\"showWeeks\" class=\"text-center h6\"><em>{{ weekNumbers[$index] }}</em></td>\n" +
  3809. " <td ng-repeat=\"dt in row track by dt.date\" class=\"text-center\" role=\"gridcell\" id=\"{{dt.uid}}\" aria-disabled=\"{{!!dt.disabled}}\">\n" +
  3810. " <button type=\"button\" style=\"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" +
  3811. " </td>\n" +
  3812. " </tr>\n" +
  3813. " </tbody>\n" +
  3814. "</table>\n" +
  3815. "");
  3816. }]);
  3817. angular.module("template/datepicker/month.html", []).run(["$templateCache", function($templateCache) {
  3818. $templateCache.put("template/datepicker/month.html",
  3819. "<table role=\"grid\" aria-labelledby=\"{{uniqueId}}-title\" aria-activedescendant=\"{{activeDateId}}\">\n" +
  3820. " <thead>\n" +
  3821. " <tr>\n" +
  3822. " <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" +
  3823. " <th><button id=\"{{uniqueId}}-title\" role=\"heading\" aria-live=\"assertive\" aria-atomic=\"true\" type=\"button\" class=\"btn btn-default btn-sm\" ng-click=\"toggleMode()\" tabindex=\"-1\" style=\"width:100%;\"><strong>{{title}}</strong></button></th>\n" +
  3824. " <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" +
  3825. " </tr>\n" +
  3826. " </thead>\n" +
  3827. " <tbody>\n" +
  3828. " <tr ng-repeat=\"row in rows track by $index\">\n" +
  3829. " <td ng-repeat=\"dt in row track by dt.date\" class=\"text-center\" role=\"gridcell\" id=\"{{dt.uid}}\" aria-disabled=\"{{!!dt.disabled}}\">\n" +
  3830. " <button type=\"button\" style=\"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" +
  3831. " </td>\n" +
  3832. " </tr>\n" +
  3833. " </tbody>\n" +
  3834. "</table>\n" +
  3835. "");
  3836. }]);
  3837. angular.module("template/datepicker/week.html", []).run(["$templateCache", function($templateCache) {
  3838. $templateCache.put("template/datepicker/week.html",
  3839. "<table role=\"grid\" aria-labelledby=\"{{uniqueId}}-title\" aria-activedescendant=\"{{activeDateId}}\">\n" +
  3840. " <thead>\n" +
  3841. " <tr>\n" +
  3842. " <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" +
  3843. " <th><button id=\"{{uniqueId}}-title\" role=\"heading\" aria-live=\"assertive\" aria-atomic=\"true\" type=\"button\" class=\"btn btn-default btn-sm\" ng-click=\"toggleMode()\" tabindex=\"-1\" style=\"width:100%;\"><strong>{{title}}</strong></button></th>\n" +
  3844. " <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" +
  3845. " </tr>\n" +
  3846. " </thead>\n" +
  3847. " <tbody>\n" +
  3848. " <tr ng-repeat=\"row in rows track by $index\">\n" +
  3849. " <td ng-repeat=\"dt in row track by dt.date\" class=\"text-center\" role=\"gridcell\" id=\"{{dt.uid}}\" aria-disabled=\"{{!!dt.disabled}}\">\n" +
  3850. " <button type=\"button\" style=\"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" +
  3851. " </td>\n" +
  3852. " </tr>\n" +
  3853. " </tbody>\n" +
  3854. "</table>\n" +
  3855. "");
  3856. }]);
  3857. angular.module("template/datepicker/popup.html", []).run(["$templateCache", function($templateCache) {
  3858. $templateCache.put("template/datepicker/popup.html",
  3859. "<ul class=\"dropdown-menu\" ng-style=\"{display: (isOpen && 'block') || 'none', top: position.top+'px', left: position.left+'px'}\" ng-keydown=\"keydown($event)\">\n" +
  3860. " <li ng-transclude></li>\n" +
  3861. " <li ng-if=\"showButtonBar\">\n" +
  3862. // "<div class=\"pull-left\" style=\"padding:40px 40px \">时分选择"+
  3863. // "</div>"+
  3864. "<div class='pull-left' style=\"margin-left:35px;width:150px\"><timepicker ng-model=\"data\" ng-change=\"updateHours(data)\" hour-step=\"hstep\" minute-step=\"mstep\" show-meridian=\"ismeridian\"></timepicker></div>" +
  3865. " <span class=\"btn-group pull-right padintop\">\n" +
  3866. // " <button type=\"button\" class=\"btn btn-sm btn-primary\" ng-click=\"save()\">{{ getText('save') }}</button>\n" +
  3867. " <button type=\"button\" class=\"btn btn-sm btn-info\" ng-click=\"select('today')\">{{ getText('current') }}</button>\n" +
  3868. " <button type=\"button\" class=\"btn btn-sm btn-success \" ng-click=\"close()\">{{ getText('close') }}</button>\n" +
  3869. " </span>\n" +
  3870. " </li>\n" +
  3871. "</ul>\n" +
  3872. "");
  3873. }]);
  3874. angular.module("template/datepicker/popuptime.html", []).run(["$templateCache", function($templateCache) {
  3875. $templateCache.put("template/datepicker/popuptime.html",
  3876. "<ul class=\"dropdown-time\" ng-style=\"{display: (isOpen && 'block') || 'none', top: position.top+'px', left: position.left+'px'}\" ng-keydown=\"keydown($event)\">\n" +
  3877. " <li ng-transclude></li>\n" +
  3878. " <li ng-if=\"showButtonBar\" style=\"padding:10px 9px 2px\">\n" +
  3879. " <span class=\"btn-group pull-left\">\n" +
  3880. " <button type=\"button\" class=\"btn btn-sm btn-info\" ng-click=\"select('today')\">{{ getText('current') }}</button>\n" +
  3881. " <button type=\"button\" class=\"btn btn-sm btn-danger\" ng-click=\"select(null)\">{{ getText('clear') }}</button>\n" +
  3882. " </span>\n" +
  3883. " <button type=\"button\" class=\"btn btn-sm btn-success pull-right\" ng-click=\"close()\">{{ getText('close') }}</button>\n" +
  3884. " </li>\n" +
  3885. "</ul>\n" +
  3886. "");
  3887. }]);
  3888. angular.module("template/datepicker/year.html", []).run(["$templateCache", function($templateCache) {
  3889. $templateCache.put("template/datepicker/year.html",
  3890. "<table role=\"grid\" aria-labelledby=\"{{uniqueId}}-title\" aria-activedescendant=\"{{activeDateId}}\">\n" +
  3891. " <thead>\n" +
  3892. " <tr>\n" +
  3893. " <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" +
  3894. " <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()\" tabindex=\"-1\" style=\"width:100%;\"><strong>{{title}}</strong></button></th>\n" +
  3895. " <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" +
  3896. " </tr>\n" +
  3897. " </thead>\n" +
  3898. " <tbody>\n" +
  3899. " <tr ng-repeat=\"row in rows track by $index\">\n" +
  3900. " <td ng-repeat=\"dt in row track by dt.date\" class=\"text-center\" role=\"gridcell\" id=\"{{dt.uid}}\" aria-disabled=\"{{!!dt.disabled}}\">\n" +
  3901. " <button type=\"button\" style=\"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" +
  3902. " </td>\n" +
  3903. " </tr>\n" +
  3904. " </tbody>\n" +
  3905. "</table>\n" +
  3906. "");
  3907. }]);
  3908. angular.module("template/modal/backdrop.html", []).run(["$templateCache", function($templateCache) {
  3909. $templateCache.put("template/modal/backdrop.html",
  3910. "<div class=\"modal-backdrop fade {{ backdropClass }}\"\n" +
  3911. " ng-class=\"{in: animate}\"\n" +
  3912. " ng-style=\"{'z-index': 1040 + (index && 1 || 0) + index*10}\"\n" +
  3913. "></div>\n" +
  3914. "");
  3915. }]);
  3916. angular.module("template/modal/window.html", []).run(["$templateCache", function($templateCache) {
  3917. $templateCache.put("template/modal/window.html",
  3918. "<div tabindex=\"-1\" role=\"dialog\" class=\"modal fade\" ng-class=\"{in: animate}\" ng-style=\"{'z-index': 1050 + index*10, display: 'block'}\" ng-click=\"close($event)\">\n" +
  3919. " <div class=\"modal-dialog\" ng-class=\"{'modal-sm': size == 'sm', 'modal-lg': size == 'lg'}\"><div class=\"modal-content\" modal-transclude></div></div>\n" +
  3920. "</div>");
  3921. }]);
  3922. angular.module("template/pagination/pager.html", []).run(["$templateCache", function($templateCache) {
  3923. $templateCache.put("template/pagination/pager.html",
  3924. "<ul class=\"pager\">\n" +
  3925. " <li ng-class=\"{disabled: noPrevious(), previous: align}\"><a href ng-click=\"selectPage(page - 1)\">{{getText('previous')}}</a></li>\n" +
  3926. " <li ng-class=\"{disabled: noNext(), next: align}\"><a href ng-click=\"selectPage(page + 1)\">{{getText('next')}}</a></li>\n" +
  3927. "</ul>");
  3928. }]);
  3929. angular.module("template/pagination/pagination.html", []).run(["$templateCache", function($templateCache) {
  3930. $templateCache.put("template/pagination/pagination.html",
  3931. "<ul class=\"pagination\">\n" +
  3932. " <li ng-if=\"boundaryLinks\" ng-class=\"{disabled: noPrevious()}\"><a href ng-click=\"selectPage(1)\">{{getText('first')}}</a></li>\n" +
  3933. " <li ng-if=\"directionLinks\" ng-class=\"{disabled: noPrevious()}\"><a href ng-click=\"selectPage(page - 1)\">{{getText('previous')}}</a></li>\n" +
  3934. " <li ng-repeat=\"page in pages track by $index\" ng-class=\"{active: page.active}\"><a href ng-click=\"selectPage(page.number)\">{{page.text}}</a></li>\n" +
  3935. " <li ng-if=\"directionLinks\" ng-class=\"{disabled: noNext()}\"><a href ng-click=\"selectPage(page + 1)\">{{getText('next')}}</a></li>\n" +
  3936. " <li ng-if=\"boundaryLinks\" ng-class=\"{disabled: noNext()}\"><a href ng-click=\"selectPage(totalPages)\">{{getText('last')}}</a></li>\n" +
  3937. "</ul>");
  3938. }]);
  3939. angular.module("template/tooltip/tooltip-html-unsafe-popup.html", []).run(["$templateCache", function($templateCache) {
  3940. $templateCache.put("template/tooltip/tooltip-html-unsafe-popup.html",
  3941. "<div class=\"tooltip {{placement}}\" ng-class=\"{ in: isOpen(), fade: animation() }\">\n" +
  3942. " <div class=\"tooltip-arrow\"></div>\n" +
  3943. " <div class=\"tooltip-inner\" bind-html-unsafe=\"content\"></div>\n" +
  3944. "</div>\n" +
  3945. "");
  3946. }]);
  3947. angular.module("template/tooltip/tooltip-popup.html", []).run(["$templateCache", function($templateCache) {
  3948. $templateCache.put("template/tooltip/tooltip-popup.html",
  3949. "<div class=\"tooltip {{placement}}\" ng-class=\"{ in: isOpen(), fade: animation() }\">\n" +
  3950. " <div class=\"tooltip-arrow\"></div>\n" +
  3951. " <div class=\"tooltip-inner\" ng-bind=\"content\"></div>\n" +
  3952. "</div>\n" +
  3953. "");
  3954. }]);
  3955. angular.module("template/popover/popover.html", []).run(["$templateCache", function($templateCache) {
  3956. $templateCache.put("template/popover/popover.html",
  3957. "<div class=\"popover {{placement}}\" ng-class=\"{ in: isOpen(), fade: animation() }\">\n" +
  3958. " <div class=\"arrow\"></div>\n" +
  3959. "\n" +
  3960. " <div class=\"popover-inner\">\n" +
  3961. " <h3 class=\"popover-title\" ng-bind=\"title\" ng-show=\"title\"></h3>\n" +
  3962. " <div class=\"popover-content\" ng-bind=\"content\"></div>\n" +
  3963. " </div>\n" +
  3964. "</div>\n" +
  3965. "");
  3966. }]);
  3967. angular.module("template/progressbar/bar.html", []).run(["$templateCache", function($templateCache) {
  3968. $templateCache.put("template/progressbar/bar.html",
  3969. "<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 + '%'}\" aria-valuetext=\"{{percent | number:0}}%\" ng-transclude></div>");
  3970. }]);
  3971. angular.module("template/progressbar/progress.html", []).run(["$templateCache", function($templateCache) {
  3972. $templateCache.put("template/progressbar/progress.html",
  3973. "<div class=\"progress\" ng-transclude></div>");
  3974. }]);
  3975. angular.module("template/progressbar/progressbar.html", []).run(["$templateCache", function($templateCache) {
  3976. $templateCache.put("template/progressbar/progressbar.html",
  3977. "<div class=\"progress\">\n" +
  3978. " <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 + '%'}\" aria-valuetext=\"{{percent | number:0}}%\" ng-transclude></div>\n" +
  3979. "</div>");
  3980. }]);
  3981. angular.module("template/rating/rating.html", []).run(["$templateCache", function($templateCache) {
  3982. $templateCache.put("template/rating/rating.html",
  3983. "<span ng-mouseleave=\"reset()\" ng-keydown=\"onKeydown($event)\" tabindex=\"0\" role=\"slider\" aria-valuemin=\"0\" aria-valuemax=\"{{range.length}}\" aria-valuenow=\"{{value}}\">\n" +
  3984. " <i ng-repeat=\"r in range track by $index\" 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')\">\n" +
  3985. " <span class=\"sr-only\">({{ $index < value ? '*' : ' ' }})</span>\n" +
  3986. " </i>\n" +
  3987. "</span>");
  3988. }]);
  3989. angular.module("template/tabs/tab.html", []).run(["$templateCache", function($templateCache) {
  3990. $templateCache.put("template/tabs/tab.html",
  3991. "<li ng-class=\"{active: active, disabled: disabled}\">\n" +
  3992. " <a href ng-click=\"select()\" tab-heading-transclude>{{heading}}</a>\n" +
  3993. "</li>\n" +
  3994. "");
  3995. }]);
  3996. angular.module("template/tabs/tabset.html", []).run(["$templateCache", function($templateCache) {
  3997. $templateCache.put("template/tabs/tabset.html",
  3998. "<div>\n" +
  3999. " <ul class=\"nav nav-{{type || 'tabs'}}\" ng-class=\"{'nav-stacked': vertical, 'nav-justified': justified}\" ng-transclude></ul>\n" +
  4000. " <div class=\"tab-content\">\n" +
  4001. " <div class=\"tab-pane\" \n" +
  4002. " ng-repeat=\"tab in tabs\" \n" +
  4003. " ng-class=\"{active: tab.active}\"\n" +
  4004. " tab-content-transclude=\"tab\">\n" +
  4005. " </div>\n" +
  4006. " </div>\n" +
  4007. "</div>\n" +
  4008. "");
  4009. }]);
  4010. angular.module("template/timepicker/timepicker.html", []).run(["$templateCache", function($templateCache) {
  4011. $templateCache.put("template/timepicker/timepicker.html",
  4012. "<table>\n" +
  4013. " <tbody>\n" +
  4014. " <tr class=\"text-center\">\n" +
  4015. " <td><a ng-click=\"incrementHours()\" class=\"btn-link\" ><span class=\"glyphicon glyphicon-chevron-up\" style=\"font-size:8px\"></span></a></td>\n" +
  4016. " <td>&nbsp;</td>\n" +
  4017. " <td><a ng-click=\"incrementMinutes()\" class=\" btn-link\"><span class=\"glyphicon glyphicon-chevron-up\" style=\"font-size:8px\"></span></a></td>\n" +
  4018. " <td ng-show=\"showMeridian\"></td>\n" +
  4019. " </tr>\n" +
  4020. " <tr>\n" +
  4021. " <td style=\"width:80px;\" class=\"form-group\" ng-class=\"{'has-error': invalidHours}\">\n" +
  4022. " <input type=\"text\" style=\"margin-top:-3px\" ng-model=\"hours\" ng-change=\"updateHours()\" class=\"form-control text-center hourdata\" ng-mousewheel=\"incrementHours()\" ng-readonly=\"readonlyInput\" maxlength=\"2\">\n" +
  4023. " </td>\n" +
  4024. " <td>:</td>\n" +
  4025. " <td style=\"width:80px;\" class=\"form-group\" ng-class=\"{'has-error': invalidMinutes}\">\n" +
  4026. " <input type=\"text\" style=\"margin-top:-3px\" ng-model=\"minutes\" ng-change=\"updateMinutes()\" class=\"form-control text-center hourdata\" ng-readonly=\"readonlyInput\" maxlength=\"2\">\n" +
  4027. " </td>\n" +
  4028. " <td ng-show=\"showMeridian\"><button type=\"button\" class=\"btn btn-default text-center\" ng-click=\"toggleMeridian()\">{{meridian}}</button></td>\n" +
  4029. " </tr>\n" +
  4030. " <tr class=\"text-center\">\n" +
  4031. " <td><a ng-click=\"decrementHours()\" class=\" btn-link\"><span class=\"glyphicon glyphicon-chevron-down\" style=\"font-size:8px;margin-top:-3px\"></span></a></td>\n" +
  4032. " <td>&nbsp;</td>\n" +
  4033. " <td><a ng-click=\"decrementMinutes()\" class=\" btn-link\"><span class=\"glyphicon glyphicon-chevron-down\" style=\"font-size:8px;margin-top:-3px\"></span></a></td>\n" +
  4034. " <td ng-show=\"showMeridian\"></td>\n" +
  4035. " </tr>\n" +
  4036. " </tbody>\n" +
  4037. "</table>\n" +
  4038. "");
  4039. }]);
  4040. angular.module("template/typeahead/typeahead-match.html", []).run(["$templateCache", function($templateCache) {
  4041. $templateCache.put("template/typeahead/typeahead-match.html",
  4042. "<a tabindex=\"-1\" bind-html-unsafe=\"match.label | typeaheadHighlight:query\"></a>");
  4043. }]);
  4044. angular.module("template/typeahead/typeahead-popup.html", []).run(["$templateCache", function($templateCache) {
  4045. $templateCache.put("template/typeahead/typeahead-popup.html",
  4046. "<ul class=\"dropdown-menu\" ng-show=\"isOpen()\" ng-style=\"{top: position.top+'px', left: position.left+'px'}\" style=\"display: block;\" role=\"listbox\" aria-hidden=\"{{!isOpen()}}\">\n" +
  4047. " <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" +
  4048. " <div typeahead-match index=\"$index\" match=\"match\" query=\"query\" template-url=\"templateUrl\"></div>\n" +
  4049. " </li>\n" +
  4050. "</ul>\n" +
  4051. "");
  4052. }]);