Added LSformElement :: postaladdress

This commit is contained in:
Benjamin Renard 2011-04-11 11:23:24 +02:00
parent 3af8351a36
commit 53e12f2cb2
5 changed files with 174 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 447 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 842 B

View file

@ -0,0 +1,36 @@
<?php
/*******************************************************************************
* Copyright (C) 2007 Easter-eggs
* http://ldapsaisie.labs.libre-entreprise.org
*
* Author: See AUTHORS file in top-level directory.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
******************************************************************************/
LSsession :: loadLSclass('LSattr_html_textarea');
/**
* Type d'attribut HTML postaladdress
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*/
class LSattr_html_postaladdress extends LSattr_html_textarea {
var $LSformElement_type = 'postaladdress';
}
?>

View file

@ -0,0 +1,63 @@
<?php
/*******************************************************************************
* Copyright (C) 2007 Easter-eggs
* http://ldapsaisie.labs.libre-entreprise.org
*
* Author: See AUTHORS file in top-level directory.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
******************************************************************************/
LSsession :: loadLSclass('LSformElement_textarea');
/**
* Element postaladdress d'un formulaire pour LdapSaisie
*
* @author Benjamin Renard <brenard@easter-eggs.com>
*/
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;
}
}
?>

View file

@ -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();
});