PluginProbe ʕ •ᴥ•ʔ
Code Manager / 1.0.9
Code Manager v1.0.9
1.0.47 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.2 1.0.20 1.0.21 1.0.22 1.0.23 1.0.24 1.0.25 1.0.26 1.0.27 1.0.28 1.0.3 1.0.30 1.0.31 1.0.32 1.0.33 1.0.34 1.0.35 1.0.36 1.0.37 1.0.38 1.0.39 1.0.4 1.0.40 1.0.41 1.0.42 1.0.43 1.0.44 1.0.45 1.0.46 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9
code-manager / assets / js / code_manager_listmode.js
code-manager / assets / js Last commit date
code_manager.js 4 years ago code_manager_dashboard.js 4 years ago code_manager_listmode.js 4 years ago code_manager_tabmode.js 4 years ago notify.min.js 4 years ago
code_manager_listmode.js
202 lines
1 /**
2 * JavaScript code to support code activation in list mode
3 *
4 * @author Peter Schulz
5 * @since 1.0.0
6 */
7
8 var href = window.location.href;
9 var pathname = href.substring(0, href.lastIndexOf('/')) + '/admin-ajax.php';
10
11 jQuery(function() {
12 jQuery('#doaction').click(function () {
13 return cm_action_button();
14 });
15
16 jQuery('#doaction2').click(function () {
17 return cm_action_button();
18 });
19
20 new ClipboardJS('.c2c');
21
22 jQuery(function(){
23 jQuery('.cm_menu_title').tooltip();
24 jQuery('.c2c').tooltip();
25 jQuery('.cm_tooltip').tooltip();
26 jQuery('#disable_preview').tooltip();
27 jQuery('#disable_preview').on('click', function() {
28 html = "<div>This turns of preview mode for all code IDs for all users. Do you want to continue?</div>";
29 var dialog = jQuery(html).dialog({
30 dialogClass: 'no-close',
31 title: 'Reset preview',
32 buttons: {
33 'Yes': function() {
34 dialog.dialog('destroy');
35 reset_preview();
36 },
37 'No': function() {
38 dialog.dialog('destroy');
39 },
40 'Cancel': function() {
41 dialog.dialog('destroy');
42 }
43 }
44 });
45 });
46 });
47
48 code_type_list = '<label for="selected_code_type" style="float:left;font-weight:bold;padding-top:6px;">Show&nbsp;</label>';
49 code_type_list += '<select id="selected_code_type" name="selected_code_type" onchange="jQuery(\'#cm_list_table\').submit()">';
50 code_type_list += '<option value="*">All</option>';
51 for (var code_group in code_manager_code_groups) {
52 code_type_list += '<optgroup label="' + code_group + '">';
53 code_manager_code_group = code_manager_code_groups[code_group];
54 for (var label in code_manager_code_group ) {
55 if (code_manager_selected_code_type===label) {
56 selected = ' selected';
57 } else {
58 selected = '';
59 }
60 code_type_list +=
61 '<option value="' + label + '"' + selected + '>' +
62 code_manager_code_group[label] +
63 '</option>';
64 }
65 code_type_list += '</optgroup>';
66 }
67 code_type_list += '</select>';
68 jQuery('#doaction').after('<span style="float:right">' + code_type_list + '</span>');
69 jQuery('#doaction').after(
70 '<span style="float:right">' +
71 '<a id="disable_preview" href="javascript:void(0)" class="material-icons cm_menu_title" style="text-decoration:none" title="Turn of preview mode for all code IDs">visibility_off</a>' +
72 '</span>'
73 );
74 });
75
76 function reset_preview() {
77 jQuery.ajax({
78 type: 'POST',
79 url: pathname + '?action=code_manager_reset_preview',
80 data: {
81 wpnonce: wpnonce,
82 page: 'code_manager_post'
83 }
84 }).done(
85 function (msg) {
86 if ( msg === 'OK' ) {
87 jQuery.notify(msg, 'success');
88
89 window.location.href = window.location.href;
90 } else {
91 jQuery.notify(msg, 'info');
92 }
93 }
94 ).fail(
95 function () {
96 jQuery.notify(msg, 'error');
97 }
98 );
99 }
100
101 function set_code_preview(id, wpnonce, checked) {
102 action = checked ? 'code_manager_activate_code_preview' : 'code_manager_deactivate_code_preview';
103 mode = checked ? 'on' : 'off';
104 jQuery.ajax({
105 type: 'POST',
106 url: pathname + '?action=' + action,
107 data: {
108 code_id: id,
109 wpnonce: wpnonce,
110 page: 'code_manager_post'
111 }
112 }).done(
113 function (msg) {
114 if ( msg === 'OK' ) {
115 jQuery.notify('Preview ' + mode, 'success');
116 } else {
117 jQuery.notify(msg, 'info');
118 }
119 }
120 ).fail(
121 function () {
122 jQuery.notify('The request could not be handled', 'error');
123 }
124 );
125 }
126
127 function activate_code(id, wpnonce) {
128 if (jQuery('#code_enabled_' + id).is('select')) {
129 // Listbox
130 code_item_value = jQuery('#code_enabled_' + id).val();
131 } else {
132 // Checkbox
133 code_item_value = jQuery('#code_enabled_' + id).is(':checked') ? '1' : '0';
134 }
135
136 jQuery.ajax({
137 type: 'POST',
138 url: pathname + '?action=code_manager_activate_code',
139 data: {
140 code_id: id,
141 code_item_value: code_item_value,
142 wpnonce: wpnonce,
143 page: 'code_manager_post'
144 }
145 }).done(
146 function (msg) {
147 if ( msg.substr(0, 3) === 'UPD' ) {
148 if (jQuery('#code_enabled_' + id).is(':checked')) {
149 jQuery.notify('Code enabled', 'success');
150 } else {
151 jQuery.notify('Code disabled', 'success');
152 }
153 } else {
154 jQuery.notify('Settings not saved', 'error');
155 }
156 }
157 ).fail(
158 function () {
159 jQuery.notify('The request could not be handled', 'error');
160 }
161 );
162 }
163
164 function cm_show_notice( value ) {
165 if ('bulk-delete'===value) {
166 html = "<div>You are about to permanently delete the selected code from your site. This action cannot be undone. 'No' to stop, 'Yes' to delete.</div>";
167 var dialog = jQuery(html).dialog({
168 dialogClass: 'no-close',
169 title: 'Delete code?',
170 modal: true,
171 buttons: {
172 'Yes': function() {
173 jQuery('#cm_list_table').submit();
174 dialog.dialog('destroy');
175 },
176 'No': function() {
177 dialog.dialog('destroy');
178 },
179 'Cancel': function() {
180 dialog.dialog('destroy');
181 }
182 }
183 });
184 event.preventDefault();
185 event.stopPropagation();
186 return false;
187 }
188 }
189
190 function cm_action_button() {
191 action1 = jQuery("#cm_list_table :input[name='action']").val();
192 if (action1!=='-1') {
193 return cm_show_notice(action1);
194 }
195 action2 = jQuery("#cm_list_table :input[name='action2']").val();
196 if (action2!=='-1') {
197 return cm_show_notice(action2);
198 }
199 jQuery.notify('No bulk action selected', 'info');
200 return false;
201 }
202