Mercurial > hg > digilib-old
changeset 649:fd526464ae87 jquery
beter event handling for setMark...
author | robcast |
---|---|
date | Thu, 20 Jan 2011 14:31:45 +0100 |
parents | 64cc32ec25de |
children | 0c5930916d53 |
files | client/digitallibrary/jquery/jquery.digilib.js |
diffstat | 1 files changed, 15 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/client/digitallibrary/jquery/jquery.digilib.js Thu Jan 20 13:02:22 2011 +0100 +++ b/client/digitallibrary/jquery/jquery.digilib.js Thu Jan 20 14:31:45 2011 +0100 @@ -524,6 +524,7 @@ $elem.append($scaler); $scaler.append($img); $img.addClass('pic'); + data.$scaler = $scaler; data.$img = $img; $img.load(scalerImgLoadedHandler(data)); }; @@ -551,20 +552,22 @@ $button.attr('title', actionSettings.tooltip); $button.addClass('button-' + actionName); // create handler for the buttons - $a.bind('click', (function () { + $a.bind('click.digilib', (function () { // we create a new closure to capture the value of method var method = actionSettings.onclick; if ($.isArray(method)) { // the handler function calls digilib with method and parameters - return function () { - console.debug('click method=', method); + return function (evt) { + console.debug('click method=', method, ' evt=', evt); $elem.digilib.apply($elem, method); + return false; }; } else { // the handler function calls digilib with method - return function () { - console.debug('click method=', method); + return function (evt) { + console.debug('click method=', method, ' evt=', evt); $elem.digilib(method); + return false; }; } })()); @@ -616,9 +619,10 @@ $link.attr('href', settings.homeUrl); $content.text('Version: ' + settings.version); // click hides - $aboutDiv.bind('click', function () { + $aboutDiv.bind('click.digilib', function () { settings.isAboutDivVisible = showDiv(settings.isAboutDivVisible, $aboutDiv, 0); - }); + return false; + }); data.$aboutDiv = $aboutDiv; }; @@ -672,6 +676,7 @@ var renderMarks = function (data) { var $elem = data.$elem; var marks = data.marks; + // TODO: clear marks first(?) for (var i = 0; i < marks.length; i++) { var mark = marks[i]; if (data.zoomArea.containsPosition(mark)) { @@ -702,18 +707,17 @@ // add a mark where clicked var setMark = function (data) { - var $div = data.$elem; - var $img = data.$img; + var $scaler = data.$scaler; console.debug("setmark"); // start event capturing - $img.one('click.digilib', function (evt) { + $scaler.one('click.digilib', function (evt) { // event handler adding a new mark console.debug("setmark.click evt=",evt); var mpos = geom.position(evt.pageX, evt.pageY); var pos = data.imgTrafo.invtransform(mpos); data.marks.push(pos); redisplay(data); - //return stopEvent(evt); + return false; // do we even get here? }); };