Archived
1
0

update image-inline

This commit is contained in:
Jeff Becker 2016-04-30 08:51:01 -04:00
parent a02c6f040e
commit ed62c4e879
No known key found for this signature in database
GPG Key ID: AB950234D6EA286B
3 changed files with 5 additions and 3 deletions

View File

@ -18,11 +18,12 @@ function setupInlineImage(thumb, url) {
var oldurl = img.src;
thumb.onclick = function() {
if (expanded) {
thumb.
img.setAttribute("class", "thumbnail");
img.src = oldurl;
expanded = false;
} else {
img.setAttribute("class", "thumbnail expanded");
img.setAttribute("class", "expanded-thumbnail");
img.src = url;
expanded = true;
}

View File

@ -16,7 +16,7 @@ parent.backlink=true;}};parent.backlink=true;}
function inject_hover_for_element(elem){var elems=elem.getElementsByClassName("backlink");var ls=[];var l=elems.length;for(var idx=0;idx<l;idx++){var e=elems[idx];ls.push(e);}
for(var elem in ls){inject_hover(prefix,ls[elem]);}}
function init(prefix){inject_hover_for_element(document);}var banner_count=3;function nntpchan_inject_banners(elem,prefix){var n=Math.floor(Math.random()*banner_count);var banner=prefix+"static/banner_"+n+".jpg";var e=document.createElement("img");e.src=banner;e.id="nntpchan_banner";elem.appendChild(e);}function filenameIsImage(fname){return/\.(gif|jpeg|jpg|png|webp)/.test(fname);}
function setupInlineImage(thumb,url){if(thumb.inlineIsSetUp)return;thumb.inlineIsSetUp=true;var img=thumb.querySelector("img.thumbnail");var expanded=false;var oldurl=img.src;thumb.onclick=function(){if(expanded){img.setAttribute("class","thumbnail");img.src=oldurl;expanded=false;}else{img.setAttribute("class","thumbnail expanded");img.src=url;expanded=true;}
function setupInlineImage(thumb,url){if(thumb.inlineIsSetUp)return;thumb.inlineIsSetUp=true;var img=thumb.querySelector("img.thumbnail");var expanded=false;var oldurl=img.src;thumb.onclick=function(){if(expanded){thumb.img.setAttribute("class","thumbnail");img.src=oldurl;expanded=false;}else{img.setAttribute("class","expanded-thumbnail");img.src=url;expanded=true;}
return false;}}
function setupInlineImageIn(element){var thumbs=element.querySelectorAll("a.file");for(var i=0;i<thumbs.length;i++){var url=thumbs[i].href;if(filenameIsImage(url)){console.log("matched url",url);setupInlineImage(thumbs[i],url);}}}
onready(function(){setupInlineImageIn(document);if(window.MutationObserver){var observer=new MutationObserver(function(mutations){for(var i=0;i<mutations.length;i++){var additions=mutations[i].addedNodes;if(additions==null)continue;for(var j=0;j<additions.length;j++){var node=additions[j];if(node.nodeType==1){setupInlineImageIn(node);}}}});observer.observe(document.body,{childList:true,subtree:true});}});var configRoot="";if(typeof _=='undefined'){var _=function(a){return a;};}

View File

@ -366,7 +366,8 @@ input, textarea {
float: left;
}
.expanded {
.expanded-thumbnail {
display: inline;
max-width: 100%;
max-height: 100%;
margin: 10px 10px 10px;