PageSourceSearch

https://www.rusartnet.com/components/com_flexicontent/assets/js/tmpl-common.js

js rusartnet.com collected 2026-10-02 12:21:14 UTC 14,206 bytes, 431 lines download raw bytes

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

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.