ui-bootstrap-tpls-0.11.0.js 136 KB

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