summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleš Smodiš <aless@guru.si>2015-09-18 18:39:55 +0200
committerAleš Smodiš <aless@guru.si>2015-09-18 18:39:55 +0200
commit5ae5ffc6e86a0181799b6f45167bfb57ea91a32c (patch)
tree18aad2a144e2c743e94ddad3d1ecad54e8f17904
parent45e1dc64a3f36222eb775a00157f587ebdaabd2d (diff)
Use a link instead of a button in a static hint sequence.
-rw-r--r--css/codeq/hint.css3
-rw-r--r--index.html1
-rw-r--r--js/codeq/hint.js14
3 files changed, 14 insertions, 4 deletions
diff --git a/css/codeq/hint.css b/css/codeq/hint.css
new file mode 100644
index 0000000..76090b2
--- /dev/null
+++ b/css/codeq/hint.css
@@ -0,0 +1,3 @@
+a.hint-static-link {
+ cursor: pointer;
+} \ No newline at end of file
diff --git a/index.html b/index.html
index f7c4252..b9a08ce 100644
--- a/index.html
+++ b/index.html
@@ -15,6 +15,7 @@
<!-- App -->
<link rel="stylesheet" href="css/codeq.css" type="text/css">
<link rel="stylesheet" href="css/codeq/console.css" type="text/css">
+ <link rel="stylesheet" href="css/codeq/hint.css" type="text/css">
<title>CodeQ</title>
</head>
<body>
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 = $('<div class="hint-static-group"></div>');
- jqButton = $('<button type="button">More...</button>'); // TODO: translate "more"
+ jqButton = $('<a class="hint-static-link"></a>');
jqHints.append(jqContainer);
N = template.length;
- jqContainer.append('<div class="hint-static">' + processTemplate(template[0], args) + '</div>');
+ tmpl = template[0];
+ tmplIsObject = (typeof tmpl === 'object') && (tmpl !== null);
+ jqContainer.append('<div class="hint-static">' + processTemplate((tmplIsObject ? tmpl.message : tmpl) || '', args) + '</div>');
jqContainer.append(jqButton);
+ jqButton.text(tmplIsObject && tmpl.linkText ? tmpl.linkText : 'More...'); // TODO: translate "more"
i = 1;
jqButton.on('click', function () {
- var jqNext = $('<div class="hint-static">' + processTemplate(template[i], args) + '</div>');
+ var tmpl = template[i],
+ tmplIsObject = (typeof tmpl === 'object') && (tmpl !== null),
+ jqNext = $('<div class="hint-static">' + processTemplate((tmplIsObject ? tmpl.message : tmpl) || '', args) + '</div>');
i++;
if (i < N) {
jqButton.before(jqNext);
+ jqButton.text(tmplIsObject && tmpl.linkText ? tmpl.linkText : 'More...'); // TODO: translate "more"
}
else {
jqButton.remove();