' + labels[3] + '
';
$('body').append(confdialog);
var btns = {};
if (rtlsupport == "") {
diagclass = "inmage-annotate-dialog";
} else {
diagclass = "inmage-annotate-dialog-rtl";
}
btns[labels[5]] = function(){ var delform = $(this).attr("rel"); $("form#" + delform).submit(); };
btns[labels[6]] = function(){ location.reload(); };
$('#image-annotate-conf-dialog').dialog({
modal: true,
resizable: false,
dialogClass: diagclass,
title: labels[7],
close: function(event, ui) { location.reload(); },
buttons: btns
});
})
var form = this;
this.editarea.bind('click',function () {
var alink = $(cssaclass);
alink.unbind();
alink.attr ('href', '#');
alink.removeAttr ('rel');
form.edit(tags, labels, saveUrl, csrf, rtlsupport);
})
this.delarea.hide();
this.editarea.hide();
}
// Add the note
var notedescription = "";
if (note.description != "") {
notedescription = "
" + note.description;
}
this.form = $('
' + note.text + notedescription + '
');
this.form.hide();
image.canvas.children('.image-annotate-view').append(this.form);
this.form.children('span.actions').hide();
// Set the position and size of the note
this.setPosition(rtlsupport);
// Add the behavior: hide/display the note when hovering the area
var annotation = this;
this.area.hover(function() {
annotation.show();
if (annotation.delarea != undefined) {
annotation.delarea.show();
annotation.editarea.show();
}
}, function() {
annotation.hide();
if (annotation.delarea != undefined) {
annotation.delarea.hide();
annotation.editarea.hide();
}
});
if (editable) {
this.delarea.hover(function() {
annotation.delarea.show();
annotation.editarea.show();
}, function() {
annotation.delarea.hide();
annotation.editarea.hide();
});
this.editarea.hover(function() {
annotation.delarea.show();
annotation.editarea.show();
}, function() {
annotation.delarea.hide();
annotation.editarea.hide();
});
}
// Edit a note feature
if (note.url != "" && note.url != null) {
this.area.bind('click',function () {
var alink = $(cssaclass);
alink.unbind();
alink.attr ('href', '#');
alink.removeAttr ('rel');
window.location = note.url;
})
}
};
$.fn.annotateView.prototype.setPosition = function(rtlsupport) {
///
/// Sets the position of an annotation.
///
this.area.children('div').height((parseInt(this.note.height) - 2) + 'px');
this.area.children('div').width((parseInt(this.note.width) - 2) + 'px');
this.area.css('left', (this.note.left) + 'px');
this.area.css('top', (this.note.top) + 'px');
this.form.css('left', (this.note.left) + 'px');
this.form.css('top', (parseInt(this.note.top) + parseInt(this.note.height) + 7) + 'px');
if (this.delarea != undefined) {
this.delarea.children('div').height('14px');
this.delarea.children('div').width('14px');
this.delarea.css('top', (this.note.top) + 'px');
this.editarea.children('div').height('14px');
this.editarea.children('div').width('14px');
if (rtlsupport == '') {
this.delarea.css('left', (this.note.left + parseInt(this.note.width)) + 'px');
this.editarea.css('left', (this.note.left + parseInt(this.note.width)) + 'px');
} else {
this.delarea.css('left', (this.note.left - 16) + 'px');
this.editarea.css('left', (this.note.left - 16) + 'px');
}
this.editarea.css('top', (this.note.top + 16) + 'px');
}
};
$.fn.annotateView.prototype.show = function() {
///
/// Highlights the annotation
///
this.form.fadeIn(250);
if (!this.note.editable) {
this.area.addClass('image-annotate-area-hover');
} else {
this.area.addClass('image-annotate-area-editable-hover');
}
};
$.fn.annotateView.prototype.hide = function() {
///
/// Removes the highlight from the annotation.
///
this.form.fadeOut(250);
this.area.removeClass('image-annotate-area-hover');
this.area.removeClass('image-annotate-area-editable-hover');
};
$.fn.annotateView.prototype.destroy = function() {
///
/// Destroys the annotation.
///
this.area.remove();
this.form.remove();
}
$.fn.annotateView.prototype.edit = function(tags, labels, saveUrl, csrf, rtlsupport) {
///
/// Edits the annotation.
///
if (this.image.mode == 'view') {
this.image.mode = 'edit';
var annotation = this;
// Create/prepare the editable note elements
var editable = new $.fn.annotateEdit(this.image, this.note, tags, labels, saveUrl, csrf, rtlsupport);
$.fn.annotateImage.createSaveButton(editable, this.image, annotation, rtlsupport);
$.fn.annotateImage.createCancelButton(editable, this.image, rtlsupport);
}
};
$.fn.annotateImage.appendPosition = function(form, editable) {
///
/// Appends the annotations coordinates to the given form that is posted to the server.
///
var areaFields = $('
' +
'
' +
'
' +
'
' +
'
');
form.append(areaFields);
}
$.fn.annotateView.prototype.resetPosition = function(editable, text) {
///
/// Sets the position of an annotation.
///
this.form.html(text);
this.form.hide();
// Resize
this.area.children('div').height(editable.area.height() + 'px');
this.area.children('div').width((editable.area.width() - 2) + 'px');
this.area.css('left', (editable.area.position().left) + 'px');
this.area.css('top', (editable.area.position().top) + 'px');
this.form.css('left', (editable.area.position().left) + 'px');
this.form.css('top', (parseInt(editable.area.position().top) + parseInt(editable.area.height()) + 7) + 'px');
// Save new position to note
this.note.top = editable.area.position().top;
this.note.left = editable.area.position().left;
this.note.height = editable.area.height();
this.note.width = editable.area.width();
this.note.text = text;
this.note.id = editable.note.id;
this.editable = true;
};
})(jQuery);