diff options
author | Chirayu Chiripal <chirayu.chiripal@gmail.com> | 2014-06-28 16:27:18 +0400 |
---|---|---|
committer | Chirayu Chiripal <chirayu.chiripal@gmail.com> | 2014-07-12 00:22:32 +0400 |
commit | 1f324be4b12c854b26ece2517c425b41053525ec (patch) | |
tree | 8b678ae49fdc46d504735086c10563611c8900c9 /js/transformations | |
parent | 43f3179db6429c777e10e611f7c525cd992036f6 (diff) |
RFE-637: Custom field handlers (input transformations)
Signed-off-by: Chirayu Chiripal <chirayu.chiripal@gmail.com>
Diffstat (limited to 'js/transformations')
-rw-r--r-- | js/transformations/image_upload.js | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/js/transformations/image_upload.js b/js/transformations/image_upload.js new file mode 100644 index 0000000000..d0c2b92888 --- /dev/null +++ b/js/transformations/image_upload.js @@ -0,0 +1,28 @@ +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * Image upload transformations plugin js + * + * @package PhpMyAdmin + */ + +AJAX.registerOnload('transformations/image_upload.js', function() { + // Change thumbnail when image file is selected + // through file upload dialog + $('input.image-upload').on('change', function(event) { + if (this.files && this.files[0]) { + var reader = new FileReader(); + var $input = $(this); + reader.onload = function (e) { + $input.prevAll('img').attr('src', e.target.result); + }; + reader.readAsDataURL(this.files[0]); + } + }); +}); + +/** + * Unbind all event handlers before tearing down a page + */ +AJAX.registerTeardown('transformations/image_upload.js', function() { + $('input.image-upload').off('change'); +}); |