一派护法 十九级 |
var pic={ albums:{ create:function(){ jswindow.open("创建相册","back/create_albums.php?b="+pic.board.url,450,220); }, edit:function(id){ jswindow.open("编辑相册","back/create_albums.php?action=edit&i="+id,450,220); }, drop:function(id){ jswindow.open("删除相册","back/create_albums.php?action=drop&i="+id,450,220); }, hualun:{ moveup:{ onmouseover:function(that){ if (this.disabled(that)) return false; that.className='onmouseover'; }, onmouseout:function(that){ if (this.disabled(that)) return false; that.className=''; }, disabled:function(that){ return that.className=="disabled"; }, setdisabled:function(that,isTrue){ if (isTrue!==false) isTrue=true; var cn=(isTrue)?'disabled':''; that.className=cn; return cn; }, onclick:function(fx){ if (fx==0){ pic.albums.hualun.marqueeArea.wheel(null,1,true); }else{ pic.albums.hualun.marqueeArea.wheel(null,2,true); } } }, marqueeArea:{ lastNode:null, onmouseover:function(that){ if (this.selected(that)) return false; that.className="onmouseover"; }, onmouseout:function(that){ if (this.selected(that)) return false; that.className=""; }, onclick:function(that){ if (this.selected(that)) return false; if (this.lastNode!==null) this.lastNode.className=''; that.className="selected"; this.lastNode=that; var si=Number(that.id.replace(/^whole_for/,'')); this.selectedid=si; pic.albums.show(si); }, selected:function(that){ var cn=that.className; return (cn=="selected"); }, wheel:function(event,result,clicked){ var size=40; var basenum=120; switch (result){ case 1: //向上 var sil=$('marqueeArea'); if (clicked===true){ //计算应滚动到哪个相册 var cur=Number(sil.scrollTop); var bal=Math.ceil(cur/basenum)*basenum-basenum; for (var i=0;i<(cur-bal)/2;i++){ var fund=function(){ var d=$('marqueeArea'); d.scrollTop-=2; pic.albums.hualun.marqueeArea.updateDisabled(d); } window.setTimeout(fund,i+1); } }else{ sil.scrollTop-=size; } this.updateDisabled(sil); break; case 2: //向下 var sil=$('marqueeArea'); if (clicked===true){ var cur=Number(sil.scrollTop); var bal=Math.ceil(cur/basenum)*basenum+basenum; for (var i=0;i<(bal-cur)/2;i++){ var fund=function(){ var d=$('marqueeArea'); d.scrollTop+=2; pic.albums.hualun.marqueeArea.updateDisabled(d); } window.setTimeout(fund,i+1); } }else{ sil.scrollTop+=size; this.updateDisabled(sil); } break; default: if (!event) event=window.event; if (event.wheelDelta){ //IE switch (event.wheelDelta){ case 120: this.wheel(null,1); break; case -120: this.wheel(null,2); break; default: return false; } }else if (event.detail){ //Firefox switch (event.detail){ case 3: this.wheel(null,2); break; case -3: this.wheel(null,1); break; } } break; } }, updateDisabled:function(sock){ //更新按钮状态 var a=(sock.scrollTop==0); var b=(sock.scrollTop+sock.clientHeight==sock.scrollHeight); $('moveup').className=a?'disabled':''; $('movedown').className=b?'disabled':''; return new Array(a,b); } } }, show:function(alid){ var url="../Ajax/pictures_data.php"; var pars="id="+alid+"&type=getalbum"; var comp=function(q){ var xm=q.responseXML.documentElement.childNodes; var reg=/:\d{0,2}$/; var name=xmlvalue(xm[0]); var user=xmlvalue(xm[1]); var addtime=xm[2].getAttribute("add").replace(reg,''); var edittime=xm[2].getAttribute("edit").replace(reg,''); var clicks=xmlvalue(xm[3]); var desc=xmlvalue(xm[4]); var img=xm[5].getAttribute("src"); var amount=xmlvalue(xm[6]); $('xcName').innerHTML=name; $('xcUser').innerHTML=user; $('xcAddTime').innerHTML=addtime; $('xcEditTime').innerHTML=edittime; $('xcClicks').innerHTML=clicks $('xcDescription').innerHTML=desc; if (img=="no") img="../Images/board/nopictures.gif"; $('xchm').src=img; $('xcAmount').innerHTML=Number(amount); } var myAjax=new Ajax.Request(url,{method:'post',parameters:pars,onComplete:comp}); } }, page:{ createAlbums:{ onload:function(){ $('textfield').select(); }, onsubmit:function(){ var name=Trim($F('textfield')); var descr=Trim($F('textarea')); var url="../Ajax/pictures.php"; var pars="type=0&bi="+$F('bi')+"&name="+ajaxcode(name)+"&descr="+ajaxcode('descr'); $('button').disabled=true; var myAjax=new Ajax.Request(url,{method:'post',parameters:pars,onComplete:this.submited}); return false; }, submited:function(q){ try{ var msg=Number(q.responseXML.documentElement.firstChild.nodeValue); switch (msg){ case 0: top.Alert("操作失败","没有权限(错误代码:1144)",300,110,'$_WIN(1).pic.page.createAlbums.failed()'); break; case 1: top.Alert("操作失败","相册名称只能由中文、数字、字母和下划线组成",350,110,'$_WIN(1).pic.page.createAlbums.failed()'); break; case 2: top.Alert("操作失败","指定的相册名称与现有相册重名,请另换一个名称",400,110,'$_WIN(1).pic.page.createAlbums.failed()'); break; case 3: top.document.URL=top.location.href; break; } }catch(e){ top.Alert("操作失败","系统错误(错误代码:1133)",300,110,'$_WIN(1).pic.page.createAlbums.failed()'); } }, failed:function(){ $('button').disabled=false; top.jswindow.close(); } } }, photos:{ upload:function(type){ var url="back/newpictures.php?b="+pic.board.url; if (type=="albums") url+="&selectedid="+pic.albums.hualun.marqueeArea.selectedid; jswindow.open("图片上传",url,620,570,null,true); }, startupload:function(){ $('button').disabled=true; //判断是否至少上传一个文件 var f1=$F('fileField0'); if (f1==""){ top.Alert('操作失败','必须至少选择一个文件',300,110,'$_WIN(1).pic.photos.failed()'); return false; }else{ document.form1.target="yager"; document.form1.action="../Ajax/pbase_upload.php"; return true; } }, iframe:function(){ try{ var msg=window.frames['yager'].document.getElementById('msg').innerHTML; if (msg=="default"){ return true; } }catch(e){ return e; } }, failed:function(){ $('button').disabled=false; top.jswindow.close(); } }, onload:function(){ set_searchtext(this.board.name); //加载滑轮 switch (this.board.hualunid){ case 1: var span=$('hualun'); var eve=new Function("event","pic.albums.hualun.marqueeArea.wheel(event);return false"); if (window.addEventListener){ //Firefox window.addEventListener('DOMMouseScroll',eve,false); }else{ //IE span.onmousewheel=eve; } var hsd=Number(pic.board.hualun_selectedid); if (hsd>0){ var hsD=$('whole_for'+hsd); if (hsD!==null){ pic.albums.hualun.marqueeArea.lastNode=hsD; //初始相册 //滑轮滑动到初始相册 var sock=$('marqueeArea'); var lis=sock.getElementsByTagName('li'); var j=0; var reg=/^whole_for\d+$/; for (var i=0;i<lis.length;i++){ if (lis[i].className=="selected"){ var scs=(j-2)*120; sock.scrollTop=scs; this.albums.hualun.marqueeArea.updateDisabled(sock); break; }else if (reg.test(lis[i].id)){ j++; } } //调用相册信息 pic.albums.hualun.marqueeArea.selectedid=hsd; pic.albums.show(hsd); } } break; } } }
|