Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Minor glitches addressed

  • Loading branch information...
commit 41536b37989ffdf2ceff58316036e20fc4a1db3a 1 parent 780cfa1
Chris Van Pelt authored
Showing with 6 additions and 1 deletion.
  1. +5 −0 mootools/js/fancyzoom.js
  2. +1 −1  mootools/js/fancyzoom.min.js
View
5 mootools/js/fancyzoom.js
@@ -64,6 +64,7 @@ var FancyZoom = new Class({
}
},
onComplete: function(element) {
+ FancyZoom.zoomed = true;
if (!element.retrieve('scaleImg'))
$('zoom_content').set('html', element.retrieve('content_div').get('html'));
$('zoom_close').setStyle('display', '');
@@ -78,6 +79,7 @@ var FancyZoom = new Class({
$('zoom_close').setStyle('display', 'none');
},
onComplete: function(element) {
+ FancyZoom.zoomed = false;
element.setStyle('display', 'none');
FancyZoom.unfixBackgroundsForIE();
}
@@ -96,6 +98,7 @@ var FancyZoom = new Class({
});
}
});
+FancyZoom.zoomed = false;
FancyZoom.show = function(e) {
e.stop();
var element = $(e.target).match('a') ? e.target : e.target.getParent('a');
@@ -130,6 +133,8 @@ FancyZoom.show = function(e) {
height: height})
}
FancyZoom.hide = function(e) {
+ if(!FancyZoom.zoomed)
+ return
e.stop();
FancyZoom.fixBackgroundsForIE();
FancyZoom.hideFx.start({
View
2  mootools/js/fancyzoom.min.js
@@ -1 +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?"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.unfixBackgroundsForIE()}});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");FancyZoom.unfixBackgroundsForIE()}});$("zoom_close").addEvent("click",FancyZoom.hide);$$("html")[0].addEvent("click",function(C){if(!($(C.target).match("#zoom")||$(C.target).getParent("#zoom"))){FancyZoom.hide(C)}});$(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.fixBackgroundsForIE();FancyZoom.showFx.start({opacity:1,top:G,left:H,width:B,height:I})};FancyZoom.hide=function(A){A.stop();FancyZoom.fixBackgroundsForIE();FancyZoom.hideFx.start({left:$("zoom").retrieve("curLeft"),top:$("zoom").retrieve("curTop"),width:1,height:1,opacity:0})};FancyZoom.switchBackgroundImagesTo=function(C){$$("#zoom_table td").each(function(E){var D=E.getStyle("background-image").replace(/\.(png|gif|none)\)$/,"."+C+")");E.setStyle("background-image",D)});var B=zoom_close.getElement("img");var A=B.get("src").replace(/\.(png|gif|none)$/,"."+C);B.set("src",A)};FancyZoom.fixBackgroundsForIE=function(){if(Browser.Engine.trident5){FancyZoom.switchBackgroundImagesTo("gif")}};FancyZoom.unfixBackgroundsForIE=function(){if(Browser.Engine.trident5){FancyZoom.switchBackgroundImagesTo("png")}};
+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?"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){FancyZoom.zoomed=true;if(!C.retrieve("scaleImg")){$("zoom_content").set("html",C.retrieve("content_div").get("html"))}$("zoom_close").setStyle("display","");FancyZoom.unfixBackgroundsForIE()}});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){FancyZoom.zoomed=false;C.setStyle("display","none");FancyZoom.unfixBackgroundsForIE()}});$("zoom_close").addEvent("click",FancyZoom.hide);$$("html")[0].addEvent("click",function(C){if(!($(C.target).match("#zoom")||$(C.target).getParent("#zoom"))){FancyZoom.hide(C)}});$(document).addEvent("keyup",function(C){if(C.key=="esc"){FancyZoom.hide(C)}})}});FancyZoom.zoomed=false;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.fixBackgroundsForIE();FancyZoom.showFx.start({opacity:1,top:G,left:H,width:B,height:I})};FancyZoom.hide=function(A){if(!FancyZoom.zoomed){return }A.stop();FancyZoom.fixBackgroundsForIE();FancyZoom.hideFx.start({left:$("zoom").retrieve("curLeft"),top:$("zoom").retrieve("curTop"),width:1,height:1,opacity:0})};FancyZoom.switchBackgroundImagesTo=function(C){$$("#zoom_table td").each(function(E){var D=E.getStyle("background-image").replace(/\.(png|gif|none)\)$/,"."+C+")");E.setStyle("background-image",D)});var B=zoom_close.getElement("img");var A=B.get("src").replace(/\.(png|gif|none)$/,"."+C);B.set("src",A)};FancyZoom.fixBackgroundsForIE=function(){if(Browser.Engine.trident5){FancyZoom.switchBackgroundImagesTo("gif")}};FancyZoom.unfixBackgroundsForIE=function(){if(Browser.Engine.trident5){FancyZoom.switchBackgroundImagesTo("png")}};
Please sign in to comment.
Something went wrong with that request. Please try again.