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 * @namespace framework.plugins 12 */ 13 Ext.namespace("framework.plugins"); 14 15 /** 16 * Provides control for getting Latitude and Longitude of a click point. 17 * @name_ LinkToLayerWebSite 18 * @class Provides control for getting Latitude and Longitude of a click point. 19 * @constructor 20 * @extends <a target="_blank" href="http://gxp.opengeo.org/master/doc/lib/plugins/Tool.html">gxp.plugins.Tool</a> 21 */ 22 framework.plugins.MetaDataLinker = Ext.extend(gxp.plugins.Tool, 23 /** 24 * @lends framework.plugins.MetaDataLinker.prototype 25 */ 26 { 27 28 /** 29 * framework_metadatalinker plugin type. 30 * @public 31 * @type String 32 */ 33 ptype: "framework_metadatalinker", 34 35 /** 36 * Menu text item (i18n). 37 * @public 38 * @type string 39 */ 40 menuText: "Vai alla scheda metadato", 41 42 /** 43 * Tooltip text item (i18n). 44 * @public 45 * @type string 46 */ 47 tooltip: "Vai alla scheda metadato", 48 49 /** 50 * The target extent. If none is provided, the map's visible extent will be used. 51 * @public 52 * @type Array | OpenLayers.Bounds 53 */ 54 extent: null, 55 56 /** 57 * Button image 58 * @public 59 * @type string 60 */ 61 iconCls: "gxp-icon-metadata", 62 63 /** 64 * @private 65 * @param {Object} config configuration object 66 */ 67 constructor: function(config) { 68 framework.plugins.MetaDataLinker.superclass.constructor.apply(this, arguments); 69 }, 70 71 /** 72 * Create and append a click action 73 * @public 74 * @returns {framework.plugins.MenuPlugins} Object with MetaDataLinker control inside 75 */ 76 addActions: function() { 77 var selectedLayer; 78 79 this.target.on("layerselectionchange", function(record) { 80 selectedLayer = record; 81 if(selectedLayer && selectedLayer.data.metadataURLs 82 && selectedLayer.data.metadataURLs.length > 0 && selectedLayer.data.metadataURLs[0].href.length > 0) 83 this.actions[0].setDisabled(false); 84 else 85 this.actions[0].setDisabled(true); 86 }, this); 87 88 return framework.plugins.MetaDataLinker.superclass.addActions.apply(this, [{ 89 text: this.buttonText, 90 menuText: this.menuText, 91 iconCls: this.iconCls, 92 tooltip: this.tooltip, 93 handler: function() { 94 window.open(selectedLayer.data.metadataURLs[0].href); 95 }, 96 scope: this 97 }]); 98 } 99 100 }); 101 102 Ext.preg(framework.plugins.MetaDataLinker.prototype.ptype, framework.plugins.MetaDataLinker); 103