@ -15,9 +15,9 @@
|
||||
//= require turbolinks
|
||||
//= require modernizr-lite/modernizr
|
||||
//= require jquery-linedtextarea-moser
|
||||
|
||||
//= require button-group
|
||||
//= require form-animation
|
||||
//= require summary-edit
|
||||
//= require test-builder
|
||||
//= require textarea-limit
|
||||
//= require live-coder
|
||||
|
@ -1,5 +1,4 @@
|
||||
function updateResults(elem) {
|
||||
var resultsContainer = $(elem).find('[data-id="results"]')[0];
|
||||
function updateResults(elem) { var resultsContainer = $(elem).find('[data-id="results"]')[0];
|
||||
var codeHtml = $(elem).find('.code-html')[0].value.trim();
|
||||
var codeCss = $(elem).find('.code-css')[0].value.trim();
|
||||
var codeJs = $(elem).find('.code-js')[0].value.trim();
|
||||
@ -92,22 +91,8 @@ function indentSelection(e){
|
||||
}
|
||||
}
|
||||
|
||||
function loadLiveCoders(){
|
||||
$.each($('.answer-sec.live_code-type, .answer-sec.live_code_text-type'), function(index, elem){
|
||||
var qid = $(elem).data('qid');
|
||||
$(elem).find("[data-id='live-coder-answer']").load("/live-coder-entry/" + qid, function(){
|
||||
$(elem).find('.js-error').addClass('hidden');
|
||||
$(elem).find(".code-input textarea").linedtextarea();
|
||||
if(window.location.href.indexOf("summary") > -1) {
|
||||
$(elem).find(".code-input textarea").attr('disabled', true);
|
||||
}
|
||||
updateResults(this);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
timer = 0;
|
||||
|
||||
$(function(){
|
||||
// wait a half second before updating results
|
||||
// restart the timer if they resume typing
|
||||
@ -117,14 +102,13 @@ $(function(){
|
||||
timer = setTimeout(updateResults(elem), 500);
|
||||
});
|
||||
|
||||
$("[data-id=live-coder-answer]").each(function(){
|
||||
updateResults(this);
|
||||
});
|
||||
|
||||
$("html").on('keydown', "textarea[data-id^=code-]", function(e){
|
||||
indentSelection(e);
|
||||
});
|
||||
|
||||
$.when(loadLiveCoders()).done(function(){
|
||||
//simple live coder for summary page
|
||||
$("[data-id=live-coder-no-js], [data-id=live-coder-finish-later]").addClass('hidden');
|
||||
$("[data-id=live-coder]").removeClass('hidden');
|
||||
});
|
||||
|
||||
$(".code-input textarea").linedtextarea();
|
||||
});
|
||||
|
@ -177,16 +177,6 @@ $('.answer-block').prop('disabled', true);
|
||||
// Question events
|
||||
$('.answer-sec')
|
||||
.find('.button-cancel, .button-save').hide().end()
|
||||
// delegating events
|
||||
.on('click', '.button-edit', editClickHandler)
|
||||
.on('click', '.button-cancel', cancelClickHandler)
|
||||
.on('click', '.button-save', saveClickHandler);
|
||||
|
||||
// Dynamically load in coders
|
||||
$.each($('.answer-sec.live_code-type, .answer-sec.live_code_text-type'), function(index, elem){
|
||||
var qid = $(elem).data('qid');
|
||||
$(elem).find("[data-id='live-coder-answer']").load("/live-coder-entry/" + qid, function(){
|
||||
$(elem).find('.js-error').addClass('hidden');
|
||||
$(elem).find(".code-input textarea").linedtextarea();
|
||||
});
|
||||
});
|
||||
|
@ -1,66 +0,0 @@
|
||||
$(document).ready(function() {
|
||||
//$(".answer_container").hide();
|
||||
//$(".test-builder-success").hide();
|
||||
//$(".question-edit-container").hide();
|
||||
|
||||
$(".skills-app-form").each(function () {
|
||||
var thisQu = $(this),
|
||||
questionOf = thisQu.find(".question-block").text();
|
||||
|
||||
|
||||
thisQu.find(".testbuilderquestion").val(questionOf);
|
||||
|
||||
thisQu.find(".answer_type").change(function(){
|
||||
if ( $(this).val() == "1" ) {
|
||||
thisQu.find(".answer_container").hide();
|
||||
thisQu.find(".answer_container.answer_text").show();
|
||||
}
|
||||
if ( $(this).val() == "2" ) {
|
||||
thisQu.find(".answer_container").hide();
|
||||
thisQu.find(".answer_container.answer_multiple").show();
|
||||
}
|
||||
if ( $(this).val() == "3" ) {
|
||||
thisQu.find(".answer_container").hide();
|
||||
thisQu.find(".answer_container.answer_multiple").show();
|
||||
}
|
||||
});
|
||||
thisQu.find(".test-builder-edit").click(function(){
|
||||
thisQu.find(".question-display").slideUp().fadeOut();
|
||||
thisQu.find(".question-edit-container").slideDown().fadeIn();
|
||||
});
|
||||
thisQu.find(".btn-saveedit").click(function(){
|
||||
if(thisQu.valid()) {
|
||||
thisQu.find(".question-display").slideDown().fadeIn();
|
||||
thisQu.find(".question-edit-container").slideUp().fadeOut();
|
||||
thisQu.find(".test-builder-success").slideDown().fadeIn();
|
||||
thisQu.find(".test-builder-success").delay(3000).slideUp().fadeOut();
|
||||
}
|
||||
});
|
||||
thisQu.find(".btn-cancel-edit").click(function(){
|
||||
thisQu.find(".question-display").slideDown().fadeIn();
|
||||
thisQu.find(".question-edit-container").slideUp().fadeOut();
|
||||
});
|
||||
thisQu.find(".btn-cancel").click(function(){
|
||||
thisQu.find(".answer_container").hide();
|
||||
});
|
||||
thisQu.find(".skills-app-form").submit(function() {
|
||||
return false;
|
||||
});
|
||||
thisQu.find(".test-builder-save").click(function(){
|
||||
if(thisQu.valid()) {
|
||||
thisQu.find(".answer_container").hide();
|
||||
thisQu.find(".test-builder-success").slideDown();
|
||||
thisQu.find(".test-builder-success").delay(3000).slideUp();
|
||||
}
|
||||
else {
|
||||
thisQu.find(".form-validation-script:invalid").css("border-color", "red");
|
||||
}
|
||||
});
|
||||
thisQu.find( ".btn-save" ).click(function() {
|
||||
if(thisQu.valid()) {
|
||||
window.location.href = "test-builder-success.html";
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
});
|
Reference in New Issue
Block a user