$(function() {
// add the close button
$("#personalnote").prepend('
');
// clear the note
personalnote_clear();
// close the personal note
$("#personalnoteclose").live('click',function(){
$("#personalnote").slideUp();
personalnote_clear();
})
// show the personal note (if there is another personal note already showing we first hide it and then show the second one
$(".personalnotetrigger").live('click',function(){
// storing the identifier of the personal note (the id)
var identifier = $(this).attr("id");
// if there is already a personalnote visible we first have to slide it away and then remove the content and then load the requested note
if($("#personalnote").is(':visible')) {
// slide the already visible note away
$("#personalnote").slideUp();
// clear the personal note
personalnote_clear();
// show the personal note and load the content of the personal note
$("#personalnote").slideDown(function(){
personalnote_load(identifier);
});
} else {
// show the personalnote
$("#personalnote").slideDown();
// load the content of the personal note
personalnote_load(identifier);
}
});
// save the personal note
$("#personalnotesave").live('click', function(){
var course = $("#form_course").val();
var tool = $("#form_tool").val();
var ref = $("#form_ref").val();
var user_id = $("#form_user_id").val();
var content = $("#personalnotecontenttext").val();
var identifier = $("#form_identifier").val();
$.post("http://stagescholen.augent.be/pcvowaasendurme/elo/main/inc/lib/personalnote.lib.php", {action:"save_personalnote",user_id: user_id, course: course, tool: tool,ref: ref, content: content},
function(text) {
// display the feedback message
$("#personalnotesactions").append(text)
// hide the feedback message after X seconds
setTimeout(function () { $('.feedback').fadeOut('slow', function(){ $('.feedback').remove(); }); }, 2000);
// change the personal note icon of the item
$("."+tool+ref).attr("src","http://stagescholen.augent.be/pcvowaasendurme/elo/main/img/personalnote.png");
});
});
// delete the personal note
$("#personalnotedelete").live('click', function(){
var course = $("#form_course").val();
var tool = $("#form_tool").val();
var ref = $("#form_ref").val();
var user_id = $("#form_user_id").val();
var content = $("#personalnotecontenttext").val();
var identifier = $("#form_identifier").val();
$.post("http://stagescholen.augent.be/pcvowaasendurme/elo/main/inc/lib/personalnote.lib.php", {action:"delete_personalnote",user_id: user_id, course: course, tool: tool,ref: ref, content: content},
function(text) {
// display the feedback message
$("#personalnotesactions").append(text)
// hide the feedback message after X seconds
setTimeout(function () { $('.feedback').fadeOut('slow', function(){ $('.feedback').remove(); }); }, 2000);
// change the personal note icon of the item
$("."+tool+ref).attr("src","http://stagescholen.augent.be/pcvowaasendurme/elo/main/img/personalnote_na.png");
// remove the content in the form
$("#personalnotecontenttext").val('')
});
});
});
function personalnote_clear(){
$("#personalnotecontent").html('
