Debian Codegraph @

dojox/drawing/ui/dom/Zoom.js

raw symbols SCIP
1 define(["dojo", "../../util/oo", "../../plugins/_Plugin"],
2 function(dojo, oo, Plugin){
3
4 var Zoom = oo.declare(
5 // NOTE:
6 // dojox.drawing.ui.dom.Zoom is DEPRECATED.
7 // This was a temporary DOM solution. Use the non-dom
8 // tools for Toolbar and Plugins.
9
10 // summary:
11 // A plugin that allows for zooming the canvas in and out. An
12 // action-tool is added to the toolbar with plus, minus and 100%
13 // buttons.
14 // example:
15 // | <div dojoType="dojox.drawing.Toolbar" drawingId="drawingNode" class="drawingToolbar vertical">
16 // | <div tool="dojox.drawing.tools.Line" selected="true">Line</div>
17 // | <div plugin="dojox.drawing.ui.dom.Zoom" options="{zoomInc:.1,minZoom:.5,maxZoom:2}">Zoom</div>
18 // | </div>
19
20 Plugin,
21 function(options){
22 var cls = options.node.className;
23 var txt = options.node.innerHTML;
24 this.domNode = dojo.create("div", {id:"btnZoom", "class":"toolCombo"}, options.node, "replace");
25
26 this.makeButton("ZoomIn", this.topClass);
27 this.makeButton("Zoom100", this.midClass);
28 this.makeButton("ZoomOut", this.botClass);
29
30 },
31 {
32 type:"dojox.drawing.ui.dom.Zoom",
33
34 // zoomInc: Float
35 // The amount of zoom that will occur upon each click.
36 zoomInc:.1,
37
38 // maxZoom: Number
39 // The maximum the canvas can be zoomed in. 10 = 1000%
40 maxZoom:10,
41
42 // minZoom: Float
43 // The most the canvas can be zoomed out. .1 = 10%
44 minZoom:.1,
45
46 // zoomFactor: [readonly] Float
47 // The current zoom amount
48 zoomFactor:1,
49
50 // baseClass: String
51 // The CSS class added to the Toolbar buttons
52 baseClass:"drawingButton",
53
54 // topClass: String
55 // The CSS class added to the top (or left) Toolbar button
56 topClass:"toolComboTop",
57
58 // midClass: String
59 // The CSS class added to the middle Toolbar button
60 midClass:"toolComboMid",
61
62 // botClass: String
63 // The CSS class added to the bottom (or right) Toolbar button
64 botClass:"toolComboBot",
65
66 makeButton: function(name, cls){
67 // summary:
68 // Internal. Creates one of the buttons in the zoom-button set.
69
70 var node = dojo.create("div", {id:"btn"+name, "class":this.baseClass+" "+cls,
71 innerHTML:'<div title="Zoom In" class="icon icon'+name+'"></div>'}, this.domNode);
72
73 dojo.connect(document, "mouseup", function(evt){
74 dojo.stopEvent(evt);
75 dojo.removeClass(node, "active");
76 });
77 dojo.connect(node, "mouseup", this, function(evt){
78 dojo.stopEvent(evt);
79 dojo.removeClass(node, "active");
80 this["on"+name](); // this is what calls the methods below
81 });
82 dojo.connect(node, "mouseover", function(evt){
83 dojo.stopEvent(evt);
84 dojo.addClass(node, "hover");
85 });
86 dojo.connect(node, "mousedown", this, function(evt){
87 dojo.stopEvent(evt);
88 dojo.addClass(node, "active");
89 });
90
91 dojo.connect(node, "mouseout", this, function(evt){
92 dojo.stopEvent(evt);
93 dojo.removeClass(node, "hover");
94 });
95
96 },
97
98 onZoomIn: function(/*Mouse Event*/evt){
99 // summary:
100 // Handles zoom in.
101
102 this.zoomFactor += this.zoomInc;
103 this.zoomFactor = Math.min(this.zoomFactor, this.maxZoom);
104 this.canvas.setZoom(this.zoomFactor);
105 this.mouse.setZoom(this.zoomFactor);
106 },
107 onZoom100: function(/*Mouse Event*/evt){
108 // summary:
109 // Zooms to 100%
110
111 this.zoomFactor = 1;
112 this.canvas.setZoom(this.zoomFactor);
113 this.mouse.setZoom(this.zoomFactor);
114 },
115 onZoomOut: function(/*Mouse Event*/evt){
116 // summary:
117 // Handles zoom out.
118
119 this.zoomFactor -= this.zoomInc;
120 this.zoomFactor = Math.max(this.zoomFactor, this.minZoom);
121 this.canvas.setZoom(this.zoomFactor);
122 this.mouse.setZoom(this.zoomFactor);
123 }
124 }
125 );
126
127 dojo.setObject("dojox.drawing.ui.dom.Zoom", Zoom);
128 //dojox.drawing.register(dojox.drawing.plugins.tools.Pan, "plugin");
129
130 return Zoom;
131 });