function _disclaimer_get_js in Disclaimer 6
Generate js function
1 call to _disclaimer_get_js()
- disclaimer_init in ./
disclaimer.module - Implementation of hook_init().
File
- ./
disclaimer.module, line 173 - Create and show disclaimer for your site. Visotors need js enabled and accept cookie
Code
function _disclaimer_get_js() {
$cookie_path = variable_get('disclaimer_cookie_path', '/');
$cookie_expires = variable_get('disclaimer_cookie_expires', '');
$cookie_domain = variable_get('disclaimer_cookie_domain', '');
$modal = variable_get('disclaimer_modal', 'thickbox');
if ($modal == 'nyroModal' || $modal == 'thickbox') {
$debug = variable_get('disclaimer_debug', 'false');
$width = variable_get('disclaimer_width', 400);
$height = variable_get('disclaimer_height', 300);
$padding = variable_get('disclaimer_padding', 20);
$bgcolor = variable_get('disclaimer_bgcolor', '000000');
}
elseif ($modal == 'jqModal') {
$overlay = variable_get('disclaimer_jqmodal_overlay', 90);
}
$js = 'function WriteCookie(nom, valeur){' . "\n";
$js .= 'var argv=WriteCookie.arguments;' . "\n";
$js .= 'var argc=WriteCookie.arguments.length;' . "\n";
$js .= 'var expires=(argc > 2) ? argv[2] : null;' . "\n";
$js .= 'var secure=(argc > 5) ? argv[5] : false;' . "\n";
if (empty($cookie_path)) {
$js .= 'var path=(argc > 3) ? argv[3] : null;' . "\n";
}
if (empty($cookie_domain)) {
$js .= 'var domain=(argc > 4) ? argv[4] : null;' . "\n";
}
$js .= 'document.cookie=nom+"="+escape(valeur)+' . "\n";
$js .= '((expires==null) ? "" : ("; expires="+expires.toGMTString()))+' . "\n";
if (empty($cookie_path)) {
$js .= '((path==null) ? "" : ("; path="+path))+' . "\n";
}
else {
$js .= '("; path=' . $cookie_path . '")+' . "\n";
}
if (empty($cookie_domain)) {
$js .= '((domain==null) ? "" : ("; domain="+domain))+' . "\n";
}
else {
$js .= '("; domain=' . $cookie_domain . '")+' . "\n";
}
$js .= '((secure==true) ? "; secure" : "");}' . "\n";
$js .= 'if (ReadCookie("' . variable_get('disclaimer_cookie_name', 'disclaimerShow') . '") == null) {';
$js .= '$(document).ready(function(){';
switch ($modal) {
case 'nyroModal':
$js .= '$.nyroModalManual({url:\'' . url('disclaimer') . '\',modal:true, minWidth:' . $width . ', minHeight:' . $height . ', padding:' . $padding . ', debug:' . $debug . ', bgcolor:\'#' . $bgcolor . '\'});';
break;
case 'jqModal':
$js .= '$(\'#disclaimer\').jqm({ajax:\'' . url('disclaimer') . '\', overlay:' . $overlay . ', modal:true}).jqmShow();';
break;
case 'thickbox':
$js .= 'tb_show(\'test\', \'' . url('disclaimer', array(
'query' => array(
'modal' => 'true',
'height' => $height,
'width' => $width,
),
)) . '\')';
break;
}
$js .= '});}';
return $js;
}