diff --git a/forms/admin/photos/photos.js b/forms/admin/photos/photos.js index 0f2b7da4..a391a31d 100644 --- a/forms/admin/photos/photos.js +++ b/forms/admin/photos/photos.js @@ -6,38 +6,37 @@ Vn.Photos = new Class ,activate: function () { this.$('schema').value = 'catalog'; - this.$('photo-size').value = 10 /* MB */ * 1048576; this.$('photo-id').focus (); - this.$('html-form').action = - '//'+ Vn.Config['image_host'] +'/rest.php?action=image'; + + var self = this; + this.$('html-form').onsubmit = function () + { self.onSubmit (); return false; }; } - - ,onFormSubmit: function () + + ,onSubmit: function () { this.$('schema-field').value = this.$('schema').value; this.$('submit').disabled = true; this.gui.loaderPush (); - } - ,onImageUpload: function () - { + var request = new Vn.JsonRequest (); + request.sendFormMultipart (this.$('html-form'), + this.onResponse.bind (this)); + } + + ,onResponse: function (request, json, error) + { this.gui.loaderPop (); this.$('submit').disabled = false; - try { - var responseText = this.$('iframe').contentDocument.body.textContent; - var response = eval ('('+ responseText +')'); - - if (response.data) - { - this.$('photo-id').value = ''; - this.$('photo-id').focus (); - Htk.Toast.showMessage (_('ImageUploaded')); - } - else - Htk.Toast.showError (response.error.message +' ('+ response.error.code +')'); + if (json) + { + this.$('photo-id').value = ''; + this.$('photo-id').focus (); + Htk.Toast.showMessage (_('ImageAdded')); } - catch (e) {} + else + Htk.Toast.showError (error.message); } }); diff --git a/forms/admin/photos/style.css b/forms/admin/photos/style.css index c25d6923..59dedb12 100644 --- a/forms/admin/photos/style.css +++ b/forms/admin/photos/style.css @@ -20,11 +20,12 @@ /* Footer */ -.photos button +.photos input[type=submit] { display: block; margin: 0 auto; padding: 0.6em; margin-top: 1.5em; + font-size: 1.2em; } diff --git a/forms/admin/photos/ui.xml b/forms/admin/photos/ui.xml index 1b074152..23d9d94c 100755 --- a/forms/admin/photos/ui.xml +++ b/forms/admin/photos/ui.xml @@ -7,10 +7,8 @@
+ enctype="multipart/form-data"> +
@@ -20,27 +18,22 @@
- - + - SELECT name, `desc` FROM image_schema ORDER BY `desc` + + SELECT name, `desc` FROM image_schema ORDER BY `desc` + +
-
- +
-