Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Reimplement the Zooming Image Tool #36012

Merged
merged 1 commit into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions cms/static/sass/elements/_vendor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
239 changes: 239 additions & 0 deletions xmodule/templates/html/zooming_image.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,239 @@
---
metadata:
display_name: Zooming Image Tool
data: |
<p>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.</p>
<p>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 <i>italics</i> accordingly:</p>
<pre>
&lt;div class="zooming-image"&gt;
&lt;a <strong>data-src</strong>="<i style="color: blue">(Optional) URL to the magnified image</i>"&gt;
&lt;img <strong>src</strong>="<i style="color: blue">URL to the regular image</i>" /&gt;
&lt;/a&gt;
&lt;/div&gt;
</pre>
<p>If a magnified image is not provided, the regular one will be used at its native size.</p>
<p>Feel free to modify the example below for your own use, but take care not to remove the included Javascript.</p>
<div class="zooming-image">
<a data-src="">
<!-- The following sample image is in the public domain. Source: https://commons.wikimedia.org/wiki/File:12-Color-SVG.svg -->
<img alt="A color wheel." src="data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0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iIGZpbHRlcj0idXJsKCNzMCkiIHhsaW5rOmhyZWY9IiNzY2hpcm0iIC8+CiA8L2c+Cjwvc3ZnPg==" />
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to reviewer:

I tried using a placeholder image that already exists in the codebase, but there are issues when linking to local assets outside a course via bare /static/ URLs (see openedx/frontend-app-authoring#1265 (comment)).

This is the least egregious alternative to linking to some random image on the internet that I found: a base64 encode of an SVG with a small footprint (~5kb) that is still complex enough to illustrate the purpose of the tool.

</a>
</div>
<script type="text/javascript">//<![CDATA[
/*
jQuery loupeAndLightbox Plugin
* Version 1.1
* 12-11-2024
* Authors: M.Biscan, Adolfo R. Brandes
* requires jQuery 1.4.2
Copyright (c) 2010 M.Biscan

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
(function($) {
if ('loupe' in $.fn)
return;

$.fn.loupe = function(options) {
mariajgrimaldi marked this conversation as resolved.
Show resolved Hide resolved
var settings = $.extend({}, $.fn.loupe.defaults, options);

return this.each(function() {
var $this = $(this);

if ($this.hasClass('loupe')) {
return;
} else {
$this.addClass('loupe').css({
position: 'relative'
});
}

var $targetAnchor = $this.find('> a');
var $targetImage = $targetAnchor.find('> img');
var $magnifiedImage = $('<img />');
var $loupe = $('<div class="larger" style="overflow: hidden;">');
var $errorMessage = $('<div class="lal_errorMessage">');
var $loader = $('<div class="lal_loader">Loading...</div>');

$targetAnchor.css({
cursor: 'default'
});

$targetImage.css({
cursor: 'pointer'
});

$magnifiedImage.css({
position: 'absolute',
maxWidth: 'none'
});

$loupe.css({
cursor: 'none',
display: 'none',
border: settings.border,
height: settings.height,
overflow: 'hidden',
position: 'absolute',
bottom: 0,
left: 0,
width: settings.width,
zIndex: settings.zIndex,
borderRadius: '50%',
background: '#FFF',
});

$errorMessage
.text(settings.errorMessage)
.css({
height:settings.height,
width:settings.width
});

$loader.css({
height:settings.height,
width:settings.width
});

$targetAnchor.click(function(event) {
event.preventDefault();
});

$targetImage.click(function(event) {
if(!$loupe.hasClass('visible')) {
var left = event.pageX;
var top = event.pageY;

if(!$magnifiedImage.hasClass('appended')) {
getMagnifiedImage();
}

setTimeout(function() {
appendLoupe();
magnify(left, top);
}, 100);
}
});

$targetImage.mousemove(function(event) {
var left = event.pageX;
var top = event.pageY;
var offsetTop = $targetImage.offset().top-($loupe.width()/2);
var offsetLeft = $targetImage.offset().left-($loupe.height()/2);
var offsetBottom = $targetImage.offset().top+$targetImage.height()+($loupe.height()/2);
var offsetRight = $targetImage.offset().left+$targetImage.width()+($loupe.width()/2);

if(left < offsetLeft || left > offsetRight || top < offsetTop || top > offsetBottom) {
$targetImage.css({cursor:'default'});
} else {
$targetImage.css({cursor:'crosshair'});
magnify(left, top);
}
}).click(function() {
detachLoupe();
}).mouseleave(function() {
pulseLoupe();
});

// Detach when clicking outside of the loupe
$(document).click(function(event) {
if($loupe.hasClass('visible')) {
detachLoupe();
}
});

// Resize with window
$(window).resize(function() {
if($loupe.is(':visible')) {
$magnifiedImage.css({
left: -($magnifiedImage.width() / 2) + ($loupe.width() / 2),
top: -($magnifiedImage.height() / 2) + ($loupe.height() / 2)
});
}
});

function magnify(left, top) {
var heightDiff = $magnifiedImage.height() / $targetImage.height();
var widthDiff = $magnifiedImage.width() / $targetImage.width();
var magnifierTop = (-(top - $targetImage.offset().top) * heightDiff) + (settings.height / 2);
var magnifierLeft = (-(left - $targetImage.offset().left) * widthDiff) + (settings.width / 2);

$magnifiedImage.css({
top: magnifierTop,
left: magnifierLeft
});
};

function appendLoupe() {
$loupe
.appendTo($this)
.append($magnifiedImage)
.fadeIn(settings.fadeSpeed, function() {
$(this).addClass('visible');
});
};

function getMagnifiedImage() {
var src = $targetAnchor.data('src') ? $targetAnchor.data('src') : $targetImage.attr('src');
$loader.appendTo($loupe);

$magnifiedImage
.load(function() {
$(this).addClass('appended');
$loader.detach();
})
.error(function () {
$(this).hide();
$loupe
.append($errorMessage)
.addClass('lal_loadError');
$loader.detach();
})
.attr('src', src);
};

function detachLoupe() {
$loupe.fadeOut(settings.fadeSpeed, function() {
$(this)
.removeClass('visible')
.detach();
});
};

function pulseLoupe() {
$loupe.fadeTo(150, 0.25, function() {
$(this).fadeTo(150, 1.0);
});
};
});
};

$.fn.loupe.defaults = {
zIndex: 1000,
width: 350,
height: 350,
border: '2px solid #ccc',
fadeSpeed: 250,
errorMessage: 'Image load error'
};
})(jQuery);

$('.zooming-image').loupe();
//]]></script>
Loading