Revision: 3738 Author: hans URL: http://bknr.net/trac/changeset/3738
Fix button reloading for Safari, which does not call onload when an image src is set to the same image as the one already loaded into the img element.
U trunk/projects/quickhoney/website/static/javascript.js
Modified: trunk/projects/quickhoney/website/static/javascript.js =================================================================== --- trunk/projects/quickhoney/website/static/javascript.js 2008-08-26 18:55:34 UTC (rev 3737) +++ trunk/projects/quickhoney/website/static/javascript.js 2008-08-27 01:13:34 UTC (rev 3738) @@ -639,7 +639,7 @@ map(function (directory) { var id = 'home_' + directory; $(id).style.visibility = 'hidden'; - $(id).src = random_button_image('home', directory, 318, 318, directory); + $(id).replace(random_button_image('home', directory, 318, 318, directory)); }, home_buttons);
if (subcategories[current_directory]) { @@ -649,7 +649,7 @@ map(function (subdirectory_name) { var id = 'button' + i++; $(id).style.visibility = 'hidden'; - $(id).src = random_button_image(current_directory, subdirectory_name, 208, 208, current_directory); + $(id).replace(random_button_image(current_directory, subdirectory_name, 208, 208, current_directory)); $(id).parentNode.href = '#' + current_directory + '/' + subdirectory_name; }, subcategories[current_directory]); } @@ -690,7 +690,14 @@ var animator = this; map(function (image) { $(image).animator = animator; - $(image).reveal = function (image) { image.animator.imageLoaded() } + $(image).reveal = function () { this.animator.imageLoaded() } + $(image).replace = function (path) { + if (this.src.match(path + '$')) { + this.reveal(); + } else { + this.src = path; + } + } }, images); }