(context)
| 4 | |
| 5 | |
| 6 | export function uiLoading(context) { |
| 7 | const assets = context.systems.assets; |
| 8 | |
| 9 | let _modalSelection = d3_select(null); |
| 10 | let _message = ''; |
| 11 | let _blocking = false; |
| 12 | |
| 13 | |
| 14 | let loading = (selection) => { |
| 15 | _modalSelection = uiModal(selection, _blocking); |
| 16 | |
| 17 | let loadertext = _modalSelection.select('.content') |
| 18 | .classed('loading-modal', true) |
| 19 | .append('div') |
| 20 | .attr('class', 'modal-section fillL'); |
| 21 | |
| 22 | loadertext |
| 23 | .append('img') |
| 24 | .attr('class', 'loader') |
| 25 | .attr('src', assets.getFileURL('img/loader-white.gif')); |
| 26 | |
| 27 | loadertext |
| 28 | .append('h3') |
| 29 | .text(_message); |
| 30 | |
| 31 | _modalSelection.select('button.close') |
| 32 | .attr('class', 'hide'); |
| 33 | |
| 34 | return loading; |
| 35 | }; |
| 36 | |
| 37 | |
| 38 | loading.message = function(val) { |
| 39 | if (!arguments.length) return _message; |
| 40 | _message = val; |
| 41 | return loading; |
| 42 | }; |
| 43 | |
| 44 | |
| 45 | loading.blocking = function(val) { |
| 46 | if (!arguments.length) return _blocking; |
| 47 | _blocking = val; |
| 48 | return loading; |
| 49 | }; |
| 50 | |
| 51 | |
| 52 | loading.close = () => { |
| 53 | _modalSelection.remove(); |
| 54 | }; |
| 55 | |
| 56 | |
| 57 | loading.isShown = () => { |
| 58 | return _modalSelection && !_modalSelection.empty() && _modalSelection.node().parentNode; |
| 59 | }; |
| 60 | |
| 61 | |
| 62 | return loading; |
| 63 | } |
no test coverage detected