root / trunk / web / dojo / dojox / layout / ScrollPane.js @ 10
History | View | Annotate | Download (2.89 KB)
| 1 | /*
 | 
|---|---|
| 2 |         Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
 | 
| 3 |         Available via Academic Free License >= 2.1 OR the modified BSD license.
 | 
| 4 |         see: http://dojotoolkit.org/license for details
 | 
| 5 | */
 | 
| 6 |  | 
| 7 |  | 
| 8 | if(!dojo._hasResource["dojox.layout.ScrollPane"]){ | 
| 9 | dojo._hasResource["dojox.layout.ScrollPane"]=true; | 
| 10 | dojo.provide("dojox.layout.ScrollPane");
 | 
| 11 | dojo.experimental("dojox.layout.ScrollPane");
 | 
| 12 | dojo.require("dijit.layout.ContentPane");
 | 
| 13 | dojo.require("dijit._Templated");
 | 
| 14 | dojo.declare("dojox.layout.ScrollPane",[dijit.layout.ContentPane,dijit._Templated],{_line:null,_lo:null,_offset:15,orientation:"vertical",autoHide:true,templateString:dojo.cache("dojox.layout","resources/ScrollPane.html","<div class=\"dojoxScrollWindow\" dojoAttachEvent=\"onmouseenter: _enter, onmouseleave: _leave\">\n <div class=\"dojoxScrollWrapper\" style=\"${style}\" dojoAttachPoint=\"wrapper\" dojoAttachEvent=\"onmousemove: _calc\">\n\t<div class=\"dojoxScrollPane\" dojoAttachPoint=\"containerNode\"></div>\n </div>\n <div dojoAttachPoint=\"helper\" class=\"dojoxScrollHelper\"><span class=\"helperInner\">|</span></div>\n</div>\n"),resize:function(_1){ | 
| 15 | if(_1){
 | 
| 16 | if(_1.h){
 | 
| 17 | dojo.style(this.domNode,"height",_1.h+"px"); | 
| 18 | } | 
| 19 | if(_1.w){
 | 
| 20 | dojo.style(this.domNode,"width",_1.w+"px"); | 
| 21 | } | 
| 22 | } | 
| 23 | var _2=this._dir,_3=this._vertical,_4=this.containerNode[(_3?"scrollHeight":"scrollWidth")]; | 
| 24 | dojo.style(this.wrapper,this._dir,this.domNode.style[this._dir]); | 
| 25 | this._lo=dojo.coords(this.wrapper,true); | 
| 26 | this._size=Math.max(0,_4-this._lo[(_3?"h":"w")]); | 
| 27 | if(!this._size){ | 
| 28 | this.helper.style.display="none"; | 
| 29 | this.wrapper[this._scroll]=0; | 
| 30 | return;
 | 
| 31 | }else{
 | 
| 32 | this.helper.style.display=""; | 
| 33 | } | 
| 34 | this._line=new dojo._Line(0-this._offset,this._size+(this._offset*2)); | 
| 35 | var u=this._lo[(_3?"h":"w")],r=Math.min(1,u/_4),s=u*r,c=Math.floor(u-(u*r)); | 
| 36 | this._helpLine=new dojo._Line(0,c); | 
| 37 | dojo.style(this.helper,_2,Math.floor(s)+"px"); | 
| 38 | },postCreate:function(){ | 
| 39 | this.inherited(arguments); | 
| 40 | if(this.autoHide){ | 
| 41 | this._showAnim=dojo._fade({node:this.helper,end:0.5,duration:350}); | 
| 42 | this._hideAnim=dojo.fadeOut({node:this.helper,duration:750}); | 
| 43 | } | 
| 44 | this._vertical=(this.orientation=="vertical"); | 
| 45 | if(!this._vertical){ | 
| 46 | dojo.addClass(this.containerNode,"dijitInline"); | 
| 47 | this._dir="width"; | 
| 48 | this._edge="left"; | 
| 49 | this._scroll="scrollLeft"; | 
| 50 | }else{
 | 
| 51 | this._dir="height"; | 
| 52 | this._edge="top"; | 
| 53 | this._scroll="scrollTop"; | 
| 54 | } | 
| 55 | if(this._hideAnim){ | 
| 56 | this._hideAnim.play();
 | 
| 57 | } | 
| 58 | dojo.style(this.wrapper,"overflow","hidden"); | 
| 59 | },_set:function(n){ | 
| 60 | if(!this._size){ | 
| 61 | return;
 | 
| 62 | } | 
| 63 | this.wrapper[this._scroll]=Math.floor(this._line.getValue(n)); | 
| 64 | dojo.style(this.helper,this._edge,Math.floor(this._helpLine.getValue(n))+"px"); | 
| 65 | },_calc:function(e){ | 
| 66 | if(!this._lo){ | 
| 67 | this.resize();
 | 
| 68 | } | 
| 69 | this._set(this._vertical?((e.pageY-this._lo.y)/this._lo.h):((e.pageX-this._lo.x)/this._lo.w)); | 
| 70 | },_enter:function(e){ | 
| 71 | if(this._hideAnim){ | 
| 72 | if(this._hideAnim.status()=="playing"){ | 
| 73 | this._hideAnim.stop();
 | 
| 74 | } | 
| 75 | this._showAnim.play();
 | 
| 76 | } | 
| 77 | },_leave:function(e){ | 
| 78 | if(this._hideAnim){ | 
| 79 | this._hideAnim.play();
 | 
| 80 | } | 
| 81 | }}); | 
| 82 | } |