# HG changeset patch # User robcast # Date 1295135819 -3600 # Node ID 53ee659e2d00c714884fd8995dd0724cd2963f68 # Parent fb94f1b74d59d133a335d72487ef0efb45a93dc1 keeping img tag for embedded mode seems to work now diff -r fb94f1b74d59 -r 53ee659e2d00 client/digitallibrary/jquery/jquery-test-full.html --- a/client/digitallibrary/jquery/jquery-test-full.html Fri Jan 14 17:07:09 2011 +0100 +++ b/client/digitallibrary/jquery/jquery-test-full.html Sun Jan 16 00:56:59 2011 +0100 @@ -34,7 +34,7 @@ + + + + + + + + + +
+
+ +
+
+
+ +
+
+ +
+
+ +
+ + + diff -r fb94f1b74d59 -r 53ee659e2d00 client/digitallibrary/jquery/jquery.digilib.js --- a/client/digitallibrary/jquery/jquery.digilib.js Fri Jan 14 17:07:09 2011 +0100 +++ b/client/digitallibrary/jquery/jquery.digilib.js Sun Jan 16 00:56:59 2011 +0100 @@ -214,7 +214,10 @@ // returns parameters taken from embedded img-element var parseImgParams = function($elem) { - var src = $elem.children('img').attr('src'); + var src = $elem.find('img').first().attr('src'); + if (!src) { + return null; + } var pos = src.indexOf('?'); var query = (pos < 0) ? '' : src.substring(pos + 1); var scalerUrl = src.substring(0, pos); @@ -265,29 +268,36 @@ // creates HTML structure for digilib in elem var setupScalerDiv = function ($elem, settings) { + var rewrite; if (settings.interactionMode === 'fullscreen') { // fullscreen var imgSize = getFullscreenImgSize($elem); settings.dw = imgSize.width; settings.dh = imgSize.height; - // create new html - $elem.empty(); // TODO: should we keep stuff for customization? + $img = $(''); var scalerUrl = getScalerString(settings); - var scalerHTML = '
'; - $elem.append(scalerHTML); - var $img = $elem.find("img.pic"); $img.attr('src', scalerUrl); - //$img.load(scalerImgLoaded); + $img.addClass('pic'); } else { - // embedded mode -- keep inner img - var $img = $elem.detach('img'); - $elem.empty(); // TODO: should we keep stuff for customization? - $img.addClass('pic'); - var $scaler = $('
'); - $scaler.append($img); - $elem.append($scaler); - //$img.load(scalerImgLoaded); + // embedded mode -- try to keep img tag + var $img = $elem.find('img'); + if ($img.length > 0) { + console.debug("img detach:",$img); + $img.detach(); + $img.addClass('picsi'); + } else { + $img = $(''); + var scalerUrl = getScalerString(settings); + $img.attr('src', scalerUrl); + $img.addClass('pic'); + } } + // create new html + $elem.empty(); // TODO: should we keep stuff for customization? + var $scaler = $('
'); + $elem.append($scaler); + $scaler.append($img); + $img.load(scalerImgLoadedFn(settings)); }; // creates HTML structure for buttons in elem @@ -312,7 +322,7 @@ $button.addClass('button-' + buttonName); // let the clicked element know about the digilib context $a.data('digilib', { 'name' : buttonName, 'settings' : settings } ); - $a.bind('click', function(){ + $a.bind('click', function() { // get the context settings var data = $(this).data('digilib'); // find the action for the clicked element @@ -328,6 +338,12 @@ return $buttonsDiv; }; + // returns function for load event of scaler img + var scalerImgLoadedFn = function(settings) { + return function() { + console.debug("img loaded! settings=", settings); + }; + }; // hook plugin into jquery $.fn.digilib = function(method) { if (methods[method]) {