mirror of
https://github.com/GitbookIO/gitbook.git
synced 2026-09-21 01:53:26 +00:00
Merge pull request #144 from attomos/master
Make quiz easier to click by surround it with label.
This commit is contained in:
@@ -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
@@ -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 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user