$(document).ready( function() {
$(".exercise-answer").each( function() {
var lheight = $(this).css("line-height");
$(this).wrap('<span class="exercise-answer-c" />');
$(this).css({"bottom": lheight} );
$(this).parent(".exercise-answer-c").css("height", lheight);
});
$(".exercise-answer-c").click().toggle( function() {
$(this).children(".exercise-answer").animate({"bottom": "0px"});
}, function() {
var lheight = $(this).css("line-height");
$(this).children(".exercise-answer").animate({"bottom": lheight});
});
$("table.box button img").attr({ src: "http://upload.wikimedia.org/wikipedia/commons/thumb/9/93/View-playback_Gion_simple.svg/20px-View-playback_Gion_simple.svg.png", width: "20", height: "20" });
});
$(".maintext").hover( function() {
if (!$(this).parents().hasClass("tbox")) {
var pos = $(this).position(); // position of the 'maintext'
$(this).wrap('<div class="tbox" />'); // make 'maintext' a part of 'tbox'
var tbox = $(this).parent(".tbox");
$(this).data('title',$(this).attr('title'));
var tooltip = $(this).data("title");
$(this).removeAttr('title'); // remove title to prevent native tooltip
tbox.append('<div class="tooltip">' + tooltip + "</div>"); // add the tooltip text
tbox.css( { "display": "block", "left": (pos.left-13) + "px", "top": (pos.top-9) + "px" } ); // set the position of the 'tbox'
$(this).clone().insertBefore(tbox).attr("id", "ctext"); // place a clone of the 'maintext' as a placeholder
}
}, function() {
var tbox = $(this).parent(".tbox");
var clone = tbox.prev("#ctext");
clone.remove(); //remove clone
$(this).insertBefore(tbox); //replace 'maintext'
var tbox = $(this).siblings(".tbox"); //tbox is no longer parent
tbox.remove();
$(this).attr('title',$(this).data("title")); //replace 'title' for another hover event
} );
/*
$(".suffix").mouseover(showMenu);
var showMenu = function(ev) {
//get the position of the placeholder element
var pos = $(".suffix").offset();
var width = $(".suffix").width();
//show the menu directly over the placeholder
$(".tbox").css( { "left": (pos.left + width) + "px", "top":pos.top + "px" , "display":"inline-block"} );
}
$("#placeholder").mouseover(showMenu);
var showMenu = function(ev) {
//get the position of the placeholder element
var pos = $("#placeholder").offset();
var width = $("#placeholder").width();
//show the menu directly over the placeholder
$("#menu").css( { "left": (pos.left + width) + "px", "top":pos.top + "px" } );
$("#menu").show();
}
*/