]> git.agnieray.net Git - galette.git/blob - galette/templates/default/elements/edit_socials.html.twig
2e89b097498b13e86d20fcc5e7cb35ac8bfe69ab
[galette.git] / galette / templates / default / elements / edit_socials.html.twig
1 {% if tabbed ?? false == true %}
2 <div id="social" class="ui{{ tab == 'social' ? ' active' }} tab segment" data-tab="social">
3 {% block social_edit %}
4 {% for social in socials %}
5 <div class="inline field stored">
6 <label for="social_{{ social.id }}">{{ social.getSystemType(social.type) }}</label>
7 <div class="ui right action input">
8 <input type="text" name="social_{{ social.id }}" id="social_{{ social.id }}" value="{{ social.url }}" class="large"/>
9 <a href="#" class="ui icon red button delete delsocial" title="{{ _T("Remove %type")|replace({"%type": social.getSystemType(social.type)})|e() }}">
10 <i class="trash icon"></i>
11 <span class="displaynone">{{ _T("Remove %type")|replace({"%type": social.getSystemType(social.type)})|e() }}</span>
12 </a>
13 </div>
14 </div>
15 {% endfor %}
16 {% if socials|length() > 0 %}<div class="ui divider"></div>{% endif %}
17 <div class="field addsocial">
18 <label>{{ _T("Add new social network") }}</label>
19 <div class="combo-social fields">
20 <div class="field">
21 <select name="social_new_type_1" id="social_new_type_1" class="socials_dropdown ui search dropdown nochosen">
22 <option value="">{{ _T("Choose or enter your own...") }}</option>
23 {% for social_type in osocials.getSystemTypes(false) %}
24 <option value="{{ social_type }}">{{ osocials.getSystemType(social_type) }}</option>
25 {% endfor %}
26 </select>
27 </div>
28 <div class="field">
29 <input type="text" name="social_new_value_1" id="social_new_value_1" value="" size="50"/>
30 </div>
31 </div>
32 <a href="#" class="ui tiny green labeled icon button action addsocial">
33 <i class="plus icon"></i>
34 {{ _T("Add") }}
35 </a>
36 </div>
37 <script type="text/javascript">
38 var _dropdown = function(selector) {
39 if ( !selector ) {
40 selector = '.socials_dropdown';
41 }
42
43 $(selector).dropdown({
44 allowAdditions: true
45 });
46 }
47
48 var _rmFilter = function(elt) {
49 if ( typeof elt == 'undefined') {
50 elt = $('#social .stored');
51 }
52 elt.find('.delsocial').click(function(e){
53 e.preventDefault();
54 var _this = $(this);
55 _this.parents('.field.stored').remove();
56 });
57 }
58
59 $(function(){
60 _rmFilter();
61 _dropdown();
62
63 $('.addsocial').click(function(e){
64 e.preventDefault();
65
66 var _newindex = $(this).parents('.addsocial').find('.combo-social:last select').attr('id').replace('social_new_type_', '');
67 ++_newindex;
68 $(this).parents('.addsocial').find ('.combo-social:last')
69 .clone() // copy
70 .insertAfter('#social .combo-social:last') // where
71 .find('select').attr('id', 'social_new_type_' + _newindex).attr('name', 'social_new_type_' + _newindex)
72 .parent().parent().parent().find('input').attr('id', 'social_new_value_' + _newindex).attr('name', 'social_new_value_' + _newindex)
73 ;
74
75 _dropdown();
76 });
77 });
78 </script>
79 {% endblock %}
80 </div>
81 {% else %}
82 <div id="social" class="ui styled fluid accordion field">
83 <div class="active title">
84 <i class="jsonly displaynone icon dropdown"></i>
85 {{ _T("Social networks") }}
86 </div>
87 <div class="active content field">
88 {{ block('social_edit') }}
89 </div>
90 </div>
91 {% endif %}