forked from willylatorre/angular-typeform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
angular-typeform.min.js
1 lines (1 loc) · 2.78 KB
/
angular-typeform.min.js
1
!function(){"use strict";angular.module("angularTypeform",[]),angular.module("angularTypeform").provider("typeformConfig",function(){this.accountId="",this.setAccount=function(t){this.accountId=t},this.$get=function(){return this}}),angular.module("angularTypeform").controller("ControllerEmbed",["$scope","typeformConfig","$timeout",function(t,e,r){function n(){var t,e,r=document,n=r.getElementById,o=r.createElement,a=r.getElementsByTagName,c="typef_orm_widget";n.call(r,c)?new Typeform.Widget:(t=o.call(r,"script"),t.id=c,t.src="https://s3-eu-west-1.amazonaws.com/share.typeform.com/widget.js",e=a.call(r,"script")[0],e.parentNode.insertBefore(t,e))}if(!e.accountId)throw new EvalError("Account ID not set in config");t.accountId=e.accountId,r(function(){!t.tfCustom&&n()})}]).directive("typeformEmbed",["$sce","$httpParamSerializer",function(t,e){return{restrict:"EA",replace:!0,scope:{tfId:"@",tfText:"@",tfHidden:"=?",tfCustom:"@?"},template:function(t,e){return angular.isUndefined(e.tfCustom)?'<div class="typeform-widget" ng-attr-data-url="{{formUrl}}" ng-attr-data-text="{{tfText}}"></div>':'<div class="typeform-widget-custom"><iframe ng-src="{{formUrl}}" width="100%" height="100%" frameborder="0"></iframe></div>'},controller:"ControllerEmbed",link:function(r,n,o){r.style=r.tfStyle?r.tfStyle:"height:100%; margin:0;",r.urlParams=e(r.tfHidden),o.$observe("tfId",function(){r.formUrl=t.trustAsResourceUrl("https://"+r.accountId+".typeform.com/to/"+r.tfId+"?"+r.urlParams)})}}}]),angular.module("angularTypeform").controller("ControllerLink",["$scope","typeformConfig","$timeout",function(t,e,r){function n(t){var e,r,n,o,a=document,c=a.getElementById,i=a.createElement,f=a.getElementsByTagName,s="typef_orm_share",u="https://s3-eu-west-1.amazonaws.com/share.typeform.com/";c.call(a,s)||(r=i.call(a,"script"),r.id=s,r.src=u+"share.js",n=f.call(a,"script")[0],n.parentNode.insertBefore(r,n)),s+="_",t!=l||c.call(a,s)||(e=i.call(a,"link"),e.rel="stylesheet",e.id=s,e.href=u+"share-button.css",o=f.call(a,"head")[0],o.appendChild(e,o))}var o="popup",a="banner",c="link",l="button";if(!e.accountId)throw new EvalError("Account ID not set in config");t.accountId=e.accountId;var i=function(t){if(!t)return c;switch(t){case l:return l;case c:default:return c}}(t.tfType);t.type=i,t.mode=function(t){if(!t)return"1";switch(t){case a:return"2";case o:default:return"1"}}(t.tfMode),r(function(){n(i)})}]).directive("typeformLink",function(){return{restrict:"EA",replace:!0,scope:{tfMode:"@",tfType:"@",tfId:"@",tfText:"@",tfStyle:"@"},template:'<a ng-attr-class="typeform-share {{type}}" ng-attr-href="https://{{accountId}}.typeform.com/to/{{tfId}}" ng-attr-data-mode="{{mode}}" ng-attr-style="{{style}}" target="_blank">{{tfText}}</a>',controller:"ControllerLink",link:function(t,e,r){t.style=t.tfStyle?t.tfStyle:"height:100%; margin:0;"}}})}();