86d972102a4fe9b77b62cf5efe1003864c25df9e
max
  Thu Mar 16 02:50:52 2023 -0700
clean kent first, no redmine, github #75

diff --git src/hg/js/jquery.imgareaselect.js src/hg/js/jquery.imgareaselect.js
index 428a185..ec1fe29 100644
--- src/hg/js/jquery.imgareaselect.js
+++ src/hg/js/jquery.imgareaselect.js
@@ -3,30 +3,32 @@
  * version 0.6.2
  *
  * Copyright (c) 2008 Michal Wojciechowski (odyniec.net)
  *
  * Dual licensed under the MIT (MIT-LICENSE.txt)
  * and GPL (GPL-LICENSE.txt) licenses.
  *
  * http://odyniec.net/projects/imgareaselect/
  *
  * modified by larrym to support hgTracks functionality; added:
  *
  * o options.clickClipHeight - allows click through to map items
  *
  * o selection.event - provides access mouse event object to callbacks
  *
+ * modified by max to support: minX, maxX - do not allow selecting before or after a given x position
+ *
  */
 
 jQuery.imgAreaSelect = { onKeyPress: null };
 
 jQuery.imgAreaSelect.init = function (img, options) {
     var $area = jQuery('<div></div>'),
         $border1 = jQuery('<div></div>'),
         $border2 = jQuery('<div></div>'),
         $outLeft = jQuery('<div></div>'),
         $outTop = jQuery('<div></div>'),
         $outRight = jQuery('<div></div>'),
         $outBottom = jQuery('<div></div>'),
         left, top, imgOfs, imgWidth, imgHeight, parent, parOfs, parScroll,
         adjusted, zIndex = 0, fixed, $p, startX, startY, moveX, moveY,
         resizeMargin = 10, resize = [ ], V = 0, H = 1,
@@ -202,35 +204,41 @@
 
     function aspectRatioYX()
     {
         y2 = Math.max(top, Math.min(top + imgHeight,
             y1 + Math.abs(x2 - x1) / aspectRatio * (y2 >= y1 ? 1 : -1)));
         x2 = Math.round(Math.max(left, Math.min(left + imgWidth,
             x1 + Math.abs(y2 - y1) * aspectRatio * (x2 >= x1 ? 1 : -1))));
         y2 = Math.round(y2);
     }
 
     function doResize(newX2, newY2)
     {
         x2 = newX2;
         y2 = newY2;
 
+        if (options.minX && x2 < options.minX)
+            x2 = options.minX;
+        if (options.maxX && x2 > options.maxX)
+            x2 = options.maxX;
+
         if (options.minWidth && Math.abs(x2 - x1) < options.minWidth) {
             x2 = x1 - options.minWidth * (x2 < x1 ? 1 : -1);
 
             if (x2 < left)
                 x1 = left + options.minWidth;
+
             else if (x2 > left + imgWidth)
                 x1 = left + imgWidth - options.minWidth;
         }
 
         if (options.minHeight && Math.abs(y2 - y1) < options.minHeight) {
             y2 = y1 - options.minHeight * (y2 < y1 ? 1 : -1);
 
             if (y2 < top)
                 y1 = top + options.minHeight;
             else if (y2 > top + imgHeight)
                 y1 = top + imgHeight - options.minHeight;
         }
 
         x2 = Math.max(left, Math.min(x2, left + imgWidth));
         y2 = Math.max(top, Math.min(y2, top + imgHeight));