ui-bootstrap-tpls_1.js 168 KB

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