1 /**
  2 * @fileOverview  
  3 * Copyright (c) 2013 Regione Autonoma della Sardegna
  4 * Published under the GPL license.<br>
  5 * See <a href="https://sardegnageoportale.it/webgis/license.txt">https://sardegnageoportale.it/webgis/license.txt</a>
  6 * for the full text of the license.
  7 * @version 0.1
  8 */
  9 
 10 /**
 11  * @requires plugins/Tool.js
 12  * @require OpenLayers/Control/ZoomBox.js
 13  * @require GeoExt/widgets/Action.js
 14  */
 15 
 16 /**
 17  * @namespace framework.plugins
 18  */
 19 Ext.namespace("framework.plugins");
 20 
 21 /** 
 22  *  Provides actions for box zooming, zooming in and zooming out.
 23  *  @name_ ZoomBoxAction
 24  *  @class Provides actions for box zooming, zooming in and zooming out.
 25  *  @constructor
 26  *  @extends <a target="_blank" href="http://gxp.opengeo.org/master/doc/lib/plugins/Tool.html">gxp.plugins.Tool</a>
 27  */
 28 framework.plugins.ZoomBoxAction = Ext.extend(gxp.plugins.Tool, 
 29 /** 
 30  * @lends framework.plugins.ZoomBoxAction.prototype 
 31  */
 32 {
 33     /**
 34     * framework_zoomboxaction plugin type.
 35     * @public
 36     * @type String
 37     */
 38     ptype: "framework_zoomboxaction",
 39     
 40     /**
 41     * Text for zoom box menu item (i18n).
 42     * @public
 43     * @type string
 44     */
 45     zoomMenuText: "Zoom Box",
 46     
 47     /**
 48     * Text for zoom in menu item (i18n).
 49     * @public
 50     * @type string
 51     */
 52     zoomInMenuText: "Zoom In",
 53     
 54     /**
 55     * Text for zoom out menu item (i18n).
 56     * @public
 57     * @type string
 58     */
 59     zoomOutMenuText: "Zoom Out",
 60     
 61     /**
 62     * Text for zoom box action tooltip (i18n).
 63     * @public
 64     * @type string
 65     */
 66     zoomTooltip: "Zoom by dragging a box",
 67     
 68     /**
 69     * Text for zoom in action tooltip (i18n).
 70     * @public
 71     * @type string
 72     */
 73     zoomInTooltip: "Zoom in",
 74     
 75     /**
 76     *  Text for zoom out action tooltip (i18n).
 77     * @public
 78     * @type string
 79     */
 80     zoomOutTooltip: "Zoom out",
 81 
 82     /**
 83     * @private
 84     * @param {Object} config configuration object
 85     */ 
 86     constructor: function(config) {
 87         framework.plugins.ZoomBoxAction.superclass.constructor.apply(this, arguments);
 88     },
 89             
 90     /**
 91     * Create and append zoom-in action, zoom-out action, and zoomBox action
 92     * @public
 93     * @returns {framework.plugins.ZoomBoxAction} Object with zoom controls inside
 94     */ 
 95     addActions: function() {
 96 
 97         if (this.showZoomInOut) {
 98             var actions = [{
 99                     menuText: this.zoomInMenuText,
100                     iconCls: "gxp-icon-zoom-in",
101                     tooltip: this.zoomInTooltip,
102                     handler: function() {
103                         this.target.mapPanel.map.zoomIn();
104                     },
105                     scope: this
106                 }, {
107                     menuText: this.zoomOutMenuText,
108                     iconCls: "gxp-icon-zoom-out",
109                     tooltip: this.zoomOutTooltip,
110                     handler: function() {
111                         this.target.mapPanel.map.zoomOut();
112                     },
113                     scope: this
114                 }];
115         }
116         else {
117             var actions = [];
118         }
119         if (this.showZoomBoxAction) {
120             actions.unshift(new GeoExt.Action({
121                 menuText: this.zoomText,
122                 iconCls: "gxp-icon-zoom",
123                 tooltip: this.zoomTooltip,
124                 control: new OpenLayers.Control.ZoomBox(this.controlOptions),
125                 map: this.target.mapPanel.map,
126                 enableToggle: true,
127                 allowDepress: true,
128                 toggleGroup: this.toggleGroup
129             }));
130         }
131         return framework.plugins.ZoomBoxAction.superclass.addActions.apply(this, [actions]);
132     }
133 
134 });
135 
136 Ext.preg(framework.plugins.ZoomBoxAction.prototype.ptype, framework.plugins.ZoomBoxAction);
137