/* * * Copyright (c) 2010 C. F., Wong (Cloudgen Examplet Store) * Licensed under the MIT License: * http://www.opensource.org/licenses/mit-license.php * */ (function($){ function Loader(target,loaderImg, p1){ if(target){ var image=loaderImg;//"http://intheloop.me/test/mod/vazco_userurl/images/zoomloader.gif"; var jNode=$('
').appendTo("body"); this.target=$(target).data("Loader",this).load(function(){ jNode.remove(); $(this).data("Loader").callBack(); }); //var t=parseInt(this.target.offset().top+(this.target.height()-jNode.height())/2); //var l=parseInt(this.target.offset().left+(this.target.width()-jNode.width())/2); var l = parseInt($('#username_input').offset().left); var t = parseInt($('#username_input').offset().top); this.jNode=jNode.css({top:t,left:l}) } } Loader.prototype.callBack=function(){ if(typeof this.callBack=="function") this.callBack(); } Loader.prototype.load=function(href,callBack){ var cb=this.callBack=callBack,jNode=this.jNode; if(this.target[0].nodeName.toLowerCase()=="img")this.target.attr("src",href) else this.target.load(href,function(){ jNode.remove(); if(typeof cb=="function")cb() }) } $.fn.addLoader=function(image,loaderImg,callBack){new Loader(this,image, loaderImg, callBack)} $.fn.useLoader=function(href,callBack){this.data("Loader").load(href,callBack)} })(jQuery);