Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [JavaScript][HTML][PHP] Jak zrobić opóźnienie funkcji wyskakującego PopUp-a
danieele
post
Post #1





Grupa: Zarejestrowani
Postów: 2
Pomógł: 0
Dołączył: 23.09.2011

Ostrzeżenie: (0%)
-----


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?

  1. <?php
  2. /**
  3.  * @Package Plugin System Modal Popups Content - BECóV
  4.  * @Version 1.2
  5.  * @Author ROALCANA
  6.  * @AuthorUrl www.roalcana.com
  7.  * @copyright (C) 2011 ROALCANA. All rights reserved.
  8.  * @license GNU/GPL <a href="http://www.gnu.org/copyleft/gpl.html" target="_blank">http://www.gnu.org/copyleft/gpl.html</a>
  9.  * Plugin System Modal Popups Content is Free Software
  10.  */
  11.  
  12. // Check to ensure this file is included in Joomla!
  13. defined( '_JEXEC' ) or die( 'Restricted access' );
  14.  
  15. jimport( 'joomla.plugin.plugin' );
  16.  
  17. class plgSystemMpcontent extends JPlugin
  18.  
  19.  
  20.  
  21. {
  22.  
  23. /**
  24.   * plgSystemMPContent::plgSystemMPContent()
  25.   *
  26.   * @param mixed $subject
  27.   * @return
  28.   */
  29. function plgSystemMpcontent( &$subject, $config )
  30. {
  31. parent::__construct($subject, $config);
  32. }
  33.  
  34. /**
  35.   * plgSystemMPContent::onAfterInitialise()
  36.   *
  37.   * @return
  38.   */
  39. function onAfterRoute()
  40. {
  41. # Disable the popup if not corresponding Itemid (menu item)
  42. $filter = $this->params->get( 'mpc_filter', '0' );
  43. $menuop = $this->params->get( 'mpc_when', '' );
  44.  
  45. if ( $filter && $menuop != '' && $menuop != JRequest::getInt( 'Itemid' , 0 ) ) {
  46. return;
  47. }
  48.  
  49. # Disable the popup if there is nothing to display
  50. $id = $this->params->get( 'mpc_content', null );
  51. if ( !$id ) {
  52. return;
  53. }
  54.  
  55. # Disable the popup for non-HTML interface (like RSS)
  56. $document = &JFactory::getDocument();
  57. $doctype = $document->getType();
  58. if ( $doctype !== 'html' ) {
  59. return;
  60. }
  61.  
  62. # Get the required path info
  63. $uri = &JURI::getInstance();
  64. $base = str_replace( '/administrator', '', JURI::Base(true) );
  65.  
  66. # Determine if we're in the backend
  67. if ( JPATH_BASE != JPATH_ADMINISTRATOR ) {
  68. $isadmin = false;
  69. } else {
  70. $isadmin = true;
  71. }
  72.  
  73. # Disable the popup on joomla_root/index2.php calls
  74. if ( JRequest::getVar('tmpl') == 'component' ) {
  75. return;
  76. }
  77.  
  78. # Get where the popup will be shown
  79. $mpc_where = $this->params->get( 'mpc_where', 0 );
  80.  
  81. # If we're in the backend and the plugin is configured to display only in frontend
  82. # then disable the popup
  83. if ( $isadmin && $mpc_where == 0 ) {
  84. return;
  85. }
  86.  
  87. # If we're in the frontend and the plugin is configured to display only in backend
  88. # then disable the popup
  89. if ( !$isadmin && $mpc_where == 1 ) {
  90. return;
  91. }
  92.  
  93. # Get how often the popup will be shown
  94. $mpc_freq = $this->params->get( 'mpc_freq', 1 );
  95.  
  96. # Determine if it's time for the popup to be displayed
  97. if ( $mpc_freq > 0 ) {
  98. $mpc_next = JRequest::getVar( 'mpc_next_' . $id, null, 'cookie', 'int' );
  99. if ( $mpc_next > time() ) {
  100. return;
  101. }
  102. }
  103.  
  104. # Get the popup's remaining parameters
  105. $mpc_width = $this->params->get( 'mpc_width', 500 );
  106. $mpc_height = $this->params->get( 'mpc_height', 500 );
  107. if ( $mpc_width == 0 )
  108. $mpc_width = 500;
  109. if ( $mpc_height == 0 )
  110. $mpc_height = 500;
  111.  
  112. # Display the popup
  113. $content = "
  114.  
  115. function init() {
  116. SqueezeBox.fromElement(
  117. '" . $base . "/index.php?option=com_content&view=article&id={$id}&tmpl=component',
  118. {handler: 'iframe', size: {x: $mpc_width, y: $mpc_height}}
  119. )
  120. };
  121.  
  122. if (document.addEventListener) {
  123. document.addEventListener(\"DOMContentLoaded\", init, false);
  124. } else {
  125. window.onload = init;
  126. }";
  127.  
  128. JHTML::_( 'behavior.modal' );
  129. $document->addScriptDeclaration( $content, 'text/javascript' );
  130.  
  131. #Set coockie as required
  132. $period = 60 * 60 * 24 * 365;
  133. switch ( $mpc_freq ) {
  134. case 1:
  135. setcookie( 'mpc_next_' . $id, '', time() - $period, '/' );
  136. setcookie( 'mpc_next_' . $id, time() + $period, 0, '/' );
  137. break;
  138. case 2:
  139. setcookie( 'mpc_next_' . $id, '', time() - $period, '/' );
  140. setcookie( 'mpc_next_' . $id, time() + $period, time() + $period, '/' );
  141. break;
  142. case 3:
  143. setcookie( 'mpc_next_' . $id, '', time() - $period, '/' );
  144. $period = $this->params->get( 'mpc_period', 600 );
  145. setcookie( 'mpc_next_' . $id, time() + $period, time() + (60 * 60 * 24 * 365), '/' );
  146. break;
  147. default:
  148. break;
  149. }
  150. #End of plugin
  151. return;
  152. }
  153. }



Ten post edytował danieele 23.09.2011, 13:09:42
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 23.12.2025 - 02:40