]> git.agnieray.net Git - galette.git/blob - galette/templates/default/gestion_pdf.tpl
098181e7956a21d116a1ea06ade916c48b3760ea
[galette.git] / galette / templates / default / gestion_pdf.tpl
1 {extends file="page.tpl"}
2
3 {block name="content"}
4 <div class="tabbed">
5 <div id="tabs">
6 <ul>
7 {foreach from=$models item=m name=formodels}
8 {if $m->id eq $model->id}
9 {assign var='activetab' value=$smarty.foreach.formodels.iteration}
10 {/if}
11 <li{if $m->id eq $model->id} class="ui-tabs-selected"{/if}><a href="{path_for name="pdfModels" data=["id" => $m->id]}">{$m->name}</a></li>
12 {/foreach}
13 </ul>
14 <div id="ui-tabs-{$activetab}">
15 {include file="gestion_pdf_content.tpl"}
16 </div>
17 </div>
18 </div>
19 {/block}
20
21 {block name="javascripts"}
22 <script type="text/javascript">
23 $('#tabs').append('<a id="btnlegend" class="tab-button tooltip action" title="{_T string="Show existing variables"}"><i class="fas fa-info-circle fa-2x"></i> <span class="sr-only">{_T string="Show existing variables" escape="js"}</span></a>');
24
25 var _handleLegend = function(index) {
26 $('#legende' + index + ' h1').remove();
27 $('#legende' + index).dialog({
28 autoOpen: false,
29 modal: true,
30 hide: 'fold',
31 width: '60em'
32 }).dialog('close');
33
34 $('#btnlegend').unbind('click').click(function(){
35 $('#legende' + index).dialog('open');
36 return false;
37 });
38 };
39
40 $(function(){
41 $('#tabs').tabs({
42 active: {$activetab-1},
43 load: function(event, ui) {
44 $('#tabs input:submit, #tabs .button, #tabs input:reset' ).button();
45 _handleLegend($(event.currentTarget).attr('href').replace('{path_for name="pdfModels"}/', ''));
46 },
47 {* Cannot include js_loader.tpl here because we need to use beforeSend specificaly... *}
48 beforeLoad: function(event, ui) {
49 _tab_name = ui.ajaxSettings.url.split('/');
50 _tab_name = _tab_name[_tab_name.length-1];
51
52 _handleLegend({$model->id});
53
54 if ( ui.ajaxSettings.url == '{path_for name="pdfModels" data=["id" => $model->id]}'
55 || ui.ajaxSettings.url == '{path_for name="pdfModels"}'
56 ) {
57 var _current = $('#ui-tabs-{$activetab}');
58 if (_current) {
59 $('#'+ui.panel[0].id).append(_current)
60 }
61 return false; //avoid reloading first tab onload
62 }
63
64 var _img = $('<figure id="loading"><p><img src="{base_url}/{$template_subdir}images/loading.png" alt="{_T string="Loading..."}"/><br/>{_T string="Currently loading..."}</p></figure>');
65 $('body').append(_img);
66
67 ui.jqXHR.always(function(){
68 $('#loading').remove();
69 });
70
71 ui.jqXHR.fail(function(){
72 alert('{_T string="An error occurred :(" escape="js"}');
73 });
74 }
75 });
76 });
77 </script>
78 {/block}