$(function() { // add the close button $("#personalnote").prepend('close'); // 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('
Bezig met laden...
'); } function personalnote_load(id){ // the id attribute cannot contain / or %2F so these have been replaced with : // to separate the ref of the item we used :: (and also the tool was added in front because the id attribute has to start with a letter) var information = id.split('::'); // getting the tool var url = $(location).attr('href'); url = url.replace("http://stagescholen.augent.be/pcvowaasendurme/elo/main/",""); url = url.split('/'); var tool = url[0]; // showing only the last part of the title var fullname = information[1].replace(/:/g,'/'); // attention: the javascript replace function only replaces the first occurence so we use this regex var nameparts = fullname.split('/'); name = nameparts[nameparts.length-1]; // setting the title of the personal note (/ or %2F has been replaced with : in the id attribute) $("#personalnotecontent").html(""+urldecode(name)+""); // getting the content and displaying it $.get("http://stagescholen.augent.be/pcvowaasendurme/elo/main/inc/lib/personalnote.lib.php", {action:"get_personalnote",user_id: "", course: "", tool: tool,ref: information[2]}, function(text) { $("#personalnotecontent").append('
Opslaan
Verwijderen
'); }); }