# HG changeset patch # User Dan # Date 1203800535 18000 # Node ID d9f37d2ea2cf0b6f21a7543066972b1164c744c8 # Parent 7f3bd3030ae91bd5ca0d350b80479cf3ad0e1f80 Fixed race condition on canvas init (caused boxes to appear off by ~320px); fixed JSON response of null when row[img_tags] is NULL diff -r 7f3bd3030ae9 -r d9f37d2ea2cf plugins/gallery/fetcher.php --- a/plugins/gallery/fetcher.php Sun Feb 17 15:21:47 2008 -0500 +++ b/plugins/gallery/fetcher.php Sat Feb 23 16:02:15 2008 -0500 @@ -30,6 +30,9 @@ { global $db, $session, $paths, $template, $plugins; // Common objects + // artificial race condition for debug + // sleep(5); + $type = $paths->getParam(0); if ( !in_array($type, array('thumb', 'preview', 'full')) ) { diff -r 7f3bd3030ae9 -r d9f37d2ea2cf plugins/gallery/tagging.js --- a/plugins/gallery/tagging.js Sun Feb 17 15:21:47 2008 -0500 +++ b/plugins/gallery/tagging.js Sat Feb 23 16:02:15 2008 -0500 @@ -361,8 +361,17 @@ } } -var snapr_tags_onload = function() +// Don't fire the tag init until JS init *and* image are finished. +// Thanks to pmccullough for pointing out this race condition. +var snapr_lock_onload_js = true; +var snapr_lock_onload_img = true; + +var snapr_tags_onload_real = function() { + // make sure we aren't waiting... + if ( snapr_lock_onload_img || snapr_lock_onload_js ) + return false; + // add the new box var parent_obj = document.getElementById('snapr_preview_img').parentNode; var id = parent_obj.getAttribute('snapr:imgid'); @@ -371,5 +380,11 @@ ajaxPost(makeUrlNS('Gallery', id), 'ajax=true&act=get_tags', snapr_process_ajax_tag_packet); } +var snapr_tags_onload = function() +{ + snapr_lock_onload_js = false; + snapr_tags_onload_real(); +} + addOnloadHook(snapr_tags_onload); diff -r 7f3bd3030ae9 -r d9f37d2ea2cf plugins/gallery/viewimage.php --- a/plugins/gallery/viewimage.php Sun Feb 17 15:21:47 2008 -0500 +++ b/plugins/gallery/viewimage.php Sat Feb 23 16:02:15 2008 -0500 @@ -281,6 +281,10 @@ break; case 'get_tags': + if ( empty($row['img_tags']) ) + { + $row['img_tags'] = '[]'; + } $response = snapr_json_decode($row['img_tags']); foreach ( $response as $key => $_ ) { @@ -338,8 +342,9 @@ $img_url = makeUrlNS('Special', 'GalleryFetcher/preview/' . $img_id); $img_href = makeUrlNS('Special', 'GalleryFetcher/full/' . $img_id); + // The actual image $iehack = ( strstr(@$_SERVER['HTTP_USER_AGENT'], 'MSIE') ) ? ' style="width: 1px;"' : ''; - echo '
'; + echo ''; echo ''; |