PluginProbe
Webling / trunk
Webling vtrunk
trunk 2.0 3.0 3.0.1 3.0.2 3.0.3 3.1.0 3.1.1 3.1.2 3.2.0 3.2.1 3.3.0 3.4.0 3.4.1 3.5.0 3.6.0 3.7.0 3.7.1 3.7.2 3.7.3 3.8.0 3.9.0 3.9.1 3.9.2
webling / js / admin.js

admin.js in Webling trunk, at js/admin.js

163 lines 4.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1
2 /**
3 * Add/remove the selected class after selecting
4 * and update the hidden config field
5 */
6 function webling_update_sorted_member_fields() {
7 var fieldConfig = [];
8 // find and update selected fields
9 jQuery("#sortable > li").each(function (index, element) {
10 if (jQuery(element).children('input').is(':checked')) {
11 fieldConfig.push(jQuery(element).data('field'));
12 jQuery(element).addClass('selected');
13 } else {
14 jQuery(element).removeClass('selected');
15 }
16 });
17 // update hidden config field
18 jQuery("#fields").val(JSON.stringify(fieldConfig));
19 }
20
21 /**
22 * Show/hide the group selector or savedsearch selector in the memberlist editor
23 */
24 function webling_memberlist_type_changed() {
25 var type = jQuery("#memberlist_type").val();
26
27 // hide all selectors
28 jQuery("#groupselector").hide();
29 jQuery("#savedsearchselector").hide();
30
31 // show correct selector
32 if (type === 'GROUPS') {
33 jQuery("#groupselector").show();
34 }
35 if (type === 'SAVEDSEARCH') {
36 jQuery("#savedsearchselector").show();
37 }
38 }
39
40
41 /**
42 * Change the design view after changing the radio input
43 */
44 function webling_memberlist_design_updated() {
45 var design = jQuery('input[name="design"]:checked').val();
46 if (design === 'CUSTOM') {
47 jQuery("#webling_design_custom").show();
48 jQuery("#webling_design_list").hide();
49 } else {
50 jQuery("#webling_design_custom").hide();
51 jQuery("#webling_design_list").show();
52 }
53 }
54
55 /**
56 * Show/hide the confirmation email settings form editor settings
57 */
58 function webling_toggle_confirmation_settings() {
59 if (jQuery("#confirmation_email_enabled").is(':checked')) {
60 jQuery("#webling_form_emails .webling_confirmation_settings").show();
61 } else {
62 jQuery("#webling_form_emails .webling_confirmation_settings").hide();
63 }
64 }
65
66 /**
67 * Activate a form editor tab and toggle contents
68 * @param tabname
69 */
70 function webling_change_form_tab(tabname) {
71 jQuery(".webling-tabs a").removeClass('nav-tab-active');
72 jQuery(".webling-tabs #webling_form_tab_" + tabname).addClass('nav-tab-active');
73 jQuery(".webling-tabs-body > div").hide();
74 jQuery(".webling-tabs-body #webling_form_" + tabname).show();
75
76 if (tabname == 'fields') {
77 jQuery("#webling_fields_div").show();
78 } else {
79 jQuery("#webling_fields_div").hide();
80 }
81 }
82
83 /**
84 * Open and close detailed form field config
85 * @param id string the id of the field
86 */
87 function webling_toggle_field(id) {
88 var node = jQuery('#webling-field-' + id);
89 var is_in_sidebar = jQuery(node).parent().attr('id') == 'sortable_side';
90 if (node.hasClass('open') || is_in_sidebar) {
91 node.removeClass('open');
92 jQuery('#webling-field-' + id + ' .widget-inside').hide();
93 } else {
94 node.addClass('open');
95 jQuery('#webling-field-' + id + ' .widget-inside').show();
96 }
97 return false;
98 }
99
100 /**
101 * updates the hidden order field
102 */
103 function webling_update_sorted_form_fields() {
104
105 // set order of active fields
106 var order = 1;
107 jQuery("#sortable_main > li input.order").each(function (index, element) {
108 jQuery(element).val(order);
109 order++;
110 });
111
112 // set order of items in sidebar to 0 (= not shown)
113 jQuery("#sortable_side > li input.order").each(function (index, element) {
114 jQuery(element).val(0);
115 });
116
117 webling_update_email_field_selector();
118 }
119
120 /**
121 * updates the field selector to only show available fields.
122 * The selected value is stored in `preselected_confirmation_email_webling_field`
123 * because the options are completly redrawn and the selected state is lost
124 */
125 function webling_update_email_field_selector() {
126 var select = jQuery("#confirmation_email_webling_field");
127 select.html('');
128 var count = 0;
129 jQuery("#sortable_main > li[data-webling-type='email']").each(function (index, element) {
130 var id = jQuery(element).find('input.fieldid').val();
131 select.append(jQuery('<option>', {
132 value: id,
133 text: jQuery(element).find('input.fieldname').val(),
134 selected: (preselected_confirmation_email_webling_field == id ? true : false)
135 }));
136 count++;
137 });
138
139 if (count === 0) {
140 select.append(jQuery('<option>', {
141 value: 0,
142 text: ' '
143 }));
144 jQuery("#confirmation_email_webling_field_error").show();
145 } else {
146 jQuery("#confirmation_email_webling_field_error").hide();
147 }
148 }
149
150 /**
151 * moves a field from the selected list to the sidebar
152 * @param id Webling field Id
153 * @returns {boolean}
154 */
155 function webling_remove_field(id) {
156 var node = jQuery('#webling-field-' + id).detach();
157 jQuery('#sortable_side').prepend(node);
158 jQuery("#sortable_side").sortable("refresh");
159 jQuery("#sortable_main").sortable("refresh");
160 webling_update_sorted_form_fields();
161 return false;
162 }
163