root / trunk / web / dojo / dojox / sketch / Slider.js @ 12
History | View | Annotate | Download (1.24 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.sketch.Slider"]){ |
9 |
dojo._hasResource["dojox.sketch.Slider"]=true; |
10 |
dojo.provide("dojox.sketch.Slider");
|
11 |
dojo.require("dijit.form.HorizontalSlider");
|
12 |
dojo.declare("dojox.sketch.Slider",dojox.sketch._Plugin,{_initButton:function(){ |
13 |
this.slider=new dijit.form.HorizontalSlider({minimum:5,maximum:100,style:"width:100px;float:right"}); |
14 |
this.slider._movable.node.title="Double Click to \"Zoom to Fit\""; |
15 |
this.connect(this.slider,"onChange","_setZoom"); |
16 |
this.connect(this.slider.sliderHandle,"ondblclick","_zoomToFit"); |
17 |
},_zoomToFit:function(){ |
18 |
var r=this.figure.getFit(); |
19 |
this.slider.attr("value",this.slider.maximum<r?this.slider.maximum:(this.slider.minimum>r?this.slider.minimum:r)); |
20 |
},_setZoom:function(v){ |
21 |
if(v&&this.figure){ |
22 |
this.figure.zoom(v);
|
23 |
} |
24 |
},reset:function(){ |
25 |
this.slider.attr("value",this.slider.maximum); |
26 |
this._zoomToFit();
|
27 |
},setToolbar:function(t){ |
28 |
this._initButton();
|
29 |
t.addChild(this.slider);
|
30 |
if(!t._reset2Zoom){
|
31 |
t._reset2Zoom=true;
|
32 |
this.connect(t,"reset","reset"); |
33 |
} |
34 |
}}); |
35 |
dojox.sketch.registerTool("Slider",dojox.sketch.Slider);
|
36 |
} |