diff --git a/modules/xerte/parent_templates/Nottingham/common_html5/js/xenith.js b/modules/xerte/parent_templates/Nottingham/common_html5/js/xenith.js index 02008bc4bf..dbda127842 100644 --- a/modules/xerte/parent_templates/Nottingham/common_html5/js/xenith.js +++ b/modules/xerte/parent_templates/Nottingham/common_html5/js/xenith.js @@ -1522,7 +1522,7 @@ function x_insertCSS(href) { // ___ FUNCTIONS CALLED FROM PAGE MODELS ___ // function called from model pages to scale images - scale, firstScale & setH are optional -function x_scaleImg(img, maxW, maxH, scale, firstScale, setH) { +function x_scaleImg(img, maxW, maxH, scale, firstScale, setH, enlarge) { var $img = $(img); if (scale != false) { var imgW = $img.width(), @@ -1535,19 +1535,20 @@ function x_scaleImg(img, maxW, maxH, scale, firstScale, setH) { imgH = $img.data("origSize")[1]; } - if (imgW > maxW || imgH > maxH || firstScale != true) { - if (imgW > maxW) { - var scale = maxW / imgW; - imgW = imgW * scale; - imgH = imgH * scale; + if (imgW > maxW || imgH > maxH || firstScale != true || enlarge == true) { + var scaleW = maxW / imgW; + var scaleH = maxH / imgH; + var scaleFactor; + if (enlarge == true && scaleW > 1 && scaleH > 1) + { + scaleFactor = Math.min(scaleW, scaleH); } - if (imgH > maxH) { - var scale = maxH / imgH; - imgH = imgH * scale; - imgW = imgW * scale; + else + { + scaleFactor = Math.min(scaleW, scaleH); } - imgW = Math.round(imgW); - imgH = Math.round(imgH); + imgW = Math.round(imgW * scaleFactor); + imgH = Math.round(imgH * scaleFactor); $img.css("width", imgW + "px"); // set width only to constrain proportions if (setH == true) { diff --git a/modules/xerte/parent_templates/Nottingham/models_html5/connectorHotspotImage.html b/modules/xerte/parent_templates/Nottingham/models_html5/connectorHotspotImage.html index 74ded139fa..0c653771c4 100644 --- a/modules/xerte/parent_templates/Nottingham/models_html5/connectorHotspotImage.html +++ b/modules/xerte/parent_templates/Nottingham/models_html5/connectorHotspotImage.html @@ -26,8 +26,7 @@ var $imageHolder, $img, $mainText; - - + // function called every time the page is viewed after it has initially loaded this.pageChanged = function() { $("#pageContents .selected").removeClass("selected"); @@ -39,7 +38,10 @@ // function called every time the size of the LO is changed this.sizeChanged = function() { - + var html = ''; + html += '
'; + $("#imageHolder").html(html); + connectorHotspotImage.init(); } @@ -47,7 +49,7 @@ $imageHolder = $("#imageHolder"); $img = $("#image"); $mainText = $("#mainText"); - + // ignores most of the textWidth attributes (narrow/wide/max) - except "none" if (x_currentPageXML.getAttribute("textWidth") == "none") { $mainText.remove(); @@ -102,25 +104,29 @@ this.imgLoaded = function() { - var imgMaxW = 500, imgMaxH = 476; + var holderWidth = $x_mainHolder.width(), + holderHeight = $x_mainHolder.height(); + //var imgMaxW = 500, imgMaxH = 476; + var imgMaxW = Math.round(holderWidth * (500.0/800.0)), + imgMaxH = Math.round(holderHeight * (576.0/600.0) - 100); if (x_browserInfo.mobile == true) { imgMaxW = 250; // mobile imgMaxH = 250; } else { if (x_currentPageXML.getAttribute("textWidth") == "none") { - imgMaxW = 760; - imgMaxH = 450; + imgMaxW = Math.round(holderWidth * (780.0/800.0)); + imgMaxH = Math.round(holderHeight * (576.0/600.0) - 100); } else if (x_currentPageXML.getAttribute("textWidth") == "narrow") { - imgMaxW = 600; - imgMaxH = 450; + imgMaxW = Math.round(holderWidth * (600.0/800.0)); + imgMaxH = Math.round(holderHeight * (550.0/600.0) - 100); } else if (x_currentPageXML.getAttribute("textWidth") == "max") { - imgMaxW = 400; - imgMaxH = 450; + imgMaxW = Math.round(holderWidth * (400.0/800.0)); + imgMaxH = Math.round(holderHeight * (550.0/600.0) - 100); } } - x_scaleImg($img, imgMaxW, imgMaxH, true, true); - + x_scaleImg($img, imgMaxW, imgMaxH, true, true, false, true); + $img.css({ "opacity" :1, "filter" :'alpha(opacity=100)' @@ -177,7 +183,7 @@ // open dialog popup if (this.getAttribute("hotspotMovie") != undefined && this.getAttribute("hotspotMovie") != "") { hsType = "dialog"; - hsInfo = "video"; + hsInfo = "video";Math.round(docWidth * (500.0/800.0)) } else if (this.getAttribute("hotspotSound") != undefined && this.getAttribute("hotspotSound") != "") { hsType = "dialog"; hsInfo = "sound"; diff --git a/modules/xerte/parent_templates/Nottingham/models_html5/hotspotImage.html b/modules/xerte/parent_templates/Nottingham/models_html5/hotspotImage.html index 2b79582b88..6b7a9edc50 100644 --- a/modules/xerte/parent_templates/Nottingham/models_html5/hotspotImage.html +++ b/modules/xerte/parent_templates/Nottingham/models_html5/hotspotImage.html @@ -35,15 +35,24 @@ // function called every time the size of the LO is changed this.sizeChanged = function() { - + var html = ''; + html += '
'; + html += '
'; + html += ' '; + html += ' '; + html += '
'; + $("#imageHolder").html(html); + hotspotImage.init(); } this.init = function() { $imageHolder = $("#imageHolder"); $img = $("#image"); padding = parseInt($imageHolder.css("padding-left")); - - if (x_currentPageXML.getAttribute("align") == "Left") { + + debugger; + + if (x_currentPageXML.getAttribute("align") == "Left") { $("#pageContents").prepend($("#textContents")); $imageHolder.css("right", "10px"); } @@ -55,13 +64,17 @@ "filter" :'alpha(opacity=0)' }) .one("load", function() { - var imgMaxW = 400, imgMaxH = 450; + var holderWidth = $x_mainHolder.width(), + holderHeight = $x_mainHolder.height(); + //var imgMaxW = 400, imgMaxH = 450; + var imgMaxW = Math.round(holderWidth * (400.0/800.0)), + imgMaxH = Math.round(holderHeight * (550.0/600.0) - 100); if (x_browserInfo.mobile == true) { imgMaxW = 250; // mobile imgMaxH = 250; } - x_scaleImg(this, imgMaxW, imgMaxH, true, true); + x_scaleImg(this, imgMaxW, imgMaxH, true, true, false, true); $(this).css({ // stops flicker on 1st load of image "opacity" :1,