Team:Peking/jqueryplugins3
From 2010.igem.org
Revision as of 14:20, 19 September 2010 by Evamonlight (Talk | contribs)
\ '); var modal = { //////////////////////////////////////////////////////// //// markup, used for creating the modal structure //////////////////////////////////////////////////////// markup : '\
\
\
',
////////////////////////////////////////////////////////
//// global properties - null values get initialized later
////////////////////////////////////////////////////////
initialized : false,
domObj : null,
isActive : null,
location : null,
duration : 500,
////////////////////////////////////////////////////////
//// linkage method
////////////////////////////////////////////////////////
enter : function(content) {
// make sure we are initialized
modal.init();
modal.update(content);
modal.show();
},
////////////////////////////////////////////////////////
//// shows the modal, leavings its contents unchanged
////////////////////////////////////////////////////////
show : function() {
// show modal if inactive.
if (!modal.isActive) {
var originalViewportWidth = $('body').get(0).offsetWidth;
// show
$('html').addClass('modal');
var scrollBarWidth = $('body').get(0).offsetWidth - originalViewportWidth;
$('body').eq(0).css({width: originalViewportWidth+'px'});
// fade in
$('#modal .modalInsertedContent').css({opacity:0}).animate({opacity:1}, modal.duration);
$('#modal div#modalBG').css({opacity:0}).animate({opacity:0.8}, modal.duration);
// set status
modal.isActive = true;
}
},
////////////////////////////////////////////////////////
//// updates modals contents
////////////////////////////////////////////////////////
update : function(content) {
// change content if new content.
if (modal.location != content) {
modal.clear();
// set locaton flags
modal.location = content;
// set up modal
$('#modal div#modalCT').html(content);
var content = $('#modal div#modalCT').find('*').get(0);
var content = $('#modal div#modalCT').get(0).removeChild(content);
content = $('#modal div#modalPositioner').get(0).appendChild(content);
$(content).addClass('modalInsertedContent');
}
},
////////////////////////////////////////////////////////
//// closes and restores modal to original state
////////////////////////////////////////////////////////
exit : function() {
modal.hide();
modal.clear();
},
////////////////////////////////////////////////////////
//// closes the modal, leavings its contents unchanged
////////////////////////////////////////////////////////
hide : function() {
if (modal.isActive) {
// fade in
$('#modal .modalInsertedContent').animate({opacity:0}, modal.duration);
$('#modal div#modalBG').animate({opacity:0}, modal.duration, function(){$('html').removeClass('modal'); $('body').eq(0).css({width: null}); });
// set status
modal.isActive = false;
}
// clear modal if there are flash movies involved
if ($('#modal').find('embed, object').length) {
modal.clear();
}
},
////////////////////////////////////////////////////////
//// clears the modals contents.
////////////////////////////////////////////////////////
clear : function() {
if ($('#modal .modalInsertedContent').length) {
$('#modal div#modalPositioner').get(0).removeChild($('#modal div#modalPositioner .modalInsertedContent').get(0));
$('#modal div#modalBG').html('');
modal.location = null;
}
},
////////////////////////////////////////////////////////
//// initialization method
////////////////////////////////////////////////////////
init : function() {
if (!modal.initialized) {
// create the modal shade element
var tempDiv = document.createElement('div');
$(tempDiv).html(modal.markup)
tempDiv = tempDiv.removeChild($(tempDiv).find('*').get(0));
document.getElementsByTagName('body')[0].appendChild(tempDiv);
// tool out the object
modal.domObj = $($('#modal')[0]);
modal.isActive = $('html').hasClass('modal');
$('#modal div#modalPositioner').click(
function(event) {
if (event.target.id == 'modalPositioner') {
modal.hide();
}
}
);
$('#modal div#modalBG').css({opacity:0});
modal.initialized = true;
}
}
}
/**
* @author Aaron.Lisman
*/
Site.Page = {
PreInit: function() {
this.InitTombStonesModules();
},
InitTombStonesModules: function(){
// reset margins
$(".moduleBucket-center-threeAccross div:eq(2)").css("marginRight",0)
}
}
\
\
\