/** * * plugin: jquery.webox * developer: blank * version: 1.0 beta * update: 2012.07.08 * **/ $.extend({ webox:function(option){ var _x,_y,m,allscreen=false; if(!option){ alert('options can\'t be empty'); return; }; if(!option['html']&&!option['iframe']){ alert('html attribute and iframe attribute can\'t be both empty'); return; }; option['parent']='webox'; option['locked']='locked'; $(document).ready(function(e){ $('.webox').remove(); $('.background').remove(); var width=option['width']?option['width']:400; var height=option['height']?option['height']:240; $('body').append(''); if(navigator.useragent.indexof('msie 7')>0||navigator.useragent.indexof('msie 8')>0){ $('.webox').css({'filter':'progid:dximagetransform.microsoft.gradient(startcolorstr=#55000000,endcolorstr=#55000000)'}); }if(option['bgvisibel']){ $('.background').fadeto('slow',0.3); }; $('.webox').css({display:'block'}); $('#'+option['locked']+' .span').click(function(){ $('.webox').css({display:'none'}); $('.background').css({display:'none'}); }); var marginleft=parseint(width/2); var margintop=parseint(height/2); var winwidth=parseint($(window).width()/2); var winheight=parseint($(window).height()/2.2); var left=winwidth-marginleft; var top=winheight-margintop; $('.webox').css({left:left,top:top}); $('#'+option['locked']).mousedown(function(e){ if(e.which){ m=true; _x=e.pagex-parseint($('.webox').css('left')); _y=e.pagey-parseint($('.webox').css('top')); } }).dblclick(function(){ if(allscreen){ $('.webox').css({height:height,width:width}); $('#inside').height(height); $('.w_iframe').height(height-30); $('.webox').css({left:left,top:top}); allscreen = false; }else{ allscreen=true; var screenheight = $(window).height(); var screenwidth = $(window).width();$ ('.webox').css({'width':screenwidth-18,'height':screenheight-18,'top':'0px','left':'0px'}); $('#inside').height(screenheight-20); $('.w_iframe').height(screenheight-50); } }); }).mousemove(function(e){ if(m && !allscreen){ var x=e.pagex-_x; var y=e.pagey-_y; $('.webox').css({left:x}); $('.webox').css({top:y}); } }).mouseup(function(){ m=false; }); $(window).resize(function(){ if(allscreen){ var screenheight = $(window).height(); var screenwidth = $(window).width(); $('.webox').css({'width':screenwidth-18,'height':screenheight-18,'top':'0px','left':'0px'}); $('#inside').height(screenheight-20); $('.w_iframe').height(screenheight-50); } }); } });