# HG changeset patch # User hertzhaft # Date 1299507411 -3600 # Node ID 2c401f68d577141b625e2976d44402aa65bbeb49 # Parent 4658ec2f9565d45158496e35b3fafb0a7313da45 better region info diff -r 4658ec2f9565 -r 2c401f68d577 client/digitallibrary/jquery/jquery-test-full.html --- a/client/digitallibrary/jquery/jquery-test-full.html Mon Mar 07 09:54:36 2011 +0100 +++ b/client/digitallibrary/jquery/jquery-test-full.html Mon Mar 07 15:16:51 2011 +0100 @@ -84,13 +84,13 @@
-
- MPI fuer Wissenschaftsgeschichte - Bibliotheca Hertziana - -
DEBUG
+
+ MPI fuer Wissenschaftsgeschichte + Bibliotheca Hertziana + +
diff -r 4658ec2f9565 -r 2c401f68d577 client/digitallibrary/jquery/jquery.digilib.css --- a/client/digitallibrary/jquery/jquery.digilib.css Mon Mar 07 09:54:36 2011 +0100 +++ b/client/digitallibrary/jquery/jquery.digilib.css Mon Mar 07 15:16:51 2011 +0100 @@ -92,7 +92,6 @@ display: none; position: absolute; top: 100px; - left: 250px; padding: 10px; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; @@ -108,6 +107,25 @@ font-weight: bold; } +div.infobutton { + background-color: white; + color: grey; + padding: 0px 4px; + margin: 0px 2px; + float: left; +} + +div.info { + clear: both; + display: none; + margin: 10px; +} + +div.infoheader { + width: 300px; + margin-bottom: 20px; +} + /* special definitions for fullscreen */ div.digilib.dl_fullscreen div.buttons { position: fixed; diff -r 4658ec2f9565 -r 2c401f68d577 client/digitallibrary/jquery/jquery.digilib.regions.js --- a/client/digitallibrary/jquery/jquery.digilib.regions.js Mon Mar 07 09:54:36 2011 +0100 +++ b/client/digitallibrary/jquery/jquery.digilib.regions.js Mon Mar 07 15:16:51 2011 +0100 @@ -37,7 +37,7 @@ icon : "regions.png" }, regionhtml : { - onclick : "showRegionHTML", + onclick : "showRegionInfo", tooltip : "show information about regions", icon : "regioninfo.png" } @@ -49,7 +49,7 @@ // are region numbers shown? 'showRegionNumbers' : false, // is window with region HTML shown? - 'showRegionHTML' : false, + 'showRegionInfo' : false, // is there region content in the page? 'hasRegionContent' : false, // turn any region into a clickable link to its detail view @@ -152,28 +152,19 @@ }, // show/hide region HTML code - "showRegionHTML" : function (data) { - var show = !data.settings.showRegionHTML; - data.settings.showRegionHTML = show; + "showRegionInfo" : function (data) { + var show = !data.settings.showRegionInfo; + data.settings.showRegionInfo = show; fn.highlightButtons(data, 'regionhtml', show); var $html = data.$htmlDiv; if (!show) { + // empty the div $html.fadeOut(function () { $html.contents().remove(); }); return; } - // empty the div for HTML display - $html.append($('
').text('
')); - $.each(data.regions, function(index, region) { - var area = "area:" - + region.x + "/" + region.y + "/" - + region.width + "/" + region.height; - $html.append($('
').text('')); - $html.append($('
').text('')); - }); - $html.append($('
').text('
')); - $html.fadeIn(); + regionInfo(data); }, "redraw" : function (data) { @@ -191,6 +182,77 @@ console.debug("regions", data.regions, "regionRect", regionRect); }; + // clickable header + var regionInfoHeader = function (data) { + var $infoDiv = $('
'); + var $h01 = $('
HTML
'); + var $h02 = $('
SVG
'); + var $h03 = $('
Digilib
'); + var $h04 = $('
X
'); + var bind = function($div, name) { + $div.bind('click.regioninfo', function () { + var $top = $(this).parent().parent(); + $top.find('.info').hide(); + $top.find('.' + name).show(); + }); + }; + bind($h01, 'html'); + bind($h02, 'svgattr'); + bind($h03, 'digilib'); + var $html = data.$htmlDiv; + $h04.bind('click.regioninfo', function () { + data.settings.showRegionInfo = false; + fn.highlightButtons(data, 'regionhtml', false); + $html.fadeOut(function () { + $html.contents().remove(); + }); + }); + $infoDiv.append($h01, $h02, $h03, $h04); + return $infoDiv; + }; + + // html for later insertion + var regionInfoHTML = function (data) { + var $infoDiv = $('
'); + $infoDiv.append($('
').text('
')); + $.each(data.regions, function(index, r) { + var area = [r.x, r.y, r.width, r.height].join(','); + $infoDiv.append($('
').text('')); + }); + $infoDiv.append($('
').text('
')); + return $infoDiv; + }; + + // SVG-style + var regionInfoSVG = function (data) { + var $infoDiv = $('
'); + $.each(data.regions, function(index, r) { + var area = [r.x, r.y, r.width, r.height].join(' '); + $infoDiv.append($('
').text('"' + area + '"')); + }); + return $infoDiv; + }; + + // digilib-style + var regionInfoDigilib = function (data) { + var $infoDiv = $('
'); + $.each(data.regions, function(index, r) { + var area = r.width + 'x' + r.height + '@' + r.x + ',' + r.y; + $infoDiv.append($('
').text(area)); + }); + return $infoDiv; + }; + + // show region info in a window + var regionInfo = function (data) { + var $html = data.$htmlDiv; + $html.append(regionInfoHeader(data)) + $html.append(regionInfoHTML(data)); + $html.append(regionInfoSVG(data)); + $html.append(regionInfoDigilib(data)); + $html.fadeIn(); + }; + // add a region to data.$elem var addRegionDiv = function (data, index, url) { var nr = index + 1; // we count regions from 1 @@ -366,7 +428,7 @@ // regions are defined in the URL } else { createRegionsFromURL(data); - fn.highlightButtons(data, 'regionhtml', data.settings.showRegionHTML); + fn.highlightButtons(data, 'regionhtml', data.settings.showRegionInfo); } }; @@ -376,7 +438,7 @@ console.debug("regions: handleUpdate"); var settings = data.settings; fn.highlightButtons(data, 'regions' , settings.isRegionVisible); - fn.highlightButtons(data, 'regionhtml' , settings.showRegionHTML); + fn.highlightButtons(data, 'regionhtml' , settings.showRegionInfo); renderRegions(data); };