]> git.mxchange.org Git - friendica.git/blob - view/templates/settings/pagetypes.tpl
Merge pull request #13128 from annando/owa
[friendica.git] / view / templates / settings / pagetypes.tpl
1
2 <h4>{{$account_types}}</h4>
3 {{include file="field_radio.tpl" field=$account_person}}
4 <div id="account-type-sub-0" class="pageflags">
5         <h5>{{$user}}</h5>
6         {{include file="field_radio.tpl" field=$page_normal}}
7         {{include file="field_radio.tpl" field=$page_soapbox}}
8         {{include file="field_radio.tpl" field=$page_freelove}}
9 </div>
10
11 {{include file="field_radio.tpl" field=$account_organisation}}
12 {{include file="field_radio.tpl" field=$account_news}}
13
14 {{include file="field_radio.tpl" field=$account_community}}
15 <div id="account-type-sub-3" class="pageflags">
16         <h5>{{$community}}</h5>
17         {{include file="field_radio.tpl" field=$page_community}}
18         {{include file="field_radio.tpl" field=$page_prvgroup}}
19 </div>
20
21 <script language="javascript" type="text/javascript">
22         // This js part changes the state of page-flags radio buttons according
23         // to the selected account type.
24         var accountType = {{$account_type}};
25
26         $(document).ready(function(){
27                 // Hide all DIV for page-flags except the one which belongs to the present
28                 // account-type
29                 showPageFlags(accountType);
30
31                 // Save the ID of the active page-flags
32                 var activeFlag = $('[id^=id_page-flags_]:checked');
33
34                 $("[id^=id_account-type_]").change(function(){
35                         // Since the ID of the radio buttons containing the type of
36                         // the account-type we catch the last character of the ID to
37                         // know for what account-type the radio button stands for.
38                         var type = this.id.substr(this.id.length - 1);
39
40                         // Hide all DIV with page-flags and show only the one which belongs
41                         // to the selected radio button
42                         showPageFlags(type);
43
44                         // Uncheck all page-flags radio buttons
45                         $('input:radio[name="page-flags"]').prop("checked", false);
46
47                         // If the selected account type is the active one mark the page-flag
48                         // radio button as checked which is already by database state
49                         if (accountType == type) {
50                                 $(activeFlag).prop("checked", true);
51                         } else if (type == 1 || type == 2) {
52                                 // For account-type 1 or 2 the page-flags are always set to 1
53                                 $('#id_page-flags_1').prop("checked", true);
54                         } else {
55                                 // Mark the first available page-flags radio button of the selected
56                                 // account-type as checked
57                                 $('#account-type-sub-' + type + ' input:radio[name="page-flags"]').first().prop("checked", true);
58                         }
59                 });
60         });
61
62         // Show/Hide the page-flags according to the selected account-type
63         function showPageFlags(type) {
64                 $(".pageflags").hide();
65
66                 if (type == 0 || type == 3) {
67                         $("#account-type-sub-" + type).show();
68                 }
69         }
70 </script>