Team:University College London/js/initjs
From 2012.igem.org
(Difference between revisions)
(24 intermediate revisions not shown) | |||
Line 13: | Line 13: | ||
var ucligem = $('#ucligem'); | var ucligem = $('#ucligem'); | ||
+ | |||
+ | // GLOSSARY | ||
ucligem.append('<div id="glossary-box"></div>'); | ucligem.append('<div id="glossary-box"></div>'); | ||
var glossarybox = $('#glossary-box'); | var glossarybox = $('#glossary-box'); | ||
- | + | $('.glossary').each(function() { | |
+ | $this = $(this); | ||
+ | $.data(this, 'title', $this.attr('title')); | ||
+ | $this.removeAttr('title'); | ||
+ | }); | ||
+ | |||
$('.glossary').mouseenter(function(e){ | $('.glossary').mouseenter(function(e){ | ||
var caller = $(this); | var caller = $(this); | ||
- | + | var title = $.data(this,'title'); | |
- | + | var left = e.pageX - ucligem.offset().left - 150; // -150 as width is 300 | |
- | glossarybox.show(); | + | if(left < 0) { left = 0; } else if(left > 690) { left = 690; } |
+ | glossarybox.css({"left":left,"top":e.pageY+30}); | ||
+ | $.ajax({ | ||
+ | url: "https://2012.igem.org/wiki/index.php?title=Team:University_College_London/Glossary/"+title+"&action=raw", | ||
+ | success: function(data){glossarybox.text(data); glossarybox.show();}, | ||
+ | }); | ||
}).mouseout(function(){glossarybox.hide();}); | }).mouseout(function(){glossarybox.hide();}); | ||
+ | |||
+ | // FOOTNOTES | ||
+ | ucligem.append('<div id="footnote-box"><span id="footnote-box-content"></span><div id="footnote-close"></div></div>'); | ||
+ | var footnotebox = $('#footnote-box'); | ||
+ | |||
+ | $('.footnote').each(function() { | ||
+ | $this = $(this); | ||
+ | $.data(this, 'title', $this.attr('title')); | ||
+ | $this.removeAttr('title'); | ||
+ | }); | ||
+ | |||
+ | $('.footnote').click(function(e){ | ||
+ | var caller = $(this); | ||
+ | var title = $.data(this,'title'); | ||
+ | var left = e.pageX - ucligem.offset().left - 150; // -150 as width is 300 | ||
+ | if(left < 0) { left = 0; } else if(left > 690) { left = 690; } | ||
+ | footnotebox.css({"left":left,"top":e.pageY+30}); | ||
+ | $.ajax({ | ||
+ | url: "https://2012.igem.org/wiki/index.php?title=Team:University_College_London/Bibliography/"+title+"&action=raw", | ||
+ | success: function(data){$('#footnote-box-content').html(data); footnotebox.show();}, | ||
+ | }); | ||
+ | }); | ||
+ | $('#footnote-close').click(function(){footnotebox.hide();}); | ||
}); | }); |
Latest revision as of 10:18, 9 August 2012
$(document).ready(function(){
$('#wikimenutoggleon').click(function(){ $('#top-section').show(); $('#wikimenutoggleoff').show(); $('#wikimenutoggleon').hide(); });
$('#wikimenutoggleoff').click(function(){
$('#top-section').hide(); $('#wikimenutoggleoff').hide(); $('#wikimenutoggleon').show(); });
var ucligem = $('#ucligem');
// GLOSSARY
ucligem.append('');var glossarybox = $('#glossary-box');
$('.glossary').each(function() {
$this = $(this); $.data(this, 'title', $this.attr('title')); $this.removeAttr('title'); });
$('.glossary').mouseenter(function(e){
var caller = $(this); var title = $.data(this,'title'); var left = e.pageX - ucligem.offset().left - 150; // -150 as width is 300 if(left < 0) { left = 0; } else if(left > 690) { left = 690; } glossarybox.css({"left":left,"top":e.pageY+30}); $.ajax({ url: "https://2012.igem.org/wiki/index.php?title=Team:University_College_London/Glossary/"+title+"&action=raw", success: function(data){glossarybox.text(data); glossarybox.show();}, }); }).mouseout(function(){glossarybox.hide();});
// FOOTNOTES
ucligem.append('');
var footnotebox = $('#footnote-box');
$('.footnote').each(function() {
$this = $(this); $.data(this, 'title', $this.attr('title')); $this.removeAttr('title'); });
$('.footnote').click(function(e){
var caller = $(this); var title = $.data(this,'title'); var left = e.pageX - ucligem.offset().left - 150; // -150 as width is 300 if(left < 0) { left = 0; } else if(left > 690) { left = 690; } footnotebox.css({"left":left,"top":e.pageY+30}); $.ajax({ url: "https://2012.igem.org/wiki/index.php?title=Team:University_College_London/Bibliography/"+title+"&action=raw", success: function(data){$('#footnote-box-content').html(data); footnotebox.show();}, }); });
$('#footnote-close').click(function(){footnotebox.hide();}); });