3 * http://angular-ui.github.io/bootstrap/
5 * Version: 1.3.2 - 2016-04-14
7 */angular.module("ui.bootstrap", ["ui.bootstrap.tpls", "ui.bootstrap.collapse","ui.bootstrap.accordion","ui.bootstrap.alert","ui.bootstrap.buttons","ui.bootstrap.carousel","ui.bootstrap.dateparser","ui.bootstrap.isClass","ui.bootstrap.datepicker","ui.bootstrap.position","ui.bootstrap.datepickerPopup","ui.bootstrap.debounce","ui.bootstrap.dropdown","ui.bootstrap.stackedMap","ui.bootstrap.modal","ui.bootstrap.paging","ui.bootstrap.pager","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", ["uib/template/accordion/accordion-group.html","uib/template/accordion/accordion.html","uib/template/alert/alert.html","uib/template/carousel/carousel.html","uib/template/carousel/slide.html","uib/template/datepicker/datepicker.html","uib/template/datepicker/day.html","uib/template/datepicker/month.html","uib/template/datepicker/year.html","uib/template/datepickerPopup/popup.html","uib/template/modal/backdrop.html","uib/template/modal/window.html","uib/template/pager/pager.html","uib/template/pagination/pagination.html","uib/template/tooltip/tooltip-html-popup.html","uib/template/tooltip/tooltip-popup.html","uib/template/tooltip/tooltip-template-popup.html","uib/template/popover/popover-html.html","uib/template/popover/popover-template.html","uib/template/popover/popover.html","uib/template/progressbar/bar.html","uib/template/progressbar/progress.html","uib/template/progressbar/progressbar.html","uib/template/rating/rating.html","uib/template/tabs/tab.html","uib/template/tabs/tabset.html","uib/template/timepicker/timepicker.html","uib/template/typeahead/typeahead-match.html","uib/template/typeahead/typeahead-popup.html"]);
9 angular.module('ui.bootstrap.collapse', [])
11 .directive('uibCollapse', ['$animate', '$q', '$parse', '$injector', function($animate, $q, $parse, $injector) {
12 var $animateCss = $injector.has('$animateCss') ? $injector.get('$animateCss') : null;
14 link: function(scope, element, attrs) {
15 var expandingExpr = $parse(attrs.expanding),
16 expandedExpr = $parse(attrs.expanded),
17 collapsingExpr = $parse(attrs.collapsing),
18 collapsedExpr = $parse(attrs.collapsed);
20 if (!scope.$eval(attrs.uibCollapse)) {
21 element.addClass('in')
23 .attr('aria-expanded', true)
24 .attr('aria-hidden', false)
25 .css({height: 'auto'});
29 if (element.hasClass('collapse') && element.hasClass('in')) {
33 $q.resolve(expandingExpr(scope))
35 element.removeClass('collapse')
36 .addClass('collapsing')
37 .attr('aria-expanded', true)
38 .attr('aria-hidden', false);
41 $animateCss(element, {
44 to: { height: element[0].scrollHeight + 'px' }
45 }).start()['finally'](expandDone);
47 $animate.addClass(element, 'in', {
48 to: { height: element[0].scrollHeight + 'px' }
54 function expandDone() {
55 element.removeClass('collapsing')
57 .css({height: 'auto'});
62 if (!element.hasClass('collapse') && !element.hasClass('in')) {
63 return collapseDone();
66 $q.resolve(collapsingExpr(scope))
69 // IMPORTANT: The height must be set before adding "collapsing" class.
70 // Otherwise, the browser attempts to animate from height 0 (in
71 // collapsing class) to the given height here.
72 .css({height: element[0].scrollHeight + 'px'})
73 // initially all panel collapse have the collapse class, this removal
74 // prevents the animation from jumping to collapsed state
75 .removeClass('collapse')
76 .addClass('collapsing')
77 .attr('aria-expanded', false)
78 .attr('aria-hidden', true);
81 $animateCss(element, {
84 }).start()['finally'](collapseDone);
86 $animate.removeClass(element, 'in', {
88 }).then(collapseDone);
93 function collapseDone() {
94 element.css({height: '0'}); // Required so that collapse works when animation is disabled
95 element.removeClass('collapsing')
96 .addClass('collapse');
100 scope.$watch(attrs.uibCollapse, function(shouldCollapse) {
101 if (shouldCollapse) {
111 angular.module('ui.bootstrap.accordion', ['ui.bootstrap.collapse'])
113 .constant('uibAccordionConfig', {
117 .controller('UibAccordionController', ['$scope', '$attrs', 'uibAccordionConfig', function($scope, $attrs, accordionConfig) {
118 // This array keeps track of the accordion groups
121 // Ensure that all the groups in this accordion are closed, unless close-others explicitly says not to
122 this.closeOthers = function(openGroup) {
123 var closeOthers = angular.isDefined($attrs.closeOthers) ?
124 $scope.$eval($attrs.closeOthers) : accordionConfig.closeOthers;
126 angular.forEach(this.groups, function(group) {
127 if (group !== openGroup) {
128 group.isOpen = false;
134 // This is called from the accordion-group directive to add itself to the accordion
135 this.addGroup = function(groupScope) {
137 this.groups.push(groupScope);
139 groupScope.$on('$destroy', function(event) {
140 that.removeGroup(groupScope);
144 // This is called from the accordion-group directive when to remove itself
145 this.removeGroup = function(group) {
146 var index = this.groups.indexOf(group);
148 this.groups.splice(index, 1);
153 // The accordion directive simply sets up the directive controller
154 // and adds an accordion CSS class to itself element.
155 .directive('uibAccordion', function() {
157 controller: 'UibAccordionController',
158 controllerAs: 'accordion',
160 templateUrl: function(element, attrs) {
161 return attrs.templateUrl || 'uib/template/accordion/accordion.html';
166 // The accordion-group directive indicates a block of html that will expand and collapse in an accordion
167 .directive('uibAccordionGroup', function() {
169 require: '^uibAccordion', // We need this directive to be inside an accordion
170 transclude: true, // It transcludes the contents of the directive into the template
171 replace: true, // The element containing the directive will be replaced with the template
172 templateUrl: function(element, attrs) {
173 return attrs.templateUrl || 'uib/template/accordion/accordion-group.html';
176 heading: '@', // Interpolate the heading attribute onto this scope
177 panelClass: '@?', // Ditto with panelClass
181 controller: function() {
182 this.setHeading = function(element) {
183 this.heading = element;
186 link: function(scope, element, attrs, accordionCtrl) {
187 accordionCtrl.addGroup(scope);
189 scope.openClass = attrs.openClass || 'panel-open';
190 scope.panelClass = attrs.panelClass || 'panel-default';
191 scope.$watch('isOpen', function(value) {
192 element.toggleClass(scope.openClass, !!value);
194 accordionCtrl.closeOthers(scope);
198 scope.toggleOpen = function($event) {
199 if (!scope.isDisabled) {
200 if (!$event || $event.which === 32) {
201 scope.isOpen = !scope.isOpen;
206 var id = 'accordiongroup-' + scope.$id + '-' + Math.floor(Math.random() * 10000);
207 scope.headingId = id + '-tab';
208 scope.panelId = id + '-panel';
213 // Use accordion-heading below an accordion-group to provide a heading containing HTML
214 .directive('uibAccordionHeading', function() {
216 transclude: true, // Grab the contents to be used as the heading
217 template: '', // In effect remove this element!
219 require: '^uibAccordionGroup',
220 link: function(scope, element, attrs, accordionGroupCtrl, transclude) {
221 // Pass the heading to the accordion-group controller
222 // so that it can be transcluded into the right place in the template
223 // [The second parameter to transclude causes the elements to be cloned so that they work in ng-repeat]
224 accordionGroupCtrl.setHeading(transclude(scope, angular.noop));
229 // Use in the accordion-group template to indicate where you want the heading to be transcluded
230 // You must provide the property on the accordion-group controller that will hold the transcluded element
231 .directive('uibAccordionTransclude', function() {
233 require: '^uibAccordionGroup',
234 link: function(scope, element, attrs, controller) {
235 scope.$watch(function() { return controller[attrs.uibAccordionTransclude]; }, function(heading) {
237 var elem = angular.element(element[0].querySelector('[uib-accordion-header]'));
239 elem.append(heading);
246 angular.module('ui.bootstrap.alert', [])
248 .controller('UibAlertController', ['$scope', '$attrs', '$interpolate', '$timeout', function($scope, $attrs, $interpolate, $timeout) {
249 $scope.closeable = !!$attrs.close;
251 var dismissOnTimeout = angular.isDefined($attrs.dismissOnTimeout) ?
252 $interpolate($attrs.dismissOnTimeout)($scope.$parent) : null;
254 if (dismissOnTimeout) {
255 $timeout(function() {
257 }, parseInt(dismissOnTimeout, 10));
261 .directive('uibAlert', function() {
263 controller: 'UibAlertController',
264 controllerAs: 'alert',
265 templateUrl: function(element, attrs) {
266 return attrs.templateUrl || 'uib/template/alert/alert.html';
277 angular.module('ui.bootstrap.buttons', [])
279 .constant('uibButtonConfig', {
280 activeClass: 'active',
284 .controller('UibButtonsController', ['uibButtonConfig', function(buttonConfig) {
285 this.activeClass = buttonConfig.activeClass || 'active';
286 this.toggleEvent = buttonConfig.toggleEvent || 'click';
289 .directive('uibBtnRadio', ['$parse', function($parse) {
291 require: ['uibBtnRadio', 'ngModel'],
292 controller: 'UibButtonsController',
293 controllerAs: 'buttons',
294 link: function(scope, element, attrs, ctrls) {
295 var buttonsCtrl = ctrls[0], ngModelCtrl = ctrls[1];
296 var uncheckableExpr = $parse(attrs.uibUncheckable);
298 element.find('input').css({display: 'none'});
301 ngModelCtrl.$render = function() {
302 element.toggleClass(buttonsCtrl.activeClass, angular.equals(ngModelCtrl.$modelValue, scope.$eval(attrs.uibBtnRadio)));
306 element.on(buttonsCtrl.toggleEvent, function() {
307 if (attrs.disabled) {
311 var isActive = element.hasClass(buttonsCtrl.activeClass);
313 if (!isActive || angular.isDefined(attrs.uncheckable)) {
314 scope.$apply(function() {
315 ngModelCtrl.$setViewValue(isActive ? null : scope.$eval(attrs.uibBtnRadio));
316 ngModelCtrl.$render();
321 if (attrs.uibUncheckable) {
322 scope.$watch(uncheckableExpr, function(uncheckable) {
323 attrs.$set('uncheckable', uncheckable ? '' : undefined);
330 .directive('uibBtnCheckbox', function() {
332 require: ['uibBtnCheckbox', 'ngModel'],
333 controller: 'UibButtonsController',
334 controllerAs: 'button',
335 link: function(scope, element, attrs, ctrls) {
336 var buttonsCtrl = ctrls[0], ngModelCtrl = ctrls[1];
338 element.find('input').css({display: 'none'});
340 function getTrueValue() {
341 return getCheckboxValue(attrs.btnCheckboxTrue, true);
344 function getFalseValue() {
345 return getCheckboxValue(attrs.btnCheckboxFalse, false);
348 function getCheckboxValue(attribute, defaultValue) {
349 return angular.isDefined(attribute) ? scope.$eval(attribute) : defaultValue;
353 ngModelCtrl.$render = function() {
354 element.toggleClass(buttonsCtrl.activeClass, angular.equals(ngModelCtrl.$modelValue, getTrueValue()));
358 element.on(buttonsCtrl.toggleEvent, function() {
359 if (attrs.disabled) {
363 scope.$apply(function() {
364 ngModelCtrl.$setViewValue(element.hasClass(buttonsCtrl.activeClass) ? getFalseValue() : getTrueValue());
365 ngModelCtrl.$render();
372 angular.module('ui.bootstrap.carousel', [])
374 .controller('UibCarouselController', ['$scope', '$element', '$interval', '$timeout', '$animate', function($scope, $element, $interval, $timeout, $animate) {
376 slides = self.slides = $scope.slides = [],
377 SLIDE_DIRECTION = 'uib-slideDirection',
378 currentIndex = $scope.active,
379 currentInterval, isPlaying, bufferedTransitions = [];
381 var destroyed = false;
383 self.addSlide = function(slide, element) {
388 slides.sort(function(a, b) {
389 return +a.slide.index - +b.slide.index;
391 //if this is the first slide or the slide is set to active, select it
392 if (slide.index === $scope.active || slides.length === 1 && !angular.isNumber($scope.active)) {
393 if ($scope.$currentTransition) {
394 $scope.$currentTransition = null;
397 currentIndex = slide.index;
398 $scope.active = slide.index;
399 setActive(currentIndex);
400 self.select(slides[findSlideIndex(slide)]);
401 if (slides.length === 1) {
407 self.getCurrentIndex = function() {
408 for (var i = 0; i < slides.length; i++) {
409 if (slides[i].slide.index === currentIndex) {
415 self.next = $scope.next = function() {
416 var newIndex = (self.getCurrentIndex() + 1) % slides.length;
418 if (newIndex === 0 && $scope.noWrap()) {
423 return self.select(slides[newIndex], 'next');
426 self.prev = $scope.prev = function() {
427 var newIndex = self.getCurrentIndex() - 1 < 0 ? slides.length - 1 : self.getCurrentIndex() - 1;
429 if ($scope.noWrap() && newIndex === slides.length - 1) {
434 return self.select(slides[newIndex], 'prev');
437 self.removeSlide = function(slide) {
438 var index = findSlideIndex(slide);
440 var bufferedIndex = bufferedTransitions.indexOf(slides[index]);
441 if (bufferedIndex !== -1) {
442 bufferedTransitions.splice(bufferedIndex, 1);
445 //get the index of the slide inside the carousel
446 slides.splice(index, 1);
447 if (slides.length > 0 && currentIndex === index) {
448 if (index >= slides.length) {
449 currentIndex = slides.length - 1;
450 $scope.active = currentIndex;
451 setActive(currentIndex);
452 self.select(slides[slides.length - 1]);
454 currentIndex = index;
455 $scope.active = currentIndex;
456 setActive(currentIndex);
457 self.select(slides[index]);
459 } else if (currentIndex > index) {
461 $scope.active = currentIndex;
464 //clean the active value when no more slide
465 if (slides.length === 0) {
467 $scope.active = null;
468 clearBufferedTransitions();
472 /* direction: "prev" or "next" */
473 self.select = $scope.select = function(nextSlide, direction) {
474 var nextIndex = findSlideIndex(nextSlide.slide);
475 //Decide direction if it's not given
476 if (direction === undefined) {
477 direction = nextIndex > self.getCurrentIndex() ? 'next' : 'prev';
479 //Prevent this user-triggered transition from occurring if there is already one in progress
480 if (nextSlide.slide.index !== currentIndex &&
481 !$scope.$currentTransition) {
482 goNext(nextSlide.slide, nextIndex, direction);
483 } else if (nextSlide && nextSlide.slide.index !== currentIndex && $scope.$currentTransition) {
484 bufferedTransitions.push(slides[nextIndex]);
488 /* Allow outside people to call indexOf on slides array */
489 $scope.indexOfSlide = function(slide) {
490 return +slide.slide.index;
493 $scope.isActive = function(slide) {
494 return $scope.active === slide.slide.index;
497 $scope.isPrevDisabled = function() {
498 return $scope.active === 0 && $scope.noWrap();
501 $scope.isNextDisabled = function() {
502 return $scope.active === slides.length - 1 && $scope.noWrap();
505 $scope.pause = function() {
506 if (!$scope.noPause) {
512 $scope.play = function() {
519 $scope.$on('$destroy', function() {
524 $scope.$watch('noTransition', function(noTransition) {
525 $animate.enabled($element, !noTransition);
528 $scope.$watch('interval', restartTimer);
530 $scope.$watchCollection('slides', resetTransition);
532 $scope.$watch('active', function(index) {
533 if (angular.isNumber(index) && currentIndex !== index) {
534 for (var i = 0; i < slides.length; i++) {
535 if (slides[i].slide.index === index) {
541 var slide = slides[index];
544 self.select(slides[index]);
545 currentIndex = index;
550 function clearBufferedTransitions() {
551 while (bufferedTransitions.length) {
552 bufferedTransitions.shift();
556 function getSlideByIndex(index) {
557 for (var i = 0, l = slides.length; i < l; ++i) {
558 if (slides[i].index === index) {
564 function setActive(index) {
565 for (var i = 0; i < slides.length; i++) {
566 slides[i].slide.active = i === index;
570 function goNext(slide, index, direction) {
575 angular.extend(slide, {direction: direction});
576 angular.extend(slides[currentIndex].slide || {}, {direction: direction});
577 if ($animate.enabled($element) && !$scope.$currentTransition &&
578 slides[index].element && self.slides.length > 1) {
579 slides[index].element.data(SLIDE_DIRECTION, slide.direction);
580 var currentIdx = self.getCurrentIndex();
582 if (angular.isNumber(currentIdx) && slides[currentIdx].element) {
583 slides[currentIdx].element.data(SLIDE_DIRECTION, slide.direction);
586 $scope.$currentTransition = true;
587 $animate.on('addClass', slides[index].element, function(element, phase) {
588 if (phase === 'close') {
589 $scope.$currentTransition = null;
590 $animate.off('addClass', element);
591 if (bufferedTransitions.length) {
592 var nextSlide = bufferedTransitions.pop().slide;
593 var nextIndex = nextSlide.index;
594 var nextDirection = nextIndex > self.getCurrentIndex() ? 'next' : 'prev';
595 clearBufferedTransitions();
597 goNext(nextSlide, nextIndex, nextDirection);
603 $scope.active = slide.index;
604 currentIndex = slide.index;
607 //every time you change slides, reset the timer
611 function findSlideIndex(slide) {
612 for (var i = 0; i < slides.length; i++) {
613 if (slides[i].slide === slide) {
619 function resetTimer() {
620 if (currentInterval) {
621 $interval.cancel(currentInterval);
622 currentInterval = null;
626 function resetTransition(slides) {
627 if (!slides.length) {
628 $scope.$currentTransition = null;
629 clearBufferedTransitions();
633 function restartTimer() {
635 var interval = +$scope.interval;
636 if (!isNaN(interval) && interval > 0) {
637 currentInterval = $interval(timerFn, interval);
642 var interval = +$scope.interval;
643 if (isPlaying && !isNaN(interval) && interval > 0 && slides.length) {
651 .directive('uibCarousel', function() {
655 controller: 'UibCarouselController',
656 controllerAs: 'carousel',
657 templateUrl: function(element, attrs) {
658 return attrs.templateUrl || 'uib/template/carousel/carousel.html';
670 .directive('uibSlide', function() {
672 require: '^uibCarousel',
675 templateUrl: function(element, attrs) {
676 return attrs.templateUrl || 'uib/template/carousel/slide.html';
682 link: function (scope, element, attrs, carouselCtrl) {
683 carouselCtrl.addSlide(scope, element);
684 //when the scope is destroyed then remove the slide from the current slides array
685 scope.$on('$destroy', function() {
686 carouselCtrl.removeSlide(scope);
692 .animation('.item', ['$animateCss',
693 function($animateCss) {
694 var SLIDE_DIRECTION = 'uib-slideDirection';
696 function removeClass(element, className, callback) {
697 element.removeClass(className);
704 beforeAddClass: function(element, className, done) {
705 if (className === 'active') {
707 var direction = element.data(SLIDE_DIRECTION);
708 var directionClass = direction === 'next' ? 'left' : 'right';
709 var removeClassFn = removeClass.bind(this, element,
710 directionClass + ' ' + direction, done);
711 element.addClass(direction);
713 $animateCss(element, {addClass: directionClass})
715 .done(removeClassFn);
723 beforeRemoveClass: function (element, className, done) {
724 if (className === 'active') {
726 var direction = element.data(SLIDE_DIRECTION);
727 var directionClass = direction === 'next' ? 'left' : 'right';
728 var removeClassFn = removeClass.bind(this, element, directionClass, done);
730 $animateCss(element, {addClass: directionClass})
732 .done(removeClassFn);
743 angular.module('ui.bootstrap.dateparser', [])
745 .service('uibDateParser', ['$log', '$locale', 'dateFilter', 'orderByFilter', function($log, $locale, dateFilter, orderByFilter) {
746 // Pulled from https://github.com/mbostock/d3/blob/master/src/format/requote.js
747 var SPECIAL_CHARACTERS_REGEXP = /[\\\^\$\*\+\?\|\[\]\(\)\.\{\}]/g;
750 var formatCodeToRegex;
752 this.init = function() {
753 localeId = $locale.id;
756 this.formatters = {};
758 formatCodeToRegex = [
762 apply: function(value) { this.year = +value; },
763 formatter: function(date) {
764 var _date = new Date();
765 _date.setFullYear(Math.abs(date.getFullYear()));
766 return dateFilter(_date, 'yyyy');
772 apply: function(value) { value = +value; this.year = value < 69 ? value + 2000 : value + 1900; },
773 formatter: function(date) {
774 var _date = new Date();
775 _date.setFullYear(Math.abs(date.getFullYear()));
776 return dateFilter(_date, 'yy');
782 apply: function(value) { this.year = +value; },
783 formatter: function(date) {
784 var _date = new Date();
785 _date.setFullYear(Math.abs(date.getFullYear()));
786 return dateFilter(_date, 'y');
791 regex: '0?[1-9]|1[0-2]',
792 apply: function(value) { this.month = value - 1; },
793 formatter: function(date) {
794 var value = date.getMonth();
795 if (/^[0-9]$/.test(value)) {
796 return dateFilter(date, 'MM');
799 return dateFilter(date, 'M');
804 regex: $locale.DATETIME_FORMATS.MONTH.join('|'),
805 apply: function(value) { this.month = $locale.DATETIME_FORMATS.MONTH.indexOf(value); },
806 formatter: function(date) { return dateFilter(date, 'MMMM'); }
810 regex: $locale.DATETIME_FORMATS.SHORTMONTH.join('|'),
811 apply: function(value) { this.month = $locale.DATETIME_FORMATS.SHORTMONTH.indexOf(value); },
812 formatter: function(date) { return dateFilter(date, 'MMM'); }
816 regex: '0[1-9]|1[0-2]',
817 apply: function(value) { this.month = value - 1; },
818 formatter: function(date) { return dateFilter(date, 'MM'); }
822 regex: '[1-9]|1[0-2]',
823 apply: function(value) { this.month = value - 1; },
824 formatter: function(date) { return dateFilter(date, 'M'); }
828 regex: '[0-2]?[0-9]{1}|3[0-1]{1}',
829 apply: function(value) { this.date = +value; },
830 formatter: function(date) {
831 var value = date.getDate();
832 if (/^[1-9]$/.test(value)) {
833 return dateFilter(date, 'dd');
836 return dateFilter(date, 'd');
841 regex: '[0-2][0-9]{1}|3[0-1]{1}',
842 apply: function(value) { this.date = +value; },
843 formatter: function(date) { return dateFilter(date, 'dd'); }
847 regex: '[1-2]?[0-9]{1}|3[0-1]{1}',
848 apply: function(value) { this.date = +value; },
849 formatter: function(date) { return dateFilter(date, 'd'); }
853 regex: $locale.DATETIME_FORMATS.DAY.join('|'),
854 formatter: function(date) { return dateFilter(date, 'EEEE'); }
858 regex: $locale.DATETIME_FORMATS.SHORTDAY.join('|'),
859 formatter: function(date) { return dateFilter(date, 'EEE'); }
863 regex: '(?:0|1)[0-9]|2[0-3]',
864 apply: function(value) { this.hours = +value; },
865 formatter: function(date) { return dateFilter(date, 'HH'); }
869 regex: '0[0-9]|1[0-2]',
870 apply: function(value) { this.hours = +value; },
871 formatter: function(date) { return dateFilter(date, 'hh'); }
875 regex: '1?[0-9]|2[0-3]',
876 apply: function(value) { this.hours = +value; },
877 formatter: function(date) { return dateFilter(date, 'H'); }
881 regex: '[0-9]|1[0-2]',
882 apply: function(value) { this.hours = +value; },
883 formatter: function(date) { return dateFilter(date, 'h'); }
888 apply: function(value) { this.minutes = +value; },
889 formatter: function(date) { return dateFilter(date, 'mm'); }
893 regex: '[0-9]|[1-5][0-9]',
894 apply: function(value) { this.minutes = +value; },
895 formatter: function(date) { return dateFilter(date, 'm'); }
899 regex: '[0-9][0-9][0-9]',
900 apply: function(value) { this.milliseconds = +value; },
901 formatter: function(date) { return dateFilter(date, 'sss'); }
906 apply: function(value) { this.seconds = +value; },
907 formatter: function(date) { return dateFilter(date, 'ss'); }
911 regex: '[0-9]|[1-5][0-9]',
912 apply: function(value) { this.seconds = +value; },
913 formatter: function(date) { return dateFilter(date, 's'); }
917 regex: $locale.DATETIME_FORMATS.AMPMS.join('|'),
918 apply: function(value) {
919 if (this.hours === 12) {
923 if (value === 'PM') {
927 formatter: function(date) { return dateFilter(date, 'a'); }
932 apply: function(value) {
933 var matches = value.match(/([+-])(\d{2})(\d{2})/),
936 minutes = matches[3];
937 this.hours += toInt(sign + hours);
938 this.minutes += toInt(sign + minutes);
940 formatter: function(date) {
941 return dateFilter(date, 'Z');
946 regex: '[0-4][0-9]|5[0-3]',
947 formatter: function(date) { return dateFilter(date, 'ww'); }
951 regex: '[0-9]|[1-4][0-9]|5[0-3]',
952 formatter: function(date) { return dateFilter(date, 'w'); }
956 regex: $locale.DATETIME_FORMATS.ERANAMES.join('|').replace(/\s/g, '\\s'),
957 formatter: function(date) { return dateFilter(date, 'GGGG'); }
961 regex: $locale.DATETIME_FORMATS.ERAS.join('|'),
962 formatter: function(date) { return dateFilter(date, 'GGG'); }
966 regex: $locale.DATETIME_FORMATS.ERAS.join('|'),
967 formatter: function(date) { return dateFilter(date, 'GG'); }
971 regex: $locale.DATETIME_FORMATS.ERAS.join('|'),
972 formatter: function(date) { return dateFilter(date, 'G'); }
979 function createParser(format, func) {
980 var map = [], regex = format.split('');
982 // check for literal values
983 var quoteIndex = format.indexOf('\'');
984 if (quoteIndex > -1) {
985 var inLiteral = false;
986 format = format.split('');
987 for (var i = quoteIndex; i < format.length; i++) {
989 if (format[i] === '\'') {
990 if (i + 1 < format.length && format[i+1] === '\'') { // escaped single quote
993 } else { // end of literal
1000 if (format[i] === '\'') { // start of literal
1008 format = format.join('');
1011 angular.forEach(formatCodeToRegex, function(data) {
1012 var index = format.indexOf(data.key);
1015 format = format.split('');
1017 regex[index] = '(' + data.regex + ')';
1018 format[index] = '$'; // Custom symbol to define consumed part of format
1019 for (var i = index + 1, n = index + data.key.length; i < n; i++) {
1023 format = format.join('');
1035 regex: new RegExp('^' + regex.join('') + '$'),
1036 map: orderByFilter(map, 'index')
1040 this.filter = function(date, format) {
1041 if (!angular.isDate(date) || isNaN(date) || !format) {
1045 format = $locale.DATETIME_FORMATS[format] || format;
1047 if ($locale.id !== localeId) {
1051 if (!this.formatters[format]) {
1052 this.formatters[format] = createParser(format, 'formatter');
1055 var parser = this.formatters[format],
1058 var _format = format;
1060 return map.reduce(function(str, mapper, i) {
1061 var match = _format.match(new RegExp('(.*)' + mapper.key));
1062 if (match && angular.isString(match[1])) {
1064 _format = _format.replace(match[1] + mapper.key, '');
1067 var endStr = i === map.length - 1 ? _format : '';
1070 return str + mapper.apply.call(null, date) + endStr;
1073 return str + endStr;
1077 this.parse = function(input, format, baseDate) {
1078 if (!angular.isString(input) || !format) {
1082 format = $locale.DATETIME_FORMATS[format] || format;
1083 format = format.replace(SPECIAL_CHARACTERS_REGEXP, '\\$&');
1085 if ($locale.id !== localeId) {
1089 if (!this.parsers[format]) {
1090 this.parsers[format] = createParser(format, 'apply');
1093 var parser = this.parsers[format],
1094 regex = parser.regex,
1096 results = input.match(regex),
1098 if (results && results.length) {
1100 if (angular.isDate(baseDate) && !isNaN(baseDate.getTime())) {
1102 year: baseDate.getFullYear(),
1103 month: baseDate.getMonth(),
1104 date: baseDate.getDate(),
1105 hours: baseDate.getHours(),
1106 minutes: baseDate.getMinutes(),
1107 seconds: baseDate.getSeconds(),
1108 milliseconds: baseDate.getMilliseconds()
1112 $log.warn('dateparser:', 'baseDate is not a valid date');
1114 fields = { year: 1900, month: 0, date: 1, hours: 0, minutes: 0, seconds: 0, milliseconds: 0 };
1117 for (var i = 1, n = results.length; i < n; i++) {
1118 var mapper = map[i - 1];
1119 if (mapper.matcher === 'Z') {
1124 mapper.apply.call(fields, results[i]);
1128 var datesetter = tzOffset ? Date.prototype.setUTCFullYear :
1129 Date.prototype.setFullYear;
1130 var timesetter = tzOffset ? Date.prototype.setUTCHours :
1131 Date.prototype.setHours;
1133 if (isValid(fields.year, fields.month, fields.date)) {
1134 if (angular.isDate(baseDate) && !isNaN(baseDate.getTime()) && !tzOffset) {
1135 dt = new Date(baseDate);
1136 datesetter.call(dt, fields.year, fields.month, fields.date);
1137 timesetter.call(dt, fields.hours, fields.minutes,
1138 fields.seconds, fields.milliseconds);
1141 datesetter.call(dt, fields.year, fields.month, fields.date);
1142 timesetter.call(dt, fields.hours || 0, fields.minutes || 0,
1143 fields.seconds || 0, fields.milliseconds || 0);
1151 // Check if date is valid for specific month (and year for February).
1152 // Month: 0 = Jan, 1 = Feb, etc
1153 function isValid(year, month, date) {
1158 if (month === 1 && date > 28) {
1159 return date === 29 && (year % 4 === 0 && year % 100 !== 0 || year % 400 === 0);
1162 if (month === 3 || month === 5 || month === 8 || month === 10) {
1169 function toInt(str) {
1170 return parseInt(str, 10);
1173 this.toTimezone = toTimezone;
1174 this.fromTimezone = fromTimezone;
1175 this.timezoneToOffset = timezoneToOffset;
1176 this.addDateMinutes = addDateMinutes;
1177 this.convertTimezoneToLocal = convertTimezoneToLocal;
1179 function toTimezone(date, timezone) {
1180 return date && timezone ? convertTimezoneToLocal(date, timezone) : date;
1183 function fromTimezone(date, timezone) {
1184 return date && timezone ? convertTimezoneToLocal(date, timezone, true) : date;
1187 //https://github.com/angular/angular.js/blob/4daafd3dbe6a80d578f5a31df1bb99c77559543e/src/Angular.js#L1207
1188 function timezoneToOffset(timezone, fallback) {
1189 var requestedTimezoneOffset = Date.parse('Jan 01, 1970 00:00:00 ' + timezone) / 60000;
1190 return isNaN(requestedTimezoneOffset) ? fallback : requestedTimezoneOffset;
1193 function addDateMinutes(date, minutes) {
1194 date = new Date(date.getTime());
1195 date.setMinutes(date.getMinutes() + minutes);
1199 function convertTimezoneToLocal(date, timezone, reverse) {
1200 reverse = reverse ? -1 : 1;
1201 var timezoneOffset = timezoneToOffset(timezone, date.getTimezoneOffset());
1202 return addDateMinutes(date, reverse * (timezoneOffset - date.getTimezoneOffset()));
1206 // Avoiding use of ng-class as it creates a lot of watchers when a class is to be applied to
1207 // at most one element.
1208 angular.module('ui.bootstrap.isClass', [])
1209 .directive('uibIsClass', [
1211 function ($animate) {
1212 // 11111111 22222222
1213 var ON_REGEXP = /^\s*([\s\S]+?)\s+on\s+([\s\S]+?)\s*$/;
1214 // 11111111 22222222
1215 var IS_REGEXP = /^\s*([\s\S]+?)\s+for\s+([\s\S]+?)\s*$/;
1217 var dataPerTracked = {};
1221 compile: function(tElement, tAttrs) {
1222 var linkedScopes = [];
1225 var lastActivated = null;
1226 var onExpMatches = tAttrs.uibIsClass.match(ON_REGEXP);
1227 var onExp = onExpMatches[2];
1228 var expsStr = onExpMatches[1];
1229 var exps = expsStr.split(',');
1233 function linkFn(scope, element, attrs) {
1234 linkedScopes.push(scope);
1240 exps.forEach(function(exp, k) {
1241 addForExp(exp, scope);
1244 scope.$on('$destroy', removeScope);
1247 function addForExp(exp, scope) {
1248 var matches = exp.match(IS_REGEXP);
1249 var clazz = scope.$eval(matches[1]);
1250 var compareWithExp = matches[2];
1251 var data = expToData[exp];
1253 var watchFn = function(compareWithVal) {
1254 var newActivated = null;
1255 instances.some(function(instance) {
1256 var thisVal = instance.scope.$eval(onExp);
1257 if (thisVal === compareWithVal) {
1258 newActivated = instance;
1262 if (data.lastActivated !== newActivated) {
1263 if (data.lastActivated) {
1264 $animate.removeClass(data.lastActivated.element, clazz);
1267 $animate.addClass(newActivated.element, clazz);
1269 data.lastActivated = newActivated;
1272 expToData[exp] = data = {
1273 lastActivated: null,
1276 compareWithExp: compareWithExp,
1277 watcher: scope.$watch(compareWithExp, watchFn)
1280 data.watchFn(scope.$eval(compareWithExp));
1283 function removeScope(e) {
1284 var removedScope = e.targetScope;
1285 var index = linkedScopes.indexOf(removedScope);
1286 linkedScopes.splice(index, 1);
1287 instances.splice(index, 1);
1288 if (linkedScopes.length) {
1289 var newWatchScope = linkedScopes[0];
1290 angular.forEach(expToData, function(data) {
1291 if (data.scope === removedScope) {
1292 data.watcher = newWatchScope.$watch(data.compareWithExp, data.watchFn);
1293 data.scope = newWatchScope;
1303 angular.module('ui.bootstrap.datepicker', ['ui.bootstrap.dateparser', 'ui.bootstrap.isClass'])
1305 .value('$datepickerSuppressError', false)
1307 .value('$datepickerLiteralWarning', true)
1309 .constant('uibDatepickerConfig', {
1310 datepickerMode: 'day',
1312 formatMonth: 'MMMM',
1314 formatDayHeader: 'EEE',
1315 formatDayTitle: 'MMMM yyyy',
1316 formatMonthTitle: 'yyyy',
1322 shortcutPropagation: false,
1328 .controller('UibDatepickerController', ['$scope', '$attrs', '$parse', '$interpolate', '$locale', '$log', 'dateFilter', 'uibDatepickerConfig', '$datepickerLiteralWarning', '$datepickerSuppressError', 'uibDateParser',
1329 function($scope, $attrs, $parse, $interpolate, $locale, $log, dateFilter, datepickerConfig, $datepickerLiteralWarning, $datepickerSuppressError, dateParser) {
1331 ngModelCtrl = { $setViewValue: angular.noop }, // nullModelCtrl;
1332 ngModelOptions = {},
1333 watchListeners = [],
1334 optionsUsed = !!$attrs.datepickerOptions;
1336 if (!$scope.datepickerOptions) {
1337 $scope.datepickerOptions = {};
1341 this.modes = ['day', 'month', 'year'];
1358 'shortcutPropagation',
1362 ].forEach(function(key) {
1365 case 'dateDisabled':
1366 $scope[key] = $scope.datepickerOptions[key] || angular.noop;
1368 case 'datepickerMode':
1369 $scope.datepickerMode = angular.isDefined($scope.datepickerOptions.datepickerMode) ?
1370 $scope.datepickerOptions.datepickerMode : datepickerConfig.datepickerMode;
1373 case 'formatDayHeader':
1374 case 'formatDayTitle':
1376 case 'formatMonthTitle':
1378 self[key] = angular.isDefined($scope.datepickerOptions[key]) ?
1379 $interpolate($scope.datepickerOptions[key])($scope.$parent) :
1380 datepickerConfig[key];
1383 case 'shortcutPropagation':
1386 self[key] = angular.isDefined($scope.datepickerOptions[key]) ?
1387 $scope.datepickerOptions[key] : datepickerConfig[key];
1390 if (angular.isDefined($scope.datepickerOptions.startingDay)) {
1391 self.startingDay = $scope.datepickerOptions.startingDay;
1392 } else if (angular.isNumber(datepickerConfig.startingDay)) {
1393 self.startingDay = datepickerConfig.startingDay;
1395 self.startingDay = ($locale.DATETIME_FORMATS.FIRSTDAYOFWEEK + 8) % 7;
1401 $scope.$watch('datepickerOptions.' + key, function(value) {
1403 if (angular.isDate(value)) {
1404 self[key] = dateParser.fromTimezone(new Date(value), ngModelOptions.timezone);
1406 if ($datepickerLiteralWarning) {
1407 $log.warn('Literal date support has been deprecated, please switch to date object usage');
1410 self[key] = new Date(dateFilter(value, 'medium'));
1413 self[key] = datepickerConfig[key] ?
1414 dateParser.fromTimezone(new Date(datepickerConfig[key]), ngModelOptions.timezone) :
1424 if ($scope.datepickerOptions[key]) {
1425 $scope.$watch(function() { return $scope.datepickerOptions[key]; }, function(value) {
1426 self[key] = $scope[key] = angular.isDefined(value) ? value : datepickerOptions[key];
1427 if (key === 'minMode' && self.modes.indexOf($scope.datepickerOptions.datepickerMode) < self.modes.indexOf(self[key]) ||
1428 key === 'maxMode' && self.modes.indexOf($scope.datepickerOptions.datepickerMode) > self.modes.indexOf(self[key])) {
1429 $scope.datepickerMode = self[key];
1430 $scope.datepickerOptions.datepickerMode = self[key];
1434 self[key] = $scope[key] = datepickerConfig[key] || null;
1441 $scope.uniqueId = 'datepicker-' + $scope.$id + '-' + Math.floor(Math.random() * 10000);
1443 $scope.disabled = angular.isDefined($attrs.disabled) || false;
1444 if (angular.isDefined($attrs.ngDisabled)) {
1445 watchListeners.push($scope.$parent.$watch($attrs.ngDisabled, function(disabled) {
1446 $scope.disabled = disabled;
1451 $scope.isActive = function(dateObject) {
1452 if (self.compare(dateObject.date, self.activeDate) === 0) {
1453 $scope.activeDateId = dateObject.uid;
1459 this.init = function(ngModelCtrl_) {
1460 ngModelCtrl = ngModelCtrl_;
1461 ngModelOptions = ngModelCtrl_.$options || datepickerConfig.ngModelOptions;
1462 if ($scope.datepickerOptions.initDate) {
1463 self.activeDate = dateParser.fromTimezone($scope.datepickerOptions.initDate, ngModelOptions.timezone) || new Date();
1464 $scope.$watch('datepickerOptions.initDate', function(initDate) {
1465 if (initDate && (ngModelCtrl.$isEmpty(ngModelCtrl.$modelValue) || ngModelCtrl.$invalid)) {
1466 self.activeDate = dateParser.fromTimezone(initDate, ngModelOptions.timezone);
1471 self.activeDate = new Date();
1474 this.activeDate = ngModelCtrl.$modelValue ?
1475 dateParser.fromTimezone(new Date(ngModelCtrl.$modelValue), ngModelOptions.timezone) :
1476 dateParser.fromTimezone(new Date(), ngModelOptions.timezone);
1478 ngModelCtrl.$render = function() {
1483 this.render = function() {
1484 if (ngModelCtrl.$viewValue) {
1485 var date = new Date(ngModelCtrl.$viewValue),
1486 isValid = !isNaN(date);
1489 this.activeDate = dateParser.fromTimezone(date, ngModelOptions.timezone);
1490 } else if (!$datepickerSuppressError) {
1491 $log.error('Datepicker directive: "ng-model" value must be a Date object');
1497 this.refreshView = function() {
1499 $scope.selectedDt = null;
1500 this._refreshView();
1501 if ($scope.activeDt) {
1502 $scope.activeDateId = $scope.activeDt.uid;
1505 var date = ngModelCtrl.$viewValue ? new Date(ngModelCtrl.$viewValue) : null;
1506 date = dateParser.fromTimezone(date, ngModelOptions.timezone);
1507 ngModelCtrl.$setValidity('dateDisabled', !date ||
1508 this.element && !this.isDisabled(date));
1512 this.createDateObject = function(date, format) {
1513 var model = ngModelCtrl.$viewValue ? new Date(ngModelCtrl.$viewValue) : null;
1514 model = dateParser.fromTimezone(model, ngModelOptions.timezone);
1515 var today = new Date();
1516 today = dateParser.fromTimezone(today, ngModelOptions.timezone);
1517 var time = this.compare(date, today);
1520 label: dateParser.filter(date, format),
1521 selected: model && this.compare(date, model) === 0,
1522 disabled: this.isDisabled(date),
1524 current: time === 0,
1526 customClass: this.customClass(date) || null
1529 if (model && this.compare(date, model) === 0) {
1530 $scope.selectedDt = dt;
1533 if (self.activeDate && this.compare(dt.date, self.activeDate) === 0) {
1534 $scope.activeDt = dt;
1540 this.isDisabled = function(date) {
1541 return $scope.disabled ||
1542 this.minDate && this.compare(date, this.minDate) < 0 ||
1543 this.maxDate && this.compare(date, this.maxDate) > 0 ||
1544 $scope.dateDisabled && $scope.dateDisabled({date: date, mode: $scope.datepickerMode});
1547 this.customClass = function(date) {
1548 return $scope.customClass({date: date, mode: $scope.datepickerMode});
1551 // Split array into smaller arrays
1552 this.split = function(arr, size) {
1554 while (arr.length > 0) {
1555 arrays.push(arr.splice(0, size));
1560 $scope.select = function(date) {
1561 if ($scope.datepickerMode === self.minMode) {
1562 var dt = ngModelCtrl.$viewValue ? dateParser.fromTimezone(new Date(ngModelCtrl.$viewValue), ngModelOptions.timezone) : new Date(0, 0, 0, 0, 0, 0, 0);
1563 dt.setFullYear(date.getFullYear(), date.getMonth(), date.getDate());
1564 dt = dateParser.toTimezone(dt, ngModelOptions.timezone);
1565 ngModelCtrl.$setViewValue(dt);
1566 ngModelCtrl.$render();
1568 self.activeDate = date;
1569 setMode(self.modes[self.modes.indexOf($scope.datepickerMode) - 1]);
1571 $scope.$emit('uib:datepicker.mode');
1574 $scope.$broadcast('uib:datepicker.focus');
1577 $scope.move = function(direction) {
1578 var year = self.activeDate.getFullYear() + direction * (self.step.years || 0),
1579 month = self.activeDate.getMonth() + direction * (self.step.months || 0);
1580 self.activeDate.setFullYear(year, month, 1);
1584 $scope.toggleMode = function(direction) {
1585 direction = direction || 1;
1587 if ($scope.datepickerMode === self.maxMode && direction === 1 ||
1588 $scope.datepickerMode === self.minMode && direction === -1) {
1592 setMode(self.modes[self.modes.indexOf($scope.datepickerMode) + direction]);
1594 $scope.$emit('uib:datepicker.mode');
1598 $scope.keys = { 13: 'enter', 32: 'space', 33: 'pageup', 34: 'pagedown', 35: 'end', 36: 'home', 37: 'left', 38: 'up', 39: 'right', 40: 'down' };
1600 var focusElement = function() {
1601 self.element[0].focus();
1604 // Listen for focus requests from popup directive
1605 $scope.$on('uib:datepicker.focus', focusElement);
1607 $scope.keydown = function(evt) {
1608 var key = $scope.keys[evt.which];
1610 if (!key || evt.shiftKey || evt.altKey || $scope.disabled) {
1614 evt.preventDefault();
1615 if (!self.shortcutPropagation) {
1616 evt.stopPropagation();
1619 if (key === 'enter' || key === 'space') {
1620 if (self.isDisabled(self.activeDate)) {
1621 return; // do nothing
1623 $scope.select(self.activeDate);
1624 } else if (evt.ctrlKey && (key === 'up' || key === 'down')) {
1625 $scope.toggleMode(key === 'up' ? 1 : -1);
1627 self.handleKeyDown(key, evt);
1632 $scope.$on('$destroy', function() {
1633 //Clear all watch listeners on destroy
1634 while (watchListeners.length) {
1635 watchListeners.shift()();
1639 function setMode(mode) {
1640 $scope.datepickerMode = mode;
1641 $scope.datepickerOptions.datepickerMode = mode;
1645 .controller('UibDaypickerController', ['$scope', '$element', 'dateFilter', function(scope, $element, dateFilter) {
1646 var DAYS_IN_MONTH = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
1648 this.step = { months: 1 };
1649 this.element = $element;
1650 function getDaysInMonth(year, month) {
1651 return month === 1 && year % 4 === 0 &&
1652 (year % 100 !== 0 || year % 400 === 0) ? 29 : DAYS_IN_MONTH[month];
1655 this.init = function(ctrl) {
1656 angular.extend(ctrl, this);
1657 scope.showWeeks = ctrl.showWeeks;
1661 this.getDates = function(startDate, n) {
1662 var dates = new Array(n), current = new Date(startDate), i = 0, date;
1664 date = new Date(current);
1666 current.setDate(current.getDate() + 1);
1671 this._refreshView = function() {
1672 var year = this.activeDate.getFullYear(),
1673 month = this.activeDate.getMonth(),
1674 firstDayOfMonth = new Date(this.activeDate);
1676 firstDayOfMonth.setFullYear(year, month, 1);
1678 var difference = this.startingDay - firstDayOfMonth.getDay(),
1679 numDisplayedFromPreviousMonth = difference > 0 ?
1680 7 - difference : - difference,
1681 firstDate = new Date(firstDayOfMonth);
1683 if (numDisplayedFromPreviousMonth > 0) {
1684 firstDate.setDate(-numDisplayedFromPreviousMonth + 1);
1687 // 42 is the number of days on a six-week calendar
1688 var days = this.getDates(firstDate, 42);
1689 for (var i = 0; i < 42; i ++) {
1690 days[i] = angular.extend(this.createDateObject(days[i], this.formatDay), {
1691 secondary: days[i].getMonth() !== month,
1692 uid: scope.uniqueId + '-' + i
1696 scope.labels = new Array(7);
1697 for (var j = 0; j < 7; j++) {
1699 abbr: dateFilter(days[j].date, this.formatDayHeader),
1700 full: dateFilter(days[j].date, 'EEEE')
1704 scope.title = dateFilter(this.activeDate, this.formatDayTitle);
1705 scope.rows = this.split(days, 7);
1707 if (scope.showWeeks) {
1708 scope.weekNumbers = [];
1709 var thursdayIndex = (4 + 7 - this.startingDay) % 7,
1710 numWeeks = scope.rows.length;
1711 for (var curWeek = 0; curWeek < numWeeks; curWeek++) {
1712 scope.weekNumbers.push(
1713 getISO8601WeekNumber(scope.rows[curWeek][thursdayIndex].date));
1718 this.compare = function(date1, date2) {
1719 var _date1 = new Date(date1.getFullYear(), date1.getMonth(), date1.getDate());
1720 var _date2 = new Date(date2.getFullYear(), date2.getMonth(), date2.getDate());
1721 _date1.setFullYear(date1.getFullYear());
1722 _date2.setFullYear(date2.getFullYear());
1723 return _date1 - _date2;
1726 function getISO8601WeekNumber(date) {
1727 var checkDate = new Date(date);
1728 checkDate.setDate(checkDate.getDate() + 4 - (checkDate.getDay() || 7)); // Thursday
1729 var time = checkDate.getTime();
1730 checkDate.setMonth(0); // Compare with Jan 1
1731 checkDate.setDate(1);
1732 return Math.floor(Math.round((time - checkDate) / 86400000) / 7) + 1;
1735 this.handleKeyDown = function(key, evt) {
1736 var date = this.activeDate.getDate();
1738 if (key === 'left') {
1740 } else if (key === 'up') {
1742 } else if (key === 'right') {
1744 } else if (key === 'down') {
1746 } else if (key === 'pageup' || key === 'pagedown') {
1747 var month = this.activeDate.getMonth() + (key === 'pageup' ? - 1 : 1);
1748 this.activeDate.setMonth(month, 1);
1749 date = Math.min(getDaysInMonth(this.activeDate.getFullYear(), this.activeDate.getMonth()), date);
1750 } else if (key === 'home') {
1752 } else if (key === 'end') {
1753 date = getDaysInMonth(this.activeDate.getFullYear(), this.activeDate.getMonth());
1755 this.activeDate.setDate(date);
1759 .controller('UibMonthpickerController', ['$scope', '$element', 'dateFilter', function(scope, $element, dateFilter) {
1760 this.step = { years: 1 };
1761 this.element = $element;
1763 this.init = function(ctrl) {
1764 angular.extend(ctrl, this);
1768 this._refreshView = function() {
1769 var months = new Array(12),
1770 year = this.activeDate.getFullYear(),
1773 for (var i = 0; i < 12; i++) {
1774 date = new Date(this.activeDate);
1775 date.setFullYear(year, i, 1);
1776 months[i] = angular.extend(this.createDateObject(date, this.formatMonth), {
1777 uid: scope.uniqueId + '-' + i
1781 scope.title = dateFilter(this.activeDate, this.formatMonthTitle);
1782 scope.rows = this.split(months, 3);
1785 this.compare = function(date1, date2) {
1786 var _date1 = new Date(date1.getFullYear(), date1.getMonth());
1787 var _date2 = new Date(date2.getFullYear(), date2.getMonth());
1788 _date1.setFullYear(date1.getFullYear());
1789 _date2.setFullYear(date2.getFullYear());
1790 return _date1 - _date2;
1793 this.handleKeyDown = function(key, evt) {
1794 var date = this.activeDate.getMonth();
1796 if (key === 'left') {
1798 } else if (key === 'up') {
1800 } else if (key === 'right') {
1802 } else if (key === 'down') {
1804 } else if (key === 'pageup' || key === 'pagedown') {
1805 var year = this.activeDate.getFullYear() + (key === 'pageup' ? - 1 : 1);
1806 this.activeDate.setFullYear(year);
1807 } else if (key === 'home') {
1809 } else if (key === 'end') {
1812 this.activeDate.setMonth(date);
1816 .controller('UibYearpickerController', ['$scope', '$element', 'dateFilter', function(scope, $element, dateFilter) {
1818 this.element = $element;
1820 function getStartingYear(year) {
1821 return parseInt((year - 1) / range, 10) * range + 1;
1824 this.yearpickerInit = function() {
1825 columns = this.yearColumns;
1826 range = this.yearRows * columns;
1827 this.step = { years: range };
1830 this._refreshView = function() {
1831 var years = new Array(range), date;
1833 for (var i = 0, start = getStartingYear(this.activeDate.getFullYear()); i < range; i++) {
1834 date = new Date(this.activeDate);
1835 date.setFullYear(start + i, 0, 1);
1836 years[i] = angular.extend(this.createDateObject(date, this.formatYear), {
1837 uid: scope.uniqueId + '-' + i
1841 scope.title = [years[0].label, years[range - 1].label].join(' - ');
1842 scope.rows = this.split(years, columns);
1843 scope.columns = columns;
1846 this.compare = function(date1, date2) {
1847 return date1.getFullYear() - date2.getFullYear();
1850 this.handleKeyDown = function(key, evt) {
1851 var date = this.activeDate.getFullYear();
1853 if (key === 'left') {
1855 } else if (key === 'up') {
1856 date = date - columns;
1857 } else if (key === 'right') {
1859 } else if (key === 'down') {
1860 date = date + columns;
1861 } else if (key === 'pageup' || key === 'pagedown') {
1862 date += (key === 'pageup' ? - 1 : 1) * range;
1863 } else if (key === 'home') {
1864 date = getStartingYear(this.activeDate.getFullYear());
1865 } else if (key === 'end') {
1866 date = getStartingYear(this.activeDate.getFullYear()) + range - 1;
1868 this.activeDate.setFullYear(date);
1872 .directive('uibDatepicker', function() {
1875 templateUrl: function(element, attrs) {
1876 return attrs.templateUrl || 'uib/template/datepicker/datepicker.html';
1879 datepickerOptions: '=?'
1881 require: ['uibDatepicker', '^ngModel'],
1882 controller: 'UibDatepickerController',
1883 controllerAs: 'datepicker',
1884 link: function(scope, element, attrs, ctrls) {
1885 var datepickerCtrl = ctrls[0], ngModelCtrl = ctrls[1];
1887 datepickerCtrl.init(ngModelCtrl);
1892 .directive('uibDaypicker', function() {
1895 templateUrl: function(element, attrs) {
1896 return attrs.templateUrl || 'uib/template/datepicker/day.html';
1898 require: ['^uibDatepicker', 'uibDaypicker'],
1899 controller: 'UibDaypickerController',
1900 link: function(scope, element, attrs, ctrls) {
1901 var datepickerCtrl = ctrls[0],
1902 daypickerCtrl = ctrls[1];
1904 daypickerCtrl.init(datepickerCtrl);
1909 .directive('uibMonthpicker', function() {
1912 templateUrl: function(element, attrs) {
1913 return attrs.templateUrl || 'uib/template/datepicker/month.html';
1915 require: ['^uibDatepicker', 'uibMonthpicker'],
1916 controller: 'UibMonthpickerController',
1917 link: function(scope, element, attrs, ctrls) {
1918 var datepickerCtrl = ctrls[0],
1919 monthpickerCtrl = ctrls[1];
1921 monthpickerCtrl.init(datepickerCtrl);
1926 .directive('uibYearpicker', function() {
1929 templateUrl: function(element, attrs) {
1930 return attrs.templateUrl || 'uib/template/datepicker/year.html';
1932 require: ['^uibDatepicker', 'uibYearpicker'],
1933 controller: 'UibYearpickerController',
1934 link: function(scope, element, attrs, ctrls) {
1935 var ctrl = ctrls[0];
1936 angular.extend(ctrl, ctrls[1]);
1937 ctrl.yearpickerInit();
1944 angular.module('ui.bootstrap.position', [])
1947 * A set of utility methods for working with the DOM.
1948 * It is meant to be used where we need to absolute-position elements in
1949 * relation to another element (this is the case for tooltips, popovers,
1950 * typeahead suggestions etc.).
1952 .factory('$uibPosition', ['$document', '$window', function($document, $window) {
1954 * Used by scrollbarWidth() function to cache scrollbar's width.
1955 * Do not access this variable directly, use scrollbarWidth() instead.
1957 var SCROLLBAR_WIDTH;
1959 * scrollbar on body and html element in IE and Edge overlay
1960 * content and should be considered 0 width.
1962 var BODY_SCROLLBAR_WIDTH;
1963 var OVERFLOW_REGEX = {
1964 normal: /(auto|scroll)/,
1965 hidden: /(auto|scroll|hidden)/
1967 var PLACEMENT_REGEX = {
1968 auto: /\s?auto?\s?/i,
1969 primary: /^(top|bottom|left|right)$/,
1970 secondary: /^(top|bottom|left|right|center)$/,
1971 vertical: /^(top|bottom)$/
1973 var BODY_REGEX = /(HTML|BODY)/;
1978 * Provides a raw DOM element from a jQuery/jQLite element.
1980 * @param {element} elem - The element to convert.
1982 * @returns {element} A HTML element.
1984 getRawNode: function(elem) {
1985 return elem.nodeName ? elem : elem[0] || elem;
1989 * Provides a parsed number for a style property. Strips
1990 * units and casts invalid numbers to 0.
1992 * @param {string} value - The style value to parse.
1994 * @returns {number} A valid number.
1996 parseStyle: function(value) {
1997 value = parseFloat(value);
1998 return isFinite(value) ? value : 0;
2002 * Provides the closest positioned ancestor.
2004 * @param {element} element - The element to get the offest parent for.
2006 * @returns {element} The closest positioned ancestor.
2008 offsetParent: function(elem) {
2009 elem = this.getRawNode(elem);
2011 var offsetParent = elem.offsetParent || $document[0].documentElement;
2013 function isStaticPositioned(el) {
2014 return ($window.getComputedStyle(el).position || 'static') === 'static';
2017 while (offsetParent && offsetParent !== $document[0].documentElement && isStaticPositioned(offsetParent)) {
2018 offsetParent = offsetParent.offsetParent;
2021 return offsetParent || $document[0].documentElement;
2025 * Provides the scrollbar width, concept from TWBS measureScrollbar()
2026 * function in https://github.com/twbs/bootstrap/blob/master/js/modal.js
2027 * In IE and Edge, scollbar on body and html element overlay and should
2028 * return a width of 0.
2030 * @returns {number} The width of the browser scollbar.
2032 scrollbarWidth: function(isBody) {
2034 if (angular.isUndefined(BODY_SCROLLBAR_WIDTH)) {
2035 var bodyElem = $document.find('body');
2036 bodyElem.addClass('uib-position-body-scrollbar-measure');
2037 BODY_SCROLLBAR_WIDTH = $window.innerWidth - bodyElem[0].clientWidth;
2038 BODY_SCROLLBAR_WIDTH = isFinite(BODY_SCROLLBAR_WIDTH) ? BODY_SCROLLBAR_WIDTH : 0;
2039 bodyElem.removeClass('uib-position-body-scrollbar-measure');
2041 return BODY_SCROLLBAR_WIDTH;
2044 if (angular.isUndefined(SCROLLBAR_WIDTH)) {
2045 var scrollElem = angular.element('<div class="uib-position-scrollbar-measure"></div>');
2046 $document.find('body').append(scrollElem);
2047 SCROLLBAR_WIDTH = scrollElem[0].offsetWidth - scrollElem[0].clientWidth;
2048 SCROLLBAR_WIDTH = isFinite(SCROLLBAR_WIDTH) ? SCROLLBAR_WIDTH : 0;
2049 scrollElem.remove();
2052 return SCROLLBAR_WIDTH;
2056 * Provides the padding required on an element to replace the scrollbar.
2058 * @returns {object} An object with the following properties:
2060 * <li>**scrollbarWidth**: the width of the scrollbar</li>
2061 * <li>**widthOverflow**: whether the the width is overflowing</li>
2062 * <li>**right**: the amount of right padding on the element needed to replace the scrollbar</li>
2063 * <li>**rightOriginal**: the amount of right padding currently on the element</li>
2064 * <li>**heightOverflow**: whether the the height is overflowing</li>
2065 * <li>**bottom**: the amount of bottom padding on the element needed to replace the scrollbar</li>
2066 * <li>**bottomOriginal**: the amount of bottom padding currently on the element</li>
2069 scrollbarPadding: function(elem) {
2070 elem = this.getRawNode(elem);
2072 var elemStyle = $window.getComputedStyle(elem);
2073 var paddingRight = this.parseStyle(elemStyle.paddingRight);
2074 var paddingBottom = this.parseStyle(elemStyle.paddingBottom);
2075 var scrollParent = this.scrollParent(elem, false, true);
2076 var scrollbarWidth = this.scrollbarWidth(scrollParent, BODY_REGEX.test(scrollParent.tagName));
2078 var scrollbarWidth = 0;
2081 scrollbarWidth: scrollbarWidth,
2082 widthOverflow: scrollParent.scrollWidth > scrollParent.clientWidth,
2083 right: paddingRight + scrollbarWidth,
2084 originalRight: paddingRight,
2085 heightOverflow: scrollParent.scrollHeight > scrollParent.clientHeight,
2086 bottom: paddingBottom + scrollbarWidth,
2087 originalBottom: paddingBottom
2092 * Checks to see if the element is scrollable.
2094 * @param {element} elem - The element to check.
2095 * @param {boolean=} [includeHidden=false] - Should scroll style of 'hidden' be considered,
2098 * @returns {boolean} Whether the element is scrollable.
2100 isScrollable: function(elem, includeHidden) {
2101 elem = this.getRawNode(elem);
2103 var overflowRegex = includeHidden ? OVERFLOW_REGEX.hidden : OVERFLOW_REGEX.normal;
2104 var elemStyle = $window.getComputedStyle(elem);
2105 return overflowRegex.test(elemStyle.overflow + elemStyle.overflowY + elemStyle.overflowX);
2109 * Provides the closest scrollable ancestor.
2110 * A port of the jQuery UI scrollParent method:
2111 * https://github.com/jquery/jquery-ui/blob/master/ui/scroll-parent.js
2113 * @param {element} elem - The element to find the scroll parent of.
2114 * @param {boolean=} [includeHidden=false] - Should scroll style of 'hidden' be considered,
2116 * @param {boolean=} [includeSelf=false] - Should the element being passed be
2117 * included in the scrollable llokup.
2119 * @returns {element} A HTML element.
2121 scrollParent: function(elem, includeHidden, includeSelf) {
2122 elem = this.getRawNode(elem);
2124 var overflowRegex = includeHidden ? OVERFLOW_REGEX.hidden : OVERFLOW_REGEX.normal;
2125 var documentEl = $document[0].documentElement;
2126 var elemStyle = $window.getComputedStyle(elem);
2127 if (includeSelf && overflowRegex.test(elemStyle.overflow + elemStyle.overflowY + elemStyle.overflowX)) {
2130 var excludeStatic = elemStyle.position === 'absolute';
2131 var scrollParent = elem.parentElement || documentEl;
2133 if (scrollParent === documentEl || elemStyle.position === 'fixed') {
2137 while (scrollParent.parentElement && scrollParent !== documentEl) {
2138 var spStyle = $window.getComputedStyle(scrollParent);
2139 if (excludeStatic && spStyle.position !== 'static') {
2140 excludeStatic = false;
2143 if (!excludeStatic && overflowRegex.test(spStyle.overflow + spStyle.overflowY + spStyle.overflowX)) {
2146 scrollParent = scrollParent.parentElement;
2149 return scrollParent;
2153 * Provides read-only equivalent of jQuery's position function:
2154 * http://api.jquery.com/position/ - distance to closest positioned
2155 * ancestor. Does not account for margins by default like jQuery position.
2157 * @param {element} elem - The element to caclulate the position on.
2158 * @param {boolean=} [includeMargins=false] - Should margins be accounted
2159 * for, default is false.
2161 * @returns {object} An object with the following properties:
2163 * <li>**width**: the width of the element</li>
2164 * <li>**height**: the height of the element</li>
2165 * <li>**top**: distance to top edge of offset parent</li>
2166 * <li>**left**: distance to left edge of offset parent</li>
2169 position: function(elem, includeMagins) {
2170 elem = this.getRawNode(elem);
2172 var elemOffset = this.offset(elem);
2173 if (includeMagins) {
2174 var elemStyle = $window.getComputedStyle(elem);
2175 elemOffset.top -= this.parseStyle(elemStyle.marginTop);
2176 elemOffset.left -= this.parseStyle(elemStyle.marginLeft);
2178 var parent = this.offsetParent(elem);
2179 var parentOffset = {top: 0, left: 0};
2181 if (parent !== $document[0].documentElement) {
2182 parentOffset = this.offset(parent);
2183 parentOffset.top += parent.clientTop - parent.scrollTop;
2184 parentOffset.left += parent.clientLeft - parent.scrollLeft;
2188 width: Math.round(angular.isNumber(elemOffset.width) ? elemOffset.width : elem.offsetWidth),
2189 height: Math.round(angular.isNumber(elemOffset.height) ? elemOffset.height : elem.offsetHeight),
2190 top: Math.round(elemOffset.top - parentOffset.top),
2191 left: Math.round(elemOffset.left - parentOffset.left)
2196 * Provides read-only equivalent of jQuery's offset function:
2197 * http://api.jquery.com/offset/ - distance to viewport. Does
2198 * not account for borders, margins, or padding on the body
2201 * @param {element} elem - The element to calculate the offset on.
2203 * @returns {object} An object with the following properties:
2205 * <li>**width**: the width of the element</li>
2206 * <li>**height**: the height of the element</li>
2207 * <li>**top**: distance to top edge of viewport</li>
2208 * <li>**right**: distance to bottom edge of viewport</li>
2211 offset: function(elem) {
2212 elem = this.getRawNode(elem);
2214 var elemBCR = elem.getBoundingClientRect();
2216 width: Math.round(angular.isNumber(elemBCR.width) ? elemBCR.width : elem.offsetWidth),
2217 height: Math.round(angular.isNumber(elemBCR.height) ? elemBCR.height : elem.offsetHeight),
2218 top: Math.round(elemBCR.top + ($window.pageYOffset || $document[0].documentElement.scrollTop)),
2219 left: Math.round(elemBCR.left + ($window.pageXOffset || $document[0].documentElement.scrollLeft))
2224 * Provides offset distance to the closest scrollable ancestor
2225 * or viewport. Accounts for border and scrollbar width.
2227 * Right and bottom dimensions represent the distance to the
2228 * respective edge of the viewport element. If the element
2229 * edge extends beyond the viewport, a negative value will be
2232 * @param {element} elem - The element to get the viewport offset for.
2233 * @param {boolean=} [useDocument=false] - Should the viewport be the document element instead
2234 * of the first scrollable element, default is false.
2235 * @param {boolean=} [includePadding=true] - Should the padding on the offset parent element
2236 * be accounted for, default is true.
2238 * @returns {object} An object with the following properties:
2240 * <li>**top**: distance to the top content edge of viewport element</li>
2241 * <li>**bottom**: distance to the bottom content edge of viewport element</li>
2242 * <li>**left**: distance to the left content edge of viewport element</li>
2243 * <li>**right**: distance to the right content edge of viewport element</li>
2246 viewportOffset: function(elem, useDocument, includePadding) {
2247 elem = this.getRawNode(elem);
2248 includePadding = includePadding !== false ? true : false;
2250 var elemBCR = elem.getBoundingClientRect();
2251 var offsetBCR = {top: 0, left: 0, bottom: 0, right: 0};
2253 var offsetParent = useDocument ? $document[0].documentElement : this.scrollParent(elem);
2254 var offsetParentBCR = offsetParent.getBoundingClientRect();
2256 offsetBCR.top = offsetParentBCR.top + offsetParent.clientTop;
2257 offsetBCR.left = offsetParentBCR.left + offsetParent.clientLeft;
2258 if (offsetParent === $document[0].documentElement) {
2259 offsetBCR.top += $window.pageYOffset;
2260 offsetBCR.left += $window.pageXOffset;
2262 offsetBCR.bottom = offsetBCR.top + offsetParent.clientHeight;
2263 offsetBCR.right = offsetBCR.left + offsetParent.clientWidth;
2265 if (includePadding) {
2266 var offsetParentStyle = $window.getComputedStyle(offsetParent);
2267 offsetBCR.top += this.parseStyle(offsetParentStyle.paddingTop);
2268 offsetBCR.bottom -= this.parseStyle(offsetParentStyle.paddingBottom);
2269 offsetBCR.left += this.parseStyle(offsetParentStyle.paddingLeft);
2270 offsetBCR.right -= this.parseStyle(offsetParentStyle.paddingRight);
2274 top: Math.round(elemBCR.top - offsetBCR.top),
2275 bottom: Math.round(offsetBCR.bottom - elemBCR.bottom),
2276 left: Math.round(elemBCR.left - offsetBCR.left),
2277 right: Math.round(offsetBCR.right - elemBCR.right)
2282 * Provides an array of placement values parsed from a placement string.
2283 * Along with the 'auto' indicator, supported placement strings are:
2285 * <li>top: element on top, horizontally centered on host element.</li>
2286 * <li>top-left: element on top, left edge aligned with host element left edge.</li>
2287 * <li>top-right: element on top, lerightft edge aligned with host element right edge.</li>
2288 * <li>bottom: element on bottom, horizontally centered on host element.</li>
2289 * <li>bottom-left: element on bottom, left edge aligned with host element left edge.</li>
2290 * <li>bottom-right: element on bottom, right edge aligned with host element right edge.</li>
2291 * <li>left: element on left, vertically centered on host element.</li>
2292 * <li>left-top: element on left, top edge aligned with host element top edge.</li>
2293 * <li>left-bottom: element on left, bottom edge aligned with host element bottom edge.</li>
2294 * <li>right: element on right, vertically centered on host element.</li>
2295 * <li>right-top: element on right, top edge aligned with host element top edge.</li>
2296 * <li>right-bottom: element on right, bottom edge aligned with host element bottom edge.</li>
2298 * A placement string with an 'auto' indicator is expected to be
2299 * space separated from the placement, i.e: 'auto bottom-left' If
2300 * the primary and secondary placement values do not match 'top,
2301 * bottom, left, right' then 'top' will be the primary placement and
2302 * 'center' will be the secondary placement. If 'auto' is passed, true
2303 * will be returned as the 3rd value of the array.
2305 * @param {string} placement - The placement string to parse.
2307 * @returns {array} An array with the following values
2309 * <li>**[0]**: The primary placement.</li>
2310 * <li>**[1]**: The secondary placement.</li>
2311 * <li>**[2]**: If auto is passed: true, else undefined.</li>
2314 parsePlacement: function(placement) {
2315 var autoPlace = PLACEMENT_REGEX.auto.test(placement);
2317 placement = placement.replace(PLACEMENT_REGEX.auto, '');
2320 placement = placement.split('-');
2322 placement[0] = placement[0] || 'top';
2323 if (!PLACEMENT_REGEX.primary.test(placement[0])) {
2324 placement[0] = 'top';
2327 placement[1] = placement[1] || 'center';
2328 if (!PLACEMENT_REGEX.secondary.test(placement[1])) {
2329 placement[1] = 'center';
2333 placement[2] = true;
2335 placement[2] = false;
2342 * Provides coordinates for an element to be positioned relative to
2343 * another element. Passing 'auto' as part of the placement parameter
2344 * will enable smart placement - where the element fits. i.e:
2345 * 'auto left-top' will check to see if there is enough space to the left
2346 * of the hostElem to fit the targetElem, if not place right (same for secondary
2347 * top placement). Available space is calculated using the viewportOffset
2350 * @param {element} hostElem - The element to position against.
2351 * @param {element} targetElem - The element to position.
2352 * @param {string=} [placement=top] - The placement for the targetElem,
2353 * default is 'top'. 'center' is assumed as secondary placement for
2354 * 'top', 'left', 'right', and 'bottom' placements. Available placements are:
2357 * <li>top-right</li>
2360 * <li>bottom-left</li>
2361 * <li>bottom-right</li>
2364 * <li>left-bottom</li>
2366 * <li>right-top</li>
2367 * <li>right-bottom</li>
2369 * @param {boolean=} [appendToBody=false] - Should the top and left values returned
2370 * be calculated from the body element, default is false.
2372 * @returns {object} An object with the following properties:
2374 * <li>**top**: Value for targetElem top.</li>
2375 * <li>**left**: Value for targetElem left.</li>
2376 * <li>**placement**: The resolved placement.</li>
2379 positionElements: function(hostElem, targetElem, placement, appendToBody) {
2380 hostElem = this.getRawNode(hostElem);
2381 targetElem = this.getRawNode(targetElem);
2383 // need to read from prop to support tests.
2384 var targetWidth = angular.isDefined(targetElem.offsetWidth) ? targetElem.offsetWidth : targetElem.prop('offsetWidth');
2385 var targetHeight = angular.isDefined(targetElem.offsetHeight) ? targetElem.offsetHeight : targetElem.prop('offsetHeight');
2387 placement = this.parsePlacement(placement);
2389 var hostElemPos = appendToBody ? this.offset(hostElem) : this.position(hostElem);
2390 var targetElemPos = {top: 0, left: 0, placement: ''};
2393 var viewportOffset = this.viewportOffset(hostElem, appendToBody);
2395 var targetElemStyle = $window.getComputedStyle(targetElem);
2396 var adjustedSize = {
2397 width: targetWidth + Math.round(Math.abs(this.parseStyle(targetElemStyle.marginLeft) + this.parseStyle(targetElemStyle.marginRight))),
2398 height: targetHeight + Math.round(Math.abs(this.parseStyle(targetElemStyle.marginTop) + this.parseStyle(targetElemStyle.marginBottom)))
2401 placement[0] = placement[0] === 'top' && adjustedSize.height > viewportOffset.top && adjustedSize.height <= viewportOffset.bottom ? 'bottom' :
2402 placement[0] === 'bottom' && adjustedSize.height > viewportOffset.bottom && adjustedSize.height <= viewportOffset.top ? 'top' :
2403 placement[0] === 'left' && adjustedSize.width > viewportOffset.left && adjustedSize.width <= viewportOffset.right ? 'right' :
2404 placement[0] === 'right' && adjustedSize.width > viewportOffset.right && adjustedSize.width <= viewportOffset.left ? 'left' :
2407 placement[1] = placement[1] === 'top' && adjustedSize.height - hostElemPos.height > viewportOffset.bottom && adjustedSize.height - hostElemPos.height <= viewportOffset.top ? 'bottom' :
2408 placement[1] === 'bottom' && adjustedSize.height - hostElemPos.height > viewportOffset.top && adjustedSize.height - hostElemPos.height <= viewportOffset.bottom ? 'top' :
2409 placement[1] === 'left' && adjustedSize.width - hostElemPos.width > viewportOffset.right && adjustedSize.width - hostElemPos.width <= viewportOffset.left ? 'right' :
2410 placement[1] === 'right' && adjustedSize.width - hostElemPos.width > viewportOffset.left && adjustedSize.width - hostElemPos.width <= viewportOffset.right ? 'left' :
2413 if (placement[1] === 'center') {
2414 if (PLACEMENT_REGEX.vertical.test(placement[0])) {
2415 var xOverflow = hostElemPos.width / 2 - targetWidth / 2;
2416 if (viewportOffset.left + xOverflow < 0 && adjustedSize.width - hostElemPos.width <= viewportOffset.right) {
2417 placement[1] = 'left';
2418 } else if (viewportOffset.right + xOverflow < 0 && adjustedSize.width - hostElemPos.width <= viewportOffset.left) {
2419 placement[1] = 'right';
2422 var yOverflow = hostElemPos.height / 2 - adjustedSize.height / 2;
2423 if (viewportOffset.top + yOverflow < 0 && adjustedSize.height - hostElemPos.height <= viewportOffset.bottom) {
2424 placement[1] = 'top';
2425 } else if (viewportOffset.bottom + yOverflow < 0 && adjustedSize.height - hostElemPos.height <= viewportOffset.top) {
2426 placement[1] = 'bottom';
2432 switch (placement[0]) {
2434 targetElemPos.top = hostElemPos.top - targetHeight;
2437 targetElemPos.top = hostElemPos.top + hostElemPos.height;
2440 targetElemPos.left = hostElemPos.left - targetWidth;
2443 targetElemPos.left = hostElemPos.left + hostElemPos.width;
2447 switch (placement[1]) {
2449 targetElemPos.top = hostElemPos.top;
2452 targetElemPos.top = hostElemPos.top + hostElemPos.height - targetHeight;
2455 targetElemPos.left = hostElemPos.left;
2458 targetElemPos.left = hostElemPos.left + hostElemPos.width - targetWidth;
2461 if (PLACEMENT_REGEX.vertical.test(placement[0])) {
2462 targetElemPos.left = hostElemPos.left + hostElemPos.width / 2 - targetWidth / 2;
2464 targetElemPos.top = hostElemPos.top + hostElemPos.height / 2 - targetHeight / 2;
2469 targetElemPos.top = Math.round(targetElemPos.top);
2470 targetElemPos.left = Math.round(targetElemPos.left);
2471 targetElemPos.placement = placement[1] === 'center' ? placement[0] : placement[0] + '-' + placement[1];
2473 return targetElemPos;
2477 * Provides a way for positioning tooltip & dropdown
2478 * arrows when using placement options beyond the standard
2479 * left, right, top, or bottom.
2481 * @param {element} elem - The tooltip/dropdown element.
2482 * @param {string} placement - The placement for the elem.
2484 positionArrow: function(elem, placement) {
2485 elem = this.getRawNode(elem);
2487 var innerElem = elem.querySelector('.tooltip-inner, .popover-inner');
2492 var isTooltip = angular.element(innerElem).hasClass('tooltip-inner');
2494 var arrowElem = isTooltip ? elem.querySelector('.tooltip-arrow') : elem.querySelector('.arrow');
2506 placement = this.parsePlacement(placement);
2507 if (placement[1] === 'center') {
2508 // no adjustment necessary - just reset styles
2509 angular.element(arrowElem).css(arrowCss);
2513 var borderProp = 'border-' + placement[0] + '-width';
2514 var borderWidth = $window.getComputedStyle(arrowElem)[borderProp];
2516 var borderRadiusProp = 'border-';
2517 if (PLACEMENT_REGEX.vertical.test(placement[0])) {
2518 borderRadiusProp += placement[0] + '-' + placement[1];
2520 borderRadiusProp += placement[1] + '-' + placement[0];
2522 borderRadiusProp += '-radius';
2523 var borderRadius = $window.getComputedStyle(isTooltip ? innerElem : elem)[borderRadiusProp];
2525 switch (placement[0]) {
2527 arrowCss.bottom = isTooltip ? '0' : '-' + borderWidth;
2530 arrowCss.top = isTooltip ? '0' : '-' + borderWidth;
2533 arrowCss.right = isTooltip ? '0' : '-' + borderWidth;
2536 arrowCss.left = isTooltip ? '0' : '-' + borderWidth;
2540 arrowCss[placement[1]] = borderRadius;
2542 angular.element(arrowElem).css(arrowCss);
2547 angular.module('ui.bootstrap.datepickerPopup', ['ui.bootstrap.datepicker', 'ui.bootstrap.position'])
2549 .value('$datepickerPopupLiteralWarning', true)
2551 .constant('uibDatepickerPopupConfig', {
2552 altInputFormats: [],
2553 appendToBody: false,
2555 closeOnDateSelection: true,
2557 currentText: 'Today',
2558 datepickerPopup: 'yyyy-MM-dd',
2559 datepickerPopupTemplateUrl: 'uib/template/datepickerPopup/popup.html',
2560 datepickerTemplateUrl: 'uib/template/datepicker/datepicker.html',
2563 'datetime-local': 'yyyy-MM-ddTHH:mm:ss.sss',
2567 showButtonBar: true,
2568 placement: 'auto bottom-left'
2571 .controller('UibDatepickerPopupController', ['$scope', '$element', '$attrs', '$compile', '$log', '$parse', '$window', '$document', '$rootScope', '$uibPosition', 'dateFilter', 'uibDateParser', 'uibDatepickerPopupConfig', '$timeout', 'uibDatepickerConfig', '$datepickerPopupLiteralWarning',
2572 function($scope, $element, $attrs, $compile, $log, $parse, $window, $document, $rootScope, $position, dateFilter, dateParser, datepickerPopupConfig, $timeout, datepickerConfig, $datepickerPopupLiteralWarning) {
2574 isHtml5DateInput = false;
2575 var dateFormat, closeOnDateSelection, appendToBody, onOpenFocus,
2576 datepickerPopupTemplateUrl, datepickerTemplateUrl, popupEl, datepickerEl, scrollParentEl,
2577 ngModel, ngModelOptions, $popup, altInputFormats, watchListeners = [],
2580 this.init = function(_ngModel_) {
2581 ngModel = _ngModel_;
2582 ngModelOptions = _ngModel_.$options;
2583 closeOnDateSelection = angular.isDefined($attrs.closeOnDateSelection) ?
2584 $scope.$parent.$eval($attrs.closeOnDateSelection) :
2585 datepickerPopupConfig.closeOnDateSelection;
2586 appendToBody = angular.isDefined($attrs.datepickerAppendToBody) ?
2587 $scope.$parent.$eval($attrs.datepickerAppendToBody) :
2588 datepickerPopupConfig.appendToBody;
2589 onOpenFocus = angular.isDefined($attrs.onOpenFocus) ?
2590 $scope.$parent.$eval($attrs.onOpenFocus) : datepickerPopupConfig.onOpenFocus;
2591 datepickerPopupTemplateUrl = angular.isDefined($attrs.datepickerPopupTemplateUrl) ?
2592 $attrs.datepickerPopupTemplateUrl :
2593 datepickerPopupConfig.datepickerPopupTemplateUrl;
2594 datepickerTemplateUrl = angular.isDefined($attrs.datepickerTemplateUrl) ?
2595 $attrs.datepickerTemplateUrl : datepickerPopupConfig.datepickerTemplateUrl;
2596 altInputFormats = angular.isDefined($attrs.altInputFormats) ?
2597 $scope.$parent.$eval($attrs.altInputFormats) :
2598 datepickerPopupConfig.altInputFormats;
2600 $scope.showButtonBar = angular.isDefined($attrs.showButtonBar) ?
2601 $scope.$parent.$eval($attrs.showButtonBar) :
2602 datepickerPopupConfig.showButtonBar;
2604 if (datepickerPopupConfig.html5Types[$attrs.type]) {
2605 dateFormat = datepickerPopupConfig.html5Types[$attrs.type];
2606 isHtml5DateInput = true;
2608 dateFormat = $attrs.uibDatepickerPopup || datepickerPopupConfig.datepickerPopup;
2609 $attrs.$observe('uibDatepickerPopup', function(value, oldValue) {
2610 var newDateFormat = value || datepickerPopupConfig.datepickerPopup;
2611 // Invalidate the $modelValue to ensure that formatters re-run
2612 // FIXME: Refactor when PR is merged: https://github.com/angular/angular.js/pull/10764
2613 if (newDateFormat !== dateFormat) {
2614 dateFormat = newDateFormat;
2615 ngModel.$modelValue = null;
2618 throw new Error('uibDatepickerPopup must have a date format specified.');
2625 throw new Error('uibDatepickerPopup must have a date format specified.');
2628 if (isHtml5DateInput && $attrs.uibDatepickerPopup) {
2629 throw new Error('HTML5 date input types do not support custom formats.');
2632 // popup element used to display calendar
2633 popupEl = angular.element('<div uib-datepicker-popup-wrap><div uib-datepicker></div></div>');
2634 if (ngModelOptions) {
2635 timezone = ngModelOptions.timezone;
2636 $scope.ngModelOptions = angular.copy(ngModelOptions);
2637 $scope.ngModelOptions.timezone = null;
2638 if ($scope.ngModelOptions.updateOnDefault === true) {
2639 $scope.ngModelOptions.updateOn = $scope.ngModelOptions.updateOn ?
2640 $scope.ngModelOptions.updateOn + ' default' : 'default';
2643 popupEl.attr('ng-model-options', 'ngModelOptions');
2650 'ng-change': 'dateSelection(date)',
2651 'template-url': datepickerPopupTemplateUrl
2654 // datepicker element
2655 datepickerEl = angular.element(popupEl.children()[0]);
2656 datepickerEl.attr('template-url', datepickerTemplateUrl);
2658 if (!$scope.datepickerOptions) {
2659 $scope.datepickerOptions = {};
2662 if (isHtml5DateInput) {
2663 if ($attrs.type === 'month') {
2664 $scope.datepickerOptions.datepickerMode = 'month';
2665 $scope.datepickerOptions.minMode = 'month';
2669 datepickerEl.attr('datepicker-options', 'datepickerOptions');
2671 if (!isHtml5DateInput) {
2672 // Internal API to maintain the correct ng-invalid-[key] class
2673 ngModel.$$parserName = 'date';
2674 ngModel.$validators.date = validator;
2675 ngModel.$parsers.unshift(parseDate);
2676 ngModel.$formatters.push(function(value) {
2677 if (ngModel.$isEmpty(value)) {
2678 $scope.date = value;
2682 $scope.date = dateParser.fromTimezone(value, timezone);
2684 if (angular.isNumber($scope.date)) {
2685 $scope.date = new Date($scope.date);
2688 return dateParser.filter($scope.date, dateFormat);
2691 ngModel.$formatters.push(function(value) {
2692 $scope.date = dateParser.fromTimezone(value, timezone);
2697 // Detect changes in the view from the text box
2698 ngModel.$viewChangeListeners.push(function() {
2699 $scope.date = parseDateString(ngModel.$viewValue);
2702 $element.on('keydown', inputKeydownBind);
2704 $popup = $compile(popupEl)($scope);
2705 // Prevent jQuery cache memory leak (template is now redundant after linking)
2709 $document.find('body').append($popup);
2711 $element.after($popup);
2714 $scope.$on('$destroy', function() {
2715 if ($scope.isOpen === true) {
2716 if (!$rootScope.$$phase) {
2717 $scope.$apply(function() {
2718 $scope.isOpen = false;
2724 $element.off('keydown', inputKeydownBind);
2725 $document.off('click', documentClickBind);
2726 if (scrollParentEl) {
2727 scrollParentEl.off('scroll', positionPopup);
2729 angular.element($window).off('resize', positionPopup);
2731 //Clear all watch listeners on destroy
2732 while (watchListeners.length) {
2733 watchListeners.shift()();
2738 $scope.getText = function(key) {
2739 return $scope[key + 'Text'] || datepickerPopupConfig[key + 'Text'];
2742 $scope.isDisabled = function(date) {
2743 if (date === 'today') {
2744 date = dateParser.fromTimezone(new Date(), timezone);
2748 angular.forEach(['minDate', 'maxDate'], function(key) {
2749 if (!$scope.datepickerOptions[key]) {
2751 } else if (angular.isDate($scope.datepickerOptions[key])) {
2752 dates[key] = dateParser.fromTimezone(new Date($scope.datepickerOptions[key]), timezone);
2754 if ($datepickerPopupLiteralWarning) {
2755 $log.warn('Literal date support has been deprecated, please switch to date object usage');
2758 dates[key] = new Date(dateFilter($scope.datepickerOptions[key], 'medium'));
2762 return $scope.datepickerOptions &&
2763 dates.minDate && $scope.compare(date, dates.minDate) < 0 ||
2764 dates.maxDate && $scope.compare(date, dates.maxDate) > 0;
2767 $scope.compare = function(date1, date2) {
2768 return new Date(date1.getFullYear(), date1.getMonth(), date1.getDate()) - new Date(date2.getFullYear(), date2.getMonth(), date2.getDate());
2772 $scope.dateSelection = function(dt) {
2773 if (angular.isDefined(dt)) {
2776 var date = $scope.date ? dateParser.filter($scope.date, dateFormat) : null; // Setting to NULL is necessary for form validators to function
2778 ngModel.$setViewValue(date);
2780 if (closeOnDateSelection) {
2781 $scope.isOpen = false;
2782 $element[0].focus();
2786 $scope.keydown = function(evt) {
2787 if (evt.which === 27) {
2788 evt.stopPropagation();
2789 $scope.isOpen = false;
2790 $element[0].focus();
2794 $scope.select = function(date, evt) {
2795 evt.stopPropagation();
2797 if (date === 'today') {
2798 var today = new Date();
2799 if (angular.isDate($scope.date)) {
2800 date = new Date($scope.date);
2801 date.setFullYear(today.getFullYear(), today.getMonth(), today.getDate());
2803 date = new Date(today.setHours(0, 0, 0, 0));
2806 $scope.dateSelection(date);
2809 $scope.close = function(evt) {
2810 evt.stopPropagation();
2812 $scope.isOpen = false;
2813 $element[0].focus();
2816 $scope.disabled = angular.isDefined($attrs.disabled) || false;
2817 if ($attrs.ngDisabled) {
2818 watchListeners.push($scope.$parent.$watch($parse($attrs.ngDisabled), function(disabled) {
2819 $scope.disabled = disabled;
2823 $scope.$watch('isOpen', function(value) {
2825 if (!$scope.disabled) {
2826 $timeout(function() {
2830 $scope.$broadcast('uib:datepicker.focus');
2833 $document.on('click', documentClickBind);
2835 var placement = $attrs.popupPlacement ? $attrs.popupPlacement : datepickerPopupConfig.placement;
2836 if (appendToBody || $position.parsePlacement(placement)[2]) {
2837 scrollParentEl = scrollParentEl || angular.element($position.scrollParent($element));
2838 if (scrollParentEl) {
2839 scrollParentEl.on('scroll', positionPopup);
2842 scrollParentEl = null;
2845 angular.element($window).on('resize', positionPopup);
2848 $scope.isOpen = false;
2851 $document.off('click', documentClickBind);
2852 if (scrollParentEl) {
2853 scrollParentEl.off('scroll', positionPopup);
2855 angular.element($window).off('resize', positionPopup);
2859 function cameltoDash(string) {
2860 return string.replace(/([A-Z])/g, function($1) { return '-' + $1.toLowerCase(); });
2863 function parseDateString(viewValue) {
2864 var date = dateParser.parse(viewValue, dateFormat, $scope.date);
2866 for (var i = 0; i < altInputFormats.length; i++) {
2867 date = dateParser.parse(viewValue, altInputFormats[i], $scope.date);
2876 function parseDate(viewValue) {
2877 if (angular.isNumber(viewValue)) {
2878 // presumably timestamp to date object
2879 viewValue = new Date(viewValue);
2886 if (angular.isDate(viewValue) && !isNaN(viewValue)) {
2890 if (angular.isString(viewValue)) {
2891 var date = parseDateString(viewValue);
2893 return dateParser.toTimezone(date, timezone);
2897 return ngModel.$options && ngModel.$options.allowInvalid ? viewValue : undefined;
2900 function validator(modelValue, viewValue) {
2901 var value = modelValue || viewValue;
2903 if (!$attrs.ngRequired && !value) {
2907 if (angular.isNumber(value)) {
2908 value = new Date(value);
2915 if (angular.isDate(value) && !isNaN(value)) {
2919 if (angular.isString(value)) {
2920 return !isNaN(parseDateString(viewValue));
2926 function documentClickBind(event) {
2927 if (!$scope.isOpen && $scope.disabled) {
2931 var popup = $popup[0];
2932 var dpContainsTarget = $element[0].contains(event.target);
2933 // The popup node may not be an element node
2934 // In some browsers (IE) only element nodes have the 'contains' function
2935 var popupContainsTarget = popup.contains !== undefined && popup.contains(event.target);
2936 if ($scope.isOpen && !(dpContainsTarget || popupContainsTarget)) {
2937 $scope.$apply(function() {
2938 $scope.isOpen = false;
2943 function inputKeydownBind(evt) {
2944 if (evt.which === 27 && $scope.isOpen) {
2945 evt.preventDefault();
2946 evt.stopPropagation();
2947 $scope.$apply(function() {
2948 $scope.isOpen = false;
2950 $element[0].focus();
2951 } else if (evt.which === 40 && !$scope.isOpen) {
2952 evt.preventDefault();
2953 evt.stopPropagation();
2954 $scope.$apply(function() {
2955 $scope.isOpen = true;
2960 function positionPopup() {
2961 if ($scope.isOpen) {
2962 var dpElement = angular.element($popup[0].querySelector('.uib-datepicker-popup'));
2963 var placement = $attrs.popupPlacement ? $attrs.popupPlacement : datepickerPopupConfig.placement;
2964 var position = $position.positionElements($element, dpElement, placement, appendToBody);
2965 dpElement.css({top: position.top + 'px', left: position.left + 'px'});
2966 if (dpElement.hasClass('uib-position-measure')) {
2967 dpElement.removeClass('uib-position-measure');
2972 $scope.$on('uib:datepicker.mode', function() {
2973 $timeout(positionPopup, 0, false);
2977 .directive('uibDatepickerPopup', function() {
2979 require: ['ngModel', 'uibDatepickerPopup'],
2980 controller: 'UibDatepickerPopupController',
2982 datepickerOptions: '=?',
2988 link: function(scope, element, attrs, ctrls) {
2989 var ngModel = ctrls[0],
2997 .directive('uibDatepickerPopupWrap', function() {
3001 templateUrl: function(element, attrs) {
3002 return attrs.templateUrl || 'uib/template/datepickerPopup/popup.html';
3007 angular.module('ui.bootstrap.debounce', [])
3009 * A helper, internal service that debounces a function
3011 .factory('$$debounce', ['$timeout', function($timeout) {
3012 return function(callback, debounceTime) {
3017 var args = Array.prototype.slice.call(arguments);
3018 if (timeoutPromise) {
3019 $timeout.cancel(timeoutPromise);
3022 timeoutPromise = $timeout(function() {
3023 callback.apply(self, args);
3029 angular.module('ui.bootstrap.dropdown', ['ui.bootstrap.position'])
3031 .constant('uibDropdownConfig', {
3032 appendToOpenClass: 'uib-dropdown-open',
3036 .service('uibDropdownService', ['$document', '$rootScope', function($document, $rootScope) {
3037 var openScope = null;
3039 this.open = function(dropdownScope, element) {
3041 $document.on('click', closeDropdown);
3042 element.on('keydown', keybindFilter);
3045 if (openScope && openScope !== dropdownScope) {
3046 openScope.isOpen = false;
3049 openScope = dropdownScope;
3052 this.close = function(dropdownScope, element) {
3053 if (openScope === dropdownScope) {
3055 $document.off('click', closeDropdown);
3056 element.off('keydown', keybindFilter);
3060 var closeDropdown = function(evt) {
3061 // This method may still be called during the same mouse event that
3062 // unbound this event handler. So check openScope before proceeding.
3063 if (!openScope) { return; }
3065 if (evt && openScope.getAutoClose() === 'disabled') { return; }
3067 if (evt && evt.which === 3) { return; }
3069 var toggleElement = openScope.getToggleElement();
3070 if (evt && toggleElement && toggleElement[0].contains(evt.target)) {
3074 var dropdownElement = openScope.getDropdownElement();
3075 if (evt && openScope.getAutoClose() === 'outsideClick' &&
3076 dropdownElement && dropdownElement[0].contains(evt.target)) {
3080 openScope.isOpen = false;
3082 if (!$rootScope.$$phase) {
3087 var keybindFilter = function(evt) {
3088 if (evt.which === 27) {
3089 evt.stopPropagation();
3090 openScope.focusToggleElement();
3092 } else if (openScope.isKeynavEnabled() && [38, 40].indexOf(evt.which) !== -1 && openScope.isOpen) {
3093 evt.preventDefault();
3094 evt.stopPropagation();
3095 openScope.focusDropdownEntry(evt.which);
3100 .controller('UibDropdownController', ['$scope', '$element', '$attrs', '$parse', 'uibDropdownConfig', 'uibDropdownService', '$animate', '$uibPosition', '$document', '$compile', '$templateRequest', function($scope, $element, $attrs, $parse, dropdownConfig, uibDropdownService, $animate, $position, $document, $compile, $templateRequest) {
3102 scope = $scope.$new(), // create a child scope so we are not polluting original one
3104 appendToOpenClass = dropdownConfig.appendToOpenClass,
3105 openClass = dropdownConfig.openClass,
3107 setIsOpen = angular.noop,
3108 toggleInvoker = $attrs.onToggle ? $parse($attrs.onToggle) : angular.noop,
3109 appendToBody = false,
3111 keynavEnabled = false,
3112 selectedOption = null,
3113 body = $document.find('body');
3115 $element.addClass('dropdown');
3117 this.init = function() {
3118 if ($attrs.isOpen) {
3119 getIsOpen = $parse($attrs.isOpen);
3120 setIsOpen = getIsOpen.assign;
3122 $scope.$watch(getIsOpen, function(value) {
3123 scope.isOpen = !!value;
3127 if (angular.isDefined($attrs.dropdownAppendTo)) {
3128 var appendToEl = $parse($attrs.dropdownAppendTo)(scope);
3130 appendTo = angular.element(appendToEl);
3134 appendToBody = angular.isDefined($attrs.dropdownAppendToBody);
3135 keynavEnabled = angular.isDefined($attrs.keyboardNav);
3137 if (appendToBody && !appendTo) {
3141 if (appendTo && self.dropdownMenu) {
3142 appendTo.append(self.dropdownMenu);
3143 $element.on('$destroy', function handleDestroyEvent() {
3144 self.dropdownMenu.remove();
3149 this.toggle = function(open) {
3150 scope.isOpen = arguments.length ? !!open : !scope.isOpen;
3151 if (angular.isFunction(setIsOpen)) {
3152 setIsOpen(scope, scope.isOpen);
3155 return scope.isOpen;
3158 // Allow other directives to watch status
3159 this.isOpen = function() {
3160 return scope.isOpen;
3163 scope.getToggleElement = function() {
3164 return self.toggleElement;
3167 scope.getAutoClose = function() {
3168 return $attrs.autoClose || 'always'; //or 'outsideClick' or 'disabled'
3171 scope.getElement = function() {
3175 scope.isKeynavEnabled = function() {
3176 return keynavEnabled;
3179 scope.focusDropdownEntry = function(keyCode) {
3180 var elems = self.dropdownMenu ? //If append to body is used.
3181 angular.element(self.dropdownMenu).find('a') :
3182 $element.find('ul').eq(0).find('a');
3186 if (!angular.isNumber(self.selectedOption)) {
3187 self.selectedOption = 0;
3189 self.selectedOption = self.selectedOption === elems.length - 1 ?
3190 self.selectedOption :
3191 self.selectedOption + 1;
3196 if (!angular.isNumber(self.selectedOption)) {
3197 self.selectedOption = elems.length - 1;
3199 self.selectedOption = self.selectedOption === 0 ?
3200 0 : self.selectedOption - 1;
3205 elems[self.selectedOption].focus();
3208 scope.getDropdownElement = function() {
3209 return self.dropdownMenu;
3212 scope.focusToggleElement = function() {
3213 if (self.toggleElement) {
3214 self.toggleElement[0].focus();
3218 scope.$watch('isOpen', function(isOpen, wasOpen) {
3219 if (appendTo && self.dropdownMenu) {
3220 var pos = $position.positionElements($element, self.dropdownMenu, 'bottom-left', true),
3225 top: pos.top + 'px',
3226 display: isOpen ? 'block' : 'none'
3229 rightalign = self.dropdownMenu.hasClass('dropdown-menu-right');
3231 css.left = pos.left + 'px';
3235 css.right = window.innerWidth -
3236 (pos.left + $element.prop('offsetWidth')) + 'px';
3239 // Need to adjust our positioning to be relative to the appendTo container
3240 // if it's not the body element
3241 if (!appendToBody) {
3242 var appendOffset = $position.offset(appendTo);
3244 css.top = pos.top - appendOffset.top + 'px';
3247 css.left = pos.left - appendOffset.left + 'px';
3249 css.right = window.innerWidth -
3250 (pos.left - appendOffset.left + $element.prop('offsetWidth')) + 'px';
3254 self.dropdownMenu.css(css);
3257 var openContainer = appendTo ? appendTo : $element;
3258 var hasOpenClass = openContainer.hasClass(appendTo ? appendToOpenClass : openClass);
3260 if (hasOpenClass === !isOpen) {
3261 $animate[isOpen ? 'addClass' : 'removeClass'](openContainer, appendTo ? appendToOpenClass : openClass).then(function() {
3262 if (angular.isDefined(isOpen) && isOpen !== wasOpen) {
3263 toggleInvoker($scope, { open: !!isOpen });
3269 if (self.dropdownMenuTemplateUrl) {
3270 $templateRequest(self.dropdownMenuTemplateUrl).then(function(tplContent) {
3271 templateScope = scope.$new();
3272 $compile(tplContent.trim())(templateScope, function(dropdownElement) {
3273 var newEl = dropdownElement;
3274 self.dropdownMenu.replaceWith(newEl);
3275 self.dropdownMenu = newEl;
3280 scope.focusToggleElement();
3281 uibDropdownService.open(scope, $element);
3283 if (self.dropdownMenuTemplateUrl) {
3284 if (templateScope) {
3285 templateScope.$destroy();
3287 var newEl = angular.element('<ul class="dropdown-menu"></ul>');
3288 self.dropdownMenu.replaceWith(newEl);
3289 self.dropdownMenu = newEl;
3292 uibDropdownService.close(scope, $element);
3293 self.selectedOption = null;
3296 if (angular.isFunction(setIsOpen)) {
3297 setIsOpen($scope, isOpen);
3302 .directive('uibDropdown', function() {
3304 controller: 'UibDropdownController',
3305 link: function(scope, element, attrs, dropdownCtrl) {
3306 dropdownCtrl.init();
3311 .directive('uibDropdownMenu', function() {
3314 require: '?^uibDropdown',
3315 link: function(scope, element, attrs, dropdownCtrl) {
3316 if (!dropdownCtrl || angular.isDefined(attrs.dropdownNested)) {
3320 element.addClass('dropdown-menu');
3322 var tplUrl = attrs.templateUrl;
3324 dropdownCtrl.dropdownMenuTemplateUrl = tplUrl;
3327 if (!dropdownCtrl.dropdownMenu) {
3328 dropdownCtrl.dropdownMenu = element;
3334 .directive('uibDropdownToggle', function() {
3336 require: '?^uibDropdown',
3337 link: function(scope, element, attrs, dropdownCtrl) {
3338 if (!dropdownCtrl) {
3342 element.addClass('dropdown-toggle');
3344 dropdownCtrl.toggleElement = element;
3346 var toggleDropdown = function(event) {
3347 event.preventDefault();
3349 if (!element.hasClass('disabled') && !attrs.disabled) {
3350 scope.$apply(function() {
3351 dropdownCtrl.toggle();
3356 element.bind('click', toggleDropdown);
3359 element.attr({ 'aria-haspopup': true, 'aria-expanded': false });
3360 scope.$watch(dropdownCtrl.isOpen, function(isOpen) {
3361 element.attr('aria-expanded', !!isOpen);
3364 scope.$on('$destroy', function() {
3365 element.unbind('click', toggleDropdown);
3371 angular.module('ui.bootstrap.stackedMap', [])
3373 * A helper, internal data structure that acts as a map but also allows getting / removing
3374 * elements in the LIFO order
3376 .factory('$$stackedMap', function() {
3378 createNew: function() {
3382 add: function(key, value) {
3388 get: function(key) {
3389 for (var i = 0; i < stack.length; i++) {
3390 if (key === stack[i].key) {
3397 for (var i = 0; i < stack.length; i++) {
3398 keys.push(stack[i].key);
3403 return stack[stack.length - 1];
3405 remove: function(key) {
3407 for (var i = 0; i < stack.length; i++) {
3408 if (key === stack[i].key) {
3413 return stack.splice(idx, 1)[0];
3415 removeTop: function() {
3416 return stack.splice(stack.length - 1, 1)[0];
3418 length: function() {
3419 return stack.length;
3425 angular.module('ui.bootstrap.modal', ['ui.bootstrap.stackedMap', 'ui.bootstrap.position'])
3427 * A helper, internal data structure that stores all references attached to key
3429 .factory('$$multiMap', function() {
3431 createNew: function() {
3435 entries: function() {
3436 return Object.keys(map).map(function(key) {
3443 get: function(key) {
3446 hasKey: function(key) {
3450 return Object.keys(map);
3452 put: function(key, value) {
3457 map[key].push(value);
3459 remove: function(key, value) {
3460 var values = map[key];
3466 var idx = values.indexOf(value);
3469 values.splice(idx, 1);
3472 if (!values.length) {
3482 * Pluggable resolve mechanism for the modal resolve resolution
3483 * Supports UI Router's $resolve service
3485 .provider('$uibResolve', function() {
3487 this.resolver = null;
3489 this.setResolver = function(resolver) {
3490 this.resolver = resolver;
3493 this.$get = ['$injector', '$q', function($injector, $q) {
3494 var resolver = resolve.resolver ? $injector.get(resolve.resolver) : null;
3496 resolve: function(invocables, locals, parent, self) {
3498 return resolver.resolve(invocables, locals, parent, self);
3503 angular.forEach(invocables, function(value) {
3504 if (angular.isFunction(value) || angular.isArray(value)) {
3505 promises.push($q.resolve($injector.invoke(value)));
3506 } else if (angular.isString(value)) {
3507 promises.push($q.resolve($injector.get(value)));
3509 promises.push($q.resolve(value));
3513 return $q.all(promises).then(function(resolves) {
3514 var resolveObj = {};
3515 var resolveIter = 0;
3516 angular.forEach(invocables, function(value, key) {
3517 resolveObj[key] = resolves[resolveIter++];
3528 * A helper directive for the $modal service. It creates a backdrop element.
3530 .directive('uibModalBackdrop', ['$animate', '$injector', '$uibModalStack',
3531 function($animate, $injector, $modalStack) {
3534 templateUrl: 'uib/template/modal/backdrop.html',
3535 compile: function(tElement, tAttrs) {
3536 tElement.addClass(tAttrs.backdropClass);
3541 function linkFn(scope, element, attrs) {
3542 if (attrs.modalInClass) {
3543 $animate.addClass(element, attrs.modalInClass);
3545 scope.$on($modalStack.NOW_CLOSING_EVENT, function(e, setIsAsync) {
3546 var done = setIsAsync();
3547 if (scope.modalOptions.animation) {
3548 $animate.removeClass(element, attrs.modalInClass).then(done);
3557 .directive('uibModalWindow', ['$uibModalStack', '$q', '$animateCss', '$document',
3558 function($modalStack, $q, $animateCss, $document) {
3565 templateUrl: function(tElement, tAttrs) {
3566 return tAttrs.templateUrl || 'uib/template/modal/window.html';
3568 link: function(scope, element, attrs) {
3569 element.addClass(attrs.windowClass || '');
3570 element.addClass(attrs.windowTopClass || '');
3571 scope.size = attrs.size;
3573 scope.close = function(evt) {
3574 var modal = $modalStack.getTop();
3575 if (modal && modal.value.backdrop &&
3576 modal.value.backdrop !== 'static' &&
3577 evt.target === evt.currentTarget) {
3578 evt.preventDefault();
3579 evt.stopPropagation();
3580 $modalStack.dismiss(modal.key, 'backdrop click');
3584 // moved from template to fix issue #2280
3585 element.on('click', scope.close);
3587 // This property is only added to the scope for the purpose of detecting when this directive is rendered.
3588 // We can detect that by using this property in the template associated with this directive and then use
3589 // {@link Attribute#$observe} on it. For more details please see {@link TableColumnResize}.
3590 scope.$isRendered = true;
3592 // Deferred object that will be resolved when this modal is render.
3593 var modalRenderDeferObj = $q.defer();
3594 // Observe function will be called on next digest cycle after compilation, ensuring that the DOM is ready.
3595 // In order to use this way of finding whether DOM is ready, we need to observe a scope property used in modal's template.
3596 attrs.$observe('modalRender', function(value) {
3597 if (value === 'true') {
3598 modalRenderDeferObj.resolve();
3602 modalRenderDeferObj.promise.then(function() {
3603 var animationPromise = null;
3605 if (attrs.modalInClass) {
3606 animationPromise = $animateCss(element, {
3607 addClass: attrs.modalInClass
3610 scope.$on($modalStack.NOW_CLOSING_EVENT, function(e, setIsAsync) {
3611 var done = setIsAsync();
3612 $animateCss(element, {
3613 removeClass: attrs.modalInClass
3614 }).start().then(done);
3619 $q.when(animationPromise).then(function() {
3620 // Notify {@link $modalStack} that modal is rendered.
3621 var modal = $modalStack.getTop();
3623 $modalStack.modalRendered(modal.key);
3627 * If something within the freshly-opened modal already has focus (perhaps via a
3628 * directive that causes focus). then no need to try and focus anything.
3630 if (!($document[0].activeElement && element[0].contains($document[0].activeElement))) {
3631 var inputWithAutofocus = element[0].querySelector('[autofocus]');
3633 * Auto-focusing of a freshly-opened modal element causes any child elements
3634 * with the autofocus attribute to lose focus. This is an issue on touch
3635 * based devices which will show and then hide the onscreen keyboard.
3636 * Attempts to refocus the autofocus element via JavaScript will not reopen
3637 * the onscreen keyboard. Fixed by updated the focusing logic to only autofocus
3638 * the modal element if the modal does not contain an autofocus element.
3640 if (inputWithAutofocus) {
3641 inputWithAutofocus.focus();
3652 .directive('uibModalAnimationClass', function() {
3654 compile: function(tElement, tAttrs) {
3655 if (tAttrs.modalAnimation) {
3656 tElement.addClass(tAttrs.uibModalAnimationClass);
3662 .directive('uibModalTransclude', function() {
3664 link: function(scope, element, attrs, controller, transclude) {
3665 transclude(scope.$parent, function(clone) {
3667 element.append(clone);
3673 .factory('$uibModalStack', ['$animate', '$animateCss', '$document',
3674 '$compile', '$rootScope', '$q', '$$multiMap', '$$stackedMap', '$uibPosition',
3675 function($animate, $animateCss, $document, $compile, $rootScope, $q, $$multiMap, $$stackedMap, $uibPosition) {
3676 var OPENED_MODAL_CLASS = 'modal-open';
3678 var backdropDomEl, backdropScope;
3679 var openedWindows = $$stackedMap.createNew();
3680 var openedClasses = $$multiMap.createNew();
3682 NOW_CLOSING_EVENT: 'modal.stack.now-closing'
3684 var topModalIndex = 0;
3685 var previousTopOpenedModal = null;
3687 //Modal focus behavior
3688 var tabableSelector = 'a[href], area[href], input:not([disabled]), ' +
3689 'button:not([disabled]),select:not([disabled]), textarea:not([disabled]), ' +
3690 'iframe, object, embed, *[tabindex], *[contenteditable=true]';
3691 var scrollbarPadding;
3693 function isVisible(element) {
3694 return !!(element.offsetWidth ||
3695 element.offsetHeight ||
3696 element.getClientRects().length);
3699 function backdropIndex() {
3700 var topBackdropIndex = -1;
3701 var opened = openedWindows.keys();
3702 for (var i = 0; i < opened.length; i++) {
3703 if (openedWindows.get(opened[i]).value.backdrop) {
3704 topBackdropIndex = i;
3708 // If any backdrop exist, ensure that it's index is always
3709 // right below the top modal
3710 if (topBackdropIndex > -1 && topBackdropIndex < topModalIndex) {
3711 topBackdropIndex = topModalIndex;
3713 return topBackdropIndex;
3716 $rootScope.$watch(backdropIndex, function(newBackdropIndex) {
3717 if (backdropScope) {
3718 backdropScope.index = newBackdropIndex;
3722 function removeModalWindow(modalInstance, elementToReceiveFocus) {
3723 var modalWindow = openedWindows.get(modalInstance).value;
3724 var appendToElement = modalWindow.appendTo;
3726 //clean up the stack
3727 openedWindows.remove(modalInstance);
3728 previousTopOpenedModal = openedWindows.top();
3729 if (previousTopOpenedModal) {
3730 topModalIndex = parseInt(previousTopOpenedModal.value.modalDomEl.attr('index'), 10);
3733 removeAfterAnimate(modalWindow.modalDomEl, modalWindow.modalScope, function() {
3734 var modalBodyClass = modalWindow.openedClass || OPENED_MODAL_CLASS;
3735 openedClasses.remove(modalBodyClass, modalInstance);
3736 var areAnyOpen = openedClasses.hasKey(modalBodyClass);
3737 appendToElement.toggleClass(modalBodyClass, areAnyOpen);
3738 if (!areAnyOpen && scrollbarPadding && scrollbarPadding.heightOverflow && scrollbarPadding.scrollbarWidth) {
3739 if (scrollbarPadding.originalRight) {
3740 appendToElement.css({paddingRight: scrollbarPadding.originalRight + 'px'});
3742 appendToElement.css({paddingRight: ''});
3744 scrollbarPadding = null;
3746 toggleTopWindowClass(true);
3747 }, modalWindow.closedDeferred);
3748 checkRemoveBackdrop();
3750 //move focus to specified element if available, or else to body
3751 if (elementToReceiveFocus && elementToReceiveFocus.focus) {
3752 elementToReceiveFocus.focus();
3753 } else if (appendToElement.focus) {
3754 appendToElement.focus();
3758 // Add or remove "windowTopClass" from the top window in the stack
3759 function toggleTopWindowClass(toggleSwitch) {
3762 if (openedWindows.length() > 0) {
3763 modalWindow = openedWindows.top().value;
3764 modalWindow.modalDomEl.toggleClass(modalWindow.windowTopClass || '', toggleSwitch);
3768 function checkRemoveBackdrop() {
3769 //remove backdrop if no longer needed
3770 if (backdropDomEl && backdropIndex() === -1) {
3771 var backdropScopeRef = backdropScope;
3772 removeAfterAnimate(backdropDomEl, backdropScope, function() {
3773 backdropScopeRef = null;
3775 backdropDomEl = undefined;
3776 backdropScope = undefined;
3780 function removeAfterAnimate(domEl, scope, done, closedDeferred) {
3782 var asyncPromise = null;
3783 var setIsAsync = function() {
3784 if (!asyncDeferred) {
3785 asyncDeferred = $q.defer();
3786 asyncPromise = asyncDeferred.promise;
3789 return function asyncDone() {
3790 asyncDeferred.resolve();
3793 scope.$broadcast($modalStack.NOW_CLOSING_EVENT, setIsAsync);
3795 // Note that it's intentional that asyncPromise might be null.
3796 // That's when setIsAsync has not been called during the
3797 // NOW_CLOSING_EVENT broadcast.
3798 return $q.when(asyncPromise).then(afterAnimating);
3800 function afterAnimating() {
3801 if (afterAnimating.done) {
3804 afterAnimating.done = true;
3806 $animate.leave(domEl).then(function() {
3808 if (closedDeferred) {
3809 closedDeferred.resolve();
3820 $document.on('keydown', keydownListener);
3822 $rootScope.$on('$destroy', function() {
3823 $document.off('keydown', keydownListener);
3826 function keydownListener(evt) {
3827 if (evt.isDefaultPrevented()) {
3831 var modal = openedWindows.top();
3833 switch (evt.which) {
3835 if (modal.value.keyboard) {
3836 evt.preventDefault();
3837 $rootScope.$apply(function() {
3838 $modalStack.dismiss(modal.key, 'escape key press');
3844 var list = $modalStack.loadFocusElementList(modal);
3845 var focusChanged = false;
3847 if ($modalStack.isFocusInFirstItem(evt, list) || $modalStack.isModalFocused(evt, modal)) {
3848 focusChanged = $modalStack.focusLastFocusableElement(list);
3851 if ($modalStack.isFocusInLastItem(evt, list)) {
3852 focusChanged = $modalStack.focusFirstFocusableElement(list);
3857 evt.preventDefault();
3858 evt.stopPropagation();
3867 $modalStack.open = function(modalInstance, modal) {
3868 var modalOpener = $document[0].activeElement,
3869 modalBodyClass = modal.openedClass || OPENED_MODAL_CLASS;
3871 toggleTopWindowClass(false);
3873 // Store the current top first, to determine what index we ought to use
3874 // for the current top modal
3875 previousTopOpenedModal = openedWindows.top();
3877 openedWindows.add(modalInstance, {
3878 deferred: modal.deferred,
3879 renderDeferred: modal.renderDeferred,
3880 closedDeferred: modal.closedDeferred,
3881 modalScope: modal.scope,
3882 backdrop: modal.backdrop,
3883 keyboard: modal.keyboard,
3884 openedClass: modal.openedClass,
3885 windowTopClass: modal.windowTopClass,
3886 animation: modal.animation,
3887 appendTo: modal.appendTo
3890 openedClasses.put(modalBodyClass, modalInstance);
3892 var appendToElement = modal.appendTo,
3893 currBackdropIndex = backdropIndex();
3895 if (!appendToElement.length) {
3896 throw new Error('appendTo element not found. Make sure that the element passed is in DOM.');
3899 if (currBackdropIndex >= 0 && !backdropDomEl) {
3900 backdropScope = $rootScope.$new(true);
3901 backdropScope.modalOptions = modal;
3902 backdropScope.index = currBackdropIndex;
3903 backdropDomEl = angular.element('<div uib-modal-backdrop="modal-backdrop"></div>');
3904 backdropDomEl.attr('backdrop-class', modal.backdropClass);
3905 if (modal.animation) {
3906 backdropDomEl.attr('modal-animation', 'true');
3908 $compile(backdropDomEl)(backdropScope);
3909 $animate.enter(backdropDomEl, appendToElement);
3910 scrollbarPadding = $uibPosition.scrollbarPadding(appendToElement);
3911 if (scrollbarPadding.heightOverflow && scrollbarPadding.scrollbarWidth) {
3912 appendToElement.css({paddingRight: scrollbarPadding.right + 'px'});
3916 // Set the top modal index based on the index of the previous top modal
3917 topModalIndex = previousTopOpenedModal ? parseInt(previousTopOpenedModal.value.modalDomEl.attr('index'), 10) + 1 : 0;
3918 var angularDomEl = angular.element('<div uib-modal-window="modal-window"></div>');
3920 'template-url': modal.windowTemplateUrl,
3921 'window-class': modal.windowClass,
3922 'window-top-class': modal.windowTopClass,
3924 'index': topModalIndex,
3925 'animate': 'animate'
3926 }).html(modal.content);
3927 if (modal.animation) {
3928 angularDomEl.attr('modal-animation', 'true');
3931 appendToElement.addClass(modalBodyClass);
3932 $animate.enter($compile(angularDomEl)(modal.scope), appendToElement);
3934 openedWindows.top().value.modalDomEl = angularDomEl;
3935 openedWindows.top().value.modalOpener = modalOpener;
3938 function broadcastClosing(modalWindow, resultOrReason, closing) {
3939 return !modalWindow.value.modalScope.$broadcast('modal.closing', resultOrReason, closing).defaultPrevented;
3942 $modalStack.close = function(modalInstance, result) {
3943 var modalWindow = openedWindows.get(modalInstance);
3944 if (modalWindow && broadcastClosing(modalWindow, result, true)) {
3945 modalWindow.value.modalScope.$$uibDestructionScheduled = true;
3946 modalWindow.value.deferred.resolve(result);
3947 removeModalWindow(modalInstance, modalWindow.value.modalOpener);
3950 return !modalWindow;
3953 $modalStack.dismiss = function(modalInstance, reason) {
3954 var modalWindow = openedWindows.get(modalInstance);
3955 if (modalWindow && broadcastClosing(modalWindow, reason, false)) {
3956 modalWindow.value.modalScope.$$uibDestructionScheduled = true;
3957 modalWindow.value.deferred.reject(reason);
3958 removeModalWindow(modalInstance, modalWindow.value.modalOpener);
3961 return !modalWindow;
3964 $modalStack.dismissAll = function(reason) {
3965 var topModal = this.getTop();
3966 while (topModal && this.dismiss(topModal.key, reason)) {
3967 topModal = this.getTop();
3971 $modalStack.getTop = function() {
3972 return openedWindows.top();
3975 $modalStack.modalRendered = function(modalInstance) {
3976 var modalWindow = openedWindows.get(modalInstance);
3978 modalWindow.value.renderDeferred.resolve();
3982 $modalStack.focusFirstFocusableElement = function(list) {
3983 if (list.length > 0) {
3990 $modalStack.focusLastFocusableElement = function(list) {
3991 if (list.length > 0) {
3992 list[list.length - 1].focus();
3998 $modalStack.isModalFocused = function(evt, modalWindow) {
3999 if (evt && modalWindow) {
4000 var modalDomEl = modalWindow.value.modalDomEl;
4001 if (modalDomEl && modalDomEl.length) {
4002 return (evt.target || evt.srcElement) === modalDomEl[0];
4008 $modalStack.isFocusInFirstItem = function(evt, list) {
4009 if (list.length > 0) {
4010 return (evt.target || evt.srcElement) === list[0];
4015 $modalStack.isFocusInLastItem = function(evt, list) {
4016 if (list.length > 0) {
4017 return (evt.target || evt.srcElement) === list[list.length - 1];
4022 $modalStack.loadFocusElementList = function(modalWindow) {
4024 var modalDomE1 = modalWindow.value.modalDomEl;
4025 if (modalDomE1 && modalDomE1.length) {
4026 var elements = modalDomE1[0].querySelectorAll(tabableSelector);
4028 Array.prototype.filter.call(elements, function(element) {
4029 return isVisible(element);
4038 .provider('$uibModal', function() {
4039 var $modalProvider = {
4042 backdrop: true, //can also be false or 'static'
4045 $get: ['$rootScope', '$q', '$document', '$templateRequest', '$controller', '$uibResolve', '$uibModalStack',
4046 function ($rootScope, $q, $document, $templateRequest, $controller, $uibResolve, $modalStack) {
4049 function getTemplatePromise(options) {
4050 return options.template ? $q.when(options.template) :
4051 $templateRequest(angular.isFunction(options.templateUrl) ?
4052 options.templateUrl() : options.templateUrl);
4055 var promiseChain = null;
4056 $modal.getPromiseChain = function() {
4057 return promiseChain;
4060 $modal.open = function(modalOptions) {
4061 var modalResultDeferred = $q.defer();
4062 var modalOpenedDeferred = $q.defer();
4063 var modalClosedDeferred = $q.defer();
4064 var modalRenderDeferred = $q.defer();
4066 //prepare an instance of a modal to be injected into controllers and returned to a caller
4067 var modalInstance = {
4068 result: modalResultDeferred.promise,
4069 opened: modalOpenedDeferred.promise,
4070 closed: modalClosedDeferred.promise,
4071 rendered: modalRenderDeferred.promise,
4072 close: function (result) {
4073 return $modalStack.close(modalInstance, result);
4075 dismiss: function (reason) {
4076 return $modalStack.dismiss(modalInstance, reason);
4080 //merge and clean up options
4081 modalOptions = angular.extend({}, $modalProvider.options, modalOptions);
4082 modalOptions.resolve = modalOptions.resolve || {};
4083 modalOptions.appendTo = modalOptions.appendTo || $document.find('body').eq(0);
4086 if (!modalOptions.template && !modalOptions.templateUrl) {
4087 throw new Error('One of template or templateUrl options is required.');
4090 var templateAndResolvePromise =
4091 $q.all([getTemplatePromise(modalOptions), $uibResolve.resolve(modalOptions.resolve, {}, null, null)]);
4093 function resolveWithTemplate() {
4094 return templateAndResolvePromise;
4097 // Wait for the resolution of the existing promise chain.
4098 // Then switch to our own combined promise dependency (regardless of how the previous modal fared).
4099 // Then add to $modalStack and resolve opened.
4100 // Finally clean up the chain variable if no subsequent modal has overwritten it.
4102 samePromise = promiseChain = $q.all([promiseChain])
4103 .then(resolveWithTemplate, resolveWithTemplate)
4104 .then(function resolveSuccess(tplAndVars) {
4105 var providedScope = modalOptions.scope || $rootScope;
4107 var modalScope = providedScope.$new();
4108 modalScope.$close = modalInstance.close;
4109 modalScope.$dismiss = modalInstance.dismiss;
4111 modalScope.$on('$destroy', function() {
4112 if (!modalScope.$$uibDestructionScheduled) {
4113 modalScope.$dismiss('$uibUnscheduledDestruction');
4117 var ctrlInstance, ctrlInstantiate, ctrlLocals = {};
4120 if (modalOptions.controller) {
4121 ctrlLocals.$scope = modalScope;
4122 ctrlLocals.$uibModalInstance = modalInstance;
4123 angular.forEach(tplAndVars[1], function(value, key) {
4124 ctrlLocals[key] = value;
4127 // the third param will make the controller instantiate later,private api
4128 // @see https://github.com/angular/angular.js/blob/master/src/ng/controller.js#L126
4129 ctrlInstantiate = $controller(modalOptions.controller, ctrlLocals, true);
4130 if (modalOptions.controllerAs) {
4131 ctrlInstance = ctrlInstantiate.instance;
4133 if (modalOptions.bindToController) {
4134 ctrlInstance.$close = modalScope.$close;
4135 ctrlInstance.$dismiss = modalScope.$dismiss;
4136 angular.extend(ctrlInstance, providedScope);
4139 ctrlInstance = ctrlInstantiate();
4141 modalScope[modalOptions.controllerAs] = ctrlInstance;
4143 ctrlInstance = ctrlInstantiate();
4146 if (angular.isFunction(ctrlInstance.$onInit)) {
4147 ctrlInstance.$onInit();
4151 $modalStack.open(modalInstance, {
4153 deferred: modalResultDeferred,
4154 renderDeferred: modalRenderDeferred,
4155 closedDeferred: modalClosedDeferred,
4156 content: tplAndVars[0],
4157 animation: modalOptions.animation,
4158 backdrop: modalOptions.backdrop,
4159 keyboard: modalOptions.keyboard,
4160 backdropClass: modalOptions.backdropClass,
4161 windowTopClass: modalOptions.windowTopClass,
4162 windowClass: modalOptions.windowClass,
4163 windowTemplateUrl: modalOptions.windowTemplateUrl,
4164 size: modalOptions.size,
4165 openedClass: modalOptions.openedClass,
4166 appendTo: modalOptions.appendTo
4168 modalOpenedDeferred.resolve(true);
4170 }, function resolveError(reason) {
4171 modalOpenedDeferred.reject(reason);
4172 modalResultDeferred.reject(reason);
4173 })['finally'](function() {
4174 if (promiseChain === samePromise) {
4175 promiseChain = null;
4179 return modalInstance;
4187 return $modalProvider;
4190 angular.module('ui.bootstrap.paging', [])
4192 * Helper internal service for generating common controller code between the
4193 * pager and pagination components
4195 .factory('uibPaging', ['$parse', function($parse) {
4197 create: function(ctrl, $scope, $attrs) {
4198 ctrl.setNumPages = $attrs.numPages ? $parse($attrs.numPages).assign : angular.noop;
4199 ctrl.ngModelCtrl = { $setViewValue: angular.noop }; // nullModelCtrl
4200 ctrl._watchers = [];
4202 ctrl.init = function(ngModelCtrl, config) {
4203 ctrl.ngModelCtrl = ngModelCtrl;
4204 ctrl.config = config;
4206 ngModelCtrl.$render = function() {
4210 if ($attrs.itemsPerPage) {
4211 ctrl._watchers.push($scope.$parent.$watch($attrs.itemsPerPage, function(value) {
4212 ctrl.itemsPerPage = parseInt(value, 10);
4213 $scope.totalPages = ctrl.calculateTotalPages();
4217 ctrl.itemsPerPage = config.itemsPerPage;
4220 $scope.$watch('totalItems', function(newTotal, oldTotal) {
4221 if (angular.isDefined(newTotal) || newTotal !== oldTotal) {
4222 $scope.totalPages = ctrl.calculateTotalPages();
4228 ctrl.calculateTotalPages = function() {
4229 var totalPages = ctrl.itemsPerPage < 1 ? 1 : Math.ceil($scope.totalItems / ctrl.itemsPerPage);
4230 return Math.max(totalPages || 0, 1);
4233 ctrl.render = function() {
4234 $scope.page = parseInt(ctrl.ngModelCtrl.$viewValue, 10) || 1;
4237 $scope.selectPage = function(page, evt) {
4239 evt.preventDefault();
4242 var clickAllowed = !$scope.ngDisabled || !evt;
4243 if (clickAllowed && $scope.page !== page && page > 0 && page <= $scope.totalPages) {
4244 if (evt && evt.target) {
4247 ctrl.ngModelCtrl.$setViewValue(page);
4248 ctrl.ngModelCtrl.$render();
4252 $scope.getText = function(key) {
4253 return $scope[key + 'Text'] || ctrl.config[key + 'Text'];
4256 $scope.noPrevious = function() {
4257 return $scope.page === 1;
4260 $scope.noNext = function() {
4261 return $scope.page === $scope.totalPages;
4264 ctrl.updatePage = function() {
4265 ctrl.setNumPages($scope.$parent, $scope.totalPages); // Readonly variable
4267 if ($scope.page > $scope.totalPages) {
4268 $scope.selectPage($scope.totalPages);
4270 ctrl.ngModelCtrl.$render();
4274 $scope.$on('$destroy', function() {
4275 while (ctrl._watchers.length) {
4276 ctrl._watchers.shift()();
4283 angular.module('ui.bootstrap.pager', ['ui.bootstrap.paging'])
4285 .controller('UibPagerController', ['$scope', '$attrs', 'uibPaging', 'uibPagerConfig', function($scope, $attrs, uibPaging, uibPagerConfig) {
4286 $scope.align = angular.isDefined($attrs.align) ? $scope.$parent.$eval($attrs.align) : uibPagerConfig.align;
4288 uibPaging.create(this, $scope, $attrs);
4291 .constant('uibPagerConfig', {
4293 previousText: '« Previous',
4294 nextText: 'Next »',
4298 .directive('uibPager', ['uibPagerConfig', function(uibPagerConfig) {
4306 require: ['uibPager', '?ngModel'],
4307 controller: 'UibPagerController',
4308 controllerAs: 'pager',
4309 templateUrl: function(element, attrs) {
4310 return attrs.templateUrl || 'uib/template/pager/pager.html';
4313 link: function(scope, element, attrs, ctrls) {
4314 var paginationCtrl = ctrls[0], ngModelCtrl = ctrls[1];
4317 return; // do nothing if no ng-model
4320 paginationCtrl.init(ngModelCtrl, uibPagerConfig);
4325 angular.module('ui.bootstrap.pagination', ['ui.bootstrap.paging'])
4326 .controller('UibPaginationController', ['$scope', '$attrs', '$parse', 'uibPaging', 'uibPaginationConfig', function($scope, $attrs, $parse, uibPaging, uibPaginationConfig) {
4328 // Setup configuration parameters
4329 var maxSize = angular.isDefined($attrs.maxSize) ? $scope.$parent.$eval($attrs.maxSize) : uibPaginationConfig.maxSize,
4330 rotate = angular.isDefined($attrs.rotate) ? $scope.$parent.$eval($attrs.rotate) : uibPaginationConfig.rotate,
4331 forceEllipses = angular.isDefined($attrs.forceEllipses) ? $scope.$parent.$eval($attrs.forceEllipses) : uibPaginationConfig.forceEllipses,
4332 boundaryLinkNumbers = angular.isDefined($attrs.boundaryLinkNumbers) ? $scope.$parent.$eval($attrs.boundaryLinkNumbers) : uibPaginationConfig.boundaryLinkNumbers,
4333 pageLabel = angular.isDefined($attrs.pageLabel) ? function(idx) { return $scope.$parent.$eval($attrs.pageLabel, {$page: idx}); } : angular.identity;
4334 $scope.boundaryLinks = angular.isDefined($attrs.boundaryLinks) ? $scope.$parent.$eval($attrs.boundaryLinks) : uibPaginationConfig.boundaryLinks;
4335 $scope.directionLinks = angular.isDefined($attrs.directionLinks) ? $scope.$parent.$eval($attrs.directionLinks) : uibPaginationConfig.directionLinks;
4337 uibPaging.create(this, $scope, $attrs);
4339 if ($attrs.maxSize) {
4340 ctrl._watchers.push($scope.$parent.$watch($parse($attrs.maxSize), function(value) {
4341 maxSize = parseInt(value, 10);
4346 // Create page object used in template
4347 function makePage(number, text, isActive) {
4355 function getPages(currentPage, totalPages) {
4358 // Default page limits
4359 var startPage = 1, endPage = totalPages;
4360 var isMaxSized = angular.isDefined(maxSize) && maxSize < totalPages;
4362 // recompute if maxSize
4365 // Current page is displayed in the middle of the visible ones
4366 startPage = Math.max(currentPage - Math.floor(maxSize / 2), 1);
4367 endPage = startPage + maxSize - 1;
4369 // Adjust if limit is exceeded
4370 if (endPage > totalPages) {
4371 endPage = totalPages;
4372 startPage = endPage - maxSize + 1;
4375 // Visible pages are paginated with maxSize
4376 startPage = (Math.ceil(currentPage / maxSize) - 1) * maxSize + 1;
4378 // Adjust last page if limit is exceeded
4379 endPage = Math.min(startPage + maxSize - 1, totalPages);
4383 // Add page number links
4384 for (var number = startPage; number <= endPage; number++) {
4385 var page = makePage(number, pageLabel(number), number === currentPage);
4389 // Add links to move between page sets
4390 if (isMaxSized && maxSize > 0 && (!rotate || forceEllipses || boundaryLinkNumbers)) {
4391 if (startPage > 1) {
4392 if (!boundaryLinkNumbers || startPage > 3) { //need ellipsis for all options unless range is too close to beginning
4393 var previousPageSet = makePage(startPage - 1, '...', false);
4394 pages.unshift(previousPageSet);
4396 if (boundaryLinkNumbers) {
4397 if (startPage === 3) { //need to replace ellipsis when the buttons would be sequential
4398 var secondPageLink = makePage(2, '2', false);
4399 pages.unshift(secondPageLink);
4401 //add the first page
4402 var firstPageLink = makePage(1, '1', false);
4403 pages.unshift(firstPageLink);
4407 if (endPage < totalPages) {
4408 if (!boundaryLinkNumbers || endPage < totalPages - 2) { //need ellipsis for all options unless range is too close to end
4409 var nextPageSet = makePage(endPage + 1, '...', false);
4410 pages.push(nextPageSet);
4412 if (boundaryLinkNumbers) {
4413 if (endPage === totalPages - 2) { //need to replace ellipsis when the buttons would be sequential
4414 var secondToLastPageLink = makePage(totalPages - 1, totalPages - 1, false);
4415 pages.push(secondToLastPageLink);
4418 var lastPageLink = makePage(totalPages, totalPages, false);
4419 pages.push(lastPageLink);
4426 var originalRender = this.render;
4427 this.render = function() {
4429 if ($scope.page > 0 && $scope.page <= $scope.totalPages) {
4430 $scope.pages = getPages($scope.page, $scope.totalPages);
4435 .constant('uibPaginationConfig', {
4437 boundaryLinks: false,
4438 boundaryLinkNumbers: false,
4439 directionLinks: true,
4441 previousText: 'Previous',
4445 forceEllipses: false
4448 .directive('uibPagination', ['$parse', 'uibPaginationConfig', function($parse, uibPaginationConfig) {
4458 require: ['uibPagination', '?ngModel'],
4459 controller: 'UibPaginationController',
4460 controllerAs: 'pagination',
4461 templateUrl: function(element, attrs) {
4462 return attrs.templateUrl || 'uib/template/pagination/pagination.html';
4465 link: function(scope, element, attrs, ctrls) {
4466 var paginationCtrl = ctrls[0], ngModelCtrl = ctrls[1];
4469 return; // do nothing if no ng-model
4472 paginationCtrl.init(ngModelCtrl, uibPaginationConfig);
4478 * The following features are still outstanding: animation as a
4479 * function, placement as a function, inside, support for more triggers than
4480 * just mouse enter/leave, html tooltips, and selector delegation.
4482 angular.module('ui.bootstrap.tooltip', ['ui.bootstrap.position', 'ui.bootstrap.stackedMap'])
4485 * The $tooltip service creates tooltip- and popover-like directives as well as
4486 * houses global options for them.
4488 .provider('$uibTooltip', function() {
4489 // The default options tooltip and popover.
4490 var defaultOptions = {
4492 placementClassPrefix: '',
4496 useContentExp: false
4499 // Default hide triggers for each show trigger
4501 'mouseenter': 'mouseleave',
4503 'outsideClick': 'outsideClick',
4508 // The options specified to the provider globally.
4509 var globalOptions = {};
4512 * `options({})` allows global configuration of all tooltips in the
4515 * var app = angular.module( 'App', ['ui.bootstrap.tooltip'], function( $tooltipProvider ) {
4516 * // place tooltips left instead of top by default
4517 * $tooltipProvider.options( { placement: 'left' } );
4520 this.options = function(value) {
4521 angular.extend(globalOptions, value);
4525 * This allows you to extend the set of trigger mappings available. E.g.:
4527 * $tooltipProvider.setTriggers( { 'openTrigger': 'closeTrigger' } );
4529 this.setTriggers = function setTriggers(triggers) {
4530 angular.extend(triggerMap, triggers);
4534 * This is a helper function for translating camel-case to snake_case.
4536 function snake_case(name) {
4537 var regexp = /[A-Z]/g;
4538 var separator = '-';
4539 return name.replace(regexp, function(letter, pos) {
4540 return (pos ? separator : '') + letter.toLowerCase();
4545 * Returns the actual instance of the $tooltip service.
4546 * TODO support multiple triggers
4548 this.$get = ['$window', '$compile', '$timeout', '$document', '$uibPosition', '$interpolate', '$rootScope', '$parse', '$$stackedMap', function($window, $compile, $timeout, $document, $position, $interpolate, $rootScope, $parse, $$stackedMap) {
4549 var openedTooltips = $$stackedMap.createNew();
4550 $document.on('keypress', keypressListener);
4552 $rootScope.$on('$destroy', function() {
4553 $document.off('keypress', keypressListener);
4556 function keypressListener(e) {
4557 if (e.which === 27) {
4558 var last = openedTooltips.top();
4561 openedTooltips.removeTop();
4567 return function $tooltip(ttType, prefix, defaultTriggerShow, options) {
4568 options = angular.extend({}, defaultOptions, globalOptions, options);
4571 * Returns an object of show and hide triggers.
4573 * If a trigger is supplied,
4574 * it is used to show the tooltip; otherwise, it will use the `trigger`
4575 * option passed to the `$tooltipProvider.options` method; else it will
4576 * default to the trigger supplied to this directive factory.
4578 * The hide trigger is based on the show trigger. If the `trigger` option
4579 * was passed to the `$tooltipProvider.options` method, it will use the
4580 * mapped trigger from `triggerMap` or the passed trigger if the map is
4581 * undefined; otherwise, it uses the `triggerMap` value of the show
4582 * trigger; else it will just use the show trigger.
4584 function getTriggers(trigger) {
4585 var show = (trigger || options.trigger || defaultTriggerShow).split(' ');
4586 var hide = show.map(function(trigger) {
4587 return triggerMap[trigger] || trigger;
4595 var directiveName = snake_case(ttType);
4597 var startSym = $interpolate.startSymbol();
4598 var endSym = $interpolate.endSymbol();
4600 '<div '+ directiveName + '-popup ' +
4601 'uib-title="' + startSym + 'title' + endSym + '" ' +
4602 (options.useContentExp ?
4603 'content-exp="contentExp()" ' :
4604 'content="' + startSym + 'content' + endSym + '" ') +
4605 'placement="' + startSym + 'placement' + endSym + '" ' +
4606 'popup-class="' + startSym + 'popupClass' + endSym + '" ' +
4607 'animation="animation" ' +
4608 'is-open="isOpen" ' +
4609 'origin-scope="origScope" ' +
4610 'class="uib-position-measure"' +
4615 compile: function(tElem, tAttrs) {
4616 var tooltipLinker = $compile(template);
4618 return function link(scope, element, attrs, tooltipCtrl) {
4620 var tooltipLinkedScope;
4621 var transitionTimeout;
4624 var positionTimeout;
4625 var appendToBody = angular.isDefined(options.appendToBody) ? options.appendToBody : false;
4626 var triggers = getTriggers(undefined);
4627 var hasEnableExp = angular.isDefined(attrs[prefix + 'Enable']);
4628 var ttScope = scope.$new(true);
4629 var repositionScheduled = false;
4630 var isOpenParse = angular.isDefined(attrs[prefix + 'IsOpen']) ? $parse(attrs[prefix + 'IsOpen']) : false;
4631 var contentParse = options.useContentExp ? $parse(attrs[ttType]) : false;
4635 var positionTooltip = function() {
4636 // check if tooltip exists and is not empty
4637 if (!tooltip || !tooltip.html()) { return; }
4639 if (!positionTimeout) {
4640 positionTimeout = $timeout(function() {
4641 var ttPosition = $position.positionElements(element, tooltip, ttScope.placement, appendToBody);
4642 tooltip.css({ top: ttPosition.top + 'px', left: ttPosition.left + 'px' });
4644 if (!tooltip.hasClass(ttPosition.placement.split('-')[0])) {
4645 tooltip.removeClass(lastPlacement.split('-')[0]);
4646 tooltip.addClass(ttPosition.placement.split('-')[0]);
4649 if (!tooltip.hasClass(options.placementClassPrefix + ttPosition.placement)) {
4650 tooltip.removeClass(options.placementClassPrefix + lastPlacement);
4651 tooltip.addClass(options.placementClassPrefix + ttPosition.placement);
4654 // first time through tt element will have the
4655 // uib-position-measure class or if the placement
4656 // has changed we need to position the arrow.
4657 if (tooltip.hasClass('uib-position-measure')) {
4658 $position.positionArrow(tooltip, ttPosition.placement);
4659 tooltip.removeClass('uib-position-measure');
4660 } else if (lastPlacement !== ttPosition.placement) {
4661 $position.positionArrow(tooltip, ttPosition.placement);
4663 lastPlacement = ttPosition.placement;
4665 positionTimeout = null;
4670 // Set up the correct scope to allow transclusion later
4671 ttScope.origScope = scope;
4673 // By default, the tooltip is not open.
4674 // TODO add ability to start tooltip opened
4675 ttScope.isOpen = false;
4676 openedTooltips.add(ttScope, {
4680 function toggleTooltipBind() {
4681 if (!ttScope.isOpen) {
4688 // Show the tooltip with delay if specified, otherwise show it immediately
4689 function showTooltipBind() {
4690 if (hasEnableExp && !scope.$eval(attrs[prefix + 'Enable'])) {
4697 if (ttScope.popupDelay) {
4698 // Do nothing if the tooltip was already scheduled to pop-up.
4699 // This happens if show is triggered multiple times before any hide is triggered.
4701 showTimeout = $timeout(show, ttScope.popupDelay, false);
4708 function hideTooltipBind() {
4711 if (ttScope.popupCloseDelay) {
4713 hideTimeout = $timeout(hide, ttScope.popupCloseDelay, false);
4720 // Show the tooltip popup element.
4725 // Don't show empty tooltips.
4726 if (!ttScope.content) {
4727 return angular.noop;
4732 // And show the tooltip.
4733 ttScope.$evalAsync(function() {
4734 ttScope.isOpen = true;
4740 function cancelShow() {
4742 $timeout.cancel(showTimeout);
4746 if (positionTimeout) {
4747 $timeout.cancel(positionTimeout);
4748 positionTimeout = null;
4752 // Hide the tooltip popup element.
4758 // First things first: we don't show it anymore.
4759 ttScope.$evalAsync(function() {
4761 ttScope.isOpen = false;
4762 assignIsOpen(false);
4763 // And now we remove it from the DOM. However, if we have animation, we
4764 // need to wait for it to expire beforehand.
4765 // FIXME: this is a placeholder for a port of the transitions library.
4766 // The fade transition in TWBS is 150ms.
4767 if (ttScope.animation) {
4768 if (!transitionTimeout) {
4769 transitionTimeout = $timeout(removeTooltip, 150, false);
4778 function cancelHide() {
4780 $timeout.cancel(hideTimeout);
4784 if (transitionTimeout) {
4785 $timeout.cancel(transitionTimeout);
4786 transitionTimeout = null;
4790 function createTooltip() {
4791 // There can only be one tooltip element per directive shown at once.
4796 tooltipLinkedScope = ttScope.$new();
4797 tooltip = tooltipLinker(tooltipLinkedScope, function(tooltip) {
4799 $document.find('body').append(tooltip);
4801 element.after(tooltip);
4808 function removeTooltip() {
4811 unregisterObservers();
4817 if (tooltipLinkedScope) {
4818 tooltipLinkedScope.$destroy();
4819 tooltipLinkedScope = null;
4824 * Set the initial scope values. Once
4825 * the tooltip is created, the observers
4826 * will be added to keep things in sync.
4828 function prepareTooltip() {
4829 ttScope.title = attrs[prefix + 'Title'];
4831 ttScope.content = contentParse(scope);
4833 ttScope.content = attrs[ttType];
4836 ttScope.popupClass = attrs[prefix + 'Class'];
4837 ttScope.placement = angular.isDefined(attrs[prefix + 'Placement']) ? attrs[prefix + 'Placement'] : options.placement;
4838 var placement = $position.parsePlacement(ttScope.placement);
4839 lastPlacement = placement[1] ? placement[0] + '-' + placement[1] : placement[0];
4841 var delay = parseInt(attrs[prefix + 'PopupDelay'], 10);
4842 var closeDelay = parseInt(attrs[prefix + 'PopupCloseDelay'], 10);
4843 ttScope.popupDelay = !isNaN(delay) ? delay : options.popupDelay;
4844 ttScope.popupCloseDelay = !isNaN(closeDelay) ? closeDelay : options.popupCloseDelay;
4847 function assignIsOpen(isOpen) {
4848 if (isOpenParse && angular.isFunction(isOpenParse.assign)) {
4849 isOpenParse.assign(scope, isOpen);
4853 ttScope.contentExp = function() {
4854 return ttScope.content;
4858 * Observe the relevant attributes.
4860 attrs.$observe('disabled', function(val) {
4865 if (val && ttScope.isOpen) {
4871 scope.$watch(isOpenParse, function(val) {
4872 if (ttScope && !val === ttScope.isOpen) {
4873 toggleTooltipBind();
4878 function prepObservers() {
4879 observers.length = 0;
4883 scope.$watch(contentParse, function(val) {
4884 ttScope.content = val;
4885 if (!val && ttScope.isOpen) {
4892 tooltipLinkedScope.$watch(function() {
4893 if (!repositionScheduled) {
4894 repositionScheduled = true;
4895 tooltipLinkedScope.$$postDigest(function() {
4896 repositionScheduled = false;
4897 if (ttScope && ttScope.isOpen) {
4906 attrs.$observe(ttType, function(val) {
4907 ttScope.content = val;
4908 if (!val && ttScope.isOpen) {
4918 attrs.$observe(prefix + 'Title', function(val) {
4919 ttScope.title = val;
4920 if (ttScope.isOpen) {
4927 attrs.$observe(prefix + 'Placement', function(val) {
4928 ttScope.placement = val ? val : options.placement;
4929 if (ttScope.isOpen) {
4936 function unregisterObservers() {
4937 if (observers.length) {
4938 angular.forEach(observers, function(observer) {
4941 observers.length = 0;
4945 // hide tooltips/popovers for outsideClick trigger
4946 function bodyHideTooltipBind(e) {
4947 if (!ttScope || !ttScope.isOpen || !tooltip) {
4950 // make sure the tooltip/popover link or tool tooltip/popover itself were not clicked
4951 if (!element[0].contains(e.target) && !tooltip[0].contains(e.target)) {
4956 var unregisterTriggers = function() {
4957 triggers.show.forEach(function(trigger) {
4958 if (trigger === 'outsideClick') {
4959 element.off('click', toggleTooltipBind);
4961 element.off(trigger, showTooltipBind);
4962 element.off(trigger, toggleTooltipBind);
4965 triggers.hide.forEach(function(trigger) {
4966 if (trigger === 'outsideClick') {
4967 $document.off('click', bodyHideTooltipBind);
4969 element.off(trigger, hideTooltipBind);
4974 function prepTriggers() {
4975 var val = attrs[prefix + 'Trigger'];
4976 unregisterTriggers();
4978 triggers = getTriggers(val);
4980 if (triggers.show !== 'none') {
4981 triggers.show.forEach(function(trigger, idx) {
4982 if (trigger === 'outsideClick') {
4983 element.on('click', toggleTooltipBind);
4984 $document.on('click', bodyHideTooltipBind);
4985 } else if (trigger === triggers.hide[idx]) {
4986 element.on(trigger, toggleTooltipBind);
4987 } else if (trigger) {
4988 element.on(trigger, showTooltipBind);
4989 element.on(triggers.hide[idx], hideTooltipBind);
4992 element.on('keypress', function(e) {
4993 if (e.which === 27) {
5003 var animation = scope.$eval(attrs[prefix + 'Animation']);
5004 ttScope.animation = angular.isDefined(animation) ? !!animation : options.animation;
5006 var appendToBodyVal;
5007 var appendKey = prefix + 'AppendToBody';
5008 if (appendKey in attrs && attrs[appendKey] === undefined) {
5009 appendToBodyVal = true;
5011 appendToBodyVal = scope.$eval(attrs[appendKey]);
5014 appendToBody = angular.isDefined(appendToBodyVal) ? appendToBodyVal : appendToBody;
5016 // Make sure tooltip is destroyed and removed.
5017 scope.$on('$destroy', function onDestroyTooltip() {
5018 unregisterTriggers();
5020 openedTooltips.remove(ttScope);
5030 // This is mostly ngInclude code but with a custom scope
5031 .directive('uibTooltipTemplateTransclude', [
5032 '$animate', '$sce', '$compile', '$templateRequest',
5033 function ($animate, $sce, $compile, $templateRequest) {
5035 link: function(scope, elem, attrs) {
5036 var origScope = scope.$eval(attrs.tooltipTemplateTranscludeScope);
5038 var changeCounter = 0,
5043 var cleanupLastIncludeContent = function() {
5044 if (previousElement) {
5045 previousElement.remove();
5046 previousElement = null;
5050 currentScope.$destroy();
5051 currentScope = null;
5054 if (currentElement) {
5055 $animate.leave(currentElement).then(function() {
5056 previousElement = null;
5058 previousElement = currentElement;
5059 currentElement = null;
5063 scope.$watch($sce.parseAsResourceUrl(attrs.uibTooltipTemplateTransclude), function(src) {
5064 var thisChangeId = ++changeCounter;
5067 //set the 2nd param to true to ignore the template request error so that the inner
5068 //contents and scope can be cleaned up.
5069 $templateRequest(src, true).then(function(response) {
5070 if (thisChangeId !== changeCounter) { return; }
5071 var newScope = origScope.$new();
5072 var template = response;
5074 var clone = $compile(template)(newScope, function(clone) {
5075 cleanupLastIncludeContent();
5076 $animate.enter(clone, elem);
5079 currentScope = newScope;
5080 currentElement = clone;
5082 currentScope.$emit('$includeContentLoaded', src);
5084 if (thisChangeId === changeCounter) {
5085 cleanupLastIncludeContent();
5086 scope.$emit('$includeContentError', src);
5089 scope.$emit('$includeContentRequested', src);
5091 cleanupLastIncludeContent();
5095 scope.$on('$destroy', cleanupLastIncludeContent);
5101 * Note that it's intentional that these classes are *not* applied through $animate.
5102 * They must not be animated as they're expected to be present on the tooltip on
5105 .directive('uibTooltipClasses', ['$uibPosition', function($uibPosition) {
5108 link: function(scope, element, attrs) {
5109 // need to set the primary position so the
5110 // arrow has space during position measure.
5111 // tooltip.positionTooltip()
5112 if (scope.placement) {
5113 // // There are no top-left etc... classes
5114 // // in TWBS, so we need the primary position.
5115 var position = $uibPosition.parsePlacement(scope.placement);
5116 element.addClass(position[0]);
5119 if (scope.popupClass) {
5120 element.addClass(scope.popupClass);
5123 if (scope.animation()) {
5124 element.addClass(attrs.tooltipAnimationClass);
5130 .directive('uibTooltipPopup', function() {
5133 scope: { content: '@', placement: '@', popupClass: '@', animation: '&', isOpen: '&' },
5134 templateUrl: 'uib/template/tooltip/tooltip-popup.html'
5138 .directive('uibTooltip', [ '$uibTooltip', function($uibTooltip) {
5139 return $uibTooltip('uibTooltip', 'tooltip', 'mouseenter');
5142 .directive('uibTooltipTemplatePopup', function() {
5145 scope: { contentExp: '&', placement: '@', popupClass: '@', animation: '&', isOpen: '&',
5147 templateUrl: 'uib/template/tooltip/tooltip-template-popup.html'
5151 .directive('uibTooltipTemplate', ['$uibTooltip', function($uibTooltip) {
5152 return $uibTooltip('uibTooltipTemplate', 'tooltip', 'mouseenter', {
5157 .directive('uibTooltipHtmlPopup', function() {
5160 scope: { contentExp: '&', placement: '@', popupClass: '@', animation: '&', isOpen: '&' },
5161 templateUrl: 'uib/template/tooltip/tooltip-html-popup.html'
5165 .directive('uibTooltipHtml', ['$uibTooltip', function($uibTooltip) {
5166 return $uibTooltip('uibTooltipHtml', 'tooltip', 'mouseenter', {
5172 * The following features are still outstanding: popup delay, animation as a
5173 * function, placement as a function, inside, support for more triggers than
5174 * just mouse enter/leave, and selector delegatation.
5176 angular.module('ui.bootstrap.popover', ['ui.bootstrap.tooltip'])
5178 .directive('uibPopoverTemplatePopup', function() {
5181 scope: { uibTitle: '@', contentExp: '&', placement: '@', popupClass: '@', animation: '&', isOpen: '&',
5183 templateUrl: 'uib/template/popover/popover-template.html'
5187 .directive('uibPopoverTemplate', ['$uibTooltip', function($uibTooltip) {
5188 return $uibTooltip('uibPopoverTemplate', 'popover', 'click', {
5193 .directive('uibPopoverHtmlPopup', function() {
5196 scope: { contentExp: '&', uibTitle: '@', placement: '@', popupClass: '@', animation: '&', isOpen: '&' },
5197 templateUrl: 'uib/template/popover/popover-html.html'
5201 .directive('uibPopoverHtml', ['$uibTooltip', function($uibTooltip) {
5202 return $uibTooltip('uibPopoverHtml', 'popover', 'click', {
5207 .directive('uibPopoverPopup', function() {
5210 scope: { uibTitle: '@', content: '@', placement: '@', popupClass: '@', animation: '&', isOpen: '&' },
5211 templateUrl: 'uib/template/popover/popover.html'
5215 .directive('uibPopover', ['$uibTooltip', function($uibTooltip) {
5216 return $uibTooltip('uibPopover', 'popover', 'click');
5219 angular.module('ui.bootstrap.progressbar', [])
5221 .constant('uibProgressConfig', {
5226 .controller('UibProgressController', ['$scope', '$attrs', 'uibProgressConfig', function($scope, $attrs, progressConfig) {
5228 animate = angular.isDefined($attrs.animate) ? $scope.$parent.$eval($attrs.animate) : progressConfig.animate;
5231 $scope.max = getMaxOrDefault();
5233 this.addBar = function(bar, element, attrs) {
5235 element.css({'transition': 'none'});
5238 this.bars.push(bar);
5240 bar.max = getMaxOrDefault();
5241 bar.title = attrs && angular.isDefined(attrs.title) ? attrs.title : 'progressbar';
5243 bar.$watch('value', function(value) {
5244 bar.recalculatePercentage();
5247 bar.recalculatePercentage = function() {
5248 var totalPercentage = self.bars.reduce(function(total, bar) {
5249 bar.percent = +(100 * bar.value / bar.max).toFixed(2);
5250 return total + bar.percent;
5253 if (totalPercentage > 100) {
5254 bar.percent -= totalPercentage - 100;
5258 bar.$on('$destroy', function() {
5260 self.removeBar(bar);
5264 this.removeBar = function(bar) {
5265 this.bars.splice(this.bars.indexOf(bar), 1);
5266 this.bars.forEach(function (bar) {
5267 bar.recalculatePercentage();
5271 //$attrs.$observe('maxParam', function(maxParam) {
5272 $scope.$watch('maxParam', function(maxParam) {
5273 self.bars.forEach(function(bar) {
5274 bar.max = getMaxOrDefault();
5275 bar.recalculatePercentage();
5279 function getMaxOrDefault () {
5280 return angular.isDefined($scope.maxParam) ? $scope.maxParam : progressConfig.max;
5284 .directive('uibProgress', function() {
5288 controller: 'UibProgressController',
5289 require: 'uibProgress',
5293 templateUrl: 'uib/template/progressbar/progress.html'
5297 .directive('uibBar', function() {
5301 require: '^uibProgress',
5306 templateUrl: 'uib/template/progressbar/bar.html',
5307 link: function(scope, element, attrs, progressCtrl) {
5308 progressCtrl.addBar(scope, element, attrs);
5313 .directive('uibProgressbar', function() {
5317 controller: 'UibProgressController',
5323 templateUrl: 'uib/template/progressbar/progressbar.html',
5324 link: function(scope, element, attrs, progressCtrl) {
5325 progressCtrl.addBar(scope, angular.element(element.children()[0]), {title: attrs.title});
5330 angular.module('ui.bootstrap.rating', [])
5332 .constant('uibRatingConfig', {
5337 titles : ['one', 'two', 'three', 'four', 'five']
5340 .controller('UibRatingController', ['$scope', '$attrs', 'uibRatingConfig', function($scope, $attrs, ratingConfig) {
5341 var ngModelCtrl = { $setViewValue: angular.noop },
5344 this.init = function(ngModelCtrl_) {
5345 ngModelCtrl = ngModelCtrl_;
5346 ngModelCtrl.$render = this.render;
5348 ngModelCtrl.$formatters.push(function(value) {
5349 if (angular.isNumber(value) && value << 0 !== value) {
5350 value = Math.round(value);
5356 this.stateOn = angular.isDefined($attrs.stateOn) ? $scope.$parent.$eval($attrs.stateOn) : ratingConfig.stateOn;
5357 this.stateOff = angular.isDefined($attrs.stateOff) ? $scope.$parent.$eval($attrs.stateOff) : ratingConfig.stateOff;
5358 this.enableReset = angular.isDefined($attrs.enableReset) ?
5359 $scope.$parent.$eval($attrs.enableReset) : ratingConfig.enableReset;
5360 var tmpTitles = angular.isDefined($attrs.titles) ? $scope.$parent.$eval($attrs.titles) : ratingConfig.titles;
5361 this.titles = angular.isArray(tmpTitles) && tmpTitles.length > 0 ?
5362 tmpTitles : ratingConfig.titles;
5364 var ratingStates = angular.isDefined($attrs.ratingStates) ?
5365 $scope.$parent.$eval($attrs.ratingStates) :
5366 new Array(angular.isDefined($attrs.max) ? $scope.$parent.$eval($attrs.max) : ratingConfig.max);
5367 $scope.range = this.buildTemplateObjects(ratingStates);
5370 this.buildTemplateObjects = function(states) {
5371 for (var i = 0, n = states.length; i < n; i++) {
5372 states[i] = angular.extend({ index: i }, { stateOn: this.stateOn, stateOff: this.stateOff, title: this.getTitle(i) }, states[i]);
5377 this.getTitle = function(index) {
5378 if (index >= this.titles.length) {
5382 return this.titles[index];
5385 $scope.rate = function(value) {
5386 if (!$scope.readonly && value >= 0 && value <= $scope.range.length) {
5387 var newViewValue = self.enableReset && ngModelCtrl.$viewValue === value ? 0 : value;
5388 ngModelCtrl.$setViewValue(newViewValue);
5389 ngModelCtrl.$render();
5393 $scope.enter = function(value) {
5394 if (!$scope.readonly) {
5395 $scope.value = value;
5397 $scope.onHover({value: value});
5400 $scope.reset = function() {
5401 $scope.value = ngModelCtrl.$viewValue;
5405 $scope.onKeydown = function(evt) {
5406 if (/(37|38|39|40)/.test(evt.which)) {
5407 evt.preventDefault();
5408 evt.stopPropagation();
5409 $scope.rate($scope.value + (evt.which === 38 || evt.which === 39 ? 1 : -1));
5413 this.render = function() {
5414 $scope.value = ngModelCtrl.$viewValue;
5415 $scope.title = self.getTitle($scope.value - 1);
5419 .directive('uibRating', function() {
5421 require: ['uibRating', 'ngModel'],
5423 readonly: '=?readOnly',
5427 controller: 'UibRatingController',
5428 templateUrl: 'uib/template/rating/rating.html',
5430 link: function(scope, element, attrs, ctrls) {
5431 var ratingCtrl = ctrls[0], ngModelCtrl = ctrls[1];
5432 ratingCtrl.init(ngModelCtrl);
5437 angular.module('ui.bootstrap.tabs', [])
5439 .controller('UibTabsetController', ['$scope', function ($scope) {
5444 ctrl.select = function(index, evt) {
5446 var previousIndex = findTabIndex(oldIndex);
5447 var previousSelected = ctrl.tabs[previousIndex];
5448 if (previousSelected) {
5449 previousSelected.tab.onDeselect({
5452 if (evt && evt.isDefaultPrevented()) {
5455 previousSelected.tab.active = false;
5458 var selected = ctrl.tabs[index];
5460 selected.tab.onSelect({
5463 selected.tab.active = true;
5464 ctrl.active = selected.index;
5465 oldIndex = selected.index;
5466 } else if (!selected && angular.isNumber(oldIndex)) {
5473 ctrl.addTab = function addTab(tab) {
5478 ctrl.tabs.sort(function(t1, t2) {
5479 if (t1.index > t2.index) {
5483 if (t1.index < t2.index) {
5490 if (tab.index === ctrl.active || !angular.isNumber(ctrl.active) && ctrl.tabs.length === 1) {
5491 var newActiveIndex = findTabIndex(tab.index);
5492 ctrl.select(newActiveIndex);
5496 ctrl.removeTab = function removeTab(tab) {
5498 for (var i = 0; i < ctrl.tabs.length; i++) {
5499 if (ctrl.tabs[i].tab === tab) {
5505 if (ctrl.tabs[index].index === ctrl.active) {
5506 var newActiveTabIndex = index === ctrl.tabs.length - 1 ?
5507 index - 1 : index + 1 % ctrl.tabs.length;
5508 ctrl.select(newActiveTabIndex);
5511 ctrl.tabs.splice(index, 1);
5514 $scope.$watch('tabset.active', function(val) {
5515 if (angular.isNumber(val) && val !== oldIndex) {
5516 ctrl.select(findTabIndex(val));
5521 $scope.$on('$destroy', function() {
5525 function findTabIndex(index) {
5526 for (var i = 0; i < ctrl.tabs.length; i++) {
5527 if (ctrl.tabs[i].index === index) {
5534 .directive('uibTabset', function() {
5543 controller: 'UibTabsetController',
5544 controllerAs: 'tabset',
5545 templateUrl: function(element, attrs) {
5546 return attrs.templateUrl || 'uib/template/tabs/tabset.html';
5548 link: function(scope, element, attrs) {
5549 scope.vertical = angular.isDefined(attrs.vertical) ?
5550 scope.$parent.$eval(attrs.vertical) : false;
5551 scope.justified = angular.isDefined(attrs.justified) ?
5552 scope.$parent.$eval(attrs.justified) : false;
5553 if (angular.isUndefined(attrs.active)) {
5560 .directive('uibTab', ['$parse', function($parse) {
5562 require: '^uibTabset',
5564 templateUrl: function(element, attrs) {
5565 return attrs.templateUrl || 'uib/template/tabs/tab.html';
5572 onSelect: '&select', //This callback is called in contentHeadingTransclude
5573 //once it inserts the tab's content into the dom
5574 onDeselect: '&deselect'
5576 controller: function() {
5577 //Empty controller so other directives can require being 'under' a tab
5579 controllerAs: 'tab',
5580 link: function(scope, elm, attrs, tabsetCtrl, transclude) {
5581 scope.disabled = false;
5582 if (attrs.disable) {
5583 scope.$parent.$watch($parse(attrs.disable), function(value) {
5584 scope.disabled = !! value;
5588 if (angular.isUndefined(attrs.index)) {
5589 if (tabsetCtrl.tabs && tabsetCtrl.tabs.length) {
5590 scope.index = Math.max.apply(null, tabsetCtrl.tabs.map(function(t) { return t.index; })) + 1;
5596 if (angular.isUndefined(attrs.classes)) {
5600 scope.select = function(evt) {
5601 if (!scope.disabled) {
5603 for (var i = 0; i < tabsetCtrl.tabs.length; i++) {
5604 if (tabsetCtrl.tabs[i].tab === scope) {
5610 tabsetCtrl.select(index, evt);
5614 tabsetCtrl.addTab(scope);
5615 scope.$on('$destroy', function() {
5616 tabsetCtrl.removeTab(scope);
5619 //We need to transclude later, once the content container is ready.
5620 //when this link happens, we're inside a tab heading.
5621 scope.$transcludeFn = transclude;
5626 .directive('uibTabHeadingTransclude', function() {
5630 link: function(scope, elm) {
5631 scope.$watch('headingElement', function updateHeadingElement(heading) {
5634 elm.append(heading);
5641 .directive('uibTabContentTransclude', function() {
5644 require: '^uibTabset',
5645 link: function(scope, elm, attrs) {
5646 var tab = scope.$eval(attrs.uibTabContentTransclude).tab;
5648 //Now our tab is ready to be transcluded: both the tab heading area
5649 //and the tab content area are loaded. Transclude 'em both.
5650 tab.$transcludeFn(tab.$parent, function(contents) {
5651 angular.forEach(contents, function(node) {
5652 if (isTabHeading(node)) {
5653 //Let tabHeadingTransclude know.
5654 tab.headingElement = node;
5663 function isTabHeading(node) {
5664 return node.tagName && (
5665 node.hasAttribute('uib-tab-heading') ||
5666 node.hasAttribute('data-uib-tab-heading') ||
5667 node.hasAttribute('x-uib-tab-heading') ||
5668 node.tagName.toLowerCase() === 'uib-tab-heading' ||
5669 node.tagName.toLowerCase() === 'data-uib-tab-heading' ||
5670 node.tagName.toLowerCase() === 'x-uib-tab-heading' ||
5671 node.tagName.toLowerCase() === 'uib:tab-heading'
5676 angular.module('ui.bootstrap.timepicker', [])
5678 .constant('uibTimepickerConfig', {
5685 readonlyInput: false,
5689 templateUrl: 'uib/template/timepicker/timepicker.html'
5692 .controller('UibTimepickerController', ['$scope', '$element', '$attrs', '$parse', '$log', '$locale', 'uibTimepickerConfig', function($scope, $element, $attrs, $parse, $log, $locale, timepickerConfig) {
5693 var selected = new Date(),
5695 ngModelCtrl = { $setViewValue: angular.noop }, // nullModelCtrl
5696 meridians = angular.isDefined($attrs.meridians) ? $scope.$parent.$eval($attrs.meridians) : timepickerConfig.meridians || $locale.DATETIME_FORMATS.AMPMS,
5697 padHours = angular.isDefined($attrs.padHours) ? $scope.$parent.$eval($attrs.padHours) : true;
5699 $scope.tabindex = angular.isDefined($attrs.tabindex) ? $attrs.tabindex : 0;
5700 $element.removeAttr('tabindex');
5702 this.init = function(ngModelCtrl_, inputs) {
5703 ngModelCtrl = ngModelCtrl_;
5704 ngModelCtrl.$render = this.render;
5706 ngModelCtrl.$formatters.unshift(function(modelValue) {
5707 return modelValue ? new Date(modelValue) : null;
5710 var hoursInputEl = inputs.eq(0),
5711 minutesInputEl = inputs.eq(1),
5712 secondsInputEl = inputs.eq(2);
5714 var mousewheel = angular.isDefined($attrs.mousewheel) ? $scope.$parent.$eval($attrs.mousewheel) : timepickerConfig.mousewheel;
5717 this.setupMousewheelEvents(hoursInputEl, minutesInputEl, secondsInputEl);
5720 var arrowkeys = angular.isDefined($attrs.arrowkeys) ? $scope.$parent.$eval($attrs.arrowkeys) : timepickerConfig.arrowkeys;
5722 this.setupArrowkeyEvents(hoursInputEl, minutesInputEl, secondsInputEl);
5725 $scope.readonlyInput = angular.isDefined($attrs.readonlyInput) ? $scope.$parent.$eval($attrs.readonlyInput) : timepickerConfig.readonlyInput;
5726 this.setupInputEvents(hoursInputEl, minutesInputEl, secondsInputEl);
5729 var hourStep = timepickerConfig.hourStep;
5730 if ($attrs.hourStep) {
5731 watchers.push($scope.$parent.$watch($parse($attrs.hourStep), function(value) {
5736 var minuteStep = timepickerConfig.minuteStep;
5737 if ($attrs.minuteStep) {
5738 watchers.push($scope.$parent.$watch($parse($attrs.minuteStep), function(value) {
5739 minuteStep = +value;
5744 watchers.push($scope.$parent.$watch($parse($attrs.min), function(value) {
5745 var dt = new Date(value);
5746 min = isNaN(dt) ? undefined : dt;
5750 watchers.push($scope.$parent.$watch($parse($attrs.max), function(value) {
5751 var dt = new Date(value);
5752 max = isNaN(dt) ? undefined : dt;
5755 var disabled = false;
5756 if ($attrs.ngDisabled) {
5757 watchers.push($scope.$parent.$watch($parse($attrs.ngDisabled), function(value) {
5762 $scope.noIncrementHours = function() {
5763 var incrementedSelected = addMinutes(selected, hourStep * 60);
5764 return disabled || incrementedSelected > max ||
5765 incrementedSelected < selected && incrementedSelected < min;
5768 $scope.noDecrementHours = function() {
5769 var decrementedSelected = addMinutes(selected, -hourStep * 60);
5770 return disabled || decrementedSelected < min ||
5771 decrementedSelected > selected && decrementedSelected > max;
5774 $scope.noIncrementMinutes = function() {
5775 var incrementedSelected = addMinutes(selected, minuteStep);
5776 return disabled || incrementedSelected > max ||
5777 incrementedSelected < selected && incrementedSelected < min;
5780 $scope.noDecrementMinutes = function() {
5781 var decrementedSelected = addMinutes(selected, -minuteStep);
5782 return disabled || decrementedSelected < min ||
5783 decrementedSelected > selected && decrementedSelected > max;
5786 $scope.noIncrementSeconds = function() {
5787 var incrementedSelected = addSeconds(selected, secondStep);
5788 return disabled || incrementedSelected > max ||
5789 incrementedSelected < selected && incrementedSelected < min;
5792 $scope.noDecrementSeconds = function() {
5793 var decrementedSelected = addSeconds(selected, -secondStep);
5794 return disabled || decrementedSelected < min ||
5795 decrementedSelected > selected && decrementedSelected > max;
5798 $scope.noToggleMeridian = function() {
5799 if (selected.getHours() < 12) {
5800 return disabled || addMinutes(selected, 12 * 60) > max;
5803 return disabled || addMinutes(selected, -12 * 60) < min;
5806 var secondStep = timepickerConfig.secondStep;
5807 if ($attrs.secondStep) {
5808 watchers.push($scope.$parent.$watch($parse($attrs.secondStep), function(value) {
5809 secondStep = +value;
5813 $scope.showSeconds = timepickerConfig.showSeconds;
5814 if ($attrs.showSeconds) {
5815 watchers.push($scope.$parent.$watch($parse($attrs.showSeconds), function(value) {
5816 $scope.showSeconds = !!value;
5821 $scope.showMeridian = timepickerConfig.showMeridian;
5822 if ($attrs.showMeridian) {
5823 watchers.push($scope.$parent.$watch($parse($attrs.showMeridian), function(value) {
5824 $scope.showMeridian = !!value;
5826 if (ngModelCtrl.$error.time) {
5827 // Evaluate from template
5828 var hours = getHoursFromTemplate(), minutes = getMinutesFromTemplate();
5829 if (angular.isDefined(hours) && angular.isDefined(minutes)) {
5830 selected.setHours(hours);
5839 // Get $scope.hours in 24H mode if valid
5840 function getHoursFromTemplate() {
5841 var hours = +$scope.hours;
5842 var valid = $scope.showMeridian ? hours > 0 && hours < 13 :
5843 hours >= 0 && hours < 24;
5844 if (!valid || $scope.hours === '') {
5848 if ($scope.showMeridian) {
5852 if ($scope.meridian === meridians[1]) {
5859 function getMinutesFromTemplate() {
5860 var minutes = +$scope.minutes;
5861 var valid = minutes >= 0 && minutes < 60;
5862 if (!valid || $scope.minutes === '') {
5868 function getSecondsFromTemplate() {
5869 var seconds = +$scope.seconds;
5870 return seconds >= 0 && seconds < 60 ? seconds : undefined;
5873 function pad(value, noPad) {
5874 if (value === null) {
5878 return angular.isDefined(value) && value.toString().length < 2 && !noPad ?
5879 '0' + value : value.toString();
5882 // Respond on mousewheel spin
5883 this.setupMousewheelEvents = function(hoursInputEl, minutesInputEl, secondsInputEl) {
5884 var isScrollingUp = function(e) {
5885 if (e.originalEvent) {
5886 e = e.originalEvent;
5888 //pick correct delta variable depending on event
5889 var delta = e.wheelDelta ? e.wheelDelta : -e.deltaY;
5890 return e.detail || delta > 0;
5893 hoursInputEl.bind('mousewheel wheel', function(e) {
5895 $scope.$apply(isScrollingUp(e) ? $scope.incrementHours() : $scope.decrementHours());
5900 minutesInputEl.bind('mousewheel wheel', function(e) {
5902 $scope.$apply(isScrollingUp(e) ? $scope.incrementMinutes() : $scope.decrementMinutes());
5907 secondsInputEl.bind('mousewheel wheel', function(e) {
5909 $scope.$apply(isScrollingUp(e) ? $scope.incrementSeconds() : $scope.decrementSeconds());
5915 // Respond on up/down arrowkeys
5916 this.setupArrowkeyEvents = function(hoursInputEl, minutesInputEl, secondsInputEl) {
5917 hoursInputEl.bind('keydown', function(e) {
5919 if (e.which === 38) { // up
5921 $scope.incrementHours();
5923 } else if (e.which === 40) { // down
5925 $scope.decrementHours();
5931 minutesInputEl.bind('keydown', function(e) {
5933 if (e.which === 38) { // up
5935 $scope.incrementMinutes();
5937 } else if (e.which === 40) { // down
5939 $scope.decrementMinutes();
5945 secondsInputEl.bind('keydown', function(e) {
5947 if (e.which === 38) { // up
5949 $scope.incrementSeconds();
5951 } else if (e.which === 40) { // down
5953 $scope.decrementSeconds();
5960 this.setupInputEvents = function(hoursInputEl, minutesInputEl, secondsInputEl) {
5961 if ($scope.readonlyInput) {
5962 $scope.updateHours = angular.noop;
5963 $scope.updateMinutes = angular.noop;
5964 $scope.updateSeconds = angular.noop;
5968 var invalidate = function(invalidHours, invalidMinutes, invalidSeconds) {
5969 ngModelCtrl.$setViewValue(null);
5970 ngModelCtrl.$setValidity('time', false);
5971 if (angular.isDefined(invalidHours)) {
5972 $scope.invalidHours = invalidHours;
5975 if (angular.isDefined(invalidMinutes)) {
5976 $scope.invalidMinutes = invalidMinutes;
5979 if (angular.isDefined(invalidSeconds)) {
5980 $scope.invalidSeconds = invalidSeconds;
5984 $scope.updateHours = function() {
5985 var hours = getHoursFromTemplate(),
5986 minutes = getMinutesFromTemplate();
5988 ngModelCtrl.$setDirty();
5990 if (angular.isDefined(hours) && angular.isDefined(minutes)) {
5991 selected.setHours(hours);
5992 selected.setMinutes(minutes);
5993 if (selected < min || selected > max) {
6003 hoursInputEl.bind('blur', function(e) {
6004 ngModelCtrl.$setTouched();
6005 if (modelIsEmpty()) {
6007 } else if ($scope.hours === null || $scope.hours === '') {
6009 } else if (!$scope.invalidHours && $scope.hours < 10) {
6010 $scope.$apply(function() {
6011 $scope.hours = pad($scope.hours, !padHours);
6016 $scope.updateMinutes = function() {
6017 var minutes = getMinutesFromTemplate(),
6018 hours = getHoursFromTemplate();
6020 ngModelCtrl.$setDirty();
6022 if (angular.isDefined(minutes) && angular.isDefined(hours)) {
6023 selected.setHours(hours);
6024 selected.setMinutes(minutes);
6025 if (selected < min || selected > max) {
6026 invalidate(undefined, true);
6031 invalidate(undefined, true);
6035 minutesInputEl.bind('blur', function(e) {
6036 ngModelCtrl.$setTouched();
6037 if (modelIsEmpty()) {
6039 } else if ($scope.minutes === null) {
6040 invalidate(undefined, true);
6041 } else if (!$scope.invalidMinutes && $scope.minutes < 10) {
6042 $scope.$apply(function() {
6043 $scope.minutes = pad($scope.minutes);
6048 $scope.updateSeconds = function() {
6049 var seconds = getSecondsFromTemplate();
6051 ngModelCtrl.$setDirty();
6053 if (angular.isDefined(seconds)) {
6054 selected.setSeconds(seconds);
6057 invalidate(undefined, undefined, true);
6061 secondsInputEl.bind('blur', function(e) {
6062 if (modelIsEmpty()) {
6064 } else if (!$scope.invalidSeconds && $scope.seconds < 10) {
6065 $scope.$apply( function() {
6066 $scope.seconds = pad($scope.seconds);
6073 this.render = function() {
6074 var date = ngModelCtrl.$viewValue;
6077 ngModelCtrl.$setValidity('time', false);
6078 $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.');
6084 if (selected < min || selected > max) {
6085 ngModelCtrl.$setValidity('time', false);
6086 $scope.invalidHours = true;
6087 $scope.invalidMinutes = true;
6095 // Call internally when we know that model is valid.
6096 function refresh(keyboardChange) {
6098 ngModelCtrl.$setViewValue(new Date(selected));
6099 updateTemplate(keyboardChange);
6102 function makeValid() {
6103 ngModelCtrl.$setValidity('time', true);
6104 $scope.invalidHours = false;
6105 $scope.invalidMinutes = false;
6106 $scope.invalidSeconds = false;
6109 function updateTemplate(keyboardChange) {
6110 if (!ngModelCtrl.$modelValue) {
6111 $scope.hours = null;
6112 $scope.minutes = null;
6113 $scope.seconds = null;
6114 $scope.meridian = meridians[0];
6116 var hours = selected.getHours(),
6117 minutes = selected.getMinutes(),
6118 seconds = selected.getSeconds();
6120 if ($scope.showMeridian) {
6121 hours = hours === 0 || hours === 12 ? 12 : hours % 12; // Convert 24 to 12 hour system
6124 $scope.hours = keyboardChange === 'h' ? hours : pad(hours, !padHours);
6125 if (keyboardChange !== 'm') {
6126 $scope.minutes = pad(minutes);
6128 $scope.meridian = selected.getHours() < 12 ? meridians[0] : meridians[1];
6130 if (keyboardChange !== 's') {
6131 $scope.seconds = pad(seconds);
6133 $scope.meridian = selected.getHours() < 12 ? meridians[0] : meridians[1];
6137 function addSecondsToSelected(seconds) {
6138 selected = addSeconds(selected, seconds);
6142 function addMinutes(selected, minutes) {
6143 return addSeconds(selected, minutes*60);
6146 function addSeconds(date, seconds) {
6147 var dt = new Date(date.getTime() + seconds * 1000);
6148 var newDate = new Date(date);
6149 newDate.setHours(dt.getHours(), dt.getMinutes(), dt.getSeconds());
6153 function modelIsEmpty() {
6154 return ($scope.hours === null || $scope.hours === '') &&
6155 ($scope.minutes === null || $scope.minutes === '') &&
6156 (!$scope.showSeconds || $scope.showSeconds && ($scope.seconds === null || $scope.seconds === ''));
6159 $scope.showSpinners = angular.isDefined($attrs.showSpinners) ?
6160 $scope.$parent.$eval($attrs.showSpinners) : timepickerConfig.showSpinners;
6162 $scope.incrementHours = function() {
6163 if (!$scope.noIncrementHours()) {
6164 addSecondsToSelected(hourStep * 60 * 60);
6168 $scope.decrementHours = function() {
6169 if (!$scope.noDecrementHours()) {
6170 addSecondsToSelected(-hourStep * 60 * 60);
6174 $scope.incrementMinutes = function() {
6175 if (!$scope.noIncrementMinutes()) {
6176 addSecondsToSelected(minuteStep * 60);
6180 $scope.decrementMinutes = function() {
6181 if (!$scope.noDecrementMinutes()) {
6182 addSecondsToSelected(-minuteStep * 60);
6186 $scope.incrementSeconds = function() {
6187 if (!$scope.noIncrementSeconds()) {
6188 addSecondsToSelected(secondStep);
6192 $scope.decrementSeconds = function() {
6193 if (!$scope.noDecrementSeconds()) {
6194 addSecondsToSelected(-secondStep);
6198 $scope.toggleMeridian = function() {
6199 var minutes = getMinutesFromTemplate(),
6200 hours = getHoursFromTemplate();
6202 if (!$scope.noToggleMeridian()) {
6203 if (angular.isDefined(minutes) && angular.isDefined(hours)) {
6204 addSecondsToSelected(12 * 60 * (selected.getHours() < 12 ? 60 : -60));
6206 $scope.meridian = $scope.meridian === meridians[0] ? meridians[1] : meridians[0];
6211 $scope.blur = function() {
6212 ngModelCtrl.$setTouched();
6215 $scope.$on('$destroy', function() {
6216 while (watchers.length) {
6222 .directive('uibTimepicker', ['uibTimepickerConfig', function(uibTimepickerConfig) {
6224 require: ['uibTimepicker', '?^ngModel'],
6225 controller: 'UibTimepickerController',
6226 controllerAs: 'timepicker',
6229 templateUrl: function(element, attrs) {
6230 return attrs.templateUrl || uibTimepickerConfig.templateUrl;
6232 link: function(scope, element, attrs, ctrls) {
6233 var timepickerCtrl = ctrls[0], ngModelCtrl = ctrls[1];
6236 timepickerCtrl.init(ngModelCtrl, element.find('input'));
6242 angular.module('ui.bootstrap.typeahead', ['ui.bootstrap.debounce', 'ui.bootstrap.position'])
6245 * A helper service that can parse typeahead's syntax (string provided by users)
6246 * Extracted to a separate service for ease of unit testing
6248 .factory('uibTypeaheadParser', ['$parse', function($parse) {
6249 // 00000111000000000000022200000000000000003333333333333330000000000044000
6250 var TYPEAHEAD_REGEXP = /^\s*([\s\S]+?)(?:\s+as\s+([\s\S]+?))?\s+for\s+(?:([\$\w][\$\w\d]*))\s+in\s+([\s\S]+?)$/;
6252 parse: function(input) {
6253 var match = input.match(TYPEAHEAD_REGEXP);
6256 'Expected typeahead specification in form of "_modelValue_ (as _label_)? for _item_ in _collection_"' +
6257 ' but got "' + input + '".');
6262 source: $parse(match[4]),
6263 viewMapper: $parse(match[2] || match[1]),
6264 modelMapper: $parse(match[1])
6270 .controller('UibTypeaheadController', ['$scope', '$element', '$attrs', '$compile', '$parse', '$q', '$timeout', '$document', '$window', '$rootScope', '$$debounce', '$uibPosition', 'uibTypeaheadParser',
6271 function(originalScope, element, attrs, $compile, $parse, $q, $timeout, $document, $window, $rootScope, $$debounce, $position, typeaheadParser) {
6272 var HOT_KEYS = [9, 13, 27, 38, 40];
6273 var eventDebounceTime = 200;
6274 var modelCtrl, ngModelOptions;
6275 //SUPPORTED ATTRIBUTES (OPTIONS)
6277 //minimal no of characters that needs to be entered before typeahead kicks-in
6278 var minLength = originalScope.$eval(attrs.typeaheadMinLength);
6279 if (!minLength && minLength !== 0) {
6283 originalScope.$watch(attrs.typeaheadMinLength, function (newVal) {
6284 minLength = !newVal && newVal !== 0 ? 1 : newVal;
6287 //minimal wait time after last character typed before typeahead kicks-in
6288 var waitTime = originalScope.$eval(attrs.typeaheadWaitMs) || 0;
6290 //should it restrict model values to the ones selected from the popup only?
6291 var isEditable = originalScope.$eval(attrs.typeaheadEditable) !== false;
6292 originalScope.$watch(attrs.typeaheadEditable, function (newVal) {
6293 isEditable = newVal !== false;
6296 //binding to a variable that indicates if matches are being retrieved asynchronously
6297 var isLoadingSetter = $parse(attrs.typeaheadLoading).assign || angular.noop;
6299 //a callback executed when a match is selected
6300 var onSelectCallback = $parse(attrs.typeaheadOnSelect);
6302 //should it select highlighted popup value when losing focus?
6303 var isSelectOnBlur = angular.isDefined(attrs.typeaheadSelectOnBlur) ? originalScope.$eval(attrs.typeaheadSelectOnBlur) : false;
6305 //binding to a variable that indicates if there were no results after the query is completed
6306 var isNoResultsSetter = $parse(attrs.typeaheadNoResults).assign || angular.noop;
6308 var inputFormatter = attrs.typeaheadInputFormatter ? $parse(attrs.typeaheadInputFormatter) : undefined;
6310 var appendToBody = attrs.typeaheadAppendToBody ? originalScope.$eval(attrs.typeaheadAppendToBody) : false;
6312 var appendTo = attrs.typeaheadAppendTo ?
6313 originalScope.$eval(attrs.typeaheadAppendTo) : null;
6315 var focusFirst = originalScope.$eval(attrs.typeaheadFocusFirst) !== false;
6317 //If input matches an item of the list exactly, select it automatically
6318 var selectOnExact = attrs.typeaheadSelectOnExact ? originalScope.$eval(attrs.typeaheadSelectOnExact) : false;
6320 //binding to a variable that indicates if dropdown is open
6321 var isOpenSetter = $parse(attrs.typeaheadIsOpen).assign || angular.noop;
6323 var showHint = originalScope.$eval(attrs.typeaheadShowHint) || false;
6325 //INTERNAL VARIABLES
6327 //model setter executed upon match selection
6328 var parsedModel = $parse(attrs.ngModel);
6329 var invokeModelSetter = $parse(attrs.ngModel + '($$$p)');
6330 var $setModelValue = function(scope, newValue) {
6331 if (angular.isFunction(parsedModel(originalScope)) &&
6332 ngModelOptions && ngModelOptions.$options && ngModelOptions.$options.getterSetter) {
6333 return invokeModelSetter(scope, {$$$p: newValue});
6336 return parsedModel.assign(scope, newValue);
6339 //expressions used by typeahead
6340 var parserResult = typeaheadParser.parse(attrs.uibTypeahead);
6344 //Used to avoid bug in iOS webview where iOS keyboard does not fire
6345 //mousedown & mouseup events
6349 //create a child scope for the typeahead directive so we are not polluting original scope
6350 //with typeahead-specific data (matches, query etc.)
6351 var scope = originalScope.$new();
6352 var offDestroy = originalScope.$on('$destroy', function() {
6355 scope.$on('$destroy', offDestroy);
6358 var popupId = 'typeahead-' + scope.$id + '-' + Math.floor(Math.random() * 10000);
6360 'aria-autocomplete': 'list',
6361 'aria-expanded': false,
6362 'aria-owns': popupId
6365 var inputsContainer, hintInputElem;
6366 //add read-only input to show hint
6368 inputsContainer = angular.element('<div></div>');
6369 inputsContainer.css('position', 'relative');
6370 element.after(inputsContainer);
6371 hintInputElem = element.clone();
6372 hintInputElem.attr('placeholder', '');
6373 hintInputElem.attr('tabindex', '-1');
6374 hintInputElem.val('');
6376 'position': 'absolute',
6379 'border-color': 'transparent',
6380 'box-shadow': 'none',
6382 'background': 'none 0% 0% / auto repeat scroll padding-box border-box rgb(255, 255, 255)',
6386 'position': 'relative',
6387 'vertical-align': 'top',
6388 'background-color': 'transparent'
6390 inputsContainer.append(hintInputElem);
6391 hintInputElem.after(element);
6394 //pop-up element used to display matches
6395 var popUpEl = angular.element('<div uib-typeahead-popup></div>');
6399 active: 'activeIdx',
6400 select: 'select(activeIdx, evt)',
6401 'move-in-progress': 'moveInProgress',
6403 position: 'position',
6404 'assign-is-open': 'assignIsOpen(isOpen)',
6405 debounce: 'debounceUpdate'
6407 //custom item template
6408 if (angular.isDefined(attrs.typeaheadTemplateUrl)) {
6409 popUpEl.attr('template-url', attrs.typeaheadTemplateUrl);
6412 if (angular.isDefined(attrs.typeaheadPopupTemplateUrl)) {
6413 popUpEl.attr('popup-template-url', attrs.typeaheadPopupTemplateUrl);
6416 var resetHint = function() {
6418 hintInputElem.val('');
6422 var resetMatches = function() {
6424 scope.activeIdx = -1;
6425 element.attr('aria-expanded', false);
6429 var getMatchId = function(index) {
6430 return popupId + '-option-' + index;
6433 // Indicate that the specified match is the active (pre-selected) item in the list owned by this typeahead.
6434 // This attribute is added or removed automatically when the `activeIdx` changes.
6435 scope.$watch('activeIdx', function(index) {
6437 element.removeAttr('aria-activedescendant');
6439 element.attr('aria-activedescendant', getMatchId(index));
6443 var inputIsExactMatch = function(inputValue, index) {
6444 if (scope.matches.length > index && inputValue) {
6445 return inputValue.toUpperCase() === scope.matches[index].label.toUpperCase();
6451 var getMatchesAsync = function(inputValue, evt) {
6452 var locals = {$viewValue: inputValue};
6453 isLoadingSetter(originalScope, true);
6454 isNoResultsSetter(originalScope, false);
6455 $q.when(parserResult.source(originalScope, locals)).then(function(matches) {
6456 //it might happen that several async queries were in progress if a user were typing fast
6457 //but we are interested only in responses that correspond to the current view value
6458 var onCurrentRequest = inputValue === modelCtrl.$viewValue;
6459 if (onCurrentRequest && hasFocus) {
6460 if (matches && matches.length > 0) {
6461 scope.activeIdx = focusFirst ? 0 : -1;
6462 isNoResultsSetter(originalScope, false);
6463 scope.matches.length = 0;
6466 for (var i = 0; i < matches.length; i++) {
6467 locals[parserResult.itemName] = matches[i];
6468 scope.matches.push({
6470 label: parserResult.viewMapper(scope, locals),
6475 scope.query = inputValue;
6476 //position pop-up with matches - we need to re-calculate its position each time we are opening a window
6477 //with matches as a pop-up might be absolute-positioned and position of an input might have changed on a page
6478 //due to other elements being rendered
6479 recalculatePosition();
6481 element.attr('aria-expanded', true);
6483 //Select the single remaining option if user input matches
6484 if (selectOnExact && scope.matches.length === 1 && inputIsExactMatch(inputValue, 0)) {
6485 if (angular.isNumber(scope.debounceUpdate) || angular.isObject(scope.debounceUpdate)) {
6486 $$debounce(function() {
6487 scope.select(0, evt);
6488 }, angular.isNumber(scope.debounceUpdate) ? scope.debounceUpdate : scope.debounceUpdate['default']);
6490 scope.select(0, evt);
6495 var firstLabel = scope.matches[0].label;
6496 if (angular.isString(inputValue) &&
6497 inputValue.length > 0 &&
6498 firstLabel.slice(0, inputValue.length).toUpperCase() === inputValue.toUpperCase()) {
6499 hintInputElem.val(inputValue + firstLabel.slice(inputValue.length));
6501 hintInputElem.val('');
6506 isNoResultsSetter(originalScope, true);
6509 if (onCurrentRequest) {
6510 isLoadingSetter(originalScope, false);
6514 isLoadingSetter(originalScope, false);
6515 isNoResultsSetter(originalScope, true);
6519 // bind events only if appendToBody params exist - performance feature
6521 angular.element($window).on('resize', fireRecalculating);
6522 $document.find('body').on('scroll', fireRecalculating);
6525 // Declare the debounced function outside recalculating for
6526 // proper debouncing
6527 var debouncedRecalculate = $$debounce(function() {
6528 // if popup is visible
6529 if (scope.matches.length) {
6530 recalculatePosition();
6533 scope.moveInProgress = false;
6534 }, eventDebounceTime);
6536 // Default progress type
6537 scope.moveInProgress = false;
6539 function fireRecalculating() {
6540 if (!scope.moveInProgress) {
6541 scope.moveInProgress = true;
6545 debouncedRecalculate();
6548 // recalculate actual position and set new values to scope
6549 // after digest loop is popup in right position
6550 function recalculatePosition() {
6551 scope.position = appendToBody ? $position.offset(element) : $position.position(element);
6552 scope.position.top += element.prop('offsetHeight');
6555 //we need to propagate user's query so we can higlight matches
6556 scope.query = undefined;
6558 //Declare the timeout promise var outside the function scope so that stacked calls can be cancelled later
6561 var scheduleSearchWithTimeout = function(inputValue) {
6562 timeoutPromise = $timeout(function() {
6563 getMatchesAsync(inputValue);
6567 var cancelPreviousTimeout = function() {
6568 if (timeoutPromise) {
6569 $timeout.cancel(timeoutPromise);
6575 scope.assignIsOpen = function (isOpen) {
6576 isOpenSetter(originalScope, isOpen);
6579 scope.select = function(activeIdx, evt) {
6580 //called from within the $digest() cycle
6585 locals[parserResult.itemName] = item = scope.matches[activeIdx].model;
6586 model = parserResult.modelMapper(originalScope, locals);
6587 $setModelValue(originalScope, model);
6588 modelCtrl.$setValidity('editable', true);
6589 modelCtrl.$setValidity('parse', true);
6591 onSelectCallback(originalScope, {
6594 $label: parserResult.viewMapper(originalScope, locals),
6600 //return focus to the input element if a match was selected via a mouse click event
6601 // use timeout to avoid $rootScope:inprog error
6602 if (scope.$eval(attrs.typeaheadFocusOnSelect) !== false) {
6603 $timeout(function() { element[0].focus(); }, 0, false);
6607 //bind keyboard events: arrows up(38) / down(40), enter(13) and tab(9), esc(27)
6608 element.on('keydown', function(evt) {
6609 //typeahead is open and an "interesting" key was pressed
6610 if (scope.matches.length === 0 || HOT_KEYS.indexOf(evt.which) === -1) {
6615 * if there's nothing selected (i.e. focusFirst) and enter or tab is hit
6617 * shift + tab is pressed to bring focus to the previous element
6618 * then clear the results
6620 if (scope.activeIdx === -1 && (evt.which === 9 || evt.which === 13) || evt.which === 9 && !!evt.shiftKey) {
6626 evt.preventDefault();
6628 switch (evt.which) {
6631 scope.$apply(function () {
6632 if (angular.isNumber(scope.debounceUpdate) || angular.isObject(scope.debounceUpdate)) {
6633 $$debounce(function() {
6634 scope.select(scope.activeIdx, evt);
6635 }, angular.isNumber(scope.debounceUpdate) ? scope.debounceUpdate : scope.debounceUpdate['default']);
6637 scope.select(scope.activeIdx, evt);
6642 evt.stopPropagation();
6645 originalScope.$digest();
6648 scope.activeIdx = (scope.activeIdx > 0 ? scope.activeIdx : scope.matches.length) - 1;
6650 target = popUpEl.find('li')[scope.activeIdx];
6651 target.parentNode.scrollTop = target.offsetTop;
6654 scope.activeIdx = (scope.activeIdx + 1) % scope.matches.length;
6656 target = popUpEl.find('li')[scope.activeIdx];
6657 target.parentNode.scrollTop = target.offsetTop;
6662 element.bind('focus', function (evt) {
6664 if (minLength === 0 && !modelCtrl.$viewValue) {
6665 $timeout(function() {
6666 getMatchesAsync(modelCtrl.$viewValue, evt);
6671 element.bind('blur', function(evt) {
6672 if (isSelectOnBlur && scope.matches.length && scope.activeIdx !== -1 && !selected) {
6674 scope.$apply(function() {
6675 if (angular.isObject(scope.debounceUpdate) && angular.isNumber(scope.debounceUpdate.blur)) {
6676 $$debounce(function() {
6677 scope.select(scope.activeIdx, evt);
6678 }, scope.debounceUpdate.blur);
6680 scope.select(scope.activeIdx, evt);
6684 if (!isEditable && modelCtrl.$error.editable) {
6685 modelCtrl.$setViewValue();
6686 // Reset validity as we are clearing
6687 modelCtrl.$setValidity('editable', true);
6688 modelCtrl.$setValidity('parse', true);
6695 // Keep reference to click handler to unbind it.
6696 var dismissClickHandler = function(evt) {
6698 // Firefox treats right click as a click on document
6699 if (element[0] !== evt.target && evt.which !== 3 && scope.matches.length !== 0) {
6701 if (!$rootScope.$$phase) {
6702 originalScope.$digest();
6707 $document.on('click', dismissClickHandler);
6709 originalScope.$on('$destroy', function() {
6710 $document.off('click', dismissClickHandler);
6711 if (appendToBody || appendTo) {
6716 angular.element($window).off('resize', fireRecalculating);
6717 $document.find('body').off('scroll', fireRecalculating);
6719 // Prevent jQuery cache memory leak
6723 inputsContainer.remove();
6727 var $popup = $compile(popUpEl)(scope);
6730 $document.find('body').append($popup);
6731 } else if (appendTo) {
6732 angular.element(appendTo).eq(0).append($popup);
6734 element.after($popup);
6737 this.init = function(_modelCtrl, _ngModelOptions) {
6738 modelCtrl = _modelCtrl;
6739 ngModelOptions = _ngModelOptions;
6741 scope.debounceUpdate = modelCtrl.$options && $parse(modelCtrl.$options.debounce)(originalScope);
6743 //plug into $parsers pipeline to open a typeahead on view changes initiated from DOM
6744 //$parsers kick-in on all the changes coming from the view as well as manually triggered by $setViewValue
6745 modelCtrl.$parsers.unshift(function(inputValue) {
6748 if (minLength === 0 || inputValue && inputValue.length >= minLength) {
6750 cancelPreviousTimeout();
6751 scheduleSearchWithTimeout(inputValue);
6753 getMatchesAsync(inputValue);
6756 isLoadingSetter(originalScope, false);
6757 cancelPreviousTimeout();
6766 // Reset in case user had typed something previously.
6767 modelCtrl.$setValidity('editable', true);
6771 modelCtrl.$setValidity('editable', false);
6775 modelCtrl.$formatters.push(function(modelValue) {
6776 var candidateViewValue, emptyViewValue;
6779 // The validity may be set to false via $parsers (see above) if
6780 // the model is restricted to selected values. If the model
6781 // is set manually it is considered to be valid.
6783 modelCtrl.$setValidity('editable', true);
6786 if (inputFormatter) {
6787 locals.$model = modelValue;
6788 return inputFormatter(originalScope, locals);
6791 //it might happen that we don't have enough info to properly render input value
6792 //we need to check for this situation and simply return model value if we can't apply custom formatting
6793 locals[parserResult.itemName] = modelValue;
6794 candidateViewValue = parserResult.viewMapper(originalScope, locals);
6795 locals[parserResult.itemName] = undefined;
6796 emptyViewValue = parserResult.viewMapper(originalScope, locals);
6798 return candidateViewValue !== emptyViewValue ? candidateViewValue : modelValue;
6803 .directive('uibTypeahead', function() {
6805 controller: 'UibTypeaheadController',
6806 require: ['ngModel', '^?ngModelOptions', 'uibTypeahead'],
6807 link: function(originalScope, element, attrs, ctrls) {
6808 ctrls[2].init(ctrls[0], ctrls[1]);
6813 .directive('uibTypeaheadPopup', ['$$debounce', function($$debounce) {
6820 moveInProgress: '=',
6826 templateUrl: function(element, attrs) {
6827 return attrs.popupTemplateUrl || 'uib/template/typeahead/typeahead-popup.html';
6829 link: function(scope, element, attrs) {
6830 scope.templateUrl = attrs.templateUrl;
6832 scope.isOpen = function() {
6833 var isDropdownOpen = scope.matches.length > 0;
6834 scope.assignIsOpen({ isOpen: isDropdownOpen });
6835 return isDropdownOpen;
6838 scope.isActive = function(matchIdx) {
6839 return scope.active === matchIdx;
6842 scope.selectActive = function(matchIdx) {
6843 scope.active = matchIdx;
6846 scope.selectMatch = function(activeIdx, evt) {
6847 var debounce = scope.debounce();
6848 if (angular.isNumber(debounce) || angular.isObject(debounce)) {
6849 $$debounce(function() {
6850 scope.select({activeIdx: activeIdx, evt: evt});
6851 }, angular.isNumber(debounce) ? debounce : debounce['default']);
6853 scope.select({activeIdx: activeIdx, evt: evt});
6860 .directive('uibTypeaheadMatch', ['$templateRequest', '$compile', '$parse', function($templateRequest, $compile, $parse) {
6867 link: function(scope, element, attrs) {
6868 var tplUrl = $parse(attrs.templateUrl)(scope.$parent) || 'uib/template/typeahead/typeahead-match.html';
6869 $templateRequest(tplUrl).then(function(tplContent) {
6870 var tplEl = angular.element(tplContent.trim());
6871 element.replaceWith(tplEl);
6872 $compile(tplEl)(scope);
6878 .filter('uibTypeaheadHighlight', ['$sce', '$injector', '$log', function($sce, $injector, $log) {
6879 var isSanitizePresent;
6880 isSanitizePresent = $injector.has('$sanitize');
6882 function escapeRegexp(queryToEscape) {
6883 // Regex: capture the whole query string and replace it with the string that will be used to match
6884 // the results, for example if the capture is "a" the result will be \a
6885 return queryToEscape.replace(/([.?*+^$[\]\\(){}|-])/g, '\\$1');
6888 function containsHtml(matchItem) {
6889 return /<.*>/g.test(matchItem);
6892 return function(matchItem, query) {
6893 if (!isSanitizePresent && containsHtml(matchItem)) {
6894 $log.warn('Unsafe use of typeahead please use ngSanitize'); // Warn the user about the danger
6896 matchItem = query ? ('' + matchItem).replace(new RegExp(escapeRegexp(query), 'gi'), '<strong>$&</strong>') : matchItem; // Replaces the capture string with a the same string inside of a "strong" tag
6897 if (!isSanitizePresent) {
6898 matchItem = $sce.trustAsHtml(matchItem); // If $sanitize is not present we pack the string in a $sce object for the ng-bind-html directive
6904 angular.module("uib/template/accordion/accordion-group.html", []).run(["$templateCache", function($templateCache) {
6905 $templateCache.put("uib/template/accordion/accordion-group.html",
6906 "<div class=\"panel\" ng-class=\"panelClass || 'panel-default'\">\n" +
6907 " <div role=\"tab\" id=\"{{::headingId}}\" aria-selected=\"{{isOpen}}\" class=\"panel-heading\" ng-keypress=\"toggleOpen($event)\">\n" +
6908 " <h4 class=\"panel-title\">\n" +
6909 " <a role=\"button\" data-toggle=\"collapse\" href aria-expanded=\"{{isOpen}}\" aria-controls=\"{{::panelId}}\" tabindex=\"0\" class=\"accordion-toggle\" ng-click=\"toggleOpen()\" uib-accordion-transclude=\"heading\"><span uib-accordion-header ng-class=\"{'text-muted': isDisabled}\">{{heading}}</span></a>\n" +
6912 " <div id=\"{{::panelId}}\" aria-labelledby=\"{{::headingId}}\" aria-hidden=\"{{!isOpen}}\" role=\"tabpanel\" class=\"panel-collapse collapse\" uib-collapse=\"!isOpen\">\n" +
6913 " <div class=\"panel-body\" ng-transclude></div>\n" +
6919 angular.module("uib/template/accordion/accordion.html", []).run(["$templateCache", function($templateCache) {
6920 $templateCache.put("uib/template/accordion/accordion.html",
6921 "<div role=\"tablist\" class=\"panel-group\" ng-transclude></div>");
6924 angular.module("uib/template/alert/alert.html", []).run(["$templateCache", function($templateCache) {
6925 $templateCache.put("uib/template/alert/alert.html",
6926 "<div class=\"alert\" ng-class=\"['alert-' + (type || 'warning'), closeable ? 'alert-dismissible' : null]\" role=\"alert\">\n" +
6927 " <button ng-show=\"closeable\" type=\"button\" class=\"close\" ng-click=\"close({$event: $event})\">\n" +
6928 " <span aria-hidden=\"true\">×</span>\n" +
6929 " <span class=\"sr-only\">Close</span>\n" +
6931 " <div ng-transclude></div>\n" +
6936 angular.module("uib/template/carousel/carousel.html", []).run(["$templateCache", function($templateCache) {
6937 $templateCache.put("uib/template/carousel/carousel.html",
6938 "<div ng-mouseenter=\"pause()\" ng-mouseleave=\"play()\" class=\"carousel\" ng-swipe-right=\"prev()\" ng-swipe-left=\"next()\">\n" +
6939 " <div class=\"carousel-inner\" ng-transclude></div>\n" +
6940 " <a role=\"button\" href class=\"left carousel-control\" ng-click=\"prev()\" ng-class=\"{ disabled: isPrevDisabled() }\" ng-show=\"slides.length > 1\">\n" +
6941 " <span aria-hidden=\"true\" class=\"glyphicon glyphicon-chevron-left\"></span>\n" +
6942 " <span class=\"sr-only\">previous</span>\n" +
6944 " <a role=\"button\" href class=\"right carousel-control\" ng-click=\"next()\" ng-class=\"{ disabled: isNextDisabled() }\" ng-show=\"slides.length > 1\">\n" +
6945 " <span aria-hidden=\"true\" class=\"glyphicon glyphicon-chevron-right\"></span>\n" +
6946 " <span class=\"sr-only\">next</span>\n" +
6948 " <ol class=\"carousel-indicators\" ng-show=\"slides.length > 1\">\n" +
6949 " <li ng-repeat=\"slide in slides | orderBy:indexOfSlide track by $index\" ng-class=\"{ active: isActive(slide) }\" ng-click=\"select(slide)\">\n" +
6950 " <span class=\"sr-only\">slide {{ $index + 1 }} of {{ slides.length }}<span ng-if=\"isActive(slide)\">, currently active</span></span>\n" +
6957 angular.module("uib/template/carousel/slide.html", []).run(["$templateCache", function($templateCache) {
6958 $templateCache.put("uib/template/carousel/slide.html",
6959 "<div ng-class=\"{\n" +
6960 " 'active': active\n" +
6961 " }\" class=\"item text-center\" ng-transclude></div>\n" +
6965 angular.module("uib/template/datepicker/datepicker.html", []).run(["$templateCache", function($templateCache) {
6966 $templateCache.put("uib/template/datepicker/datepicker.html",
6967 "<div class=\"uib-datepicker\" ng-switch=\"datepickerMode\" role=\"application\" ng-keydown=\"keydown($event)\">\n" +
6968 " <uib-daypicker ng-switch-when=\"day\" tabindex=\"0\"></uib-daypicker>\n" +
6969 " <uib-monthpicker ng-switch-when=\"month\" tabindex=\"0\"></uib-monthpicker>\n" +
6970 " <uib-yearpicker ng-switch-when=\"year\" tabindex=\"0\"></uib-yearpicker>\n" +
6975 angular.module("uib/template/datepicker/day.html", []).run(["$templateCache", function($templateCache) {
6976 $templateCache.put("uib/template/datepicker/day.html",
6977 "<table class=\"uib-daypicker\" role=\"grid\" aria-labelledby=\"{{::uniqueId}}-title\" aria-activedescendant=\"{{activeDateId}}\">\n" +
6980 " <th><button type=\"button\" class=\"btn btn-default btn-sm pull-left uib-left\" ng-click=\"move(-1)\" tabindex=\"-1\"><i class=\"glyphicon glyphicon-chevron-left\"></i></button></th>\n" +
6981 " <th colspan=\"{{::5 + showWeeks}}\"><button id=\"{{::uniqueId}}-title\" role=\"heading\" aria-live=\"assertive\" aria-atomic=\"true\" type=\"button\" class=\"btn btn-default btn-sm uib-title\" ng-click=\"toggleMode()\" ng-disabled=\"datepickerMode === maxMode\" tabindex=\"-1\"><strong>{{title}}</strong></button></th>\n" +
6982 " <th><button type=\"button\" class=\"btn btn-default btn-sm pull-right uib-right\" ng-click=\"move(1)\" tabindex=\"-1\"><i class=\"glyphicon glyphicon-chevron-right\"></i></button></th>\n" +
6985 " <th ng-if=\"showWeeks\" class=\"text-center\"></th>\n" +
6986 " <th ng-repeat=\"label in ::labels track by $index\" class=\"text-center\"><small aria-label=\"{{::label.full}}\">{{::label.abbr}}</small></th>\n" +
6990 " <tr class=\"uib-weeks\" ng-repeat=\"row in rows track by $index\">\n" +
6991 " <td ng-if=\"showWeeks\" class=\"text-center h6\"><em>{{ weekNumbers[$index] }}</em></td>\n" +
6992 " <td ng-repeat=\"dt in row\" class=\"uib-day text-center\" role=\"gridcell\"\n" +
6993 " id=\"{{::dt.uid}}\"\n" +
6994 " ng-class=\"::dt.customClass\">\n" +
6995 " <button type=\"button\" class=\"btn btn-default btn-sm\"\n" +
6996 " uib-is-class=\"\n" +
6997 " 'btn-info' for selectedDt,\n" +
6998 " 'active' for activeDt\n" +
7000 " ng-click=\"select(dt.date)\"\n" +
7001 " ng-disabled=\"::dt.disabled\"\n" +
7002 " tabindex=\"-1\"><span ng-class=\"::{'text-muted': dt.secondary, 'text-info': dt.current}\">{{::dt.label}}</span></button>\n" +
7010 angular.module("uib/template/datepicker/month.html", []).run(["$templateCache", function($templateCache) {
7011 $templateCache.put("uib/template/datepicker/month.html",
7012 "<table class=\"uib-monthpicker\" role=\"grid\" aria-labelledby=\"{{::uniqueId}}-title\" aria-activedescendant=\"{{activeDateId}}\">\n" +
7015 " <th><button type=\"button\" class=\"btn btn-default btn-sm pull-left uib-left\" ng-click=\"move(-1)\" tabindex=\"-1\"><i class=\"glyphicon glyphicon-chevron-left\"></i></button></th>\n" +
7016 " <th><button id=\"{{::uniqueId}}-title\" role=\"heading\" aria-live=\"assertive\" aria-atomic=\"true\" type=\"button\" class=\"btn btn-default btn-sm uib-title\" ng-click=\"toggleMode()\" ng-disabled=\"datepickerMode === maxMode\" tabindex=\"-1\"><strong>{{title}}</strong></button></th>\n" +
7017 " <th><button type=\"button\" class=\"btn btn-default btn-sm pull-right uib-right\" ng-click=\"move(1)\" tabindex=\"-1\"><i class=\"glyphicon glyphicon-chevron-right\"></i></button></th>\n" +
7021 " <tr class=\"uib-months\" ng-repeat=\"row in rows track by $index\">\n" +
7022 " <td ng-repeat=\"dt in row\" class=\"uib-month text-center\" role=\"gridcell\"\n" +
7023 " id=\"{{::dt.uid}}\"\n" +
7024 " ng-class=\"::dt.customClass\">\n" +
7025 " <button type=\"button\" class=\"btn btn-default\"\n" +
7026 " uib-is-class=\"\n" +
7027 " 'btn-info' for selectedDt,\n" +
7028 " 'active' for activeDt\n" +
7030 " ng-click=\"select(dt.date)\"\n" +
7031 " ng-disabled=\"::dt.disabled\"\n" +
7032 " tabindex=\"-1\"><span ng-class=\"::{'text-info': dt.current}\">{{::dt.label}}</span></button>\n" +
7040 angular.module("uib/template/datepicker/year.html", []).run(["$templateCache", function($templateCache) {
7041 $templateCache.put("uib/template/datepicker/year.html",
7042 "<table class=\"uib-yearpicker\" role=\"grid\" aria-labelledby=\"{{::uniqueId}}-title\" aria-activedescendant=\"{{activeDateId}}\">\n" +
7045 " <th><button type=\"button\" class=\"btn btn-default btn-sm pull-left uib-left\" ng-click=\"move(-1)\" tabindex=\"-1\"><i class=\"glyphicon glyphicon-chevron-left\"></i></button></th>\n" +
7046 " <th colspan=\"{{::columns - 2}}\"><button id=\"{{::uniqueId}}-title\" role=\"heading\" aria-live=\"assertive\" aria-atomic=\"true\" type=\"button\" class=\"btn btn-default btn-sm uib-title\" ng-click=\"toggleMode()\" ng-disabled=\"datepickerMode === maxMode\" tabindex=\"-1\"><strong>{{title}}</strong></button></th>\n" +
7047 " <th><button type=\"button\" class=\"btn btn-default btn-sm pull-right uib-right\" ng-click=\"move(1)\" tabindex=\"-1\"><i class=\"glyphicon glyphicon-chevron-right\"></i></button></th>\n" +
7051 " <tr class=\"uib-years\" ng-repeat=\"row in rows track by $index\">\n" +
7052 " <td ng-repeat=\"dt in row\" class=\"uib-year text-center\" role=\"gridcell\"\n" +
7053 " id=\"{{::dt.uid}}\"\n" +
7054 " ng-class=\"::dt.customClass\">\n" +
7055 " <button type=\"button\" class=\"btn btn-default\"\n" +
7056 " uib-is-class=\"\n" +
7057 " 'btn-info' for selectedDt,\n" +
7058 " 'active' for activeDt\n" +
7060 " ng-click=\"select(dt.date)\"\n" +
7061 " ng-disabled=\"::dt.disabled\"\n" +
7062 " tabindex=\"-1\"><span ng-class=\"::{'text-info': dt.current}\">{{::dt.label}}</span></button>\n" +
7070 angular.module("uib/template/datepickerPopup/popup.html", []).run(["$templateCache", function($templateCache) {
7071 $templateCache.put("uib/template/datepickerPopup/popup.html",
7073 " <ul class=\"uib-datepicker-popup dropdown-menu uib-position-measure\" dropdown-nested ng-if=\"isOpen\" ng-keydown=\"keydown($event)\" ng-click=\"$event.stopPropagation()\">\n" +
7074 " <li ng-transclude></li>\n" +
7075 " <li ng-if=\"showButtonBar\" class=\"uib-button-bar\">\n" +
7076 " <span class=\"btn-group pull-left\">\n" +
7077 " <button type=\"button\" class=\"btn btn-sm btn-info uib-datepicker-current\" ng-click=\"select('today', $event)\" ng-disabled=\"isDisabled('today')\">{{ getText('current') }}</button>\n" +
7078 " <button type=\"button\" class=\"btn btn-sm btn-danger uib-clear\" ng-click=\"select(null, $event)\">{{ getText('clear') }}</button>\n" +
7080 " <button type=\"button\" class=\"btn btn-sm btn-success pull-right uib-close\" ng-click=\"close($event)\">{{ getText('close') }}</button>\n" +
7087 angular.module("uib/template/modal/backdrop.html", []).run(["$templateCache", function($templateCache) {
7088 $templateCache.put("uib/template/modal/backdrop.html",
7089 "<div class=\"angular-content modal-backdrop\"\n" +
7090 " uib-modal-animation-class=\"fade\"\n" +
7091 " modal-in-class=\"in\"\n" +
7092 " ng-style=\"{'z-index': 1040 + (index && 1 || 0) + index*10}\"\n" +
7097 angular.module("uib/template/modal/window.html", []).run(["$templateCache", function($templateCache) {
7098 $templateCache.put("uib/template/modal/window.html",
7099 "<div modal-render=\"{{$isRendered}}\" tabindex=\"-1\" role=\"dialog\" class=\"angular-content modal\"\n" +
7100 " uib-modal-animation-class=\"fade\"\n" +
7101 " modal-in-class=\"in\"\n" +
7102 " ng-style=\"{'z-index': 1050 + index*10, display: 'block'}\">\n" +
7103 " <div class=\"modal-dialog {{size ? 'modal-' + size : ''}}\"><div class=\"modal-content\" uib-modal-transclude></div></div>\n" +
7108 angular.module("uib/template/pager/pager.html", []).run(["$templateCache", function($templateCache) {
7109 $templateCache.put("uib/template/pager/pager.html",
7110 "<ul class=\"pager\">\n" +
7111 " <li ng-class=\"{disabled: noPrevious()||ngDisabled, previous: align}\"><a href ng-click=\"selectPage(page - 1, $event)\">{{::getText('previous')}}</a></li>\n" +
7112 " <li ng-class=\"{disabled: noNext()||ngDisabled, next: align}\"><a href ng-click=\"selectPage(page + 1, $event)\">{{::getText('next')}}</a></li>\n" +
7117 angular.module("uib/template/pagination/pagination.html", []).run(["$templateCache", function($templateCache) {
7118 $templateCache.put("uib/template/pagination/pagination.html",
7119 "<ul class=\"pagination\">\n" +
7120 " <li ng-if=\"::boundaryLinks\" ng-class=\"{disabled: noPrevious()||ngDisabled}\" class=\"pagination-first\"><a href ng-click=\"selectPage(1, $event)\">{{::getText('first')}}</a></li>\n" +
7121 " <li ng-if=\"::directionLinks\" ng-class=\"{disabled: noPrevious()||ngDisabled}\" class=\"pagination-prev\"><a href ng-click=\"selectPage(page - 1, $event)\">{{::getText('previous')}}</a></li>\n" +
7122 " <li ng-repeat=\"page in pages track by $index\" ng-class=\"{active: page.active,disabled: ngDisabled&&!page.active}\" class=\"pagination-page\"><a href ng-click=\"selectPage(page.number, $event)\">{{page.text}}</a></li>\n" +
7123 " <li ng-if=\"::directionLinks\" ng-class=\"{disabled: noNext()||ngDisabled}\" class=\"pagination-next\"><a href ng-click=\"selectPage(page + 1, $event)\">{{::getText('next')}}</a></li>\n" +
7124 " <li ng-if=\"::boundaryLinks\" ng-class=\"{disabled: noNext()||ngDisabled}\" class=\"pagination-last\"><a href ng-click=\"selectPage(totalPages, $event)\">{{::getText('last')}}</a></li>\n" +
7129 angular.module("uib/template/tooltip/tooltip-html-popup.html", []).run(["$templateCache", function($templateCache) {
7130 $templateCache.put("uib/template/tooltip/tooltip-html-popup.html",
7131 "<div class=\"tooltip\"\n" +
7132 " tooltip-animation-class=\"fade\"\n" +
7133 " uib-tooltip-classes\n" +
7134 " ng-class=\"{ in: isOpen() }\">\n" +
7135 " <div class=\"tooltip-arrow\"></div>\n" +
7136 " <div class=\"tooltip-inner\" ng-bind-html=\"contentExp()\"></div>\n" +
7141 angular.module("uib/template/tooltip/tooltip-popup.html", []).run(["$templateCache", function($templateCache) {
7142 $templateCache.put("uib/template/tooltip/tooltip-popup.html",
7143 "<div class=\"tooltip\"\n" +
7144 " tooltip-animation-class=\"fade\"\n" +
7145 " uib-tooltip-classes\n" +
7146 " ng-class=\"{ in: isOpen() }\">\n" +
7147 " <div class=\"tooltip-arrow\"></div>\n" +
7148 " <div class=\"tooltip-inner\" ng-bind=\"content\"></div>\n" +
7153 angular.module("uib/template/tooltip/tooltip-template-popup.html", []).run(["$templateCache", function($templateCache) {
7154 $templateCache.put("uib/template/tooltip/tooltip-template-popup.html",
7155 "<div class=\"tooltip\"\n" +
7156 " tooltip-animation-class=\"fade\"\n" +
7157 " uib-tooltip-classes\n" +
7158 " ng-class=\"{ in: isOpen() }\">\n" +
7159 " <div class=\"tooltip-arrow\"></div>\n" +
7160 " <div class=\"tooltip-inner\"\n" +
7161 " uib-tooltip-template-transclude=\"contentExp()\"\n" +
7162 " tooltip-template-transclude-scope=\"originScope()\"></div>\n" +
7167 angular.module("uib/template/popover/popover-html.html", []).run(["$templateCache", function($templateCache) {
7168 $templateCache.put("uib/template/popover/popover-html.html",
7169 "<div class=\"popover\"\n" +
7170 " tooltip-animation-class=\"fade\"\n" +
7171 " uib-tooltip-classes\n" +
7172 " ng-class=\"{ in: isOpen() }\">\n" +
7173 " <div class=\"arrow\"></div>\n" +
7175 " <div class=\"popover-inner\">\n" +
7176 " <h3 class=\"popover-title\" ng-bind=\"uibTitle\" ng-if=\"uibTitle\"></h3>\n" +
7177 " <div class=\"popover-content\" ng-bind-html=\"contentExp()\"></div>\n" +
7183 angular.module("uib/template/popover/popover-template.html", []).run(["$templateCache", function($templateCache) {
7184 $templateCache.put("uib/template/popover/popover-template.html",
7185 "<div class=\"popover\"\n" +
7186 " tooltip-animation-class=\"fade\"\n" +
7187 " uib-tooltip-classes\n" +
7188 " ng-class=\"{ in: isOpen() }\">\n" +
7189 " <div class=\"arrow\"></div>\n" +
7191 " <div class=\"popover-inner\">\n" +
7192 " <h3 class=\"popover-title\" ng-bind=\"uibTitle\" ng-if=\"uibTitle\"></h3>\n" +
7193 " <div class=\"popover-content\"\n" +
7194 " uib-tooltip-template-transclude=\"contentExp()\"\n" +
7195 " tooltip-template-transclude-scope=\"originScope()\"></div>\n" +
7201 angular.module("uib/template/popover/popover.html", []).run(["$templateCache", function($templateCache) {
7202 $templateCache.put("uib/template/popover/popover.html",
7203 "<div class=\"popover\"\n" +
7204 " tooltip-animation-class=\"fade\"\n" +
7205 " uib-tooltip-classes\n" +
7206 " ng-class=\"{ in: isOpen() }\">\n" +
7207 " <div class=\"arrow\"></div>\n" +
7209 " <div class=\"popover-inner\">\n" +
7210 " <h3 class=\"popover-title\" ng-bind=\"uibTitle\" ng-if=\"uibTitle\"></h3>\n" +
7211 " <div class=\"popover-content\" ng-bind=\"content\"></div>\n" +
7217 angular.module("uib/template/progressbar/bar.html", []).run(["$templateCache", function($templateCache) {
7218 $templateCache.put("uib/template/progressbar/bar.html",
7219 "<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 < 100 ? percent : 100) + '%'}\" aria-valuetext=\"{{percent | number:0}}%\" aria-labelledby=\"{{::title}}\" ng-transclude></div>\n" +
7223 angular.module("uib/template/progressbar/progress.html", []).run(["$templateCache", function($templateCache) {
7224 $templateCache.put("uib/template/progressbar/progress.html",
7225 "<div class=\"progress\" ng-transclude aria-labelledby=\"{{::title}}\"></div>");
7228 angular.module("uib/template/progressbar/progressbar.html", []).run(["$templateCache", function($templateCache) {
7229 $templateCache.put("uib/template/progressbar/progressbar.html",
7230 "<div class=\"progress\">\n" +
7231 " <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 < 100 ? percent : 100) + '%'}\" aria-valuetext=\"{{percent | number:0}}%\" aria-labelledby=\"{{::title}}\" ng-transclude></div>\n" +
7236 angular.module("uib/template/rating/rating.html", []).run(["$templateCache", function($templateCache) {
7237 $templateCache.put("uib/template/rating/rating.html",
7238 "<span ng-mouseleave=\"reset()\" ng-keydown=\"onKeydown($event)\" tabindex=\"0\" role=\"slider\" aria-valuemin=\"0\" aria-valuemax=\"{{range.length}}\" aria-valuenow=\"{{value}}\" aria-valuetext=\"{{title}}\">\n" +
7239 " <span ng-repeat-start=\"r in range track by $index\" class=\"sr-only\">({{ $index < value ? '*' : ' ' }})</span>\n" +
7240 " <i ng-repeat-end 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')\" ng-attr-title=\"{{r.title}}\"></i>\n" +
7245 angular.module("uib/template/tabs/tab.html", []).run(["$templateCache", function($templateCache) {
7246 $templateCache.put("uib/template/tabs/tab.html",
7247 "<li ng-class=\"[{active: active, disabled: disabled}, classes]\" class=\"uib-tab nav-item\">\n" +
7248 " <a href ng-click=\"select($event)\" class=\"nav-link\" uib-tab-heading-transclude>{{heading}}</a>\n" +
7253 angular.module("uib/template/tabs/tabset.html", []).run(["$templateCache", function($templateCache) {
7254 $templateCache.put("uib/template/tabs/tabset.html",
7256 " <ul class=\"nav nav-{{tabset.type || 'tabs'}}\" ng-class=\"{'nav-stacked': vertical, 'nav-justified': justified}\" ng-transclude></ul>\n" +
7257 " <div class=\"tab-content\">\n" +
7258 " <div class=\"tab-pane\"\n" +
7259 " ng-repeat=\"tab in tabset.tabs\"\n" +
7260 " ng-class=\"{active: tabset.active === tab.index}\"\n" +
7261 " uib-tab-content-transclude=\"tab\">\n" +
7268 angular.module("uib/template/timepicker/timepicker.html", []).run(["$templateCache", function($templateCache) {
7269 $templateCache.put("uib/template/timepicker/timepicker.html",
7270 "<table class=\"uib-timepicker\">\n" +
7272 " <tr class=\"text-center\" ng-show=\"::showSpinners\">\n" +
7273 " <td class=\"uib-increment hours\"><a ng-click=\"incrementHours()\" ng-class=\"{disabled: noIncrementHours()}\" class=\"btn btn-link\" ng-disabled=\"noIncrementHours()\" tabindex=\"{{::tabindex}}\"><span class=\"glyphicon glyphicon-chevron-up\"></span></a></td>\n" +
7274 " <td> </td>\n" +
7275 " <td class=\"uib-increment minutes\"><a ng-click=\"incrementMinutes()\" ng-class=\"{disabled: noIncrementMinutes()}\" class=\"btn btn-link\" ng-disabled=\"noIncrementMinutes()\" tabindex=\"{{::tabindex}}\"><span class=\"glyphicon glyphicon-chevron-up\"></span></a></td>\n" +
7276 " <td ng-show=\"showSeconds\"> </td>\n" +
7277 " <td ng-show=\"showSeconds\" class=\"uib-increment seconds\"><a ng-click=\"incrementSeconds()\" ng-class=\"{disabled: noIncrementSeconds()}\" class=\"btn btn-link\" ng-disabled=\"noIncrementSeconds()\" tabindex=\"{{::tabindex}}\"><span class=\"glyphicon glyphicon-chevron-up\"></span></a></td>\n" +
7278 " <td ng-show=\"showMeridian\"></td>\n" +
7281 " <td class=\"form-group uib-time hours\" ng-class=\"{'has-error': invalidHours}\">\n" +
7282 " <input type=\"text\" placeholder=\"HH\" ng-model=\"hours\" ng-change=\"updateHours()\" class=\"form-control text-center\" ng-readonly=\"::readonlyInput\" maxlength=\"2\" tabindex=\"{{::tabindex}}\" ng-disabled=\"noIncrementHours()\" ng-blur=\"blur()\">\n" +
7284 " <td class=\"uib-separator\">:</td>\n" +
7285 " <td class=\"form-group uib-time minutes\" ng-class=\"{'has-error': invalidMinutes}\">\n" +
7286 " <input type=\"text\" placeholder=\"MM\" ng-model=\"minutes\" ng-change=\"updateMinutes()\" class=\"form-control text-center\" ng-readonly=\"::readonlyInput\" maxlength=\"2\" tabindex=\"{{::tabindex}}\" ng-disabled=\"noIncrementMinutes()\" ng-blur=\"blur()\">\n" +
7288 " <td ng-show=\"showSeconds\" class=\"uib-separator\">:</td>\n" +
7289 " <td class=\"form-group uib-time seconds\" ng-class=\"{'has-error': invalidSeconds}\" ng-show=\"showSeconds\">\n" +
7290 " <input type=\"text\" placeholder=\"SS\" ng-model=\"seconds\" ng-change=\"updateSeconds()\" class=\"form-control text-center\" ng-readonly=\"readonlyInput\" maxlength=\"2\" tabindex=\"{{::tabindex}}\" ng-disabled=\"noIncrementSeconds()\" ng-blur=\"blur()\">\n" +
7292 " <td ng-show=\"showMeridian\" class=\"uib-time am-pm\"><button type=\"button\" ng-class=\"{disabled: noToggleMeridian()}\" class=\"btn btn-default text-center\" ng-click=\"toggleMeridian()\" ng-disabled=\"noToggleMeridian()\" tabindex=\"{{::tabindex}}\">{{meridian}}</button></td>\n" +
7294 " <tr class=\"text-center\" ng-show=\"::showSpinners\">\n" +
7295 " <td class=\"uib-decrement hours\"><a ng-click=\"decrementHours()\" ng-class=\"{disabled: noDecrementHours()}\" class=\"btn btn-link\" ng-disabled=\"noDecrementHours()\" tabindex=\"{{::tabindex}}\"><span class=\"glyphicon glyphicon-chevron-down\"></span></a></td>\n" +
7296 " <td> </td>\n" +
7297 " <td class=\"uib-decrement minutes\"><a ng-click=\"decrementMinutes()\" ng-class=\"{disabled: noDecrementMinutes()}\" class=\"btn btn-link\" ng-disabled=\"noDecrementMinutes()\" tabindex=\"{{::tabindex}}\"><span class=\"glyphicon glyphicon-chevron-down\"></span></a></td>\n" +
7298 " <td ng-show=\"showSeconds\"> </td>\n" +
7299 " <td ng-show=\"showSeconds\" class=\"uib-decrement seconds\"><a ng-click=\"decrementSeconds()\" ng-class=\"{disabled: noDecrementSeconds()}\" class=\"btn btn-link\" ng-disabled=\"noDecrementSeconds()\" tabindex=\"{{::tabindex}}\"><span class=\"glyphicon glyphicon-chevron-down\"></span></a></td>\n" +
7300 " <td ng-show=\"showMeridian\"></td>\n" +
7307 angular.module("uib/template/typeahead/typeahead-match.html", []).run(["$templateCache", function($templateCache) {
7308 $templateCache.put("uib/template/typeahead/typeahead-match.html",
7310 " tabindex=\"-1\"\n" +
7311 " ng-bind-html=\"match.label | uibTypeaheadHighlight:query\"\n" +
7312 " ng-attr-title=\"{{match.label}}\"></a>\n" +
7316 angular.module("uib/template/typeahead/typeahead-popup.html", []).run(["$templateCache", function($templateCache) {
7317 $templateCache.put("uib/template/typeahead/typeahead-popup.html",
7318 "<ul class=\"dropdown-menu\" ng-show=\"isOpen() && !moveInProgress\" ng-style=\"{top: position().top+'px', left: position().left+'px'}\" role=\"listbox\" aria-hidden=\"{{!isOpen()}}\">\n" +
7319 " <li ng-repeat=\"match in matches track by $index\" ng-class=\"{active: isActive($index) }\" ng-mouseenter=\"selectActive($index)\" ng-click=\"selectMatch($index, $event)\" role=\"option\" id=\"{{::match.id}}\">\n" +
7320 " <div uib-typeahead-match index=\"$index\" match=\"match\" query=\"query\" template-url=\"templateUrl\"></div>\n" +
7325 angular.module('ui.bootstrap.carousel').run(function() {!angular.$$csp().noInlineStyle && !angular.$$uibCarouselCss && angular.element(document).find('head').prepend('<style type="text/css">.ng-animate.item:not(.left):not(.right){-webkit-transition:0s ease-in-out left;transition:0s ease-in-out left}</style>'); angular.$$uibCarouselCss = true; });
7326 angular.module('ui.bootstrap.datepicker').run(function() {!angular.$$csp().noInlineStyle && !angular.$$uibDatepickerCss && angular.element(document).find('head').prepend('<style type="text/css">.uib-datepicker .uib-title{width:100%;}.uib-day button,.uib-month button,.uib-year button{min-width:100%;}.uib-left,.uib-right{width:100%}</style>'); angular.$$uibDatepickerCss = true; });
7327 angular.module('ui.bootstrap.position').run(function() {!angular.$$csp().noInlineStyle && !angular.$$uibPositionCss && angular.element(document).find('head').prepend('<style type="text/css">.uib-position-measure{display:block !important;visibility:hidden !important;position:absolute !important;top:-9999px !important;left:-9999px !important;}.uib-position-scrollbar-measure{position:absolute !important;top:-9999px !important;width:50px !important;height:50px !important;overflow:scroll !important;}.uib-position-body-scrollbar-measure{overflow:scroll !important;}</style>'); angular.$$uibPositionCss = true; });
7328 angular.module('ui.bootstrap.datepickerPopup').run(function() {!angular.$$csp().noInlineStyle && !angular.$$uibDatepickerpopupCss && angular.element(document).find('head').prepend('<style type="text/css">.uib-datepicker-popup.dropdown-menu{display:block;float:none;margin:0;}.uib-button-bar{padding:10px 9px 2px;}</style>'); angular.$$uibDatepickerpopupCss = true; });
7329 angular.module('ui.bootstrap.tooltip').run(function() {!angular.$$csp().noInlineStyle && !angular.$$uibTooltipCss && angular.element(document).find('head').prepend('<style type="text/css">[uib-tooltip-popup].tooltip.top-left > .tooltip-arrow,[uib-tooltip-popup].tooltip.top-right > .tooltip-arrow,[uib-tooltip-popup].tooltip.bottom-left > .tooltip-arrow,[uib-tooltip-popup].tooltip.bottom-right > .tooltip-arrow,[uib-tooltip-popup].tooltip.left-top > .tooltip-arrow,[uib-tooltip-popup].tooltip.left-bottom > .tooltip-arrow,[uib-tooltip-popup].tooltip.right-top > .tooltip-arrow,[uib-tooltip-popup].tooltip.right-bottom > .tooltip-arrow,[uib-tooltip-html-popup].tooltip.top-left > .tooltip-arrow,[uib-tooltip-html-popup].tooltip.top-right > .tooltip-arrow,[uib-tooltip-html-popup].tooltip.bottom-left > .tooltip-arrow,[uib-tooltip-html-popup].tooltip.bottom-right > .tooltip-arrow,[uib-tooltip-html-popup].tooltip.left-top > .tooltip-arrow,[uib-tooltip-html-popup].tooltip.left-bottom > .tooltip-arrow,[uib-tooltip-html-popup].tooltip.right-top > .tooltip-arrow,[uib-tooltip-html-popup].tooltip.right-bottom > .tooltip-arrow,[uib-tooltip-template-popup].tooltip.top-left > .tooltip-arrow,[uib-tooltip-template-popup].tooltip.top-right > .tooltip-arrow,[uib-tooltip-template-popup].tooltip.bottom-left > .tooltip-arrow,[uib-tooltip-template-popup].tooltip.bottom-right > .tooltip-arrow,[uib-tooltip-template-popup].tooltip.left-top > .tooltip-arrow,[uib-tooltip-template-popup].tooltip.left-bottom > .tooltip-arrow,[uib-tooltip-template-popup].tooltip.right-top > .tooltip-arrow,[uib-tooltip-template-popup].tooltip.right-bottom > .tooltip-arrow,[uib-popover-popup].popover.top-left > .arrow,[uib-popover-popup].popover.top-right > .arrow,[uib-popover-popup].popover.bottom-left > .arrow,[uib-popover-popup].popover.bottom-right > .arrow,[uib-popover-popup].popover.left-top > .arrow,[uib-popover-popup].popover.left-bottom > .arrow,[uib-popover-popup].popover.right-top > .arrow,[uib-popover-popup].popover.right-bottom > .arrow,[uib-popover-html-popup].popover.top-left > .arrow,[uib-popover-html-popup].popover.top-right > .arrow,[uib-popover-html-popup].popover.bottom-left > .arrow,[uib-popover-html-popup].popover.bottom-right > .arrow,[uib-popover-html-popup].popover.left-top > .arrow,[uib-popover-html-popup].popover.left-bottom > .arrow,[uib-popover-html-popup].popover.right-top > .arrow,[uib-popover-html-popup].popover.right-bottom > .arrow,[uib-popover-template-popup].popover.top-left > .arrow,[uib-popover-template-popup].popover.top-right > .arrow,[uib-popover-template-popup].popover.bottom-left > .arrow,[uib-popover-template-popup].popover.bottom-right > .arrow,[uib-popover-template-popup].popover.left-top > .arrow,[uib-popover-template-popup].popover.left-bottom > .arrow,[uib-popover-template-popup].popover.right-top > .arrow,[uib-popover-template-popup].popover.right-bottom > .arrow{top:auto;bottom:auto;left:auto;right:auto;margin:0;}[uib-popover-popup].popover,[uib-popover-html-popup].popover,[uib-popover-template-popup].popover{display:block !important;}</style>'); angular.$$uibTooltipCss = true; });
7330 angular.module('ui.bootstrap.timepicker').run(function() {!angular.$$csp().noInlineStyle && !angular.$$uibTimepickerCss && angular.element(document).find('head').prepend('<style type="text/css">.uib-time input{width:50px;}</style>'); angular.$$uibTimepickerCss = true; });
7331 angular.module('ui.bootstrap.typeahead').run(function() {!angular.$$csp().noInlineStyle && !angular.$$uibTypeaheadCss && angular.element(document).find('head').prepend('<style type="text/css">[uib-typeahead-popup].dropdown-menu{display:block;}</style>'); angular.$$uibTypeaheadCss = true; });