Merge pull request #144 from attomos/master

Make quiz easier to click by surround it with label.
This commit is contained in:
Samy Pessé
2014-04-25 14:29:04 +02:00
3 changed files with 15 additions and 6 deletions
+8 -3
View File
@@ -18,6 +18,7 @@ function GitBookRenderer(options, extra_options) {
this._extra_options = extra_options;
this.quizRowId = 0;
this.id = rendererId++;
this.quizIndex = 0;
}
inherits(GitBookRenderer, marked.Renderer);
@@ -66,7 +67,7 @@ GitBookRenderer.prototype.link = function(href, title, text) {
} else if (o && o.repo && o.dir) {
href = url.resolve('https://github.com/' + o.repo + '/blob/', [o.dir, _href].join("/"));
parsed = url.parse(href);
_href = parsed.href;
_href = parsed.href;
}
}
@@ -116,10 +117,14 @@ GitBookRenderer.prototype._createCheckboxAndRadios = function(text) {
if (!match) {
return text;
}
var field = "<input name='quiz-row-" + this.id + "-" + this.quizRowId + "' type='";
var quizIdentifier = 'quiz-row-' + this.id + '-' + this.quizRowId + '-' + this.quizIndex++;
var field = "<input name='" + quizIdentifier + "' id='" + quizIdentifier + "' type='";
field += match[1] === '(' ? "radio" : "checkbox";
field += match[2] === 'x' ? "' checked/>" : "'/>";
return text.replace(fieldRegex, field);
var splittedText = text.split(fieldRegex);
var length = splittedText.length;
var label = '<label class="quiz-label" for="' + quizIdentifier + '">' + splittedText[length - 1] + '</label>';
return text.replace(fieldRegex, field).replace(splittedText[length - 1], label);
}
GitBookRenderer.prototype.tablecell = function(content, flags) {
File diff suppressed because one or more lines are too long
+6 -2
View File
@@ -29,8 +29,12 @@
.question-inner {
padding: 15px;
.quiz-label {
font-weight: normal;
cursor: pointer;
}
}
table {
margin-bottom: 10px;
width: 100%;
@@ -46,4 +50,4 @@
}
}
}
}
}