ui-bootstrap-tpls.js 185 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701
  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 && scope.$parent.incidentModel.yyTime){
  1773. scope.hours = scope.$parent.incidentModel.yyTime.getHours();
  1774. scope.minutes = scope.$parent.incidentModel.yyTime.getMinutes();
  1775. }else if(scope.$parent.incidentModel && scope.$parent.incidentModel.acceptDate && scope.$parent.endOpen){
  1776. scope.hours = scope.$parent.incidentModel.acceptDate.getHours();
  1777. scope.minutes = scope.$parent.incidentModel.acceptDate.getMinutes();
  1778. }else if(scope.$parent.incidentModel && scope.$parent.incidentModel.responseHandleTime && scope.$parent.endOpen1){
  1779. scope.hours = scope.$parent.incidentModel.responseHandleTime.getHours();
  1780. scope.minutes = scope.$parent.incidentModel.responseHandleTime.getMinutes();
  1781. }else if(scope.$parent.incidentModel && scope.$parent.incidentModel.handleTime && scope.$parent.endOpen2){
  1782. scope.hours = scope.$parent.incidentModel.handleTime.getHours();
  1783. scope.minutes = scope.$parent.incidentModel.handleTime.getMinutes();
  1784. }
  1785. scope.incrementHours = function() {
  1786. addMinutes(1 * 60);
  1787. };
  1788. scope.save = function(hours, minutes) {
  1789. if(scope.$parent.model){
  1790. 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');
  1791. }else if(scope.$parent.incidentModel && scope.$parent.incidentModel.yyTime){
  1792. scope.$parent.incidentModel.yyTime = moment((new Date(Date.parse(scope.$parent.incidentModel.yyTime))).setHours(hours, minutes)).format('YYYY-MM-DD HH:mm:ss');
  1793. }else if(scope.$parent.incidentModel && scope.$parent.incidentModel.acceptDate && scope.$parent.endOpen){
  1794. scope.$parent.incidentModel.acceptDate = moment((new Date(Date.parse(scope.$parent.incidentModel.acceptDate))).setHours(hours, minutes)).format('YYYY-MM-DD HH:mm:ss');
  1795. }else if(scope.$parent.incidentModel && scope.$parent.incidentModel.responseHandleTime && scope.$parent.endOpen1){
  1796. scope.$parent.incidentModel.responseHandleTime = moment((new Date(Date.parse(scope.$parent.incidentModel.responseHandleTime))).setHours(hours, minutes)).format('YYYY-MM-DD HH:mm:ss');
  1797. }else if(scope.$parent.incidentModel && scope.$parent.incidentModel.handleTime && scope.$parent.endOpen2){
  1798. scope.$parent.incidentModel.handleTime = moment((new Date(Date.parse(scope.$parent.incidentModel.handleTime))).setHours(hours, minutes)).format('YYYY-MM-DD HH:mm:ss');
  1799. }
  1800. scope.isOpen = false;
  1801. };
  1802. scope.updateHours = function(dates) { //手动填写时
  1803. // scope.hours =(new Date(new Date(new Date(Date.parse(scope.$parent.model[scope.$parent.options.key]))).setHours( minutes))).getHours();
  1804. if(scope.$parent.model){
  1805. scope.$parent.model[scope.$parent.options.key] = moment(new Date(dates)).startOf('minute').format('YYYY-MM-DD HH:mm:ss');
  1806. }else if(scope.$parent.incidentModel && scope.$parent.incidentModel.yyTime){
  1807. scope.$parent.incidentModel.yyTime = moment(new Date(dates)).startOf('minute').format('YYYY-MM-DD HH:mm:ss');
  1808. }else if(scope.$parent.incidentModel && scope.$parent.incidentModel.acceptDate && scope.$parent.endOpen){
  1809. scope.$parent.incidentModel.acceptDate = moment(new Date(dates)).startOf('minute').format('YYYY-MM-DD HH:mm:ss');
  1810. }else if(scope.$parent.incidentModel && scope.$parent.incidentModel.responseHandleTime && scope.$parent.endOpen1){
  1811. scope.$parent.incidentModel.responseHandleTime = moment(new Date(dates)).startOf('minute').format('YYYY-MM-DD HH:mm:ss');
  1812. }else if(scope.$parent.incidentModel && scope.$parent.incidentModel.handleTime && scope.$parent.endOpen2){
  1813. scope.$parent.incidentModel.handleTime = moment(new Date(dates)).startOf('minute').format('YYYY-MM-DD HH:mm:ss');
  1814. }
  1815. }
  1816. }
  1817. };
  1818. });
  1819. angular.module('ui.bootstrap.dropdown', [])
  1820. .constant('dropdownConfig', {
  1821. openClass: 'open'
  1822. })
  1823. .service('dropdownService', ['$document', function($document) {
  1824. var openScope = null;
  1825. this.open = function(dropdownScope) {
  1826. if (!openScope) {
  1827. $document.bind('click', closeDropdown);
  1828. $document.bind('keydown', escapeKeyBind);
  1829. }
  1830. if (openScope && openScope !== dropdownScope) {
  1831. openScope.isOpen = false;
  1832. }
  1833. openScope = dropdownScope;
  1834. };
  1835. this.close = function(dropdownScope) {
  1836. if (openScope === dropdownScope) {
  1837. openScope = null;
  1838. $document.unbind('click', closeDropdown);
  1839. $document.unbind('keydown', escapeKeyBind);
  1840. }
  1841. };
  1842. var closeDropdown = function(evt) {
  1843. // This method may still be called during the same mouse event that
  1844. // unbound this event handler. So check openScope before proceeding.
  1845. if (!openScope) { return; }
  1846. var toggleElement = openScope.getToggleElement();
  1847. if (evt && toggleElement && toggleElement[0].contains(evt.target)) {
  1848. return;
  1849. }
  1850. openScope.$apply(function() {
  1851. openScope.isOpen = false;
  1852. });
  1853. };
  1854. var escapeKeyBind = function(evt) {
  1855. if (evt.which === 27) {
  1856. openScope.focusToggleElement();
  1857. closeDropdown();
  1858. }
  1859. };
  1860. }])
  1861. .controller('DropdownController', ['$scope', '$attrs', '$parse', 'dropdownConfig', 'dropdownService', '$animate', function($scope, $attrs, $parse, dropdownConfig, dropdownService, $animate) {
  1862. var self = this,
  1863. scope = $scope.$new(), // create a child scope so we are not polluting original one
  1864. openClass = dropdownConfig.openClass,
  1865. getIsOpen,
  1866. setIsOpen = angular.noop,
  1867. toggleInvoker = $attrs.onToggle ? $parse($attrs.onToggle) : angular.noop;
  1868. this.init = function(element) {
  1869. self.$element = element;
  1870. if ($attrs.isOpen) {
  1871. getIsOpen = $parse($attrs.isOpen);
  1872. setIsOpen = getIsOpen.assign;
  1873. $scope.$watch(getIsOpen, function(value) {
  1874. scope.isOpen = !!value;
  1875. });
  1876. }
  1877. };
  1878. this.toggle = function(open) {
  1879. return scope.isOpen = arguments.length ? !!open : !scope.isOpen;
  1880. };
  1881. // Allow other directives to watch status
  1882. this.isOpen = function() {
  1883. return scope.isOpen;
  1884. };
  1885. scope.getToggleElement = function() {
  1886. return self.toggleElement;
  1887. };
  1888. scope.focusToggleElement = function() {
  1889. if (self.toggleElement) {
  1890. self.toggleElement[0].focus();
  1891. }
  1892. };
  1893. scope.$watch('isOpen', function(isOpen, wasOpen) {
  1894. $animate[isOpen ? 'addClass' : 'removeClass'](self.$element, openClass);
  1895. if (isOpen) {
  1896. scope.focusToggleElement();
  1897. dropdownService.open(scope);
  1898. } else {
  1899. dropdownService.close(scope);
  1900. }
  1901. setIsOpen($scope, isOpen);
  1902. if (angular.isDefined(isOpen) && isOpen !== wasOpen) {
  1903. toggleInvoker($scope, { open: !!isOpen });
  1904. }
  1905. });
  1906. $scope.$on('$locationChangeSuccess', function() {
  1907. scope.isOpen = false;
  1908. });
  1909. $scope.$on('$destroy', function() {
  1910. scope.$destroy();
  1911. });
  1912. }])
  1913. .directive('dropdown', function() {
  1914. return {
  1915. controller: 'DropdownController',
  1916. link: function(scope, element, attrs, dropdownCtrl) {
  1917. dropdownCtrl.init(element);
  1918. }
  1919. };
  1920. })
  1921. .directive('dropdownToggle', function() {
  1922. return {
  1923. require: '?^dropdown',
  1924. link: function(scope, element, attrs, dropdownCtrl) {
  1925. if (!dropdownCtrl) {
  1926. return;
  1927. }
  1928. dropdownCtrl.toggleElement = element;
  1929. var toggleDropdown = function(event) {
  1930. event.preventDefault();
  1931. if (!element.hasClass('disabled') && !attrs.disabled) {
  1932. scope.$apply(function() {
  1933. dropdownCtrl.toggle();
  1934. });
  1935. }
  1936. };
  1937. element.bind('click', toggleDropdown);
  1938. // WAI-ARIA
  1939. element.attr({ 'aria-haspopup': true, 'aria-expanded': false });
  1940. scope.$watch(dropdownCtrl.isOpen, function(isOpen) {
  1941. element.attr('aria-expanded', !!isOpen);
  1942. });
  1943. scope.$on('$destroy', function() {
  1944. element.unbind('click', toggleDropdown);
  1945. });
  1946. }
  1947. };
  1948. });
  1949. angular.module('ui.bootstrap.modal', ['ui.bootstrap.transition'])
  1950. /**
  1951. * A helper, internal data structure that acts as a map but also allows getting / removing
  1952. * elements in the LIFO order
  1953. */
  1954. .factory('$$stackedMap', function() {
  1955. return {
  1956. createNew: function() {
  1957. var stack = [];
  1958. return {
  1959. add: function(key, value) {
  1960. stack.push({
  1961. key: key,
  1962. value: value
  1963. });
  1964. },
  1965. get: function(key) {
  1966. for (var i = 0; i < stack.length; i++) {
  1967. if (key == stack[i].key) {
  1968. return stack[i];
  1969. }
  1970. }
  1971. },
  1972. keys: function() {
  1973. var keys = [];
  1974. for (var i = 0; i < stack.length; i++) {
  1975. keys.push(stack[i].key);
  1976. }
  1977. return keys;
  1978. },
  1979. top: function() {
  1980. return stack[stack.length - 1];
  1981. },
  1982. remove: function(key) {
  1983. var idx = -1;
  1984. for (var i = 0; i < stack.length; i++) {
  1985. if (key == stack[i].key) {
  1986. idx = i;
  1987. break;
  1988. }
  1989. }
  1990. return stack.splice(idx, 1)[0];
  1991. },
  1992. removeTop: function() {
  1993. return stack.splice(stack.length - 1, 1)[0];
  1994. },
  1995. length: function() {
  1996. return stack.length;
  1997. }
  1998. };
  1999. }
  2000. };
  2001. })
  2002. /**
  2003. * A helper directive for the $modal service. It creates a backdrop element.
  2004. */
  2005. .directive('modalBackdrop', ['$timeout', function($timeout) {
  2006. return {
  2007. restrict: 'EA',
  2008. replace: true,
  2009. templateUrl: 'template/modal/backdrop.html',
  2010. link: function(scope, element, attrs) {
  2011. scope.backdropClass = attrs.backdropClass || '';
  2012. scope.animate = false;
  2013. //trigger CSS transitions
  2014. $timeout(function() {
  2015. scope.animate = true;
  2016. });
  2017. }
  2018. };
  2019. }])
  2020. .directive('modalWindow', ['$modalStack', '$timeout', function($modalStack, $timeout) {
  2021. return {
  2022. restrict: 'EA',
  2023. scope: {
  2024. index: '@',
  2025. animate: '='
  2026. },
  2027. replace: true,
  2028. transclude: true,
  2029. templateUrl: function(tElement, tAttrs) {
  2030. return tAttrs.templateUrl || 'template/modal/window.html';
  2031. },
  2032. link: function(scope, element, attrs) {
  2033. element.addClass(attrs.windowClass || '');
  2034. scope.size = attrs.size;
  2035. $timeout(function() {
  2036. // trigger CSS transitions
  2037. scope.animate = true;
  2038. /**
  2039. * Auto-focusing of a freshly-opened modal element causes any child elements
  2040. * with the autofocus attribute to lose focus. This is an issue on touch
  2041. * based devices which will show and then hide the onscreen keyboard.
  2042. * Attempts to refocus the autofocus element via JavaScript will not reopen
  2043. * the onscreen keyboard. Fixed by updated the focusing logic to only autofocus
  2044. * the modal element if the modal does not contain an autofocus element.
  2045. */
  2046. if (!element[0].querySelectorAll('[autofocus]').length) {
  2047. element[0].focus();
  2048. }
  2049. });
  2050. scope.close = function(evt) {
  2051. var modal = $modalStack.getTop();
  2052. if (modal && modal.value.backdrop && modal.value.backdrop != 'static' && (evt.target === evt.currentTarget)) {
  2053. evt.preventDefault();
  2054. evt.stopPropagation();
  2055. $modalStack.dismiss(modal.key, 'backdrop click');
  2056. }
  2057. };
  2058. }
  2059. };
  2060. }])
  2061. .directive('modalTransclude', function() {
  2062. return {
  2063. link: function($scope, $element, $attrs, controller, $transclude) {
  2064. $transclude($scope.$parent, function(clone) {
  2065. $element.empty();
  2066. $element.append(clone);
  2067. });
  2068. }
  2069. };
  2070. })
  2071. .factory('$modalStack', ['$transition', '$timeout', '$document', '$compile', '$rootScope', '$$stackedMap',
  2072. function($transition, $timeout, $document, $compile, $rootScope, $$stackedMap) {
  2073. var OPENED_MODAL_CLASS = 'modal-open';
  2074. var backdropDomEl, backdropScope;
  2075. var openedWindows = $$stackedMap.createNew();
  2076. var $modalStack = {};
  2077. function backdropIndex() {
  2078. var topBackdropIndex = -1;
  2079. var opened = openedWindows.keys();
  2080. for (var i = 0; i < opened.length; i++) {
  2081. if (openedWindows.get(opened[i]).value.backdrop) {
  2082. topBackdropIndex = i;
  2083. }
  2084. }
  2085. return topBackdropIndex;
  2086. }
  2087. $rootScope.$watch(backdropIndex, function(newBackdropIndex) {
  2088. if (backdropScope) {
  2089. backdropScope.index = newBackdropIndex;
  2090. }
  2091. });
  2092. function removeModalWindow(modalInstance) {
  2093. var body = $document.find('body').eq(0);
  2094. var modalWindow = openedWindows.get(modalInstance).value;
  2095. //clean up the stack
  2096. openedWindows.remove(modalInstance);
  2097. //remove window DOM element
  2098. removeAfterAnimate(modalWindow.modalDomEl, modalWindow.modalScope, 300, function() {
  2099. modalWindow.modalScope.$destroy();
  2100. body.toggleClass(OPENED_MODAL_CLASS, openedWindows.length() > 0);
  2101. checkRemoveBackdrop();
  2102. });
  2103. }
  2104. function checkRemoveBackdrop() {
  2105. //remove backdrop if no longer needed
  2106. if (backdropDomEl && backdropIndex() == -1) {
  2107. var backdropScopeRef = backdropScope;
  2108. removeAfterAnimate(backdropDomEl, backdropScope, 150, function() {
  2109. backdropScopeRef.$destroy();
  2110. backdropScopeRef = null;
  2111. });
  2112. backdropDomEl = undefined;
  2113. backdropScope = undefined;
  2114. }
  2115. }
  2116. function removeAfterAnimate(domEl, scope, emulateTime, done) {
  2117. // Closing animation
  2118. scope.animate = false;
  2119. var transitionEndEventName = $transition.transitionEndEventName;
  2120. if (transitionEndEventName) {
  2121. // transition out
  2122. var timeout = $timeout(afterAnimating, emulateTime);
  2123. domEl.bind(transitionEndEventName, function() {
  2124. $timeout.cancel(timeout);
  2125. afterAnimating();
  2126. scope.$apply();
  2127. });
  2128. } else {
  2129. // Ensure this call is async
  2130. $timeout(afterAnimating);
  2131. }
  2132. function afterAnimating() {
  2133. if (afterAnimating.done) {
  2134. return;
  2135. }
  2136. afterAnimating.done = true;
  2137. domEl.remove();
  2138. if (done) {
  2139. done();
  2140. }
  2141. }
  2142. }
  2143. $document.bind('keydown', function(evt) {
  2144. var modal;
  2145. if (evt.which === 27) {
  2146. modal = openedWindows.top();
  2147. if (modal && modal.value.keyboard) {
  2148. evt.preventDefault();
  2149. $rootScope.$apply(function() {
  2150. $modalStack.dismiss(modal.key, 'escape key press');
  2151. });
  2152. }
  2153. }
  2154. });
  2155. $modalStack.open = function(modalInstance, modal) {
  2156. openedWindows.add(modalInstance, {
  2157. deferred: modal.deferred,
  2158. modalScope: modal.scope,
  2159. backdrop: modal.backdrop,
  2160. keyboard: modal.keyboard
  2161. });
  2162. var body = $document.find('body').eq(0),
  2163. currBackdropIndex = backdropIndex();
  2164. if (currBackdropIndex >= 0 && !backdropDomEl) {
  2165. backdropScope = $rootScope.$new(true);
  2166. backdropScope.index = currBackdropIndex;
  2167. var angularBackgroundDomEl = angular.element('<div modal-backdrop></div>');
  2168. angularBackgroundDomEl.attr('backdrop-class', modal.backdropClass);
  2169. backdropDomEl = $compile(angularBackgroundDomEl)(backdropScope);
  2170. body.append(backdropDomEl);
  2171. }
  2172. var angularDomEl = angular.element('<div modal-window></div>');
  2173. angularDomEl.attr({
  2174. 'template-url': modal.windowTemplateUrl,
  2175. 'window-class': modal.windowClass,
  2176. 'size': modal.size,
  2177. 'index': openedWindows.length() - 1,
  2178. 'animate': 'animate'
  2179. }).html(modal.content);
  2180. var modalDomEl = $compile(angularDomEl)(modal.scope);
  2181. openedWindows.top().value.modalDomEl = modalDomEl;
  2182. body.append(modalDomEl);
  2183. body.addClass(OPENED_MODAL_CLASS);
  2184. };
  2185. $modalStack.close = function(modalInstance, result) {
  2186. var modalWindow = openedWindows.get(modalInstance);
  2187. if (modalWindow) {
  2188. modalWindow.value.deferred.resolve(result);
  2189. removeModalWindow(modalInstance);
  2190. }
  2191. };
  2192. $modalStack.dismiss = function(modalInstance, reason) {
  2193. var modalWindow = openedWindows.get(modalInstance);
  2194. if (modalWindow) {
  2195. modalWindow.value.deferred.reject(reason);
  2196. removeModalWindow(modalInstance);
  2197. }
  2198. };
  2199. $modalStack.dismissAll = function(reason) {
  2200. var topModal = this.getTop();
  2201. while (topModal) {
  2202. this.dismiss(topModal.key, reason);
  2203. topModal = this.getTop();
  2204. }
  2205. };
  2206. $modalStack.getTop = function() {
  2207. return openedWindows.top();
  2208. };
  2209. return $modalStack;
  2210. }
  2211. ])
  2212. .provider('$modal', function() {
  2213. var $modalProvider = {
  2214. options: {
  2215. backdrop: true, //can be also false or 'static'
  2216. keyboard: true
  2217. },
  2218. $get: ['$injector', '$rootScope', '$q', '$http', '$templateCache', '$controller', '$modalStack',
  2219. function($injector, $rootScope, $q, $http, $templateCache, $controller, $modalStack) {
  2220. var $modal = {};
  2221. function getTemplatePromise(options) {
  2222. return options.template ? $q.when(options.template) :
  2223. $http.get(angular.isFunction(options.templateUrl) ? (options.templateUrl)() : options.templateUrl, { cache: $templateCache }).then(function(result) {
  2224. return result.data;
  2225. });
  2226. }
  2227. function getResolvePromises(resolves) {
  2228. var promisesArr = [];
  2229. angular.forEach(resolves, function(value) {
  2230. if (angular.isFunction(value) || angular.isArray(value)) {
  2231. promisesArr.push($q.when($injector.invoke(value)));
  2232. }
  2233. });
  2234. return promisesArr;
  2235. }
  2236. $modal.open = function(modalOptions) {
  2237. var modalResultDeferred = $q.defer();
  2238. var modalOpenedDeferred = $q.defer();
  2239. //prepare an instance of a modal to be injected into controllers and returned to a caller
  2240. var modalInstance = {
  2241. result: modalResultDeferred.promise,
  2242. opened: modalOpenedDeferred.promise,
  2243. close: function(result) {
  2244. $modalStack.close(modalInstance, result);
  2245. },
  2246. dismiss: function(reason) {
  2247. $modalStack.dismiss(modalInstance, reason);
  2248. }
  2249. };
  2250. //merge and clean up options
  2251. modalOptions = angular.extend({}, $modalProvider.options, modalOptions);
  2252. modalOptions.resolve = modalOptions.resolve || {};
  2253. //verify options
  2254. if (!modalOptions.template && !modalOptions.templateUrl) {
  2255. throw new Error('One of template or templateUrl options is required.');
  2256. }
  2257. var templateAndResolvePromise =
  2258. $q.all([getTemplatePromise(modalOptions)].concat(getResolvePromises(modalOptions.resolve)));
  2259. templateAndResolvePromise.then(function resolveSuccess(tplAndVars) {
  2260. var modalScope = (modalOptions.scope || $rootScope).$new();
  2261. modalScope.$close = modalInstance.close;
  2262. modalScope.$dismiss = modalInstance.dismiss;
  2263. var ctrlInstance, ctrlLocals = {};
  2264. var resolveIter = 1;
  2265. //controllers
  2266. if (modalOptions.controller) {
  2267. ctrlLocals.$scope = modalScope;
  2268. ctrlLocals.$modalInstance = modalInstance;
  2269. angular.forEach(modalOptions.resolve, function(value, key) {
  2270. ctrlLocals[key] = tplAndVars[resolveIter++];
  2271. });
  2272. ctrlInstance = $controller(modalOptions.controller, ctrlLocals);
  2273. if (modalOptions.controllerAs) {
  2274. modalScope[modalOptions.controllerAs] = ctrlInstance;
  2275. }
  2276. }
  2277. $modalStack.open(modalInstance, {
  2278. scope: modalScope,
  2279. deferred: modalResultDeferred,
  2280. content: tplAndVars[0],
  2281. backdrop: modalOptions.backdrop,
  2282. keyboard: modalOptions.keyboard,
  2283. backdropClass: modalOptions.backdropClass,
  2284. windowClass: modalOptions.windowClass,
  2285. windowTemplateUrl: modalOptions.windowTemplateUrl,
  2286. size: modalOptions.size
  2287. });
  2288. }, function resolveError(reason) {
  2289. modalResultDeferred.reject(reason);
  2290. });
  2291. templateAndResolvePromise.then(function() {
  2292. modalOpenedDeferred.resolve(true);
  2293. }, function() {
  2294. modalOpenedDeferred.reject(false);
  2295. });
  2296. return modalInstance;
  2297. };
  2298. return $modal;
  2299. }
  2300. ]
  2301. };
  2302. return $modalProvider;
  2303. });
  2304. angular.module('ui.bootstrap.pagination', [])
  2305. .controller('PaginationController', ['$scope', '$attrs', '$parse', function($scope, $attrs, $parse) {
  2306. var self = this,
  2307. ngModelCtrl = { $setViewValue: angular.noop }, // nullModelCtrl
  2308. setNumPages = $attrs.numPages ? $parse($attrs.numPages).assign : angular.noop;
  2309. this.init = function(ngModelCtrl_, config) {
  2310. ngModelCtrl = ngModelCtrl_;
  2311. this.config = config;
  2312. ngModelCtrl.$render = function() {
  2313. self.render();
  2314. };
  2315. if ($attrs.itemsPerPage) {
  2316. $scope.$parent.$watch($parse($attrs.itemsPerPage), function(value) {
  2317. self.itemsPerPage = parseInt(value, 10);
  2318. $scope.totalPages = self.calculateTotalPages();
  2319. });
  2320. } else {
  2321. this.itemsPerPage = config.itemsPerPage;
  2322. }
  2323. };
  2324. this.calculateTotalPages = function() {
  2325. var totalPages = this.itemsPerPage < 1 ? 1 : Math.ceil($scope.totalItems / this.itemsPerPage);
  2326. return Math.max(totalPages || 0, 1);
  2327. };
  2328. this.render = function() {
  2329. $scope.page = parseInt(ngModelCtrl.$viewValue, 10) || 1;
  2330. };
  2331. $scope.selectPage = function(page) {
  2332. if ($scope.page !== page && page > 0 && page <= $scope.totalPages) {
  2333. ngModelCtrl.$setViewValue(page);
  2334. ngModelCtrl.$render();
  2335. }
  2336. };
  2337. $scope.getText = function(key) {
  2338. return $scope[key + 'Text'] || self.config[key + 'Text'];
  2339. };
  2340. $scope.noPrevious = function() {
  2341. return $scope.page === 1;
  2342. };
  2343. $scope.noNext = function() {
  2344. return $scope.page === $scope.totalPages;
  2345. };
  2346. $scope.$watch('totalItems', function() {
  2347. $scope.totalPages = self.calculateTotalPages();
  2348. });
  2349. $scope.$watch('totalPages', function(value) {
  2350. setNumPages($scope.$parent, value); // Readonly variable
  2351. if ($scope.page > value) {
  2352. $scope.selectPage(value);
  2353. } else {
  2354. ngModelCtrl.$render();
  2355. }
  2356. });
  2357. }])
  2358. .constant('paginationConfig', {
  2359. itemsPerPage: 10,
  2360. boundaryLinks: false,
  2361. directionLinks: true,
  2362. firstText: 'First',
  2363. previousText: 'Previous',
  2364. nextText: 'Next',
  2365. lastText: 'Last',
  2366. rotate: true
  2367. })
  2368. .directive('pagination', ['$parse', 'paginationConfig', function($parse, paginationConfig) {
  2369. return {
  2370. restrict: 'EA',
  2371. scope: {
  2372. totalItems: '=',
  2373. firstText: '@',
  2374. previousText: '@',
  2375. nextText: '@',
  2376. lastText: '@'
  2377. },
  2378. require: ['pagination', '?ngModel'],
  2379. controller: 'PaginationController',
  2380. templateUrl: 'template/pagination/pagination.html',
  2381. replace: true,
  2382. link: function(scope, element, attrs, ctrls) {
  2383. var paginationCtrl = ctrls[0],
  2384. ngModelCtrl = ctrls[1];
  2385. if (!ngModelCtrl) {
  2386. return; // do nothing if no ng-model
  2387. }
  2388. // Setup configuration parameters
  2389. var maxSize = angular.isDefined(attrs.maxSize) ? scope.$parent.$eval(attrs.maxSize) : paginationConfig.maxSize,
  2390. rotate = angular.isDefined(attrs.rotate) ? scope.$parent.$eval(attrs.rotate) : paginationConfig.rotate;
  2391. scope.boundaryLinks = angular.isDefined(attrs.boundaryLinks) ? scope.$parent.$eval(attrs.boundaryLinks) : paginationConfig.boundaryLinks;
  2392. scope.directionLinks = angular.isDefined(attrs.directionLinks) ? scope.$parent.$eval(attrs.directionLinks) : paginationConfig.directionLinks;
  2393. paginationCtrl.init(ngModelCtrl, paginationConfig);
  2394. if (attrs.maxSize) {
  2395. scope.$parent.$watch($parse(attrs.maxSize), function(value) {
  2396. maxSize = parseInt(value, 10);
  2397. paginationCtrl.render();
  2398. });
  2399. }
  2400. // Create page object used in template
  2401. function makePage(number, text, isActive) {
  2402. return {
  2403. number: number,
  2404. text: text,
  2405. active: isActive
  2406. };
  2407. }
  2408. function getPages(currentPage, totalPages) {
  2409. var pages = [];
  2410. // Default page limits
  2411. var startPage = 1,
  2412. endPage = totalPages;
  2413. var isMaxSized = (angular.isDefined(maxSize) && maxSize < totalPages);
  2414. // recompute if maxSize
  2415. if (isMaxSized) {
  2416. if (rotate) {
  2417. // Current page is displayed in the middle of the visible ones
  2418. startPage = Math.max(currentPage - Math.floor(maxSize / 2), 1);
  2419. endPage = startPage + maxSize - 1;
  2420. // Adjust if limit is exceeded
  2421. if (endPage > totalPages) {
  2422. endPage = totalPages;
  2423. startPage = endPage - maxSize + 1;
  2424. }
  2425. } else {
  2426. // Visible pages are paginated with maxSize
  2427. startPage = ((Math.ceil(currentPage / maxSize) - 1) * maxSize) + 1;
  2428. // Adjust last page if limit is exceeded
  2429. endPage = Math.min(startPage + maxSize - 1, totalPages);
  2430. }
  2431. }
  2432. // Add page number links
  2433. for (var number = startPage; number <= endPage; number++) {
  2434. var page = makePage(number, number, number === currentPage);
  2435. pages.push(page);
  2436. }
  2437. // Add links to move between page sets
  2438. if (isMaxSized && !rotate) {
  2439. if (startPage > 1) {
  2440. var previousPageSet = makePage(startPage - 1, '...', false);
  2441. pages.unshift(previousPageSet);
  2442. }
  2443. if (endPage < totalPages) {
  2444. var nextPageSet = makePage(endPage + 1, '...', false);
  2445. pages.push(nextPageSet);
  2446. }
  2447. }
  2448. return pages;
  2449. }
  2450. var originalRender = paginationCtrl.render;
  2451. paginationCtrl.render = function() {
  2452. originalRender();
  2453. if (scope.page > 0 && scope.page <= scope.totalPages) {
  2454. scope.pages = getPages(scope.page, scope.totalPages);
  2455. }
  2456. };
  2457. }
  2458. };
  2459. }])
  2460. .constant('pagerConfig', {
  2461. itemsPerPage: 10,
  2462. previousText: '« Previous',
  2463. nextText: 'Next »',
  2464. align: true
  2465. })
  2466. .directive('pager', ['pagerConfig', function(pagerConfig) {
  2467. return {
  2468. restrict: 'EA',
  2469. scope: {
  2470. totalItems: '=',
  2471. previousText: '@',
  2472. nextText: '@'
  2473. },
  2474. require: ['pager', '?ngModel'],
  2475. controller: 'PaginationController',
  2476. templateUrl: 'template/pagination/pager.html',
  2477. replace: true,
  2478. link: function(scope, element, attrs, ctrls) {
  2479. var paginationCtrl = ctrls[0],
  2480. ngModelCtrl = ctrls[1];
  2481. if (!ngModelCtrl) {
  2482. return; // do nothing if no ng-model
  2483. }
  2484. scope.align = angular.isDefined(attrs.align) ? scope.$parent.$eval(attrs.align) : pagerConfig.align;
  2485. paginationCtrl.init(ngModelCtrl, pagerConfig);
  2486. }
  2487. };
  2488. }]);
  2489. /**
  2490. * The following features are still outstanding: animation as a
  2491. * function, placement as a function, inside, support for more triggers than
  2492. * just mouse enter/leave, html tooltips, and selector delegation.
  2493. */
  2494. angular.module('ui.bootstrap.tooltip', ['ui.bootstrap.position', 'ui.bootstrap.bindHtml'])
  2495. /**
  2496. * The $tooltip service creates tooltip- and popover-like directives as well as
  2497. * houses global options for them.
  2498. */
  2499. .provider('$tooltip', function() {
  2500. // The default options tooltip and popover.
  2501. var defaultOptions = {
  2502. placement: 'top',
  2503. animation: true,
  2504. popupDelay: 0
  2505. };
  2506. // Default hide triggers for each show trigger
  2507. var triggerMap = {
  2508. 'mouseenter': 'mouseleave',
  2509. 'click': 'click',
  2510. 'focus': 'blur'
  2511. };
  2512. // The options specified to the provider globally.
  2513. var globalOptions = {};
  2514. /**
  2515. * `options({})` allows global configuration of all tooltips in the
  2516. * application.
  2517. *
  2518. * var app = angular.module( 'App', ['ui.bootstrap.tooltip'], function( $tooltipProvider ) {
  2519. * // place tooltips left instead of top by default
  2520. * $tooltipProvider.options( { placement: 'left' } );
  2521. * });
  2522. */
  2523. this.options = function(value) {
  2524. angular.extend(globalOptions, value);
  2525. };
  2526. /**
  2527. * This allows you to extend the set of trigger mappings available. E.g.:
  2528. *
  2529. * $tooltipProvider.setTriggers( 'openTrigger': 'closeTrigger' );
  2530. */
  2531. this.setTriggers = function setTriggers(triggers) {
  2532. angular.extend(triggerMap, triggers);
  2533. };
  2534. /**
  2535. * This is a helper function for translating camel-case to snake-case.
  2536. */
  2537. function snake_case(name) {
  2538. var regexp = /[A-Z]/g;
  2539. var separator = '-';
  2540. return name.replace(regexp, function(letter, pos) {
  2541. return (pos ? separator : '') + letter.toLowerCase();
  2542. });
  2543. }
  2544. /**
  2545. * Returns the actual instance of the $tooltip service.
  2546. * TODO support multiple triggers
  2547. */
  2548. this.$get = ['$window', '$compile', '$timeout', '$document', '$position', '$interpolate', function($window, $compile, $timeout, $document, $position, $interpolate) {
  2549. return function $tooltip(type, prefix, defaultTriggerShow) {
  2550. var options = angular.extend({}, defaultOptions, globalOptions);
  2551. /**
  2552. * Returns an object of show and hide triggers.
  2553. *
  2554. * If a trigger is supplied,
  2555. * it is used to show the tooltip; otherwise, it will use the `trigger`
  2556. * option passed to the `$tooltipProvider.options` method; else it will
  2557. * default to the trigger supplied to this directive factory.
  2558. *
  2559. * The hide trigger is based on the show trigger. If the `trigger` option
  2560. * was passed to the `$tooltipProvider.options` method, it will use the
  2561. * mapped trigger from `triggerMap` or the passed trigger if the map is
  2562. * undefined; otherwise, it uses the `triggerMap` value of the show
  2563. * trigger; else it will just use the show trigger.
  2564. */
  2565. function getTriggers(trigger) {
  2566. var show = trigger || options.trigger || defaultTriggerShow;
  2567. var hide = triggerMap[show] || show;
  2568. return {
  2569. show: show,
  2570. hide: hide
  2571. };
  2572. }
  2573. var directiveName = snake_case(type);
  2574. var startSym = $interpolate.startSymbol();
  2575. var endSym = $interpolate.endSymbol();
  2576. var template =
  2577. '<div ' + directiveName + '-popup ' +
  2578. 'title="' + startSym + 'title' + endSym + '" ' +
  2579. 'content="' + startSym + 'content' + endSym + '" ' +
  2580. 'placement="' + startSym + 'placement' + endSym + '" ' +
  2581. 'animation="animation" ' +
  2582. 'is-open="isOpen"' +
  2583. '>' +
  2584. '</div>';
  2585. return {
  2586. restrict: 'EA',
  2587. compile: function(tElem, tAttrs) {
  2588. var tooltipLinker = $compile(template);
  2589. return function link(scope, element, attrs) {
  2590. var tooltip;
  2591. var tooltipLinkedScope;
  2592. var transitionTimeout;
  2593. var popupTimeout;
  2594. var appendToBody = angular.isDefined(options.appendToBody) ? options.appendToBody : false;
  2595. var triggers = getTriggers(undefined);
  2596. var hasEnableExp = angular.isDefined(attrs[prefix + 'Enable']);
  2597. var ttScope = scope.$new(true);
  2598. var positionTooltip = function() {
  2599. var ttPosition = $position.positionElements(element, tooltip, ttScope.placement, appendToBody);
  2600. ttPosition.top += 'px';
  2601. ttPosition.left += 'px';
  2602. // Now set the calculated positioning.
  2603. tooltip.css(ttPosition);
  2604. };
  2605. // By default, the tooltip is not open.
  2606. // TODO add ability to start tooltip opened
  2607. ttScope.isOpen = false;
  2608. function toggleTooltipBind() {
  2609. if (!ttScope.isOpen) {
  2610. showTooltipBind();
  2611. } else {
  2612. hideTooltipBind();
  2613. }
  2614. }
  2615. // Show the tooltip with delay if specified, otherwise show it immediately
  2616. function showTooltipBind() {
  2617. if (hasEnableExp && !scope.$eval(attrs[prefix + 'Enable'])) {
  2618. return;
  2619. }
  2620. prepareTooltip();
  2621. if (ttScope.popupDelay) {
  2622. // Do nothing if the tooltip was already scheduled to pop-up.
  2623. // This happens if show is triggered multiple times before any hide is triggered.
  2624. if (!popupTimeout) {
  2625. popupTimeout = $timeout(show, ttScope.popupDelay, false);
  2626. popupTimeout.then(function(reposition) { reposition(); });
  2627. }
  2628. } else {
  2629. show()();
  2630. }
  2631. }
  2632. function hideTooltipBind() {
  2633. scope.$apply(function() {
  2634. hide();
  2635. });
  2636. }
  2637. // Show the tooltip popup element.
  2638. function show() {
  2639. popupTimeout = null;
  2640. // If there is a pending remove transition, we must cancel it, lest the
  2641. // tooltip be mysteriously removed.
  2642. if (transitionTimeout) {
  2643. $timeout.cancel(transitionTimeout);
  2644. transitionTimeout = null;
  2645. }
  2646. // Don't show empty tooltips.
  2647. if (!ttScope.content) {
  2648. return angular.noop;
  2649. }
  2650. createTooltip();
  2651. // Set the initial positioning.
  2652. tooltip.css({ top: 0, left: 0, display: 'block' });
  2653. ttScope.$digest();
  2654. positionTooltip();
  2655. // And show the tooltip.
  2656. ttScope.isOpen = true;
  2657. ttScope.$digest(); // digest required as $apply is not called
  2658. // Return positioning function as promise callback for correct
  2659. // positioning after draw.
  2660. return positionTooltip;
  2661. }
  2662. // Hide the tooltip popup element.
  2663. function hide() {
  2664. // First things first: we don't show it anymore.
  2665. ttScope.isOpen = false;
  2666. //if tooltip is going to be shown after delay, we must cancel this
  2667. $timeout.cancel(popupTimeout);
  2668. popupTimeout = null;
  2669. // And now we remove it from the DOM. However, if we have animation, we
  2670. // need to wait for it to expire beforehand.
  2671. // FIXME: this is a placeholder for a port of the transitions library.
  2672. if (ttScope.animation) {
  2673. if (!transitionTimeout) {
  2674. transitionTimeout = $timeout(removeTooltip, 500);
  2675. }
  2676. } else {
  2677. removeTooltip();
  2678. }
  2679. }
  2680. function createTooltip() {
  2681. // There can only be one tooltip element per directive shown at once.
  2682. if (tooltip) {
  2683. removeTooltip();
  2684. }
  2685. tooltipLinkedScope = ttScope.$new();
  2686. tooltip = tooltipLinker(tooltipLinkedScope, function(tooltip) {
  2687. if (appendToBody) {
  2688. $document.find('body').append(tooltip);
  2689. } else {
  2690. element.after(tooltip);
  2691. }
  2692. });
  2693. }
  2694. function removeTooltip() {
  2695. transitionTimeout = null;
  2696. if (tooltip) {
  2697. tooltip.remove();
  2698. tooltip = null;
  2699. }
  2700. if (tooltipLinkedScope) {
  2701. tooltipLinkedScope.$destroy();
  2702. tooltipLinkedScope = null;
  2703. }
  2704. }
  2705. function prepareTooltip() {
  2706. prepPlacement();
  2707. prepPopupDelay();
  2708. }
  2709. /**
  2710. * Observe the relevant attributes.
  2711. */
  2712. attrs.$observe(type, function(val) {
  2713. ttScope.content = val;
  2714. if (!val && ttScope.isOpen) {
  2715. hide();
  2716. }
  2717. });
  2718. attrs.$observe(prefix + 'Title', function(val) {
  2719. ttScope.title = val;
  2720. });
  2721. function prepPlacement() {
  2722. var val = attrs[prefix + 'Placement'];
  2723. ttScope.placement = angular.isDefined(val) ? val : options.placement;
  2724. }
  2725. function prepPopupDelay() {
  2726. var val = attrs[prefix + 'PopupDelay'];
  2727. var delay = parseInt(val, 10);
  2728. ttScope.popupDelay = !isNaN(delay) ? delay : options.popupDelay;
  2729. }
  2730. var unregisterTriggers = function() {
  2731. element.unbind(triggers.show, showTooltipBind);
  2732. element.unbind(triggers.hide, hideTooltipBind);
  2733. };
  2734. function prepTriggers() {
  2735. var val = attrs[prefix + 'Trigger'];
  2736. unregisterTriggers();
  2737. triggers = getTriggers(val);
  2738. if (triggers.show === triggers.hide) {
  2739. element.bind(triggers.show, toggleTooltipBind);
  2740. } else {
  2741. element.bind(triggers.show, showTooltipBind);
  2742. element.bind(triggers.hide, hideTooltipBind);
  2743. }
  2744. }
  2745. prepTriggers();
  2746. var animation = scope.$eval(attrs[prefix + 'Animation']);
  2747. ttScope.animation = angular.isDefined(animation) ? !!animation : options.animation;
  2748. var appendToBodyVal = scope.$eval(attrs[prefix + 'AppendToBody']);
  2749. appendToBody = angular.isDefined(appendToBodyVal) ? appendToBodyVal : appendToBody;
  2750. // if a tooltip is attached to <body> we need to remove it on
  2751. // location change as its parent scope will probably not be destroyed
  2752. // by the change.
  2753. if (appendToBody) {
  2754. scope.$on('$locationChangeSuccess', function closeTooltipOnLocationChangeSuccess() {
  2755. if (ttScope.isOpen) {
  2756. hide();
  2757. }
  2758. });
  2759. }
  2760. // Make sure tooltip is destroyed and removed.
  2761. scope.$on('$destroy', function onDestroyTooltip() {
  2762. $timeout.cancel(transitionTimeout);
  2763. $timeout.cancel(popupTimeout);
  2764. unregisterTriggers();
  2765. removeTooltip();
  2766. ttScope = null;
  2767. });
  2768. };
  2769. }
  2770. };
  2771. };
  2772. }];
  2773. })
  2774. .directive('tooltipPopup', function() {
  2775. return {
  2776. restrict: 'EA',
  2777. replace: true,
  2778. scope: { content: '@', placement: '@', animation: '&', isOpen: '&' },
  2779. templateUrl: 'template/tooltip/tooltip-popup.html'
  2780. };
  2781. })
  2782. .directive('tooltip', ['$tooltip', function($tooltip) {
  2783. return $tooltip('tooltip', 'tooltip', 'mouseenter');
  2784. }])
  2785. .directive('tooltipHtmlUnsafePopup', function() {
  2786. return {
  2787. restrict: 'EA',
  2788. replace: true,
  2789. scope: { content: '@', placement: '@', animation: '&', isOpen: '&' },
  2790. templateUrl: 'template/tooltip/tooltip-html-unsafe-popup.html'
  2791. };
  2792. })
  2793. .directive('tooltipHtmlUnsafe', ['$tooltip', function($tooltip) {
  2794. return $tooltip('tooltipHtmlUnsafe', 'tooltip', 'mouseenter');
  2795. }]);
  2796. /**
  2797. * The following features are still outstanding: popup delay, animation as a
  2798. * function, placement as a function, inside, support for more triggers than
  2799. * just mouse enter/leave, html popovers, and selector delegatation.
  2800. */
  2801. angular.module('ui.bootstrap.popover', ['ui.bootstrap.tooltip'])
  2802. .directive('popoverPopup', function() {
  2803. return {
  2804. restrict: 'EA',
  2805. replace: true,
  2806. scope: { title: '@', content: '@', placement: '@', animation: '&', isOpen: '&' },
  2807. templateUrl: 'template/popover/popover.html'
  2808. };
  2809. })
  2810. .directive('popover', ['$tooltip', function($tooltip) {
  2811. return $tooltip('popover', 'popover', 'click');
  2812. }]);
  2813. angular.module('ui.bootstrap.progressbar', [])
  2814. .constant('progressConfig', {
  2815. animate: true,
  2816. max: 100
  2817. })
  2818. .controller('ProgressController', ['$scope', '$attrs', 'progressConfig', function($scope, $attrs, progressConfig) {
  2819. var self = this,
  2820. animate = angular.isDefined($attrs.animate) ? $scope.$parent.$eval($attrs.animate) : progressConfig.animate;
  2821. this.bars = [];
  2822. $scope.max = angular.isDefined($attrs.max) ? $scope.$parent.$eval($attrs.max) : progressConfig.max;
  2823. this.addBar = function(bar, element) {
  2824. if (!animate) {
  2825. element.css({ 'transition': 'none' });
  2826. }
  2827. this.bars.push(bar);
  2828. bar.$watch('value', function(value) {
  2829. bar.percent = +(100 * value / $scope.max).toFixed(2);
  2830. });
  2831. bar.$on('$destroy', function() {
  2832. element = null;
  2833. self.removeBar(bar);
  2834. });
  2835. };
  2836. this.removeBar = function(bar) {
  2837. this.bars.splice(this.bars.indexOf(bar), 1);
  2838. };
  2839. }])
  2840. .directive('progress', function() {
  2841. return {
  2842. restrict: 'EA',
  2843. replace: true,
  2844. transclude: true,
  2845. controller: 'ProgressController',
  2846. require: 'progress',
  2847. scope: {},
  2848. templateUrl: 'template/progressbar/progress.html'
  2849. };
  2850. })
  2851. .directive('bar', function() {
  2852. return {
  2853. restrict: 'EA',
  2854. replace: true,
  2855. transclude: true,
  2856. require: '^progress',
  2857. scope: {
  2858. value: '=',
  2859. type: '@'
  2860. },
  2861. templateUrl: 'template/progressbar/bar.html',
  2862. link: function(scope, element, attrs, progressCtrl) {
  2863. progressCtrl.addBar(scope, element);
  2864. }
  2865. };
  2866. })
  2867. .directive('progressbar', function() {
  2868. return {
  2869. restrict: 'EA',
  2870. replace: true,
  2871. transclude: true,
  2872. controller: 'ProgressController',
  2873. scope: {
  2874. value: '=',
  2875. type: '@'
  2876. },
  2877. templateUrl: 'template/progressbar/progressbar.html',
  2878. link: function(scope, element, attrs, progressCtrl) {
  2879. progressCtrl.addBar(scope, angular.element(element.children()[0]));
  2880. }
  2881. };
  2882. });
  2883. angular.module('ui.bootstrap.rating', [])
  2884. .constant('ratingConfig', {
  2885. max: 5,
  2886. stateOn: null,
  2887. stateOff: null
  2888. })
  2889. .controller('RatingController', ['$scope', '$attrs', 'ratingConfig', function($scope, $attrs, ratingConfig) {
  2890. var ngModelCtrl = { $setViewValue: angular.noop };
  2891. this.init = function(ngModelCtrl_) {
  2892. ngModelCtrl = ngModelCtrl_;
  2893. ngModelCtrl.$render = this.render;
  2894. this.stateOn = angular.isDefined($attrs.stateOn) ? $scope.$parent.$eval($attrs.stateOn) : ratingConfig.stateOn;
  2895. this.stateOff = angular.isDefined($attrs.stateOff) ? $scope.$parent.$eval($attrs.stateOff) : ratingConfig.stateOff;
  2896. var ratingStates = angular.isDefined($attrs.ratingStates) ? $scope.$parent.$eval($attrs.ratingStates) :
  2897. new Array(angular.isDefined($attrs.max) ? $scope.$parent.$eval($attrs.max) : ratingConfig.max);
  2898. $scope.range = this.buildTemplateObjects(ratingStates);
  2899. };
  2900. this.buildTemplateObjects = function(states) {
  2901. for (var i = 0, n = states.length; i < n; i++) {
  2902. states[i] = angular.extend({ index: i }, { stateOn: this.stateOn, stateOff: this.stateOff }, states[i]);
  2903. }
  2904. return states;
  2905. };
  2906. $scope.rate = function(value) {
  2907. if (!$scope.readonly && value >= 0 && value <= $scope.range.length) {
  2908. ngModelCtrl.$setViewValue(value);
  2909. ngModelCtrl.$render();
  2910. }
  2911. };
  2912. $scope.enter = function(value) {
  2913. if (!$scope.readonly) {
  2914. $scope.value = value;
  2915. }
  2916. $scope.onHover({ value: value });
  2917. };
  2918. $scope.reset = function() {
  2919. $scope.value = ngModelCtrl.$viewValue;
  2920. $scope.onLeave();
  2921. };
  2922. $scope.onKeydown = function(evt) {
  2923. if (/(37|38|39|40)/.test(evt.which)) {
  2924. evt.preventDefault();
  2925. evt.stopPropagation();
  2926. $scope.rate($scope.value + (evt.which === 38 || evt.which === 39 ? 1 : -1));
  2927. }
  2928. };
  2929. this.render = function() {
  2930. $scope.value = ngModelCtrl.$viewValue;
  2931. };
  2932. }])
  2933. .directive('rating', function() {
  2934. return {
  2935. restrict: 'EA',
  2936. require: ['rating', 'ngModel'],
  2937. scope: {
  2938. readonly: '=?',
  2939. onHover: '&',
  2940. onLeave: '&'
  2941. },
  2942. controller: 'RatingController',
  2943. templateUrl: 'template/rating/rating.html',
  2944. replace: true,
  2945. link: function(scope, element, attrs, ctrls) {
  2946. var ratingCtrl = ctrls[0],
  2947. ngModelCtrl = ctrls[1];
  2948. if (ngModelCtrl) {
  2949. ratingCtrl.init(ngModelCtrl);
  2950. }
  2951. }
  2952. };
  2953. });
  2954. /**
  2955. * @ngdoc overview
  2956. * @name ui.bootstrap.tabs
  2957. *
  2958. * @description
  2959. * AngularJS version of the tabs directive.
  2960. */
  2961. angular.module('ui.bootstrap.tabs', [])
  2962. .controller('TabsetController', ['$scope', function TabsetCtrl($scope) {
  2963. var ctrl = this,
  2964. tabs = ctrl.tabs = $scope.tabs = [];
  2965. ctrl.select = function(selectedTab) {
  2966. angular.forEach(tabs, function(tab) {
  2967. if (tab.active && tab !== selectedTab) {
  2968. tab.active = false;
  2969. tab.onDeselect();
  2970. }
  2971. });
  2972. selectedTab.active = true;
  2973. selectedTab.onSelect();
  2974. };
  2975. ctrl.addTab = function addTab(tab) {
  2976. tabs.push(tab);
  2977. // we can't run the select function on the first tab
  2978. // since that would select it twice
  2979. if (tabs.length === 1) {
  2980. tab.active = true;
  2981. } else if (tab.active) {
  2982. ctrl.select(tab);
  2983. }
  2984. };
  2985. ctrl.removeTab = function removeTab(tab) {
  2986. var index = tabs.indexOf(tab);
  2987. //Select a new tab if the tab to be removed is selected and not destroyed
  2988. if (tab.active && tabs.length > 1 && !destroyed) {
  2989. //If this is the last tab, select the previous tab. else, the next tab.
  2990. var newActiveIndex = index == tabs.length - 1 ? index - 1 : index + 1;
  2991. ctrl.select(tabs[newActiveIndex]);
  2992. }
  2993. tabs.splice(index, 1);
  2994. };
  2995. var destroyed;
  2996. $scope.$on('$destroy', function() {
  2997. destroyed = true;
  2998. });
  2999. }])
  3000. /**
  3001. * @ngdoc directive
  3002. * @name ui.bootstrap.tabs.directive:tabset
  3003. * @restrict EA
  3004. *
  3005. * @description
  3006. * Tabset is the outer container for the tabs directive
  3007. *
  3008. * @param {boolean=} vertical Whether or not to use vertical styling for the tabs.
  3009. * @param {boolean=} justified Whether or not to use justified styling for the tabs.
  3010. *
  3011. * @example
  3012. <example module="ui.bootstrap">
  3013. <file name="index.html">
  3014. <tabset>
  3015. <tab heading="Tab 1"><b>First</b> Content!</tab>
  3016. <tab heading="Tab 2"><i>Second</i> Content!</tab>
  3017. </tabset>
  3018. <hr />
  3019. <tabset vertical="true">
  3020. <tab heading="Vertical Tab 1"><b>First</b> Vertical Content!</tab>
  3021. <tab heading="Vertical Tab 2"><i>Second</i> Vertical Content!</tab>
  3022. </tabset>
  3023. <tabset justified="true">
  3024. <tab heading="Justified Tab 1"><b>First</b> Justified Content!</tab>
  3025. <tab heading="Justified Tab 2"><i>Second</i> Justified Content!</tab>
  3026. </tabset>
  3027. </file>
  3028. </example>
  3029. */
  3030. .directive('tabset', function() {
  3031. return {
  3032. restrict: 'EA',
  3033. transclude: true,
  3034. replace: true,
  3035. scope: {
  3036. type: '@'
  3037. },
  3038. controller: 'TabsetController',
  3039. templateUrl: 'template/tabs/tabset.html',
  3040. link: function(scope, element, attrs) {
  3041. scope.vertical = angular.isDefined(attrs.vertical) ? scope.$parent.$eval(attrs.vertical) : false;
  3042. scope.justified = angular.isDefined(attrs.justified) ? scope.$parent.$eval(attrs.justified) : false;
  3043. }
  3044. };
  3045. })
  3046. /**
  3047. * @ngdoc directive
  3048. * @name ui.bootstrap.tabs.directive:tab
  3049. * @restrict EA
  3050. *
  3051. * @param {string=} heading The visible heading, or title, of the tab. Set HTML headings with {@link ui.bootstrap.tabs.directive:tabHeading tabHeading}.
  3052. * @param {string=} select An expression to evaluate when the tab is selected.
  3053. * @param {boolean=} active A binding, telling whether or not this tab is selected.
  3054. * @param {boolean=} disabled A binding, telling whether or not this tab is disabled.
  3055. *
  3056. * @description
  3057. * Creates a tab with a heading and content. Must be placed within a {@link ui.bootstrap.tabs.directive:tabset tabset}.
  3058. *
  3059. * @example
  3060. <example module="ui.bootstrap">
  3061. <file name="index.html">
  3062. <div ng-controller="TabsDemoCtrl">
  3063. <button class="btn btn-small" ng-click="items[0].active = true">
  3064. Select item 1, using active binding
  3065. </button>
  3066. <button class="btn btn-small" ng-click="items[1].disabled = !items[1].disabled">
  3067. Enable/disable item 2, using disabled binding
  3068. </button>
  3069. <br />
  3070. <tabset>
  3071. <tab heading="Tab 1">First Tab</tab>
  3072. <tab select="alertMe()">
  3073. <tab-heading><i class="icon-bell"></i> Alert me!</tab-heading>
  3074. Second Tab, with alert callback and html heading!
  3075. </tab>
  3076. <tab ng-repeat="item in items"
  3077. heading="{{item.title}}"
  3078. disabled="item.disabled"
  3079. active="item.active">
  3080. {{item.content}}
  3081. </tab>
  3082. </tabset>
  3083. </div>
  3084. </file>
  3085. <file name="script.js">
  3086. function TabsDemoCtrl($scope) {
  3087. $scope.items = [
  3088. { title:"Dynamic Title 1", content:"Dynamic Item 0" },
  3089. { title:"Dynamic Title 2", content:"Dynamic Item 1", disabled: true }
  3090. ];
  3091. $scope.alertMe = function() {
  3092. setTimeout(function() {
  3093. alert("You've selected the alert tab!");
  3094. });
  3095. };
  3096. };
  3097. </file>
  3098. </example>
  3099. */
  3100. /**
  3101. * @ngdoc directive
  3102. * @name ui.bootstrap.tabs.directive:tabHeading
  3103. * @restrict EA
  3104. *
  3105. * @description
  3106. * Creates an HTML heading for a {@link ui.bootstrap.tabs.directive:tab tab}. Must be placed as a child of a tab element.
  3107. *
  3108. * @example
  3109. <example module="ui.bootstrap">
  3110. <file name="index.html">
  3111. <tabset>
  3112. <tab>
  3113. <tab-heading><b>HTML</b> in my titles?!</tab-heading>
  3114. And some content, too!
  3115. </tab>
  3116. <tab>
  3117. <tab-heading><i class="icon-heart"></i> Icon heading?!?</tab-heading>
  3118. That's right.
  3119. </tab>
  3120. </tabset>
  3121. </file>
  3122. </example>
  3123. */
  3124. .directive('tab', ['$parse', function($parse) {
  3125. return {
  3126. require: '^tabset',
  3127. restrict: 'EA',
  3128. replace: true,
  3129. templateUrl: 'template/tabs/tab.html',
  3130. transclude: true,
  3131. scope: {
  3132. active: '=?',
  3133. heading: '@',
  3134. onSelect: '&select', //This callback is called in contentHeadingTransclude
  3135. //once it inserts the tab's content into the dom
  3136. onDeselect: '&deselect'
  3137. },
  3138. controller: function() {
  3139. //Empty controller so other directives can require being 'under' a tab
  3140. },
  3141. compile: function(elm, attrs, transclude) {
  3142. return function postLink(scope, elm, attrs, tabsetCtrl) {
  3143. scope.$watch('active', function(active) {
  3144. if (active) {
  3145. tabsetCtrl.select(scope);
  3146. }
  3147. });
  3148. scope.disabled = false;
  3149. if (attrs.disabled) {
  3150. scope.$parent.$watch($parse(attrs.disabled), function(value) {
  3151. scope.disabled = !!value;
  3152. });
  3153. }
  3154. scope.select = function() {
  3155. if (!scope.disabled) {
  3156. scope.active = true;
  3157. }
  3158. };
  3159. tabsetCtrl.addTab(scope);
  3160. scope.$on('$destroy', function() {
  3161. tabsetCtrl.removeTab(scope);
  3162. });
  3163. //We need to transclude later, once the content container is ready.
  3164. //when this link happens, we're inside a tab heading.
  3165. scope.$transcludeFn = transclude;
  3166. };
  3167. }
  3168. };
  3169. }])
  3170. .directive('tabHeadingTransclude', [function() {
  3171. return {
  3172. restrict: 'A',
  3173. require: '^tab',
  3174. link: function(scope, elm, attrs, tabCtrl) {
  3175. scope.$watch('headingElement', function updateHeadingElement(heading) {
  3176. if (heading) {
  3177. elm.html('');
  3178. elm.append(heading);
  3179. }
  3180. });
  3181. }
  3182. };
  3183. }])
  3184. .directive('tabContentTransclude', function() {
  3185. return {
  3186. restrict: 'A',
  3187. require: '^tabset',
  3188. link: function(scope, elm, attrs) {
  3189. var tab = scope.$eval(attrs.tabContentTransclude);
  3190. //Now our tab is ready to be transcluded: both the tab heading area
  3191. //and the tab content area are loaded. Transclude 'em both.
  3192. tab.$transcludeFn(tab.$parent, function(contents) {
  3193. angular.forEach(contents, function(node) {
  3194. if (isTabHeading(node)) {
  3195. //Let tabHeadingTransclude know.
  3196. tab.headingElement = node;
  3197. } else {
  3198. elm.append(node);
  3199. }
  3200. });
  3201. });
  3202. }
  3203. };
  3204. function isTabHeading(node) {
  3205. return node.tagName && (
  3206. node.hasAttribute('tab-heading') ||
  3207. node.hasAttribute('data-tab-heading') ||
  3208. node.tagName.toLowerCase() === 'tab-heading' ||
  3209. node.tagName.toLowerCase() === 'data-tab-heading'
  3210. );
  3211. }
  3212. })
  3213. ;
  3214. angular.module('ui.bootstrap.timepicker', [])
  3215. .constant('timepickerConfig', {
  3216. hourStep: 1,
  3217. minuteStep: 1,
  3218. showMeridian: true,
  3219. meridians: null,
  3220. readonlyInput: false,
  3221. mousewheel: true
  3222. })
  3223. .controller('TimepickerController', ['$scope', '$attrs', '$parse', '$log', '$locale', 'timepickerConfig', function($scope, $attrs, $parse, $log, $locale, timepickerConfig) {
  3224. var selected = new Date(),
  3225. ngModelCtrl = { $setViewValue: angular.noop }, // nullModelCtrl
  3226. meridians = angular.isDefined($attrs.meridians) ? $scope.$parent.$eval($attrs.meridians) : timepickerConfig.meridians || $locale.DATETIME_FORMATS.AMPMS;
  3227. this.init = function(ngModelCtrl_, inputs) {
  3228. ngModelCtrl = ngModelCtrl_;
  3229. ngModelCtrl.$render = this.render;
  3230. var hoursInputEl = inputs.eq(0),
  3231. minutesInputEl = inputs.eq(1);
  3232. var mousewheel = angular.isDefined($attrs.mousewheel) ? $scope.$parent.$eval($attrs.mousewheel) : timepickerConfig.mousewheel;
  3233. if (mousewheel) {
  3234. this.setupMousewheelEvents(hoursInputEl, minutesInputEl);
  3235. }
  3236. $scope.readonlyInput = angular.isDefined($attrs.readonlyInput) ? $scope.$parent.$eval($attrs.readonlyInput) : timepickerConfig.readonlyInput;
  3237. this.setupInputEvents(hoursInputEl, minutesInputEl);
  3238. };
  3239. var hourStep = timepickerConfig.hourStep;
  3240. if ($attrs.hourStep) {
  3241. $scope.$parent.$watch($parse($attrs.hourStep), function(value) {
  3242. hourStep = parseInt(value, 10);
  3243. });
  3244. }
  3245. var minuteStep = timepickerConfig.minuteStep;
  3246. if ($attrs.minuteStep) {
  3247. $scope.$parent.$watch($parse($attrs.minuteStep), function(value) {
  3248. minuteStep = parseInt(value, 10);
  3249. });
  3250. }
  3251. // 12H / 24H mode
  3252. $scope.showMeridian = timepickerConfig.showMeridian;
  3253. if ($attrs.showMeridian) {
  3254. $scope.$parent.$watch($parse($attrs.showMeridian), function(value) {
  3255. $scope.showMeridian = !!value;
  3256. if (ngModelCtrl.$error.time) {
  3257. // Evaluate from template
  3258. var hours = getHoursFromTemplate(),
  3259. minutes = getMinutesFromTemplate();
  3260. if (angular.isDefined(hours) && angular.isDefined(minutes)) {
  3261. selected.setHours(hours);
  3262. refresh();
  3263. }
  3264. } else {
  3265. updateTemplate();
  3266. }
  3267. });
  3268. }
  3269. // Get $scope.hours in 24H mode if valid
  3270. function getHoursFromTemplate() {
  3271. var hours = parseInt($scope.hours, 10);
  3272. var valid = ($scope.showMeridian) ? (hours > 0 && hours < 13) : (hours >= 0 && hours < 24);
  3273. if (!valid) {
  3274. return undefined;
  3275. }
  3276. if ($scope.showMeridian) {
  3277. if (hours === 12) {
  3278. hours = 0;
  3279. }
  3280. if ($scope.meridian === meridians[1]) {
  3281. hours = hours + 12;
  3282. }
  3283. }
  3284. return hours;
  3285. }
  3286. function getMinutesFromTemplate() {
  3287. var minutes = parseInt($scope.minutes, 10);
  3288. return (minutes >= 0 && minutes < 60) ? minutes : undefined;
  3289. }
  3290. function pad(value) {
  3291. return (angular.isDefined(value) && value.toString().length < 2) ? '0' + value : value;
  3292. }
  3293. // Respond on mousewheel spin
  3294. this.setupMousewheelEvents = function(hoursInputEl, minutesInputEl) {
  3295. var isScrollingUp = function(e) {
  3296. if (e.originalEvent) {
  3297. e = e.originalEvent;
  3298. }
  3299. //pick correct delta variable depending on event
  3300. var delta = (e.wheelDelta) ? e.wheelDelta : -e.deltaY;
  3301. return (e.detail || delta > 0);
  3302. };
  3303. hoursInputEl.bind('mousewheel wheel', function(e) {
  3304. $scope.$apply((isScrollingUp(e)) ? $scope.incrementHours() : $scope.decrementHours());
  3305. e.preventDefault();
  3306. });
  3307. minutesInputEl.bind('mousewheel wheel', function(e) {
  3308. $scope.$apply((isScrollingUp(e)) ? $scope.incrementMinutes() : $scope.decrementMinutes());
  3309. e.preventDefault();
  3310. });
  3311. };
  3312. this.setupInputEvents = function(hoursInputEl, minutesInputEl) {
  3313. if ($scope.readonlyInput) {
  3314. $scope.updateHours = angular.noop;
  3315. $scope.updateMinutes = angular.noop;
  3316. return;
  3317. }
  3318. var invalidate = function(invalidHours, invalidMinutes) {
  3319. ngModelCtrl.$setViewValue(null);
  3320. ngModelCtrl.$setValidity('time', false);
  3321. if (angular.isDefined(invalidHours)) {
  3322. $scope.invalidHours = invalidHours;
  3323. }
  3324. if (angular.isDefined(invalidMinutes)) {
  3325. $scope.invalidMinutes = invalidMinutes;
  3326. }
  3327. };
  3328. $scope.updateHours = function() {
  3329. var hours = getHoursFromTemplate();
  3330. if (angular.isDefined(hours)) {
  3331. selected.setHours(hours);
  3332. refresh('h');
  3333. } else {
  3334. invalidate(true);
  3335. }
  3336. };
  3337. hoursInputEl.bind('blur', function(e) {
  3338. if (!$scope.invalidHours && $scope.hours < 10) {
  3339. $scope.$apply(function() {
  3340. $scope.hours = pad($scope.hours);
  3341. });
  3342. }
  3343. });
  3344. $scope.updateMinutes = function() {
  3345. var minutes = getMinutesFromTemplate();
  3346. if (angular.isDefined(minutes)) {
  3347. selected.setMinutes(minutes);
  3348. refresh('m');
  3349. } else {
  3350. invalidate(undefined, true);
  3351. }
  3352. };
  3353. minutesInputEl.bind('blur', function(e) {
  3354. if (!$scope.invalidMinutes && $scope.minutes < 10) {
  3355. $scope.$apply(function() {
  3356. $scope.minutes = pad($scope.minutes);
  3357. });
  3358. }
  3359. });
  3360. };
  3361. this.render = function() {
  3362. var date = ngModelCtrl.$modelValue ? new Date(ngModelCtrl.$modelValue) : null;
  3363. if (isNaN(date)) {
  3364. ngModelCtrl.$setValidity('time', false);
  3365. $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.');
  3366. } else {
  3367. if (date) {
  3368. selected = date;
  3369. }
  3370. makeValid();
  3371. updateTemplate();
  3372. }
  3373. };
  3374. // Call internally when we know that model is valid.
  3375. function refresh(keyboardChange) {
  3376. makeValid();
  3377. ngModelCtrl.$setViewValue(new Date(selected));
  3378. updateTemplate(keyboardChange);
  3379. }
  3380. function makeValid() {
  3381. ngModelCtrl.$setValidity('time', true);
  3382. $scope.invalidHours = false;
  3383. $scope.invalidMinutes = false;
  3384. }
  3385. function updateTemplate(keyboardChange) {
  3386. var hours = selected.getHours(),
  3387. minutes = selected.getMinutes();
  3388. if ($scope.showMeridian) {
  3389. hours = (hours === 0 || hours === 12) ? 12 : hours % 12; // Convert 24 to 12 hour system
  3390. }
  3391. $scope.hours = keyboardChange === 'h' ? hours : pad(hours);
  3392. $scope.minutes = keyboardChange === 'm' ? minutes : pad(minutes);
  3393. $scope.meridian = selected.getHours() < 12 ? meridians[0] : meridians[1];
  3394. }
  3395. function addMinutes(minutes) {
  3396. var dt = new Date(selected.getTime() + minutes * 60000);
  3397. selected.setHours(dt.getHours(), dt.getMinutes());
  3398. refresh();
  3399. }
  3400. $scope.incrementHours = function() {
  3401. addMinutes(1 * 60);
  3402. };
  3403. $scope.decrementHours = function() {
  3404. addMinutes(-1 * 60);
  3405. };
  3406. $scope.incrementMinutes = function() {
  3407. addMinutes(1);
  3408. };
  3409. $scope.decrementMinutes = function() {
  3410. addMinutes(-1);
  3411. };
  3412. $scope.toggleMeridian = function() {
  3413. addMinutes(12 * 60 * ((selected.getHours() < 12) ? 1 : -1));
  3414. };
  3415. }])
  3416. .directive('timepicker', function() {
  3417. return {
  3418. restrict: 'EA',
  3419. require: ['timepicker', '?^ngModel'],
  3420. controller: 'TimepickerController',
  3421. replace: true,
  3422. scope: {},
  3423. templateUrl: 'template/timepicker/timepicker.html',
  3424. link: function(scope, element, attrs, ctrls) {
  3425. var timepickerCtrl = ctrls[0],
  3426. ngModelCtrl = ctrls[1];
  3427. if (ngModelCtrl) {
  3428. timepickerCtrl.init(ngModelCtrl, element.find('input'));
  3429. }
  3430. }
  3431. };
  3432. });
  3433. angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.position', 'ui.bootstrap.bindHtml'])
  3434. /**
  3435. * A helper service that can parse typeahead's syntax (string provided by users)
  3436. * Extracted to a separate service for ease of unit testing
  3437. */
  3438. .factory('typeaheadParser', ['$parse', function($parse) {
  3439. // 00000111000000000000022200000000000000003333333333333330000000000044000
  3440. var TYPEAHEAD_REGEXP = /^\s*([\s\S]+?)(?:\s+as\s+([\s\S]+?))?\s+for\s+(?:([\$\w][\$\w\d]*))\s+in\s+([\s\S]+?)$/;
  3441. return {
  3442. parse: function(input) {
  3443. var match = input.match(TYPEAHEAD_REGEXP);
  3444. if (!match) {
  3445. throw new Error(
  3446. 'Expected typeahead specification in form of "_modelValue_ (as _label_)? for _item_ in _collection_"' +
  3447. ' but got "' + input + '".');
  3448. }
  3449. return {
  3450. itemName: match[3],
  3451. source: $parse(match[4]),
  3452. viewMapper: $parse(match[2] || match[1]),
  3453. modelMapper: $parse(match[1])
  3454. };
  3455. }
  3456. };
  3457. }])
  3458. .directive('typeahead', ['$compile', '$parse', '$q', '$timeout', '$document', '$position', 'typeaheadParser',
  3459. function($compile, $parse, $q, $timeout, $document, $position, typeaheadParser) {
  3460. var HOT_KEYS = [9, 13, 27, 38, 40];
  3461. return {
  3462. require: 'ngModel',
  3463. link: function(originalScope, element, attrs, modelCtrl) {
  3464. //SUPPORTED ATTRIBUTES (OPTIONS)
  3465. //minimal no of characters that needs to be entered before typeahead kicks-in
  3466. var minSearch = originalScope.$eval(attrs.typeaheadMinLength) || 1;
  3467. //minimal wait time after last character typed before typehead kicks-in
  3468. var waitTime = originalScope.$eval(attrs.typeaheadWaitMs) || 0;
  3469. //should it restrict model values to the ones selected from the popup only?
  3470. var isEditable = originalScope.$eval(attrs.typeaheadEditable) !== false;
  3471. //binding to a variable that indicates if matches are being retrieved asynchronously
  3472. var isLoadingSetter = $parse(attrs.typeaheadLoading).assign || angular.noop;
  3473. //a callback executed when a match is selected
  3474. var onSelectCallback = $parse(attrs.typeaheadOnSelect);
  3475. var inputFormatter = attrs.typeaheadInputFormatter ? $parse(attrs.typeaheadInputFormatter) : undefined;
  3476. var appendToBody = attrs.typeaheadAppendToBody ? originalScope.$eval(attrs.typeaheadAppendToBody) : false;
  3477. var focusFirst = originalScope.$eval(attrs.typeaheadFocusFirst) !== false;
  3478. //INTERNAL VARIABLES
  3479. //model setter executed upon match selection
  3480. var $setModelValue = $parse(attrs.ngModel).assign;
  3481. //expressions used by typeahead
  3482. var parserResult = typeaheadParser.parse(attrs.typeahead);
  3483. var hasFocus;
  3484. //create a child scope for the typeahead directive so we are not polluting original scope
  3485. //with typeahead-specific data (matches, query etc.)
  3486. var scope = originalScope.$new();
  3487. originalScope.$on('$destroy', function() {
  3488. scope.$destroy();
  3489. });
  3490. // WAI-ARIA
  3491. var popupId = 'typeahead-' + scope.$id + '-' + Math.floor(Math.random() * 10000);
  3492. element.attr({
  3493. 'aria-autocomplete': 'list',
  3494. 'aria-expanded': false,
  3495. 'aria-owns': popupId
  3496. });
  3497. //pop-up element used to display matches
  3498. var popUpEl = angular.element('<div typeahead-popup></div>');
  3499. popUpEl.attr({
  3500. id: popupId,
  3501. matches: 'matches',
  3502. active: 'activeIdx',
  3503. select: 'select(activeIdx)',
  3504. query: 'query',
  3505. position: 'position'
  3506. });
  3507. //custom item template
  3508. if (angular.isDefined(attrs.typeaheadTemplateUrl)) {
  3509. popUpEl.attr('template-url', attrs.typeaheadTemplateUrl);
  3510. }
  3511. var resetMatches = function() {
  3512. scope.matches = [];
  3513. scope.activeIdx = -1;
  3514. element.attr('aria-expanded', false);
  3515. };
  3516. var getMatchId = function(index) {
  3517. return popupId + '-option-' + index;
  3518. };
  3519. // Indicate that the specified match is the active (pre-selected) item in the list owned by this typeahead.
  3520. // This attribute is added or removed automatically when the `activeIdx` changes.
  3521. scope.$watch('activeIdx', function(index) {
  3522. if (index < 0) {
  3523. element.removeAttr('aria-activedescendant');
  3524. } else {
  3525. element.attr('aria-activedescendant', getMatchId(index));
  3526. }
  3527. });
  3528. var getMatchesAsync = function(inputValue) {
  3529. var locals = { $viewValue: inputValue };
  3530. isLoadingSetter(originalScope, true);
  3531. $q.when(parserResult.source(originalScope, locals)).then(function(matches) {
  3532. //it might happen that several async queries were in progress if a user were typing fast
  3533. //but we are interested only in responses that correspond to the current view value
  3534. var onCurrentRequest = (inputValue === modelCtrl.$viewValue);
  3535. if (onCurrentRequest && hasFocus) {
  3536. if (matches.length > 0) {
  3537. scope.activeIdx = focusFirst ? 0 : -1;
  3538. scope.matches.length = 0;
  3539. //transform labels
  3540. for (var i = 0; i < matches.length; i++) {
  3541. locals[parserResult.itemName] = matches[i];
  3542. scope.matches.push({
  3543. id: getMatchId(i),
  3544. label: parserResult.viewMapper(scope, locals),
  3545. model: matches[i]
  3546. });
  3547. }
  3548. scope.query = inputValue;
  3549. //position pop-up with matches - we need to re-calculate its position each time we are opening a window
  3550. //with matches as a pop-up might be absolute-positioned and position of an input might have changed on a page
  3551. //due to other elements being rendered
  3552. scope.position = appendToBody ? $position.offset(element) : $position.position(element);
  3553. scope.position.top = scope.position.top + element.prop('offsetHeight');
  3554. element.attr('aria-expanded', true);
  3555. } else {
  3556. resetMatches();
  3557. }
  3558. }
  3559. if (onCurrentRequest) {
  3560. isLoadingSetter(originalScope, false);
  3561. }
  3562. }, function() {
  3563. resetMatches();
  3564. isLoadingSetter(originalScope, false);
  3565. });
  3566. };
  3567. resetMatches();
  3568. //we need to propagate user's query so we can higlight matches
  3569. scope.query = undefined;
  3570. //Declare the timeout promise var outside the function scope so that stacked calls can be cancelled later
  3571. var timeoutPromise;
  3572. var scheduleSearchWithTimeout = function(inputValue) {
  3573. timeoutPromise = $timeout(function() {
  3574. getMatchesAsync(inputValue);
  3575. }, waitTime);
  3576. };
  3577. var cancelPreviousTimeout = function() {
  3578. if (timeoutPromise) {
  3579. $timeout.cancel(timeoutPromise);
  3580. }
  3581. };
  3582. //plug into $parsers pipeline to open a typeahead on view changes initiated from DOM
  3583. //$parsers kick-in on all the changes coming from the view as well as manually triggered by $setViewValue
  3584. modelCtrl.$parsers.unshift(function(inputValue) {
  3585. hasFocus = true;
  3586. if (inputValue && inputValue.length >= minSearch) {
  3587. if (waitTime > 0) {
  3588. cancelPreviousTimeout();
  3589. scheduleSearchWithTimeout(inputValue);
  3590. } else {
  3591. getMatchesAsync(inputValue);
  3592. }
  3593. } else {
  3594. isLoadingSetter(originalScope, false);
  3595. cancelPreviousTimeout();
  3596. resetMatches();
  3597. }
  3598. if (isEditable) {
  3599. return inputValue;
  3600. } else {
  3601. if (!inputValue) {
  3602. // Reset in case user had typed something previously.
  3603. modelCtrl.$setValidity('editable', true);
  3604. return inputValue;
  3605. } else {
  3606. modelCtrl.$setValidity('editable', false);
  3607. return undefined;
  3608. }
  3609. }
  3610. });
  3611. modelCtrl.$formatters.push(function(modelValue) {
  3612. var candidateViewValue, emptyViewValue;
  3613. var locals = {};
  3614. if (inputFormatter) {
  3615. locals.$model = modelValue;
  3616. return inputFormatter(originalScope, locals);
  3617. } else {
  3618. //it might happen that we don't have enough info to properly render input value
  3619. //we need to check for this situation and simply return model value if we can't apply custom formatting
  3620. locals[parserResult.itemName] = modelValue;
  3621. candidateViewValue = parserResult.viewMapper(originalScope, locals);
  3622. locals[parserResult.itemName] = undefined;
  3623. emptyViewValue = parserResult.viewMapper(originalScope, locals);
  3624. return candidateViewValue !== emptyViewValue ? candidateViewValue : modelValue;
  3625. }
  3626. });
  3627. scope.select = function(activeIdx) {
  3628. //called from within the $digest() cycle
  3629. var locals = {};
  3630. var model, item;
  3631. locals[parserResult.itemName] = item = scope.matches[activeIdx].model;
  3632. model = parserResult.modelMapper(originalScope, locals);
  3633. $setModelValue(originalScope, model);
  3634. modelCtrl.$setValidity('editable', true);
  3635. onSelectCallback(originalScope, {
  3636. $item: item,
  3637. $model: model,
  3638. $label: parserResult.viewMapper(originalScope, locals)
  3639. });
  3640. resetMatches();
  3641. //return focus to the input element if a match was selected via a mouse click event
  3642. // use timeout to avoid $rootScope:inprog error
  3643. $timeout(function() { element[0].focus(); }, 0, false);
  3644. };
  3645. //bind keyboard events: arrows up(38) / down(40), enter(13) and tab(9), esc(27)
  3646. element.bind('keydown', function(evt) {
  3647. //typeahead is open and an "interesting" key was pressed
  3648. if (scope.matches.length === 0 || HOT_KEYS.indexOf(evt.which) === -1) {
  3649. return;
  3650. }
  3651. // if there's nothing selected (i.e. focusFirst) and enter is hit, don't do anything
  3652. if (scope.activeIdx == -1 && (evt.which === 13 || evt.which === 9)) {
  3653. return;
  3654. }
  3655. evt.preventDefault();
  3656. if (evt.which === 40) {
  3657. scope.activeIdx = (scope.activeIdx + 1) % scope.matches.length;
  3658. scope.$digest();
  3659. } else if (evt.which === 38) {
  3660. scope.activeIdx = (scope.activeIdx > 0 ? scope.activeIdx : scope.matches.length) - 1;
  3661. scope.$digest();
  3662. } else if (evt.which === 13 || evt.which === 9) {
  3663. scope.$apply(function() {
  3664. scope.select(scope.activeIdx);
  3665. });
  3666. } else if (evt.which === 27) {
  3667. evt.stopPropagation();
  3668. resetMatches();
  3669. scope.$digest();
  3670. }
  3671. });
  3672. element.bind('blur', function(evt) {
  3673. hasFocus = false;
  3674. });
  3675. // Keep reference to click handler to unbind it.
  3676. var dismissClickHandler = function(evt) {
  3677. if (element[0] !== evt.target) {
  3678. resetMatches();
  3679. scope.$digest();
  3680. }
  3681. };
  3682. $document.bind('click', dismissClickHandler);
  3683. originalScope.$on('$destroy', function() {
  3684. $document.unbind('click', dismissClickHandler);
  3685. if (appendToBody) {
  3686. $popup.remove();
  3687. }
  3688. });
  3689. var $popup = $compile(popUpEl)(scope);
  3690. if (appendToBody) {
  3691. $document.find('body').append($popup);
  3692. } else {
  3693. element.after($popup);
  3694. }
  3695. }
  3696. };
  3697. }
  3698. ])
  3699. .directive('typeaheadPopup', function() {
  3700. return {
  3701. restrict: 'EA',
  3702. scope: {
  3703. matches: '=',
  3704. query: '=',
  3705. active: '=',
  3706. position: '=',
  3707. select: '&'
  3708. },
  3709. replace: true,
  3710. templateUrl: 'template/typeahead/typeahead-popup.html',
  3711. link: function(scope, element, attrs) {
  3712. scope.templateUrl = attrs.templateUrl;
  3713. scope.isOpen = function() {
  3714. return scope.matches.length > 0;
  3715. };
  3716. scope.isActive = function(matchIdx) {
  3717. return scope.active == matchIdx;
  3718. };
  3719. scope.selectActive = function(matchIdx) {
  3720. scope.active = matchIdx;
  3721. };
  3722. scope.selectMatch = function(activeIdx) {
  3723. scope.select({ activeIdx: activeIdx });
  3724. };
  3725. }
  3726. };
  3727. })
  3728. .directive('typeaheadMatch', ['$http', '$templateCache', '$compile', '$parse', function($http, $templateCache, $compile, $parse) {
  3729. return {
  3730. restrict: 'EA',
  3731. scope: {
  3732. index: '=',
  3733. match: '=',
  3734. query: '='
  3735. },
  3736. link: function(scope, element, attrs) {
  3737. var tplUrl = $parse(attrs.templateUrl)(scope.$parent) || 'template/typeahead/typeahead-match.html';
  3738. $http.get(tplUrl, { cache: $templateCache }).success(function(tplContent) {
  3739. element.replaceWith($compile(tplContent.trim())(scope));
  3740. });
  3741. }
  3742. };
  3743. }])
  3744. .filter('typeaheadHighlight', function() {
  3745. function escapeRegexp(queryToEscape) {
  3746. return queryToEscape.replace(/([.?*+^$[\]\\(){}|-])/g, '\\$1');
  3747. }
  3748. return function(matchItem, query) {
  3749. return query ? ('' + matchItem).replace(new RegExp(escapeRegexp(query), 'gi'), '<strong>$&</strong>') : matchItem;
  3750. };
  3751. });
  3752. angular.module("template/accordion/accordion-group.html", []).run(["$templateCache", function($templateCache) {
  3753. $templateCache.put("template/accordion/accordion-group.html",
  3754. "<div class=\"panel panel-default\">\n" +
  3755. " <div class=\"panel-heading\">\n" +
  3756. " <h4 class=\"panel-title\">\n" +
  3757. " <a href class=\"accordion-toggle\" ng-click=\"toggleOpen()\" accordion-transclude=\"heading\"><span ng-class=\"{'text-muted': isDisabled}\">{{heading}}</span></a>\n" +
  3758. " </h4>\n" +
  3759. " </div>\n" +
  3760. " <div class=\"panel-collapse\" collapse=\"!isOpen\">\n" +
  3761. " <div class=\"panel-body\" ng-transclude></div>\n" +
  3762. " </div>\n" +
  3763. "</div>\n" +
  3764. "");
  3765. }]);
  3766. angular.module("template/accordion/accordion.html", []).run(["$templateCache", function($templateCache) {
  3767. $templateCache.put("template/accordion/accordion.html",
  3768. "<div class=\"panel-group\" ng-transclude></div>");
  3769. }]);
  3770. angular.module("template/alert/alert.html", []).run(["$templateCache", function($templateCache) {
  3771. $templateCache.put("template/alert/alert.html",
  3772. "<div class=\"alert\" ng-class=\"['alert-' + (type || 'warning'), closeable ? 'alert-dismissable' : null]\" role=\"alert\">\n" +
  3773. " <button ng-show=\"closeable\" type=\"button\" class=\"close\" ng-click=\"close()\">\n" +
  3774. " <span aria-hidden=\"true\">&times;</span>\n" +
  3775. " <span class=\"sr-only\">Close</span>\n" +
  3776. " </button>\n" +
  3777. " <div ng-transclude></div>\n" +
  3778. "</div>\n" +
  3779. "");
  3780. }]);
  3781. angular.module("template/carousel/carousel.html", []).run(["$templateCache", function($templateCache) {
  3782. $templateCache.put("template/carousel/carousel.html",
  3783. "<div ng-mouseenter=\"pause()\" ng-mouseleave=\"play()\" class=\"carousel\" ng-swipe-right=\"prev()\" ng-swipe-left=\"next()\">\n" +
  3784. " <ol class=\"carousel-indicators\" ng-show=\"slides.length > 1\">\n" +
  3785. " <li ng-repeat=\"slide in slides track by $index\" ng-class=\"{active: isActive(slide)}\" ng-click=\"select(slide)\"></li>\n" +
  3786. " </ol>\n" +
  3787. " <div class=\"carousel-inner\" ng-transclude></div>\n" +
  3788. " <a class=\"left carousel-control\" ng-click=\"prev()\" ng-show=\"slides.length > 1\"><span class=\"glyphicon glyphicon-chevron-left\"></span></a>\n" +
  3789. " <a class=\"right carousel-control\" ng-click=\"next()\" ng-show=\"slides.length > 1\"><span class=\"glyphicon glyphicon-chevron-right\"></span></a>\n" +
  3790. "</div>\n" +
  3791. "");
  3792. }]);
  3793. angular.module("template/carousel/slide.html", []).run(["$templateCache", function($templateCache) {
  3794. $templateCache.put("template/carousel/slide.html",
  3795. "<div ng-class=\"{\n" +
  3796. " 'active': leaving || (active && !entering),\n" +
  3797. " 'prev': (next || active) && direction=='prev',\n" +
  3798. " 'next': (next || active) && direction=='next',\n" +
  3799. " 'right': direction=='prev',\n" +
  3800. " 'left': direction=='next'\n" +
  3801. " }\" class=\"item text-center\" ng-transclude></div>\n" +
  3802. "");
  3803. }]);
  3804. angular.module("template/datepicker/datepicker.html", []).run(["$templateCache", function($templateCache) {
  3805. $templateCache.put("template/datepicker/datepicker.html",
  3806. "<div ng-switch=\"datepickerMode\" role=\"application\" ng-keydown=\"keydown($event)\">\n" +
  3807. " <daypicker ng-switch-when=\"day\" tabindex=\"0\"></daypicker>\n" +
  3808. " <weekpicker ng-switch-when=\"week\" tabindex=\"0\"></weekpicker>\n" +
  3809. " <monthpicker ng-switch-when=\"month\" tabindex=\"0\"></monthpicker>\n" +
  3810. " <yearpicker ng-switch-when=\"year\" tabindex=\"0\"></yearpicker>\n" +
  3811. "</div>");
  3812. }]);
  3813. angular.module("template/datepicker/day.html", []).run(["$templateCache", function($templateCache) {
  3814. $templateCache.put("template/datepicker/day.html",
  3815. "<table role=\"grid\" aria-labelledby=\"{{uniqueId}}-title\" aria-activedescendant=\"{{activeDateId}}\">\n" +
  3816. " <thead>\n" +
  3817. " <tr>\n" +
  3818. " <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" +
  3819. " <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" +
  3820. " <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" +
  3821. " </tr>\n" +
  3822. " <tr>\n" +
  3823. " <th ng-show=\"showWeeks\" class=\"text-center\"></th>\n" +
  3824. " <th ng-repeat=\"label in labels track by $index\" class=\"text-center\"><small aria-label=\"{{label.full}}\">{{label.abbr}}</small></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-show=\"showWeeks\" class=\"text-center h6\"><em>{{ weekNumbers[$index] }}</em></td>\n" +
  3830. " <td ng-repeat=\"dt in row track by dt.date\" class=\"text-center\" role=\"gridcell\" id=\"{{dt.uid}}\" aria-disabled=\"{{!!dt.disabled}}\">\n" +
  3831. " <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" +
  3832. " </td>\n" +
  3833. " </tr>\n" +
  3834. " </tbody>\n" +
  3835. "</table>\n" +
  3836. "");
  3837. }]);
  3838. angular.module("template/datepicker/month.html", []).run(["$templateCache", function($templateCache) {
  3839. $templateCache.put("template/datepicker/month.html",
  3840. "<table role=\"grid\" aria-labelledby=\"{{uniqueId}}-title\" aria-activedescendant=\"{{activeDateId}}\">\n" +
  3841. " <thead>\n" +
  3842. " <tr>\n" +
  3843. " <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" +
  3844. " <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" +
  3845. " <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" +
  3846. " </tr>\n" +
  3847. " </thead>\n" +
  3848. " <tbody>\n" +
  3849. " <tr ng-repeat=\"row in rows track by $index\">\n" +
  3850. " <td ng-repeat=\"dt in row track by dt.date\" class=\"text-center\" role=\"gridcell\" id=\"{{dt.uid}}\" aria-disabled=\"{{!!dt.disabled}}\">\n" +
  3851. " <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" +
  3852. " </td>\n" +
  3853. " </tr>\n" +
  3854. " </tbody>\n" +
  3855. "</table>\n" +
  3856. "");
  3857. }]);
  3858. angular.module("template/datepicker/week.html", []).run(["$templateCache", function($templateCache) {
  3859. $templateCache.put("template/datepicker/week.html",
  3860. "<table role=\"grid\" aria-labelledby=\"{{uniqueId}}-title\" aria-activedescendant=\"{{activeDateId}}\">\n" +
  3861. " <thead>\n" +
  3862. " <tr>\n" +
  3863. " <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" +
  3864. " <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" +
  3865. " <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" +
  3866. " </tr>\n" +
  3867. " </thead>\n" +
  3868. " <tbody>\n" +
  3869. " <tr ng-repeat=\"row in rows track by $index\">\n" +
  3870. " <td ng-repeat=\"dt in row track by dt.date\" class=\"text-center\" role=\"gridcell\" id=\"{{dt.uid}}\" aria-disabled=\"{{!!dt.disabled}}\">\n" +
  3871. " <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" +
  3872. " </td>\n" +
  3873. " </tr>\n" +
  3874. " </tbody>\n" +
  3875. "</table>\n" +
  3876. "");
  3877. }]);
  3878. angular.module("template/datepicker/popup.html", []).run(["$templateCache", function($templateCache) {
  3879. $templateCache.put("template/datepicker/popup.html",
  3880. "<ul class=\"dropdown-menu\" ng-style=\"{display: (isOpen && 'block') || 'none', top: position.top+'px', left: position.left+'px'}\" ng-keydown=\"keydown($event)\">\n" +
  3881. " <li ng-transclude></li>\n" +
  3882. " <li ng-if=\"showButtonBar\">\n" +
  3883. // "<div class=\"pull-left\" style=\"padding:40px 40px \">时分选择"+
  3884. // "</div>"+
  3885. "<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>" +
  3886. " <span class=\"btn-group pull-right padintop\">\n" +
  3887. // " <button type=\"button\" class=\"btn btn-sm btn-primary\" ng-click=\"save()\">{{ getText('save') }}</button>\n" +
  3888. " <button type=\"button\" class=\"btn btn-sm btn-info\" ng-click=\"select('today')\">{{ getText('current') }}</button>\n" +
  3889. " <button type=\"button\" class=\"btn btn-sm btn-success \" ng-click=\"close()\">{{ getText('close') }}</button>\n" +
  3890. " </span>\n" +
  3891. " </li>\n" +
  3892. "</ul>\n" +
  3893. "");
  3894. }]);
  3895. angular.module("template/datepicker/popuptime.html", []).run(["$templateCache", function($templateCache) {
  3896. $templateCache.put("template/datepicker/popuptime.html",
  3897. "<ul class=\"dropdown-time\" ng-style=\"{display: (isOpen && 'block') || 'none', top: position.top+'px', left: position.left+'px'}\" ng-keydown=\"keydown($event)\">\n" +
  3898. " <li ng-transclude></li>\n" +
  3899. " <li ng-if=\"showButtonBar\" style=\"padding:10px 9px 2px\">\n" +
  3900. " <span class=\"btn-group pull-left\">\n" +
  3901. " <button type=\"button\" class=\"btn btn-sm btn-info\" ng-click=\"select('today')\">{{ getText('current') }}</button>\n" +
  3902. " <button type=\"button\" class=\"btn btn-sm btn-danger\" ng-click=\"select(null)\">{{ getText('clear') }}</button>\n" +
  3903. " </span>\n" +
  3904. " <button type=\"button\" class=\"btn btn-sm btn-success pull-right\" ng-click=\"close()\">{{ getText('close') }}</button>\n" +
  3905. " </li>\n" +
  3906. "</ul>\n" +
  3907. "");
  3908. }]);
  3909. angular.module("template/datepicker/year.html", []).run(["$templateCache", function($templateCache) {
  3910. $templateCache.put("template/datepicker/year.html",
  3911. "<table role=\"grid\" aria-labelledby=\"{{uniqueId}}-title\" aria-activedescendant=\"{{activeDateId}}\">\n" +
  3912. " <thead>\n" +
  3913. " <tr>\n" +
  3914. " <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" +
  3915. " <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" +
  3916. " <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" +
  3917. " </tr>\n" +
  3918. " </thead>\n" +
  3919. " <tbody>\n" +
  3920. " <tr ng-repeat=\"row in rows track by $index\">\n" +
  3921. " <td ng-repeat=\"dt in row track by dt.date\" class=\"text-center\" role=\"gridcell\" id=\"{{dt.uid}}\" aria-disabled=\"{{!!dt.disabled}}\">\n" +
  3922. " <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" +
  3923. " </td>\n" +
  3924. " </tr>\n" +
  3925. " </tbody>\n" +
  3926. "</table>\n" +
  3927. "");
  3928. }]);
  3929. angular.module("template/modal/backdrop.html", []).run(["$templateCache", function($templateCache) {
  3930. $templateCache.put("template/modal/backdrop.html",
  3931. "<div class=\"modal-backdrop fade {{ backdropClass }}\"\n" +
  3932. " ng-class=\"{in: animate}\"\n" +
  3933. " ng-style=\"{'z-index': 1040 + (index && 1 || 0) + index*10}\"\n" +
  3934. "></div>\n" +
  3935. "");
  3936. }]);
  3937. angular.module("template/modal/window.html", []).run(["$templateCache", function($templateCache) {
  3938. $templateCache.put("template/modal/window.html",
  3939. "<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" +
  3940. " <div class=\"modal-dialog\" ng-class=\"{'modal-sm': size == 'sm', 'modal-lg': size == 'lg'}\"><div class=\"modal-content\" modal-transclude></div></div>\n" +
  3941. "</div>");
  3942. }]);
  3943. angular.module("template/pagination/pager.html", []).run(["$templateCache", function($templateCache) {
  3944. $templateCache.put("template/pagination/pager.html",
  3945. "<ul class=\"pager\">\n" +
  3946. " <li ng-class=\"{disabled: noPrevious(), previous: align}\"><a href ng-click=\"selectPage(page - 1)\">{{getText('previous')}}</a></li>\n" +
  3947. " <li ng-class=\"{disabled: noNext(), next: align}\"><a href ng-click=\"selectPage(page + 1)\">{{getText('next')}}</a></li>\n" +
  3948. "</ul>");
  3949. }]);
  3950. angular.module("template/pagination/pagination.html", []).run(["$templateCache", function($templateCache) {
  3951. $templateCache.put("template/pagination/pagination.html",
  3952. "<ul class=\"pagination\">\n" +
  3953. " <li ng-if=\"boundaryLinks\" ng-class=\"{disabled: noPrevious()}\"><a href ng-click=\"selectPage(1)\">{{getText('first')}}</a></li>\n" +
  3954. " <li ng-if=\"directionLinks\" ng-class=\"{disabled: noPrevious()}\"><a href ng-click=\"selectPage(page - 1)\">{{getText('previous')}}</a></li>\n" +
  3955. " <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" +
  3956. " <li ng-if=\"directionLinks\" ng-class=\"{disabled: noNext()}\"><a href ng-click=\"selectPage(page + 1)\">{{getText('next')}}</a></li>\n" +
  3957. " <li ng-if=\"boundaryLinks\" ng-class=\"{disabled: noNext()}\"><a href ng-click=\"selectPage(totalPages)\">{{getText('last')}}</a></li>\n" +
  3958. "</ul>");
  3959. }]);
  3960. angular.module("template/tooltip/tooltip-html-unsafe-popup.html", []).run(["$templateCache", function($templateCache) {
  3961. $templateCache.put("template/tooltip/tooltip-html-unsafe-popup.html",
  3962. "<div class=\"tooltip {{placement}}\" ng-class=\"{ in: isOpen(), fade: animation() }\">\n" +
  3963. " <div class=\"tooltip-arrow\"></div>\n" +
  3964. " <div class=\"tooltip-inner\" bind-html-unsafe=\"content\"></div>\n" +
  3965. "</div>\n" +
  3966. "");
  3967. }]);
  3968. angular.module("template/tooltip/tooltip-popup.html", []).run(["$templateCache", function($templateCache) {
  3969. $templateCache.put("template/tooltip/tooltip-popup.html",
  3970. "<div class=\"tooltip {{placement}}\" ng-class=\"{ in: isOpen(), fade: animation() }\">\n" +
  3971. " <div class=\"tooltip-arrow\"></div>\n" +
  3972. " <div class=\"tooltip-inner\" ng-bind=\"content\"></div>\n" +
  3973. "</div>\n" +
  3974. "");
  3975. }]);
  3976. angular.module("template/popover/popover.html", []).run(["$templateCache", function($templateCache) {
  3977. $templateCache.put("template/popover/popover.html",
  3978. "<div class=\"popover {{placement}}\" ng-class=\"{ in: isOpen(), fade: animation() }\">\n" +
  3979. " <div class=\"arrow\"></div>\n" +
  3980. "\n" +
  3981. " <div class=\"popover-inner\">\n" +
  3982. " <h3 class=\"popover-title\" ng-bind=\"title\" ng-show=\"title\"></h3>\n" +
  3983. " <div class=\"popover-content\" ng-bind=\"content\"></div>\n" +
  3984. " </div>\n" +
  3985. "</div>\n" +
  3986. "");
  3987. }]);
  3988. angular.module("template/progressbar/bar.html", []).run(["$templateCache", function($templateCache) {
  3989. $templateCache.put("template/progressbar/bar.html",
  3990. "<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>");
  3991. }]);
  3992. angular.module("template/progressbar/progress.html", []).run(["$templateCache", function($templateCache) {
  3993. $templateCache.put("template/progressbar/progress.html",
  3994. "<div class=\"progress\" ng-transclude></div>");
  3995. }]);
  3996. angular.module("template/progressbar/progressbar.html", []).run(["$templateCache", function($templateCache) {
  3997. $templateCache.put("template/progressbar/progressbar.html",
  3998. "<div class=\"progress\">\n" +
  3999. " <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" +
  4000. "</div>");
  4001. }]);
  4002. angular.module("template/rating/rating.html", []).run(["$templateCache", function($templateCache) {
  4003. $templateCache.put("template/rating/rating.html",
  4004. "<span ng-mouseleave=\"reset()\" ng-keydown=\"onKeydown($event)\" tabindex=\"0\" role=\"slider\" aria-valuemin=\"0\" aria-valuemax=\"{{range.length}}\" aria-valuenow=\"{{value}}\">\n" +
  4005. " <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" +
  4006. " <span class=\"sr-only\">({{ $index < value ? '*' : ' ' }})</span>\n" +
  4007. " </i>\n" +
  4008. "</span>");
  4009. }]);
  4010. angular.module("template/tabs/tab.html", []).run(["$templateCache", function($templateCache) {
  4011. $templateCache.put("template/tabs/tab.html",
  4012. "<li ng-class=\"{active: active, disabled: disabled}\">\n" +
  4013. " <a href ng-click=\"select()\" tab-heading-transclude>{{heading}}</a>\n" +
  4014. "</li>\n" +
  4015. "");
  4016. }]);
  4017. angular.module("template/tabs/tabset.html", []).run(["$templateCache", function($templateCache) {
  4018. $templateCache.put("template/tabs/tabset.html",
  4019. "<div>\n" +
  4020. " <ul class=\"nav nav-{{type || 'tabs'}}\" ng-class=\"{'nav-stacked': vertical, 'nav-justified': justified}\" ng-transclude></ul>\n" +
  4021. " <div class=\"tab-content\">\n" +
  4022. " <div class=\"tab-pane\" \n" +
  4023. " ng-repeat=\"tab in tabs\" \n" +
  4024. " ng-class=\"{active: tab.active}\"\n" +
  4025. " tab-content-transclude=\"tab\">\n" +
  4026. " </div>\n" +
  4027. " </div>\n" +
  4028. "</div>\n" +
  4029. "");
  4030. }]);
  4031. angular.module("template/timepicker/timepicker.html", []).run(["$templateCache", function($templateCache) {
  4032. $templateCache.put("template/timepicker/timepicker.html",
  4033. "<table>\n" +
  4034. " <tbody>\n" +
  4035. " <tr class=\"text-center\">\n" +
  4036. " <td><a ng-click=\"incrementHours()\" class=\"btn-link\" ><span class=\"glyphicon glyphicon-chevron-up\" style=\"font-size:8px\"></span></a></td>\n" +
  4037. " <td>&nbsp;</td>\n" +
  4038. " <td><a ng-click=\"incrementMinutes()\" class=\" btn-link\"><span class=\"glyphicon glyphicon-chevron-up\" style=\"font-size:8px\"></span></a></td>\n" +
  4039. " <td ng-show=\"showMeridian\"></td>\n" +
  4040. " </tr>\n" +
  4041. " <tr>\n" +
  4042. " <td style=\"width:80px;\" class=\"form-group\" ng-class=\"{'has-error': invalidHours}\">\n" +
  4043. " <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" +
  4044. " </td>\n" +
  4045. " <td>:</td>\n" +
  4046. " <td style=\"width:80px;\" class=\"form-group\" ng-class=\"{'has-error': invalidMinutes}\">\n" +
  4047. " <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" +
  4048. " </td>\n" +
  4049. " <td ng-show=\"showMeridian\"><button type=\"button\" class=\"btn btn-default text-center\" ng-click=\"toggleMeridian()\">{{meridian}}</button></td>\n" +
  4050. " </tr>\n" +
  4051. " <tr class=\"text-center\">\n" +
  4052. " <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" +
  4053. " <td>&nbsp;</td>\n" +
  4054. " <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" +
  4055. " <td ng-show=\"showMeridian\"></td>\n" +
  4056. " </tr>\n" +
  4057. " </tbody>\n" +
  4058. "</table>\n" +
  4059. "");
  4060. }]);
  4061. angular.module("template/typeahead/typeahead-match.html", []).run(["$templateCache", function($templateCache) {
  4062. $templateCache.put("template/typeahead/typeahead-match.html",
  4063. "<a tabindex=\"-1\" bind-html-unsafe=\"match.label | typeaheadHighlight:query\"></a>");
  4064. }]);
  4065. angular.module("template/typeahead/typeahead-popup.html", []).run(["$templateCache", function($templateCache) {
  4066. $templateCache.put("template/typeahead/typeahead-popup.html",
  4067. "<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" +
  4068. " <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" +
  4069. " <div typeahead-match index=\"$index\" match=\"match\" query=\"query\" template-url=\"templateUrl\"></div>\n" +
  4070. " </li>\n" +
  4071. "</ul>\n" +
  4072. "");
  4073. }]);