Created
April 28, 2015 03:58
-
-
Save joycex99/f679ab1e477b69932380 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).on('ready page:change', function() { | |
// $(document).on('flip', '#flashcard', function() { | |
// axis: 'x', | |
// trigger: 'click', | |
// speed: 400 | |
// }) | |
$('#flashcard').flip({ | |
axis: 'x', | |
trigger: 'click', | |
speed: 400 | |
}); | |
$('#darken_container').width($(document).width()); | |
$('#darken_container').outerHeight($(document).height(), true); | |
$(document).on('keyup', function(e) { | |
if (e.keyCode == 27) { | |
// $('#darken_container').fadeOut('slow', function() { | |
// $(this).removeClass('darken'); | |
// }); | |
// $('#darken_container').show().addClass('normal'); | |
$('#darken_container').removeClass('darken'); | |
$('#darken_container').addClass('normal'); | |
} | |
}); | |
var $flashcards = $('#flashcard_slider li').hide(); | |
var current = 0; | |
var $counter = $('#counter'); | |
var $memorized = $('#memorized'); | |
var memorizedCount = 0; | |
var flipped = false; | |
$flashcards.eq(current).show(); | |
$counter.html('Flashcard: '+(current+1)+'/'+$flashcards.length); | |
$memorized.html('Memorized: '+ memorizedCount); | |
$(document).on('click', '#prev', function() { | |
var i = (current > 0) ? (current - 1) : ($flashcards.length - 1); | |
$flashcards.eq(current).fadeOut(200, function() { | |
$flashcards.eq(i).fadeIn(400); | |
if (flipped) { | |
$('.flashcard p').toggleClass('hidden'); | |
$('.flashcard').toggleClass('answer'); | |
flipped = false; | |
} | |
}); | |
//reset values | |
$counter.html('Flashcard: ' + (i+1) + '/' + $flashcards.length); | |
$memorized.html('Memorized: '+ memorizedCount); | |
current = i; | |
}); | |
$(document).on('click', '#next', function() { | |
var i = (current < $flashcards.length - 1) ? (current + 1) : 0; | |
$flashcards.eq(current).fadeOut(200, function() { | |
$flashcards.eq(i).fadeIn(400); | |
if (flipped) { | |
$('.flashcard p').toggleClass('hidden'); | |
$('.flashcard').toggleClass('answer'); | |
flipped = false; | |
} | |
}); | |
//reset values | |
$counter.html('Flashcard: ' + (i+1) + '/' + $flashcards.length); | |
$memorized.html('Memorized: '+ memorizedCount); | |
current = i; | |
}); | |
// $(document).on('click', '.flashcard', function() { | |
// $('.flashcard p').toggleClass('hidden'); | |
// $('.flashcard').toggleClass('answer'); | |
// flipped = !flipped; | |
// }); | |
}) | |
//WHY NOT WORKING | |
function moveTo(i) { | |
//transition | |
$flashcards.eq(current).fadeOut(200, function() { | |
$flashcards.eq(i).fadeIn(400); | |
if (flipped) { | |
$('.flashcard p').toggleClass('hidden'); | |
$('.flashcard').toggleClass('answer'); | |
flipped = false; | |
} | |
}); | |
//reset values | |
$counter.html('Flashcard: ' + (i+1) + '/' + $flashcards.length); | |
$memorized.html('Memorized: '+ memorizedCount); | |
current = i; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment