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 * Popup to show informations and metadata linker. 17 * Parameters in config object are used to populate the rows (excepts for metadata parameter) 18 * @name_ InfoMetaPopup 19 * @class InfoMetaPopup 20 * @constructor 21 * @extends <a target="_blank" href="http://gxp.opengeo.org/master/doc/lib/plugins/Tool.html">gxp.plugins.Tool</a> 22 */ 23 framework.plugins.InfoMetaPopup = Ext.extend(gxp.plugins.Tool, 24 /** 25 * @lends framework.plugins.InfoMetaPopup.prototype 26 */ 27 { 28 /** 29 * @cfg {String} metadata 30 * Link to metadata (opened on button click) 31 */ 32 /** 33 * @cfg {int} width 34 * Width of the window. It's not mandatory, 35 * if it's not specified default value will be used. 36 * Link to metadata (opened on button click) 37 */ 38 /** 39 * @cfg {int} height 40 * Height of the window. It's not mandatory, 41 * if it's not specified default value will be used. 42 */ 43 /** 44 * plugin type. 45 * @public 46 * @type String 47 */ 48 ptype: "framework_infometapopup", 49 /** 50 * Window width (default 240) 51 * @private 52 * @type int 53 */ 54 _width:240, 55 /** 56 * Window height (default 180) 57 * @private 58 * @type int 59 */ 60 _height: 300, 61 /** 62 * Text to show as rows info 63 * @private 64 * @type String 65 */ 66 _rowText: "", 67 /** 68 * Metadata link 69 * @private 70 * @type String 71 */ 72 _metadata: null, 73 /** 74 * Text metadata link 75 * @private 76 * @type String 77 */ 78 _textmetadata: "scheda metadato", 79 /** 80 * @private 81 * @param {Object} config configuration 82 */ 83 constructor: function(config) { 84 for (var property in config) { 85 if (config.hasOwnProperty(property)) { 86 if (property === 'metadata') { 87 this._metadata = config[property]; 88 } else if (property === 'width') { 89 this._width = config[property]; 90 } else if (property === 'height') { 91 this._height = config[property]; 92 } else if (property === 'titolo') { 93 var value = (Ext.isDefined(config[property])) ? config[property] : ''; 94 this._rowText += '<b>' + value + '</b><br/><br/>'; 95 } else { 96 var value = (Ext.isDefined(config[property])) ? config[property] : ''; 97 this._rowText += '<b>'+property+'</b>: ' + value + '<br/>'; 98 } 99 } 100 } 101 // Call our superclass constructor to complete 102 // construction process. 103 framework.plugins.ClickableAttribution.superclass.constructor.apply(this, arguments); 104 }, 105 /** 106 * Opens the window 107 * @public 108 */ 109 show: function() { 110 var text = '<p style="text-align: left;">'+this._rowText+'</p>'; 111 text += '<p class="buttonRow">'; 112 var cls = (Ext.isDefined(this._metadata)) ? 'roundedButton' : 'roundedButtonDisabled'; 113 text += '<span class="' + cls + '" style="width: 151px; height: 53px;"'; 114 if (Ext.isDefined(this._metadata)) { 115 //action to be used to open metadata 116 text += ' onclick="window.open(\''+this._metadata+'\');"'; 117 } 118 text += '>'+this._textmetadata+'</span></p>'; 119 var info = new Ext.Panel({ 120 html: '<div class="gx-info-panel">' + text + '</div>', 121 height: 'auto', 122 width: 'auto' 123 }); 124 125 var win = new Ext.Window({ 126 title: "Informazioni", 127 modal: true, 128 layout: "fit", 129 width: this._width, 130 height: 'auto', 131 items: [info] 132 }); 133 win.show(); 134 } 135 }); 136 137 Ext.preg(framework.plugins.InfoMetaPopup.prototype.ptype, framework.plugins.InfoMetaPopup); 138