ui-bootstrap-tpls.js 140 KB

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