diff --git a/public_html/images/black/map_go.png b/public_html/images/black/map_go.png new file mode 100644 index 00000000..acd1091b Binary files /dev/null and b/public_html/images/black/map_go.png differ diff --git a/public_html/images/default/map_go.png b/public_html/images/default/map_go.png new file mode 100644 index 00000000..11eab26d Binary files /dev/null and b/public_html/images/default/map_go.png differ diff --git a/public_html/includes/class/class.LSattr_html_postaladdress.php b/public_html/includes/class/class.LSattr_html_postaladdress.php new file mode 100644 index 00000000..208efe0c --- /dev/null +++ b/public_html/includes/class/class.LSattr_html_postaladdress.php @@ -0,0 +1,36 @@ + + */ +class LSattr_html_postaladdress extends LSattr_html_textarea { + + var $LSformElement_type = 'postaladdress'; + +} + +?> diff --git a/public_html/includes/class/class.LSformElement_postaladdress.php b/public_html/includes/class/class.LSformElement_postaladdress.php new file mode 100644 index 00000000..7d1fd4f5 --- /dev/null +++ b/public_html/includes/class/class.LSformElement_postaladdress.php @@ -0,0 +1,63 @@ + + */ + +class LSformElement_postaladdress extends LSformElement_textarea { + + var $fieldTemplateExtraClass = 'LSformElement_postaladdress'; + + /** + * Retourne les infos d'affichage de l'élément + * + * Cette méthode retourne les informations d'affichage de l'élement + * + * @retval array + */ + function getDisplay(){ + $return = parent :: getDisplay(); + if ($this -> isFreeze()) { + if (isset($this -> params['html_options']['map_url_format']) && !empty($this->values)) { + LSsession :: addJSconfigParam('LSformElement_postaladdress_'.$this -> name, array ( + 'map_url' => $this -> attr_html -> attribute -> ldapObject -> getFData($this -> params['html_options']['map_url_format']) + ) + ); + LSsession :: addHelpInfos( + 'LSformElement_postaladdress', + array( + 'viewOnMap' => _('View on map') + ) + ); + LSsession :: addJSscript('LSformElement_postaladdress.js'); + } + } + return $return; + } +} + +?> diff --git a/public_html/includes/js/LSformElement_postaladdress.js b/public_html/includes/js/LSformElement_postaladdress.js new file mode 100644 index 00000000..a2c9f3bb --- /dev/null +++ b/public_html/includes/js/LSformElement_postaladdress.js @@ -0,0 +1,75 @@ +var LSformElement_postaladdress = new Class({ + initialize: function(){ + this.initialiseLSformElement_postaladdress(); + if (typeof(varLSform) != "undefined") { + varLSform.addModule("LSformElement_postaladdress",this); + } + }, + + initialiseLSformElement_postaladdress: function(el) { + if (typeof(el) == 'undefined') { + el = document; + } + el.getElements('p.LSformElement_postaladdress').each(function(p) { + this.addBtnAfter.bind(this)(p); + }, this); + }, + + getFieldName: function(el) { + try { + var name = el.getParent().getParent().id; + return name; + } + catch (err) { + LSdebug(err); + } + return; + }, + + getFieldParams: function(el) { + var name = this.getFieldName(el); + if (typeof(varLSdefault.LSjsConfig['LSformElement_postaladdress_'+name]) != "undefined") { + var params = varLSdefault.LSjsConfig['LSformElement_postaladdress_'+name]; + if (typeof(params)!="undefined") { + return params; + } + } + return; + }, + + addBtnAfter: function(el) { + var name = this.getFieldName(el); + if (typeof(varLSdefault.LSjsConfig['LSformElement_postaladdress_'+name]) == "undefined") { + return; + } + var btn = new Element('img'); + btn.setProperties({ + src: varLSdefault.imagePath('map_go.png'), + alt: 'View on map' + }); + btn.addClass('btn'); + btn.setStyle('float','left'); + btn.injectBefore(el); + btn.addEvent('click',this.onBtnClick.bind(this,el)); + varLSdefault.addHelpInfo(btn,'LSformElement_postaladdress','viewOnMap'); + }, + + reinitialize: function(el) { + varLSform.initializeModule('LSformElement_textarea',el); + this.initialiseLSformElement_postaladdress(el); + }, + + onBtnClick: function(el) { + var address = el.get('html'); + if (typeof(address)!="undefined") { + var params = this.getFieldParams(el); + if (params && typeof(params.map_url)!="undefined") { + href = params.map_url; + } + window.open(href,'_blank'); + } + } +}); +window.addEvent(window.ie ? 'load' : 'domready', function() { + varLSformElement_postaladdress = new LSformElement_postaladdress(); +});