ui-bootstrap-tpls.js 181 KB

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