From f4d110c896ec1d4b242b19d54a49d1c3e1663b72 Mon Sep 17 00:00:00 2001 From: "Adolfo R. Brandes" Date: Wed, 11 Dec 2024 09:45:04 -0300 Subject: [PATCH] feat: Reimplement the Zooming Image Tool This recreates the Zooming Image Tool template for the HTML block. It does it in such a way that doesn't depend on any external resources: both the loupe code and sample image are inlined. Some benefits to this version are: * We can now maintain the loupe javascript code properly * Because the javascript is included in the contents of the block itself, the course author can customize it as needed * As opposed to the previous iteration, the magnified image URL is now optional: if it's not present, the regular image will be used for magnification * There can now be two or more instances of the tool in the same unit. This also removes some CSS left over from the previous iteration. --- cms/static/sass/elements/_vendor.scss | 7 - xmodule/templates/html/zooming_image.yaml | 239 ++++++++++++++++++++++ 2 files changed, 239 insertions(+), 7 deletions(-) create mode 100644 xmodule/templates/html/zooming_image.yaml diff --git a/cms/static/sass/elements/_vendor.scss b/cms/static/sass/elements/_vendor.scss index 5418745922f9..b57fa04175c2 100644 --- a/cms/static/sass/elements/_vendor.scss +++ b/cms/static/sass/elements/_vendor.scss @@ -66,13 +66,6 @@ z-index: 100000 !important; } -//jQuery loupeAndLightbox Plugin -.zooming-image-place { - .larger { - left: 0 !important; - bottom: 100% !important; - } -} // ==================== // reset styles to remove ui-lightness jquery ui theme from the tabs component (used in the add component problem tab menu) diff --git a/xmodule/templates/html/zooming_image.yaml b/xmodule/templates/html/zooming_image.yaml new file mode 100644 index 000000000000..14e9ef2c2392 --- /dev/null +++ b/xmodule/templates/html/zooming_image.yaml @@ -0,0 +1,239 @@ +--- +metadata: + display_name: Zooming Image Tool +data: | +

Use the Zooming Image Tool to enable learners to see details of large, complex images. With the tool, the learner can move the mouse pointer over a part of the image to enlarge it and see more detail.

+

To set it up, first upload the regular image file and, optionally, a magnified image file to your course. Then refer to them with the following HTML code, replacing the values in italics accordingly:

+
+      <div class="zooming-image">
+        <a data-src="(Optional) URL to the magnified image">
+          <img src="URL to the regular image" />
+        </a>
+      </div>
+      
+

If a magnified image is not provided, the regular one will be used at its native size.

+

Feel free to modify the example below for your own use, but take care not to remove the included Javascript.

+
+ + + A color wheel. + +
+