custom.js 634 B

1234567891011121314151617181920212223242526272829
  1. function onReady() {
  2. var imgs = $(`p>img`)
  3. imgs
  4. .after(appendExpandButton)
  5. .next()
  6. .on('click', onExpandButton);
  7. imgs.parent().addClass(`img-container`);
  8. $(`#expand-img button`).on(`click`, onHideImgExpand);
  9. }
  10. function appendExpandButton(img) {
  11. return `<button class='btn btn-primary btn-lg' data-img="${this.src}">+</button>`
  12. }
  13. function onExpandButton(e) {
  14. var imgSrc = this.getAttribute(`data-img`);
  15. $(`#expand-img img`).attr(`src`, imgSrc);
  16. $(`#expand-img`).show(0);
  17. }
  18. function onHideImgExpand() {
  19. $(`#expand-img`).hide(500);
  20. }
  21. (function() {
  22. $(document).ready(onReady)
  23. })()