Skip to content

Commit

Permalink
Bootstrap glyphicons.
Browse files Browse the repository at this point in the history
  • Loading branch information
arfurlaneto committed Aug 28, 2015
1 parent 98f3075 commit daa47ff
Show file tree
Hide file tree
Showing 8 changed files with 325 additions and 14 deletions.
10 changes: 9 additions & 1 deletion css/mathtrainer.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,12 @@

.container-fluid {
padding-top: 15px;
}
}

input.optionerror {
border-color: #a94442;
}

div.optionerror {
border: 1px solid #a94442;
}
Binary file added fonts/glyphicons-halflings-regular.eot
Binary file not shown.
288 changes: 288 additions & 0 deletions fonts/glyphicons-halflings-regular.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added fonts/glyphicons-halflings-regular.ttf
Binary file not shown.
Binary file added fonts/glyphicons-halflings-regular.woff
Binary file not shown.
Binary file added fonts/glyphicons-halflings-regular.woff2
Binary file not shown.
21 changes: 16 additions & 5 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ <h1 class="i18n" data-i18n="labels.appName"></h1>
</label>
</div>
</div>
<div class="form-group">
<div class="form-group" id="op_wrapper">
<div class="checkbox">
<label>
<input type="checkbox" id="op_add" checked="checked" />
Expand All @@ -91,7 +91,9 @@ <h1 class="i18n" data-i18n="labels.appName"></h1>
</div>
</div>
<div class="form-group">
<button type="button" class="btn btn-primary i18n col-xs-12" id="start" style="display: none" data-i18n="labels.start">
<button type="button" class="btn btn-primary col-xs-12" id="start" style="display: none">
<span class="glyphicon glyphicon-ok" aria-hidden="true"></span>
<span class="i18n" data-i18n="labels.start"></span>
</button>
</div>
</form>
Expand Down Expand Up @@ -120,16 +122,25 @@ <h1 id="question_math"></h1>
</div>
<div class="row">
<div class="col-xs-6 text-center">
<button type="button" class="btn btn-info i18n col-xs-12" id="clear_question" data-i18n="labels.clear"/>
<button type="button" class="btn btn-info col-xs-12" id="clear_question">
<span class="glyphicon glyphicon-erase" aria-hidden="true"></span>
<span class="i18n" data-i18n="labels.clear"></span>
</button>
</div>
<div class="col-xs-6 text-center">
<button type="button" class="btn btn-warning i18n col-xs-12" id="skip_question" data-i18n="labels.skip"/>
<button type="button" class="btn btn-warning col-xs-12" id="skip_question">
<span class="glyphicon glyphicon-refresh" aria-hidden="true"></span>
<span class="i18n" data-i18n="labels.skip"></span>
</button>
</div>
</div>
<br>
<div class="row">
<div class="col-xs-12 text-center">
<button type="button" class="btn btn-danger i18n col-xs-12" id="quit_to_options" data-i18n="labels.quitToOptions"/>
<button type="button" class="btn btn-danger col-xs-12" id="quit_to_options">
<span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
<span class="i18n" data-i18n="labels.quitToOptions"></span>
</button>
</div>
</div>
</div>
Expand Down
20 changes: 12 additions & 8 deletions js/mathtrainer.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,14 @@
* @param {String} id The ID of the field/checkbox the error is about
* @param {String} message The message to output
*/
var add = function (id, message) {
var add = function (ids, message) {
errorAdded = true;
$('#options_error').append(message + '<br />');
$('#' + id).addClass('optionerror');
var errorDiv = $('<div class="errormessage"><span class="glyphicon glyphicon-warning-sign"></span> </div>');
errorDiv.append(message);
$('#options_error').append(errorDiv);
$.each(ids, function (key, value) {
$('#' + value).addClass('optionerror');
});
};
/**
* Returns whether an error was added since reset() was last called.
Expand Down Expand Up @@ -215,17 +219,17 @@
var hasErrors = false;

if (isNaN(min) || min < -9999999 || min > 9999999) {
error.add('min', i18n.t('errors.rangeMinInvalid', {min: -9999999, max: 9999999}));
error.add(['min'], i18n.t('errors.rangeMinInvalid', {min: -9999999, max: 9999999}));
hasErrors = true;
}

if (isNaN(max) || max < -9999999 || max > 9999999) {
error.add('max', i18n.t('errors.rangeMaxInvalid', {min: -9999999, max: 9999999}));
error.add(['max'], i18n.t('errors.rangeMaxInvalid', {min: -9999999, max: 9999999}));
hasErrors = true;
}

if (!hasErrors && min >= max) {
error.add('max', i18n.t('errors.rangeIntervalInvalid'));
error.add(['min', 'max'], i18n.t('errors.rangeIntervalInvalid'));
hasErrors = true;
}

Expand All @@ -240,7 +244,7 @@
var initializeMinutes = function () {
var timerValue = parseInt($('#timer_length').val());
if (isNaN(timerValue) || timerValue <= 0 || timerValue > 60) {
error.add('timer_length', i18n.t('errors.minutesInvalid', {min: 1, max: 60}));
error.add(['timer_length'], i18n.t('errors.minutesInvalid', {min: 1, max: 60}));
} else {
config.minutes = timerValue;
}
Expand All @@ -261,7 +265,7 @@
}
}
if (inputOperators.length === 0) {
error.add('op_wrapper', i18n.t('errors.noOperators'));
error.add(['op_wrapper'], i18n.t('errors.noOperators'));
} else {
config.operators = inputOperators;
}
Expand Down

0 comments on commit daa47ff

Please sign in to comment.