(function() { "use strict"; angular.module('shared') .component('popoverContent', { bindings: { position: '@?', offpageContent: '@?', overrideClass: '@?' }, require: { popoverCtrl: '^popover' }, controller: 'PopoverContent', templateUrl: '/shared/js/angular/ui/popover-content.html', transclude: { 'lazModal': '?lazModal' } }) .controller('PopoverContent', ['$scope', '$element', '$attrs', '$transclude', function PopoverContentCtrl($scope, $element, $attrs, $transclude) { var ctrl = this; ctrl.$onInit = function () { ctrl.popoverCtrl.addContent(this); if (ctrl.position) { ctrl.popoverCtrl.setPosition($scope.$eval(ctrl.position)) } if ('lightwindow' in $attrs) { ctrl.lightwindow = true; ctrl.popoverCtrl.lightwindow = true; } ctrl.dropShadow = ('dropshadow' in $attrs) || ('lightwindow' in $attrs); ctrl.hasCloseButton = ('hasCloseButton' in $attrs) || ('lightwindow' in $attrs); ctrl.isLazModal = ctrl.isContentLazModal(); ctrl.popoverCtrl.isLazModal = ctrl.isLazModal; }; ctrl.isOpen = function () { return ctrl.popoverCtrl.isOpen(); }; ctrl.$postLink = function () { if (ctrl.popoverCtrl.openOnHover()) { $element.on('mouseenter', ctrl.popoverCtrl.onEnter) } if (ctrl.popoverCtrl.openOnHover() && !ctrl.popoverCtrl.stayOpenOnHoverOff()) { $element.on('mouseleave', ctrl.popoverCtrl.onLeave) } $element.addClass('is-linked'); }; ctrl.$onDestroy = function () { ctrl.popoverCtrl.removeContent(this); $element.off('mouseenter', ctrl.popoverCtrl.onEnter) .off('mouseenter', ctrl.popoverCtrl.onEnter) }; ctrl.getClass = function() { if(ctrl.overrideClass) { return ctrl.overrideClass; } else if(ctrl.lightwindow) { return 'modalWindow'; } else if(ctrl.isLazModal) { return ''; } else { return 'popover-content'; } }; ctrl.close = function () { ctrl.popoverCtrl.close(); }; ctrl.isContentLazModal = function() { return $transclude.isSlotFilled('lazModal'); }; }]); })();