@dintero/checkout-web-sdk 0.0.15 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc +3 -0
- package/.github/dependabot.yml +10 -0
- package/.github/workflows/build.yml +25 -0
- package/.github/workflows/release.yml +34 -0
- package/.releaserc.json +11 -0
- package/CHANGELOG.md +17 -3
- package/LISENCE +20 -0
- package/README.md +91 -24
- package/coverage/Chrome Headless 80.0.3987.0 (Linux x86_64)/html/base.css +224 -0
- package/coverage/Chrome Headless 80.0.3987.0 (Linux x86_64)/html/block-navigation.js +79 -0
- package/coverage/Chrome Headless 80.0.3987.0 (Linux x86_64)/html/checkout.ts.html +383 -0
- package/coverage/Chrome Headless 80.0.3987.0 (Linux x86_64)/html/createIframeAsync.ts.html +254 -0
- package/coverage/Chrome Headless 80.0.3987.0 (Linux x86_64)/html/favicon.png +0 -0
- package/coverage/Chrome Headless 80.0.3987.0 (Linux x86_64)/html/index.html +171 -0
- package/coverage/Chrome Headless 80.0.3987.0 (Linux x86_64)/html/index.ts.html +1133 -0
- package/coverage/Chrome Headless 80.0.3987.0 (Linux x86_64)/html/prettify.css +1 -0
- package/coverage/Chrome Headless 80.0.3987.0 (Linux x86_64)/html/prettify.js +2 -0
- package/coverage/Chrome Headless 80.0.3987.0 (Linux x86_64)/html/sort-arrow-sprite.png +0 -0
- package/coverage/Chrome Headless 80.0.3987.0 (Linux x86_64)/html/sorter.js +170 -0
- package/coverage/Chrome Headless 80.0.3987.0 (Linux x86_64)/html/subscribe.ts.html +443 -0
- package/coverage/Chrome Headless 80.0.3987.0 (Linux x86_64)/html/url.ts.html +185 -0
- package/dist/declarations/package.d.ts +52 -0
- package/dist/{src → declarations}/src/checkout.d.ts +20 -2
- package/dist/{src → declarations}/src/createIframeAsync.d.ts +0 -0
- package/dist/{src/src/dintero-checkout-web-sdk.d.ts → declarations/src/index.d.ts} +6 -2
- package/dist/declarations/src/session.d.ts +953 -0
- package/dist/{src → declarations}/src/subscribe.d.ts +10 -2
- package/dist/{src → declarations}/src/url.d.ts +1 -0
- package/dist/dintero-checkout-web-sdk.cjs.d.ts +1 -0
- package/dist/dintero-checkout-web-sdk.cjs.dev.js +475 -0
- package/dist/dintero-checkout-web-sdk.cjs.js +7 -0
- package/dist/dintero-checkout-web-sdk.cjs.prod.js +475 -0
- package/dist/dintero-checkout-web-sdk.esm.js +470 -0
- package/dist/dintero-checkout-web-sdk.umd.min.js +7 -0
- package/dist/dintero-checkout-web-sdk.umd.min.js.map +1 -0
- package/karma.conf.js +33 -0
- package/package.json +49 -43
- package/dist/checkout-web-sdk.js +0 -2
- package/dist/checkout-web-sdk.js.map +0 -1
- package/dist/checkout-web-sdk.js.mjs +0 -2
- package/dist/checkout-web-sdk.js.mjs.map +0 -1
- package/dist/checkout-web-sdk.modern.js +0 -2
- package/dist/checkout-web-sdk.modern.js.map +0 -1
- package/dist/checkout-web-sdk.umd.js +0 -2
- package/dist/checkout-web-sdk.umd.js.map +0 -1
package/.babelrc
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
branches: [ master ]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
|
|
9
|
+
build:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
|
|
12
|
+
steps:
|
|
13
|
+
- uses: actions/checkout@v2
|
|
14
|
+
with:
|
|
15
|
+
fetch-depth: 0
|
|
16
|
+
- uses: actions/setup-node@v2
|
|
17
|
+
with:
|
|
18
|
+
node-version: 'lts/*'
|
|
19
|
+
cache: npm
|
|
20
|
+
|
|
21
|
+
- name: npm install, build and test
|
|
22
|
+
run: |
|
|
23
|
+
npm install
|
|
24
|
+
npm run test
|
|
25
|
+
npm run build
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- master
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
release:
|
|
10
|
+
name: Release
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
|
|
13
|
+
steps:
|
|
14
|
+
- name: Checkout
|
|
15
|
+
uses: actions/checkout@v2
|
|
16
|
+
with:
|
|
17
|
+
fetch-depth: 0
|
|
18
|
+
|
|
19
|
+
- name: Setup Node.js
|
|
20
|
+
uses: actions/setup-node@v2
|
|
21
|
+
with:
|
|
22
|
+
node-version: 'lts/*'
|
|
23
|
+
|
|
24
|
+
- name: Install dependencies
|
|
25
|
+
run: |
|
|
26
|
+
npm install
|
|
27
|
+
npm run test
|
|
28
|
+
npm run build
|
|
29
|
+
|
|
30
|
+
- name: Release
|
|
31
|
+
env:
|
|
32
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
33
|
+
NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
|
|
34
|
+
run: npx semantic-release
|
package/.releaserc.json
ADDED
package/CHANGELOG.md
CHANGED
|
@@ -1,15 +1,29 @@
|
|
|
1
|
+
## [0.0.17]
|
|
2
|
+
|
|
3
|
+
### Changed
|
|
4
|
+
|
|
5
|
+
- Adds `onActivePaymentProductType` callback.
|
|
6
|
+
- Adds `setActivePaymentProductType` function.
|
|
7
|
+
|
|
8
|
+
## [0.0.16]
|
|
9
|
+
|
|
10
|
+
### Changed
|
|
11
|
+
|
|
12
|
+
- Changed build tool from microbundle to preconstruct, should fix exported types, updated/fixed documentation
|
|
13
|
+
|
|
1
14
|
## [0.0.15]
|
|
2
15
|
|
|
3
16
|
### Changed
|
|
17
|
+
|
|
4
18
|
- Added `lockSession` and `refreshSession` functions
|
|
5
19
|
|
|
6
20
|
## [0.0.14]
|
|
7
21
|
|
|
8
22
|
### Changed
|
|
9
23
|
|
|
10
|
-
-
|
|
11
|
-
-
|
|
12
|
-
|
|
24
|
+
- Added `onSessionLocked` and `onSessionLockFailed` callbacks
|
|
25
|
+
- Bumped dev dependencies to fix security issues with some of the
|
|
26
|
+
dev dependencies
|
|
13
27
|
|
|
14
28
|
## [0.0.13]
|
|
15
29
|
|
package/LISENCE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright 2020 Dintero
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
|
7
|
+
the Software without restriction, including without limitation the rights to
|
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
|
10
|
+
subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Dintero Checkout JavaScript SDK for frontend applications
|
|
1
|
+
# Dintero Checkout JavaScript SDK for frontend applications [](https://github.com/Dintero/Dintero.Checkout.Web.SDK/actions?query=branch%3Amaster+workflow%3ACI+)
|
|
2
2
|
|
|
3
3
|
Use this SDK in your frontend application to
|
|
4
4
|
|
|
@@ -25,14 +25,6 @@ If no custom handler are added for `onPaymentError`, `onPaymentAuthorized` and `
|
|
|
25
25
|
npm install @dintero/checkout-web-sdk
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
**unpkg**
|
|
29
|
-
|
|
30
|
-
Load the Dintero Checkout SDK in a script tag on your site.
|
|
31
|
-
|
|
32
|
-
```
|
|
33
|
-
<script src="https://unpkg.com/@dintero/checkout-web-sdk@0.0.15/dist/checkout-web-sdk.umd.js" integrity="sha384-gK00EjapsB3XDSBcfZCytvn/3dISQtNuPAnHQliWpgjmgz+o7jQzhHDlVYWt3don"></script>
|
|
34
|
-
```
|
|
35
|
-
|
|
36
28
|
## Using the SDK for an embedded checkout
|
|
37
29
|
|
|
38
30
|
The Dintero Checkout will be added to the `<div id="checkout-container"></div>` DOM-node.
|
|
@@ -81,12 +73,23 @@ _The checkout sdk will add a polyfill for promises if the browser does not suppo
|
|
|
81
73
|
console.log("href", event.href);
|
|
82
74
|
checkout.destroy();
|
|
83
75
|
},
|
|
84
|
-
onSessionLocked: function(event, checkout) {
|
|
76
|
+
onSessionLocked: function(event, checkout, callback) {
|
|
85
77
|
console.log("pay_lock_id", event.pay_lock_id);
|
|
78
|
+
callback(); // refresh session
|
|
86
79
|
},
|
|
87
80
|
onSessionLockFailed: function(event, checkout) {
|
|
88
81
|
console.log("session lock failed");
|
|
89
82
|
},
|
|
83
|
+
onActivePaymentType: function(event, checkout) {
|
|
84
|
+
console.log("payment product type selected", event.payment_product_type);
|
|
85
|
+
},
|
|
86
|
+
onValidateSession: function(event, checkout, callback) {
|
|
87
|
+
console.log("validating session", event.session);
|
|
88
|
+
callback({
|
|
89
|
+
success: true,
|
|
90
|
+
clientValidationError: undefined,
|
|
91
|
+
});
|
|
92
|
+
},
|
|
90
93
|
})
|
|
91
94
|
.then(function(checkout) {
|
|
92
95
|
console.log("checkout", checkout);
|
|
@@ -98,7 +101,7 @@ _The checkout sdk will add a polyfill for promises if the browser does not suppo
|
|
|
98
101
|
|
|
99
102
|
```ts
|
|
100
103
|
import {
|
|
101
|
-
|
|
104
|
+
embed,
|
|
102
105
|
SessionLoaded,
|
|
103
106
|
SessionUpdated,
|
|
104
107
|
SessionPayment,
|
|
@@ -108,7 +111,7 @@ import {
|
|
|
108
111
|
|
|
109
112
|
const container = document.getElementById("checkout-container");
|
|
110
113
|
|
|
111
|
-
const checkout = await
|
|
114
|
+
const checkout = await embed({
|
|
112
115
|
container,
|
|
113
116
|
sid: "T11223344.<short-uuid>",
|
|
114
117
|
language: "no", \\ optional parameter, an ISO 639-1 two-letter language code
|
|
@@ -128,15 +131,40 @@ const checkout = await dintero.embed({
|
|
|
128
131
|
console.log("href", event.href);
|
|
129
132
|
checkout.destroy();
|
|
130
133
|
},
|
|
131
|
-
onSessionLocked: (event, checkout) => {
|
|
134
|
+
onSessionLocked: (event, checkout, callback) => {
|
|
132
135
|
console.log("pay_lock_id", event.pay_lock_id);
|
|
136
|
+
callback(); // refresh session
|
|
133
137
|
},
|
|
134
138
|
onSessionLockFailed: (event, checkout) => {
|
|
135
139
|
console.log("session lock failed");
|
|
136
140
|
},
|
|
141
|
+
onActivePaymentType: function(event, checkout) {
|
|
142
|
+
console.log("payment product type selected", event.payment_product_type);
|
|
143
|
+
},
|
|
144
|
+
onValidateSession: function(event, checkout, callback) {
|
|
145
|
+
console.log("validating session", event.session);
|
|
146
|
+
callback({
|
|
147
|
+
success: true,
|
|
148
|
+
clientValidationError: undefined,
|
|
149
|
+
});
|
|
150
|
+
},
|
|
137
151
|
});
|
|
138
152
|
```
|
|
139
153
|
|
|
154
|
+
### Setting payment product type
|
|
155
|
+
|
|
156
|
+
The payment product type can be set with the returned `setActivePaymentProductType()`function when embedding the checkout.
|
|
157
|
+
|
|
158
|
+
Select "vipps" payment product type:
|
|
159
|
+
```
|
|
160
|
+
checkout.setActivePaymentProductType("vipps");
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Resetting selection (so no option is selected in the checkout):
|
|
164
|
+
```
|
|
165
|
+
checkout.setActivePaymentProductType();
|
|
166
|
+
```
|
|
167
|
+
|
|
140
168
|
### Updating an Checkout Express-session
|
|
141
169
|
|
|
142
170
|
To update an existing Checkout Express-session, follow these steps:
|
|
@@ -147,7 +175,7 @@ To update an existing Checkout Express-session, follow these steps:
|
|
|
147
175
|
|
|
148
176
|
#### Locking the session
|
|
149
177
|
|
|
150
|
-
Call lockSession on the checkout object:
|
|
178
|
+
Call lockSession on the checkout object:
|
|
151
179
|
|
|
152
180
|
```js
|
|
153
181
|
checkout.lockSession();
|
|
@@ -164,23 +192,66 @@ See [session update](https://docs.dintero.com/checkout-api.html#operation/checko
|
|
|
164
192
|
|
|
165
193
|
#### Refreshing the session
|
|
166
194
|
|
|
167
|
-
After updating the session, call refreshSession on the checkout object:
|
|
195
|
+
After updating the session, call refreshSession on the checkout object:
|
|
168
196
|
|
|
169
197
|
```js
|
|
170
198
|
checkout.refreshSession();
|
|
171
199
|
```
|
|
172
200
|
|
|
201
|
+
or use the callback in `onSessionLocked`:
|
|
202
|
+
|
|
203
|
+
```js
|
|
204
|
+
onSessionLocked: (event, checkout, callback) => {
|
|
205
|
+
console.log("pay_lock_id", event.pay_lock_id);
|
|
206
|
+
callback(); // refresh session
|
|
207
|
+
}
|
|
208
|
+
```
|
|
209
|
+
|
|
173
210
|
Editing and paying in the checkout is enabled again.
|
|
174
211
|
|
|
212
|
+
### Validating session before payment
|
|
213
|
+
|
|
214
|
+
To validate the session and perform actions before the session is paid, use the `onSessionValidation`-handler.
|
|
215
|
+
|
|
216
|
+
The checkout will be locked and payment will be paused until the provided callback function is called, or `checkout.submitValidationResult` is called with the result.
|
|
217
|
+
|
|
218
|
+
When validated successfully, return a successful result:
|
|
219
|
+
|
|
220
|
+
```js
|
|
221
|
+
{
|
|
222
|
+
success: true
|
|
223
|
+
}
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
If the validation is not successful, return the result with an error message:
|
|
227
|
+
|
|
228
|
+
```js
|
|
229
|
+
{
|
|
230
|
+
success: false,
|
|
231
|
+
clientValidationError: "session is not in sync with cart"
|
|
232
|
+
}
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
Example implementation:
|
|
236
|
+
|
|
237
|
+
```
|
|
238
|
+
onValidateSession: function(event, checkout, callback) {
|
|
239
|
+
// Call the ecommerce solution to make sure the session is sync with the cart
|
|
240
|
+
callback({
|
|
241
|
+
success: false,
|
|
242
|
+
clientValidationError: "session is not in sync with cart",
|
|
243
|
+
});
|
|
244
|
+
},
|
|
245
|
+
```
|
|
175
246
|
|
|
176
247
|
## Using the SDK for a redirect checkout
|
|
177
248
|
|
|
178
249
|
The user is redirected to the Dintero Checkout to complete payment.
|
|
179
250
|
|
|
180
251
|
```ts
|
|
181
|
-
import {
|
|
252
|
+
import { redirect } from "dintero-checkout-web-sdk";
|
|
182
253
|
|
|
183
|
-
const checkout =
|
|
254
|
+
const checkout = redirect({
|
|
184
255
|
sid: "T11223344.<short-uuid>",
|
|
185
256
|
});
|
|
186
257
|
```
|
|
@@ -208,11 +279,7 @@ npm run build
|
|
|
208
279
|
|
|
209
280
|
The Dintero Checkout SDK is built with [microbundle](https://github.com/developit/microbundle).
|
|
210
281
|
|
|
211
|
-
## Creating a new release
|
|
282
|
+
## Creating a new release
|
|
212
283
|
|
|
213
|
-
1.
|
|
214
|
-
2.
|
|
215
|
-
3. Update README.md with new version/sha
|
|
216
|
-
4. Publish new version to npm with `npm publish --access=public`.
|
|
217
|
-
5. Tag and create release in Github
|
|
218
|
-
`git tag "v$(jq .version -r < package.json)"`
|
|
284
|
+
1. Enforce all commits to the master branch to be formatted according to the [Angular Commit Message Format](https://github.com/angular/angular/blob/master/CONTRIBUTING.md#-commit-message-format)
|
|
285
|
+
2. When merged to master, it will automatically be released with [semantic-release](https://github.com/semantic-release/semantic-release)
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
body, html {
|
|
2
|
+
margin:0; padding: 0;
|
|
3
|
+
height: 100%;
|
|
4
|
+
}
|
|
5
|
+
body {
|
|
6
|
+
font-family: Helvetica Neue, Helvetica, Arial;
|
|
7
|
+
font-size: 14px;
|
|
8
|
+
color:#333;
|
|
9
|
+
}
|
|
10
|
+
.small { font-size: 12px; }
|
|
11
|
+
*, *:after, *:before {
|
|
12
|
+
-webkit-box-sizing:border-box;
|
|
13
|
+
-moz-box-sizing:border-box;
|
|
14
|
+
box-sizing:border-box;
|
|
15
|
+
}
|
|
16
|
+
h1 { font-size: 20px; margin: 0;}
|
|
17
|
+
h2 { font-size: 14px; }
|
|
18
|
+
pre {
|
|
19
|
+
font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace;
|
|
20
|
+
margin: 0;
|
|
21
|
+
padding: 0;
|
|
22
|
+
-moz-tab-size: 2;
|
|
23
|
+
-o-tab-size: 2;
|
|
24
|
+
tab-size: 2;
|
|
25
|
+
}
|
|
26
|
+
a { color:#0074D9; text-decoration:none; }
|
|
27
|
+
a:hover { text-decoration:underline; }
|
|
28
|
+
.strong { font-weight: bold; }
|
|
29
|
+
.space-top1 { padding: 10px 0 0 0; }
|
|
30
|
+
.pad2y { padding: 20px 0; }
|
|
31
|
+
.pad1y { padding: 10px 0; }
|
|
32
|
+
.pad2x { padding: 0 20px; }
|
|
33
|
+
.pad2 { padding: 20px; }
|
|
34
|
+
.pad1 { padding: 10px; }
|
|
35
|
+
.space-left2 { padding-left:55px; }
|
|
36
|
+
.space-right2 { padding-right:20px; }
|
|
37
|
+
.center { text-align:center; }
|
|
38
|
+
.clearfix { display:block; }
|
|
39
|
+
.clearfix:after {
|
|
40
|
+
content:'';
|
|
41
|
+
display:block;
|
|
42
|
+
height:0;
|
|
43
|
+
clear:both;
|
|
44
|
+
visibility:hidden;
|
|
45
|
+
}
|
|
46
|
+
.fl { float: left; }
|
|
47
|
+
@media only screen and (max-width:640px) {
|
|
48
|
+
.col3 { width:100%; max-width:100%; }
|
|
49
|
+
.hide-mobile { display:none!important; }
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.quiet {
|
|
53
|
+
color: #7f7f7f;
|
|
54
|
+
color: rgba(0,0,0,0.5);
|
|
55
|
+
}
|
|
56
|
+
.quiet a { opacity: 0.7; }
|
|
57
|
+
|
|
58
|
+
.fraction {
|
|
59
|
+
font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace;
|
|
60
|
+
font-size: 10px;
|
|
61
|
+
color: #555;
|
|
62
|
+
background: #E8E8E8;
|
|
63
|
+
padding: 4px 5px;
|
|
64
|
+
border-radius: 3px;
|
|
65
|
+
vertical-align: middle;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
div.path a:link, div.path a:visited { color: #333; }
|
|
69
|
+
table.coverage {
|
|
70
|
+
border-collapse: collapse;
|
|
71
|
+
margin: 10px 0 0 0;
|
|
72
|
+
padding: 0;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
table.coverage td {
|
|
76
|
+
margin: 0;
|
|
77
|
+
padding: 0;
|
|
78
|
+
vertical-align: top;
|
|
79
|
+
}
|
|
80
|
+
table.coverage td.line-count {
|
|
81
|
+
text-align: right;
|
|
82
|
+
padding: 0 5px 0 20px;
|
|
83
|
+
}
|
|
84
|
+
table.coverage td.line-coverage {
|
|
85
|
+
text-align: right;
|
|
86
|
+
padding-right: 10px;
|
|
87
|
+
min-width:20px;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
table.coverage td span.cline-any {
|
|
91
|
+
display: inline-block;
|
|
92
|
+
padding: 0 5px;
|
|
93
|
+
width: 100%;
|
|
94
|
+
}
|
|
95
|
+
.missing-if-branch {
|
|
96
|
+
display: inline-block;
|
|
97
|
+
margin-right: 5px;
|
|
98
|
+
border-radius: 3px;
|
|
99
|
+
position: relative;
|
|
100
|
+
padding: 0 4px;
|
|
101
|
+
background: #333;
|
|
102
|
+
color: yellow;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.skip-if-branch {
|
|
106
|
+
display: none;
|
|
107
|
+
margin-right: 10px;
|
|
108
|
+
position: relative;
|
|
109
|
+
padding: 0 4px;
|
|
110
|
+
background: #ccc;
|
|
111
|
+
color: white;
|
|
112
|
+
}
|
|
113
|
+
.missing-if-branch .typ, .skip-if-branch .typ {
|
|
114
|
+
color: inherit !important;
|
|
115
|
+
}
|
|
116
|
+
.coverage-summary {
|
|
117
|
+
border-collapse: collapse;
|
|
118
|
+
width: 100%;
|
|
119
|
+
}
|
|
120
|
+
.coverage-summary tr { border-bottom: 1px solid #bbb; }
|
|
121
|
+
.keyline-all { border: 1px solid #ddd; }
|
|
122
|
+
.coverage-summary td, .coverage-summary th { padding: 10px; }
|
|
123
|
+
.coverage-summary tbody { border: 1px solid #bbb; }
|
|
124
|
+
.coverage-summary td { border-right: 1px solid #bbb; }
|
|
125
|
+
.coverage-summary td:last-child { border-right: none; }
|
|
126
|
+
.coverage-summary th {
|
|
127
|
+
text-align: left;
|
|
128
|
+
font-weight: normal;
|
|
129
|
+
white-space: nowrap;
|
|
130
|
+
}
|
|
131
|
+
.coverage-summary th.file { border-right: none !important; }
|
|
132
|
+
.coverage-summary th.pct { }
|
|
133
|
+
.coverage-summary th.pic,
|
|
134
|
+
.coverage-summary th.abs,
|
|
135
|
+
.coverage-summary td.pct,
|
|
136
|
+
.coverage-summary td.abs { text-align: right; }
|
|
137
|
+
.coverage-summary td.file { white-space: nowrap; }
|
|
138
|
+
.coverage-summary td.pic { min-width: 120px !important; }
|
|
139
|
+
.coverage-summary tfoot td { }
|
|
140
|
+
|
|
141
|
+
.coverage-summary .sorter {
|
|
142
|
+
height: 10px;
|
|
143
|
+
width: 7px;
|
|
144
|
+
display: inline-block;
|
|
145
|
+
margin-left: 0.5em;
|
|
146
|
+
background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent;
|
|
147
|
+
}
|
|
148
|
+
.coverage-summary .sorted .sorter {
|
|
149
|
+
background-position: 0 -20px;
|
|
150
|
+
}
|
|
151
|
+
.coverage-summary .sorted-desc .sorter {
|
|
152
|
+
background-position: 0 -10px;
|
|
153
|
+
}
|
|
154
|
+
.status-line { height: 10px; }
|
|
155
|
+
/* yellow */
|
|
156
|
+
.cbranch-no { background: yellow !important; color: #111; }
|
|
157
|
+
/* dark red */
|
|
158
|
+
.red.solid, .status-line.low, .low .cover-fill { background:#C21F39 }
|
|
159
|
+
.low .chart { border:1px solid #C21F39 }
|
|
160
|
+
.highlighted,
|
|
161
|
+
.highlighted .cstat-no, .highlighted .fstat-no, .highlighted .cbranch-no{
|
|
162
|
+
background: #C21F39 !important;
|
|
163
|
+
}
|
|
164
|
+
/* medium red */
|
|
165
|
+
.cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE }
|
|
166
|
+
/* light red */
|
|
167
|
+
.low, .cline-no { background:#FCE1E5 }
|
|
168
|
+
/* light green */
|
|
169
|
+
.high, .cline-yes { background:rgb(230,245,208) }
|
|
170
|
+
/* medium green */
|
|
171
|
+
.cstat-yes { background:rgb(161,215,106) }
|
|
172
|
+
/* dark green */
|
|
173
|
+
.status-line.high, .high .cover-fill { background:rgb(77,146,33) }
|
|
174
|
+
.high .chart { border:1px solid rgb(77,146,33) }
|
|
175
|
+
/* dark yellow (gold) */
|
|
176
|
+
.status-line.medium, .medium .cover-fill { background: #f9cd0b; }
|
|
177
|
+
.medium .chart { border:1px solid #f9cd0b; }
|
|
178
|
+
/* light yellow */
|
|
179
|
+
.medium { background: #fff4c2; }
|
|
180
|
+
|
|
181
|
+
.cstat-skip { background: #ddd; color: #111; }
|
|
182
|
+
.fstat-skip { background: #ddd; color: #111 !important; }
|
|
183
|
+
.cbranch-skip { background: #ddd !important; color: #111; }
|
|
184
|
+
|
|
185
|
+
span.cline-neutral { background: #eaeaea; }
|
|
186
|
+
|
|
187
|
+
.coverage-summary td.empty {
|
|
188
|
+
opacity: .5;
|
|
189
|
+
padding-top: 4px;
|
|
190
|
+
padding-bottom: 4px;
|
|
191
|
+
line-height: 1;
|
|
192
|
+
color: #888;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
.cover-fill, .cover-empty {
|
|
196
|
+
display:inline-block;
|
|
197
|
+
height: 12px;
|
|
198
|
+
}
|
|
199
|
+
.chart {
|
|
200
|
+
line-height: 0;
|
|
201
|
+
}
|
|
202
|
+
.cover-empty {
|
|
203
|
+
background: white;
|
|
204
|
+
}
|
|
205
|
+
.cover-full {
|
|
206
|
+
border-right: none !important;
|
|
207
|
+
}
|
|
208
|
+
pre.prettyprint {
|
|
209
|
+
border: none !important;
|
|
210
|
+
padding: 0 !important;
|
|
211
|
+
margin: 0 !important;
|
|
212
|
+
}
|
|
213
|
+
.com { color: #999 !important; }
|
|
214
|
+
.ignore-none { color: #999; font-weight: normal; }
|
|
215
|
+
|
|
216
|
+
.wrapper {
|
|
217
|
+
min-height: 100%;
|
|
218
|
+
height: auto !important;
|
|
219
|
+
height: 100%;
|
|
220
|
+
margin: 0 auto -48px;
|
|
221
|
+
}
|
|
222
|
+
.footer, .push {
|
|
223
|
+
height: 48px;
|
|
224
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
var jumpToCode = (function init() {
|
|
3
|
+
// Classes of code we would like to highlight in the file view
|
|
4
|
+
var missingCoverageClasses = ['.cbranch-no', '.cstat-no', '.fstat-no'];
|
|
5
|
+
|
|
6
|
+
// Elements to highlight in the file listing view
|
|
7
|
+
var fileListingElements = ['td.pct.low'];
|
|
8
|
+
|
|
9
|
+
// We don't want to select elements that are direct descendants of another match
|
|
10
|
+
var notSelector = ':not(' + missingCoverageClasses.join('):not(') + ') > '; // becomes `:not(a):not(b) > `
|
|
11
|
+
|
|
12
|
+
// Selecter that finds elements on the page to which we can jump
|
|
13
|
+
var selector =
|
|
14
|
+
fileListingElements.join(', ') +
|
|
15
|
+
', ' +
|
|
16
|
+
notSelector +
|
|
17
|
+
missingCoverageClasses.join(', ' + notSelector); // becomes `:not(a):not(b) > a, :not(a):not(b) > b`
|
|
18
|
+
|
|
19
|
+
// The NodeList of matching elements
|
|
20
|
+
var missingCoverageElements = document.querySelectorAll(selector);
|
|
21
|
+
|
|
22
|
+
var currentIndex;
|
|
23
|
+
|
|
24
|
+
function toggleClass(index) {
|
|
25
|
+
missingCoverageElements
|
|
26
|
+
.item(currentIndex)
|
|
27
|
+
.classList.remove('highlighted');
|
|
28
|
+
missingCoverageElements.item(index).classList.add('highlighted');
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function makeCurrent(index) {
|
|
32
|
+
toggleClass(index);
|
|
33
|
+
currentIndex = index;
|
|
34
|
+
missingCoverageElements.item(index).scrollIntoView({
|
|
35
|
+
behavior: 'smooth',
|
|
36
|
+
block: 'center',
|
|
37
|
+
inline: 'center'
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
function goToPrevious() {
|
|
42
|
+
var nextIndex = 0;
|
|
43
|
+
if (typeof currentIndex !== 'number' || currentIndex === 0) {
|
|
44
|
+
nextIndex = missingCoverageElements.length - 1;
|
|
45
|
+
} else if (missingCoverageElements.length > 1) {
|
|
46
|
+
nextIndex = currentIndex - 1;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
makeCurrent(nextIndex);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function goToNext() {
|
|
53
|
+
var nextIndex = 0;
|
|
54
|
+
|
|
55
|
+
if (
|
|
56
|
+
typeof currentIndex === 'number' &&
|
|
57
|
+
currentIndex < missingCoverageElements.length - 1
|
|
58
|
+
) {
|
|
59
|
+
nextIndex = currentIndex + 1;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
makeCurrent(nextIndex);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return function jump(event) {
|
|
66
|
+
switch (event.which) {
|
|
67
|
+
case 78: // n
|
|
68
|
+
case 74: // j
|
|
69
|
+
goToNext();
|
|
70
|
+
break;
|
|
71
|
+
case 66: // b
|
|
72
|
+
case 75: // k
|
|
73
|
+
case 80: // p
|
|
74
|
+
goToPrevious();
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
})();
|
|
79
|
+
window.addEventListener('keydown', jumpToCode);
|