diff options
| author | czaks <marcin@6irc.net> | 2013-07-27 01:04:36 -0400 |
|---|---|---|
| committer | czaks <marcin@6irc.net> | 2013-07-27 01:04:36 -0400 |
| commit | 64a66db6131dc2d86d9499836d64e8e35f46bf33 (patch) | |
| tree | 9e88e639b99d80d38eb72a8aa0818f3b2d4bd035 /js/inline-expanding.js | |
| parent | e3cb427feefbbb4fd6a5e76ce77ef80a240941f1 (diff) | |
| parent | 1c33285c81efe174f09e99b15be81f527c0f8ae0 (diff) | |
Merge branch 'master' of https://github.com/savetheinternet/Tinyboard
Conflicts:
js/hide-threads.js
js/inline-expanding.js
stylesheets/style.css
Diffstat (limited to 'js/inline-expanding.js')
| -rw-r--r-- | js/inline-expanding.js | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/js/inline-expanding.js b/js/inline-expanding.js index 7c9923fa..fb78c222 100644 --- a/js/inline-expanding.js +++ b/js/inline-expanding.js @@ -3,7 +3,7 @@ * https://github.com/savetheinternet/Tinyboard/blob/master/js/inline-expanding.js * * Released under the MIT license - * Copyright (c) 2012 Michael Save <savetheinternet@tinyboard.org> + * Copyright (c) 2012-2013 Michael Save <savetheinternet@tinyboard.org> * * Usage: * $config['additional_javascript'][] = 'js/jquery.min.js'; @@ -15,31 +15,38 @@ onready(function(){ var inline_expand_post = function() { var link = this.getElementsByTagName('a'); - for(var i = 0; i < link.length; i++) { - if(typeof link[i] == "object" && typeof link[i].childNodes[0] !== 'undefined' && link[i].childNodes[0].src && link[i].className != 'file') { + for (var i = 0; i < link.length; i++) { + if (typeof link[i] == "object" && link[i].childNodes && link[i].childNodes[0].src && link[i].className != 'file') { link[i].childNodes[0].style.maxWidth = '95%'; + link[i].childNodes[0].style.maxHeight = '95%'; link[i].onclick = function(e) { - if(e.which == 2) { + if (this.childNodes[0].className == 'hidden') + return false; + if (e.which == 2) return true; - } - if(!this.tag) { - this.tag = this.childNodes[0].src; + if (!this.dataset.src) { + this.dataset.expanded = 'true'; + this.dataset.src= this.childNodes[0].src; + this.dataset.width = this.childNodes[0].style.width; + this.dataset.height = this.childNodes[0].style.height; this.childNodes[0].src = this.href; this.childNodes[0].style.width = 'auto'; this.childNodes[0].style.height = 'auto'; this.childNodes[0].style.opacity = '0.4'; this.childNodes[0].style.filter = 'alpha(opacity=40)'; this.childNodes[0].onload = function() { - this.style.opacity = '1'; - this.style.filter = ''; + this.style.opacity = ''; + delete this.style.filter; } } else { - this.childNodes[0].src = this.tag; - this.childNodes[0].style.width = 'auto'; - this.childNodes[0].style.height = 'auto'; - this.tag = ''; + this.childNodes[0].src = this.dataset.src; + this.childNodes[0].style.width = this.dataset.width; + this.childNodes[0].style.height = this.dataset.height; + delete this.dataset.expanded; + delete this.dataset.src; + delete this.childNodes[0].style.opacity; + delete this.childNodes[0].style.filter; } - return false; } } } |
