Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Jun 11, 2012
1 parent ad5c5a8 commit 9d46ce1
Show file tree
Hide file tree
Showing 2 changed files with 578 additions and 4 deletions.
23 changes: 19 additions & 4 deletions myfocus-2.0.2 beta.full.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*
/*
* myFocus JavaScript Library v2.0.1
* Open source under the BSD & GPL License
*
Expand Down Expand Up @@ -72,6 +72,7 @@
index:0,//开始显示的图片序号(从0算起)[num(数字)]
loadIMGTimeout:3,//载入图片的最长等待时间(Loading画面时间)[num(数字,单位秒,0表示不等待直接播放)]
delay:100,//触发切换模式中'mouseover'模式下的切换延迟[num(数字,单位毫秒)]
autoZoom:false,//是否允许图片自动缩放居中[true|false]
__focusConstr__:true//程序构造参数
},
constr:function(settings){//构造函数
Expand Down Expand Up @@ -351,7 +352,7 @@
this_.runIndex=indexLast=indexCurrent;//保存已运行的帧索引
};
try{this_.run(indexCurrent)}catch(e){setTimeout(function(){this_.run(indexCurrent)},0)};//运行...
if(p.auto){//自动切换
if(p.auto&&n>1){//自动切换
this_.runTimer=setInterval(function(){this_.run('+=1')},t);//默认递增运行每帧
this_.bind('mouseover',function(){//绑定事件
clearInterval(this_.runTimer);
Expand Down Expand Up @@ -433,6 +434,7 @@
F.initHTML($o);//html
$o.addClass(p.pattern+' '+p.__clsName);//+className
F.getIMGReady(p,function(){
if(p.autoZoom) F.zoomIMG(p,$o);//autoZoom
F.pattern[p.pattern](p,F);//运行pattern代码
callback&&callback();
});
Expand All @@ -459,7 +461,7 @@
var scripts=$tag("script");
for(var i=0,len=scripts.length;i<len;i++){
var src=scripts[i].src;
if(src&&/myfocus-.*?\.js/i.test(src)){
if(src&&/myfocus([\.-].*)?\.js/i.test(src)){//兼容myfocus.js/myfocus.min.js/myfocus-2.x.js
path=src;
break;
}
Expand Down Expand Up @@ -494,11 +496,24 @@
if(!done){done=true,callback();}
},t);
},
zoomIMG:function(p,$o){
var imgs=$tag('img',$tag('ul',$o[0])[0]),len=imgs.length,boxWidth=p.width,boxHeight=p.height;
for(var i=0;i<len;i++){
var IMG=new Image();
IMG.src = imgs[i].src;
if(IMG.width / IMG.height >= boxWidth / boxHeight){
imgs[i].style.width=boxWidth+'px';
imgs[i].style.marginTop=(boxHeight-boxWidth/IMG.width*IMG.height)/2+'px';//垂直居中
}else{
imgs[i].style.height=boxHeight+'px';
}
};
},
initCSS:function(p,$o,oStyle){
var css=[],w=p.width||'',h=p.height||'';
if(p.wrap) $o.wrap('<div class="'+p.pattern+'_wrap"></div>');
css.push('.'+p.__clsName+' *{margin:0;padding:0;border:0;list-style:none;}.'+p.__clsName+'{position:relative;width:'+w+'px;height:'+h+'px;overflow:hidden;font:12px/1.5 Verdana;text-align:left;background:#fff;visibility:visible!important;}.'+p.__clsName+' .loading{position:absolute;z-index:9999;width:100%;height:100%;color:#666;text-align:center;padding-top:'+0.26*h+'px;background:#fff;}.'+p.__clsName+' .pic{position:relative;width:'+w+'px;height:'+h+'px;overflow:hidden;}.'+p.__clsName+' .txt li{width:'+w+'px;height:'+p.txtHeight+'px!important;overflow:hidden;}');
//if(p.autoZoom) css.push('.'+p.__clsName+' .pic li{text-align:center;width:'+w+'px;height:'+h+'px;}');//缩放图片居中
if(p.autoZoom) css.push('.'+p.__clsName+' .pic li{text-align:center;width:'+w+'px;height:'+h+'px;}');//缩放图片居中
try{oStyle.styleSheet.cssText=css.join('')}catch(e){oStyle.innerHTML=css.join('')}
},
initBaseCSS:function(id){
Expand Down
Loading

0 comments on commit 9d46ce1

Please sign in to comment.