Permalink
Browse files

Added jQuery support, and framework directories. Also included framew…

…orks scripts from the google api.
  • Loading branch information...
1 parent 2237eac commit b7e6a954d3f769e7de975a598584e9d27f33f331 @orderedlist orderedlist committed Sep 4, 2008
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -0,0 +1,141 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
+ <title>Fancy Zoom by John Nunemaker</title>
+ <link rel="stylesheet" href="../css/common.css" type="text/css" />
+ <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js"></script>
+ <script type="text/javascript" src="js/fancyzoom.js"></script>
+ <script type="text/javascript" charset="utf-8">
+ $(document).ready(function() {
+ $('div.photo a').fancyZoom({scaleImg: true});
+ $('#medium_box_link').fancyZoom({width:400, height:300});
+ $('#large_box_link').fancyZoom();
+ $('#flash_box_link').fancyZoom();
+ });
+ </script>
+
+ <style type="text/css" media="screen">
+ #large_box {width:800; height:600;}
+ </style>
+</head>
+<body>
+<div id="wrapper">
+ <div id="header">
+ <h1>Fancy Zoom (jQuery)</h1>
+ <p>Zoomy JavaScript based loosely on Fancy Zoom by Cabel Sasser.</p>
+
+ <ul id="nav">
+ <li><a href="../prototype/index.html">Prototype Version</a></li>
+ <li><a href="http://github.com/jnunemaker/fancy-zoom/">Github</a></li>
+ <li><a href="http://jnunemaker.lighthouseapp.com/projects/16389-fancyzoom/overview">Lighthouse</a></li>
+ </ul>
+ </div>
+
+ <div id="content">
+ <p>This works with any html (images, text, headings, flash). The only caveat is it doesn't currently work with AJAX. Whatever you want to zoom to must be html already on the page. Below are several examples. Width and height of zoom box are configurable through optional setting or css.</p>
+
+ <h2>Demos</h2>
+
+ <div id="photos">
+ <h3>Images</h3>
+ <div class="photo">
+ <a href="#github">
+ <img src="http://farm4.static.flickr.com/3250/2765022017_356efe6a25_s.jpg" alt="Github helmet" />
+ </a>
+ </div>
+ <div class="photo">
+ <a href="#hotdog">
+ <img src="http://farm4.static.flickr.com/3150/2726282580_05ed83e3c0_s.jpg" alt="Github helmet" />
+ </a>
+ </div>
+ <div class="photo">
+ <a href="#turtles">
+ <img src="http://farm4.static.flickr.com/3088/2709825025_fb6d71b455_s.jpg" alt="Github helmet" />
+ </a>
+ </div>
+
+ <div id="github">
+ <img src="http://farm4.static.flickr.com/3250/2765022017_356efe6a25.jpg" alt="helmet" />
+ </div>
+ <div id="hotdog">
+ <img src="http://farm4.static.flickr.com/3150/2726282580_05ed83e3c0.jpg" alt="Hot dog" />
+ </div>
+ <div id="turtles">
+ <img src="http://farm4.static.flickr.com/3088/2709825025_fb6d71b455.jpg" alt="Turtles" />
+ <p id="turtles_caption">It's true, they do bite!</p>
+ </div>
+ </div>
+
+ <div id="text">
+ <h3>Text</h3>
+ <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vivamus vitae risus vitae lorem iaculis placerat. Aliquam sit amet felis. Etiam congue. Donec risus risus, pretium ac, tincidunt eu, tempor eu, quam. Morbi blandit mollis magna. Suspendisse eu tortor. <a href="#medium_box" id="medium_box_link">Here is a medium box</a> blandit rhoncus. Ut a pede ac neque mattis facilisis. Nulla nunc ipsum, sodales vitae, hendrerit non, imperdiet ac, ante. <a href="#large_box" id="large_box_link">Here is a large box</a>. Morbi sit amet mi. Ut magna. Curabitur id est. Nulla velit. Sed consectetuer sodales justo. Aliquam dictum gravida libero. Sed eu turpis. Nunc id lorem. Aenean consequat tempor mi. Phasellus in neque. Nunc fermentum convallis ligula. <a href="#flash_box" id ="flash_box_link">You can even embed flash</a>.</p>
+
+ <div id="medium_box">
+ <h2>Here is a medium box</h2>
+ <p><strong>The width and height of this box are set in the options for this fancy zoom.</strong> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vivamus vitae risus vitae lorem iaculis placerat. Aliquam sit amet felis. Etiam congue. Donec risus risus, pretium ac, tincidunt eu, tempor eu, quam. Morbi blandit mollis magna. Suspendisse eu tortor. Donec vitae felis nec ligula blandit rhoncus.</p>
+
+ <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vivamus vitae risus vitae lorem iaculis placerat. Aliquam sit amet felis. Etiam congue. Donec risus risus, pretium ac, tincidunt eu, tempor eu, quam. Morbi blandit mollis magna. Suspendisse eu tortor. Donec vitae felis nec ligula blandit rhoncus.</p>
+ </div>
+
+ <div id="large_box">
+ <h2>Here is a large box</h2>
+ <p><strong>The width and height for this box are inferred from css. See the style tag in the &lt;head&gt; of this document.</strong> Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vivamus vitae risus vitae lorem iaculis placerat. Aliquam sit amet felis. Etiam congue. Donec risus risus, pretium ac, tincidunt eu, tempor eu, quam. Morbi blandit mollis magna. Suspendisse eu tortor. Donec vitae felis nec ligula blandit rhoncus.</p>
+
+ <p>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Vivamus vitae risus vitae lorem iaculis placerat. Aliquam sit amet felis. Etiam congue. Donec risus risus, pretium ac, tincidunt eu, tempor eu, quam. Morbi blandit mollis magna. Suspendisse eu tortor. Donec vitae felis nec ligula blandit rhoncus.</p>
+ </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>
+ </div>
+ </div>
+
+ <h2>Installation</h2>
+
+ <p>Add the following scripts and checkout the notes below (or view the source of this page).</p>
+
+<pre><code>&lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.js"&gt;&lt;/script&gt;
+&lt;script type="text/javascript" src="js/fancyzoom.js"&gt;&lt;/script&gt;</code></pre>
+
+ <h2>Notes</h2>
+ <p>$('#id').fancyZoom() where id is the id of the &lt;a&gt; tag you would like to zoom. The &lt;a&gt; tag should have an href that anchors to the id of the box that contains the contents that should be zoomed. For example:</p>
+
+ <pre><code>&lt;a href="#small_box" id="small"&gt;Small Box!&lt;/a&gt;
+&lt;div id="small_box"&gt;
+ &lt;p&gt;Here is the contents that will appear in the zoom.&lt;/p&gt;
+&lt;/div&gt;
+&lt;script type="text/javascript"&gt;
+ $('#small').fancyZoom();
+&lt;/script&gt;
+
+// other examples
+&lt;script type="text/javascript"&gt;
+ $(document).ready(function() {
+ $('a.fancy').each(function() { $(this).fancyZoom({width:500, height:300});});
+ $('#small').fancyZoom({scaleImg: true}); // Scales images inside while zooming
+ $('#medium').fancyZoom();
+ // width and height are optional. defaults to css specifications of width and height.
+ // if width and height are passed in, they override whatever may be in css.
+ $('#large').fancyZoom({width:600, height:400});
+ });
+&lt;/script&gt;</code></pre>
+
+ <p>If the images are not in a directory named 'images' that is relative to the html file you can configure it like so:</p>
+
+<pre><code>&lt;script type="text/javascript"&gt;
+ $(document).ready(function() {
+ $('#small').fancyZoom({directory: 'http://foobar.com/images/zoom'}); // no need for trailing slash
+ });
+&lt;/script&gt;</code></pre>
+
+ </div>
+
+ <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>
+ </p>
+ </div>
+</div>
+</body>
+</html>
View
@@ -0,0 +1,161 @@
+jQuery.fn.fancyZoom = function(options){
+
+ var options = options || {};
+ var directory = options && options.directory ? options.directory : 'images';
+ var zooming = false;
+
+ if ($('#zoom').length == 0) {
+ var ext = $.browser.msie ? 'gif' : 'png';
+ var html = '<div id="zoom" style="display:none;"> \
+ <table id="zoom_table" style="border-collapse:collapse; width:100%; height:100%;"> \
+ <tbody> \
+ <tr> \
+ <td class="tl" style="background:url(' + directory + '/tl.' + ext + ') 0 0 no-repeat; width:20px height:20px; overflow:hidden;" /> \
+ <td class="tm" style="background:url(' + directory + '/tm.' + ext + ') 0 0 repeat-x; height:20px; overflow:hidden;" /> \
+ <td class="tr" style="background:url(' + directory + '/tr.' + ext + ') 100% 0 no-repeat; width:20px height:20px; overflow:hidden;" /> \
+ </tr> \
+ <tr> \
+ <td class="ml" style="background:url(' + directory + '/ml.' + ext + ') 0 0 repeat-y; width:20px; overflow:hidden;" /> \
+ <td class="mm" style="background:#fff; vertical-align:top; padding:10px;"> \
+ <div id="zoom_content"> \
+ </div> \
+ </td> \
+ <td class="mr" style="background:url(' + directory + '/mr.' + ext + ') 100% 0 repeat-y; width:20px; overflow:hidden;" /> \
+ </tr> \
+ <tr> \
+ <td class="bl" style="background:url(' + directory + '/bl.' + ext + ') 0 100% no-repeat; width:20px height:20px; overflow:hidden;" /> \
+ <td class="bm" style="background:url(' + directory + '/bm.' + ext + ') 0 100% repeat-x; height:20px; overflow:hidden;" /> \
+ <td class="br" style="background:url(' + directory + '/br.' + ext + ') 100% 100% no-repeat; width:20px height:20px; overflow:hidden;" /> \
+ </tr> \
+ </tbody> \
+ </table> \
+ <a href="#" title="Close" id="zoom_close" style="position:absolute; top:0; left:0;"> \
+ <img src="' + directory + '/closebox.' + ext + '" alt="Close" style="border:none; margin:0; padding:0;" /> \
+ </a> \
+ </div>';
+
+ $('body').append(html);
+
+ $('#zoom_close').click(hide);
+ }
+
+ var zoom = $('#zoom');
+ var zoom_table = $('#zoom_table');
+ var zoom_close = $('#zoom_close');
+ var zoom_content = $('#zoom_content');
+ var middle_row = $('td.ml,td.mm,td.mr');
+
+ this.each(function(i) {
+ $($(this).attr('href')).hide();
+ $(this).click(show);
+ });
+
+ return this;
+
+ function show(e) {
+ if (zooming) return false;
+ zooming = true;
+ var content_div = $($(this).attr('href'));
+ var zoom_width = options.width;
+ var zoom_height = options.height;
+
+ var width = window.innerWidth || (window.document.documentElement.clientWidth || window.document.body.clientWidth);
+ var height = window.innerHeight || (window.document.documentElement.clientHeight || window.document.body.clientHeight);
+ var x = window.pageXOffset || (window.document.documentElement.scrollLeft || window.document.body.scrollLeft);
+ var y = window.pageYOffset || (window.document.documentElement.scrollTop || window.document.body.scrollTop);
+ var window_size = {'width':width, 'height':height, 'x':x, 'y':y}
+
+ var width = (zoom_width || content_div.width()) + 60;
+ var height = (zoom_height || content_div.height()) + 60;
+ var d = window_size;
+
+ // ensure that newTop is at least 0 so it doesn't hide close button
+ var newTop = Math.max((d.height/2) - (height/2) + y, 0);
+ var newLeft = (d.width/2) - (width/2);
+ var curTop = e.pageY;
+ var curLeft = e.pageX;
+
+ zoom_close.attr('curTop', curTop);
+ zoom_close.attr('curLeft', curLeft);
+ zoom_close.attr('scaleImg', options.scaleImg ? 'true' : 'false');
+
+ $('#zoom').hide().css({
+ position : 'absolute',
+ top : curTop + 'px',
+ left : curLeft + 'px',
+ width : '1px',
+ height : '1px'
+ });
+
+ fixBackgroundsForIE();
+ zoom_close.hide();
+ if (options.scaleImg) {
+ zoom_content.html(content_div.html());
+ $('#zoom_content img').css('width', '100%');
+ } else {
+ zoom_content.html('');
+ }
+
+ $('#zoom').animate({
+ top : newTop + 'px',
+ left : newLeft + 'px',
+ opacity : "show",
+ width : width,
+ height : height
+ }, 500, null, function() {
+ if (options.scaleImg != true) {
+ zoom_content.html(content_div.html());
+ }
+ unfixBackgroundsForIE();
+ zoom_close.show();
+ zooming = false;
+ })
+ return false;
+ }
+
+ function hide() {
+ if (zooming) return false;
+ zooming = true;
+ fixBackgroundsForIE();
+ if (zoom_close.attr('scaleImg') != 'true') {
+ zoom_content.html('');
+ }
+ zoom_close.hide();
+ $('#zoom').animate({
+ top : zoom_close.attr('curTop') + 'px',
+ left : zoom_close.attr('curLeft') + 'px',
+ opacity : "hide",
+ width : '1px',
+ height : '1px'
+ }, 500, null, function() {
+ if (zoom_close.attr('scaleImg') == 'true') {
+ zoom_content.html('');
+ }
+ unfixBackgroundsForIE();
+ zooming = false;
+ })
+ return false;
+ }
+
+ function switchBackgroundImagesTo(to) {
+ $('#zoom_table td').each(function(i) {
+ var bg = $(this).css('background-image').replace(/\.(png|gif|none)\"\)$/, '.' + to + '")');
+ $(this).css('background-image', bg);
+ });
+ var close_img = zoom_close.children('img');
+ var new_img = close_img.attr('src').replace(/\.(png|gif|none)$/, '.' + to);
+ close_img.attr('src', new_img);
+ }
+
+ function fixBackgroundsForIE() {
+ if ($.browser.msie && parseFloat($.browser.version) >= 7) {
+ switchBackgroundImagesTo('gif');
+ }
+ }
+
+ function unfixBackgroundsForIE() {
+ if ($.browser.msie && $.browser.version >= 7) {
+ switchBackgroundImagesTo('png');
+ }
+ }
+}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Diff not rendered.
Oops, something went wrong. Retry.

0 comments on commit b7e6a95

Please sign in to comment.