1 | /** |
---|
2 | * A Css and JavaScript load system for t29v6. |
---|
3 | * |
---|
4 | * This is needed because the t29Host web_prefix system, so the website can be |
---|
5 | * loaded at some different point than the document root. |
---|
6 | * |
---|
7 | * Sven Koeppel, 08.03.2013, GPL |
---|
8 | **/ |
---|
9 | |
---|
10 | if(!t29) window.t29 = {}; // the t29 namespace |
---|
11 | t29.load = {}; |
---|
12 | |
---|
13 | /** |
---|
14 | * Load the CSS file for a specific seiten_id. This is done by the t29Template on |
---|
15 | * server side automatically but can be useful for modular pagescripts loading parts |
---|
16 | * of other pages via AJAX. |
---|
17 | **/ |
---|
18 | t29.load.pagestyle = function(seiten_id) { |
---|
19 | path = "/shared/css-v6/pagestyles/" + seiten_id + ".css"; |
---|
20 | t29.load.css(path); |
---|
21 | }; |
---|
22 | |
---|
23 | t29.load.css = function(file) { |
---|
24 | file = t29.load.get_path(file); |
---|
25 | $("<style type='text/css'/>").html('@import url("'+file+'")').appendTo("head"); |
---|
26 | }; |
---|
27 | |
---|
28 | t29.load.js = function(file, callback) { |
---|
29 | file = t29.load.get_path(file); |
---|
30 | $.getScript(file, callback); |
---|
31 | }; |
---|
32 | |
---|
33 | /** |
---|
34 | * Convert a t29 relative path like /shared/css/foo to |
---|
35 | * a path converting the webroot, like /path/to/t29/site/shared/css/foo |
---|
36 | * @return string |
---|
37 | **/ |
---|
38 | t29.load.get_path = function(file) { |
---|
39 | return t29.conf.web_prefix + file; |
---|
40 | }; |
---|
41 | |
---|
42 | t29.load.setup = function() { |
---|
43 | if(!t29.conf.web_prefix) t29.conf.web_prefix = ""; |
---|
44 | }; |
---|