ui-bootstrapweek.js 147 KB

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