Hi,

I'm trying to keep some javascript from the views-accordion module from being removed for high-end devices but I cant seem to get it to work on my own. I've located the function that filters the javascript but I'm afraid I'm mostly lost when it comes to php. I tried replicating if statement in the code below that adds js from the theme with (stristr($js_filename, 'views-accordion') but that didnt seem to work. Other attempted solutions have only been able to remove the js filter completely or keep the js I want but not the themes (i.e. the accordion created at header and footer).

function _nokia_mobile_filter_js($js) {
	$new_js_list = array();
	foreach($js as $js_type => $js_filename_array) {
		if ($js_type == 'inline') {
			// leave untouched
			$new_js_list[$js_type] = $js[$js_type];
			continue;
		}
		foreach($js_filename_array as $js_filename => $vals) {
			// only allow JS that came from nokia_mobile theme
			if (stristr($js_filename, 'nokia_mobile')) {
				$new_js_list[$js_type][$js_filename] = $js[$js_type][$js_filename];
			}
			
		}
	}
	return drupal_get_js('header', $new_js_list);
}

Any help on how to fine-tune the javscript filter would be greatly appreciated!

Comments

atrasatti’s picture

Which mobile plugin are using? mobileplugin? Mobile Tools?

Depending on the plugin you might have to make different changes to the template.
I can look into making my implementation more customisable, but if you use a mobile plugin that might also remove or change your javascript.

scalp’s picture

atrasatti,

I was trying to figure out how to do this last night and got nowhere. I want to keep the js for openlayers geocoder, but have no idea how to do so. I'm using mobile tools for device detection using urls to determine the redirection to the nokia mobile theme based domain. I'd like to keep that js active no matter what device hits it though so it would seem like something I need to change in the template file. Any ideas?

yeaha’s picture

scalp,

add the following code

if (stristr($js_filename, 'openlayers_geocoder')) {
$new_js_list[$js_type][$js_filename] = $js[$js_type][$js_filename];
}

inside the foreach($js_filename_array as $js_filename => $vals) {}