PageSourceSearch

https://samtripoli.com/wp-content/plugins/ultimate-member/assets/js/common.js?ver=2.13.1

js samtripoli.com collected 2026-09-24 10:40:07 UTC 4,161 bytes, 150 lines download raw bytes

1// Custom jQuery functions.
2jQuery.fn.extend({
3	umShow: function() {
4		return this.each(function() {
5			jQuery(this).removeClass( 'um-display-none' );
6		});
7	},
8	umHide: function() {
9		return this.each(function() {
10			jQuery(this).addClass( 'um-display-none' );
11		});
12	},
13	umToggle: function() {
14		return this.each(function() {
15			jQuery(this).toggleClass( 'um-display-none' );
16		});
17	}
18});
19
20if ( typeof ( window.UM ) !== 'object' ) {
21	window.UM = {};
22}
23
24if ( typeof ( UM.common ) !== 'object' ) {
25	UM.common = {};
26}
27
28UM.common = {
29	tipsy: {
30		init: function () {
31			if ( 'function' === typeof( jQuery.fn.tipsy ) ) {
32				jQuery('.um-tip-n').tipsy({gravity: 'n', opacity: 1, live: 'a.live', offset: 3 });
33				jQuery('.um-tip-w').tipsy({gravity: 'w', opacity: 1, live: 'a.live', offset: 3 });
34				jQuery('.um-tip-e').tipsy({gravity: 'e', opacity: 1, live: 'a.live', offset: 3 });
35				jQuery('.um-tip-s').tipsy({gravity: 's', opacity: 1, live: 'a.live', offset: 3 });
36			}
37		},
38		hide: function () {
39			if ( 'function' === typeof( jQuery.fn.tipsy ) ) {
40				jQuery('.um-tip-n').tipsy('hide');
41				jQuery('.um-tip-w').tipsy('hide');
42				jQuery('.um-tip-e').tipsy('hide');
43				jQuery('.um-tip-s').tipsy('hide');
44				jQuery('.um .tipsy').remove();
45				jQuery('.um-page .tipsy').remove();
46			}
47		}
48	},
49	datetimePicker: {
50		init: function () {
51			jQuery('.um-datepicker:not(.um-inited)').each(function(){
52				let input = this;
53				jQuery(input).addClass('um-inited');
54				input.addEventListener('change', function () {
55					if ( ! this.value ) {
56						return;
57					}
58
59					this.setCustomValidity('');
60
61					// Range validation for typed values (ISO dates compare safely as strings).
62					if ( this.min && this.value < this.min ) {
63						/* translators: %s: Date range min. */
64						this.setCustomValidity( wp.i18n.sprintf( wp.i18n.__( 'Please pick a date on or after %s.', 'ultimate-member' ), this.min ) );
65						this.value = '';
66						this.reportValidity();
67						return;
68					}
69					if ( this.max && this.value > this.max ) {
70						/* translators: %s: Date range max. */
71						this.setCustomValidity( wp.i18n.sprintf( wp.i18n.__( 'Please pick a date on or before %s.', 'ultimate-member' ), this.max ) );
72						this.value = '';
73						this.reportValidity();
74						return;
75					}
76
77					let disabled = JSON.parse(this.dataset.disabled_weekdays || '[]'); // options used 1=Sun..7=Sat
78					let day = new Date(this.value + 'T00:00:00').getDay(); // this function returns 0=Sun..6=Sat
79					if (disabled.includes( day + 1 )) {
80						this.setCustomValidity(wp.i18n.__( 'This day is not selectable.', 'ultimate-member' ) );
81						this.value = '';
82						this.reportValidity();
83					} else {
84						this.setCustomValidity('');
85					}
86				});
87			});
88
89			jQuery('.um-timepicker:not(.um-inited)').each(function(){
90				let input = this;
91				jQuery(input).addClass('um-inited');
92				input.addEventListener('change', function () {
93					if ( ! this.value ) {
94						return;
95					}
96					let stepSec = parseInt(this.step, 10) || 60;
97					let [h, m] = this.value.split(':').map(Number);
98					let totalSec = (h * 3600) + (m * 60);
99					if (totalSec % stepSec !== 0) {
100						this.setCustomValidity( wp.i18n.__( 'Please pick a time on the allowed interval.', 'ultimate-member' ) );
101						this.reportValidity();
102					} else {
103						this.setCustomValidity('');
104					}
105				});
106			});
107		}
108	},
109	select: {
110		isSelected: function( selected, current ){
111			if ( selected === current ) {
112				return ' selected="selected"';
113			}
114			return "";
115		}
116	},
117	form: {
118		vanillaSerialize: function ( formID ) {
119			let form = document.querySelector('#' + formID);
120			let data = new FormData( form );
121
122			let obj = {};
123			for (let [key, value] of data) {
124				if (obj[key] !== undefined) {
125					if (!Array.isArray(obj[key])) {
126						obj[key] = [obj[key]];
127					}
128					obj[key].push(value);
129				} else {
130					obj[key] = value;
131				}
132			}
133
134			return obj;
135		}
136	}
137}
138
139jQuery(document).on( 'ajaxStart', function() {
140	UM.common.tipsy.hide();
141});
142
143jQuery(document).on( 'ajaxSuccess', function() {
144	UM.common.tipsy.init();
145});
146
147jQuery(document).ready(function() {
148	UM.common.tipsy.init();
149	UM.common.datetimePicker.init();
150});

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.