diff --git a/languagetool/include/languagetool.min.js b/languagetool/include/languagetool.min.js index e361e43..57b0f91 100644 --- a/languagetool/include/languagetool.min.js +++ b/languagetool/include/languagetool.min.js @@ -6,7 +6,6 @@ * * Contributing: https://github.com/KnowZero/tinymce4-languagetool */ - var LanguageTool = function LanguageTool(lt_set,$) { // Declare Variables @@ -31,7 +30,6 @@ var LanguageTool = function LanguageTool(lt_set,$) { var lt_remoteTimer = lt_set['lt_timer'] || 10000; // DO NOT CHANGE UNLESS YOU USE YOUR OWN URL! - var lt_setLanguage = lt_set['lt_lang'] || "en-US"; var lt_setMode = lt_set['lt_mode'] || "new_sentence"; @@ -39,6 +37,7 @@ var LanguageTool = function LanguageTool(lt_set,$) { var lt_setHighlight = lt_set['lt_highlight'] || {}; var lt_debugLevel = lt_set['lt_debug'] || 0; var lt_ignoreCallback = lt_set['lt_ignore_callback'] || function () {}; + var lt_onNext = lt_set['lt_on_next'] || function () {}; var lt_monopolizeHighlightContextMenu = lt_set['lt_monopolize_highlight_contextmenu'] || true; var lt_highlightClick = lt_set['lt_highlight_click'] || "right"; var lt_fullMessage = lt_set['lt_full_message'] || false; @@ -487,6 +486,40 @@ toval = '#lt_issueChangeTo'; lt_contextMenuClick( $(sug).data('ident-UUID'), $(sug).data('ident-HID'), $(toval).val(), 1 ); }; +var setAcceptAllDialog = function(sug, toval){ + if (sug == undefined) { + sug = '#lt_issueSuggestions'; + toval = '#lt_issueChangeTo'; + } + var uuid = $(sug).data('ident-UUID'); + var hid = $(sug).data('ident-HID'); + var value = $(toval).val(); + var mode = 1; + lt_debug( 'INFO|CONTEXT-ITEM='+uuid+'='+hid+'='+value, 4 ); + sgfunc['setundo'].call(); + + //var uuid = $(this).data("ident-uuid"); + sgstore['lock'][uuid]=0; + + var mynode = sgstore['contextmenu']; + sgstore['run'].push({ + node: mynode, mode:mode, + func: function () { + $( sgfunc['body'].call() ).find( 'span[data-word="'+window.btoa( encodeURIComponent(sgstore['lt'][uuid][hid]['word']) )+'"]' ).each(function () { + $(this).replaceWith( value ); + + }); + + if ( (this.mode||0) == 1 ) { + lt_nextIssue(); + } + + //lt_ignoreCallback.call(this,'addWord',sgstore['lt'][uuid][hid]['rule']['id']); + } + + }); +}; + // Queues @@ -532,7 +565,6 @@ lt_contextMenuClick( $(sug).data('ident-UUID'), $(sug).data('ident-HID'), $(tova lt_inactive+=100; timerRunner+=100; lastActive+=100; - $.each(sgstore['run'], function(i,val) { sgstore['run'][i].func(); }); @@ -1221,7 +1253,7 @@ $(progress_bar).val( sgstore['progress'][0] ); // Suggestion Dialog function lt_nextIssue (firstOpen) { - + lt_debug('INFO|NEXT-ISSUE='+firstOpen, 4 ); var mynode = $( sgfunc['body'].call() ).find('.lt-highlight').not('.skip-dialog-highlight').get(0); if (mynode == undefined) { @@ -1233,7 +1265,7 @@ sgfunc['alert'].call(this,'Done!'); $(mynode).addClass( 'dialog-highlight' ); - + lt_onNext(mynode); var mypnode=lt_find_parent_node(mynode); var uuid = $(mypnode).data('UUID'); @@ -1241,7 +1273,7 @@ sgfunc['alert'].call(this,'Done!'); if ( (firstOpen||0) == 0 ) { -if ( $('#lt-filter-check-'+sgstore['lt'][uuid][hid]['rule']['issueType']+'[aria-checked="false"]').length == 1 ) { +if ( $('#lt-filter-check-'+sgstore['lt'][uuid][hid].rule.issueType+'[aria-checked="false"]').length == 1 ) { $(mynode).removeClass('dialog-highlight').addClass( 'skip-dialog-highlight' ); lt_nextIssue(); return false; @@ -1253,8 +1285,10 @@ return false; $('#lt_issueSuggestions').empty(); +var txtMsg = '[' + sgstore['lt'][uuid][hid]['rule']['issueType'].charAt(0).toUpperCase() + sgstore['lt'][uuid][hid]['rule']['issueType'].slice(1) + '] ' + sgstore['lt'][uuid][hid]['message']; +$('#lt_issueMessage').text(txtMsg).attr('title', txtMsg); -$('#lt_issueMessage').text( '[' + sgstore['lt'][uuid][hid]['rule']['issueType'].charAt(0).toUpperCase() + sgstore['lt'][uuid][hid]['rule']['issueType'].slice(1) + '] ' + sgstore['lt'][uuid][hid]['message'] ); +$('#lt_issueChangeTo').val('[NO SUGGESTIONS]'); $.each(sgstore['lt'][uuid][hid]['replacements'],function(key,val) { @@ -1485,7 +1519,7 @@ function lt_contextMenuClick(uuid,hid,value,mode) { lt_debug( 'INFO|CONTEXT-ITEM='+uuid+'='+hid+'='+value, 4 ); - sgfunc['setundo'].call() + sgfunc['setundo'].call(); //var uuid = $(this).data("ident-uuid"); @@ -1526,10 +1560,6 @@ function lt_contextMenuClick(uuid,hid,value,mode) { function lt_contextMenuIgnore (uuid,hid,value,mode) { - - - - // var uuid = $(this).data("ident-uuid"); // var hid = $(this).data("ident-hid"); sgstore['lock'][uuid]=0; @@ -1542,6 +1572,7 @@ function lt_contextMenuIgnore (uuid,hid,value,mode) { if ( value == 'once' ) { + lt_debug('INFO|IGNORE-ONCE='+sgstore['lt'][uuid][hid]['word'], 4 ); if ( sgstore['ignore']['once'][uuid] == undefined ) { sgstore['ignore']['once'][uuid]={}; } @@ -1553,7 +1584,6 @@ function lt_contextMenuIgnore (uuid,hid,value,mode) { if ( mynode.nodeName == 'SPAN' && $(mynode).hasClass('lt-highlight') == true ) { - sgstore['run'].push({ node: mynode, mode:mode, func: function () { @@ -1561,9 +1591,9 @@ function lt_contextMenuIgnore (uuid,hid,value,mode) { $( mynode ).replaceWith( $(mynode).html() ); lt_queue( uuid, $(mynode).parent(), 0, 0 ); - if ( (this.mode||0) == 1 ) { - lt_nextIssue(); - } + if ( (this.mode||0) == 1 ) { + lt_nextIssue(); + } //sgcheck[ uuid ]=lt_text($(mynode).parent().text()); //sgstore['html'][ uuid ]=lt_text($(mynode).parent().html()); @@ -1628,7 +1658,7 @@ sgfunc['confirm'].call(this,'Are you sure you wish to ignore this rule going for }); } - + lt_timer(0); // Resume if idle } @@ -1694,6 +1724,7 @@ return { setProgress: setProgress, nextIssue: nextIssue, setAcceptDialog: setAcceptDialog, + setAcceptAllDialog: setAcceptAllDialog, setIgnoreDialog: setIgnoreDialog, setSkipDialog: setSkipDialog, diff --git a/languagetool/plugin.min.js b/languagetool/plugin.min.js index f957753..6ce338a 100644 --- a/languagetool/plugin.min.js +++ b/languagetool/plugin.min.js @@ -286,7 +286,11 @@ LT.setStore('viewport_process','temp'); var tfilter=[]; $.each( LT.highlightList ,function(key,val){ - tfilter.push( {type: 'checkbox', id: 'lt-filter-check-'+key, text: key.charAt(0).toUpperCase() + key.slice(1), value: val, 'class': 'lt_issueFilterAllow', checked: true } ); + tfilter.push( { + type: 'checkbox', id: 'lt-filter-check-'+key, + text: key.charAt(0).toUpperCase() + key.slice(1), + value: val, 'class': 'lt_issueFilterAllow', + checked: true } ); }); @@ -299,10 +303,11 @@ $.each( LT.highlightList ,function(key,val){ { type : 'buttongroup', name : 'buttongroup', - label : '- Action:', + label : 'Action:', items : [ - { text: 'Apply', value: 'Apply', onClick: function() { LT.setAcceptDialog(); } }, - { text: 'Skip', value: 'Skip', onClick: function () { LT.setSkipDialog(); } }, + { text: 'Change', value: 'Apply', onClick: function() { LT.setAcceptDialog(); } }, + { text: 'Change All', value: 'Apply to All', onClick: function() { LT.setAcceptAllDialog(); } }, + { text: 'Next', value: 'Skip', onClick: function () { LT.setSkipDialog(); } }, { text: 'Ignore', value: 'Ignore', onClick: function() { LT.setIgnoreDialog('once'); } }, { text: 'Ignore All', value: 'Ignore All', onClick: function() { LT.setIgnoreDialog('all'); } }, { text: 'Ignore Rule', value: 'Ignore Rule', onClick: function() { LT.setIgnoreDialog('rule'); } } @@ -334,7 +339,7 @@ $( tinymce.activeEditor.getBody() ).find('.skip-dialog-highlight').removeClass(' } }); - +$('#mce-modal-block').remove(); }