PluginProbe
Booking Manager – Sync WP Booking Calendar – Import Events, Export Bookings to ICS Calendar / trunk
Booking Manager – Sync WP Booking Calendar – Import Events, Export Bookings to ICS Calendar vtrunk
2.1.20 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 trunk 1.1 2.0 2.0.1 2.0.10.2 2.0.11 2.0.12 2.0.13 2.0.14 2.0.15 2.0.16 2.0.17 2.0.18 2.0.2 2.0.20 2.0.21 2.0.22 2.0.23 All 54 releases
booking-manager / js / admin.js

admin.js in Booking Manager – Sync WP Booking Calendar – Import Events, Export Bookings to ICS Calendar trunk, at js/admin.js

320 lines 10.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * @version 1.0
3 * @package Booking Manager
4 * @subpackage BackEnd Main Script Lib
5 * @category Scripts
6 *
7 * @author wpdevelop
8 * @link https://oplugins.com/
9 * @email info@oplugins.com
10 *
11 * @modified 2014.09.10
12 */
13
14
15 /** Set item listing row as R e a d
16 *
17 * @param {type} wpbm_id
18 * @returns {undefined}
19 */
20 function set_wpbm_row_read(wpbm_id){
21 if (wpbm_id == 0) {
22 jQuery('.new-label').addClass('hidden_items');
23 jQuery('.bk-update-count').html( '0' );
24 } else {
25 jQuery('#wpbm_mark_'+wpbm_id + '').addClass('hidden_items');
26 decrese_new_counter();
27 }
28 }
29
30 /** Set item listing row as U n R e a d
31 *
32 * @param {type} wpbm_id
33 * @returns {undefined}
34 */
35 function set_wpbm_row_unread(wpbm_id){
36 jQuery('#wpbm_mark_'+wpbm_id + '').removeClass('hidden_items');
37 increase_new_counter();
38 }
39
40
41 /** Increase counter about new items
42 *
43 * @returns {undefined}
44 */
45 function increase_new_counter () {
46 var my_num = parseInt(jQuery('.bk-update-count').html());
47 my_num = my_num + 1;
48 jQuery('.bk-update-count').html(my_num);
49 }
50
51 /** Decrease counter about new items
52 *
53 * @returns {undefined}
54 */
55 function decrese_new_counter () {
56 var my_num = parseInt(jQuery('.bk-update-count').html());
57 if (my_num>0){
58 my_num = my_num - 1;
59 jQuery('.bk-update-count').html(my_num);
60 }
61 }
62
63
64 // Set item listing R O W Approved
65 function set_wpbm_row_approved(wpbm_id){
66 jQuery('#wpbm_row_'+wpbm_id + ' .wpbm-labels .label-approved').removeClass('hidden_items');
67 jQuery('#wpbm_row_'+wpbm_id + ' .wpbm-labels .label-pending').addClass('hidden_items');
68
69 jQuery('#wpbm_row_'+wpbm_id + ' .wpbm-dates .field-wpbm-date').addClass('approved');
70
71 jQuery('#wpbm_row_'+wpbm_id + ' .wpbm-actions .approve_wpbm_link').addClass('hidden_items');
72 jQuery('#wpbm_row_'+wpbm_id + ' .wpbm-actions .pending_wpbm_link').removeClass('hidden_items');
73
74 }
75
76 // Set item listing R O W Pending
77 function set_wpbm_row_pending(wpbm_id){
78 jQuery('#wpbm_row_'+wpbm_id + ' .wpbm-labels .label-approved').addClass('hidden_items');
79 jQuery('#wpbm_row_'+wpbm_id + ' .wpbm-labels .label-pending').removeClass('hidden_items');
80
81 jQuery('#wpbm_row_'+wpbm_id + ' .wpbm-dates .field-wpbm-date').removeClass('approved');
82
83 jQuery('#wpbm_row_'+wpbm_id + ' .wpbm-actions .approve_wpbm_link').removeClass('hidden_items');
84 jQuery('#wpbm_row_'+wpbm_id + ' .wpbm-actions .pending_wpbm_link').addClass('hidden_items');
85
86 }
87
88 // Remove item listing R O W
89 function set_wpbm_row_deleted(wpbm_id){
90 jQuery('#wpbm_row_'+wpbm_id).fadeOut(1000);
91 jQuery('#gcal_imported_events_id_'+wpbm_id).remove();
92 }
93
94 // Set in item listing R O W Resource title
95 function set_wpbm_row_resource_name(wpbm_id, resourcename){
96 jQuery('#wpbm_row_'+wpbm_id + ' .wpbm-labels .label-resource').html(resourcename);
97 }
98
99 // Set in item listing R O W new Remark in hint
100 function set_wpbm_row_remark_in_hint( wpbm_id, new_remark ){
101
102 jQuery('#wpbm_row_' + wpbm_id + ' .wpbm-actions .remark_wpbm_link').attr( 'data-original-title', new_remark );
103
104 if ( new_remark != '' )
105 jQuery('#wpbm_row_' + wpbm_id + ' .wpbm-actions .remark_wpbm_link i.glyphicon-comment').addClass('red_icon_color');
106 else
107 jQuery('#wpbm_row_' + wpbm_id + ' .wpbm-actions .remark_wpbm_link i.glyphicon-comment').removeClass('red_icon_color');
108 }
109
110 // Set in item listing R O W new Remark in hint
111 function set_wpbm_row_payment_status(wpbm_id, payment_status, payment_status_show){
112
113 jQuery('#wpbm_row_'+wpbm_id + ' .wpbm-labels .label-payment-status').removeClass('label-danger');
114 jQuery('#wpbm_row_'+wpbm_id + ' .wpbm-labels .label-payment-status').removeClass('label-success');
115
116 jQuery('#wpbm_row_'+wpbm_id + ' .wpbm-labels .label-payment-status').html(payment_status_show);
117
118 if (payment_status == 'OK') {
119 jQuery('#wpbm_row_'+wpbm_id + ' .wpbm-labels .label-payment-status').addClass('label-success');
120 } else if (payment_status == '') {
121 jQuery('#wpbm_row_'+wpbm_id + ' .wpbm-labels .label-payment-status').addClass('label-danger');
122 } else {
123 jQuery('#wpbm_row_'+wpbm_id + ' .wpbm-labels .label-payment-status').addClass('label-danger');
124 }
125 }
126
127
128
129 // Interface Element
130 function showSelectedInDropdown(selector_id, title, value){
131 jQuery('#' + selector_id + '_selector .wpbm_selected_in_dropdown').html( title );
132 jQuery('#' + selector_id ).val( value );
133 jQuery('#' + selector_id + '_container').hide();
134 }
135
136 //Admin function s for checking all checkbos in one time
137 function setCheckBoxInTable(el_stutus, el_class){
138 jQuery('.'+el_class).attr('checked', el_stutus);
139
140 if ( el_stutus ) {
141 jQuery('.'+el_class).parent().parent().addClass('row_selected_color');
142 } else {
143 jQuery('.'+el_class).parent().parent().removeClass('row_selected_color');
144 }
145 }
146
147
148 // FixIn: 5.4.5
149 function wpbm_get_selected_locale( wpbm_id, wpbm_active_locale ) {
150
151 var id_to_check = "" + wpbm_id;
152 if ( id_to_check.indexOf('|') == -1 ) {
153 var selected_locale = jQuery('#locale_for_item' + wpbm_id).val();
154
155 if ( ( selected_locale != '' ) && ( typeof(selected_locale) !== 'undefined' ) ) {
156 wpbm_active_locale = selected_locale;
157 }
158 }
159 return wpbm_active_locale;
160 }
161
162
163
164
165 //FixIn: 6.1.1.10
166 // Set item listing R O W Trash
167 function set_wpbm_row_trash( wpbm_id ){
168 jQuery('#wpbm_row_'+wpbm_id + ' .wpbm-labels .label-trash').removeClass('hidden_items');
169 jQuery('#wpbm_row_'+wpbm_id + ' .wpbm-actions .trash_wpbm_link').addClass('hidden_items');
170 jQuery('#wpbm_row_'+wpbm_id + ' .wpbm-actions .restore_wpbm_link').removeClass('hidden_items');
171 jQuery('#wpbm_row_'+wpbm_id + ' .wpbm-actions .delete_wpbm_link').removeClass('hidden_items');
172
173
174 jQuery('#wpbm-id-'+wpbm_id + ' .label-trash').removeClass('hidden_items');
175 }
176
177 //FixIn: 6.1.1.10
178 // Set item listing R O W Restore
179 function set_wpbm_row_restore( wpbm_id ){
180 jQuery('#wpbm_row_'+wpbm_id + ' .wpbm-labels .label-trash').addClass('hidden_items');
181 jQuery('#wpbm_row_'+wpbm_id + ' .wpbm-actions .trash_wpbm_link').removeClass('hidden_items');
182 jQuery('#wpbm_row_'+wpbm_id + ' .wpbm-actions .restore_wpbm_link').addClass('hidden_items');
183 jQuery('#wpbm_row_'+wpbm_id + ' .wpbm-actions .delete_wpbm_link').addClass('hidden_items');
184
185 jQuery('#wpbm-id-'+wpbm_id + ' .label-trash').addClass('hidden_items');
186 }
187
188
189
190 // Get Selected rows in imported Events list
191 function get_selected_items_id_in_this_list( list_tag, skip_id_length ) {
192
193 var checkedd = jQuery( list_tag + ":checked" );
194 var id_for_approve = "";
195
196 // get all IDs
197 checkedd.each(function(){
198 var id_c = jQuery(this).attr('id');
199 id_c = id_c.substr(skip_id_length,id_c.length-skip_id_length);
200 id_for_approve += id_c + "|";
201 });
202
203 if ( id_for_approve.length > 1 )
204 id_for_approve = id_for_approve.substr(0,id_for_approve.length-1); //delete last "|"
205
206 return id_for_approve ;
207
208 }
209
210 // Get the list of ID in selected items from item listing
211 function get_selected_items_id_in_wpbm_listing(){
212
213 var checkedd = jQuery(".wpbm_list_item_checkbox:checked");
214 var id_for_approve = "";
215
216 // get all IDs
217 checkedd.each(function(){
218 var id_c = jQuery(this).attr('id');
219 id_c = id_c.substr(20,id_c.length-20);
220 id_for_approve += id_c + "|";
221 });
222
223 if ( id_for_approve.length > 1 )
224 id_for_approve = id_for_approve.substr(0,id_for_approve.length-1); //delete last "|"
225
226 return id_for_approve ;
227 }
228
229
230
231
232
233 /** Selections of several checkboxes like in gMail with shift :)
234 * Need to have this structure:
235 * .wpbm_selectable_table
236 * .wpbm_selectable_head
237 * .check-column
238 * :checkbox
239 * .wpbm_selectable_body
240 * .wpbm_row
241 * .check-column
242 * :checkbox
243 * .wpbm_selectable_foot
244 * .check-column
245 * :checkbox
246 */
247 ( function( $ ){
248 $( document ).ready(function(){
249
250 var checks, first, last, checked, sliced, lastClicked = false;
251
252 // check all checkboxes
253 $('.wpbm_selectable_body').find('.check-column').find(':checkbox').on( 'click', function(e) { //FixIn: 2.0.18.4
254 if ( 'undefined' == e.shiftKey ) { return true; }
255 if ( e.shiftKey ) {
256 if ( !lastClicked ) { return true; }
257 //checks = $( lastClicked ).closest( 'form' ).find( ':checkbox' ).filter( ':visible:enabled' );
258 checks = $( lastClicked ).closest( '.wpbm_selectable_body' ).find( ':checkbox' ).filter( ':visible:enabled' );
259 first = checks.index( lastClicked );
260 last = checks.index( this );
261 checked = $(this).prop('checked');
262 if ( 0 < first && 0 < last && first != last ) {
263 sliced = ( last > first ) ? checks.slice( first, last ) : checks.slice( last, first );
264 sliced.prop( 'checked', function() {
265 if ( $(this).closest('.wpbm_row').is(':visible') )
266 return checked;
267
268 return false;
269 });
270 }
271 }
272 lastClicked = this;
273
274 // toggle "check all" checkboxes
275 var unchecked = $(this).closest('.wpbm_selectable_body').find(':checkbox').filter(':visible:enabled').not(':checked');
276 $(this).closest('.wpbm_selectable_table').children('.wpbm_selectable_head, .wpbm_selectable_foot').find(':checkbox').prop('checked', function() {
277 return ( 0 === unchecked.length );
278 });
279
280 return true;
281 });
282
283 $('.wpbm_selectable_head, .wpbm_selectable_foot').find('.check-column :checkbox').on( 'click.wp-toggle-checkboxes', function( event ) {
284 var $this = $(this),
285 $table = $this.closest( '.wpbm_selectable_table' ),
286 controlChecked = $this.prop('checked'),
287 toggle = event.shiftKey || $this.data('wp-toggle');
288
289 $table.children( '.wpbm_selectable_body' ).filter(':visible')
290 .find('.check-column').find(':checkbox')
291 //.children().children('.check-column').find(':checkbox')
292 .prop('checked', function() {
293 if ( $(this).is(':hidden,:disabled') ) {
294 return false;
295 }
296
297 if ( toggle ) {
298 return ! $(this).prop( 'checked' );
299 } else if ( controlChecked ) {
300 return true;
301 }
302
303 return false;
304 });
305
306 $table.children('.wpbm_selectable_head, .wpbm_selectable_foot').filter(':visible')
307 .find('.check-column').find(':checkbox')
308 //.children().children('.check-column').find(':checkbox')
309 .prop('checked', function() {
310 if ( toggle ) {
311 return false;
312 } else if ( controlChecked ) {
313 return true;
314 }
315
316 return false;
317 });
318 });
319 });
320 }( jQuery ) );