( function() { 'use strict'; angular.module('shared') .service( 'LazLightwindowService', ['LazModalService', '$sce', '$window', function LazLightwindowServiceFactory(LazModalService, $sce, $window) { var service = this; service.show = function(options){ var config = angular.extend({ width: 900, height: 1000 }, options); var maxWidth = Math.max($window.document.documentElement.clientWidth - 80, 0); var maxHeight = Math.max($window.document.documentElement.clientHeight - 30, 0); config.width = Math.min(config.width, maxWidth); config.height = Math.min(config.height, maxHeight); if(!config.href) { throw "No href parameter specified"; } config.href = $sce.trustAsResourceUrl(config.href); return LazModalService.showModal({ controller: ['options', 'close', '$scope', function( options, close, $scope) { var ctrl = this; angular.extend(ctrl, options); ctrl.close = close; return ctrl; }], inputs: { options: config }, controllerAs: '$ctrl', overrideClass: 'modalWindow modalWindow-iframe', templateUrl: '/shared/js/angular/ui/laz-lightwindow.html' }); }; }]) })();