# HG changeset patch # User robcast # Date 1327610838 -3600 # Node ID 5db496a7e48c451202ef476977182af6d0809331 # Parent f34891279a6ee2f8fb34df33eaa41fc9f6973e91# Parent 3b334a7d81ecd488a189f76a439435bd4c2f132e Merge with 3b334a7d81ecd488a189f76a439435bd4c2f132e diff -r f34891279a6e -r 5db496a7e48c webapp/src/main/webapp/jquery/jquery.digilib.buttons.js --- a/webapp/src/main/webapp/jquery/jquery.digilib.buttons.js Thu Jan 26 21:46:33 2012 +0100 +++ b/webapp/src/main/webapp/jquery/jquery.digilib.buttons.js Thu Jan 26 21:47:18 2012 +0100 @@ -244,13 +244,7 @@ var $calDiv = $('#calibration'); var $input = $('#calibration-input'); $calDiv.fadeIn(); - $ - // var cm = window.prompt("The length of the scale on your screen in centimeter:"); -/* if (cm) { - var dpi = calRect.width / parseFloat(cm) * 2.54; - this.params.set("ddpi", cropFloat(dpi)); - } - */ + $input.focus(); }, // shows ScaleModeSelector @@ -337,21 +331,41 @@
\
\
Please enter the length of this scale on your screen
\ - cm\ +
\ + cm\ + \ + \ +
\ +
Please enter a numeric value like this: 12.3
\
\
'; var $calDiv = $(html); - //$rulerDiv.append($cmDiv); - //$rulerDiv.append($cmInput); - //$calDiv.append($rulerDiv); $elem.append($calDiv); + var $input = $calDiv.find("input"); + var $ok = $calDiv.find("#calibrationOk"); + var $cancel = $calDiv.find("#calibrationCancel"); + data.calibrationDiv = $calDiv; + data.calibrationErrorDiv = $calDiv.find("div.calibration-error"); + data.calibrationInput = $input; var calRect = geom.rectangle($calDiv); var screenRect = fn.getFullscreenRect(data); - console.debug('calRect:', calRect); - console.debug('screenRect:', screenRect); calRect.setCenter(screenRect.getCenter()); - console.debug('calRect:', calRect); calRect.adjustDiv($calDiv); + var handler = function(event) { + var _data = data; + if (event.keyCode == 27 || event.target.id == 'calibrationCancel') { + $calDiv.fadeOut(); + return false; + } + if (event.keyCode == 13 || event.target.id == 'calibrationOk') { + changeCalibration(_data); + return false; + } + _data.calibrationInput.removeClass('error'); + }; + $ok.on("click", handler); + $cancel.on("click", handler); + $input.on("keypress", handler); }; /** creates HTML structure for the scale mode menu @@ -393,6 +407,23 @@ digilib.actions.setScaleMode(data, newMode); }; + /** event handler + */ + var changeCalibration = function (data) { + var $calDiv = data.calibrationDiv; + var $input = data.calibrationInput; + var cm = $input.val(); + var w = $calDiv.width(); + var dpi = fn.cropFloat(w / parseFloat(cm) * 2.54); + console.debug('width', w, 'cm', cm, 'input dpi:', dpi); + if(!fn.isNumber(dpi)) { + $input.addClass('error'); + return; + } + digilib.actions.calibrate(data, dpi); + $calDiv.fadeOut(); + }; + // creates HTML structure for a single button var createButton = function (data, $div, buttonName) { var $elem = data.$elem; diff -r f34891279a6e -r 5db496a7e48c webapp/src/main/webapp/jquery/jquery.digilib.css --- a/webapp/src/main/webapp/jquery/jquery.digilib.css Thu Jan 26 21:46:33 2012 +0100 +++ b/webapp/src/main/webapp/jquery/jquery.digilib.css Thu Jan 26 21:47:18 2012 +0100 @@ -114,7 +114,6 @@ background: url('blue.png'); position: absolute; border: 1px solid lightcyan; - top: 0px; width: 400px; display: none; z-index: 9999; @@ -133,7 +132,32 @@ } div.digilib div.cm { + padding: 5px; + } + +div.digilib div.calibration-error { + color: red; padding: 10px; + display: none; + } + +div.digilib button.calibration-button { + margin: 0px 10px; + border: 1px solid lightcyan; + font-family: Verdana, Arial, Helvetica, sans-serif; + font-size: 12px; + font-weight: bold; + color: lightcyan; + background-color: transparent; + } + +div.digilib input.calibration-input { + margin: 0px 10px; + } + +div.digilib input.error { + color: red; + background-color: khaki; } div.infobutton { diff -r f34891279a6e -r 5db496a7e48c webapp/src/main/webapp/jquery/jquery.digilib.js --- a/webapp/src/main/webapp/jquery/jquery.digilib.js Thu Jan 26 21:46:33 2012 +0100 +++ b/webapp/src/main/webapp/jquery/jquery.digilib.js Thu Jan 26 21:47:18 2012 +0100 @@ -1765,6 +1765,7 @@ setFitMode : setFitMode, canMove : canMove, isFullArea : isFullArea, + isNumber : isNumber, getFullscreenRect : getFullscreenRect, getBorderWidth : getBorderWidth, cropFloat : cropFloat,