Skip to content

Commit

Permalink
Merge pull request #34 from xsolla/IGS-2628_close
Browse files Browse the repository at this point in the history
feat [IGS-2628] added close function
  • Loading branch information
epolyanina authored Jul 13, 2022
2 parents b87508e + 6a67931 commit df5033c
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 12 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Changelog
## 1.2.7
- [feature] Added close function

## 1.2.6
- [fix] hideScrollbar function fix

Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Features:

#### Linking to Xsolla CDN

Script is located on our CDN and is available here: [https://cdn.xsolla.net/embed/paystation/1.2.6/widget.min.js](https://cdn.xsolla.net/embed/paystation/1.2.6/widget.min.js). Use this URL to integrate script on your website.
Script is located on our CDN and is available here: [https://cdn.xsolla.net/embed/paystation/1.2.7/widget.min.js](https://cdn.xsolla.net/embed/paystation/1.2.7/widget.min.js). Use this URL to integrate script on your website.

#### Installing with Bower

Expand All @@ -37,7 +37,7 @@ $ bower install xsolla-paystation-widget
var s = document.createElement('script');
s.type = "text/javascript";
s.async = true;
s.src = "//cdn.xsolla.net/embed/paystation/1.2.6/widget.min.js";
s.src = "//cdn.xsolla.net/embed/paystation/1.2.7/widget.min.js";
s.addEventListener('load', function (e) {
XPayStationWidget.init(options);
}, false);
Expand All @@ -49,7 +49,7 @@ $ bower install xsolla-paystation-widget
#### Synchronous loading (blocks content)

``` javascript
<script src="//cdn.xsolla.net/embed/paystation/1.2.6/widget.min.js"></script>
<script src="//cdn.xsolla.net/embed/paystation/1.2.7/widget.min.js"></script>
<script>
XPayStationWidget.init({
access_token: 'abcdef1234567890abcdef1234567890'
Expand Down
23 changes: 19 additions & 4 deletions dist/widget.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dist/widget.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/widget.min.js.map

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module.exports = (function () {
this.eventObject = Helpers.addEventObject(this);
this.isInitiated = false;
this.postMessage = null;
this.childWindow = null;
}

App.eventTypes = {
Expand Down Expand Up @@ -217,6 +218,7 @@ module.exports = (function () {
childWindow.on('status', handleStatus);
childWindow.on(App.eventTypes.USER_COUNTRY, handleUserLocale);
childWindow.open(url, this.config.childWindow);
that.childWindow = childWindow;
} else {
var lightBox = new LightBox((new Device).isMobile() && this.config.iframeOnly);
lightBox.on('open', function handleOpen() {
Expand All @@ -239,9 +241,18 @@ module.exports = (function () {
lightBox.on('status', handleStatus);
lightBox.on(App.eventTypes.USER_COUNTRY, handleUserLocale);
lightBox.openFrame(url, this.config.lightbox);
that.childWindow = lightBox;
}
};


/**
* Close payment interface (PayStation)
*/
App.prototype.close = function () {
this.childWindow.close();
};

/**
* Attach an event handler function for one or more events to the widget
* @param event One or more space-separated event types (init, open, load, close, status, status-invoice, status-delivering, status-troubled, status-done)
Expand Down
4 changes: 4 additions & 0 deletions src/lightbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,10 @@ module.exports = (function () {
}
};

LightBox.prototype.close = function () {
this.closeFrame();
};

LightBox.prototype.on = function () {
this.eventObject.on.apply(this.eventObject, arguments);
};
Expand Down
2 changes: 1 addition & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = (function () {
return instance;
};

return Object.assign(Helpers.zipObject(['init', 'open', 'on', 'off', 'sendMessage', 'onMessage'].map(function (methodName) {
return Object.assign(Helpers.zipObject(['init', 'open', 'close', 'on', 'off', 'sendMessage', 'onMessage'].map(function (methodName) {
var app = getInstance();
return [methodName, function () {
return app[methodName].apply(app, arguments);
Expand Down
2 changes: 1 addition & 1 deletion src/version.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
module.exports = '1.2.6';
module.exports = '1.2.7';

0 comments on commit df5033c

Please sign in to comment.