Plugin Directory

Changeset 2157879


Ignore:
Timestamp:
09/17/2019 01:35:46 PM (7 years ago)
Author:
wallkit
Message:

fixes and improvements

Location:
wallkit/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • wallkit/trunk/public/js/wallkit-integration-library.js

    r2125113 r2157879  
    2727      addToTopCss: function () {
    2828        const css = '#wk-overlay {' +
    29           'display: none;position: ' +
    30           'fixed;top: 0px;' +
    31           'left: 0px;' +
    32           'right: 0px;' +
    33           'bottom: 0px;' +
    34           'background: #121214;' +
    35           'z-index: 300000;' +
    36           'opacity: 0;' +
    37           '-webkit-transition: opacity .25s linear;' +
    38           '-moz-transition: opacity .25s linear;' +
    39           '-ms-transition: opacity .25s linear;' +
    40           '-o-transition: opacity .25s linear;' +
    41           'transition: opacity .25s linear;' +
    42           '}' +
    43           '#wk-overlay.wk-active {' +
    44           'opacity: .9;' +
    45           'z-index: 300000;' +
    46           'display: block;' +
    47           'height: 100%;' +
    48           '}' +
    49           '#wk-popup-wrapper {' +
    50           'overflow-x: hidden;' +
    51           'overflow-y: auto;' +
    52           'display: none;' +
    53           'position: fixed;' +
    54           'top: 0;' +
    55           'bottom: 0;' +
    56           'left: 0;' +
    57           'right: 0;' +
    58           'overflow: auto;' +
    59           '-webkit-overflow-scrolling: touch;' +
    60           '}' +
    61           '#wk-popup-wrapper.wk-active {' +
    62           'z-index: 300050;' +
    63           'display: block;' +
    64         '}' +
    65           '#wk-popup-close-button {' +
    66           'line-height: 37px;' +
    67           'position: absolute;' +
    68           'top: 4;right: 4px;' +
    69           'width: 40px;' +
    70           'height: 40px;' +
    71           'z-index: 300100;' +
    72           'opacity: 0;' +
    73           'cursor: pointer;' +
    74           'color: #ccc;' +
    75           'font-family: Arial, sans-serif;' +
    76           'text-align: center;' +
    77           '}' +
    78           '#wk-popup-wrapper.wk-active ' +
    79           '#wk-popup-close-button {' +
    80           'display: block;' +
    81           'font-size: 37px;' +
    82           'transform: rotateZ(45deg);' +
    83           'opacity: 1;' +
    84           '}' +
    85           '#wk-iframe-wrapper {' +
    86           'position: relative;' +
    87           'margin: 40px auto;' +
    88           'box-shadow: 0 0 10px rgba(0, 0, 0, 0.21);' +
    89           '}' +
    90           '@media all and (max-width: 500px) {' +
    91           '#wk-iframe-wrapper' +
    92           '{ margin: 0 auto; }' +
    93           '}' +
    94           '#wk-popup-wrapper.wk-active ' +
    95           '#wk-iframe-wrapper {' +
    96           'transform: scale(1.0, 1.0);' +
    97           '-moz-transform: scale(1.0, 1.0);' +
    98           '-ms-transform: scale(1.0, 1.0);' +
    99           '-webkit-transform: scale(1.0, 1.0);' +
    100           '-o-transform: scale(1.0, 1.0);' +
    101           'width: 500px;min-height: 250px;' +
    102           'max-width: 100%;' +
    103           '}';
     29            'display: none;position: ' +
     30            'fixed;top: 0px;' +
     31            'left: 0px;' +
     32            'right: 0px;' +
     33            'bottom: 0px;' +
     34            'background: #121214;' +
     35            'z-index: 300000;' +
     36            'opacity: 0;' +
     37            '-webkit-transition: opacity .25s linear;' +
     38            '-moz-transition: opacity .25s linear;' +
     39            '-ms-transition: opacity .25s linear;' +
     40            '-o-transition: opacity .25s linear;' +
     41            'transition: opacity .25s linear;' +
     42            '}' +
     43            '#wk-overlay.wk-active {' +
     44            'opacity: .9;' +
     45            'z-index: 300000;' +
     46            'display: block;' +
     47            'height: 100%;' +
     48            '}' +
     49            '#wk-popup-wrapper {' +
     50            'overflow-x: hidden;' +
     51            'overflow-y: auto;' +
     52            'display: none;' +
     53            'position: fixed;' +
     54            'top: 0;' +
     55            'bottom: 0;' +
     56            'left: 0;' +
     57            'right: 0;' +
     58            'overflow: auto;' +
     59            '-webkit-overflow-scrolling: touch;' +
     60            '}' +
     61            '#wk-popup-wrapper.wk-active {' +
     62            'z-index: 300050;' +
     63            'display: block;' +
     64            '}' +
     65            '#wk-popup-close-button {' +
     66            'line-height: 37px;' +
     67            'position: absolute;' +
     68            'top: 10px;right: 10px;' +
     69            'width: 37px;' +
     70            'height: 37px;' +
     71            'z-index: 300100;' +
     72            'opacity: 0;' +
     73            'cursor: pointer;' +
     74            'color: #ccc;' +
     75            'font-family: Arial, sans-serif;' +
     76            'text-align: center;' +
     77            '}' +
     78            '#wk-popup-wrapper.wk-active ' +
     79            '#wk-popup-close-button {' +
     80            'display: block;' +
     81            'font-size: 37px;' +
     82            'transform: rotateZ(45deg);' +
     83            'opacity: 1;' +
     84            '}' +
     85            '#wk-iframe-wrapper {' +
     86            'position: relative;' +
     87            'margin: 40px auto;' +
     88            'box-shadow: 0 0 10px rgba(0, 0, 0, 0.21);' +
     89            '}' +
     90            '@media all and (max-width: 500px) {' +
     91            '#wk-iframe-wrapper' +
     92            '{ margin: 0 auto; }' +
     93            '}' +
     94            '#wk-popup-wrapper.wk-active ' +
     95            '#wk-iframe-wrapper {' +
     96            'transform: scale(1.0, 1.0);' +
     97            '-moz-transform: scale(1.0, 1.0);' +
     98            '-ms-transform: scale(1.0, 1.0);' +
     99            '-webkit-transform: scale(1.0, 1.0);' +
     100            '-o-transform: scale(1.0, 1.0);' +
     101            'width: 500px;min-height: 250px;' +
     102            'max-width: 100%;' +
     103            '}';
    104104        var head = document.head || document.getElementsByTagName('head')[0];
    105105        var style = document.createElement('style');
     
    282282      getCookie: function (name) {
    283283        var matches = document.cookie.match(new RegExp(
    284           "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
     284            "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
    285285        ));
    286286        return matches ? decodeURIComponent(matches[1]) : undefined;
     
    473473        for (var k in callbacks) {
    474474          if(
    475             typeof callbacks[k] === "object" &&
    476             typeof callbacks[k].event !== "undefined" &&
    477             callbacks[k].event === event &&
    478             typeof callbacks[k].callback !== "undefined" &&
    479             typeof callbacks[k].callback === "function"
     475              typeof callbacks[k] === "object" &&
     476              typeof callbacks[k].event !== "undefined" &&
     477              callbacks[k].event === event &&
     478              typeof callbacks[k].callback !== "undefined" &&
     479              typeof callbacks[k].callback === "function"
    480480          )
    481481          {
     
    627627
    628628    if (event &&
    629       env.origin.indexOf(event.origin) != -1 &&
    630       typeof event === "object" &&
    631       typeof event.data === "object" &&
    632       typeof event.data.name !== "undefined" &&
    633       typeof event.data.value !== "undefined") {
     629        env.origin.indexOf(event.origin) != -1 &&
     630        typeof event === "object" &&
     631        typeof event.data === "object" &&
     632        typeof event.data.name !== "undefined" &&
     633        typeof event.data.value !== "undefined") {
    634634      helper.log(" <<< ", event.data);
     635
    635636      switch (event.data.name) {
    636637        case "wk-event-token" :
     
    675676
    676677        case "wk-event-transaction" :
    677             queue.push({"task": {"name": "reload", "value": true}});
    678             helper.dispatchEvent("transaction");
     678          queue.push({"task": {"name": "reload", "value": true}});
     679          helper.dispatchEvent("transaction");
    679680          break;
    680681
     
    726727          if_ready = true;
    727728          try {
    728            if (window.ApplePaySession)
    729            {
    730              wk.sendEvent("wk-event-applepay-ready", window.ApplePaySession.canMakePayments());
    731            }
    732            else
    733            {
    734              wk.sendEvent("wk-event-applepay-ready", false);
    735            }
     729            if (window.ApplePaySession)
     730            {
     731              wk.sendEvent("wk-event-applepay-ready", window.ApplePaySession.canMakePayments());
     732            }
     733            else
     734            {
     735              wk.sendEvent("wk-event-applepay-ready", false);
     736            }
    736737          }
    737738          catch (e) {
    738            console.error("AP. e.", e);
     739            console.error("AP. e.", e);
    739740          }
    740741
  • wallkit/trunk/public/js/wallkit-integration-library.min.js

    r2125113 r2157879  
    1 !function(e){"use strict";var t;const a={auth_url:"https://wallkit.net/popups",authOrigin:"*",iframeId:"wk-integration",origin:[document.location.origin,"https://wallkit.net","https://dev.wallkit.net","https://wallkit.local"]};var o=!1,n={},i=[],s=[],r={addToTopCss:function(){var e=document.head||document.getElementsByTagName("head")[0],t=document.createElement("style");t.type="text/css",t.appendChild(document.createTextNode("#wk-overlay {display: none;position: fixed;top: 0px;left: 0px;right: 0px;bottom: 0px;background: #121214;z-index: 300000;opacity: 0;-webkit-transition: opacity .25s linear;-moz-transition: opacity .25s linear;-ms-transition: opacity .25s linear;-o-transition: opacity .25s linear;transition: opacity .25s linear;}#wk-overlay.wk-active {opacity: .9;z-index: 300000;display: block;height: 100%;}#wk-popup-wrapper {overflow-x: hidden;overflow-y: auto;display: none;position: fixed;top: 0;bottom: 0;left: 0;right: 0;overflow: auto;-webkit-overflow-scrolling: touch;}#wk-popup-wrapper.wk-active {z-index: 300050;display: block;}#wk-popup-close-button {line-height: 37px;position: absolute;top: 4;right: 4px;width: 40px;height: 40px;z-index: 300100;opacity: 0;cursor: pointer;color: #ccc;font-family: Arial, sans-serif;text-align: center;}#wk-popup-wrapper.wk-active #wk-popup-close-button {display: block;font-size: 37px;transform: rotateZ(45deg);opacity: 1;}#wk-iframe-wrapper {position: relative;margin: 40px auto;box-shadow: 0 0 10px rgba(0, 0, 0, 0.21);}@media all and (max-width: 500px) {#wk-iframe-wrapper{ margin: 0 auto; }}#wk-popup-wrapper.wk-active #wk-iframe-wrapper {transform: scale(1.0, 1.0);-moz-transform: scale(1.0, 1.0);-ms-transform: scale(1.0, 1.0);-webkit-transform: scale(1.0, 1.0);-o-transform: scale(1.0, 1.0);width: 500px;min-height: 250px;max-width: 100%;}")),e.appendChild(t)},log:function(e,t){this.getConf("debug")&&console.log("WPWKP: ",e,t)},createIframe:function(e){var t=this.getConf("auth_url"),o=this.getConf("public_key"),n=this.getConf("api_version");if(void 0===o)throw new Error("wk not configured: public key");if(void 0===t)throw new Error("wk not configured: Auth url");var i=document.getElementById("wk-overlay");i||((i=document.createElement("div")).id="wk-overlay",document.body.appendChild(i));var s=document.getElementById("wk-popup-wrapper");s||((s=document.createElement("div")).id="wk-popup-wrapper",s.onclick=function(){r.closeModal()},document.body.appendChild(s));var d=document.getElementById("wk-iframe-wrapper");d||((d=document.createElement("div")).id="wk-iframe-wrapper",s.appendChild(d));var l=document.getElementById("wk-popup-close-button");l||((l=document.createElement("div")).id="wk-popup-close-button",l.innerText="+",l.onclick=function(){r.closeModal()},d.appendChild(l));var c=document.getElementById(a.iframeId);c||(c=document.createElement("iframe"),null!==e&&e?c.setAttribute("src",t+"/"+e+"/?PUBLIC_KEY="+o+"&api_version="+n):c.setAttribute("src",t+"/?PUBLIC_KEY="+o+"&api_version="+n),c.id=a.iframeId,c.scrolling="no",c.allowtransparency="true",c.frameborder="0",c.style.width="500px",c.style.minHeight="250px",c.style.display="block",c.style.border="0",d.appendChild(c))},closeModal:function(){t.sendEvent("wk-event-modal",!1),r.display(!1),r.addClassSlug(!1)},destroyHtml:function(){var e=document.getElementById("wk-overlay");e&&e.remove();var t=document.getElementById("wk-popup-wrapper");t&&t.remove();var o=document.getElementById("wk-iframe-wrapper");o&&o.remove();var n=document.getElementById("wk-popup-close-button");n&&n.remove();var i=document.getElementById(a.iframeId);i&&i.remove(),r.dispatchEvent("destroy")},setCookie:function(e,t,a){var o=(a=a||{}).expires;if("number"==typeof o&&o){var n=new Date;n.setTime(n.getTime()+1e3*o),o=a.expires=n}o&&o.toUTCString&&(a.expires=o.toUTCString());var i=e+"="+(t=encodeURIComponent(t));for(var s in a){i+="; "+s;var r=a[s];!0!==r&&(i+="="+r)}this.log("Set cookie",i),document.cookie=i},deleteCookie:function(e){document.cookie=e+"=; expires=Thu, 01 Jan 1972 00:00:01 GMT; path=/; domain="+document.location.host},getCookie:function(e){var t=document.cookie.match(new RegExp("(?:^|; )"+e.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g,"\\$1")+"=([^;]*)"));return t?decodeURIComponent(t[1]):void 0},display:function(e){var t=document.getElementById("wk-overlay"),o=document.getElementById("wk-popup-wrapper"),n=document.getElementById(a.iframeId);return e?(t&&t.classList.add("wk-active"),o&&o.classList.add("wk-active"),n.style.width="500px",n.style.minHeight="250px",n.style.display="block",n.style.border="0",this.dispatchEvent("open")):(t&&t.classList.remove("wk-active"),o&&o.classList.remove("wk-active"),n&&(n.style.width="0px",n.style.minHeight="0px",n.style.display="none",n.style.border="0"),this.dispatchEvent("close")),!e&&i.length&&this.checkQueue(),e},addClassSlug:function(e){e&&void 0!==e?(document.getElementById("wk-popup-wrapper").classList.add("wk-inner-popup-wrapper-"+e),document.getElementById("wk-iframe-wrapper").classList.add("wk-inner-wrapper-"+e),document.getElementById("wk-overlay").classList.add("wk-inner-overlay-"+e)):(this.removeClassSlugs(document.getElementById("wk-popup-wrapper")),this.removeClassSlugs(document.getElementById("wk-iframe-wrapper")),this.removeClassSlugs(document.getElementById("wk-overlay")))},removeClassSlugs:function(e){e&&e.classList.forEach(function(e){e.indexOf("wk-inner-")>=0&&document.getElementById("wk-popup-wrapper").classList.remove(e)})},checkQueue:function(){if(i.length)for(var e in i){if(void 0!==i[e]&&void 0!==i[e].task&&void 0!==i[e].task.name&&(this.dispatchEvent(i[e].task.name),void 0!==i[e]))switch(i[e].task.name){case"reload":location.reload();break;case"modal":void 0!==i[e].task.value&&wk.sendEvent("wk-event-modal",i[e].task.value,i[e].task.params)}i.splice(e,1)}},flushQueue:function(){i=[]},getConf:function(e){return e&&void 0!==n[e]?n[e]:null},sendPageView:function(e){this.dispatchEvent("page-view");try{var t=new XMLHttpRequest;t.open("POST","https://"+this.getConf("api_host")+"/api/"+this.getConf("api_version")+"/user/event"),t.setRequestHeader("Content-Type","application/json"),t.setRequestHeader("resource",this.getConf("public_key")),t.setRequestHeader("Wallkit-Client","WPWKP v"+this.getConf("plugin_version")),this.getCookie("wk-token")&&t.setRequestHeader("token",this.getCookie("wk-token"));var a={name:"page_view",value:e};void 0!==window.wk_content_key&&window.wk_content_key&&(a.content_key=window.wk_content_key),t.send(JSON.stringify(a))}catch(e){this.getConf("debug")&&console.error(e)}},dispatchEvent:function(e,t,a){for(var o in s)if("object"==typeof s[o]&&void 0!==s[o].event&&s[o].event===e&&void 0!==s[o].callback&&"function"==typeof s[o].callback)try{s[o].callback(this,t,a)}catch(e){this.getConf("debug")&&console.error(e)}},checkExecUry:function(){var e=/#WkModal\((.*)\)$/.exec(decodeURIComponent(window.location.hash));if(e&&e[1]){var t=e[1].split(",");if(void 0!==t[1]){try{t[1]=JSON.parse(t[1])}catch(e){t[1]={value:t[1]}}setTimeout(function(){wk.modal(t[0],"object"==typeof t[1]?t[1]:null)},500),window.location.hash=""}}}};e.wk={init:function(e){if("object"!=typeof e)throw new Error("wallkit is not configured");return n=e,t=this,r.dispatchEvent("init"),t},isAuth:function(){return void 0!==r.getCookie("wk-token")},sendEvent:function(e,t,o){document.getElementById(a.iframeId).contentWindow.postMessage({name:e,value:t,params:o},a.authOrigin)},modal:function(e,t){"boolean"!=typeof e||e?(r.createIframe(e),r.addClassSlug(e),r.dispatchEvent("modal",e,t),this.sendEvent("wk-event-modal",e,t),o||i.push({task:{name:"modal",value:e,params:t}}),r.display(!0)):r.closeModal()},logout:function(){this.isAuth()&&(this.sendEvent("wk-event-logout",!0),r.display(!1),r.deleteCookie("wk-token"),i.push({task:{name:"reload",value:!0}}),r.dispatchEvent("logout"),i.length&&setTimeout(function(){location.reload()},2e3))},on:function(e,t){s.push({event:e,callback:t})}},window.addEventListener("message",function(e){if(e&&-1!=a.origin.indexOf(e.origin)&&"object"==typeof e&&"object"==typeof e.data&&void 0!==e.data.name&&void 0!==e.data.value)switch(r.log(" <<< ",e.data),e.data.name){case"wk-event-token":e.data.value&&e.data.value.length&&(r.setCookie("wk-token",e.data.value,{expires:31104e3,path:"/",domain:document.location.host}),r.dispatchEvent("token"));break;case"wk-event-auth":case"wk-event-registration":if(void 0!==e.data.value.token){var t=new Date;t.setTime(1e3*e.data.value.expires),r.setCookie("wk-token",e.data.value.token,{expires:t,path:"/",domain:document.location.host}),i.push({task:{name:"reload",value:!0}}),"wk-event-auth"===e.data.name&&r.dispatchEvent("auth"),"wk-event-registration"===e.data.name&&r.dispatchEvent("registration")}break;case"wk-event-logout":r.deleteCookie("wk-token"),i.push({task:{name:"reload",value:!0}}),r.dispatchEvent("logout");break;case"wk-event-transaction":i.push({task:{name:"reload",value:!0}}),r.dispatchEvent("transaction");break;case"wk-event-resize":o=!0;var n=e.data.value.width;n<500&&(n=500);var s=e.data.value.height;s<250&&(s=250);var d=document.getElementById(a.iframeId);d.setAttribute("style","-webkit-transition: all 0.3s linear"),d.style.maxWidth="100%",d.style.height=s+"px",d.style.width=n+"px",d.style.border="0";var l=document.getElementById("wk-iframe-wrapper");l.setAttribute("style","-moz-transform: scale(1.0, 1.0);-ms-transform: scale(1.0, 1.0);-webkit-transform: scale(1.0, 1.0);-o-transform: scale(1.0, 1.0);"),l.style.transform="scale(1.0, 1.0)",l.style.height=s+"px",l.style.width=n+"px";break;case"wk-event-close-modal":r.display(!1);break;case"wk-event-modal":e.data.value||r.display(!1);break;case"wk-event-reload-page":r.display(!1),location.reload();break;case"wk-event-modals-ready":o=!0;try{window.ApplePaySession?wk.sendEvent("wk-event-applepay-ready",window.ApplePaySession.canMakePayments()):wk.sendEvent("wk-event-applepay-ready",!1)}catch(e){console.error("AP. e.",e)}wk.isAuth()||wk.sendEvent("wk-event-get-token",r.getConf("public_key")),r.dispatchEvent("wk-ready"),r.checkQueue()}}),"complete"===document.readyState||"interactive"===document.readyState?(r.createIframe(null),r.addToTopCss(),r.getConf("send_events")&&r.sendPageView(window.location.pathname)):document.addEventListener("DOMContentLoaded",function(e){r.createIframe(null),r.addToTopCss(),r.getConf("send_events")&&r.sendPageView(window.location.pathname)}),"undefined"!=typeof wallkitSettings?wk.init(wallkitSettings):setTimeout(function(){wk.init(wallkitSettings)},1e3),r.checkExecUry()}(this);
     1!function(e){"use strict";var t;const a={auth_url:"https://wallkit.net/popups",authOrigin:"*",iframeId:"wk-integration",origin:[document.location.origin,"https://wallkit.net","https://dev.wallkit.net","https://wallkit.local"]};var o=!1,n={},i=[],s=[],r={addToTopCss:function(){var e=document.head||document.getElementsByTagName("head")[0],t=document.createElement("style");t.type="text/css",t.appendChild(document.createTextNode("#wk-overlay {display: none;position: fixed;top: 0px;left: 0px;right: 0px;bottom: 0px;background: #121214;z-index: 300000;opacity: 0;-webkit-transition: opacity .25s linear;-moz-transition: opacity .25s linear;-ms-transition: opacity .25s linear;-o-transition: opacity .25s linear;transition: opacity .25s linear;}#wk-overlay.wk-active {opacity: .9;z-index: 300000;display: block;height: 100%;}#wk-popup-wrapper {overflow-x: hidden;overflow-y: auto;display: none;position: fixed;top: 0;bottom: 0;left: 0;right: 0;overflow: auto;-webkit-overflow-scrolling: touch;}#wk-popup-wrapper.wk-active {z-index: 300050;display: block;}#wk-popup-close-button {line-height: 37px;position: absolute;top: 10px;right: 10px;width: 37px;height: 37px;z-index: 300100;opacity: 0;cursor: pointer;color: #ccc;font-family: Arial, sans-serif;text-align: center;}#wk-popup-wrapper.wk-active #wk-popup-close-button {display: block;font-size: 37px;transform: rotateZ(45deg);opacity: 1;}#wk-iframe-wrapper {position: relative;margin: 40px auto;box-shadow: 0 0 10px rgba(0, 0, 0, 0.21);}@media all and (max-width: 500px) {#wk-iframe-wrapper{ margin: 0 auto; }}#wk-popup-wrapper.wk-active #wk-iframe-wrapper {transform: scale(1.0, 1.0);-moz-transform: scale(1.0, 1.0);-ms-transform: scale(1.0, 1.0);-webkit-transform: scale(1.0, 1.0);-o-transform: scale(1.0, 1.0);width: 500px;min-height: 250px;max-width: 100%;}")),e.appendChild(t)},log:function(e,t){this.getConf("debug")&&console.log("WPWKP: ",e,t)},createIframe:function(e){var t=this.getConf("auth_url"),o=this.getConf("public_key"),n=this.getConf("api_version");if(void 0===o)throw new Error("wk not configured: public key");if(void 0===t)throw new Error("wk not configured: Auth url");var i=document.getElementById("wk-overlay");i||((i=document.createElement("div")).id="wk-overlay",document.body.appendChild(i));var s=document.getElementById("wk-popup-wrapper");s||((s=document.createElement("div")).id="wk-popup-wrapper",s.onclick=function(){r.closeModal()},document.body.appendChild(s));var d=document.getElementById("wk-iframe-wrapper");d||((d=document.createElement("div")).id="wk-iframe-wrapper",s.appendChild(d));var l=document.getElementById("wk-popup-close-button");l||((l=document.createElement("div")).id="wk-popup-close-button",l.innerText="+",l.onclick=function(){r.closeModal()},d.appendChild(l));var c=document.getElementById(a.iframeId);c||(c=document.createElement("iframe"),null!==e&&e?c.setAttribute("src",t+"/"+e+"/?PUBLIC_KEY="+o+"&api_version="+n):c.setAttribute("src",t+"/?PUBLIC_KEY="+o+"&api_version="+n),c.id=a.iframeId,c.scrolling="no",c.allowtransparency="true",c.frameborder="0",c.style.width="500px",c.style.minHeight="250px",c.style.display="block",c.style.border="0",d.appendChild(c))},closeModal:function(){t.sendEvent("wk-event-modal",!1),r.display(!1),r.addClassSlug(!1)},destroyHtml:function(){var e=document.getElementById("wk-overlay");e&&e.remove();var t=document.getElementById("wk-popup-wrapper");t&&t.remove();var o=document.getElementById("wk-iframe-wrapper");o&&o.remove();var n=document.getElementById("wk-popup-close-button");n&&n.remove();var i=document.getElementById(a.iframeId);i&&i.remove(),r.dispatchEvent("destroy")},setCookie:function(e,t,a){var o=(a=a||{}).expires;if("number"==typeof o&&o){var n=new Date;n.setTime(n.getTime()+1e3*o),o=a.expires=n}o&&o.toUTCString&&(a.expires=o.toUTCString());var i=e+"="+(t=encodeURIComponent(t));for(var s in a){i+="; "+s;var r=a[s];!0!==r&&(i+="="+r)}this.log("Set cookie",i),document.cookie=i},deleteCookie:function(e){document.cookie=e+"=; expires=Thu, 01 Jan 1972 00:00:01 GMT; path=/; domain="+document.location.host},getCookie:function(e){var t=document.cookie.match(new RegExp("(?:^|; )"+e.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g,"\\$1")+"=([^;]*)"));return t?decodeURIComponent(t[1]):void 0},display:function(e){var t=document.getElementById("wk-overlay"),o=document.getElementById("wk-popup-wrapper"),n=document.getElementById(a.iframeId);return e?(t&&t.classList.add("wk-active"),o&&o.classList.add("wk-active"),n.style.width="500px",n.style.minHeight="250px",n.style.display="block",n.style.border="0",this.dispatchEvent("open")):(t&&t.classList.remove("wk-active"),o&&o.classList.remove("wk-active"),n&&(n.style.width="0px",n.style.minHeight="0px",n.style.display="none",n.style.border="0"),this.dispatchEvent("close")),!e&&i.length&&this.checkQueue(),e},addClassSlug:function(e){e&&void 0!==e?(document.getElementById("wk-popup-wrapper").classList.add("wk-inner-popup-wrapper-"+e),document.getElementById("wk-iframe-wrapper").classList.add("wk-inner-wrapper-"+e),document.getElementById("wk-overlay").classList.add("wk-inner-overlay-"+e)):(this.removeClassSlugs(document.getElementById("wk-popup-wrapper")),this.removeClassSlugs(document.getElementById("wk-iframe-wrapper")),this.removeClassSlugs(document.getElementById("wk-overlay")))},removeClassSlugs:function(e){e&&e.classList.forEach(function(e){e.indexOf("wk-inner-")>=0&&document.getElementById("wk-popup-wrapper").classList.remove(e)})},checkQueue:function(){if(i.length)for(var e in i){if(void 0!==i[e]&&void 0!==i[e].task&&void 0!==i[e].task.name&&(this.dispatchEvent(i[e].task.name),void 0!==i[e]))switch(i[e].task.name){case"reload":location.reload();break;case"modal":void 0!==i[e].task.value&&wk.sendEvent("wk-event-modal",i[e].task.value,i[e].task.params)}i.splice(e,1)}},flushQueue:function(){i=[]},getConf:function(e){return e&&void 0!==n[e]?n[e]:null},sendPageView:function(e){this.dispatchEvent("page-view");try{var t=new XMLHttpRequest;t.open("POST","https://"+this.getConf("api_host")+"/api/"+this.getConf("api_version")+"/user/event"),t.setRequestHeader("Content-Type","application/json"),t.setRequestHeader("resource",this.getConf("public_key")),t.setRequestHeader("Wallkit-Client","WPWKP v"+this.getConf("plugin_version")),this.getCookie("wk-token")&&t.setRequestHeader("token",this.getCookie("wk-token"));var a={name:"page_view",value:e};void 0!==window.wk_content_key&&window.wk_content_key&&(a.content_key=window.wk_content_key),t.send(JSON.stringify(a))}catch(e){this.getConf("debug")&&console.error(e)}},dispatchEvent:function(e,t,a){for(var o in s)if("object"==typeof s[o]&&void 0!==s[o].event&&s[o].event===e&&void 0!==s[o].callback&&"function"==typeof s[o].callback)try{s[o].callback(this,t,a)}catch(e){this.getConf("debug")&&console.error(e)}},checkExecUry:function(){var e=/#WkModal\((.*)\)$/.exec(decodeURIComponent(window.location.hash));if(e&&e[1]){var t=e[1].split(",");if(void 0!==t[1]){try{t[1]=JSON.parse(t[1])}catch(e){t[1]={value:t[1]}}setTimeout(function(){wk.modal(t[0],"object"==typeof t[1]?t[1]:null)},500),window.location.hash=""}}}};e.wk={init:function(e){if("object"!=typeof e)throw new Error("wallkit is not configured");return n=e,t=this,r.dispatchEvent("init"),t},isAuth:function(){return void 0!==r.getCookie("wk-token")},sendEvent:function(e,t,o){document.getElementById(a.iframeId).contentWindow.postMessage({name:e,value:t,params:o},a.authOrigin)},modal:function(e,t){"boolean"!=typeof e||e?(r.createIframe(e),r.addClassSlug(e),r.dispatchEvent("modal",e,t),this.sendEvent("wk-event-modal",e,t),o||i.push({task:{name:"modal",value:e,params:t}}),r.display(!0)):r.closeModal()},logout:function(){this.isAuth()&&(this.sendEvent("wk-event-logout",!0),r.display(!1),r.deleteCookie("wk-token"),i.push({task:{name:"reload",value:!0}}),r.dispatchEvent("logout"),i.length&&setTimeout(function(){location.reload()},2e3))},on:function(e,t){s.push({event:e,callback:t})}},window.addEventListener("message",function(e){if(e&&-1!=a.origin.indexOf(e.origin)&&"object"==typeof e&&"object"==typeof e.data&&void 0!==e.data.name&&void 0!==e.data.value)switch(r.log(" <<< ",e.data),e.data.name){case"wk-event-token":e.data.value&&e.data.value.length&&(r.setCookie("wk-token",e.data.value,{expires:31104e3,path:"/",domain:document.location.host}),r.dispatchEvent("token"));break;case"wk-event-auth":case"wk-event-registration":if(void 0!==e.data.value.token){var t=new Date;t.setTime(1e3*e.data.value.expires),r.setCookie("wk-token",e.data.value.token,{expires:t,path:"/",domain:document.location.host}),i.push({task:{name:"reload",value:!0}}),"wk-event-auth"===e.data.name&&r.dispatchEvent("auth"),"wk-event-registration"===e.data.name&&r.dispatchEvent("registration")}break;case"wk-event-logout":r.deleteCookie("wk-token"),i.push({task:{name:"reload",value:!0}}),r.dispatchEvent("logout");break;case"wk-event-transaction":i.push({task:{name:"reload",value:!0}}),r.dispatchEvent("transaction");break;case"wk-event-resize":o=!0;var n=e.data.value.width;n<500&&(n=500);var s=e.data.value.height;s<250&&(s=250);var d=document.getElementById(a.iframeId);d.setAttribute("style","-webkit-transition: all 0.3s linear"),d.style.maxWidth="100%",d.style.height=s+"px",d.style.width=n+"px",d.style.border="0";var l=document.getElementById("wk-iframe-wrapper");l.setAttribute("style","-moz-transform: scale(1.0, 1.0);-ms-transform: scale(1.0, 1.0);-webkit-transform: scale(1.0, 1.0);-o-transform: scale(1.0, 1.0);"),l.style.transform="scale(1.0, 1.0)",l.style.height=s+"px",l.style.width=n+"px";break;case"wk-event-close-modal":r.display(!1);break;case"wk-event-modal":e.data.value||r.display(!1);break;case"wk-event-reload-page":r.display(!1),location.reload();break;case"wk-event-modals-ready":o=!0;try{window.ApplePaySession?wk.sendEvent("wk-event-applepay-ready",window.ApplePaySession.canMakePayments()):wk.sendEvent("wk-event-applepay-ready",!1)}catch(e){console.error("AP. e.",e)}wk.isAuth()||wk.sendEvent("wk-event-get-token",r.getConf("public_key")),r.dispatchEvent("wk-ready"),r.checkQueue()}}),"complete"===document.readyState||"interactive"===document.readyState?(r.createIframe(null),r.addToTopCss(),r.getConf("send_events")&&r.sendPageView(window.location.pathname)):document.addEventListener("DOMContentLoaded",function(e){r.createIframe(null),r.addToTopCss(),r.getConf("send_events")&&r.sendPageView(window.location.pathname)}),"undefined"!=typeof wallkitSettings?wk.init(wallkitSettings):setTimeout(function(){wk.init(wallkitSettings)},1e3),r.checkExecUry()}(this);
  • wallkit/trunk/wallkit-wp.php

    r2125113 r2157879  
    1010 * Plugin URI:        https://wallkit.net
    1111 * Description:       A Plug & Play paid-content system to manage subscribers, gather fees and drive additional content sales.
    12  * Version:           1.1.34
     12 * Version:           1.1.35
    1313 * Author:            Wallkit <dev@wallkit.net>
    1414 * Author URI:        https://wallkit.net/
     
    1717 */
    1818
    19 
    20 // If this file is called directly, abort.
     19// If this file is called directly, abort
    2120if ( ! defined( 'WPINC' ) ) {
    22     die;
     21    die;
    2322}
    2423
     
    2827 * Rename this for your plugin and update it as you release new versions.
    2928 */
    30 define( 'WPWKP_VERSION', '1.1.34' );
     29define( 'WPWKP_VERSION', '1.1.35' );
    3130
    3231/**
     
    8281 */
    8382function activate_wallkit_wp() {
    84     require_once plugin_dir_path( __FILE__ ) . 'includes/class-wallkit-wp-activator.php';
    85     Wallkit_Wp_Activator::activate();
     83    require_once plugin_dir_path( __FILE__ ) . 'includes/class-wallkit-wp-activator.php';
     84    Wallkit_Wp_Activator::activate();
    8685}
    8786
     
    9190 */
    9291function deactivate_wallkit_wp() {
    93     require_once plugin_dir_path( __FILE__ ) . 'includes/class-wallkit-wp-deactivator.php';
    94     Wallkit_Wp_Deactivator::deactivate();
     92    require_once plugin_dir_path( __FILE__ ) . 'includes/class-wallkit-wp-deactivator.php';
     93    Wallkit_Wp_Deactivator::deactivate();
    9594}
    9695
     
    116115function run_wallkit_wp(&$WallkitPhpSdk) {
    117116
    118     $plugin = new Wallkit_Wp();
    119     $plugin->run();
     117    $plugin = new Wallkit_Wp();
     118    $plugin->run();
    120119
    121120    $WallkitPhpSdk = $plugin->get_wallkit_sdk();
Note: See TracChangeset for help on using the changeset viewer.