hedera-web/js/htk/image-editor.js

69 lines
1.2 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);
2016-08-25 10:47:09 +00:00
var self = this;
this.$('form').onsubmit = function ()
{ self.onSubmit (); return false; };
2015-11-09 08:14:33 +00:00
this.parent (props);
}
,onNameChange: function ()
{
2015-12-10 13:48:43 +00:00
var newValue = this.$('name').value;
if (!newValue)
newValue = null
this.signalEmit ('name-changed', newValue);
}
2016-08-25 10:47:09 +00:00
,onSubmit: function ()
{
this.$('submit').disabled = true;
2016-05-02 13:05:49 +00:00
this.$('spinner').start ();
2016-08-25 10:47:09 +00:00
var request = new Vn.JsonRequest ();
request.sendFormMultipart (this.$('form'),
this.onResponse.bind (this));
}
2016-08-25 10:47:09 +00:00
,onResponse: function (request, json, error)
{
this.$('submit').disabled = false;
2016-05-02 13:05:49 +00:00
this.$('spinner').stop ();
2015-03-06 23:33:54 +00:00
2016-08-25 10:47:09 +00:00
if (json)
{
Htk.Toast.showMessage (_('ImageAdded'));
this.signalEmit ('file-uploaded', this.$('name').value);
2015-03-06 23:33:54 +00:00
}
2016-08-25 10:47:09 +00:00
else
Htk.Toast.showError (error.message);
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
});
});