diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md
index 7524b549..a8e64403 100644
--- a/docs/CHANGELOG.md
+++ b/docs/CHANGELOG.md
@@ -5,7 +5,13 @@ other versions come from the canonical LWT ("official" branch on Git).
For git tags, official releases are marked like "v1.0.0", while unofficial
ones are marked like "v1.0.0-fork".
-## [Unreleased]
+## [Unreleased]
+
+### Added
+
+* Word reading can be allowed on hover or on click.
+Pull request [#147](https://github.com/HugoFara/lwt/pull/147) by
+[@ProgramComputer](https://github.com/ProgramComputer).
### Fixed
diff --git a/docs/info.html b/docs/info.html
index 11da1107..00559814 100644
--- a/docs/info.html
+++ b/docs/info.html
@@ -2183,6 +2183,12 @@
▶ Changelog - [↑]
For git tags, official releases are marked like "v1.0.0", while unofficial
ones are marked like "v1.0.0-fork".
[Unreleased]
+Added
+
Fixed
The database wizard was broken since 2.9.0.
diff --git a/inc/session_utility.php b/inc/session_utility.php
index ead0c8e8..115a25c9 100644
--- a/inc/session_utility.php
+++ b/inc/session_utility.php
@@ -2409,16 +2409,23 @@ function get_annotation_position_selectoptions($v): string
}
// -------------------------------------------------------------
-function get_hts_selectoptions($v): string
+function get_hts_selectoptions($current_setting): string
{
- if (! isset($v) ) { $v = 1;
+ if (!isset($current_setting)) {
+ $current_setting = 1;
+ }
+ $options = array(
+ 1 => "Never",
+ 2 => "On Click",
+ 3 => "On Hover"
+ );
+ $r = "";
+ foreach ($options as $key => $value) {
+ $r .= sprintf(
+ '%s ',
+ $key, get_selected($current_setting, $key), $value
+ );
}
- $r = "'+$(this).text()+''}else{h+=''+$(this).text()+' '}});$(this).html(h)});$('#pe').remove();$('body').append('');$('[id$="-1"]',context).not('.hide,.wsty').addClass('nword').each(function(){$(this).attr('data_order',$(this).attr('id').split('-')[1])});$('.word',context).not('.hide').each(function(){$(this).html(''+$(this).text()+' ')});if(event.data.annotation==1){$('.wsty',context).not('.hide').each(function(){$(this).children('.tword').last().attr('data_ann',$(this).attr('data_ann')).attr('data_trans',$(this).attr('data_trans')).addClass('content'+$(this).removeClass('status1 status2 status3 status4 status5 status98 status99').attr('data_status'))})}else if(event.data.annotation==3){$('.wsty',context).not('.hide').each(function(){$(this).children('.tword').first().attr('data_ann',$(this).attr('data_ann')).attr('data_trans',$(this).attr('data_trans')).addClass('content'+$(this).removeClass('status1 status2 status3 status4 status5 status98 status99').attr('data_status'))})}
$(context).one('mouseover','.tword',function(){$('html').one('mouseup',function(){$('.wsty',context).each(function(){$(this).addClass('status'+$(this).attr('data_status'))});if(!$(this).hasClass('tword')){$('span',context).removeClass('nword tword lword');$('.wsty',context).css('background-color','').css('border-bottom-color','');$('#pe').remove()}});pos=parseInt($(this).attr('data_order'));$('.lword',context).removeClass('lword');$(this).addClass('lword');$(context).on('mouseleave',function(){$('.lword',context).removeClass('lword')});$(context).one('mouseup','.nword,.tword',function(ev){if(ev.handled!==!0){const len=$('.lword.tword',context).length;if(len>0){g=$('.lword',context).first().attr('data_order');if(len>1){const text=$('.lword',context).map(function(){return $(this).text()}).get().join('');if(text.length>250){alert('selected text is too long!!!')}else{showRightFrames('edit_mword.php?tid='+TID+'&len='+len+'&ord='+g+'&txt='+text)}}else{showRightFrames('edit_word.php?tid='+TID+'&ord='+g+'&txt='+$('#ID-'+g+'-1').text())}}
$('span',context).removeClass('tword nword');ev.handled=!0}})});$(context).hoverIntent({over:function(){$('.lword',context).removeClass('lword');const lpos=parseInt($(this).attr('data_order'));$(this).addClass('lword');if(lpos>pos){for(var i=pos;ilpos;i--){$('.tword[data_order="'+i+'"],.nword[data_order="'+i+'"]',context).addClass('lword')}}},out:function(){},sensitivity:18,selector:'.tword'})},300)}
function word_hover_over(){if(!$('.tword')[0]){const v=$(this).attr('class').replace(/.*(TERM[^ ]*)( .*)*/,'$1');$('.'+v).addClass('hword');if(JQ_TOOLTIP){$(this).trigger('mouseover')}
-if(HTS){const lg=getLangFromDict(WBLINK3);readTextAloud($(this).text(),lg)}}}
+if(HTS==3){const lg=getLangFromDict(WBLINK3);readTextAloud($(this).text(),lg)}}}
function word_hover_out(){$('.hword').removeClass('hword');if(JQ_TOOLTIP)$('.ui-helper-hidden-accessible>div[style]').remove();}
jQuery.fn.extend({tooltip_wsty_content:function(){var re=new RegExp('(['+DELIMITER+'])(?! )','g');let title='';if($(this).hasClass('mwsty')){title=""+$(this).attr('data_text')+'
'}else{title=""+$(this).text()+'
'}
const roman=$(this).attr('data_rom');let trans=$(this).attr('data_trans').replace(re,'$1 ');let statname='';const status=parseInt($(this).attr('data_status'));if(status==0)statname='Unknown [?]';else if(status<5)statname='Learning ['+status+']';if(status==5)statname='Learned [5]';if(status==98)statname='Ignored [Ign]';if(status==99)statname='Well Known [WKn]';if(roman!=''){title+='Roman. : '+roman+'
'}
diff --git a/settings.php b/settings.php
index 2436ca7d..385fc3d4 100644
--- a/settings.php
+++ b/settings.php
@@ -111,10 +111,11 @@
1 : 0
)
);
+
saveSetting(
'set-hts',
- $_REQUEST['set-hts']
- );
+ $_REQUEST['set-hts']
+ );
saveSetting(
'set-archivedtexts-per-page',
diff --git a/src/js/jq_pgm.js b/src/js/jq_pgm.js
index f692cba6..0ea301f8 100644
--- a/src/js/jq_pgm.js
+++ b/src/js/jq_pgm.js
@@ -642,6 +642,8 @@ function word_dblclick_event_do_text_text () {
/**
* Do a word edition window. Usually called when the user clicks on a word.
*
+ * @since 2.9.10-fork Read word aloud if HTS equals 2.
+ *
* @returns {bool} false
*/
function word_click_event_do_text_text () {
@@ -693,6 +695,10 @@ function word_click_event_do_text_text () {
$(this).text(), $(this).attr('data_wid'), status, multi_words, RTL, ann
);
}
+ if (HTS == 2) {
+ const lg = getLangFromDict(WBLINK3);
+ readTextAloud($(this).text(), lg);
+ }
return false;
}
@@ -715,10 +721,10 @@ function mword_click_event_do_text_text () {
$(this).attr('data_wid'), status, $(this).attr('data_code'), ann
);
}
- if (HTS == 2) {
+ if (HTS == 2) {
const lg = getLangFromDict(WBLINK3);
readTextAloud($(this).text(), lg);
- }
+ }
return false;
}