|
Project Information
Members
Featured
Downloads
Links
|
IntroductionjQuery modalBox is a simple jQuery plugin that provides a multiple customizable modal dialog. This Plugin is written in JavaScript on top of the jQuery library and shows inline content, content served through AJAX and single images.
1. IntegrationInclude the following script and stylesheet in your head of your HTML-Document: <head>
<link type="text/css" rel="stylesheet" href="jquery.modalbox.css" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<script type="text/javascript" src="jquery.modalbox-1.3.0-min.js"></script>
</head>For own translations bind following script block. The default locale is english. <script type="text/javascript">
/* <![CDATA[ */
var modalboxGlobalDefaults = {
localizedStrings : {
messageCloseWindow : 'Fenster schliessen',
messageAjaxLoader : 'Bitte warten<br />Ihre Anfrage wird verarbeitet.',
errorMessageIfNoDataAvailable : '<strong>Keine Inhalte verfügbar!</strong>',
errorMessageXMLHttpRequest : 'Ein technischer Fehler (XML-Http-Request Status "500") verhindert den Aufruf der Seite.
<br /><br />
Bitte versuchen Sie es später noch einmal',
errorMessageTextStatusError : 'Ein technischer Fehler (AJAX-Anfrage fehlgeschlagen) verhindert den Aufruf der Seite.
<br /><br />
Bitte versuchen Sie es später noch einmal'
}
};
/* ]]> */
</script>2. InitializationThe default initialization is set by the class "openmodalbox" triggered on an element: <a class="openmodalbox" href="javascript:void(0);">
Demolink
<span class="modalboxContent">
My Custom Content...
</span>
</a>Initialize custom Elements: <script type="text/javascript">
/* <![CDATA[ */
jQuery(document).ready(function(){
jQuery("a.defineYoutOwnClassHere").modalBox();
});
/* ]]> */
</script>
<a class="defineYoutOwnClassHere" href="javascript:void(0);">
Demolink
<span class="modalboxContent">
My Custom Content...
</span>
</a>Initialization of modalBox with optional parameter options: <script type="text/javascript">
/* <![CDATA[ */
jQuery(document).ready(function(){
jQuery(".openmodalbox").modalBox({
setTypeOfFaderLayer : 'black', // options: white, black, disable
killModalboxWithCloseButtonOnly : true, // options: true, false (close the modal box with close button only),
setStylesOfFaderLayer : {// define the opacity and color of fader layer here
white : 'background-color:#fff; filter:alpha(opacity=60); -moz-opacity:0.6; opacity:0.6;',
black : 'background-color:#000; filter:alpha(opacity=40); -moz-opacity:0.4; opacity:0.4;',
transparent : 'background-color:transparent;'
},
minimalTopSpacingOfModalbox : 50 // sets the minimum space between modalbox and visible area in the browser window
});
});
/* ]]> */
</script>Show hidden ContentExample 1 <a class="openmodalbox" href="javascript:void(0);">
Demolink
<span class="modalboxContent">
<h3>Test Modalbox</h3><br />
Identius, ora Disicio...
</span>
</a>
<div class="openmodalbox">
Click here
<div class="modalboxContent">
<a href="javascript:alert('It works.');">Click again</a>
</div>
</div>Example 2 <div id="yourOwnContentContainer" style="display:none;">
<h3>Test Modalbox</h3><br />
Identius, ora Disicio...
</div>
<a class="defineYoutOwnClassHere" href="javascript:void(0);">
Demolink
<span class="modalboxContent">
<h3>Test Modalbox</h3><br />
Identius, ora Disicio...
</span>
</a>
<script type="text/javascript">
/* <![CDATA[ */
jQuery(document).ready(function(){
jQuery("a.defineYoutOwnClassHere").modalBox({
getStaticContentFrom : "#yourOwnContentContainer"
});
});
/* ]]> */
</script>AJAXVia input hidden field "ajaxhref" <a class="openmodalbox" href="javascript:void(0);">
Demolink
<input type="hidden" name="ajaxhref" value="testinclude.php?test=tester" />
</a>Via Attribute "rel" <a class="openmodalbox" rel="ajax:testinclude.php?test=tester" href="javascript:void(0);">
Demolink
</a>forms / the form submit button can be the type "submit/button/image" <form id="myTestForm" name="myTestForm" action="testinclude.php" method="post">
<input class="openmodalbox" type="submit" value="open Form Content in modalBox" />
</form>Reload Ajax Content in modal layer / requires jQuery v1.3.2 or later Case: you have initialized a modalBox where you want to reload content again. <a class="openmodalbox" href="javascript:void(0);">
Reload content from ajaxhref
<input type="hidden" name="ajaxhref"
value="inc_ajaxinclude_3.php"
/>
</a>
<a class="openmodalbox" href="javascript:void(0);">
Reload hidden content
<span class="modalboxContent">
<h3>Test - reload hidden content</h3><br />
Identius, ora Disicio...
</span>
</a>PicturesVia Attribute "href": <a class="openmodalbox" href="demopicture_kalexis_newzealand_6930.JPG">
Demolink
</a>Via Attribute "rel": <a class="openmodalbox" href="javascript:void(0);" rel="demopicture_kalexis_newzealand_6930.JPG">
Demolink
</a>Custom close button<a class="closeModalBox" href="javascript:void(0);">
Close Modalbox
</a>
<input class="closeModalBox" type="button"
name="customCloseButton"
value="Custom Close Button / Button"
/>
<div class="closeModalBox">
Custom Close Button / Other
</div>Call a custom function before layer will be shown<a class="testlink" href="javascript:void(0);">
Demolink
<input type="hidden" name="ajaxhref" value="inc_ajaxinclude_1.php" />
</a>
<script type="text/javascript">
/* <![CDATA[ */
jQuery(document).ready(function(){
jQuery("a.testlink").modalBox({
callFunctionBeforeShow : function(){
alert("confirm this");
return true;
}
});
});
/* ]]> */
</script>Call a custom function after layer is shown<a class="testlink" href="javascript:void(0);">
Demolink
<input type="hidden" name="ajaxhref" value="inc_ajaxinclude_1.php" />
</a>
<script type="text/javascript">
/* <![CDATA[ */
jQuery(document).ready(function(){
jQuery("a.testlink").modalBox({
callFunctionAfterShow : function(){
alert("Modalbox is complete");
}
});
});
/* ]]> */
</script>Call a custom function before layer will be closed<a class="testlink" href="javascript:void(0);">
Demolink
<input type="hidden" name="ajaxhref" value="inc_ajaxinclude_1.php" />
</a>
<script type="text/javascript">
/* <![CDATA[ */
jQuery(document).ready(function(){
jQuery("a.testlink").modalBox({
callFunctionBeforeHide : function(){
alert("Hiding Layer after confirming this");
}
});
});
/* ]]> */
</script>Call a custom function after layer is closed<a class="testlink" href="javascript:void(0);">
Demolink
<input type="hidden" name="ajaxhref" value="inc_ajaxinclude_1.php" />
</a>
<script type="text/javascript">
/* <![CDATA[ */
jQuery(document).ready(function(){
jQuery("a.testlink").modalBox({
callFunctionAfterHide : function(){
alert("The modalbox is closed completly");
}
});
});
/* ]]> */
</script>Special functionalitiesInitializes a modalBox from any javascript function. Direct call via "source" (AJAX) <script type="text/javascript">
/* <![CDATA[ */
jQuery(document).ready(function(){
jQuery.fn.modalBox({
directCall: {
source : 'inc_ajaxinclude_1.php?test=tester'
}
});
});
/* ]]> */
</script>Direct call via "data" (push static content) <script type="text/javascript">
/* <![CDATA[ */
jQuery(document).ready(function(){
jQuery.fn.modalBox({
directCall: {
data : '<div class="testclass"><p>test</p></div>'
}
});
});
/* ]]> */
</script>Direct call via "element" (get content from HTML Element) <div id="testDirectCallHtmlContent" style="display:none;">
Test content
</div>
<script type="text/javascript">
/* <![CDATA[ */
jQuery(document).ready(function(){
jQuery.fn.modalBox({
directCall: {
element : '#testDirectCallHtmlContent'
}
});
});
/* ]]> */
</script>Direct call via "image" (get content from HTML Element) <script type="text/javascript">
/* <![CDATA[ */
jQuery(document).ready(function(){
jQuery.fn.modalBox({
directCall: {
image : 'demopicture_kalexis_newzealand_6930.JPG'
}
});
});
/* ]]> */
</script>MethodsMethod "close". Close the modalBox from everywhere. <script type="text/javascript">
/* <![CDATA[ */
jQuery.fn.modalBox("close");
/* ]]> */
</script>Method "center". Repositioning the modalBox. <script type="text/javascript">
/* <![CDATA[ */
jQuery.fn.modalBox("center");
/* ]]> */
</script>Optional parameter optionssetTypeOfFaderLayer
Release Notes2012-02-12 / 1.3.0
2011-06-02 / 1.2.1
2010-12-30 / 1.2.0
2010-11-29 / 1.1.7
2010-11-29 / 1.1.6
2010-11-28 / 1.1.5
2010-11-14 / 1.1.4
2010-11-14 / 1.1.3
2010-11-09 / 1.1.2
2010-11-05 / 1.1.1
2010-10-24 / 1.1.0
2010-05-02 / 1.0.9
2010-04-16 / 1.0.8
2010-04-14 / 1.0.7
2010-04-14 / 1.0.6
2010-04-11 / 1.0.5
2010-04-11 / 1.0.4
2010-04-05 / 1.0.3
2010-03-29 / 1.0.1
2010-03-28 / 1.0.0
|