Browse Source

Merge pull request #1 from Sorunome/patch-1

added auto-image resizing
Nathaniel van Diepen 9 years ago
parent
commit
f6f36e5c49
1 changed files with 14 additions and 1 deletions
  1. 14 1
      scripts/theme.js

+ 14 - 1
scripts/theme.js

@@ -86,4 +86,17 @@ if (is_ie7down && 'attachEvent' in window){
 			oListItems[oListItem].onmouseout = onmouseout;
 		}
 	});
-}
+}
+
+
+// automatic responsive image resizing
+$(function(){
+	if($('.poster').length > 0){
+		var $sheet = $('<style>').appendTo('head');
+		$(window).resize(function(){
+			// 90% - 40px - 15em(of .poster)
+			var w = parseFloat($(window).width())*0.9-40-(15*Number(getComputedStyle($('.poster')[0], "").fontSize.match(/(\d*(\.\d*)?)px/)[1]));
+			$sheet.html('img.bbc_img{max-width:'+w+'px;}');
+		}).resize();
+	}
+});