/* ---------------------------- */ /* XMLHTTPRequest Enable */ /* ---------------------------- */ function createObject() { var request_type; var browser = navigator.appName; if(browser == "Microsoft Internet Explorer"){ request_type = new ActiveXObject("Microsoft.XMLHTTP"); }else{ request_type = new XMLHttpRequest(); } return request_type; } var http = createObject(); /* -------------------------- */ /* INSERT */ /* -------------------------- */ /* Required: var nocache is a random number to add to request. This value solve an Internet Explorer cache issue */ var nocache = 0; function insert() { // Optional: Show a waiting message in the layer with ID login_response // Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding. var note= encodeURI(document.getElementById('note').value); var newnote= document.getElementById('note').value.replace(/(<([^>]+)>)/ig,""); var nid= encodeURI(document.getElementById('nid').value); var vid= encodeURI(document.getElementById('vid').value); var classe= encodeURI(document.getElementById('classe').value); if (note) { coloramatita(); } else { puliscimatita(); } // Update the new note cookie variable $.cookie(classe, newnote); // Pass the login variables like URL variable http.open('get', 'http://' + document.location.host + Drupal.settings.basePath + 'mynotes/insert?note=' + note + '&nid=' + nid + '&vid=' + vid + '&classe=' + classe); //http.onreadystatechange = insertReply; http.send(null); } function coloramatita(){ $("li.triggernote a").addClass('note-on'); } // end coloramatita function puliscimatita(){ $("li.triggernote a").removeClass('note-on'); } // end puliscimatita $(document).ready(function(){ var linkclasse = $('li.triggernote span', '#block-jquery_utils-0').html(); $('#block-jquery_utils-0').append('
'); $('#block-multiblock-1').append('
'); //$('#content-area').addClass('note-stripe'); DECOMMENTARE PER OTTENERE VECCHIA FUNZIONALITA loadnote(); /*if (Drupal.settings.mynotes.mod == '1') { switchover(); }*/ var label = $('li.triggernote').children().attr('title'); $('li.triggernote').children().wrap(''); $("li.triggernote").click(function () { $(".mynote").trigger('click'); }); function switchover() { // popup mode: $("p").mouseover(function(){ $(this).children(".note").removeClass("hide"); }); $("p").mouseout(function(){ $(this).children(".note").addClass("hide"); }); } function loadnote(){ /* * 25 Agosto 2011 - 16.42 * * Bug - Traduzione dei bottoni da client e non da server. * * Scoperto - 25 Agosto 2011 - In occasione della traduzione del sito GPW in polacco. * * I bottoni venivano inviati dal server via json. non venivano tradotti in quanto la richiesta non era effettuata tramite lingua. * ( nella url non era presente) * Aggiunta al lingua nella url. Se la lingua non è definita, uso come fallback il vecchio sistema. * * Adesso le traduzioni di SALVA CHIUDI CANCELLA si possono effettuare tramite il sistema di translate interface * * Fabrizio Rapelli * */ var lll = $('html').attr('lang'); if(!!lll){ lll = lll+"/"; }else{ lll=''; } //get mynotes variables $.ajax({ url: "http://"+document.location.host+Drupal.settings.basePath+lll+"mynotes/select", dataType: 'json', async: false, success: function(json){ //success code: var marginleft = 0; //var marginleft = Drupal.settings.mynotes.marginleft; DECOMMENTA PER RISPRISTINARE CONTROLLO DA INTERFACCIA // get strings variables save = json.strings[1]; clos = json.strings[2]; cancel = json.strings[3]; var lingua = $('html').attr('lang'); if (lingua == 'it') { save = 'salva'; clos = 'chiudi'; cancel = 'elimina'; } else { /*save = 'save'; clos = 'close'; cancel = 'delete';*/ } width = 200; sidewidth = 200; count = 1; nid = Drupal.settings.mynotes.nid; vid = json.vid; jQuery.each($("#notes-wrapper"), function() { $(this).addClass('paragraph paragraph-'+nid+'-'+count); var testonota = json.notes['paragraph-'+nid+'-'+count]; //create cookie to save the note $.cookie('paragraph-'+nid+'-'+count, json.notes['paragraph-'+count]); var classiparagrafo = $('div#notes-wrapper').attr('class').split(" "); var classeparagrafo = classiparagrafo[2]; if ($.cookie(classeparagrafo)) { $('body').addClass('note-on'); } $(Drupal.settings.mynotes.blacklist).addClass('blacklisted'); if ($(this).hasClass("blacklisted")) {} else { if (testonota) { switch(Drupal.settings.mynotes.mod) { // Se utilizziamo la modalità "Barra laterale" estraggo le note e le visualizzo di fianco ai paragrafi ---- 'mod = 0' case '0': //RIMUOVERE CLASS HIDE PER OTTENERE LE NOTE VICINO AL PARAGRAFO $(this).prepend('
' + testonota + '
'); $('.note').click(editnote); $('.mynote-true').click(editnote); break; // Se utilizziamo la modalità "Pop Up" estraggo le note e le visualizzo onmouseover ---- 'mod = 1' case '1': //RIMUOVERE CLASS HIDE PER OTTENERE LE NOTE VICINO AL PARAGRAFO $(this).prepend('
' + testonota + '
'); $('.note-edit-popup').click(editnote); $('.mynote-true').click(editnote); break; } // end switch mod } // end if (testonota) else { //RIMUOVERE CLASS HIDE PER OTTENERE LE NOTE VICINO AL PARAGRAFO $(this).prepend('
'); $('.mynote-false').click(editnote); } // end if .not empty paragraph count++; if (Drupal.settings.mynotes.opt1 == 'no') { // esc function after the first paragraph return false; } } // end if hasClass("blacklisted") }); //end jQuery.each($(".node p"), function() } }); // end getJSON } // end loadnote var marginleft = 0; //var marginleft = Drupal.settings.mynotes.marginleft; DECOMMENTA PER RISPRISTINARE CONTROLLO DA INTERFACCIA switch(Drupal.settings.mynotes.mod) { case '0': var editclass = 'note-edit'; break; case '1': var editclass = 'note-edit-popup'; break; } // end switch mod function editnote(){ $("#notes-wrapper").removeClass('hide'); var height = $(this).parent().height(); var classi = $(this).parent().attr('class').split(" "); var classe = classi[1]; var is = $(this); is.prev('.mynote').remove(); is.next('.note-edit-popup').remove(); var testonota = $.cookie(classe); if (testonota==null) { testonota = ''; } var inputform = '

'+save+'

-

'+cancel+'

-

'+clos+'

'; is.fadeOut(100, function(){ is.replaceWith(inputform); $('p.submit').click(savenote); $('p.close').click(closenote); $('p.cancel').click(deletenote); }); is.fadeIn(); } // end editnote function savenote(){ insert(); $("#notes-wrapper").addClass('hide'); update_elements($(this)); } // end savenote function update_elements(x){ var marginleft = 0; //var marginleft = Drupal.settings.mynotes.marginleft; DECOMMENTA PER RISPRISTINARE CONTROLLO DA INTERFACCIA var classi = x.parent().parent().attr('class').split(" "); var classe = classi[1]; var testonota = $.cookie(classe); if (testonota) { switch(Drupal.settings.mynotes.mod) { // Se utilizziamo la modalità "Barra laterale" estraggo le note e le visualizzo di fianco ai paragrafi ---- 'mod = 0' case '0': x.parent().replaceWith('
' + testonota + '
'); $('.note').click(editnote); $('.mynote-true').click(editnote); break; // Se utilizziamo la modalità "Pop Up" estraggo le note e le visualizzo onmouseover ---- 'mod = 1' case '1': x.parent().replaceWith('
' + testonota + '
'); $('.note-edit-popup').click(editnote); $('.mynote-true').click(editnote); break; } // end switch mod } // end if testonota else { x.parent().replaceWith(''); $('.note').click(editnote); $('.mynote-false').click(editnote); } $(".loading").remove(); } // end update elements function closenote(){ $("#notes-wrapper").addClass('hide'); update_elements($(this)); } // end closenote function deletenote(){ // Required: verify that all fileds is not empty. Use encodeURI() to solve some issues about character encoding. var nid= encodeURI(document.getElementById('nid').value); var vid= encodeURI(document.getElementById('vid').value); var classe= encodeURI(document.getElementById('classe').value); // delete cookie variable $.cookie(classe, null); // Pass the login variables like URL variable http.open('get', 'http://' + document.location.host + Drupal.settings.basePath + 'mynotes/delete?nid=' + nid + '&vid=' + vid + '&classe=' + classe); //http.onreadystatechange = insertReply; http.send(null); $(this).fadeOut(); update_elements($(this)); puliscimatita(); } // end deletenote //correggo html nei links $('li.triggernote', '#block-jquery_utils-0').children().children().replaceWith(linkclasse); $("body.note-on li.triggernote a").addClass('note-on'); }); // end document.ready