From 6b32fb9a011c2f8a19e3b2208f4b92a7ebe644bc Mon Sep 17 00:00:00 2001 From: Isaac Flores Date: Thu, 29 Oct 2009 13:13:59 -0500 Subject: [PATCH] Improvements of glossary in several tools --- .../glossary/fck_glossary_automatic.js | 20 ++++++++++++++----- main/inc/lib/javascript/glossary.js | 17 ++++++++++------ main/newscorm/scorm_api.php | 13 +++++++++--- 3 files changed, 36 insertions(+), 14 deletions(-) diff --git a/main/inc/lib/fckeditor/editor/plugins/glossary/fck_glossary_automatic.js b/main/inc/lib/fckeditor/editor/plugins/glossary/fck_glossary_automatic.js index 172930f30d..33e6274908 100755 --- a/main/inc/lib/fckeditor/editor/plugins/glossary/fck_glossary_automatic.js +++ b/main/inc/lib/fckeditor/editor/plugins/glossary/fck_glossary_automatic.js @@ -18,12 +18,14 @@ $(document).ready(function() { data_terms=datas.split("[|.|_|.|-|.|]"); for(i=0;i]('+specific_terms[1]+')',"g"); - new_html=my_text.replace(my_specific_terms,""+specific_terms[1]+""); + var real_term = specific_terms[1]; + var my_specific_terms = new RegExp('([^A-Za-z0-9/_\<>])'+specific_terms[1]+'[\ .,]{0,1}',"gi"); + new_html=my_text.replace(my_specific_terms,function(m){return replace_complete_char(m)}); $("body").html(new_html); my_text=$("body").html(); } - + + //mouse over event $("body .glossary-ajax").mouseover(function(){ random_id=Math.round(Math.random()*100); div_show_id="div_show_id"+random_id; @@ -46,14 +48,22 @@ $(document).ready(function() { } }); }); + + //mouse out event $("body .glossary-ajax").mouseout(function(){ var current_element, current_element=$(this); div_show_id=current_element.find("div").attr("id"); $("div#"+div_show_id).remove(); }); - - + + //Callback Helper + function replace_complete_char(m) { + var complete_term_pattern = new RegExp(real_term,"i"); + var tag = m.replace(complete_term_pattern," $&"); + return tag; + } + } }); diff --git a/main/inc/lib/javascript/glossary.js b/main/inc/lib/javascript/glossary.js index ce83b876ad..1270723feb 100644 --- a/main/inc/lib/javascript/glossary.js +++ b/main/inc/lib/javascript/glossary.js @@ -20,11 +20,11 @@ $(document).ready(function() { for(i=0;i])('+specific_terms[1]+')',"g"); - new_html=my_text.replace(my_specific_terms," "+specific_terms[1]+""); - $(".glossary-content").html(new_html); - my_text=$(".glossary-content").html(); - + var real_term = specific_terms[1]; + var my_specific_terms = new RegExp('([^A-Za-z0-9/_\<>])'+specific_terms[1]+'[\ .,]{0,1}',"gi"); + new_html=my_text.replace(my_specific_terms,function(m){return replace_complete_char(m)}); + $(".glossary-content").html(new_html); + my_text=$(".glossary-content").html(); } $(".glossary-content .glossary-ajax").mouseover(function(){ @@ -55,7 +55,12 @@ $(document).ready(function() { div_show_id=current_element.find("div").attr("id"); $("div#"+div_show_id).remove(); }); - + + function replace_complete_char(m) { + var complete_term_pattern = new RegExp(real_term,"i"); + var tag = m.replace(complete_term_pattern," $&"); + return tag; + } } diff --git a/main/newscorm/scorm_api.php b/main/newscorm/scorm_api.php index 2e6b62888c..43f5dcb1f5 100755 --- a/main/newscorm/scorm_api.php +++ b/main/newscorm/scorm_api.php @@ -1617,8 +1617,9 @@ function attach_glossary_into_scorm() { data_terms=datos.split("[|.|_|.|-|.|]"); for(i=0;i]('+specific_terms[1]+')',"g"); - new_html=my_text.replace(my_specific_terms," "+specific_terms[1]+""); + var real_term = specific_terms[1]; + var my_specific_terms = new RegExp('([^A-Za-z0-9/_\<>])'+specific_terms[1]+'[\ .,]{0,1}',"gi"); + new_html=my_text.replace(my_specific_terms,function(m){return replace_complete_char(m)}); $frame_content.html(new_html); my_text=$frame_content.html(); } @@ -1652,7 +1653,13 @@ function attach_glossary_into_scorm() { div_show_id=current_element.find("div").attr("id"); $("iframe").contents().find('body').find("div#"+div_show_id).remove(); }); - + + //Callback Helper + function replace_complete_char(m) { + var complete_term_pattern = new RegExp(real_term,"i"); + var tag = m.replace(complete_term_pattern," $&"); + return tag; + } }