forked from verdnatura/hedera-web
44 lines
938 B
JavaScript
Executable File
44 lines
938 B
JavaScript
Executable File
|
|
Vn.Photos = new Class
|
|
({
|
|
Extends: Vn.Module
|
|
|
|
,activate: function ()
|
|
{
|
|
this.$('schema').value = 'catalog';
|
|
this.$('photo-size').value = 10 /* MB */ * 1048576;
|
|
this.$('photo-id').focus ();
|
|
this.$('html-form').action =
|
|
'//'+ Vn.Config['image_host'] +'/rest.php?action=image';
|
|
}
|
|
|
|
,onFormSubmit: function ()
|
|
{
|
|
this.$('schema-field').value = this.$('schema').value;
|
|
this.$('submit').disabled = true;
|
|
this.gui.loaderPush ();
|
|
}
|
|
|
|
,onImageUpload: function ()
|
|
{
|
|
this.gui.loaderPop ();
|
|
this.$('submit').disabled = false;
|
|
|
|
try {
|
|
var responseText = this.$('iframe').contentDocument.body.textContent;
|
|
var response = eval ('('+ responseText +')');
|
|
|
|
if (response.data)
|
|
{
|
|
this.$('photo-id').value = '';
|
|
this.$('photo-id').focus ();
|
|
Htk.Toast.showMessage (_('ImageUploaded'));
|
|
}
|
|
else
|
|
Htk.Toast.showError (response.error.message +' ('+ response.error.code +')');
|
|
}
|
|
catch (e) {}
|
|
}
|
|
});
|
|
|