Permalink
Browse files

Fixed click in document in prototype. Added esc key close zoom box. C…

…hanged created by to Steve Smith for jQuery version.
  • Loading branch information...
1 parent d6f3ace commit d21cc783cdf83a080e00b4a5738ee1f6b2f31dfd @jnunemaker committed Sep 4, 2008
Showing with 26 additions and 10 deletions.
  1. +1 −1 jquery/index.html
  2. +8 −2 prototype/index.html
  3. +17 −7 prototype/js/fancyzoom.js
View
@@ -132,7 +132,7 @@ <h2>Notes</h2>
<div id="footer">
<p>
- Created by <a href="http://addictedtonew.com/about/">John Nunemaker</a> of <a href="http://orderedlist.com/">Ordered List</a> |
+ Created by <a href="http://orderedlist.com/about/">Steve Smith</a> of <a href="http://orderedlist.com/">Ordered List</a> |
<a href="http://orderedlist.com/contact/">Hire me</a>
</p>
</div>
View
@@ -87,7 +87,13 @@ <h2>Here is a large box</h2>
</div>
<div id="flash_box">
- <object type="application/x-shockwave-flash" width="400" height="300" data="http://www.flickr.com/apps/video/stewart.swf?v=59154" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"> <param name="flashvars" value="intl_lang=en-us&amp;photo_secret=1869930911&amp;photo_id=2756538377"></param> <param name="movie" value="http://www.flickr.com/apps/video/stewart.swf?v=59154"></param> <param name="bgcolor" value="#000000"></param> <param name="allowFullScreen" value="true"></param><embed type="application/x-shockwave-flash" src="http://www.flickr.com/apps/video/stewart.swf?v=59154" bgcolor="#000000" allowfullscreen="true" flashvars="intl_lang=en-us&amp;photo_secret=1869930911&amp;photo_id=2756538377" height="300" width="400"></embed></object>
+ <object type="application/x-shockwave-flash" width="400" height="300" data="http://www.flickr.com/apps/video/stewart.swf?v=59154" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">
+ <param name="flashvars" value="intl_lang=en-us&amp;photo_secret=1869930911&amp;photo_id=2756538377"></param>
+ <param name="movie" value="http://www.flickr.com/apps/video/stewart.swf?v=59154"></param>
+ <param name="bgcolor" value="#000000"></param>
+ <param name="allowFullScreen" value="true"></param>
+ <embed type="application/x-shockwave-flash" src="http://www.flickr.com/apps/video/stewart.swf?v=59154" bgcolor="#000000" allowfullscreen="true" flashvars="intl_lang=en-us&amp;photo_secret=1869930911&amp;photo_id=2756538377" height="300" width="400"></embed>
+ </object>
</div>
</div>
@@ -133,7 +139,7 @@ <h2>Notes</h2>
</div>
- <div id="footer">
+ <div id="footer">
<p>
Created by <a href="http://addictedtonew.com/about/">John Nunemaker</a> of <a href="http://orderedlist.com/">Ordered List</a> |
<a href="http://orderedlist.com/contact/">Hire me</a>
View
@@ -83,6 +83,23 @@ var FancyZoomBox = {
FancyZoomBox.middle_row = $A([$$('td.ml'), $$('td.mm'), $$('td.mr')]).flatten();
FancyZoomBox.cells = FancyZoomBox.zoom_table.select('td');
+ // hide zoom if click fired is not inside zoom
+ $$('html').first().observe('click', function(e) {
+ var click_in_zoom = e.findElement('#zoom'),
+ zoom_display = FancyZoomBox.zoom.getStyle('display');
+ if (zoom_display == 'block' && !click_in_zoom) {
+ FancyZoomBox.hide(e);
+ }
+ });
+
+ // esc to close zoom box
+ $(document).observe('keyup', function(e) {
+ var zoom_display = FancyZoomBox.zoom.getStyle('display');
+ if (e.keyCode == Event.KEY_ESC && zoom_display == 'block') {
+ FancyZoomBox.hide(e);
+ }
+ });
+
// just use gifs as ie6 and below suck
if (Prototype.Browser.ltIE7) {
FancyZoomBox.switchBackgroundImagesTo('gif');
@@ -201,11 +218,4 @@ var FancyZoom = Class.create({
this.element.observe('click', FancyZoomBox.show);
}
}
-});
-
-// hide zoom if click fired is not inside zoom
-$$('html').first().observe('click', function(e) {
- if (typeof(e.findElement('div#zoom')) == 'undefined') {
- FancyZoomBox.hide(e);
- }
});

0 comments on commit d21cc78

Please sign in to comment.