瀏覽代碼

Fix SVG size for Hotspot and Annotation exercises - refs BT#12966

Angel Fernando Quiroz Campos 7 年之前
父節點
當前提交
27427f18d3
共有 2 個文件被更改,包括 26 次插入14 次删除
  1. 2 2
      main/inc/lib/javascript/annotation/js/annotation.js
  2. 24 12
      main/inc/lib/javascript/hotspot/js/hotspot.js

+ 2 - 2
main/inc/lib/javascript/annotation/js/annotation.js

@@ -183,8 +183,8 @@
         this.el = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
         this.el.setAttribute('version', '1.1');
         this.el.setAttribute('viewBox', '0 0 ' + this.image.width + ' ' + this.image.height);
-        this.el.style.width = this.image.width + 'px';
-        this.el.style.height = this.image.height + 'px';
+        this.el.setAttribute('width', this.image.width);
+        this.el.setAttribute('height', this.image.height);
 
         var svgImage = document.createElementNS('http://www.w3.org/2000/svg', 'image');
         svgImage.setAttributeNS('http://www.w3.org/1999/xlink', 'href', this.image.src);

+ 24 - 12
main/inc/lib/javascript/hotspot/js/hotspot.js

@@ -504,6 +504,8 @@ window.HotspotQuestion = (function () {
         AdminHotspotsSVG.prototype.render = function () {
             this.el.setAttribute('version', '1.1');
             this.el.setAttribute('viewBox', '0 0 ' + this.image.width + ' ' + this.image.height);
+            this.el.setAttribute('width', this.image.width);
+            this.el.setAttribute('height', this.image.height);
 
             var imageSvg = document.createElementNS('http://www.w3.org/2000/svg', 'image');
             imageSvg.setAttributeNS('http://www.w3.org/1999/xlink', 'href', this.image.src);
@@ -802,6 +804,8 @@ window.HotspotQuestion = (function () {
         UserHotspotsSVG.prototype.render = function () {
             this.el.setAttribute('version', '1.1');
             this.el.setAttribute('viewBox', '0 0 ' + this.image.width + ' ' + this.image.height);
+            this.el.setAttribute('width', this.image.width);
+            this.el.setAttribute('height', this.image.height);
 
             var imageSvg = document.createElementNS('http://www.w3.org/2000/svg', 'image');
             imageSvg.setAttributeNS('http://www.w3.org/1999/xlink', 'href', this.image.src);
@@ -1018,6 +1022,8 @@ window.HotspotQuestion = (function () {
         SolutionHotspotsSVG.prototype.render = function () {
             this.el.setAttribute('version', '1.1');
             this.el.setAttribute('viewBox', '0 0 ' + this.image.width + ' ' + this.image.height);
+            this.el.setAttribute('width', this.image.width);
+            this.el.setAttribute('height', this.image.height);
 
             var imageSvg = document.createElementNS('http://www.w3.org/2000/svg', 'image');
             imageSvg.setAttributeNS('http://www.w3.org/1999/xlink', 'href', this.image.src);
@@ -1430,11 +1436,13 @@ window.DelineationQuestion = (function () {
         this.render = function () {
             var imageSvg = document.createElementNS('http://www.w3.org/2000/svg', 'image');
             imageSvg.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', image.src);
-            imageSvg.setAttributeNS(null, 'width', image.width);
-            imageSvg.setAttributeNS(null, 'height', image.height);
+            imageSvg.setAttribute('width', image.width);
+            imageSvg.setAttribute('height', image.height);
 
-            this.el.setAttributeNS(null, 'version', '1.1');
-            this.el.setAttributeNS(null, 'viewBox', '0 0 ' + image.width + ' ' + image.height);
+            this.el.setAttribute('version', '1.1');
+            this.el.setAttribute('viewBox', '0 0 ' + image.width + ' ' + image.height);
+            this.el.setAttribute('width', image.width);
+            this.el.setAttribute('height', image.height);
             this.el.appendChild(imageSvg);
 
             var isDrawing = false;
@@ -1550,11 +1558,13 @@ window.DelineationQuestion = (function () {
         this.render = function () {
             var imageSvg = document.createElementNS('http://www.w3.org/2000/svg', 'image');
             imageSvg.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', image.src);
-            imageSvg.setAttributeNS(null, 'width', image.width);
-            imageSvg.setAttributeNS(null, 'height', image.height);
+            imageSvg.setAttribute('width', image.width);
+            imageSvg.setAttribute('height', image.height);
 
-            this.el.setAttributeNS(null, 'version', '1.1');
-            this.el.setAttributeNS(null, 'viewBox', '0 0 ' + image.width + ' ' + image.height);
+            this.el.setAttribute('version', '1.1');
+            this.el.setAttribute('viewBox', '0 0 ' + image.width + ' ' + image.height);
+            this.el.setAttribute('width', image.width);
+            this.el.setAttribute('height', image.height);
             this.el.appendChild(imageSvg);
 
             this.renderDelineation();
@@ -1675,11 +1685,13 @@ window.DelineationQuestion = (function () {
         this.render = function () {
             var imageSvg = document.createElementNS('http://www.w3.org/2000/svg', 'image');
             imageSvg.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', image.src);
-            imageSvg.setAttributeNS(null, 'width', image.width);
-            imageSvg.setAttributeNS(null, 'height', image.height);
+            imageSvg.setAttribute('width', image.width);
+            imageSvg.setAttribute('height', image.height);
 
-            this.el.setAttributeNS(null, 'version', '1.1');
-            this.el.setAttributeNS(null, 'viewBox', '0 0 ' + image.width + ' ' + image.height);
+            this.el.setAttribute('version', '1.1');
+            this.el.setAttribute('viewBox', '0 0 ' + image.width + ' ' + image.height);
+            this.el.setAttribute('width', image.width);
+            this.el.setAttribute('height', image.height);
             this.el.appendChild(imageSvg);
         };