为什么压缩此javascript文件会导致错误

时间:2010-09-19 03:34:59

标签: javascript jquery compression

我使用Jquery,并更改了许多压缩工具,但仍会导致错误“它不知道我在此文件中创建的函数”

http://gist.github.com/586338

帮助我!!!

此文件运行正常,如果不压缩则没有错误

1 个答案:

答案 0 :(得分:0)

您应该在问题中说明您使用的压缩工具。此外,知道它被压缩到什么也可能有所帮助。使用this,它被压缩为:

//...

$(function(){
//...
      /**
       *    CENTER
       */
      $.fn.equalWmargin = function(){
            $(this).css('left',($(window).width()-$(this).outerWidth())/2);
      }
      $.fn.equalHmargin = function(){
            $(this).css('top',($(window).height()-$(this).outerHeight())/2);
      }
      $.fn.equalMargin = function(){
            $(this).css('top',($(window).height()-$(this).outerHeight())/2);
            $(this).css('left',($(window).width()-$(this).outerWidth())/2);
      };
});

您在最右侧范围内没有最后的中心功能。这里是压缩的:

$(function(){$("#flashMessage,#authMessage").hide();$("#flashMessage,#authMessage").css('top',0).css('left',0);$("#flashMessage,#authMessage").slideDown('fast');setTimeout(function(){$("#flashMessage,#authMessage").slideUp('slow')},10000);$("form").submit(function(){$(this).find(":submit").attr('disabled','disabled');});$("<div/>",{"id":"ajaxloading","style":"background-color:yellow;padding:7px 15px;border-radius: 5px;-moz-border-radius: 5px;-webkit-border-radius: 5px;box-shadow: 5px 5px 2px black;  -moz-box-shadow: 2px 2px 2px #CCC; -webkit-box-shadow: 2px 2px 2px #CCC;z-index:999;"}).appendTo("body");$("#ajaxloading").hide();$("#ajaxloading").css('position','fixed').html("<b>Now Loading ...</b>").css('left',($(window).width()-$("#ajaxloading").outerWidth())/2).css('top',($(window).height()-$("#ajaxloading").outerWidth())/2);});$(function(){$.fn.popBox=function(options){var target=options.target;var trigger=this;function _showOverlay(target,trigger){$(trigger).click(function(){$('<div>',{id:'overlay',css:{width:"100%",height:"100%",left:0,top:0,position:"fixed","z-index":1000,"background-color":"#222",opacity:0.3}}).hide().appendTo(document.body).fadeIn(100);$(target).fadeIn(100);return false;});}
function _hideOverlay(target){$('body').delegate('#overlay','click',function(){$('#overlay').fadeOut(100,function(){$(target).fadeOut(100);$(this).remove();});});}
_showOverlay(target,trigger);_hideOverlay(target);};$.fn.checkedAll=function(){$(this).click(function(){form=$(this).closest('form');if(form.find('input:checkbox').attr('checked')==""){$(form).find('input:checkbox').attr('checked','checked');}else{$(form).find('input:checkbox').attr('checked','');}
return false;});};$.fn.previewImg=function(options){var options=$.extend({'removeOld':true,'event':'click'},options);var xOffset=5;var yOffset=15;if(options.event=='hover'){$(this).hover(function(e){_showPreview(e);},function(){this.title=this.t;$("#screenshot").remove();});$(this).mousemove(function(e){$("#screenshot").css("top",(e.pageY+yOffset)+"px").css("left",(e.pageX+xOffset)+"px");});}
if(options.event=='click'){$(this).bind('click',_showPreview);}
$(this).click(function(){return false});function _showPreview(e){if(options.event=='click'&&options.removeOld==false){idscreenshot=Math.floor(Math.random()*30000);}else{$("#screenshot").remove();idscreenshot='screenshot'};e.currentTarget.t=e.currentTarget.title;e.currentTarget.title="";var c=(e.currentTarget.t!="")?"<br/><div style='text-align:center'>"+e.currentTarget.t+"</div>":"";$("body").append("<div id='"+idscreenshot+"' class='screenshot' class='position:absolute;border:1px solid #ccc;background:#333;padding:5px;display:none;color:#fff;'><img src='"+e.currentTarget.href+"' alt='url preview' />"+c+"</div>");$("#"+idscreenshot).css({position:"absolute",border:"1px solid #ccc",background:"#333","box-shadow":"5px 5px 2px #CCC","-moz-box-shadow":"2px 2px 2px #CCC","-webkit-box-shadow":"4px 4px 4px #CCC",padding:"5px",display:'none',color:"#fff",cursor:"pointer"}).css("top",(e.pageY-xOffset)+"px").css("left",(e.pageX+yOffset)+"px").fadeIn("fast");$("#"+idscreenshot).click(function(){$(this).remove();});}}
$.fn.tooltip=function(){xOffset=5;yOffset=10;if($(this).attr('title').length>0){$(this).hover(function(e){idtooltip=Math.floor(Math.random()*30000);this.t=this.title;this.title='';$("body").append("<p id='"+idtooltip+"'>"+this.t+"</p>");$("#"+idtooltip).css({position:"absolute",border:"1px solid #333",background:"#f7f5d1","box-shadow":"5px 5px 2px #CCC","-moz-box-shadow":"2px 2px 2px #CCC","-webkit-box-shadow":"2px 2px 2px #CCC",padding:"2px 5px",color:"#333",display:"none"}).css("top",(e.pageY-xOffset)+"px").css("left",(e.pageX+yOffset)+"px").fadeIn(100);},function(){this.title=this.t;$("#"+idtooltip).fadeOut('100',function(){$(this).remove();});});$(this).mousemove(function(e){$("#"+idtooltip).css("top",(e.pageY-xOffset)+"px").css("left",(e.pageX+yOffset)+"px");});}};$.fn.equalWmargin=function(){$(this).css('left',($(window).width()-$(this).outerWidth())/2);}
$.fn.equalHmargin=function(){$(this).css('top',($(window).height()-$(this).outerHeight())/2);}
$.fn.equalMargin=function(){$(this).css('top',($(window).height()-$(this).outerHeight())/2);$(this).css('left',($(window).width()-$(this).outerWidth())/2);};});