/*!

* sense-media-box - Include web pages, videos, images and much more into your Qlik Sense app.
* --
* @version v0.4.3
* @link https://github.com/stefanwalther/sense-media-box
* @author Stefan Walther
* @license MIT
*/

/*global define*/
define(["jquery","underscore","qvangular","text!./qsMbWebsite.ng.html"],function($,_,qvangular,ngTemplate){"use strict";qvangular.directive("qsMbWebsite",["$sce",function($sce){return{restrict:"E",template:ngTemplate,scope:{objectId:"=",websiteSource:"=",websiteInteraction:"=",websiteScrollBehavior:"=",editMode:"="},controller:["$scope",function($scope){$scope.trustedSource=""}],link:function($scope,$element,$attrs){$element.find("iframe");$scope.$watchCollection("[websiteSource, websiteInteraction, websiteScrollBehavior, editMode]",function(newVal,oldVal){newVal&&newVal!==oldVal&&render()});var render=function(){switch(_.isEmpty($scope.websiteSource)?$scope.trustedSource="":$scope.trustedSource=$sce.trustAsResourceUrl($scope.websiteSource),$scope.websiteScrollBehavior){case"auto":$scope.iframeScrolling="auto";break;case"none":$scope.iframeScrolling="no";break;case"on":$scope.iframeScrolling="yes";break;default:$scope.iframeScrolling="no"}$scope.websiteInteraction||($scope.iframeScrolling="no"),$scope.showOverlay=!$scope.websiteInteraction,$scope.editMode===!0&&($scope.showOverlay=!0);var $ifrPlaceHolder=$element.find(".iframePlaceHolder");$ifrPlaceHolder.empty();var $ifr=$(document.createElement("iframe"));$ifr.id="mediabox"+$scope.objectId+"_website",$ifr.attr("src",$scope.trustedSource),$ifr.attr("frameborder",0),$ifr.attr("scrolling",$scope.iframeScrolling),$ifr.attr("sandbox","allow-forms allow-pointer-lock allow-same-origin allow-scripts allow-top-navigation"),$ifr.addClass("mb_website"),$ifrPlaceHolder.append($ifr)};render()}}}])});