epic-s6ts
[kivitendo-erp.git] / js / ajax_layout.js
1 function load_layout(baseURL){
2   $.ajax({
3     url: baseURL + 'controller.pl?action=Layout/empty&format=json',
4     method: 'GET',
5     dataType: 'json',
6     success: function (data) {
7       if (data["stylesheets"]) {
8         $.each(data["stylesheets"], function(i, e){
9           $('head').append('<link rel="stylesheet" href="' + baseURL + e + '" type="text/css" title="Stylesheet">');
10         });
11       }
12       if (data["stylesheets_inline"] && data["stylesheets_inline"].size) {
13         var style = "<style type='text/css'>";
14         $.each(data["stylesheets_inline"], function(i, e){
15           style += e;
16         });
17         style += '</style>';
18         $('head').append(style);
19       }
20       if (data["start_content"]) {
21         $('body').wrapInner(data["start_content"]);
22       }
23       if (data["pre_content"]) {
24         $('body').prepend(data["pre_content"]);
25       }
26       if (data["post_content"]) {
27         $('body').append(data["post_content"]);
28       }
29       if (data["javascripts"]) {
30         $.each(data["javascripts"], function(i, e){
31           $('head').append('<script type="text/javascript" src="' + baseURL + e + '">');
32         });
33       }
34       if (data["javascripts_inline"]) {
35         var script = "<script type='text/javascript'>";
36         $.each(data["javascripts_inline"], function(i, e){
37           script += e;
38         });
39         script += '</script>';
40         $('head').append(script);
41       }
42     }
43   });
44 }