{"version":3,"sources":["directives/gated-content-form.js"],"names":["angular","module","directive","$window","$timeout","api","transclude","restrict","scope","PageId","FormHtml","templateUrl","window","Cachebuster","controller","$scope","$sce","STATES","Loading","Gated","Content","State","TrustedFormHtml","trustAsHtml","addEventListener","event","data","pardotForm","console","log","GetGatedContentHtml","then","main","document","getElementById","offset","offsetTop","scrollTo","top","left","TrustedContentHtml","link","el","attrs","form","find","iFrameResize","factory","$http","id","get","response"],"mappings":";;AAAA,CAAC,YAAY;AAETA,EAAAA,OAAO,CAACC,MAAR,CAAe,cAAf,EAA+B,CAAC,YAAD,EAAe,aAAf,CAA/B,EACKC,SADL,CACe,kBADf,EACmC,CAAC,SAAD,EAAY,UAAZ,EAAwB,iBAAxB,EAA2C,UAAUC,OAAV,EAAmBC,QAAnB,EAA6BC,GAA7B,EAAkC;AAExG,WAAO;AACHC,MAAAA,UAAU,EAAE,IADT;AAEHC,MAAAA,QAAQ,EAAE,IAFP;AAGHC,MAAAA,KAAK,EAAE;AACHC,QAAAA,MAAM,EAAE,SADL;AAEHC,QAAAA,QAAQ,EAAE;AAFP,OAHJ;AAOHC,MAAAA,WAAW,EAAE,mDAAmDC,MAAM,CAACC,WAPpE;AAQHC,MAAAA,UAAU,EAAE,CAAC,QAAD,EAAW,MAAX,EAAmB,UAAUC,MAAV,EAAkBC,IAAlB,EAAwB;AAEnDD,QAAAA,MAAM,CAACE,MAAP,GAAgB;AACZC,UAAAA,OAAO,EAAE,SADG;AAEZC,UAAAA,KAAK,EAAE,OAFK;AAGZC,UAAAA,OAAO,EAAE;AAHG,SAAhB;AAMAL,QAAAA,MAAM,CAACM,KAAP,GAAeN,MAAM,CAACE,MAAP,CAAcE,KAA7B;AACAJ,QAAAA,MAAM,CAACO,eAAP,GAAyBN,IAAI,CAACO,WAAL,CAAiBR,MAAM,CAACL,QAAxB,CAAzB;AAEAP,QAAAA,OAAO,CAACqB,gBAAR,CAAyB,SAAzB,EAAoC,UAAAC,KAAK,EAAI;AACzC,cAAI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EAA1E,EACFlB,IADE,CACG,UAAUoB,QAAV,EAAoB;AACtB,iBAAOA,QAAQ,CAACzB,IAAhB;AACH,SAHE,CAAP;AAIH;AANE,KAAP;AASH,GAZuB,CAzDhC;AAwEH,CA1ED","sourcesContent":["(function () {\r\n\r\n angular.module(\"gatedContent\", ['ngSanitize', 'loadingIcon'])\r\n .directive(\"gatedContentForm\", ['$window', '$timeout', 'gatedContentApi', function ($window, $timeout, api) {\r\n\r\n return {\r\n transclude: true,\r\n restrict: \"AE\",\r\n scope: {\r\n PageId: '=pageId',\r\n FormHtml: '=formHtml'\r\n },\r\n templateUrl: '/assets/ngtemplates/gated-content-form.html?v=' + window.Cachebuster,\r\n controller: [\"$scope\", \"$sce\", function ($scope, $sce) {\r\n\r\n $scope.STATES = {\r\n Loading: 'loading',\r\n Gated: 'gated',\r\n Content: 'content'\r\n };\r\n\r\n $scope.State = $scope.STATES.Gated;\r\n $scope.TrustedFormHtml = $sce.trustAsHtml($scope.FormHtml);\r\n\r\n $window.addEventListener('message', event => {\r\n if (event.data.pardotForm) {\r\n console.log(\"gated content form has been submitted\");\r\n $scope.State = $scope.STATES.Loading;\r\n\r\n api.GetGatedContentHtml($scope.PageId)\r\n .then(function (data) {\r\n var main = document.getElementById('main-content');\r\n var offset = main.offsetTop;\r\n\r\n $window.scrollTo({\r\n top: offset,\r\n left: 0,\r\n })\r\n \r\n $scope.TrustedContentHtml = $sce.trustAsHtml(data);\r\n $scope.State = $scope.STATES.Content;\r\n });\r\n }\r\n });\r\n\r\n \r\n\r\n\r\n }],\r\n link: function (scope, el, attrs) {\r\n\r\n $timeout(function () {\r\n var form = el.find('iframe')[0];\r\n $window.iFrameResize(null, form[0]);\r\n }, 100);\r\n }\r\n };\r\n\r\n }])\r\n .factory(\"gatedContentApi\", ['$http',\r\n function ($http) {\r\n\r\n return {\r\n GetGatedContentHtml: function (id) {\r\n return $http.get(\"/umbraco/surface/gatedcontentsurface/getbodycontent?pageid=\" + id)\r\n .then(function (response) {\r\n return response.data;\r\n });\r\n }\r\n };\r\n\r\n }\r\n ]);\r\n\r\n})(); "],"file":"../../directives/gated-content-form.js"}