(function ($, undefined) {
$(document).ready(function () {
var ControlParent = $('.SFC.ImageAnnotation-ImageAnnotation').parent();
function readURL(input) {
var Img = "";
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('.DataImg').attr('data-img', e.target.result)
};
reader.readAsDataURL(input.files[0]);
}
console.log("In ReadUrl");
}
console.log('ImageAnnotation');
$('.SFC.ImageAnnotation-ImageAnnotation').hide();
ControlParent.append('<div class="SomeClass">'+
'<button class="Btn">Add Image</button> '+
'<input type = "file" accept="image/*" class = "AddImageButton" style="display:none">' +
'<div style="margin-top:50px">'+
'<div id="CustomCanvas" data-img="" style="position:relative">'+
'</div>'+
'</div>' +
'<div class="DataImg" data-img="">text</div>'+
'</div>');
$(".Btn").on('click', function () {
$('.AddImageButton').trigger('click');
});
console.log($('.DataImg'));
$('.AddImageButton').on('change',function () {
readURL(this);
ImageUrl = $('.DataImg').attr('data-img');
console.log(ImageUrl);
// console.log($(this).parent().find('#CustomCanvas').attr('data-img'));
/* $('#CustomCanvas').annotate({
color: 'red',
images: [],
bootstrap: false
});*/
console.log('AfterAnnotate');
});
});
})(jQuery);
reader.onload = function (e) {
console.log('zzz');
$('.DataImg').attr('data-img', e.target.result)
};
readURL(this);
console.log('qqq');
(function ($, undefined) {
$(document).ready(function () {
var ControlParent = $('.SFC.ImageAnnotation-ImageAnnotation').parent();
function readURL(input) {
var Img = "";
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('.DataImg').attr('data-img', e.target.result);
afterLoad();
};
reader.readAsDataURL(input.files[0]);
}
console.log("In ReadUrl");
}
function afterLoad() {
ImageUrl = $('.DataImg').attr('data-img');
console.log(ImageUrl);
console.log('AfterAnnotate');
}
console.log('ImageAnnotation');
$('.SFC.ImageAnnotation-ImageAnnotation').hide();
ControlParent.append('<div class="SomeClass">'+
'<button class="Btn">Add Image</button> '+
'<input type = "file" accept="image/*" class = "AddImageButton" style="display:none">' +
'<div style="margin-top:50px">'+
'<div id="CustomCanvas" data-img="" style="position:relative">'+
'</div>'+
'</div>' +
'<div class="DataImg" data-img="">text</div>'+
'</div>');
$(".Btn").on('click', function () {
$('.AddImageButton').trigger('click');
});
console.log($('.DataImg'));
$('.AddImageButton').on('change',function () {
readURL(this);
});
});
})(jQuery);