PageSourceSearch

https://www.boisblanctownship.org/wp-content/plugins/claritycloud-calendar/assets/js/global.js?ver=3.2.12

js boisblanctownship.org collected 2026-10-02 19:26:53 UTC 16,056 bytes, 401 lines download raw bytes

1// Set datepicker default value.
2var datepicker_format = 'yy-mm-dd';
3
4jQuery(document).ready(function($)
5{
6    
7    if ( typeof ccec_admin_localize !== 'undefined' ) {
8        var date_splite = ccec_admin_localize.datepicker_format.split( '&' );
9        
10        if ( date_splite[0] !== undefined && date_splite.length == 2 ) {
11            datepicker_format = date_splite[0];
12        }
13    } else if ( typeof ccecdata !== 'undefined' ) {
14        var date_splite = ccecdata.datepicker_format.split( '&' );
15        
16        if ( date_splite[0] !== undefined && date_splite.length == 2 ) {
17            datepicker_format = date_splite[0];
18        }
19    }
20
21    $("#ccec_date_repeat_end_at_occurrences").bind('keyup mouseup', function () {
22        jQuery('.validation_status').val('success');
23        $('.validity').removeClass('no_publish');
24        var invalid_txt = $('.invalid_txt').html();
25        if($(this).val() != ''){
26            if($(this).val() > 52 || invalid_txt != ''){
27                jQuery('.validation_status').val('error');
28                $('.validity').addClass('no_publish');
29            }
30        }           
31    });
32
33    if ($.fn.datepicker) {
34        var year_number = $('#ccec_date_repeat_end_at_date').data('sdate');
35        $('#ccec_start_date').datepicker(
36        {
37            changeYear: true,
38            changeMonth: true,
39            dateFormat: datepicker_format,
40            gotoCurrent: true,
41            yearRange: 'c-3:c+5',
42            onSelect: function (date) {
43                var date = $(this).datepicker('getDate'),
44                day  = date.getDate(),  
45                month = date.getMonth() + 1,              
46                year =  parseInt(date.getFullYear());
47                var end_date_ctrl = $('#ccec_date_repeat_end_at_date');
48                end_date_ctrl.attr('data-sdate',year+'-'+month+'-'+day);
49                end_date_ctrl.attr('data-syear',year-2);
50                end_date_ctrl.attr('data-eyear',year+2);
51                $('#ccec_date_repeat_end_at_date').datepicker('option', 'yearRange', (year-2) + ':' + (year + 2));
52                var dateMin = $('#ccec_date_repeat_end_at_date').datepicker("getDate");
53                var selectedDatetime = new Date(dateMin).getTime() / 1000;
54                var startdatetime = new Date(date).getTime() / 1000;
55                $('.invalid_txt').text('');
56                jQuery('.validation_status').val('success');
57                if((selectedDatetime < startdatetime) && ($('#ccec_repeat_ends_date').is(':checked'))){
58                    jQuery('.invalid_txt').show();
59                    jQuery('.invalid_txt').html('<div class="notice_txt"><p>The "Stops Repeating" date must be a date in the future, relative to the Date of the event.</p><button type="button" class="notice-dismiss dismiss_button"><span class="screen-reader-text">Dismiss this notice.</span></button></div>');
60                    jQuery('.error_message_content').html('<p>The "Stops Repeating" date must be a date in the future, relative to the Date of the event.</p>');
61                }
62                if((selectedDatetime < startdatetime || $(".validity").hasClass("no_publish")) && ($("#ccec_repeat").is(':checked')) && ($('#ccec_repeat_ends_date').is(':checked'))){
63                    jQuery('.validation_status').val('error');
64                }
65            }
66        });
67        
68        $('#ccec_end_date').datepicker(
69        {
70            changeYear: true,
71            changeMonth: true,
72            dateFormat: datepicker_format,
73            gotoCurrent: true,
74            yearRange: 'c-3:c+5',
75        });
76        
77        let syear = $('#ccec_date_repeat_end_at_date').data('syear');
78        let eyear = $('#ccec_date_repeat_end_at_date').data('eyear');
79        $('#ccec_date_repeat_end_at_date').datepicker(
80        {
81            changeYear: true,
82            changeMonth: true,
83            dateFormat: datepicker_format,
84            defaultDate: new Date(year_number),
85            yearRange: syear+':'+eyear,
86            onSelect: function (date) {
87                $('.invalid_txt').text('');
88                jQuery('.validation_status').val('success');
89                var dateMin = $(this).datepicker("getDate");
90                var selectedDatetime = new Date(dateMin).getTime() / 1000;
91                var enddatetime = $('#ccec_start_date').datepicker('getDate');
92                var startdatetime = new Date(enddatetime).getTime() / 1000;
93                enddatetime.setDate(enddatetime.getDate() + 730); 
94                var edatetime = new Date(enddatetime).getTime() / 1000;
95                if(selectedDatetime > edatetime){
96                    jQuery('.invalid_txt').show();
97                    jQuery('.invalid_txt').html('<div class="notice_txt"><p>Select a date no more than 2 years in the future.</p><button type="button" class="notice-dismiss dismiss_button"><span class="screen-reader-text">Dismiss this notice.</span></button></div>');
98                    jQuery('.error_message_content').html('<p>Select a date no more than 2 years in the future.</p>');
99                }
100                if(selectedDatetime < startdatetime){
101                    jQuery('.invalid_txt').show();
102                    jQuery('.invalid_txt').html('<div class="notice_txt"><p>The "Stops Repeating" date must be a date in the future, relative to the Date of the event.</p><button type="button" class="notice-dismiss dismiss_button"><span class="screen-reader-text">Dismiss this notice.</span></button></div>');
103                    jQuery('.error_message_content').html('<p>The "Stops Repeating" date must be a date in the future, relative to the Date of the event.</p>');
104                }
105                if(selectedDatetime > edatetime || selectedDatetime < startdatetime || $(".validity").hasClass("no_publish")){
106                    jQuery('.validation_status').val('error');
107                }
108            }
109        });
110
111        $('.ccec_date_picker').datepicker(
112        {
113            changeYear: true,
114            changeMonth: true,
115            dateFormat: 'yy-mm-dd',
116            gotoCurrent: true,
117            yearRange: 'c-3:c+5',
118        });
119    }
120    
121    $('#ccec_location_id').on('change', function()
122    {
123        ccec_location_toggle();
124    });
125    
126    $('#ccec_repeat').on('change', function()
127    {
128        ccec_repeat_toggle();
129        if( (!$(this).is(':checked'))){
130            jQuery('.validation_status').val('success');
131        }
132    });
133
134    $('.stop_reapt_btn').on('click', function()
135    {
136        ccec_on_date_toggle();
137    });
138    
139    $('#ccec_repeat_type').on('change', function()
140    {
141        ccec_repeat_type_toggle();
142    });
143    
144    $('#ccec_add_in_days').on('click', function()
145    {
146        var start = $('#ccec_exceptions_in_days_start_date').val();
147        if(start === '') return false;
148
149        var end = $('#ccec_exceptions_in_days_end_date').val();
150        if(end === '') return false;
151
152        var start_hour = $('#ccec_exceptions_in_days_start_hour').val();
153        if(start_hour.length === 1) start_hour = '0'+start_hour;
154
155        var start_minutes = $('#ccec_exceptions_in_days_start_minutes').val();
156        if(start_minutes.length === 1) start_minutes = '0'+start_minutes;
157
158        var start_ampm = $('#ccec_exceptions_in_days_start_ampm').val();
159        if(typeof start_ampm === 'undefined') start_ampm = '';
160
161        var end_hour = $('#ccec_exceptions_in_days_end_hour').val();
162        if(end_hour.length === 1) end_hour = '0'+end_hour;
163
164        var end_minutes = $('#ccec_exceptions_in_days_end_minutes').val();
165        if(end_minutes.length === 1) end_minutes = '0'+end_minutes;
166
167        var end_ampm = $('#ccec_exceptions_in_days_end_ampm').val();
168        if(typeof end_ampm === 'undefined') end_ampm = '';
169
170        var value = start + ':' + end + ':' + start_hour + '-' + start_minutes + '-' + start_ampm + ':' + end_hour + '-' + end_minutes + '-' + end_ampm;
171        var label = start + ' ' + start_hour + ':' + start_minutes + ' ' + start_ampm + ' - ' + end + ' ' + end_hour + ':' + end_minutes + ' ' + end_ampm;
172
173        if($('#ccec_in_days input[value="'+value+'"]').length > 0) return false;
174
175        var $key = $('#ccec_new_in_days_key');
176        
177        var key = $key.val();
178        var html = $('#ccec_new_in_days_raw').html().replace(/:i:/g, key).replace(/:val:
178/g, value).replace(/:label:/g, label);
179        
180        $('#ccec_in_days').append(html);
181        $key.val(parseInt(key)+1);
182    });
183
184    $('#ccec_add_cancel_in_days').on('click', function()
185    {
186        let date = $('#ccec_cancel_not_in_days_date').val();
187        let note = $('#ccec_cancel_not_in_days_date_note').val();
188        if(date === '') return false;
189        let key = $('#ccec_new_cancel_in_days_key').val();
190        let html = $('#ccec_new_cancel_in_days_raw').html().replace(/:i:/g, key).replace(/:val:/g, date).replace(/:note:/g, note);
191
192        
193        $('#ccec_cancel_in_days').append(html);
194        $('#ccec_new_cancel_in_days_key').val(parseInt(key)+1);
195    });
196    
197    $('#ccec_add_not_in_days').on('click', function()
198    {
199        var date = $('#ccec_exceptions_not_in_days_date').val();
200        if(date === '') return false;
201        
202        var key = $('#ccec_new_not_in_days_key').val();
203        var html = $('#ccec_new_not_in_days_raw').html().replace(/:i:/g, key).replace(/:val:/g, date);
204        
205        $('#ccec_not_in_days').append(html);
206        $('#ccec_new_not_in_days_key').val(parseInt(key)+1);
207    });
208
209    $('#ccec-advanced-wraper ul > ul > li').click(function()
210    {
211        if($(this).attr('class') == '') $(this).attr('class', 'ccec-active');
212        else $(this).attr('class', '');
213        $('#ccec_date_repeat_advanced').val($('#ccec-advanced-wraper div:first-child > ul').find('.ccec-active').find('span').text().slice(0, -1));
214    });
215
216    // Dismiss Notice
217    jQuery(document).on('click','.dismiss_button',function(){
218        jQuery('.notice_txt').hide(600);
219    });
220
221    jQuery(document).on('click','#publish', function(){
222
223        var status = $('.validation_status').val();
224        if(status != 'success'){
225            popup_validation(status);
226            return false;
227        } 
228
229    });
230
231    jQuery('#ccec_organizer_id').on('change', function()
232    {
233        ccec_organizer_toggle();
234        var ccec_organizer_val = parseInt($(this).val());
235        var ccec_additional_organizer = $(this).parent().parent().find('#ccec-additional-organizer-wrap');
236
237        if(ccec_organizer_val != 1) ccec_additional_organizer.show();
238        else ccec_additional_organizer.hide();
239    });
240
241    $('.ccec_date_picker_dynamic_format').datepicker(
242        {
243            changeYear: true,
244            changeMonth: true,
245            dateFormat: datepicker_format,
246            gotoCurrent: true,
247            yearRange: 'c-3:c+5',
248        });
249
250    ccec_repeat_toggle();
251    ccec_on_date_toggle();
252    ccec_location_toggle();
253    ccec_organizer_toggle();
254    ccec_repeat_type_toggle();
255
256});
257
258let ccec_location_toggle = function ()
259{
260    if(jQuery('#ccec_location_id').val() != '0') jQuery('#ccec_location_new_container').hide();
261    else jQuery('#ccec_location_new_container').show();
262}
263
264let ccec_repeat_toggle = function ()
265{
266    if(jQuery('#ccec_repeat').is(':checked')){
267        jQuery('.ccec-form-repeating-event-row').show();
268        jQuery("a[data-href='ccec-exceptional-days']").css('display','block');
269        jQuery("a[data-href='ccec-cancel-days']").css('display','block');
270    }else{
271        jQuery('.ccec-form-repeating-event-row').hide();
272        jQuery("a[data-href='ccec-exceptional-days']").css('display','none');
273        jQuery("a[data-href='ccec-cancel-days']").css('display','none');
274
275    }
276}
277
278let ccec_on_date_toggle = function ()
279{
280    if(jQuery('#ccec_repeat_ends_date').prop("checked")){
281        jQuery('#ccec_date_repeat_end_at_date').show();
282
283        var dateMin = jQuery('#ccec_date_repeat_end_at_date').datepicker("getDate");
284        var selectedDatetime = new Date(dateMin).getTime() / 1000;
285
286        var enddatetime = jQuery('#ccec_start_date').datepicker('getDate');
287        var startdatetime = new Date(enddatetime).getTime() / 1000;
288
289        if(selectedDatetime < startdatetime){
290            jQuery('.invalid_txt').show();
291            jQuery('.invalid_txt').html('<div class="notice_txt"><p>The "Stops Repeating" date must be a date in the future, relative to the Date of the event.</p><button type="button" class="notice-dismiss dismiss_button"><span class="screen-reader-text">Dismiss this notice.</span></button></div>');
292            jQuery('.error_message_content').html('<p>The "Stops Repeating" date must be a date in the future, relative to the Date of the event.</p>');
293        }
294        if(selectedDatetime < startdatetime || jQuery(".validity").hasClass("no_publish")){
295            // jQuery('#publish').prop( "disabled", true );
296            // Popup Validation
297            // popup_validation(false);
298            jQuery('.validation_status').val('error');
299        }
300
301
302    }else{
303        jQuery('#ccec_date_repeat_end_at_date').hide();
304        jQuery('.invalid_txt').hide();
305        // jQuery('#publish').prop( "disabled", false );
306        jQuery('.validation_status').val('success');
307
308    }
309}
310
311let popup_validation = function ()
312{
313    
314    // Get the modal
315    var modal = document.getElementById("myModal");
316
317    // Get the <span> element that closes the modal
318    var span = document.getElementsByClassName("close")[0];
319
320    modal.style.display = "block";
321
322    // When the user clicks on <span> (x), close the modal
323    span.onclick = function() {
324        modal.style.display = "none";
325    }
326
327    // When the user clicks anywhere outside of the modal, close it
328    window.onclick = function(event) {
329        if (event.target == modal) {
330            modal.style.display = "none";
331        }
332    }
333
334}
335
336let ccec_repeat_type_toggle = function ()
337{
338    var repeat_type = jQuery('#ccec_repeat_type').val();
339    
340    if(repeat_type == 'certain_weekdays')
341    {
342        jQuery('#ccec_repeat_interval_container').hide();
343        jQuery('#ccec_repeat_certain_weekdays_container').show();
344        jQuery('#ccec_exceptions_in_days_container').hide();
345        jQuery('#ccec_end_wrapper').show();
346        jQuery('#ccec-advanced-wraper').hide();
347    }
348    else if(repeat_type == 'custom_days')
349    {
350        jQuery('#ccec_repeat_interval_container').hide();
351        jQuery('#ccec_repeat_certain_weekdays_container').hide();
352        jQuery('#ccec_exceptions_in_days_container').show();
353        jQuery('#ccec_end_wrapper').hide();
354        jQuery('#ccec-advanced-wraper').hide();
355    }
356    else if(repeat_type == 'ordinal' || repeat_type == 'advanced')
357    {
358        jQuery('#ccec_repeat_interval_container').hide();
359        jQuery('#ccec_repeat_certain_weekdays_container').hide();
360        jQuery('#ccec_exceptions_in_days_container').hide();
361        jQuery('#ccec_end_wrapper').show();
362        jQuery('#ccec-advanced-wraper').show();
363    }
364    else if(repeat_type != 'daily' && repeat_type != 'weekly')
365    {
366        jQuery('#ccec_repeat_interval_container').hide();
367        jQuery('#ccec_repeat_certain_weekdays_container').hide();
368        jQuery('#ccec_exceptions_in_days_container').hide();
369        jQuery('#ccec_end_wrapper').show();
370        jQuery('#ccec-advanced-wraper').hide();
371    }
372    else
373    {
374        jQuery('#ccec_repeat_interval_container').show();
375        jQuery('#ccec_repeat_certain_weekdays_container').hide();
376        jQuery('#ccec_exceptions_in_days_container').hide();
377        jQuery('#ccec_end_wrapper').show();
378        jQuery('#ccec-advanced-wraper').hide();
379    }
380}
381
382let ccec_in_days_remove = function (i)
383{
384    jQuery('#ccec_in_days_row'+i).remove();
385}
386
387let ccec_not_in_days_remove = function (i)
388{
389    jQuery('#ccec_not_in_days_row'+i).remove();
390}
391
392let ccec_cancel_in_days_remove = function (i)
393{
394    jQuery('#ccec_cancel_in_days_row'+i).remove();
395}
396
397let ccec_organizer_toggle = function ()
398{
399    if(jQuery('#ccec_organizer_id').val() != '0') jQuery('#ccec_organizer_new_container').hide();
400    else jQuery('#ccec_organizer_new_container').show();
401}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.