0
1
Fork 0
hedera-web-mindshore/web/js/htk/image-editor.js

65 lines
1.3 KiB
JavaScript
Raw Normal View History

Vn.resource ('js/htk/image-editor.xml');
2015-09-24 11:50:27 +00:00
Vn.define (function () {
/**
* A form to handle the image database, it allows to add new images or replace it
**/
2015-03-06 23:33:54 +00:00
Htk.ImageEditor = new Class
({
2015-03-06 23:33:54 +00:00
Extends: Htk.Widget
,initialize: function (props)
2015-03-06 23:33:54 +00:00
{
this.builderInit (this.constructor.Xml);
this.$('max-size').value = 10 /* MB */ * 1048576;
2015-09-24 11:50:27 +00:00
this.$('form').action =
2015-11-09 08:14:33 +00:00
'//'+ Vn.Config['image_host'] +'/rest.php?action=image';
this.parent (props);
}
,onNameChange: function ()
{
this.signalEmit ('name-changed', this.$('name').value);
}
,onFormSubmit: function ()
{
this.$('submit').disabled = true;
this.$('loader').style.visibility = 'visible';
}
,onIframeLoad: function ()
{
this.$('submit').disabled = false;
this.$('loader').style.visibility = 'hidden';
2015-03-06 23:33:54 +00:00
try {
var responseText = this.$('iframe').contentDocument.body.textContent;
var response = eval ('('+ responseText +')');
2015-03-06 23:33:54 +00:00
if (response.data)
{
this.signalEmit ('file-uploaded', this.$('name').value);
Htk.Toast.showMessage (_('ImageAdded'));
2015-03-06 23:33:54 +00:00
}
else
Htk.Toast.showError (response.error.message +' ('+ response.error.code +')');
2015-03-06 23:33:54 +00:00
}
catch (e) {}
2015-03-06 23:33:54 +00:00
}
,setData: function (image, directory)
{
this.$('name').value = image;
this.$('schema').value = directory;
}
}).extend
({
Xml: 'js/htk/image-editor.xml'
2015-03-06 23:33:54 +00:00
});
});