Rev | Line | |
---|
[483] | 1 | define([ |
---|
| 2 | "dojo/_base/kernel", |
---|
| 3 | "dojo/_base/lang", |
---|
| 4 | "dojo/_base/declare", |
---|
| 5 | "dijit/form/HorizontalSlider", |
---|
| 6 | "./_Plugin" |
---|
| 7 | ], function(dojo){ |
---|
| 8 | dojo.getObject("sketch", true, dojox); |
---|
| 9 | dojo.declare("dojox.sketch.Slider", dojox.sketch._Plugin,{ |
---|
| 10 | _initButton: function(){ |
---|
| 11 | this.slider=new dijit.form.HorizontalSlider({minimum:5,maximum:100,style:"width:100px;",baseClass:'dijitInline dijitSlider'}); |
---|
| 12 | this.slider._movable.node.title='Double Click to "Zoom to Fit"'; //I18N |
---|
| 13 | this.connect(this.slider,'onChange','_setZoom'); |
---|
| 14 | this.connect(this.slider.sliderHandle,'ondblclick','_zoomToFit'); |
---|
| 15 | }, |
---|
| 16 | _zoomToFit: function(){ |
---|
| 17 | var r=this.figure.getFit(); |
---|
| 18 | this.slider.attr('value',this.slider.maximum<r?this.slider.maximum:(this.slider.minimum>r?this.slider.minimum:r)); |
---|
| 19 | }, |
---|
| 20 | _setZoom: function(v){ |
---|
| 21 | if(v && this.figure){ |
---|
| 22 | this.figure.zoom(v); |
---|
| 23 | } |
---|
| 24 | }, |
---|
| 25 | reset: function(){ |
---|
| 26 | //reset slider to maximum so that onChange will be fired when _zoomToFit is called |
---|
| 27 | this.slider.attr('value',this.slider.maximum); |
---|
| 28 | this._zoomToFit(); |
---|
| 29 | }, |
---|
| 30 | setToolbar: function(t){ |
---|
| 31 | this._initButton(); |
---|
| 32 | t.addChild(this.slider); |
---|
| 33 | if(!t._reset2Zoom){ |
---|
| 34 | t._reset2Zoom=true; |
---|
| 35 | this.connect(t,'reset','reset'); |
---|
| 36 | } |
---|
| 37 | } |
---|
| 38 | }); |
---|
| 39 | |
---|
| 40 | dojox.sketch.registerTool("Slider", dojox.sketch.Slider); |
---|
| 41 | return dojox.sketch.Slider; |
---|
| 42 | }); |
---|
Note: See
TracBrowser
for help on using the repository browser.