Jak zrobić opóźnienie funkcji wyskakującego PopUp-a.
Teraz okno wyskakuje automatycznie po załadowaniu strony, a ja chciałbym aby pojawiało się po 15 sekundach
Może ktoś podpowie?
<?php
/**
* @Package Plugin System Modal Popups Content - BECóV
* @Version 1.2
* @Author ROALCANA
* @AuthorUrl www.roalcana.com
* @copyright (C) 2011 ROALCANA. All rights reserved.
* @license GNU/GPL <a href="http://www.gnu.org/copyleft/gpl.html" target="_blank">http://www.gnu.org/copyleft/gpl.html</a>
* Plugin System Modal Popups Content is Free Software
*/
// Check to ensure this file is included in Joomla!
defined( '_JEXEC' ) or
die( 'Restricted access' );
jimport( 'joomla.plugin.plugin' );
class plgSystemMpcontent extends JPlugin
{
/**
* plgSystemMPContent::plgSystemMPContent()
*
* @param mixed $subject
* @return
*/
function plgSystemMpcontent( &$subject, $config )
{
parent::__construct($subject, $config);
}
/**
* plgSystemMPContent::onAfterInitialise()
*
* @return
*/
function onAfterRoute()
{
# Disable the popup if not corresponding Itemid (menu item)
$filter = $this->params->get( 'mpc_filter', '0' );
$menuop = $this->params->get( 'mpc_when', '' );
if ( $filter && $menuop != '' && $menuop != JRequest::getInt( 'Itemid' , 0 ) ) {
return;
}
# Disable the popup if there is nothing to display
$id = $this->params->get( 'mpc_content', null );
if ( !$id ) {
return;
}
# Disable the popup for non-HTML interface (like RSS)
$document = &JFactory::getDocument();
$doctype = $document->getType();
if ( $doctype !== 'html' ) {
return;
}
# Get the required path info
$uri = &JURI::getInstance();
$base = str_replace( '/administrator', '', JURI
::Base(true) );
# Determine if we're in the backend
if ( JPATH_BASE != JPATH_ADMINISTRATOR ) {
$isadmin = false;
} else {
$isadmin = true;
}
# Disable the popup on joomla_root/index2.php calls
if ( JRequest::getVar('tmpl') == 'component' ) {
return;
}
# Get where the popup will be shown
$mpc_where = $this->params->get( 'mpc_where', 0 );
# If we're in the backend and the plugin is configured to display only in frontend
# then disable the popup
if ( $isadmin && $mpc_where == 0 ) {
return;
}
# If we're in the frontend and the plugin is configured to display only in backend
# then disable the popup
if ( !$isadmin && $mpc_where == 1 ) {
return;
}
# Get how often the popup will be shown
$mpc_freq = $this->params->get( 'mpc_freq', 1 );
# Determine if it's time for the popup to be displayed
if ( $mpc_freq > 0 ) {
$mpc_next = JRequest::getVar( 'mpc_next_' . $id, null, 'cookie', 'int' );
if ( $mpc_next > time() ) { return;
}
}
# Get the popup's remaining parameters
$mpc_width = $this->params->get( 'mpc_width', 500 );
$mpc_height = $this->params->get( 'mpc_height', 500 );
if ( $mpc_width == 0 )
$mpc_width = 500;
if ( $mpc_height == 0 )
$mpc_height = 500;
# Display the popup
$content = "
function init() {
SqueezeBox.fromElement(
'" . $base . "/index.php?option=com_content&view=article&id={$id}&tmpl=component',
{handler: 'iframe', size: {x: $mpc_width, y: $mpc_height}}
)
};
if (document.addEventListener) {
document.addEventListener(\"DOMContentLoaded\", init, false);
} else {
window.onload = init;
}";
JHTML::_( 'behavior.modal' );
$document->addScriptDeclaration( $content, 'text/javascript' );
#Set coockie as required
$period = 60 * 60 * 24 * 365;
switch ( $mpc_freq ) {
case 1:
break;
case 2:
break;
case 3:
$period = $this->params->get( 'mpc_period', 600 );
setcookie( 'mpc_next_' . $id, time() + $period, time() + (60 * 60 * 24 * 365), '/' ); break;
default:
break;
}
#End of plugin
return;
}
}
Ten post edytował danieele 23.09.2011, 13:09:42