Joomla.it Forum
Joomla! 1.5.x (versione con supporto terminato) => Joomla! 1.5 => : guardiano 29 Oct 2013, 19:53:48
-
Salve,
ho installato il plugin per visualizzare i messaggi di sistema in una finestra modal.
Di seguito il link:
http://archive.extensions.joomla.org/extensions/style-a-design/popups-a-iframes/14271
Mi piacerebbe fare in modo che dopo un tot di millisecondi si chiudesse da sola.
Così sono andato nel file del plugin ed ho trovato questo:
$document->addScriptDeclaration("
window.addEvent('domready', function(){
var message = SqueezeBox.fromElement( $('system-message'), {
size: {x: 600, y: 100},
handler: 'adopt', // this is what's moving the message inside the modal box
closable: true,
closeBtn: true,
overlayOpacity: $opacity,
classWindow: '$custom_class'
/*
Alternate attributes:
onOpen: $empty,
onClose: $empty,
onUpdate: $empty,
onResize: $empty,
onMove: $empty,
onShow: $empty,
onHide: $empty,
sizeLoading: {x: 600, y: 100},
marginInner: {x: 0, y: 0},
marginImage: {x: 0, y: 0},
target: null,
zIndex: 65555,
classOverlay: '',
overlayFx: {},
resizeFx: {},
contentFx: {},
parse: false, // 'rel'
parseSecure: false,
shadow: true,
document: null,
ajaxOptions: {},
*/
});
});
");
In che modo posso aggiungere la durata a questo script?
Grazie.
-
Ciao,
dovresti aggiungere questa parte di codice :
setTimeout($('#dialog').dialog('close'), 10000);
#dialog = è il nome del tuo elemeno modal
10000= equivale a 10 secondi
-
Dove dovrei posizionarlo?
Ti scrivo di seguito tutto il codice del file:
<?php
/**
* @version $Id: modalmessages.php $
* @package Joomla
* @copyright Copyright (C) 2010 Crossing Hippos - Babs Gšsgens. All rights reserved.
* @license GNU/GPL
*/
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport( 'joomla.plugin.plugin' );
/**
* Joomla! Debug plugin
*
* @package Joomla
* @subpackage System
*/
class plgSystemModalmessages extends JPlugin
{
/**
* Constructor
*
* For php4 compatability we must not use the __constructor as a constructor for plugins
* because func_get_args ( void ) returns a copy of all passed arguments NOT references.
* This causes problems with cross-referencing necessary for the observer design pattern.
*
* @access protected
* @param object $subject The object to observe
* @param array $config An array that holds the plugin configuration
* @since 1.0
*/
function plgSystemModalmessages(& $subject, $config)
{
parent::__construct($subject, $config);
}
/*
* Load javascript voor message modal box
*/
function onAfterInitialise()
{
global $mainframe;
$scope = $this->params->get('scope', 0);
// Check if we are in the frontend or the backend
switch($scope) {
case 0:
$active = true;
break;
case 1:
$active = JPATH_BASE == JPATH_SITE ? true : false;
break;
case 2:
$active = JPATH_BASE == JPATH_ADMINISTRATOR ? true : false;
break;
}
if($mainframe->getMessageQueue() && $active) {
// Load the mootools library, we need it
JHTML::_('behavior.modal');
$document =& JFactory::getDocument();
// Intialize some config variables
$opacity = $this->params->get('overlay_opacity', 0);
$custom_class = $this->params->get('custom_class', 'modal-message');
$custom_css_frontend = $this->params->get('custom_css_frontend');
$custom_css_backend = $this->params->get('custom_css_backend');
// System Messages Overrides
$document->addStyleDeclaration("
#system-message { visibility: hidden; display: none; }
#sbox-content #system-message { visibility: visible !important; display: block !important; }
");
if(JPATH_BASE == JPATH_SITE && !$custom_css_frontend)
$document->addStyleSheet(JURI::root().'plugins/system/modalmessages/modalmessages.css');
elseif(JPATH_BASE == JPATH_ADMINISTRATOR && !$custom_css_backend)
$document->addStyleSheet(JURI::root().'plugins/system/modalmessages/modalmessages.css');
// Load the magic
$document->addScriptDeclaration("
window.addEvent('domready', function(){
var message = SqueezeBox.fromElement( $('system-message'), {
size: {x: 600, y: 100},
handler: 'adopt', // this is what's moving the message inside the modal box
closable: true,
closeBtn: true,
overlayOpacity: $opacity,
classWindow: '$custom_class'
setTimeout($('#dialog').dialog('close'), 10000);
/*
Alternate attributes:
onOpen: $empty,
onClose: $empty,
onUpdate: $empty,
onResize: $empty,
onMove: $empty,
onShow: $empty,
onHide: $empty,
sizeLoading: {x: 600, y: 100},
marginInner: {x: 0, y: 0},
marginImage: {x: 0, y: 0},
target: null,
zIndex: 65555,
classOverlay: '',
overlayFx: {},
resizeFx: {},
contentFx: {},
parse: false, // 'rel'
parseSecure: false,
shadow: true,
document: null,
ajaxOptions: {},
*/
});
});
");
}
}
}
Grazie.
-
1- Fai un backup del file esistente
2- Cambi #dialog con l'id del tuo elemento (per esempio #mio_modal)
3- File l'upload e sostituisci il file esistente
Considera che non sono azzeccatisimo in js, quindi potrebbe non funzionare[/code]
<?php
/**
* @version $Id: modalmessages.php $
* @package Joomla
* @copyright Copyright (C) 2010 Crossing Hippos - Babs Gšsgens. All rights reserved.
* @license GNU/GPL
*/
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
jimport( 'joomla.plugin.plugin' );
/**
* Joomla! Debug plugin
*
* @package Joomla
* @subpackage System
*/
class plgSystemModalmessages extends JPlugin
{
/**
* Constructor
*
* For php4 compatability we must not use the __constructor as a constructor for plugins
* because func_get_args ( void ) returns a copy of all passed arguments NOT references.
* This causes problems with cross-referencing necessary for the observer design pattern.
*
* @access protected
* @param object $subject The object to observe
* @param array $config An array that holds the plugin configuration
* @since 1.0
*/
function plgSystemModalmessages(& $subject, $config)
{
parent::__construct($subject, $config);
}
/*
* Load javascript voor message modal box
*/
function onAfterInitialise()
{
global $mainframe;
$scope = $this->params->get('scope', 0);
// Check if we are in the frontend or the backend
switch($scope) {
case 0:
$active = true;
break;
case 1:
$active = JPATH_BASE == JPATH_SITE ? true : false;
break;
case 2:
$active = JPATH_BASE == JPATH_ADMINISTRATOR ? true : false;
break;
}
if($mainframe->getMessageQueue() && $active) {
// Load the mootools library, we need it
JHTML::_('behavior.modal');
$document =& JFactory::getDocument();
// Intialize some config variables
$opacity = $this->params->get('overlay_opacity', 0);
$custom_class = $this->params->get('custom_class', 'modal-message');
$custom_css_frontend = $this->params->get('custom_css_frontend');
$custom_css_backend = $this->params->get('custom_css_backend');
// System Messages Overrides
$document->addStyleDeclaration("
#system-message { visibility: hidden; display: none; }
#sbox-content #system-message { visibility: visible !important; display: block !important; }
");
if(JPATH_BASE == JPATH_SITE && !$custom_css_frontend)
$document->addStyleSheet(JURI::root().'plugins/system/modalmessages/modalmessages.css');
elseif(JPATH_BASE == JPATH_ADMINISTRATOR && !$custom_css_backend)
$document->addStyleSheet(JURI::root().'plugins/system/modalmessages/modalmessages.css');
// Load the magic
$document->addScriptDeclaration("
window.addEvent('domready', function(){
var message = SqueezeBox.fromElement( $('system-message'), {
size: {x: 600, y: 100},
handler: 'adopt', // this is what's moving the message inside the modal box
closable: true,
closeBtn: true,
overlayOpacity: $opacity,
classWindow: '$custom_class'
});
setTimeout($('#dialog').dialog('close'), 10000);
});
");
}
}
}
-
niente, non si chiude.
Grazie mille per l'impegno comunque :-)
-
Probabilmente ho sbagliato io qualcosa, mi spiace non poterti aiutare ma js non è proprio il mio forte.