2015-09-25 00:53:59 +00:00
|
|
|
|
|
|
|
Vn.resource ('js/htk/image-editor.xml');
|
2015-09-24 11:50:27 +00:00
|
|
|
Vn.define (function () {
|
2015-09-25 00:53:59 +00:00
|
|
|
|
2015-09-11 09:37:16 +00:00
|
|
|
/**
|
2015-12-19 15:42:38 +00:00
|
|
|
* A form to handle the image database, it allows to add new images or
|
|
|
|
* replace it.
|
2015-09-11 09:37:16 +00:00
|
|
|
**/
|
2015-03-06 23:33:54 +00:00
|
|
|
Htk.ImageEditor = new Class
|
2015-09-25 00:53:59 +00:00
|
|
|
({
|
2015-03-06 23:33:54 +00:00
|
|
|
Extends: Htk.Widget
|
|
|
|
|
2015-09-11 09:37:16 +00:00
|
|
|
,initialize: function (props)
|
2015-03-06 23:33:54 +00:00
|
|
|
{
|
2015-09-11 09:37:16 +00:00
|
|
|
this.builderInit (this.constructor.Xml);
|
2015-09-25 00:53:59 +00:00
|
|
|
|
2015-03-27 19:10:49 +00:00
|
|
|
this.$('max-size').value = 10 /* MB */ * 1048576;
|
2015-09-23 22:35:17 +00:00
|
|
|
this.$('form').action =
|
2015-09-28 10:34:59 +00:00
|
|
|
'//'+ Vn.Config['image_host'] +'/rest.php?action=image';
|
2015-11-09 08:14:33 +00:00
|
|
|
|
|
|
|
this.parent (props);
|
2015-03-27 19:10:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
,onNameChange: function ()
|
|
|
|
{
|
2015-12-10 13:48:43 +00:00
|
|
|
var newValue = this.$('name').value;
|
|
|
|
|
|
|
|
if (!newValue)
|
|
|
|
newValue = null
|
|
|
|
|
|
|
|
this.signalEmit ('name-changed', newValue);
|
2015-03-27 19:10:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
,onFormSubmit: function ()
|
|
|
|
{
|
|
|
|
this.$('submit').disabled = true;
|
2016-05-02 13:05:49 +00:00
|
|
|
this.$('spinner').start ();
|
2015-03-27 19:10:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
,onIframeLoad: function ()
|
2015-09-11 09:37:16 +00:00
|
|
|
{
|
2015-03-27 19:10:49 +00:00
|
|
|
this.$('submit').disabled = false;
|
2016-05-02 13:05:49 +00:00
|
|
|
this.$('spinner').stop ();
|
2015-03-06 23:33:54 +00:00
|
|
|
|
2015-03-27 19:10:49 +00:00
|
|
|
try {
|
|
|
|
var responseText = this.$('iframe').contentDocument.body.textContent;
|
|
|
|
var response = eval ('('+ responseText +')');
|
2015-03-06 23:33:54 +00:00
|
|
|
|
2015-03-27 19:10:49 +00:00
|
|
|
if (response.data)
|
|
|
|
{
|
|
|
|
this.signalEmit ('file-uploaded', this.$('name').value);
|
2015-08-20 11:22:36 +00:00
|
|
|
Htk.Toast.showMessage (_('ImageAdded'));
|
2015-03-06 23:33:54 +00:00
|
|
|
}
|
2015-03-27 19:10:49 +00:00
|
|
|
else
|
2015-08-20 11:22:36 +00:00
|
|
|
Htk.Toast.showError (response.error.message +' ('+ response.error.code +')');
|
2015-03-06 23:33:54 +00:00
|
|
|
}
|
2015-03-27 19:10:49 +00:00
|
|
|
catch (e) {}
|
2015-03-06 23:33:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
,setData: function (image, directory)
|
|
|
|
{
|
|
|
|
this.$('name').value = image;
|
|
|
|
this.$('schema').value = directory;
|
|
|
|
}
|
2015-09-25 13:35:01 +00:00
|
|
|
}).extend
|
|
|
|
({
|
|
|
|
Xml: 'js/htk/image-editor.xml'
|
2015-03-06 23:33:54 +00:00
|
|
|
});
|
|
|
|
|
2015-09-25 00:53:59 +00:00
|
|
|
});
|