Skip to content
Browse files

Mootools support... booyah

  • Loading branch information...
1 parent 2fb76b1 commit cbf1cd8f868892b761f66cb74c81f9a00261639d Chris Van Pelt committed Sep 13, 2008
View
BIN mootools/images/bl.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN mootools/images/bl.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN mootools/images/bm.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN mootools/images/bm.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN mootools/images/br.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN mootools/images/br.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN mootools/images/closebox.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN mootools/images/closebox.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN mootools/images/ml.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN mootools/images/ml.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN mootools/images/mr.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN mootools/images/mr.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN mootools/images/tl.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN mootools/images/tl.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN mootools/images/tm.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN mootools/images/tm.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN mootools/images/tr.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN mootools/images/tr.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
147 mootools/index.html
@@ -0,0 +1,147 @@
+<!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="js/mootools.1.2.js"></script>
+ <script type="text/javascript" src="js/fancyzoom.min.js"></script>
+ <script type="text/javascript" charset="utf-8">
+ document.addEvent('domready', function() {
+ $$("div.photo a").each(function(el) { new FancyZoom(el, {scaleImg:true}); })
+ new FancyZoom('medium_box_link', {width:400, height:300});
+ new FancyZoom('large_box_link');
+ new FancyZoom('flash_box_link');
+ });
+ </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 (Mootools)</h1>
+ <p>Zoomy JavaScript based loosely on Fancy Zoom by Cabel Sasser.</p>
+
+ <ul id="nav">
+ <li><a href="../jquery/index.html">jQuery Version</a></li>
+ <li><a href="../jquery/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="js/mootools.1.2.js"&gt;&lt;/script&gt;
+&lt;script type="text/javascript" src="js/fancyzoom.js"&gt;&lt;/script&gt;</code></pre>
+
+ <h2>Notes</h2>
+ <p>new FancyZoom(id) where id is the id of the <a> tag you would like to zoom. The <a> 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;
+ new FancyZoom('small');
+&lt;/script&gt;
+
+// other examples
+&lt;script type="text/javascript"&gt;
+ $(document).observe('dom:loaded', function() {
+ $$('a.fancy').each(function(el) { new FancyZoom(el, {width:500, height:300}); });
+ new FancyZoom('small', {scaleImg: true}); // Scales images inside while zooming
+ new FancyZoom('medium');
+ // 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.
+ new FancyZoom('large', {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;
+ // note that once this option is passed in, it remains the same for every other instance of FancyZoom on the same page
+ new FancyZoom('medium', {directory:'directory'});
+&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
139 mootools/js/fancyzoom.js
@@ -0,0 +1,139 @@
+var FancyZoom = new Class({
+ Implements: Options,
+ options: {
+ //The directory option is global to all future instances of FancyZoom on the same page
+ directory : 'images',
+ scaleImg: false,
+ width: null,
+ height: null
+ },
+ initialize: function(element, options) {
+ this.setOptions(options)
+ if(!$('zoom'))
+ this.setup()
+ this.element = $(element)
+ if (this.element) {
+ this.element.store('content_div', $(this.element.get('href').match(/#(.+)$/)[1]).setStyles({display:'block', position:'absolute', visibility:'hidden'}));
+ this.element.store('scaleImg', this.options.scaleImg)
+ this.element.store('zoom_width', this.options.width);
+ this.element.store('zoom_height', this.options.height);
+ this.element.addEvent('click', FancyZoom.show);
+ }
+ },
+ setup: function() {
+ var ext = (Browser.Engine.trident && !Browser.Engine.trident5) ? 'gif' : 'png'
+ var html = '<table id="zoom_table" style="border-collapse:collapse; width:100%; height:100%;"> \
+ <tbody> \
+ <tr> \
+ <td class="tl" style="background:url(' + this.options.directory + '/tl.'+ext+') 0 0 no-repeat; width:20px height:20px; overflow:hidden;" /> \
+ <td class="tm" style="background:url(' + this.options.directory + '/tm.'+ext+') 0 0 repeat-x; height:20px; overflow:hidden;" /> \
+ <td class="tr" style="background:url(' + this.options.directory + '/tr.'+ext+') 100% 0 no-repeat; width:20px height:20px; overflow:hidden;" /> \
+ </tr> \
+ <tr> \
+ <td class="ml" style="background:url(' + this.options.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(' + this.options.directory + '/mr.'+ext+') 100% 0 repeat-y; width:20px; overflow:hidden;" /> \
+ </tr> \
+ <tr> \
+ <td class="bl" style="background:url(' + this.options.directory + '/bl.'+ext+') 0 100% no-repeat; width:20px height:20px; overflow:hidden;" /> \
+ <td class="bm" style="background:url(' + this.options.directory + '/bm.'+ext+') 0 100% repeat-x; height:20px; overflow:hidden;" /> \
+ <td class="br" style="background:url(' + this.options.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="' + this.options.directory + '/closebox.'+ext+'" alt="Close" style="border:none; margin:0; padding:0;" /> \
+ </a>';
+ document.body.grab(new Element('div', {id:"zoom", style:"display:none", html: html}));
+ //Setup the FX as class methods
+ FancyZoom.showFx = new Fx.Morph($('zoom'), {
+ duration: 500,
+ onStart: function(element) {
+ if (element.retrieve('scaleImg')) {
+ $('zoom_content').set('html', element.retrieve('content_div').get('html'));
+ $$('#zoom_content img').setStyle('width', '100%');
+ } else {
+ $('zoom_content').set('html','');
+ }
+ // middle row height must be set for IE otherwise it tries to be "logical" with the height
+ if (Browser.trident) {
+ $A([$$('td.ml'), $$('td.mm'), $$('td.mr')]).flatten().setStyle('height', (height-40));
+ }
+ },
+ onComplete: function(element) {
+ if (!element.retrieve('scaleImg'))
+ $('zoom_content').set('html', element.retrieve('content_div').get('html'));
+ $('zoom_close').setStyle('display', '');
+ }
+ })
+ FancyZoom.hideFx = new Fx.Morph($('zoom'), {
+ duration: 500,
+ onStart: function(element) {
+ if (!element.retrieve('scaleImg'))
+ $('zoom_content').set('html', '')
+ $('zoom_close').setStyle('display', 'none');
+ },
+ onComplete: function(element) {
+ element.setStyle('display', 'none')
+ }
+ })
+ //Attach the events only once
+ $('zoom_close').addEvent('click', FancyZoom.hide);
+ // hide zoom if click fired is not inside zoom
+ $$('html')[0].addEvent('click', function(e) {
+ var click_in_zoom = e.target.match('#zoom') ? e.target : e.target.getParent('#zoom');
+ if (!click_in_zoom)
+ FancyZoom.hide(e);
+ });
+ // esc to close zoom box
+ $(document).addEvent('keyup', function(e) {
+ if (e.key == 'esc')
+ FancyZoom.hide(e);
+ });
+ }
+});
+FancyZoom.show = function(e) {
+ e.stop();
+ var element = e.target.match('a') ? e.target : e.target.getParent('a');
+ var content_div = element.retrieve('content_div')
+ var width = (element.retrieve('zoom_width') || content_div.getWidth()) + 60;
+ var height = (element.retrieve('zoom_height') || content_div.getHeight()) + 60;
+ var d = window.getSize();
+ var yOffset = window.getScrollTop();
+ // ensure that newTop is at least 0 so it doesn't hide close button
+ var newTop = Math.max((d.y/2) - (height/2) + yOffset, 0);
+ var newLeft = (d.x/2) - (width/2);
+ // store this FancyZooms info in the zoom container
+ $('zoom').store('curTop', e.client.y);
+ $('zoom').store('curLeft', e.client.x);
+ $('zoom').store('content_div', content_div)
+ $('zoom').store('scaleImg', element.retrieve('scaleImg'))
+ $('zoom').setStyles({
+ position : 'absolute',
+ display : 'block',
+ opacity : 0,
+ top : e.client.y,
+ left : e.client.x,
+ width : 1,
+ height : 1
+ });
+
+ FancyZoom.showFx.start({
+ opacity: 1,
+ top: newTop,
+ left: newLeft,
+ width: width,
+ height: height})
+}
+FancyZoom.hide = function(e) {
+ e.stop();
+ FancyZoom.hideFx.start({
+ left: $('zoom').retrieve('curLeft'),
+ top: $('zoom').retrieve('curTop'),
+ width: 1,
+ height: 1,
+ opacity: 0});
+}
View
1 mootools/js/fancyzoom.min.js
@@ -0,0 +1 @@
+var FancyZoom=new Class({Implements:Options,options:{directory:"images",scaleImg:false,width:null,height:null},initialize:function(B,A){this.setOptions(A);if(!$("zoom")){this.setup()}this.element=$(B);if(this.element){this.element.store("content_div",$(this.element.get("href").match(/#(.+)$/)[1]).setStyles({display:"block",position:"absolute",visibility:"hidden"}));this.element.store("scaleImg",this.options.scaleImg);this.element.store("zoom_width",this.options.width);this.element.store("zoom_height",this.options.height);this.element.addEvent("click",FancyZoom.show)}},setup:function(){var B=(Browser.Engine.trident&&!Browser.Engine.trident5)?"gif":"png";var A='<table id="zoom_table" style="border-collapse:collapse; width:100%; height:100%;"> <tbody> <tr> <td class="tl" style="background:url('+this.options.directory+"/tl."+B+') 0 0 no-repeat; width:20px height:20px; overflow:hidden;" /> <td class="tm" style="background:url('+this.options.directory+"/tm."+B+') 0 0 repeat-x; height:20px; overflow:hidden;" /> <td class="tr" style="background:url('+this.options.directory+"/tr."+B+') 100% 0 no-repeat; width:20px height:20px; overflow:hidden;" /> </tr> <tr> <td class="ml" style="background:url('+this.options.directory+"/ml."+B+') 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('+this.options.directory+"/mr."+B+') 100% 0 repeat-y; width:20px; overflow:hidden;" /> </tr> <tr> <td class="bl" style="background:url('+this.options.directory+"/bl."+B+') 0 100% no-repeat; width:20px height:20px; overflow:hidden;" /> <td class="bm" style="background:url('+this.options.directory+"/bm."+B+') 0 100% repeat-x; height:20px; overflow:hidden;" /> <td class="br" style="background:url('+this.options.directory+"/br."+B+') 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="'+this.options.directory+"/closebox."+B+'" alt="Close" style="border:none; margin:0; padding:0;" /> </a>';document.body.grab(new Element("div",{id:"zoom",style:"display:none",html:A}));FancyZoom.showFx=new Fx.Morph($("zoom"),{duration:500,onStart:function(C){if(C.retrieve("scaleImg")){$("zoom_content").set("html",C.retrieve("content_div").get("html"));$$("#zoom_content img").setStyle("width","100%")}else{$("zoom_content").set("html","")}if(Browser.trident){$A([$$("td.ml"),$$("td.mm"),$$("td.mr")]).flatten().setStyle("height",(height-40))}},onComplete:function(C){if(!C.retrieve("scaleImg")){$("zoom_content").set("html",C.retrieve("content_div").get("html"))}$("zoom_close").setStyle("display","")}});FancyZoom.hideFx=new Fx.Morph($("zoom"),{duration:500,onStart:function(C){if(!C.retrieve("scaleImg")){$("zoom_content").set("html","")}$("zoom_close").setStyle("display","none")},onComplete:function(C){C.setStyle("display","none")}});$("zoom_close").addEvent("click",FancyZoom.hide);$$("html")[0].addEvent("click",function(D){var C=D.target.match("#zoom")?D.target:D.target.getParent("#zoom");if(!C){FancyZoom.hide(D)}});$(document).addEvent("keyup",function(C){if(C.key=="esc"){FancyZoom.hide(C)}})}});FancyZoom.show=function(E){E.stop();var D=E.target.match("a")?E.target:E.target.getParent("a");var A=D.retrieve("content_div");var B=(D.retrieve("zoom_width")||A.getWidth())+60;var I=(D.retrieve("zoom_height")||A.getHeight())+60;var F=window.getSize();var C=window.getScrollTop();var G=Math.max((F.y/2)-(I/2)+C,0);var H=(F.x/2)-(B/2);$("zoom").store("curTop",E.client.y);$("zoom").store("curLeft",E.client.x);$("zoom").store("content_div",A);$("zoom").store("scaleImg",D.retrieve("scaleImg"));$("zoom").setStyles({position:"absolute",display:"block",opacity:0,top:E.client.y,left:E.client.x,width:1,height:1});FancyZoom.showFx.start({opacity:1,top:G,left:H,width:B,height:I})};FancyZoom.hide=function(A){A.stop();FancyZoom.hideFx.start({left:$("zoom").retrieve("curLeft"),top:$("zoom").retrieve("curTop"),width:1,height:1,opacity:0})};
View
3,816 mootools/js/mootools.1.2.js
3,816 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.

0 comments on commit cbf1cd8

Please sign in to comment.
Something went wrong with that request. Please try again.