diff options
author | Victor Häggqvist <[email protected]> | 2016-01-14 22:54:43 +0100 |
---|---|---|
committer | Victor Häggqvist <[email protected]> | 2016-01-14 22:54:43 +0100 |
commit | 382401d527314b270e1c67b4f88cd3bfbca81d46 (patch) | |
tree | 77c4831118fc9fd2d19e044ce5ffb60b8533163f /src/Plugins/ActivityIndicator.js | |
parent | dd52fd3f463c254cf54309db848aa88899caeaa0 (diff) |
create plugin architecture
Diffstat (limited to '')
-rw-r--r-- | src/Plugins/ActivityIndicator.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/Plugins/ActivityIndicator.js b/src/Plugins/ActivityIndicator.js new file mode 100644 index 0000000..8a1e83b --- /dev/null +++ b/src/Plugins/ActivityIndicator.js @@ -0,0 +1,36 @@ +/** + * + * @author Victor Häggqvist + * @since 2016-01-14 + */ + +export class ActivityIndicator { + + constructor() { + this.element = document.createElement('div'); + this.element.id = 'imagelightbox-loading'; + this.element.appendChild(document.createElement('div')) + } + + /** + * + * @param {LightBox} lightbox + */ + register(lightbox) { + lightbox.addOnLoadStartListener(this.activityIndicatorOn.bind(this)); + lightbox.addOnLoadEndListener(this.activityIndicatorOff.bind(this)); + lightbox.addOnEndListener(this.activityIndicatorOff.bind(this)); + } + + activityIndicatorOn() { + document.body.appendChild(this.element); + //$('<div id="imagelightbox-loading"><div></div></div>' ).appendTo('body'); + } + + activityIndicatorOff() { + try { + document.body.removeChild(this.element); + } catch (e) {} + } + +} |