/*
Module  : Customeranimals
Auteur  : ELHAIBA Adel
Contact : adel@fktel.fr
Descrip : Module permettant de créer des profils d'animaux et de les animer dans un slider sur le front
*/
Ajax.AdelInPlaceEditor = Class.create(Ajax.InPlaceEditor, {
handleFormCancellation: function(e) {
this.wrapUp();
if (e) Event.stop(e);
return false;
}
});
Ajax.InPlaceEditorWithEmptyText = Class.create(Ajax.AdelInPlaceEditor, {
initialize : function($super, element, url, options) {
if (!options.emptyText)        options.emptyText      = " ";
if (!options.emptyClassName)   options.emptyClassName = "inplaceeditor-empty";
$super(element, url, options);
this.checkEmpty();
},
checkEmpty : function() {
if (this.element.innerHTML.length == 0 && this.options.emptyText) {
this.element.appendChild(
new Element("span", { className : this.options.emptyClassName }).update(this.options.emptyText)
);
}
},
getText : function($super) {
if (empty_span = this.element.select("." + this.options.emptyClassName).first()) {
empty_span.remove();
}
return $super();
},
onComplete : function($super, transport) {
this.checkEmpty();
return $super(transport);
}
});
Ajax.InPlaceEditorSelect = Class.create(Ajax.AdelInPlaceEditor, {
createEditField: function() {
var fld 		= document.createElement('select');
fld.name 		= this.options.paramName;
var inputName 	= this.element.id;
new Ajax.Request('/customeranimals/index/list/',
{
method		: 'post',
parameters	: {id: inputName},
onLoading	: function(){$('wait'+inputName).show();},
onComplete	: function(){$('wait'+inputName).hide();},
onSuccess	: function(transport){fld.update(transport.responseText);},
onFailure	: function(transport) {}
});
if (this.options.submitOnBlur) 
fld.onblur = this._boundSubmitHandler;
this._controls.editor = fld;
if (this.options.loadTextURL)
this.loadExternalText();
this._form.appendChild(this._controls.editor);
}
});
