diff --git a/pinry/static/js/vue/main.js b/pinry/static/js/vue/main.js index 0ccd52d..e622be5 100644 --- a/pinry/static/js/vue/main.js +++ b/pinry/static/js/vue/main.js @@ -2,6 +2,7 @@ var events = new Vue({}); var eventsName = { pinReflowDone: "single-pin-reflow-done", allPinReflowDone: "all-pin-reflow-done", + viewPin: "view-single-pin" }; function fetchPins(offset) { @@ -98,6 +99,30 @@ function HeightTable(blockMargin) { } +Vue.component( + 'light-box', + { + data: function () { + return { + backgroundStyle: null, + lightBoxImageWrapperStyle: null, + } + }, + props: ['pin'], + template: "#lightbox-template", + created: function () { + var documentHeight = document.documentElement.getBoundingClientRect().height; + this.backgroundStyle = { + height: documentHeight + "px", + }; + this.lightBoxImageWrapperStyle = { + height: this.pin.image.standard.height + 'px', + } + } + } +); + + Vue.component('pin', { data: function () { return { @@ -126,6 +151,10 @@ Vue.component('pin', { events.$emit(eventsName.pinReflowDone); }, methods: { + showImageDetail: function(event) { + events.$emit(eventsName.viewPin, this.pin); + if (event) event.preventDefault(); + }, reflow: function() { this.heightOffset = this.heightTable.getHeightOffset(this.index, this.args.rowSize); this.imageStyle = this.getImageStyle(); @@ -365,9 +394,19 @@ var app = new Vue({ return { loading: true, noMore: false, + currentPin: null, } }, + created: function() { + events.$on( + eventsName.viewPin, + this.onViewPin, + ); + }, methods: { + onViewPin: function(pin) { + this.currentPin = pin; + }, onLoaded: function(){ this.loading = false; }, diff --git a/pinry/templates/base.html b/pinry/templates/base.html index 76136e0..64ad1a3 100644 --- a/pinry/templates/base.html +++ b/pinry/templates/base.html @@ -97,6 +97,7 @@ {% include 'includes/vue-pin.html' %} + {% include 'includes/lightbox-vue.html' %} {% block extra_templates %}{% endblock %} diff --git a/pinry/templates/core/pins.html b/pinry/templates/core/pins.html index 262721e..d3aa77a 100644 --- a/pinry/templates/core/pins.html +++ b/pinry/templates/core/pins.html @@ -11,4 +11,6 @@ + + {% endblock %} diff --git a/pinry/templates/includes/lightbox-vue.html b/pinry/templates/includes/lightbox-vue.html new file mode 100644 index 0000000..db97856 --- /dev/null +++ b/pinry/templates/includes/lightbox-vue.html @@ -0,0 +1,37 @@ +{% verbatim %} + +{% endverbatim %} diff --git a/pinry/templates/includes/lightbox.html b/pinry/templates/includes/lightbox.html index ad83737..f4323dc 100644 --- a/pinry/templates/includes/lightbox.html +++ b/pinry/templates/includes/lightbox.html @@ -1,8 +1,8 @@ {% verbatim %}