From 379d2903a8c85d875e84e9273aa9ab0925380b0f Mon Sep 17 00:00:00 2001 From: "Adolfo R. Brandes" Date: Mon, 12 Dec 2022 10:40:21 -0300 Subject: [PATCH 1/2] feat: remove the broken Zooming Image Tool The Zooming Image Tool does not load properly, currently, and even if it did, relying on an external Javascript to function across releases is not something we can support. Thus, we remove it from the list of HTML block templates until such time as a more robust solution is found. --- .../contentstore/views/tests/test_block.py | 4 +- xmodule/templates/html/zooming_image.yaml | 57 ------------------- xmodule/templates/test/zooming_image.yaml | 25 -------- xmodule/tests/test_resource_templates.py | 2 - 4 files changed, 2 insertions(+), 86 deletions(-) delete mode 100644 xmodule/templates/html/zooming_image.yaml delete mode 100644 xmodule/templates/test/zooming_image.yaml diff --git a/cms/djangoapps/contentstore/views/tests/test_block.py b/cms/djangoapps/contentstore/views/tests/test_block.py index f3e20b45b2ea..a6c0e89c775f 100644 --- a/cms/djangoapps/contentstore/views/tests/test_block.py +++ b/cms/djangoapps/contentstore/views/tests/test_block.py @@ -312,12 +312,12 @@ def test_split_test(self): resp = self.create_xblock( parent_usage_key=split_test_usage_key, category="html", - boilerplate="zooming_image.yaml", + boilerplate="latex_html.yaml", ) self.assertEqual(resp.status_code, 200) html, __ = self._get_container_preview(split_test_usage_key) self.assertIn("Announcement", html) - self.assertIn("Zooming", html) + self.assertIn("LaTeX", html) def test_split_test_edited(self): """ diff --git a/xmodule/templates/html/zooming_image.yaml b/xmodule/templates/html/zooming_image.yaml deleted file mode 100644 index b91717550b27..000000000000 --- a/xmodule/templates/html/zooming_image.yaml +++ /dev/null @@ -1,57 +0,0 @@ ---- -metadata: - display_name: Zooming Image Tool -data: | -

Zooming Image Tool

-

Use the Zooming Image Tool to enable learners to see details of large, complex images.

-

With the Zooming Image Tool, the learner can move the mouse pointer over a part of the image to enlarge it and see more detail.

-

To use the Zooming Image Tool, you must first add the jquery.loupeAndLightbox.js JavaScript file to your course.

-

You must also add both the regular and magnified image files to your course.

-

The following HTML code shows the format required to use the Zooming Image tool. For the example in this template, you must replace the values in italics.

-
-        <div class="zooming-image-place" style="position: relative;">
-          <a class="loupe" href="path to the magnified version of the image">
-            <img alt="Text for screen readers"
-              src="path to the image you want to display in the unit" />
-          </a>
-          <div class="script_placeholder"
-            data-src="path to the jquery.loupeAndLightbox.js JavaScript file in your course"/>
-        </div>
-        <script type="text/javascript">// >![CDATA[
-        JavascriptLoader.executeModuleScripts($('.zooming-image-place').eq(0), function() {
-          $('.loupe').loupeAndLightbox({
-            width: 350,
-            height: 350,
-            lightbox: false
-          });
-        });
-        // ]]></script>
-        <div id="ap_listener_added"></div>
-        
- -

You can modify the example below for your own use.

-
    -
  1. Replace the value of the link's href attribute with the path to the magnified image. Do not change the value of the class attribute.
  2. -
  3. Replace the value of the image's src attribute with the path to the image that will appear in the unit.
  4. -
  5. Replace the value of the image's alt attribute with text that both describes the image and the action or destination of clicking on the image. You must include alt text to provide an accessible label.
  6. -
  7. Replace the value of the div element's data-src attribute with the path to the jquery.loupeAndLightbox.js JavaScript file in your course.
  8. -
-

The example below shows a subset of the biochemical reactions that cells carry out.

-

You can view the chemical structures of the molecules by clicking on them. The magnified view also lists the enzymes involved in each step.

-

Press spacebar to open the magnifier.

-
- - magnify - -
-
- -
diff --git a/xmodule/templates/test/zooming_image.yaml b/xmodule/templates/test/zooming_image.yaml deleted file mode 100644 index 3ac9d63bcbbc..000000000000 --- a/xmodule/templates/test/zooming_image.yaml +++ /dev/null @@ -1,25 +0,0 @@ ---- -metadata: - display_name: Zooming Image -data: | -

ZOOMING DIAGRAMS

-

Some edX classes use extremely large, extremely detailed graphics. To make it easier to understand we can offer two versions of those graphics, with the zoomed section showing when you click on the main view.

-

The example below is from 7.00x: Introduction to Biology and shows a subset of the biochemical reactions that cells carry out.

-

You can view the chemical structures of the molecules by clicking on them. The magnified view also lists the enzymes involved in each step.

-

Press spacebar to open the magifier.

-
- - magnify - -
-
- -
diff --git a/xmodule/tests/test_resource_templates.py b/xmodule/tests/test_resource_templates.py index 742a7e9da199..470be9551489 100644 --- a/xmodule/tests/test_resource_templates.py +++ b/xmodule/tests/test_resource_templates.py @@ -18,7 +18,6 @@ class ResourceTemplatesTests(unittest.TestCase): def test_templates(self): expected = { 'latex_html.yaml', - 'zooming_image.yaml', 'announcement.yaml', 'anon_user_id.yaml'} got = {t['template_id'] for t in TestClass.templates()} @@ -38,7 +37,6 @@ def test_get_custom_template(self): def test_custom_templates(self): expected = { 'latex_html.yaml', - 'zooming_image.yaml', 'announcement.yaml', 'anon_user_id.yaml'} got = {t['template_id'] for t in TestClassResourceTemplate.templates()} From 6623b6c282d5060ecbd594072b37a1eb04771acb Mon Sep 17 00:00:00 2001 From: "Adolfo R. Brandes" Date: Wed, 11 Dec 2024 09:45:04 -0300 Subject: [PATCH 2/2] 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.

+ +