function initSlider($id, $params) { AriImageSliderHelper::includeAssets($params); $clientParams = AriImageSliderHelper::getClientParams($params); $doc = JFactory::getDocument(); $loadMethod = $params->get('loadMethod', 'load'); $doc->addScriptDeclaration(sprintf('%3$s(function() { var $ = window.jQueryNivoSlider || jQuery; $("#%1$s").nivoSlider(%2$s); });', $id, $clientParams ? AriJSONHelper::encode($clientParams) : '', $loadMethod == 'load' ? 'jQuery(window).load' : 'jQuery(document).ready')); $responsive = (bool) $params->get('responsive'); $width = intval($params->get('width', 300), 10); $height = intval($params->get('height'), 10); if (!$responsive) { $styleDec = sprintf('#%1$s_wrapper,#%1$s{width:%2$dpx;height:%3$dpx;}', $id, $width, $height); } else { $styleDec = sprintf('#%1$s_wrapper{max-width:%2$dpx;}#%1$s{width:100%%;height:auto;}', $id, $width); $doc->addCustomTag(sprintf('<!--[if lt IE 9]><style type="text/css">BODY #%1$s_wrapper,BODY #%1$s{width:%2$dpx;height:%3$dpx;}</style><![endif]-->', $id, $width, $height)); } if ($params->get('style')) { $extraStyles = trim($params->get('style')); $extraStyles = str_replace('{$id}', '#' . $id, $extraStyles); if (!empty($extraStyles)) { $styleDec .= $extraStyles; } } $doc->addStyleDeclaration($styleDec); }
function initSlider($id, $params) { AriImageSliderHelper::includeAssets($params); $clientParams = AriImageSliderHelper::getClientParams($params); $doc = JFactory::getDocument(); $loadMethod = $params->get('loadMethod', 'load'); $fixTransparentBg = (bool) $params->get('fixTransparentBg'); $animSpeed = AriUtils::getParam($clientParams, 'animSpeed', 500); $doc->addScriptDeclaration(sprintf('%3$s(function() { var $ = window.jQueryNivoSlider || jQuery; var opts = %2$s;%4$s $("#%1$s").nivoSlider(opts); });', $id, $clientParams ? AriJSONHelper::encode($clientParams) : '{}', $loadMethod == 'load' ? 'jQuery(window).load' : 'jQuery(document).ready', $fixTransparentBg ? sprintf('opts["beforeChange"] = function() { setTimeout(function() { $("#%1$s .nivo-main-image").animate({opacity:0}, %2$d);}, 20); }; opts["afterChange"] = function() { setTimeout(function() { $("#%1$s .nivo-main-image").css({opacity:1}); }, 20); };', $id, $animSpeed) : '')); $responsive = (bool) $params->get('responsive'); $width = intval($params->get('width', 300), 10); $height = intval($params->get('height'), 10); if (!$responsive) { $styleDec = sprintf('#%1$s_wrapper,#%1$s{width:%2$dpx;height:%3$dpx;}', $id, $width, $height); } else { $maxWidth = $params->get('width'); if (strpos($maxWidth, '%') === false) { $maxWidth = $width . 'px'; } $styleDec = sprintf('#%1$s_wrapper{max-width:%2$s;}#%1$s{width:100%%;height:auto;}.ari-image-slider-loading #%1$s{height:%3$dpx;}', $id, $maxWidth, $height); $doc->addCustomTag(sprintf('<!--[if lt IE 8]><style type="text/css">BODY #%1$s_wrapper,BODY #%1$s{width:%2$dpx;height:%3$dpx;}</style><![endif]-->', $id, $width, $height)); } if ($params->get('customstyle')) { $extraStyles = trim($params->get('customstyle')); $extraStyles = str_replace('{$id}', '#' . $id, $extraStyles); if (!empty($extraStyles)) { $styleDec .= $extraStyles; } } $doc->addStyleDeclaration($styleDec); }
function initSlider($id, $params) { AriImageSliderHelper::includeAssets($params); $clientParams = AriImageSliderHelper::getClientParams($params); $doc =& JFactory::getDocument(); $doc->addScriptDeclaration(sprintf('jQuery(window).load(function() { var $ = window.jQueryNivoSlider || jQuery; $("#%1$s").nivoSlider(%2$s); });', $id, $clientParams ? AriJSONHelper::encode($clientParams) : '')); $width = intval($params->get('width', 300), 10); $height = intval($params->get('height'), 10); $styleDec = sprintf('#%1$s_wrapper,#%1$s{width:%2$dpx;height:%3$dpx;}', $id, $width, $height); if ($params->get('style')) { $extraStyles = trim($params->get('style')); $extraStyles = str_replace('{$id}', '#' . $id, $extraStyles); if (!empty($extraStyles)) { $styleDec .= $extraStyles; } } $doc->addStyleDeclaration($styleDec); }