Commit 9b86f6b5 authored by Martin Gregor's avatar Martin Gregor
Browse files

pridanie popupu

parent 6d6afdd6
......@@ -75,7 +75,7 @@ class HomepagePresenter extends BasePresenter
$form->addRadioList('sentence'.$id,$label,['correct' => 'Správne','incorrect' => 'Nesprávne']);
foreach ($sentence[1] as $position => $word)
{
$form->addText($id.'word'.$position,'Preklad '.$word,40,100);
$form->addText($id.'word'.$position,'Preklad '.$word,40,100)->setAttribute('placeholder','Tu prelož '.$word);
}
$form->addText('note'.$id,'Poznámka',60,500);
}
......@@ -203,7 +203,14 @@ class HomepagePresenter extends BasePresenter
if ($this->en_words[$position] != null)
{
$words[$position] = '<span class="translation label label-primary" data-animation="true" data-html="true" data-placement="auto bottom"'
.' data-trigger="hover" data-content="test">'
.' data-trigger="manual" data-content="
<button type=\'button\' class=\'btn btn-success correct\'>
<span class=\'glyphicon glyphicon-thumbs-up\'></span>
</button>
<button type=\'button\' class=\'btn btn-danger incorrect\'>
<span class=\'glyphicon glyphicon-thumbs-down\'></span>
</button>
">'
.'<span class="en-word">'
.$this->en_words[$position]->word
.'</span><span class="sk-word hidden">'.$this->words[$position].'</span></span>';
......
This diff is collapsed.
$(function(){
var check = [];
//skrytie nepotrebnych elementov
$('#frm-translationForm fieldset').each(function() {
$(this).find('tbody tr').each(function(i) {
if (i != 0 && i != 4)
......@@ -18,9 +20,88 @@ $(function(){
});
});
//zvyraznennie prekladov
$('.highlight').on('click',function() {
$('.translation').toggleClass('label').toggleClass('label-primary');
});
//zobrazenie a skrytie popupu
$('.translation').popover();
$('.translation').on('mouseenter',function(){
if ($(this).next().hasClass('popover'))
{
$(this).next().show();
}
else
{
$(this).popover('show');
}
});
$('.translation').on('click',function(){
$(this).popover('hide');
});
$('body').on('mouseleave','.popover',function(){
$(this).hide();
});
//kliknutie na correct
$('body').on('click','button.correct',function() {
var radio = $(this).parent().parent().parent().parent().parent().next().find('input[value="correct"]');
var word_n = $(this).parent().parent().parent().find('.translation').index($(this).parent().parent().prev());
var r_name = radio.attr('name');
if (typeof(check[r_name]) == "undefined")
{
check[r_name] = [];
}
check[r_name][word_n] = true;
var next_w_n = word_n == 0 ? 1 : 0;
if (typeof(check[r_name][next_w_n]) == "undefined" || check[radio.attr('name')][next_w_n] == null || check[r_name][next_w_n] == true)
{
radio.attr('checked',true);
$(this).removeClass('btn-default').addClass('btn-success');
$(this).next().removeClass('btn-danger').addClass('btn-default');
}
$(this).parent().find('input').hide().val('');
});
//kliknutie na inccorects
$('body').on('click','button.incorrect',function() {
var radio = $(this).parent().parent().parent().parent().parent().next().find('input[value="incorrect"]');
var word_n = $(this).parent().parent().parent().find('.translation').index($(this).parent().parent().prev());
var r_name = radio.attr('name');
if (typeof(check[r_name]) == "undefined")
{
check[r_name] = [];
}
check[r_name][word_n] = false;
radio.attr('checked',true);
$(this).removeClass('btn-default').addClass('btn-danger');
$(this).prev().removeClass('btn-success').addClass('btn-default');
show_input($(this),word_n);
});
//zobrazenie inputu na zadanie opravy
function show_input(btn,word_n)
{
var input = btn.parent().find('input');
if (input.length == 0)
{
input = btn.parent().parent().parent().parent().parent().parent().next();
if (word_n == 1)
{
input = input.next();
}
input = input.find('input');
input.appendTo(btn.parent());
}
else
{
input.show();
}
}
});
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment