From ffeb1a12491780d489d96dd7159a09b5fd16090c Mon Sep 17 00:00:00 2001 From: Timotej Lazar Date: Fri, 18 Sep 2015 16:24:32 +0200 Subject: Add "Plan" button to display next "planning" hint --- js/codeq/hint.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'js/codeq/hint.js') diff --git a/js/codeq/hint.js b/js/codeq/hint.js index 06eceb0..c06aef7 100644 --- a/js/codeq/hint.js +++ b/js/codeq/hint.js @@ -7,9 +7,10 @@ var firstCharacterPos = {'line': 0, 'ch': 0}, sel_no_scroll = {'scroll': false}; - codeq.makeHinter = function (jqHints, jqEditor, editor, hintDefs) { + codeq.makeHinter = function (jqHints, jqEditor, editor, hintDefs, planDef) { var hintCounter = 0, // for generating unique class-names hintCleaners = [], + planIdx = 0, clearHints = function () { var i; @@ -124,6 +125,16 @@ }; return { + /** Display the next "planning" hint and return whether there are + * any more available. + */ + 'planNext': function () { + if (planIdx < planDef.length) { + jqHints.append('
' + planDef[planIdx++] + '
'); + } + return planIdx < planDef.length; + }, + /** * Processes and display appropriately the server hints. * TODO: sort hints so static and popup hints come first, and a (single) drop-down hint last -- cgit v1.2.1 From 5ae5ffc6e86a0181799b6f45167bfb57ea91a32c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ale=C5=A1=20Smodi=C5=A1?= Date: Fri, 18 Sep 2015 18:39:55 +0200 Subject: Use a link instead of a button in a static hint sequence. --- js/codeq/hint.js | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'js/codeq/hint.js') diff --git a/js/codeq/hint.js b/js/codeq/hint.js index c06aef7..55acac9 100644 --- a/js/codeq/hint.js +++ b/js/codeq/hint.js @@ -46,7 +46,7 @@ typeHandlers = { 'static': function (type, template, serverHint) { var args = serverHint.args, - jqContainer, jqButton, i, N; + jqContainer, jqButton, i, N, tmpl, tmplIsObject; if (template instanceof Array) { // unwrap the template if there's only one if (template.length == 0) template = ''; else if (template.length == 1) template = template[0] + ''; // it must be a string @@ -54,17 +54,23 @@ if (template instanceof Array) { codeq.log.debug('Processing an array of static hints'); jqContainer = $('
'); - jqButton = $(''); // TODO: translate "more" + jqButton = $(''); jqHints.append(jqContainer); N = template.length; - jqContainer.append('
' + processTemplate(template[0], args) + '
'); + tmpl = template[0]; + tmplIsObject = (typeof tmpl === 'object') && (tmpl !== null); + jqContainer.append('
' + processTemplate((tmplIsObject ? tmpl.message : tmpl) || '', args) + '
'); jqContainer.append(jqButton); + jqButton.text(tmplIsObject && tmpl.linkText ? tmpl.linkText : 'More...'); // TODO: translate "more" i = 1; jqButton.on('click', function () { - var jqNext = $('
' + processTemplate(template[i], args) + '
'); + var tmpl = template[i], + tmplIsObject = (typeof tmpl === 'object') && (tmpl !== null), + jqNext = $('
' + processTemplate((tmplIsObject ? tmpl.message : tmpl) || '', args) + '
'); i++; if (i < N) { jqButton.before(jqNext); + jqButton.text(tmplIsObject && tmpl.linkText ? tmpl.linkText : 'More...'); // TODO: translate "more" } else { jqButton.remove(); -- cgit v1.2.1