anchor.diff:      });
   }
   
  +// scale width and height so that neither is larger than maxSide
  +function resizeToFit(width, height, maxSide) {
  +    "use strict";
  +
  +    var result = {
  +            width : width,
  +            height : height
  +        };
  +
  +    if (width > maxSide) {
  +        result.width = maxSide;
  +        result.height = height * (maxSide / width);
  +    }
  +
  +    if (result.height > maxSide) {
  +        result.width = result.width * (maxSide / result.height);
  +        result.height = maxSide;
  +    }
  +
  +    return result;
  +}
  +
   function positionText() {
       "use strict";
   
       var imageUrl = $('#u').val(),
  -
  -        canvas,
  -        canvasHeight,
  -        canvasWidth,
  -
  -        rect1,
  -        rect2;
  +        canvas;
   
       if (imageUrl.length > 0) {
           $('#positionTable').show();
  
positive.code:         canvas = new fabric.Canvas('positionTextCanvas');
  
          canvas.setBackgroundImage(imageUrl, function () {
              var canvasWidth,
                  canvasHeight,
                  textWidth,
                  textHeight;
  
              canvas.setWidth(canvas.backgroundImage.width);
              canvas.setHeight(canvas.backgroundImage.height);
  
              canvas.renderAll.bind(canvas);
  
              canvasWidth = canvas.getWidth();
              canvasHeight = canvas.getHeight();
              textWidth = 0.9 * canvasWidth;
              textHeight = 0.25 * canvasHeight;
  
              rect1 = new fabric.Rect({
                  top  : textHeight / 2.0,
                  left : canvasWidth / 2.0,
                  width : textWidth,
                  height : textHeight,
                  fill : 'red'
  
negative.code:                 if (leftSide < 0) {
                      target.setLeft(halfWidth);
                  }
                  if (rightSide > canvas.getWidth()) {
                      target.setLeft(canvas.getWidth() - halfWidth);
                  }
                  if (topSide < 0) {
                      target.setTop(halfHeight);
                  }
                  if (bottomSide > canvas.getHeight()) {
                      target.setTop(canvas.getHeight() - halfHeight);
                  }
              });
  
  