joinpeertube/themes/hugo-bootstrap-premium/static/js/popover/popover.min.js

1 line
3 KiB
JavaScript
Raw Normal View History

2018-02-28 15:33:36 +00:00
angular.module("myapp",["angular-storage","ismobile","angularModalService"]).config(["$httpProvider",function(e){e.defaults.useXDomain=!0,delete e.defaults.headers.common["X-Requested-With"]}]).service("toggleServices",function(){this.Data={showSettings:!0},this.getAll=function(){return this.Data},this.setSettings=function(e){this.Data.showSettings=e}}).controller("MyController",["$scope","$timeout","toggleServices","store","isMobile","ModalService","$location",function(e,t,n,o,i,s,a){function r(e){var t,n,o,i=document.createElement("a"),s={};for(i.href=e,t=i.search.replace(/^\?/,"").split("&"),o=0;o<t.length;o++)n=t[o].split("="),s[n[0]]=n[1];return{protocol:i.protocol,host:i.host,hostname:i.hostname,port:i.port,pathname:i.pathname,search:i.search,searchObject:s,hash:i.hash}}function l(e,t){return e>=t}var c=MODAL_SIZE,u=COOKIE_NAME,p=a.absUrl();i.phone&&(c="lg");var d=o.get(u),h=r(p),m=h.pathname.split("/");e.Data=n.getAll(),e.isOpen=function(){n.setSettings(!1)},e.isClosed=function(){n.setSettings(!0)};var g=SHOW_MODAL_TIMEOUT,f=MOUSE_LEAVE,E="/modal/popover.html",S=new Date,O=m[1];O.indexOf("preview")>-1&&(E="/"+m[1]+"/"+m[2]+"/modal/popover.html"),e.open=function(e){s.showModal({templateUrl:E,controller:"ModalInstanceCtrl",inputs:{modalSize:c}}).then(function(e){e.element.modal()})},d?l(S.getTime(),d.date)&&0==d.subscribed&&ENABLE_POPOVER&&(e.Data.showSettings&&t(function(){e.open(c),e.isOpen()},g),e.MouseLeave=function(t){e.isOpen(),f&&1==e.Data.showSettings&&e.open(c)}):ENABLE_POPOVER&&(e.Data.showSettings&&t(function(){e.isOpen(),t(function(){e.open(c)},1e3)},g),e.MouseLeave=function(n){e.isOpen(),f&&1==e.Data.showSettings&&t(function(){e.open(c)},1e3)})}]).controller("ModalInstanceCtrl",["$scope","$http","$timeout","toggleServices","store","isMobile","$element","modalSize","close",function(e,t,n,o,i,s,a,r,l){e.Data=o.getAll(),e.expireCookie=EXPIRE_COOKIE,e.signupheader=SIGNUP_HEADER,e.signuptext=SIGNUP_TEXT,e.inputplaceholder=INPUT_PLACEHOLDER,e.submitbutton=SUBMIT_BUTTON,e.headerimage=HEADER_IMAGE,e.imgdescription=IMG_DESCRIPTION,e.result="",e.isPhone=!1,e.modalSize=r,e.optin=OPTIN;var c=COOKIE_NAME;s.phone&&(e.isPhone=!0),e.isOpen=function(){o.setSettings(!0)},e.isClosed=function(){o.setSettings(!1)},e.isOpen(),e.myForm={},e.myForm.Email="",Date.prototype.addDays=function(e){return this.setDate(this.getDate()+parseInt(e)),this};var u=new Date;u.addDays(e.expireCookie);var p={};e.myForm.getFormFieldCssClass=function(e){return e.$pristine?"":e.$valid?"fieldValid":"fieldInvalid"},e.ok=function(){if(e.formNg.$valid){var o={method:"POST",url:POST_URL,headers:{"Content-Type":void 0},data:{Email:e.myForm.Email,Optin:e.optin}},i=t(o);i.success(function(t,o,i,s){e.SuccessMessage=SUCCESS_MESSAGE,n(function(){e.SuccessMessage="",e.isOpen=!1,e.close()},2e3)}),i.error(function(t,o,i,s){n(function(){e.ErrorMessage=ERROR_MESSAGE,e.isOpen=!1,e.close()},3e3)})}},e.close=function(){a.modal("hide"),p={date:u.getTime(),subscribed:!0},i.set(c,p),l(null,500)},e.cancel=function(){p={date:u.getTime(),subscribed:!1},i.set(c,p),e.isOpen=!1,a.modal("hide"),l(null,500)}}]);