Ajax is now working for all operations but only by sacrificing the full size link.
This commit is contained in:
parent
f1084d6390
commit
f35ba09203
@ -115,12 +115,16 @@ class photoannotation_Controller extends Controller {
|
||||
}
|
||||
//Save annotation
|
||||
if ($annotate_id == "new") { //This is a new annotation
|
||||
$annotate_id = -1;
|
||||
if ($user_id != "") { //Save user
|
||||
photoannotation::saveuser($user_id, $item_id, $str_x1, $str_y1, $str_x2, $str_y2, $description);
|
||||
$new_id = photoannotation::saveuser($user_id, $item_id, $str_x1, $str_y1, $str_x2, $str_y2, $description);
|
||||
$dest_type = "user";
|
||||
} elseif ($tag_data != "") { //Save face
|
||||
photoannotation::saveface($tag_data, $item_id, $str_x1, $str_y1, $str_x2, $str_y2, $description);
|
||||
$new_id = photoannotation::saveface($tag_data, $item_id, $str_x1, $str_y1, $str_x2, $str_y2, $description);
|
||||
$dest_type = "face";
|
||||
} elseif ($item_title != "") { //Save note
|
||||
photoannotation::savenote($item_title, $item_id, $str_x1, $str_y1, $str_x2, $str_y2, $description);
|
||||
$new_id = photoannotation::savenote($item_title, $item_id, $str_x1, $str_y1, $str_x2, $str_y2, $description);
|
||||
$dest_type = "note";
|
||||
} else { //Something's wrong
|
||||
json::reply(array("result" => "error", "message" => (string)$error_noselection));
|
||||
return;
|
||||
@ -132,12 +136,15 @@ class photoannotation_Controller extends Controller {
|
||||
->where("id", "=", $annotate_id)
|
||||
->find();
|
||||
if ($user_id != "") { //Conversion user -> user
|
||||
photoannotation::saveuser($user_id, $item_id, $str_x1, $str_y1, $str_x2, $str_y2, $description);
|
||||
$new_id = photoannotation::saveuser($user_id, $item_id, $str_x1, $str_y1, $str_x2, $str_y2, $description);
|
||||
$dest_type = "user";
|
||||
} elseif ($tag_data != "") { //Conversion user -> face
|
||||
photoannotation::saveface($tag_data, $item_id, $str_x1, $str_y1, $str_x2, $str_y2, $description);
|
||||
$new_id = photoannotation::saveface($tag_data, $item_id, $str_x1, $str_y1, $str_x2, $str_y2, $description);
|
||||
$dest_type = "face";
|
||||
$updateduser->delete(); //delete old user
|
||||
} elseif ($item_title != "") { //Conversion user -> note
|
||||
photoannotation::savenote($item_title, $item_id, $str_x1, $str_y1, $str_x2, $str_y2, $description);
|
||||
$new_id = photoannotation::savenote($item_title, $item_id, $str_x1, $str_y1, $str_x2, $str_y2, $description);
|
||||
$dest_type = "note";
|
||||
$updateduser->delete(); //delete old user
|
||||
} else { //Somethings wrong
|
||||
json::reply(array("result" => "error", "message" => (string)$error_noselection));
|
||||
@ -149,12 +156,15 @@ class photoannotation_Controller extends Controller {
|
||||
->where("id", "=", $annotate_id)
|
||||
->find();
|
||||
if ($user_id != "") { //Conversion face -> user
|
||||
photoannotation::saveuser($user_id, $item_id, $str_x1, $str_y1, $str_x2, $str_y2, $description);
|
||||
$new_id = photoannotation::saveuser($user_id, $item_id, $str_x1, $str_y1, $str_x2, $str_y2, $description);
|
||||
$dest_type = "user";
|
||||
$updatedface->delete(); //delete old face
|
||||
} elseif ($tag_data != "") { //Conversion face -> face
|
||||
photoannotation::saveface($tag_data, $item_id, $str_x1, $str_y1, $str_x2, $str_y2, $description, $annotate_id);
|
||||
$new_id = photoannotation::saveface($tag_data, $item_id, $str_x1, $str_y1, $str_x2, $str_y2, $description, $annotate_id);
|
||||
$dest_type = "face";
|
||||
} elseif ($item_title != "") { //Conversion face -> note
|
||||
photoannotation::savenote($item_title, $item_id, $str_x1, $str_y1, $str_x2, $str_y2, $description);
|
||||
$new_id = photoannotation::savenote($item_title, $item_id, $str_x1, $str_y1, $str_x2, $str_y2, $description);
|
||||
$dest_type = "note";
|
||||
$updatedface->delete(); //delete old face
|
||||
} else { //Somethings wrong
|
||||
json::reply(array("result" => "error", "message" => (string)$error_noselection));
|
||||
@ -166,13 +176,16 @@ class photoannotation_Controller extends Controller {
|
||||
->where("id", "=", $annotate_id)
|
||||
->find();
|
||||
if ($user_id != "") { //Conversion note -> user
|
||||
photoannotation::saveuser($user_id, $item_id, $str_x1, $str_y1, $str_x2, $str_y2, $description);
|
||||
$new_id = photoannotation::saveuser($user_id, $item_id, $str_x1, $str_y1, $str_x2, $str_y2, $description);
|
||||
$dest_type = "user";
|
||||
$updatednote->delete(); //delete old note
|
||||
} elseif ($tag_data != "") { //Conversion note -> face
|
||||
photoannotation::saveface($tag_data, $item_id, $str_x1, $str_y1, $str_x2, $str_y2, $description);
|
||||
$new_id = photoannotation::saveface($tag_data, $item_id, $str_x1, $str_y1, $str_x2, $str_y2, $description);
|
||||
$dest_type = "face";
|
||||
$updatednote->delete(); //delete old note
|
||||
} elseif ($item_title != "") { //Conversion note -> note
|
||||
photoannotation::savenote($item_title, $item_id, $str_x1, $str_y1, $str_x2, $str_y2, $description, $annotate_id);
|
||||
$new_id = photoannotation::savenote($item_title, $item_id, $str_x1, $str_y1, $str_x2, $str_y2, $description, $annotate_id);
|
||||
$dest_type = "note";
|
||||
} else { //Somethings wrong
|
||||
json::reply(array("result" => "error", "message" => (string)$error_noselection));
|
||||
return;
|
||||
@ -184,8 +197,47 @@ class photoannotation_Controller extends Controller {
|
||||
}
|
||||
}
|
||||
//@todo: add needed data to the json reply
|
||||
json::reply(array("result" => "success"));
|
||||
return;
|
||||
$int_text = "";
|
||||
$editable = true;
|
||||
switch ($dest_type) {
|
||||
case "user":
|
||||
$fullname = module::get_var("photoannotation", "fullname", false);
|
||||
$int_text = $getuser->user->display_name() ." (". $getuser->user->name .")";
|
||||
if ($fullname) {
|
||||
$note_text = $getuser->user->display_name();
|
||||
} else {
|
||||
$note_text = $getuser->user->name;
|
||||
}
|
||||
$note_url = user_profile::url($getuser->user->id);
|
||||
break;
|
||||
case "face":
|
||||
$note_text = $tag->name;
|
||||
$note_url = $tag->url();
|
||||
break;
|
||||
case "note":
|
||||
$note_text = $item_title;
|
||||
$note_url = "";
|
||||
$editable = false;
|
||||
}
|
||||
if ($annotate_id == -1) {
|
||||
$annotation_id = "";
|
||||
} else {
|
||||
$annotation_id = "photoannotation-area-". $notetype ."-". $annotate_id;
|
||||
}
|
||||
$reply = array("result" => "success",
|
||||
"notetype" => (string)$dest_type,
|
||||
"description" => (string)$description,
|
||||
"height" => (integer)$_POST["height"],
|
||||
"internaltext" => (string)$int_text,
|
||||
"left" => (integer)$str_x1,
|
||||
"noteid" => (integer)$new_id,
|
||||
"text" => (string)$note_text,
|
||||
"top" => (integer)$str_y1,
|
||||
"url" => (string)$note_url,
|
||||
"width" => (integer)$_POST["width"],
|
||||
"editable" => (boolean)$editable,
|
||||
"annotationid" => (string)$annotation_id);
|
||||
json::reply($reply);
|
||||
}
|
||||
|
||||
public function delete($item_data) {
|
||||
|
@ -69,7 +69,6 @@
|
||||
color: #f30;
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.image-annotate-canvas {
|
||||
background-position: left top;
|
||||
background-repeat: no-repeat;
|
||||
|
@ -99,6 +99,7 @@ class photoannotation_Core {
|
||||
$item_user->y2 = $str_y2;
|
||||
$item_user->description = $description;
|
||||
$item_user->save();
|
||||
return $item_user->id;
|
||||
}
|
||||
|
||||
public static function saveface($tag_id, $item_id, $str_x1, $str_y1, $str_x2, $str_y2, $description, $annotate_id = "") {
|
||||
@ -117,6 +118,7 @@ class photoannotation_Core {
|
||||
$item_face->y2 = $str_y2;
|
||||
$item_face->description = $description;
|
||||
$item_face->save();
|
||||
return $item_face->id;
|
||||
}
|
||||
|
||||
public static function savenote($item_title, $item_id, $str_x1, $str_y1, $str_x2, $str_y2, $description, $annotate_id = "") {
|
||||
@ -135,6 +137,7 @@ class photoannotation_Core {
|
||||
$item_note->title = $item_title;
|
||||
$item_note->description = $description;
|
||||
$item_note->save();
|
||||
return $item_note->id;
|
||||
}
|
||||
|
||||
public static function send_notifications($recipient_id, $item_id, $mailtype) {
|
||||
|
@ -21,7 +21,7 @@ class photoannotation_theme_Core {
|
||||
static function head($theme) {
|
||||
$theme->css("photoannotation.css");
|
||||
if ($theme->page_subtype == "photo") {
|
||||
//$theme->script("jquery.annotate.min.js");
|
||||
$theme->script("jquery.annotate.min.js");
|
||||
$noborder = module::get_var("photoannotation", "noborder", false);
|
||||
$noclickablehover = module::get_var("photoannotation", "noclickablehover", false);
|
||||
$nohover = module::get_var("photoannotation", "nohover", false);
|
||||
@ -60,7 +60,7 @@ class photoannotation_theme_Core {
|
||||
}\n";
|
||||
}
|
||||
}
|
||||
$v .= "</style>\n<script type=\"text/javascript\" src=\"/gallery3/modules/photoannotation/js/jquery.annotate.js\"></script>";
|
||||
$v .= "</style>\n";
|
||||
return $v;
|
||||
}
|
||||
}
|
||||
|
@ -26,13 +26,13 @@
|
||||
this.cssaclass = opts.cssaclass;
|
||||
this.rtlsupport = opts.rtlsupport;
|
||||
this.users = opts.users;
|
||||
anchor = $('.g-fullsize-link');
|
||||
|
||||
// Add the canvas
|
||||
this.canvas = $('<div class="image-annotate-canvas g-thumbnail"><div class="image-annotate-view"></div><div class="image-annotate-edit"><div class="image-annotate-edit-area"></div></div></div>');
|
||||
this.canvas = $('<div class="image-annotate-canvas g-thumbnail"><div class="image-annotate-view"><div id="photoannotation-fullsize" class="image-annotate-note"></div></div><div class="image-annotate-edit"><div class="image-annotate-edit-area"></div></div></div>');
|
||||
this.canvas.children('.image-annotate-edit').hide();
|
||||
this.canvas.children('.image-annotate-view').hide();
|
||||
$('#g-photo').after(this.canvas);
|
||||
//this.image.after(this.canvas);
|
||||
|
||||
// Give the canvas and the container their size and background
|
||||
this.canvas.height(this.height());
|
||||
@ -45,10 +45,12 @@
|
||||
this.canvas.hover(function() {
|
||||
if ($(this).children('.image-annotate-edit').css('display') == 'none') {
|
||||
$(this).children('.image-annotate-view').show();
|
||||
$("#photoannotation-fullsize").show();
|
||||
}
|
||||
}, function() {
|
||||
$(this).children('.image-annotate-view').hide();
|
||||
$(this).children('.image-annotate-note').hide();
|
||||
$("#photoannotation-fullsize").hide();
|
||||
});
|
||||
|
||||
this.canvas.children('.image-annotate-view').hover(function() {
|
||||
@ -76,7 +78,11 @@
|
||||
|
||||
// Hide the original
|
||||
this.hide();
|
||||
|
||||
$('#g-photo').hide();
|
||||
$('.image-annotate-canvas').show();
|
||||
$(".g-resize").remove();
|
||||
$("#photoannotation-fullsize").append($('.g-fullsize-link:first'));
|
||||
$('.g-fullsize-link').append($('.g-fullsize-link:first').attr('title'));
|
||||
return this;
|
||||
};
|
||||
|
||||
@ -156,7 +162,7 @@
|
||||
|
||||
ok.click(function() {
|
||||
var form = $('#image-annotate-edit-form form');
|
||||
$.fn.annotateImage.appendPosition(form, editable)
|
||||
$.fn.annotateImage.appendPosition(form, editable);
|
||||
$.ajax({
|
||||
url: saveUrl,
|
||||
type: 'POST',
|
||||
@ -206,20 +212,25 @@
|
||||
buttons: btns
|
||||
});
|
||||
} else {
|
||||
var test = saveUrl;
|
||||
var newnote = new array();
|
||||
newnote.description = data.description;
|
||||
newnote.editable = true;
|
||||
newnote.height = data.height;
|
||||
newnote.internaltext = data.internaltext;
|
||||
newnote.left = data.left;
|
||||
newnote.noteid = data.noteid;
|
||||
newnote.notetype = data.notetype;
|
||||
newnote.text = data.text;
|
||||
newnote.top = data.top;
|
||||
newnote.url = data.url;
|
||||
newnote.width = data.width;
|
||||
$.fn.annotateView(!image, newnote, !image.tags, !image.labels, !image.editable, !image.csrf, !image.deleteUrl, !image.saveUrl, !image.cssaclass, !image.rtlsupport, !image.users);
|
||||
if (data.annotationid != "") {
|
||||
$("#" + data.annotationid).remove();
|
||||
$("#" + data.annotationid + "-edit").remove();
|
||||
$("#" + data.annotationid + "-delete").remove();
|
||||
$("#" + data.annotationid + "-note").remove();
|
||||
}
|
||||
editable.description = data.description;
|
||||
editable.editable = data.editable;
|
||||
editable.height = data.height;
|
||||
editable.internaltext = data.internaltext;
|
||||
editable.left = data.left;
|
||||
editable.noteid = data.noteid;
|
||||
editable.notetype = data.notetype;
|
||||
editable.text = data.text;
|
||||
editable.top = data.top;
|
||||
editable.url = data.url;
|
||||
editable.width = data.width;
|
||||
note = new $.fn.annotateView(image, editable, image.tags, image.labels, image.editable, image.csrf, image.deleteUrl, image.saveUrl, image.cssaclass, image.rtlsupport, image.users);
|
||||
|
||||
//@todo: save new annotation / update existing annotation
|
||||
//success
|
||||
}
|
||||
@ -421,8 +432,8 @@
|
||||
image.canvas.children('.image-annotate-view').prepend(this.area);
|
||||
|
||||
if (editable) {
|
||||
this.delarea = $('<div class="image-annotate-area photoannotation-del-button" rel="photoannotation-area-' + this.note.notetype + "-" + this.note.noteid + '"><div><form id="photoannotation-area-' + this.note.notetype + "-" + this.note.noteid + '-del-form" class="photoannotation-del-form" method="post" action="' + deleteUrl + '"><input type="hidden" name="notetype" value="' + this.note.notetype + '" /><input type="hidden" name="noteid" value="' + this.note.noteid + '" /><input type="hidden" name="csrf" value="' + csrf + '" /></form></div></div>');
|
||||
this.editarea = $('<div id="photoannotation-edit-' + this.note.noteid + '" class="image-annotate-area photoannotation-edit-button"><div></div></div>');
|
||||
this.delarea = $('<div id="photoannotation-area-' + this.note.notetype + "-" + this.note.noteid + '-delete" class="image-annotate-area photoannotation-del-button" rel="photoannotation-area-' + this.note.notetype + "-" + this.note.noteid + '"><div><form id="photoannotation-area-' + this.note.notetype + "-" + this.note.noteid + '-del-form" class="photoannotation-del-form" method="post" action="' + deleteUrl + '"><input type="hidden" name="notetype" value="' + this.note.notetype + '" /><input type="hidden" name="noteid" value="' + this.note.noteid + '" /><input type="hidden" name="csrf" value="' + csrf + '" /></form></div></div>');
|
||||
this.editarea = $('<div id="photoannotation-area-' + this.note.notetype + "-" + this.note.noteid + '-edit" class="image-annotate-area photoannotation-edit-button"><div></div></div>');
|
||||
image.canvas.children('.image-annotate-view').prepend(this.delarea);
|
||||
image.canvas.children('.image-annotate-view').prepend(this.editarea);
|
||||
this.delarea.bind('click',function () {
|
||||
@ -465,6 +476,9 @@
|
||||
success: function(data) {
|
||||
if (data.result == "success") {
|
||||
$("#" + data.annotationid).remove();
|
||||
$("#" + data.annotationid + "-edit").remove();
|
||||
$("#" + data.annotationid + "-delete").remove();
|
||||
$("#" + data.annotationid + "-note").remove();
|
||||
}
|
||||
},
|
||||
dataType: "json"
|
||||
@ -494,7 +508,7 @@
|
||||
if (note.description != "") {
|
||||
notedescription = "<br />" + note.description;
|
||||
}
|
||||
this.form = $('<div class="image-annotate-note">' + note.text + notedescription + '</div>');
|
||||
this.form = $('<div id="photoannotation-area-' + this.note.notetype + "-" + this.note.noteid + '-note" class="image-annotate-note">' + note.text + notedescription + '</div>');
|
||||
this.form.hide();
|
||||
image.canvas.children('.image-annotate-view').append(this.form);
|
||||
this.form.children('span.actions').hide();
|
||||
@ -573,6 +587,7 @@
|
||||
this.delarea.css('top', (this.note.top) + 'px');
|
||||
this.editarea.children('div').height('14px');
|
||||
this.editarea.children('div').width('14px');
|
||||
this.editarea.css('top', (this.note.top + 16) + 'px');
|
||||
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');
|
||||
@ -580,7 +595,6 @@
|
||||
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');
|
||||
}
|
||||
};
|
||||
|
||||
@ -663,6 +677,6 @@
|
||||
'<input type="hidden" value="' + editable.area.position().left + '" name="left"/>' +
|
||||
'<input type="hidden" value="' + editable.note.id + '" name="id"/>');
|
||||
form.append(areaFields);
|
||||
}
|
||||
};
|
||||
|
||||
})(jQuery);
|
||||
|
File diff suppressed because one or more lines are too long
@ -107,7 +107,7 @@
|
||||
}
|
||||
}
|
||||
$legend_display = $legend_users . $legend_faces . $legend_notes;
|
||||
$labels_arraystring = "labels: [ '". t("Tag:") ."','". t("Note Title:") ."','". t("Description (optional)") ."','". t("Are you sure you want to delete this annotation?") ."','". t("or") ."','". t("Yes") ."','". t("No") ."','". t("Confirm deletion") ."','". t("Save") ."','". t("Cancel") ."','". t("Person:") ."','". t("No user selected") ."','". t("Select one of the following") ."','". t("An error ocurred while saving annotation") ."','". t("OK") ."','". t("An error ocurred while deleting annotation") ."' ],";
|
||||
$labels_arraystring = "labels: [ '". t("Tag:") ."','". t("Note Title:") ."','". t("Description (optional)") ."','". t("Are you sure you want to delete this annotation?") ."','". t("or") ."','". t("Yes") ."','". t("No") ."','". t("Confirm deletion") ."','". t("Save") ."','". t("Cancel") ."','". t("Person:") ."','". t("No user selected") ."','". t("Select one of the following") ."','". t("An error ocurred while saving annotation") ."','". t("OK") ."','". t("An error ocurred while deleting annotation") ."','". t("View fullsize") ."' ],";
|
||||
?>
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function() {
|
||||
|
Reference in New Issue
Block a user