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

57 lines
1.2 KiB
JavaScript
Executable File

Htk.ImageEditor = new Class
({
Extends: Htk.Widget
,Xml: 'js/htk/image-editor.xml'
,maxFileSize: 10 /* MB */ * 1048576
,initialize: function ()
{
this.builderInit (Htk.ImageEditor.Xml);
this.$('max-size').value = this.maxFileSize;
this.$('iframe').addEventListener ('load', function ()
{
var toast = new Htk.Toast ();
this.$('submit').disabled = false;
this.$('loader').style.visibility = 'hidden';
try {
var responseText = this.$('iframe').contentDocument.body.textContent;
var response = eval ('('+ responseText +')');
if (response.data)
{
this.signalEmit ('file-uploaded', this.$('name').value);
toast.showMessage (_('ImageAdded'));
}
else
toast.showError (response.error.message +' ('+ response.error.code +')');
}
catch (e) {}
}
.bind (this));
this.$('form').addEventListener ('submit', function ()
{
this.$('submit').disabled = true;
this.$('loader').style.visibility = 'visible';
}
.bind (this));
this.$('name').addEventListener ('change', function ()
{
this.signalEmit ('name-changed', this.$('name').value);
}
.bind (this));
}
,setData: function (image, directory)
{
this.$('name').value = image;
this.$('schema').value = directory;
}
});