PageSourceSearch

https://www.sjmholdings.com/system_resources//components/com_flexi…/js/tmpl-common.js?6aac96ea83a004.06466998

js sjmholdings.com collected 2026-09-25 04:12:07 UTC 15,904 bytes, 468 lines download raw bytes

1	function fc_getCookie(name) {
2	  match = document.cookie.match(new RegExp(name + '=([^;]+)'));
3	  if (match) return match[1];
4	  else return '';
5	}
6	
7	function tableOrdering( order, dir, task )
8	{
9		var form = document.getElementById("adminForm");
10
11		form.filter_order.value 	= order;
12		form.filter_order_Dir.value	= dir;
13		
14		var form = document.getElementById("adminForm");
15		
16		adminFormPrepare(form, 2, task);
17	}
18
19	function getSEFurl(loader_el, loader_html, form, url_to_load, autosubmit_msg, autosubmit)
20	{
21		jQuery('#'+loader_el).html(loader_html);
22		jQuery.ajax({
23			type: 'GET',
24			url: url_to_load,
25			dataType: "text",
26			data: {
27			},
28			success: function( responseText )
29			{
30			 	form.action=responseText;
31			 	var fcform = jQuery(form);
32			 	fcform.attr('data-fcform_action', responseText);
33			 	if (autosubmit) {
34			 		jQuery('#'+loader_el).append(autosubmit_msg);
35					adminFormPrepare(form, 2);
36				} else {
37					jQuery('#'+loader_el).html('');
38				}
39			},
40			error: function (xhr, ajaxOptions, thrownError) {
41				alert('Error status: ' + xhr.status + ' , Error text: ' + thrownError);
42			}
43		});
44	}
45	
46	
47	function adminFormPrepare(form, postprep, task) {
48		var extra_action = '';
49		var fcform = jQuery(form);
50		
51		var fcform_action = fcform.attr('data-fcform_action');
52		if ( typeof fcform_action === "undefined" || fcform_action === null ) {
53			fcform_action = fcform.attr('action');
54			fcform.attr('data-fcform_action', fcform_action);
55		}
56		
57		var var_sep = fcform_action.match(/\?/) ? '&' : '?';
58		
59		for(i=0; i<form.elements.length; i++)
60		{
61			var element = form.elements[i];
62			if (typeof element.name === "undefined" || element.name === null || !element.name) continue;
63			
64			// No need to add the default values for ordering, to the URL
65			if (element.name=='filter_order' && element.value=='i.title') continue;
66			if (element.name=='filter_order_Dir' && element.value=='ASC') continue;
67			
68			var matches = element.name.match(/^(filter.*|cids|letter|clayout|limit|orderby|q|searchword|p|searchphrase|areas\[\]|contenttypes\[\]|txtflds|o|ordering)$/);
69			if (!matches || element.value == '') continue;
70			if ((element.type=='radio' || element.type=='checkbox') && !element.checked) continue;
71			
72			if ( element.type=='select-multiple' ) {
73				for (var p=0; p < element.length; p++) {
74					if ( ! element.options[p].selected ) continue;
75					extra_action += var_sep + element.name.replace("[]","") + '[' + ']=' + encodeURIComponent(element.options[p].value);
76					var_sep = '&';
77				}
78			} else {
79				element_value = element.value;
80				if ( jQuery(element).hasClass('fc_iscalendar') ) {
81					var frmt = '%Y-%m-%d';
82					var date = Date.parseDate(element.value || element.innerHTML, frmt);
83					if (postprep==2) element.value = date.print(frmt, true);
84					element_value = date.print(frmt, true);
85				}
86				extra_action += var_sep + element.name + '=' + encodeURIComponent(element_value);
87				var_sep = '&';
88			}
89		}
90		
91		var fc_uid = fc_getCookie('fc_uid');
92		if (fc_uid!='') {
93			extra_action += var_sep + 'cc' + '=' +fc_uid;
94		}
95		form.action = fcform_action + extra_action;  //alert(form.action);
96		
97		if (typeof postprep !== "undefined" && postprep !== null && postprep!=0) {
98			if (postprep==2) {
99				var fc_filter_form_blocker = jQuery("#fc_filter_form_blocker");
100				form.submit( task );
101				if (fc_filter_form_blocker) {
102					fc_filter_form_blocker.css("display", "block");
103					fc_progress(95, jQuery('#fc_filter_form_blocker .fc_blocker_bar'));
104				}
105			} else if (postprep==1) {
106				var form_id = jQuery(form).attr('id');
107				jQuery('#'+form_id+'_submitWarn').css("display", "inline-block");
108			}
109		}
110	}
111	
112	function adminFormClearFilters (form) {
113		for(i=0; i<form.elements.length; i++) {
114			var element = form.elements[i];
115			if (typeof element.name === "undefined" || element.name === null || !element.name) continue;
116			
117			if (element.name=='filter_order') {	element.value=='i.title'; continue; }
118			if (element.name=='filter_order_Dir') { element.value=='ASC'; continue; }
119			
120			var matches = element.name.match(/(filter[.]*|letter)/);
121			if (matches) {
122				if (jQuery(element).data('select2')) {
123					jQuery(element).select2('val', '');
124				} else {
125					element.value = '';
126				}
127			}
128		}
129	}
130	
131	function fc_toggleClass(ele, cls, fc_all) {
132		var inputs = ele.parentNode.parentNode.getElementsByTagName('input');
133		var input_0 = jQuery(inputs[0]);
134		if (typeof fc_all === "undefined" || fc_all === null || !fc_all)
135		{
136			if ( jQuery(ele).attr('checked') ) {
137				jQuery(ele).next().addClass(cls);
138				jQuery(ele).parent().addClass('fc_checkradio_checked');
139			} else {
140				jQuery(ele).next().removeClass(cls);
141				jQuery(ele).parent().removeClass('fc_checkradio_checked');
142			}
143		  // Handle disabling 'select all' checkbox (if it exists), not needed but to make sure ...
144		  if (input_0.val()=='') {
145				input_0.prop('checked', false);
146				input_0.next().removeClass(cls);
147				input_0.parent().removeClass('fc_checkradio_checked');
148		  }
149		}
150		else
151		{
152			for (var i = 0; i < inputs.length; ++i) {
153				var input_i = jQuery(inputs[i]);
154				input_i.prop('checked', false);
155				input_i.next().removeClass(cls);
156				input_i.parent().removeClass('fc_checkradio_checked');
157			}
158		  // Handle highlighting (but not enabling) 'select all' checkbox
159			jQuery(ele).prop('checked', true);
160			jQuery(ele).next().addClass(cls);
161			jQuery(ele).parent().addClass('fc_checkradio_checked');
162		}
163		//alert('done fc_toggleClass()');
164	}
165	
166	function fc_toggleClassGrp(ele, cls, fc_all) {
167		var inputs = ele.parentNode.parentNode.getElementsByTagName('input');
168		var input_0 = jQuery(inputs[0]);
169		if (typeof fc_all === "undefined" || fc_all === null || !fc_all)
170		{
171			for (var i = 0; i < inputs.length; ++i) {
172				var input_i = jQuery(inputs[i]);
173				if ( input_i.attr('checked') ) {
174					input_i.next().addClass(cls);
175					input_i.parent().addClass('fc_checkradio_checked');
176				} else {
177					input_i.next().removeClass(cls);
178					input_i.parent().removeClass('fc_checkradio_checked');
179				}
180			}
181		}
182		else
183		{
184			for (var i = 0; i < inputs.length; ++i) {
185				var input_i = jQuery(inputs[i]);
186				input_i.next().removeClass(cls);
187				input_i.parent().removeClass('fc_checkradio_checked');
188			}
189		  // Handle highlighting (but not enabling) 'select all' radio button
190			jQuery(ele).next().addClass(cls);
191			jQuery(ele).parent().addClass('fc_checkradio_checked');
192		}
193		//alert('done fc_toggleClassGrp()');
194	}
195
196
197	function fc_progress(percent, element) {
198		var progressBarWidth = percent * element.width() / 100;
199		element.find('div').animate({ width: progressBarWidth }, 5000).html("");
200	}
201
202
203
204jQuery(document).ready(function() {
205
206	// case-insensitive contains()
207	jQuery.expr[':'].contains_ci_fc = function(el,i,txt){
208		return (el.textContent || el.innerText || "").toUpperCase().indexOf(txt[3].toUpperCase()) >= 0;
209	};
210	
211	// Add instant text type filter to lists
212	jQuery('span.fc_list_filter_wrapper').each(function() {
213		var list = jQuery(this).find('ul:first');
214		// prepend text filter input to the list
215		var form = jQuery("<form>").attr({"class":"fc_instant_filter", "action":"#"}),
216		input = jQuery("<input>").attr({"class":"fc_field_filter fc_label_internal fc_instant_filter fc_autosubmit_exclude", "type":"text", "data-fc_label_text":Joomla.JText._('FLEXI_TYPE_TO_FILTER')});
217		jQuery(form).append(input).insertBefore(this);
218	
219		jQuery(input)
220		.change( function () {
221			var filter = jQuery(this).val();
222			if(filter) {
223				jQuery(list).find("li:not(.fc_checkradio_checked):not(.fc_checkradio_special) label:not(:contains_ci_fc(" + filter + "))").parent().slideUp();
224				jQuery(list).find("li:not(.fc_checkradio_checked):not(.fc_checkradio_special) label:contains_ci_fc(" + filter + ")").parent().slideDown();
225			} else {
226				jQuery(list).find("li").slideDown();
227			}
228			return false;
229		})
230		.keyup( function () {
231			jQuery(this).change();
232		});
233	});
234	
235
236	// Initialize internal labels
237	jQuery('input.fc_label_internal').each(function() {
238		var el = jQuery(this);
239		var fc_label_text = el.attr('data-fc_label_text');
240		if (!fc_label_text) fc_label_text = el.attr('fc_label_text');
241		if (!fc_label_text) return;
242		var _label = (fc_label_text.length >= 27) ? fc_label_text.substring(0, 25) + '...' : fc_label_text;
243		
244		el.before(jQuery('<span/>', {
245			'class': 'fc_has_inner_label fc_has_inner_label_input',
246			'text': _label
247		}));
248		if (el.val().length > 0) el.prev().hide();
249	});
250	
251	
252	jQuery('input.fc_label_internal').bind('focus', function() {
253		var el = jQuery(this);
254		var fc_label_text = el.attr('data-fc_label_text');
255		if (!fc_label_text) fc_label_text = el.attr('fc_label_text');
256		if (!fc_label_text) return;
257		el.prev().hide();
258		el.css("opacity", "1");
259	}).bind('change blur', function(event) {
260		var el = jQuery(this);
261		var fc_label_text = el.attr('data-fc_label_text');
262		if (!fc_label_text) fc_label_text = el.attr('fc_label_text');
263		if (!fc_label_text) return;
264		
265		if (event.type=='blur') {
266			var previous_value = el.attr('data-previous_value');
267			if ( typeof previous_value !== "undefined" && previous_value != el.val())  el.trigger('change');
268		}
269		
270		if ( el.val().length ) {
271			el.prev().hide();
272			el.css("opacity", "1");
273		} else {
274			el.prev().show();
275			el.css("opacity", "0.5");
276		}
277	});
278	
279	// handle calender fields being changed by popup calendar
280	jQuery('input + button .icon-calendar').parent().bind('click', function() {
281		var el = jQuery(this).prev();
282		el.attr('data-previous_value', el.val());
283		Calendar.prototype.__currentCalendarInput = el;   // Set a singular variable for the current input field
284		//el.focus(); // Effectivle sets: document.activeElement so that close handler of calendar 'callCloseHandler' will find it
285	});
286	
287	if (typeof Calendar !== "undefined" && typeof Calendar.prototype.callCloseHandler === 'function')
288	{
289		var oldFunc = Calendar.prototype.callCloseHandler;
290		Calendar.prototype.callCloseHandler = function()
291		{
292			var oldFuncResult = oldFunc.apply(this, arguments);
293			var el = Calendar.prototype.__currentCalendarInput; //jQuery(document.activeElement);
294			var previous_value = el.attr('data-previous_value');
295			if ( typeof previous_value !== "undefined" && previous_value != el.val())  {
296				el.trigger('change');
297			}
298			return oldFuncResult;
299		}
300	}
301	
302	var fc_select_pageSize = 10;
303	
304	// add Simple text search autocomplete
305	if (typeof jQuery.ui != 'undefined' && typeof jQuery.ui.autocomplete==='function') {
306		var theElements = jQuery("input.fc_index_complete_simple");
307		theElements.each(function () {
308			jQuery.ui.autocomplete( {
309				source: function( request, response ) {
310					var el = jQuery(this.element);
311					var el_cid  = el.attr('data-txt_ac_cid')  ? el.attr('data-txt_ac_cid')  : (parseInt(_FC_GET['cid']) || 0);
312					var el_cids = el.attr('data-txt_ac_cids') ? el.attr('data-txt_ac_cids') : _FC_GET['cids'];
313					var el_usesubs = parseInt(el.attr('data-txt_ac_usesubs')) || 0;
314					jQuery.ajax({
315						url: "index.php?option=com_flexicontent&tmpl=component",
316						dataType: "json",
317						data: {
318							type: (el.hasClass('fc_adv_complete') ? "adv_index" : "basic_index"),
319							task: "txtautocomplete",
320							pageSize: fc_select_pageSize,
321							text: request.term,
322							lang: (typeof _FC_GET !="undefined" && 'lang' in _FC_GET ? _FC_GET['lang']: ''),
323							cid: el_cid,
324							cids: el_cids,
325							usesubs: el_usesubs
326						},
327						success: function( data ) {
328							//console.log( '... done' );
329							response( jQuery.map( data.Matches, function( item ) {
330								return {
331									/*label: item.item_id +': '+ item.text,*/
332									label: item.text,
333									value: item.text
334								}
335							}));
336						}
337					});
338				},
339				delay: 200,
340				minLength: 1,
341				select: function( event, ui ) {
342					//console.log( ui.item  ?  "Selected: " + ui.item.label  :  "Nothing selected, input was " + this.value);
343					var ele = event.target;
344					jQuery(ele).val(ui.item.value); // set value before triggering change
345					jQuery(ele).trigger('change');
346				},
347				open: function() {
348					jQuery( this ).removeClass( "ui-corner-all" ).addClass( "ui-corner-top" );
349					jQuery(this).removeClass('working');
350				},
351				close: function() {
352					jQuery( this ).removeClass( "ui-corner-top" ).addClass( "ui-corner-all" );
353				},
354				search: function() {
355					//console.log( 'quering ... ' );
356					jQuery(this).addClass('working');
357				}
358			}, this );
359		});
360	}
361
362
363
364	// add Tag-Like text search autocomplete
365	if(typeof jQuery('input.fc_index_complete_tlike').select2!=='undefined') {
366		jQuery('input.fc_index_complete_tlike').select2(
367		{
368			placeholder: Joomla.JText._('FLEXI_TYPE_TO_LIST'),
369			multiple: true,
370			minimumInputLength: 1,
371			separator: " ",
372			allowClear: true,
373		
374			initSelection : function (element, callback) {
375				var data = [];
376				jQuery(element.val().split(" ")).each(function () {
377					data.push({id: this, text: this});
378				});
379				callback(data);
380			},
381		
382			ajax: {
383				quietMillis: 200,
384				url: "index.php?option=com_flexicontent&tmpl=component",
385				dataType: 'json',
386				//Our search term and what page we are on
387				data: function (term, page) {
388					return {
389						type: (jQuery(this).hasClass('fc_adv_complete') ? "adv_index" : "basic_index"),
390						task: "txtautocomplete",
391						text: term,
392						pageSize: fc_select_pageSize,
393						pageNum: page,
394						lang: (typeof _FC_GET !="undefined" && 'lang' in _FC_GET ? _FC_GET['lang']: ''),
395						cid:  (jQuery(this).attr('data-txt_ac_cid')  ? jQuery(this).attr('data-txt_ac_cid')  : (parseInt(_FC_GET['cid']) || 0)),
396						cids: (jQuery(this).attr('data-txt_ac_cids') ? jQuery(this).attr('data-txt_ac_cids') : _FC_GET['cids']),
397						usesubs: (parseInt(jQuery(this).attr('data-txt_ac_usesubs')) || 0)
398					};
399				},
400				results: function (data, page) {
401					//Used to determine whether or not there are more results available,
402					//and if requests for more data should be sent in the infinite scrolling
403					var more = (page * fc_select_pageSize) < data.Total;
404					return { results: data.Matches, more: more };
405				}
406			}
407		});
408	}
409	
410	jQuery('body').prepend(
411	 	'<span id="fc_filter_form_blocker">' +
412	    '<span class="fc_blocker_opacity"></span>' +
413	    '<span class="fc_blocker_content">' +
414	    	Joomla.JText._('FLEXI_APPLYING_FILTERING') +
415	    	'<div class="fc_blocker_bar"><div></div></div>' +
416	    '</span>' +
417	  '</span>');
418		
419		fc_recalculateWindow();
420});
421
422
423// recalculate window width/height and window scrollbars
424function fc_recalculateWindow()
425{
426	// Set these to hidden to force scrollbar recalculation when we set to auto	
427	/*document.documentElement.style.overflow = "hidden";
428	document.body.style.overflow = "hidden";
429	
430	// make sure widht & height is automatic
431	document.documentElement.style.height = "auto";
432	document.documentElement.style.width  = "auto";
433	document.body.style.height = "auto";
434	document.body.style.width  = "auto";
435	
436	setTimeout(function() {
437		document.documentElement.style.overflow = "";  // firefox, chrome, ie11+
438		document.body.style.overflow = "";
439	}, 100);*/
440	
441	// reset popup overlay containers ... TODO add more ?
442	jQuery('#OverlayContainer').css("height", jQuery('body').css('height'));
443}
444
445
446function fc_replaceUrlParam(url, paramName, paramValue)
447{
448	var pattern = new RegExp('('+paramName+'=).*?(&|$)');
449	return (url.search(pattern)>=0) ?
450		url.replace(pattern,'$1' + paramValue + '$2') :
451		url + (url.indexOf('?')>0 ? '&' : '?') + paramName + '=' + paramValue;
452}
453
454
455
456jQuery(document).ready(function () {
457	
458	var cc = (typeof _FC_GET !="undefined" && 'cc' in _FC_GET ? _FC_GET['cc']: '');
459	var fc_uid = fc_getCookie('fc_uid');
460	
461	if (cc!='' && fc_uid!=cc)
462	{
463		var staleUrl = window.location.href;
464		newUrl = fc_replaceUrlParam(staleUrl, 'cc', fc_uid);
465		window.location.replace(newUrl);
466		document.body.innerHTML = Joomla.JText._('FLEXI_UPDATING_CONTENTS') + ' <img id="loading_img" src="components/com_flexicontent/assets/images/ajax-loader.gif">';
467	}
468});

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.