Sha256: 9b76310c5fc82e381e82bdee4d680be75e4dec525160485b0b362110361a51e1

Contents?: true

Size: 1014 Bytes

Versions: 7

Compression:

Stored size: 1014 Bytes

Contents

// jekyll_img generates picture tags wrapped within divs
// We move the entire div, not just the picture tag
// If an image does not correspond to a heading, delete it
function position_outline_image(picture, before_id) {
  var img = picture.parentElement;
  var before_element = document.getElementById(before_id);
  if (before_element) {
    var parent = before_element.parentElement;
    parent.insertBefore(img, before_element);
  } else {
    img.remove();
  }
}

function getElementsByIdPrefix(selectorTag, prefix) {
  var items = [];
  var myPosts = document.getElementsByTagName(selectorTag);
  for (var i = 0; i < myPosts.length; i++) {
    //omitting undefined null check for brevity
    if (myPosts[i].id.lastIndexOf(prefix, 0) === 0)
      items.push(myPosts[i]);
  }
  return items;
}

window.onload = (event) => {
  getElementsByIdPrefix("picture", "outline_").forEach(picture => {
    num = picture.id.substring("outline_".length)
    position_outline_image(picture, `posts_wrapper_${num}`)
  });
}

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
jekyll_outline-1.2.5 demo/assets/js/jekyll_outline.js
jekyll_outline-1.2.4 demo/assets/js/jekyll_outline.js
jekyll_outline-1.2.3 demo/assets/js/jekyll_outline.js
jekyll_outline-1.2.1 demo/assets/js/jekyll_outline.js
jekyll_outline-1.2.0 demo/assets/js/jekyll_outline.js
jekyll_outline-1.1.1 demo/assets/js/jekyll_outline.js
jekyll_outline-1.1.0 demo/assets/js/jekyll_outline.js