@@ -2,6 +2,7 @@ var events = new Vue({}); | |||||
var eventsName = { | var eventsName = { | ||||
pinReflowDone: "single-pin-reflow-done", | pinReflowDone: "single-pin-reflow-done", | ||||
allPinReflowDone: "all-pin-reflow-done", | allPinReflowDone: "all-pin-reflow-done", | ||||
viewPin: "view-single-pin" | |||||
}; | }; | ||||
function fetchPins(offset) { | 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', { | Vue.component('pin', { | ||||
data: function () { | data: function () { | ||||
return { | return { | ||||
@@ -126,6 +151,10 @@ Vue.component('pin', { | |||||
events.$emit(eventsName.pinReflowDone); | events.$emit(eventsName.pinReflowDone); | ||||
}, | }, | ||||
methods: { | methods: { | ||||
showImageDetail: function(event) { | |||||
events.$emit(eventsName.viewPin, this.pin); | |||||
if (event) event.preventDefault(); | |||||
}, | |||||
reflow: function() { | reflow: function() { | ||||
this.heightOffset = this.heightTable.getHeightOffset(this.index, this.args.rowSize); | this.heightOffset = this.heightTable.getHeightOffset(this.index, this.args.rowSize); | ||||
this.imageStyle = this.getImageStyle(); | this.imageStyle = this.getImageStyle(); | ||||
@@ -365,9 +394,19 @@ var app = new Vue({ | |||||
return { | return { | ||||
loading: true, | loading: true, | ||||
noMore: false, | noMore: false, | ||||
currentPin: null, | |||||
} | } | ||||
}, | }, | ||||
created: function() { | |||||
events.$on( | |||||
eventsName.viewPin, | |||||
this.onViewPin, | |||||
); | |||||
}, | |||||
methods: { | methods: { | ||||
onViewPin: function(pin) { | |||||
this.currentPin = pin; | |||||
}, | |||||
onLoaded: function(){ | onLoaded: function(){ | ||||
this.loading = false; | this.loading = false; | ||||
}, | }, | ||||
@@ -97,6 +97,7 @@ | |||||
<!-- Templates --> | <!-- Templates --> | ||||
{% include 'includes/vue-pin.html' %} | {% include 'includes/vue-pin.html' %} | ||||
{% include 'includes/lightbox-vue.html' %} | |||||
{% block extra_templates %}{% endblock %} | {% block extra_templates %}{% endblock %} | ||||
<!-- End Templates --> | <!-- End Templates --> | ||||
@@ -11,4 +11,6 @@ | |||||
<template v-if="noMore"> | <template v-if="noMore"> | ||||
<div id="the-end">— End —</div> | <div id="the-end">— End —</div> | ||||
</template> | </template> | ||||
<light-box v-if="currentPin" :pin="currentPin"> | |||||
</light-box> | |||||
{% endblock %} | {% endblock %} |
@@ -0,0 +1,37 @@ | |||||
{% verbatim %} | |||||
<script id="lightbox-template" type="text/x-template"> | |||||
<div class="lightbox-background"> | |||||
<div class="lightbox-wrapper"> | |||||
<div class="lightbox-image-wrapper"> | |||||
<img class="lightbox-image" src="{{ pin.image.image }}" /> | |||||
</div> | |||||
<div class="lightbox-data clearfix"> | |||||
<div class="description" v-if="pin.description"> | |||||
{{ pin.description }} | |||||
</div> | |||||
<div class="avatar pull-left"> | |||||
<img src="//gravatar.com/avatar/{{submitter.gravatar}}.jpg"> | |||||
</div> | |||||
<div class="text pull-left"> | |||||
<span class="dim">pinned by</span> {{ pin.submitter.username }} | |||||
<template v-if="pin.tags"> | |||||
<br /><span class="dim">in</span> | |||||
<template v-for="tag in pin.tags"> | |||||
<span class="tag"> | |||||
<a href="/pins/tags/{{ tag }}/" class="btn btn-xs btn-primary"> | |||||
{{ tag }} | |||||
</a> | |||||
</span> | |||||
</template> | |||||
</template> | |||||
</div> | |||||
<div class="text extra pull-right"> | |||||
<a href="{{ pin.referer }}" class="btn btn-sm btn-default btn-warning" target="_blank">Referer</a> | |||||
<a href="{{ pin.url }}" class="btn btn-sm btn-default btn-primary" target="_blank">Original URL</a> | |||||
<a href="/{{ pin.id }}/" class="btn btn-sm btn-default btn-success" target="_blank">Pin URL</a> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
</div> | |||||
</script> | |||||
{% endverbatim %} |
@@ -1,8 +1,8 @@ | |||||
{% verbatim %} | {% verbatim %} | ||||
<script id="lightbox-template" type="text/x-handlebars-template"> | <script id="lightbox-template" type="text/x-handlebars-template"> | ||||
<div class="lightbox-background"> | |||||
<div class="lightbox-background" :style="backgroundStyle"> | |||||
<div class="lightbox-wrapper"> | <div class="lightbox-wrapper"> | ||||
<div class="lightbox-image-wrapper"> | |||||
<div class="lightbox-image-wrapper" :style="lightBoxImageWrapperStyle"> | |||||
<img class="lightbox-image" src="{{image.image}}" /> | <img class="lightbox-image" src="{{image.image}}" /> | ||||
</div> | </div> | ||||
<div class="lightbox-data clearfix"> | <div class="lightbox-data clearfix"> | ||||
@@ -33,7 +33,10 @@ | |||||
</div> | </div> | ||||
</transition> | </transition> | ||||
<a :href="pin.image.image" class="lightbox" :style="imageStyle"> | |||||
<a :href="pin.image.image" | |||||
@click="showImageDetail($event)" | |||||
class="lightbox" | |||||
:style="imageStyle"> | |||||
<div class="image-wrapper"> | <div class="image-wrapper"> | ||||
<img :src="pin.image.thumbnail.image" v-on:load="onImageLoad"> | <img :src="pin.image.thumbnail.image" v-on:load="onImageLoad"> | ||||
</div> | </div> | ||||