mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-22 18:09:06 +01:00
- LSform.js :
-> Refonte complète pour coller au plus près de la réalité -> Création des classes LSformElement et LSformElement_field - LSsession : -> Méthode fetchTemplate() : retourne un template compilé - LSformElement : -> Méthode fetchTemplate() : Utilisation des templates pour l'affichage des LSformElement. -> Méthode isMultiple() -> getEmptyField() : méthode d'affichage par défaut d'un champs vide - LSformElement_textarea : -> Utilisation des templates pour l'affichage -> Ajout d'un bouton clear() - LSformElement_text : -> Utilisation des templates pour l'affichage -> Adpatation pour pouvoir faire des classes filles. Celles-ci hériteront des fonctionnalités des champs textes classiques -> La méthode de génération est maintenant appliqué à tout les champs et non plus simplement au premier - LSformElement_mail : -> Refonte en utilisant l'héritage de LSformElement_text
This commit is contained in:
parent
d7b65d3455
commit
cc0a009b63
20 changed files with 297 additions and 187 deletions
|
@ -269,7 +269,7 @@ $GLOBALS['LSobjects']['LSeepeople'] = array (
|
|||
'mail' => array (
|
||||
'label' => _('Adresse e-mail'),
|
||||
'ldap_type' => 'ascii',
|
||||
'html_type' => 'text',
|
||||
'html_type' => 'mail',
|
||||
'html_options' => array(
|
||||
'generate_value_format' => '%{givenName}.%{sn}@ls.com',
|
||||
'withoutAccent' => 1,
|
||||
|
@ -320,6 +320,7 @@ $GLOBALS['LSobjects']['LSeepeople'] = array (
|
|||
'label' => _('Description'),
|
||||
'ldap_type' => 'ascii',
|
||||
'html_type' => 'textarea',
|
||||
'multiple' => 1,
|
||||
'rights' => array(
|
||||
'self' => 'w',
|
||||
'user' => 'r',
|
||||
|
|
|
@ -76,6 +76,8 @@ class LSform {
|
|||
$GLOBALS['LSsession'] -> addJSscript('LSview.js');
|
||||
}
|
||||
else {
|
||||
$GLOBALS['LSsession'] -> addJSscript('LSformElement_field.js');
|
||||
$GLOBALS['LSsession'] -> addJSscript('LSformElement.js');
|
||||
$GLOBALS['LSsession'] -> addJSscript('LSform.js');
|
||||
}
|
||||
$GLOBALS['LSsession'] -> addCssFile('LSform.css');
|
||||
|
|
|
@ -38,6 +38,8 @@ class LSformElement {
|
|||
var $_required = false;
|
||||
var $_freeze = false;
|
||||
var $attr_html;
|
||||
var $fieldTemplate = 'LSformElement_field.tpl';
|
||||
var $template = 'LSformElement.tpl';
|
||||
|
||||
/**
|
||||
* Constructeur
|
||||
|
@ -272,6 +274,10 @@ class LSformElement {
|
|||
}
|
||||
}
|
||||
|
||||
function isMultiple() {
|
||||
return ($this -> params['multiple'] == true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne le titre du champ
|
||||
*
|
||||
|
@ -280,6 +286,44 @@ class LSformElement {
|
|||
function getTitle() {
|
||||
return $this -> form -> ldapObject -> getDisplayValue().' - '.$this -> getLabel();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retournne un template Smarty compilé dans le contexte d'un LSformElement
|
||||
*
|
||||
* @param[in] string $template Le template à retourner
|
||||
* @param[in] array $variables Variables Smarty à assigner avant l'affichage
|
||||
*
|
||||
* @retval string Le HTML compilé du template
|
||||
*/
|
||||
function fetchTemplate($template=NULL,$variables=array()) {
|
||||
if (!$template) {
|
||||
$template = $this -> template;
|
||||
}
|
||||
return $GLOBALS['LSsession'] -> fetchTemplate(
|
||||
$template,
|
||||
array_merge_recursive(
|
||||
$variables,
|
||||
array(
|
||||
'freeze' => $this -> isFreeze(),
|
||||
'multiple'=> $this -> isMultiple(),
|
||||
'value' => '',
|
||||
'values' => $this -> values,
|
||||
'attr_name' => $this -> name,
|
||||
'noValueTxt' => _('Aucune valeur definie'),
|
||||
'fieldTemplate' => $this -> fieldTemplate
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne le code HTML d'un champ vide
|
||||
*
|
||||
* @retval string Code HTML d'un champ vide.
|
||||
*/
|
||||
function getEmptyField() {
|
||||
return $this -> fetchTemplate($this -> fieldTemplate);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -30,62 +30,19 @@
|
|||
* @author Benjamin Renard <brenard@easter-eggs.com>
|
||||
*/
|
||||
|
||||
class LSformElement_mail extends LSformElement {
|
||||
class LSformElement_mail extends LSformElement_text {
|
||||
|
||||
/**
|
||||
* 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 = $this -> getLabelInfos();
|
||||
// value
|
||||
if (!$this -> isFreeze()) {
|
||||
$return['html'] = "<ul class='LSform'>\n";
|
||||
if (empty($this -> values)) {
|
||||
$return['html'] .= "<li>".$this -> getEmptyField()."</li>\n";
|
||||
}
|
||||
else {
|
||||
foreach ($this -> values as $value) {
|
||||
$multiple = $this -> getMultipleData();
|
||||
$id = "LSform_".$this -> name."_".rand();
|
||||
$return['html'] .= "<li><input class='LSformElement_mail' type='text' name='".$this -> name."[]' value=\"".$value."\" id='".$id."'>$multiple</li>\n";
|
||||
}
|
||||
}
|
||||
$return['html'] .= "</ul>\n";
|
||||
}
|
||||
else {
|
||||
$return['html'] = "<ul class='LSform'>\n";
|
||||
if (empty($this -> values)) {
|
||||
$return['html'] .= "<li>"._('Aucune valeur definie')."</li>\n";
|
||||
}
|
||||
else {
|
||||
foreach ($this -> values as $value) {
|
||||
$return['html'] .= "<li><a class='LSformElement_mail' href='mailto:".$value."'>".$value."</a></li>\n";
|
||||
}
|
||||
}
|
||||
$return['html'] .= "</ul>\n";
|
||||
}
|
||||
$GLOBALS['LSsession'] -> addJSscript('LSmail.js');
|
||||
$GLOBALS['LSsession'] -> addJSscript('LSsmoothbox.js');
|
||||
$GLOBALS['LSsession'] -> addCssFile('LSsmoothbox.css');
|
||||
$GLOBALS['LSsession'] -> addJSscript('LSconfirmBox.js');
|
||||
$GLOBALS['LSsession'] -> addCssFile('LSconfirmBox.css');
|
||||
$GLOBALS['LSsession'] -> addJSscript('LSformElement_mail.js');
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne le code HTML d'un champ vide
|
||||
*
|
||||
* @retval string Code HTML d'un champ vide.
|
||||
*/
|
||||
function getEmptyField() {
|
||||
$multiple = $this -> getMultipleData();
|
||||
return "<input type='text' class='LSformElement_mail' name='".$this -> name."[]' id='LSform_".$this -> name."_".rand()."'/>".$multiple;
|
||||
}
|
||||
var $JSscripts = array(
|
||||
'LSmail.js',
|
||||
'LSsmoothbox.js',
|
||||
'LSconfirmBox.js',
|
||||
'LSformElement_mail.js'
|
||||
);
|
||||
var $CSSfiles = array(
|
||||
'LSsmoothbox.css',
|
||||
'LSconfirmBox.css'
|
||||
);
|
||||
var $fieldTemplate = 'LSformElement_mail_field.tpl';
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -32,6 +32,10 @@
|
|||
|
||||
class LSformElement_text extends LSformElement {
|
||||
|
||||
var $JSscripts = array();
|
||||
var $CSSfiles = array();
|
||||
var $fieldTemplate = 'LSformElement_text_field.tpl';
|
||||
|
||||
/**
|
||||
* Retourne les infos d'affichage de l'élément
|
||||
*
|
||||
|
@ -43,48 +47,21 @@ class LSformElement_text extends LSformElement {
|
|||
$return = $this -> getLabelInfos();
|
||||
// value
|
||||
if (!$this -> isFreeze()) {
|
||||
$return['html'] = "<ul class='LSform LSformElement_text'>\n";
|
||||
if (isset($this -> params['html_options'])) {
|
||||
$GLOBALS['LSsession'] -> addJSconfigParam($this -> name,$this -> params['html_options']);
|
||||
}
|
||||
if (empty($this -> values)) {
|
||||
$return['html'] .= "<li>".$this -> getEmptyField()."</li>\n";
|
||||
}
|
||||
else {
|
||||
foreach ($this -> values as $value) {
|
||||
$multiple = $this -> getMultipleData();
|
||||
$id = "LSform_".$this -> name."_".rand();
|
||||
$return['html'] .= "<li><input type='text' name='".$this -> name."[]' value=\"".$value."\" id='".$id."' class='LSformElement_text' />".$multiple."</li>\n";
|
||||
}
|
||||
}
|
||||
$return['html'] .= "</ul>\n";
|
||||
$GLOBALS['LSsession'] -> addJSscript('LSformElement_text_field.js');
|
||||
$GLOBALS['LSsession'] -> addJSscript('LSformElement_text.js');
|
||||
}
|
||||
else {
|
||||
$return['html'] = "<ul class='LSform LSformElement_text'>\n";
|
||||
if (empty($this -> values)) {
|
||||
$return['html'] .= "<li><span class='LSformElement_text'>"._('Aucune valeur definie')."</span><input type='hidden' name='".$this -> name."[]' class='LSformElement_text' value=''/></li>\n";
|
||||
foreach ($this -> JSscripts as $js) {
|
||||
$GLOBALS['LSsession'] -> addJSscript($js);
|
||||
}
|
||||
else {
|
||||
foreach ($this -> values as $value) {
|
||||
$return['html'] .= "<li><span class='LSformElement_text'>".$value."</span><input type='hidden' name='".$this -> name."[]' class='LSformElement_text' value=\"$value\"/></li>\n";
|
||||
}
|
||||
}
|
||||
$return['html'] .= "</ul>\n";
|
||||
foreach ($this -> CSSfiles as $css) {
|
||||
$GLOBALS['LSsession'] -> addCssFile($css);
|
||||
}
|
||||
$return['html'] = $this -> fetchTemplate();
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne le code HTML d'un champ vide
|
||||
*
|
||||
* @retval string Code HTML d'un champ vide.
|
||||
*/
|
||||
function getEmptyField() {
|
||||
$multiple = $this -> getMultipleData();
|
||||
return "<input type='text' name='".$this -> name."[]' id='LSform_".$this -> name."_".rand()."' class='LSformElement_text' />".$multiple;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -32,6 +32,8 @@
|
|||
|
||||
class LSformElement_textarea extends LSformElement {
|
||||
|
||||
var $fieldTemplate = 'LSformElement_textarea_field.tpl';
|
||||
|
||||
/**
|
||||
* Retourne les infos d'affichage de l'élément
|
||||
*
|
||||
|
@ -41,44 +43,12 @@ class LSformElement_textarea extends LSformElement {
|
|||
*/
|
||||
function getDisplay(){
|
||||
$return = $this -> getLabelInfos();
|
||||
// value
|
||||
$return['html'] = "<ul class='LSform'>\n";
|
||||
if (!$this -> isFreeze()) {
|
||||
if (empty($this -> values)) {
|
||||
$return['html'] .= "<li>".$this -> getEmptyField()."</li>\n";
|
||||
$GLOBALS['LSsession'] -> addJSscript('LSformElement_textarea.js');
|
||||
}
|
||||
else {
|
||||
foreach($this -> values as $value) {
|
||||
$multiple = $this -> getMultipleData();
|
||||
$id = "LSform_".$this -> name."_".rand();
|
||||
$return['html'].="<li><textarea name='".$this -> name."[]' id='".$id."' class='LSform'>".$value."</textarea>\n".$multiple."</li>";
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (empty($this -> values)) {
|
||||
$return['html'].="<li>"._('Aucune valeur definie')."</li>\n";
|
||||
}
|
||||
else {
|
||||
foreach ($this -> values as $value) {
|
||||
$return['html'].="<li>".$value."</li>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
$return['html'] .= "</ul>\n";
|
||||
$return['html'] = $this -> fetchTemplate();
|
||||
return $return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retourne le code HTML d'un champ vide
|
||||
*
|
||||
* @retval string Code HTML d'un champ vide.
|
||||
*/
|
||||
function getEmptyField() {
|
||||
$multiple = $this -> getMultipleData();
|
||||
return "<textarea name='".$this -> name."[]' id='LSform".$this -> name."_".rand()."' class='LSform'></textarea>\n".$multiple;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -947,6 +947,21 @@ class LSsession {
|
|||
$GLOBALS['Smarty'] -> display($this -> template);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retournne un template Smarty compilé
|
||||
*
|
||||
* @param[in] string $template Le template à retourner
|
||||
* @param[in] array $variables Variables Smarty à assigner avant l'affichage
|
||||
*
|
||||
* @retval string Le HTML compilé du template
|
||||
*/
|
||||
function fetchTemplate($template,$variables=array()) {
|
||||
foreach($variables as $name => $val) {
|
||||
$GLOBALS['Smarty'] -> assign($name,$val);
|
||||
}
|
||||
return $GLOBALS['Smarty'] -> fetch($template);
|
||||
}
|
||||
|
||||
/**
|
||||
* Charge les droits LS de l'utilisateur
|
||||
*
|
||||
|
|
|
@ -1,19 +1,22 @@
|
|||
var LSform = new Class({
|
||||
initialize: function(){
|
||||
this._modules=[];
|
||||
this.initializeLSform_AddAndRemoveBtns();
|
||||
this.LStips = new Tips('.LStips');
|
||||
this._elements=[];
|
||||
|
||||
this.objecttype = $('LSform_objecttype').value,
|
||||
this.objectdn = $('LSform_objectdn').value,
|
||||
this.idform = $('LSform_idform').value,
|
||||
|
||||
this.initializeLSform();
|
||||
},
|
||||
|
||||
initializeLSform_AddAndRemoveBtns: function(el) {
|
||||
initializeLSform: function(el) {
|
||||
this.LStips = new Tips('.LStips');
|
||||
if (typeof(el) == 'undefined') {
|
||||
el = document;
|
||||
}
|
||||
el.getElements('img[class=LSform-add-field-btn]').each(function(btn) {
|
||||
btn.addEvent('click',this.onAddFieldBtnClick.bind(this,btn));
|
||||
}, this);
|
||||
el.getElements('img[class=LSform-remove-field-btn]').each(function(btn) {
|
||||
btn.addEvent('click',this.onRemoveFieldBtnClick.bind(this,btn));
|
||||
el.getElements('ul.LSform').each(function(ul) {
|
||||
this._elements[ul.id] = new LSformElement(this,ul.id,ul);
|
||||
}, this);
|
||||
},
|
||||
|
||||
|
@ -21,53 +24,16 @@ var LSform = new Class({
|
|||
this._modules[name]=obj;
|
||||
},
|
||||
|
||||
onAddFieldBtnClick: function(img){
|
||||
var getAttrName = /LSform_add_field_btn_(.*)_.*/
|
||||
var attrName = getAttrName.exec(img.id)[1];
|
||||
LSdebug(attrName);
|
||||
|
||||
var data = {
|
||||
template: 'LSform',
|
||||
action: 'onAddFieldBtnClick',
|
||||
attribute: attrName,
|
||||
objecttype: $('LSform_objecttype').value,
|
||||
objectdn: $('LSform_objectdn').value,
|
||||
idform: $('LSform_idform').value,
|
||||
img: img.id
|
||||
};
|
||||
LSdebug(data);
|
||||
data.imgload = varLSdefault.loadingImgDisplay(img);
|
||||
new Request({url: 'index_ajax.php', data: data, onSuccess: this.onAddFieldBtnClickComplete.bind(this)}).send();
|
||||
},
|
||||
|
||||
onAddFieldBtnClickComplete: function(responseText, responseXML) {
|
||||
var data = JSON.decode(responseText);
|
||||
LSdebug(data);
|
||||
if ( varLSdefault.checkAjaxReturn(data) ) {
|
||||
var li = new Element('li');
|
||||
var img = $(data.img);
|
||||
li.set('html',data.html);
|
||||
li.injectAfter(img.getParent());
|
||||
this.initializeLSform_AddAndRemoveBtns(li);
|
||||
if (typeof(this._modules[data.fieldtype]) != "undefined") {
|
||||
initializeModule: function(fieldType,li) {
|
||||
if ($type(this._modules[fieldType])) {
|
||||
try {
|
||||
this._modules[data.fieldtype].reinitialize(li);
|
||||
this._modules[fieldType].reinitialize(li);
|
||||
}
|
||||
catch(e) {
|
||||
LSdebug('Pas de reinitialise pour ' + data.fieldtype);
|
||||
LSdebug('Pas de reinitialise pour ' + fieldType);
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
onRemoveFieldBtnClick: function(img) {
|
||||
if (img.getParent().getParent().getChildren().length == 1) {
|
||||
img.getPrevious().getPrevious().value='';
|
||||
}
|
||||
else {
|
||||
img.getParent().destroy();
|
||||
}
|
||||
}
|
||||
});
|
||||
window.addEvent(window.ie ? 'load' : 'domready', function() {
|
||||
varLSform = new LSform();
|
||||
|
|
60
trunk/includes/js/LSformElement.js
Normal file
60
trunk/includes/js/LSformElement.js
Normal file
|
@ -0,0 +1,60 @@
|
|||
var LSformElement = new Class({
|
||||
initialize: function(LSform,name,ul){
|
||||
this.LSform=LSform;
|
||||
this.name=name;
|
||||
this.ul=ul;
|
||||
this.fields=[];
|
||||
this.multiple = this.ul.hasClass('LSformElement_multiple');
|
||||
this.initializeLSformElement();
|
||||
},
|
||||
|
||||
initializeLSformElement: function(li) {
|
||||
if (typeof(li) == 'undefined') {
|
||||
var elements = this.ul.getElements('li');
|
||||
}
|
||||
else {
|
||||
var elements = [li];
|
||||
}
|
||||
elements.each(function(li) {
|
||||
var id='LSformElement_field_'+this.name+'_'+$random(1,1000);
|
||||
this.fields[id] = new LSformElement_field(this,li,id);
|
||||
}, this);
|
||||
},
|
||||
|
||||
onAddFieldBtnClick: function(field){
|
||||
var data = {
|
||||
template: 'LSform',
|
||||
action: 'onAddFieldBtnClick',
|
||||
attribute: this.name,
|
||||
objecttype: this.LSform.objecttype,
|
||||
objectdn: this.LSform.objectdn,
|
||||
idform: this.LSform.idform,
|
||||
fieldId: field.id
|
||||
};
|
||||
LSdebug(data);
|
||||
data.imgload = varLSdefault.loadingImgDisplay(field.li,'inside');
|
||||
new Request({url: 'index_ajax.php', data: data, onSuccess: this.onAddFieldBtnClickComplete.bind(this)}).send();
|
||||
},
|
||||
|
||||
onAddFieldBtnClickComplete: function(responseText, responseXML) {
|
||||
var data = JSON.decode(responseText);
|
||||
LSdebug(data);
|
||||
if ( varLSdefault.checkAjaxReturn(data) ) {
|
||||
var li = new Element('li');
|
||||
var field = this.fields[data.fieldId];
|
||||
li.set('html',data.html);
|
||||
li.injectAfter(field.li);
|
||||
this.initializeLSformElement(li);
|
||||
this.LSform.initializeModule(data.fieldtype,li);
|
||||
}
|
||||
},
|
||||
|
||||
onRemoveFieldBtnClick: function(field) {
|
||||
if (this.ul.getElements('li').length == 1) {
|
||||
field.clearValue.bind(field)();
|
||||
}
|
||||
else {
|
||||
field.remove.bind(field)();
|
||||
}
|
||||
}
|
||||
});
|
42
trunk/includes/js/LSformElement_field.js
Normal file
42
trunk/includes/js/LSformElement_field.js
Normal file
|
@ -0,0 +1,42 @@
|
|||
var LSformElement_field = new Class({
|
||||
initialize: function(LSformElement,li,id){
|
||||
this.id = id;
|
||||
this.LSformElement = LSformElement;
|
||||
this.li = li;
|
||||
|
||||
if (this.LSformElement.multiple) {
|
||||
this.addFieldBtn = new Element('img');
|
||||
this.addFieldBtn.src = varLSdefault.imagePath('add.png');
|
||||
this.addFieldBtn.addClass('btn');
|
||||
this.addFieldBtn.addEvent('click',this.LSformElement.onAddFieldBtnClick.bind(this.LSformElement,this));
|
||||
this.addFieldBtn.injectInside(this.li);
|
||||
|
||||
this.removeFieldBtn = new Element('img');
|
||||
this.removeFieldBtn.src = varLSdefault.imagePath('remove.png');
|
||||
this.removeFieldBtn.addClass('btn');
|
||||
this.removeFieldBtn.addEvent('click',this.LSformElement.onRemoveFieldBtnClick.bind(this.LSformElement,this));
|
||||
this.removeFieldBtn.injectInside(this.li);
|
||||
}
|
||||
},
|
||||
|
||||
getFormField: function() {
|
||||
if ($type(this._formField)) {
|
||||
return this._formField;
|
||||
}
|
||||
this._formField = this.li.getFirst('input');
|
||||
if(!$type(this._formField)) {
|
||||
this._formField = this.li.getFirst('textarea');
|
||||
}
|
||||
return this._formField;
|
||||
},
|
||||
|
||||
clearValue: function() {
|
||||
if ($type(this.getFormField())) {
|
||||
this.getFormField().value='';
|
||||
}
|
||||
},
|
||||
|
||||
remove: function() {
|
||||
this.li.destroy();
|
||||
}
|
||||
});
|
|
@ -32,6 +32,7 @@ var LSformElement_mail = new Class({
|
|||
},
|
||||
|
||||
reinitialize: function(el) {
|
||||
varLSform.initializeModule('LSformElement_text',el);
|
||||
this.initialiseLSformElement_mail(el);
|
||||
},
|
||||
|
||||
|
|
|
@ -1,24 +1,35 @@
|
|||
var LSformElement_text = new Class({
|
||||
initialize: function(){
|
||||
this.fields = new Hash();
|
||||
this.elements = new Hash();
|
||||
this.initialiseLSformElement_text();
|
||||
if ($type(varLSform)) {
|
||||
varLSform.addModule("LSformElement_text",this);
|
||||
}
|
||||
},
|
||||
|
||||
initialiseLSformElement_text: function(el) {
|
||||
|
||||
if (typeof(el) == 'undefined') {
|
||||
el = document;
|
||||
}
|
||||
var getName = /^(.*)\[\]$/
|
||||
el.getElements('ul.LSformElement_text').each(function(ul) {
|
||||
var first = ul.getElement('input.LSformElement_text');
|
||||
if ($type(first)) {
|
||||
var name = getName.exec(first.name)[1];
|
||||
this.fields[name] = new LSformElement_text_field(name,first,this);
|
||||
el.getElements('input.LSformElement_text').each(function(input) {
|
||||
var name = getName.exec(input.name)[1];
|
||||
if (!$type(this.elements[name])) {
|
||||
this.elements[name] = new Hash();
|
||||
}
|
||||
var id = this.elements[name].getLength();
|
||||
this.elements[name][id] = new LSformElement_text_field(name,input,this);
|
||||
}, this);
|
||||
this.fields.each(function(el) {
|
||||
el.start.bind(el)();
|
||||
this.elements.each(function(element) {
|
||||
element.each(function(field) {
|
||||
field.start.bind(field)();
|
||||
},this);
|
||||
},this);
|
||||
},
|
||||
|
||||
reinitialize: function(el) {
|
||||
this.initialiseLSformElement_text(el);
|
||||
},
|
||||
|
||||
getDependsFields: function(format) {
|
||||
|
@ -43,11 +54,11 @@ var LSformElement_text = new Class({
|
|||
},
|
||||
|
||||
getInput: function(name) {
|
||||
return this.fields[name].getInput();
|
||||
return this.elements[name][0].getInput();
|
||||
},
|
||||
|
||||
getValue: function(name) {
|
||||
return this.fields[name].getValue();
|
||||
return this.elements[name][0].getValue();
|
||||
}
|
||||
|
||||
});
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
var LSformElement_text_field = new Class({
|
||||
initialize: function(name,input,parent){
|
||||
this._start = false;
|
||||
this.name = name;
|
||||
this.parent = parent;
|
||||
this.input = input;
|
||||
|
@ -10,6 +11,9 @@ var LSformElement_text_field = new Class({
|
|||
},
|
||||
|
||||
start: function() {
|
||||
if (this._start) {
|
||||
return true;
|
||||
}
|
||||
if ($type(this.params)) {
|
||||
if ($type(this.params['generate_value_format'])) {
|
||||
this.format = this.params['generate_value_format'];
|
||||
|
@ -36,6 +40,7 @@ var LSformElement_text_field = new Class({
|
|||
input.addEvent('change',this.refreshValue.bind(this));
|
||||
},this);
|
||||
}
|
||||
this._start=true;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
32
trunk/includes/js/LSformElement_textarea.js
Normal file
32
trunk/includes/js/LSformElement_textarea.js
Normal file
|
@ -0,0 +1,32 @@
|
|||
var LSformElement_textarea = new Class({
|
||||
initialize: function(){
|
||||
this.initialiseLSformElement_textarea();
|
||||
if ($type(varLSform)) {
|
||||
varLSform.addModule("LSformElement_textarea",this);
|
||||
}
|
||||
},
|
||||
|
||||
initialiseLSformElement_textarea: function(el) {
|
||||
if (!$type(el)) {
|
||||
el = document;
|
||||
}
|
||||
el.getElements('textarea.LSform').each(function(textarea) {
|
||||
var btn = new Element('img');
|
||||
btn.addClass('btn');
|
||||
btn.src = varLSdefault.imagePath('clear.png');
|
||||
btn.addEvent('click',this.onClearBtnClick.bind(this,btn));
|
||||
btn.injectAfter(textarea);
|
||||
}, this);
|
||||
},
|
||||
|
||||
onClearBtnClick: function(btn) {
|
||||
btn.getPrevious().value='';
|
||||
},
|
||||
|
||||
reinitialize: function(el) {
|
||||
this.initialiseLSformElement_textarea(el);
|
||||
}
|
||||
});
|
||||
window.addEvent(window.ie ? 'load' : 'domready', function() {
|
||||
varLSformElement_textarea = new LSformElement_textarea();
|
||||
});
|
|
@ -45,7 +45,7 @@ if (!isset($_ERRORS)) {
|
|||
case 'LSform':
|
||||
switch($_REQUEST['action']) {
|
||||
case 'onAddFieldBtnClick':
|
||||
if ((isset($_REQUEST['attribute'])) && (isset($_REQUEST['objecttype'])) && (isset($_REQUEST['objectdn'])) && (isset($_REQUEST['idform'])) && (isset($_REQUEST['img'])) ) {
|
||||
if ((isset($_REQUEST['attribute'])) && (isset($_REQUEST['objecttype'])) && (isset($_REQUEST['objectdn'])) && (isset($_REQUEST['idform'])) && (isset($_REQUEST['fieldId'])) ) {
|
||||
if ($GLOBALS['LSsession'] -> loadLSobject($_REQUEST['objecttype'])) {
|
||||
$object = new $_REQUEST['objecttype']();
|
||||
$object -> loadData($_REQUEST['objectdn']);
|
||||
|
@ -54,7 +54,7 @@ if (!isset($_ERRORS)) {
|
|||
if ( $emptyField ) {
|
||||
$data = array(
|
||||
'html' => $form -> getEmptyField($_REQUEST['attribute']),
|
||||
'img' => $_REQUEST['img'],
|
||||
'fieldId' => $_REQUEST['fieldId'],
|
||||
'fieldtype' => get_class($form -> getElement($_REQUEST['attribute']))
|
||||
);
|
||||
}
|
||||
|
|
7
trunk/templates/default/LSformElement.tpl
Normal file
7
trunk/templates/default/LSformElement.tpl
Normal file
|
@ -0,0 +1,7 @@
|
|||
<ul class='LSform{if $multiple && !$freeze} LSformElement_multiple'{/if}' id='{$attr_name}'>
|
||||
{foreach from=$values item=value}
|
||||
<li>{include file=$fieldTemplate}</li>
|
||||
{foreachelse}
|
||||
<li>{include file=$fieldTemplate}</li>
|
||||
{/foreach}
|
||||
</ul>
|
5
trunk/templates/default/LSformElement_field.tpl
Normal file
5
trunk/templates/default/LSformElement_field.tpl
Normal file
|
@ -0,0 +1,5 @@
|
|||
{if $freeze}
|
||||
{if $value}{$value}{else}{$noValueTxt}{/if}
|
||||
{else}
|
||||
<input type='text' name='{$attr_name}[]' value="{$value}"/>
|
||||
{/if}
|
5
trunk/templates/default/LSformElement_mail_field.tpl
Normal file
5
trunk/templates/default/LSformElement_mail_field.tpl
Normal file
|
@ -0,0 +1,5 @@
|
|||
{if $freeze}
|
||||
<span class='LSformElement_text'>{if $value}<a class='LSformElement_mail' href='mailto:{$value}'>{$value}</a>{else}{$noValueTxt}{/if}</span><input type='hidden' name='{$attr_name}[]' class='LSformElement_text' value="{$value}"/>
|
||||
{else}
|
||||
<input type='text' name='{$attr_name}[]' class='LSformElement_text LSformElement_mail' value="{$value}"/>
|
||||
{/if}
|
5
trunk/templates/default/LSformElement_text_field.tpl
Normal file
5
trunk/templates/default/LSformElement_text_field.tpl
Normal file
|
@ -0,0 +1,5 @@
|
|||
{if $freeze}
|
||||
<span class='LSformElement_text'>{if $value}{$value}{else}{$noValueTxt}{/if}</span><input type='hidden' name='{$attr_name}[]' class='LSformElement_text' value="{$value}"/>
|
||||
{else}
|
||||
<input type='text' name='{$attr_name}[]' class='LSformElement_text' value="{$value}"/>
|
||||
{/if}
|
5
trunk/templates/default/LSformElement_textarea_field.tpl
Normal file
5
trunk/templates/default/LSformElement_textarea_field.tpl
Normal file
|
@ -0,0 +1,5 @@
|
|||
{if $freeze}
|
||||
{if $value}{$value}{else}{$noValueTxt}{/if}
|
||||
{else}
|
||||
<textarea name='{$attr_name}[]' class='LSform'>{$value}</textarea>
|
||||
{/if}
|
Loading…
Reference in a new issue