hedera-web/package/usr/share/hedera-web/js/htk/image-editor.js

52 lines
1.1 KiB
JavaScript
Raw Normal View History

2015-03-06 23:33:54 +00:00
Htk.ImageEditor = new Class
({
Extends: Htk.Widget
,Xml: 'js/htk/image-editor.xml'
,initialize: function ()
{
this.builderInit (Htk.ImageEditor.Xml);
this.$('max-size').value = 10 /* MB */ * 1048576;
}
,onNameChange: function ()
{
this.signalEmit ('name-changed', this.$('name').value);
}
,onFormSubmit: function ()
{
this.$('submit').disabled = true;
this.$('loader').style.visibility = 'visible';
}
,onIframeLoad: function ()
{
var toast = new Htk.Toast ();
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);
toast.showMessage (_('ImageAdded'));
2015-03-06 23:33:54 +00:00
}
else
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;
}
});