Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
bmesuere committed Jun 7, 2016
2 parents e26f458 + 6de8fb2 commit 1e11034
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 17 deletions.
11 changes: 9 additions & 2 deletions app/assets/javascripts/exercise.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ function init_exercise_show(exerciseId, loggedIn, tests) {

centerImagesAndTables();


// create feedback table
var feedbackTable = new FeedbackTable(tests);
$("#feedback-loading").hide();


// test source code if button is clicked on editor panel
$("#editor-process-btn").click(function () {
// test submitted source code
Expand All @@ -34,8 +36,6 @@ function init_exercise_show(exerciseId, loggedIn, tests) {
$('#exercise-feedback-link').tab('show');
});

MathJax.Hub.Typeset();

// hide/show correct test cases if button is clicked in menu on feedback
// panel
$("#feedback-menu-toggle-correct").click(function () {
Expand All @@ -51,6 +51,13 @@ function init_exercise_show(exerciseId, loggedIn, tests) {
$(this).dropdown('toggle');
return false;
});

MathJax.Hub.Queue(function() {
/* MathJax has not been run yet*/
if ($('span.MathJax').length === 0) {
MathJax.Hub.Queue(["Typeset",MathJax.Hub]);
}
});
}

function initEditor() {
Expand Down
10 changes: 9 additions & 1 deletion app/views/exercises/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@
<div class="card card-nav">
<div class="card-title card-title-colored">
<div class="card-title-fab">
<% if user_signed_in? %>
<button class="btn btn-primary btn-fab" id="editor-process-btn">
<span class="glyphicon glyphicon-play"></span>
</button>
<% end %>
</div>
<ul class="nav nav-tabs">
<li class="active"><a href="#code" data-toggle="tab">Code</a></li>
Expand All @@ -37,11 +39,17 @@
<div class="card-supporting-text">
<div class="tab-content">
<div class="tab-pane fade in active" id="code">
<% if !user_signed_in? %>
<div class="alert alert-info">Log in om je oplossingen te testen.</div>
<% end %>
<div id="editor-window">
<div id="editor-text"></div>
</div>
</div>
<div class="tab-pane fade" id="feedback">
<% if !user_signed_in? %>
<div class="alert alert-info">Log in om je oplossingen te testen.</div>
<% end %>
<div id="feedback-menu">
<div class="btn-group">
<span class="dropdown">
Expand All @@ -62,7 +70,7 @@
</div>
<div class="tab-pane fade" id="submissions">
<% if !user_signed_in? %>
<div class="alert alert-info">Log in om je oplossingen op te slaan.</div>
<div class="alert alert-info">Log in om je oplossingen te testen.</div>
<% elsif @submissions.length > 0 %>
<div id="submissions-table-wrapper">
<%= render partial: 'submissions/submissions_table', locals: {submissions: @submissions, exercise: @exercise} %>
Expand Down
57 changes: 43 additions & 14 deletions vendor/assets/javascripts/strip/strip.pkgd.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -765,23 +765,52 @@ function initStrip() {
d = this.view && this.view.options.onShow;
"function" == $.type(d) && d.call(Strip);

/* MathJax in caption */
/* BEGIN MathJax in caption */

function _resize(element) {
var e = Window.resize(element[c], function() {
--b < 1 && a()
}, e);
return e;
}

var numberMathJax = 0;
if (typeof MathJax !== 'undefined') {
MathJax.Hub.Queue(["Typeset", MathJax.Hub, "div.strp-caption"]);
MathJax.Hub.Queue(function() {
$("div.strp-caption div.MathJax_Display").each(function() {
$(this).contents().unwrap();
});
//force resize after mathjax is done
var a;
(a = Pages.page) && (a.animated || a.animatingWindow ? (a.fitToWindow(), a.show()) : (a.fitToWindow(), Window.resize(a.z, null, 0), Window.adjustPrevNext(null, !0)))

})

$('div.strp-caption').each(function() {
//There is math in this caption -> Typeset it
if ($(this).html().indexOf('$$') > -1) {
numberMathJax += 1;
MathJax.Hub.Queue(["Typeset", MathJax.Hub, $(this)[0]]);
}
});

parent = this;

/* Put Mathjax inline, but only when necessary */
if (numberMathJax > 0) {

MathJax.Hub.Queue(function() {
$("div.strp-caption div.MathJax_Display").each(function() {
$(this).contents().unwrap();
});
e = _resize(this);
//force explicit resize after mathjax is done
var a;
(a = Pages.page) && (a.animated || a.animatingWindow ? (a.fitToWindow(), a.show()) : (a.fitToWindow(), Window.resize(a.z, null, 0), Window.adjustPrevNext(null, !0)))
})

} else {
var e = _resize(this);
}


} else {
var e = _resize(this);
}

var e = Window.resize(this[c], function() {
--b < 1 && a()
}, e);
/* END MathJax in caption */

this._show(function() {
--b < 1 && a()
}, e), Window.adjustPrevNext(function() {
Expand Down

0 comments on commit 1e11034

Please sign in to comment.