| 1 |
define(["dojo/_base/lang", "../../util/oo", "../_Plugin", "../../manager/_registry"], |
| 2 |
function(lang, oo, Plugin, registry){ |
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
var zoomInc = Math.pow(2.0,0.25), |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
maxZoom = 10, |
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
minZoom = 0.1, |
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
zoomFactor = 1, |
| 19 |
dt; |
| 20 |
|
| 21 |
if(!lang.getObject('dojox.drawing.plugins.tools')){ |
| 22 |
lang.setObject('dojox.drawing.plugins.tools', {}); |
| 23 |
} |
| 24 |
dt = dojox.drawing.plugins.tools; |
| 25 |
|
| 26 |
dt.ZoomIn = oo.declare( |
| 27 |
|
| 28 |
Plugin, |
| 29 |
function(options){ |
| 30 |
|
| 31 |
}, |
| 32 |
{ |
| 33 |
type:"dojox.drawing.plugins.tools.ZoomIn", |
| 34 |
onZoomIn: function(){ |
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
zoomFactor *= zoomInc; |
| 39 |
zoomFactor = Math.min(zoomFactor, maxZoom); |
| 40 |
this.canvas.setZoom(zoomFactor); |
| 41 |
this.mouse.setZoom(zoomFactor); |
| 42 |
}, |
| 43 |
onClick: function(){ |
| 44 |
this.onZoomIn(); |
| 45 |
} |
| 46 |
} |
| 47 |
); |
| 48 |
|
| 49 |
dt.Zoom100 = oo.declare( |
| 50 |
|
| 51 |
Plugin, |
| 52 |
function(options){ |
| 53 |
|
| 54 |
}, |
| 55 |
{ |
| 56 |
type:"dojox.drawing.plugins.tools.Zoom100", |
| 57 |
onZoom100: function(){ |
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
zoomFactor = 1; |
| 62 |
this.canvas.setZoom(zoomFactor); |
| 63 |
this.mouse.setZoom(zoomFactor); |
| 64 |
}, |
| 65 |
onClick: function(){ |
| 66 |
this.onZoom100(); |
| 67 |
} |
| 68 |
} |
| 69 |
); |
| 70 |
|
| 71 |
dt.ZoomOut = oo.declare( |
| 72 |
|
| 73 |
Plugin, |
| 74 |
function(options){ |
| 75 |
|
| 76 |
}, |
| 77 |
{ |
| 78 |
type:"dojox.drawing.plugins.tools.ZoomOut", |
| 79 |
onZoomOut: function(){ |
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
zoomFactor /= zoomInc; |
| 84 |
zoomFactor = Math.max(zoomFactor, minZoom); |
| 85 |
this.canvas.setZoom(zoomFactor); |
| 86 |
this.mouse.setZoom(zoomFactor); |
| 87 |
}, |
| 88 |
onClick: function(){ |
| 89 |
this.onZoomOut(); |
| 90 |
} |
| 91 |
} |
| 92 |
); |
| 93 |
|
| 94 |
|
| 95 |
dt.ZoomIn.setup = { |
| 96 |
name:"dojox.drawing.plugins.tools.ZoomIn", |
| 97 |
tooltip:"Zoom In" |
| 98 |
}; |
| 99 |
registry.register(dt.ZoomIn.setup, "plugin"); |
| 100 |
|
| 101 |
dt.Zoom100.setup = { |
| 102 |
name:"dojox.drawing.plugins.tools.Zoom100", |
| 103 |
tooltip:"Zoom to 100%" |
| 104 |
}; |
| 105 |
registry.register(dt.Zoom100.setup, "plugin"); |
| 106 |
|
| 107 |
dt.ZoomOut.setup = { |
| 108 |
name:"dojox.drawing.plugins.tools.ZoomOut", |
| 109 |
tooltip:"Zoom In" |
| 110 |
}; |
| 111 |
registry.register(dt.ZoomOut.setup, "plugin"); |
| 112 |
|
| 113 |
return dt; |
| 114 |
|
| 115 |
}); |