angular-ui-bootstrap-tpls.js 140KB

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