summaryrefslogtreecommitdiff
path: root/src/Plugins/CloseButton.js
diff options
context:
space:
mode:
authorVictor Häggqvist <[email protected]>2016-01-14 22:54:43 +0100
committerVictor Häggqvist <[email protected]>2016-01-14 22:54:43 +0100
commit382401d527314b270e1c67b4f88cd3bfbca81d46 (patch)
tree77c4831118fc9fd2d19e044ce5ffb60b8533163f /src/Plugins/CloseButton.js
parentdd52fd3f463c254cf54309db848aa88899caeaa0 (diff)
create plugin architecture
Diffstat (limited to 'src/Plugins/CloseButton.js')
-rw-r--r--src/Plugins/CloseButton.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/Plugins/CloseButton.js b/src/Plugins/CloseButton.js
new file mode 100644
index 0000000..ca12e61
--- /dev/null
+++ b/src/Plugins/CloseButton.js
@@ -0,0 +1,40 @@
+/**
+ * @author Victor Häggqvist
+ * @since 2016-01-14
+ */
+
+
+export class CloseButton {
+
+ constructor() {
+ this.element = document.createElement('a');
+ this.element.id = 'imagelightbox-close';
+ this.element.innerHTML = 'Close';
+ }
+
+ register(lightbox) {
+ this.lightbox = lightbox;
+ lightbox.addOnStartListener(this.showButton.bind(this));
+ lightbox.addOnEndListener(this.hideButton.bind(this));
+ }
+
+ showButton() {
+ ['click', 'touchend'].forEach(name => {
+ this.element.addEventListener(name, this.exitLightbox.bind(this));
+ });
+
+ document.body.appendChild(this.element);
+
+ //$('<a href="#" id="imagelightbox-close">Close</a>').appendTo('body')
+ // .on('click touchend', function(){ $(this).remove(); instance.quitImageLightbox(); return false; });
+ }
+
+ hideButton() {
+ document.body.removeChild(this.element);
+ }
+
+ exitLightbox() {
+ this.lightbox.quitImageLightbox();
+ }
+
+}