1 | <?php |
---|
2 | function ajax_nav_insert_head($flux) { |
---|
3 | |
---|
4 | $options = unserialize($GLOBALS['meta']['ajax_nav_config']); |
---|
5 | |
---|
6 | function prepare($options) { |
---|
7 | $options = preg_replace("/[^a-zA-Z0-9\-\_]+/", "', ", $options); |
---|
8 | $options = preg_replace("/([a-zA-Z0-9\-\_]+)/", "'$1", $options); |
---|
9 | $options = preg_replace("/([^'])$/", "$1'", $options); |
---|
10 | return $options; |
---|
11 | } |
---|
12 | |
---|
13 | $ajaxNavFile = ($options['html4Fallback'] == 'on') ? |
---|
14 | find_in_path('ajax_nav.js') : ''; |
---|
15 | |
---|
16 | $historyLibFile = ($options['html4Fallback'] == 'on') ? |
---|
17 | find_in_path('lib/balupton-history.js/scripts/bundled/html4+html5/jquery.history.js') : ''; |
---|
18 | |
---|
19 | if ($options['useModernLib'] == "on") { |
---|
20 | $flux .= "<script type='text/javascript' src='" . find_in_path("lib/modernizr.js") . "'></script>"; |
---|
21 | } |
---|
22 | |
---|
23 | $flux .= "<script type='text/javascript'> |
---|
24 | Modernizr.load(["; |
---|
25 | |
---|
26 | if ($options['useHistoryLib'] == "on") { |
---|
27 | $flux .= " { |
---|
28 | test : Modernizr.history, |
---|
29 | yep : ['" . find_in_path("lib/balupton-history.js/scripts/bundled/html5/jquery.history.js") . "'], |
---|
30 | nope : ['" . $historyLibFile . "'] |
---|
31 | },"; |
---|
32 | } |
---|
33 | |
---|
34 | $flux .= " |
---|
35 | { |
---|
36 | test : Modernizr.history, |
---|
37 | yep : ['" . find_in_path("ajax_nav.js") . "'], |
---|
38 | nope: ['" . $ajaxNavFile . "'], |
---|
39 | complete : function () { |
---|
40 | if (typeof AjaxNav !== 'undefined') { |
---|
41 | AjaxNav.options = { |
---|
42 | pagesToAjaxify: [" . prepare($options["pagesToAjaxify"]) . "], |
---|
43 | ajaxDivs: [" . prepare($options["ajaxDivs"]) . "], |
---|
44 | localizedDivs: [" . prepare($options["localizedDivs"]) . "] |
---|
45 | }; |
---|
46 | AjaxNav(); |
---|
47 | } |
---|
48 | } |
---|
49 | } |
---|
50 | ]); |
---|
51 | </script> |
---|
52 | "; |
---|
53 | |
---|
54 | return $flux; |
---|
55 | } |
---|
56 | ?> |
---|