diff --git a/js/angular/service/popover.js b/js/angular/service/popover.js index 8a8e15a2f9..c174a53494 100644 --- a/js/angular/service/popover.js +++ b/js/angular/service/popover.js @@ -36,22 +36,22 @@ * ```js * angular.module('testApp', ['ionic']) * .controller('MyController', function($scope, $ionicPopover) { - * + * * // .fromTemplate() method * var template = '

My Popover Title

Hello!
'; - * + * * $scope.popover = $ionicPopover.fromTemplate(template, { * scope: $scope, * }); - * + * * // .fromTemplateUrl() method * $ionicPopover.fromTemplateUrl('my-popover.html', { * scope: $scope, * }).then(function(popover) { * $scope.popover = popover; * }); - * - * + * + * * $scope.openPopover = function($event) { * $scope.popover.show($event); * }; @@ -90,7 +90,7 @@ function($ionicModal, $ionicPosition, $document, $window) { function positionView(target, popoverEle) { var targetEle = angular.element(target.target || target); - var buttonOffset = $ionicPosition.offset( targetEle ); + var buttonOffset = $ionicPosition.offset(targetEle); var popoverWidth = popoverEle.prop('offsetWidth'); var popoverHeight = popoverEle.prop('offsetHeight'); var bodyWidth = $document[0].body.clientWidth; @@ -104,7 +104,7 @@ function($ionicModal, $ionicPosition, $document, $window) { if (popoverCSS.left < POPOVER_BODY_PADDING) { popoverCSS.left = POPOVER_BODY_PADDING; - } else if(popoverCSS.left + popoverWidth + POPOVER_BODY_PADDING > bodyWidth) { + } else if (popoverCSS.left + popoverWidth + POPOVER_BODY_PADDING > bodyWidth) { popoverCSS.left = bodyWidth - popoverWidth - POPOVER_BODY_PADDING; } @@ -202,7 +202,7 @@ function($ionicModal, $ionicPosition, $document, $window) { * controller (ionicPopover is built on top of $ionicPopover). */ fromTemplate: function(templateString, options) { - return $ionicModal.fromTemplate(templateString, ionic.Utils.extend(POPOVER_OPTIONS, options || {}) ); + return $ionicModal.fromTemplate(templateString, ionic.Utils.extend(POPOVER_OPTIONS, options || {})); }, /** * @ngdoc method @@ -213,7 +213,7 @@ function($ionicModal, $ionicPosition, $document, $window) { * an {@link ionic.controller:ionicPopover} controller (ionicPopover is built on top of $ionicPopover). */ fromTemplateUrl: function(url, options, _) { - return $ionicModal.fromTemplateUrl(url, options, ionic.Utils.extend(POPOVER_OPTIONS, options || {}) ); + return $ionicModal.fromTemplateUrl(url, options, ionic.Utils.extend(POPOVER_OPTIONS, options || {})); } }; diff --git a/test/unit/angular/service/popover.unit.js b/test/unit/angular/service/popover.unit.js index 867173d102..8fb17a050c 100644 --- a/test/unit/angular/service/popover.unit.js +++ b/test/unit/angular/service/popover.unit.js @@ -202,6 +202,16 @@ describe('Ionic Popover', function() { expect(instance.scope.$parent.$broadcast).toHaveBeenCalledWith('popover.shown', instance); }); + it('should set custom options', function() { + var template = '
'; + var instance = popover.fromTemplate(template, { + animation: 'custom-animation' + }); + instance.show(); + timeout.flush(); + expect(instance.$el[0].querySelector('.popover').classList.contains('custom-animation')).toBe(true); + }); + it('should broadcast "popover.hidden" on hide with self', function() { var template = '
'; var instance = popover.fromTemplate(template, {});