function _addtoany_header_script in AddToAny Share Buttons 6.3
Internal function to add inline JavaScript to the head tag.
Return value
String containing JavaScript code to initialize each drop-down menu
1 call to _addtoany_header_script()
- _addtoany_create_button in ./
addtoany.module - Internal function to generate code for AddToAny button
File
- ./
addtoany.module, line 130 - Standalone module file to handle AddToAny button integration
Code
function _addtoany_header_script() {
$script_url = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on' ? 'https://static.addtoany.com/menu/page.js' : 'http://static.addtoany.com/menu/page.js';
$javascript_header = "var a2a_config=a2a_config||{}," . "da2a={done:false," . "html_done:false," . "script_ready:false," . "script_load:function(){" . "var a=document.createElement('script')," . "s=document.getElementsByTagName('script')[0];" . "a.type='text/javascript';a.async=true;" . "a.src='" . $script_url . "';" . "s.parentNode.insertBefore(a,s);" . "da2a.script_load=function(){};" . "}," . "script_onready:function(){" . "da2a.script_ready=true;" . "if(da2a.html_done)da2a.init();" . "}," . "init:function(){" . "for(var i=0,el,target,targets=da2a.targets,length=targets.length;i<length;i++){" . "el=document.getElementById('da2a_'+(i+1));" . "target=targets[i];" . "a2a_config.linkname=target.title;" . "a2a_config.linkurl=target.url;" . "if(el)a2a.init('page',{target:el});da2a.done=true;" . "}" . "}" . "};" . "a2a_config.tracking_callback=['ready',da2a.script_onready];" . variable_get('addtoany_additional_js', '');
drupal_add_js($javascript_header, 'inline');
}