-
-
Save kaineer/3e49c32fd79b6339787130c56f6caec4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var template = document.querySelector('template'); | |
var templateContainer = 'content' in template ? template.content : template; | |
var newGallery = require('./gallery'); | |
var IMAGE_LOAD_TIMEOUT = 10000; | |
var Picture = module.exports = function(picture, i) { | |
this.data = picture; | |
this.index = i; | |
this.createPictureElement(); | |
}; | |
Picture.prototype.createPictureElement = function() { | |
this.element = templateContainer.querySelector('.picture').cloneNode(true); | |
this.comments = this.element.querySelector('.picture-comments'); | |
this.comments.textContent = this.data.comments; | |
// ... | |
this.image = new Image(182, 182); | |
// ... | |
this.image.onclick = this.onImageClick.bind(this); | |
}; | |
Picture.prototype.onImageClick = function(event) { | |
event.preventDefault(); | |
newGallery.show(this.index); | |
}; | |
Picture.prototype.remove = function() { | |
this.image.onclick = null; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment