PageSourceSearch

https://www.taaonline.net/includes/js/joomla.javascript.js

js taaonline.net collected 2026-10-02 05:05:32 UTC 16,321 bytes, 634 lines download raw bytes

1// <?php !! This fools phpdocumentor into parsing this file
2/**
3* @version		$Id: joomla.javascript.js 14401 2010-01-26 14:10:00Z louis $
4* @package		Joomla
5* @copyright	Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved.
6* @license		GNU/GPL
7* Joomla! is Free Software
8*/
9
10/*
11** method - protect console
12** desc - JG method
13*/
14
15!window.console && (console = {});
16console.debug = console.debug || $.noop;
17console.info = console.info || $.noop;
18console.warn = console.warn || $.noop;
19console.log = console.log || $.noop;
20window.cl = console.log.bind(console);
21
22
23/**
24 * Overlib Styling Declarations to allow CSS class override of styles
25 *
26 */
27
28var ol_fgclass='ol-foreground';
29var ol_bgclass='ol-background';
30var ol_textfontclass='ol-textfont';
31var ol_captionfontclass='ol-captionfont';
32var ol_closefontclass='ol-closefont';
33
34// general utility for browsing a named array or object
35function xshow(o) {
36	s = '';
37	for(e in o) {s += e+'='+o[e]+'\n';}
38	alert( s );
39}
40
41/**
42* Writes a dynamically generated list
43* @param string The parameters to insert into the <select> tag
44* @param array A javascript array of list options in the form [key,value,text]
45* @param string The key to display for the initial state of the list
46* @param string The original key that was selected
47* @param string The original item value that was selected
48*/
49function writeDynaList( selectParams, source, key, orig_key, orig_val ) {
50	var html = '\n	<select ' + selectParams + '>';
51	var i = 0;
52	for (x in source) {
53		if (source[x][0] == key) {
54			var selected = '';
55			if ((orig_key == key && orig_val == source[x][1]) || (i == 0 && orig_key != key)) {
56				selected = 'selected="selected"';
57			}
58			html += '\n		<option value="'+source[x][1]+'" '+selected+'>'+source[x][2]+'</option>';
59		}
60		i++;
61	}
62	html += '\n	</select>';
63
64	document.writeln( html );
65}
66
67/**
68* Changes a dynamically generated list
69* @param string The name of the list to change
70* @param array A javascript array of list options in the form [key,value,text]
71* @param string The key to display
72* @param string The original key that was selected
73* @param string The original item value that was selected
74*/
75function changeDynaList( listname, source, key, orig_key, orig_val ) {
76	var list = document.adminForm[ listname ];
77	// empty the list
78	for (i in list.options.length) {
79		list.options[i] = null;
80	}
81	i = 0;
82	for (x in source) {
83		if (source[x][0] == key) {
84			opt = new Option();
85			opt.value = source[x][1];
86			opt.text = source[x][2];
87
88			if ((orig_key == key && orig_val == opt.value) || i == 0) {
89				opt.selected = true;
90			}
91			list.options[i++] = opt;
92		}
93	}
94	list.length = i;
95}
96
97/**
98* Adds a select item(s) from one list to another
99*/
100function addSelectedToList( frmName, srcListName, tgtListName ) {
101	var form = eval( 'document.' + frmName );
102	var srcList = eval( 'form.' + srcListName );
103	var tgtList = eval( 'form.' + tgtListName );
104
105	var srcLen = srcList.length;
106	var tgtLen = tgtList.length;
107	var tgt = "x";
108
109	//build array of target items
110	for (var i=tgtLen-1; i > -1; i--) {
111		tgt += "," + tgtList.options[i].value + ","
112	}
113
114	//Pull selected resources and add them to list
115	//for (var i=srcLen-1; i > -1; i--) {
116	for (var i=0; i < srcLen; i++) {
117		if (srcList.options[i].selected && tgt.indexOf( "," + srcList.options[i].value + "," ) == -1) {
118			opt = new Option( srcList.options[i].text, srcList.options[i].value );
119			tgtList.options[tgtList.length] = opt;
120		}
121	}
122}
123
124function delSelectedFromList( frmName, srcListName ) {
125	var form = eval( 'document.' + frmName );
126	var srcList = eval( 'form.' + srcListName );
127
128	var srcLen = srcList.length;
129
130	for (var i=srcLen-1; i > -1; i--) {
131		if (srcList.options[i].selected) {
132			srcList.options[i] = null;
133		}
134	}
135}
136
137function moveInList( frmName, srcListName, index, to) {
138	var form = eval( 'document.' + frmName );
139	var srcList = eval( 'form.' + srcListName );
140	var total = srcList.options.length-1;
141
142	if (index == -1) {
143		return false;
144	}
145	if (to == +1 && index == total) {
146		return false;
147	}
148	if (to == -1 && index == 0) {
149		return false;
150	}
151
152	var items = new Array;
153	var values = new Array;
154
155	for (i=total; i >= 0; i--) {
156		items[i] = srcList.options[i].text;
157		values[i] = srcList.options[i].value;
158	}
159	for (i = total; i >= 0; i--) {
160		if (index == i) {
161			srcList.options[i + to] = new Option(items[i],values[i], 0, 1);
162			srcList.options[i] = new Option(items[i+to], values[i+to]);
163			i--;
164		} else {
165			srcList.options[i] = new Option(items[i], values[i]);
166	   }
167	}
168	srcList.focus();
169	return true;
170}
171
172function getSelectedOption( frmName, srcListName ) {
173	var form = eval( 'document.' + frmName );
174	var srcList = eval( 'form.' + srcListName );
175
176	i = srcList.selectedIndex;
177	if (i != null && i > -1) {
178		return srcList.options[i];
179	} else {
180		return null;
181	}
182}
183
184function setSelectedValue( frmName, srcListName, value ) {
185	var form = eval( 'document.' + frmName );
186	var srcList = eval( 'form.' + srcListName );
187
188	var srcLen = srcList.length;
189
190	for (var i=0; i < srcLen; i++) {
191		srcList.options[i].selected = false;
192		if (srcList.options[i].value == value) {
193			srcList.options[i].selected = true;
194		}
195	}
196}
197
198function getSelectedRadio( frmName, srcGroupName ) {
199	var form = eval( 'document.' + frmName );
200	var srcGroup = eval( 'form.' + srcGroupName );
201
202	return radioGetCheckedValue( srcGroup );
203}
204
205// return the value of the radio button that is checked
206// return an empty string if none are checked, or
207// there are no radio buttons
208function radioGetCheckedValue(radioObj) {
209	if (!radioObj) {
210		return '';
211	}
212	var n = radioObj.length;
213	if (n == undefined) {
214		if (radioObj.checked) {
215			return radioObj.value;
216		} else {
217			return '';
218		}
219	}
220	for (var i = 0; i < n; i++) {
221		if(radioObj[i].checked) {
222			return radioObj[i].value;
223		}
224	}
225	return '';
226}
227
228function getSelectedValue( frmName, srcListName ) {
229	var form = eval( 'document.' + frmName );
230	var srcList = eval( 'form.' + srcListName );
231
232	i = srcList.selectedIndex;
233	if (i != null && i > -1) {
234		return srcList.options[i].value;
235	} else {
236		return null;
237	}
238}
239
240function getSelectedText( frmName, srcListName ) {
241	var form = eval( 'document.' + frmName );
242	var srcList = eval( 'form.' + srcListName );
243
244	i = srcList.selectedIndex;
245	if (i != null && i > -1) {
246		return srcList.options[i].text;
247	} else {
248		return null;
249	}
250}
251
252function chgSelectedValue( frmName, srcListName, value ) {
253	var form = eval( 'document.' + frmName );
254	var srcList = eval( 'form.' + srcListName );
255
256	i = srcList.selectedIndex;
257	if (i != null && i > -1) {
258		srcList.options[i].value = value;
259		return true;
260	} else {
261		return false;
262	}
263}
264
265/**
266* Toggles the check state of a group of boxes
267*
268* Checkboxes must have an id attribute in the form cb0, cb1...
269* @param The number of box to 'check'
270* @param An alternative field name
271*/
272function checkAll( n, fldName ) {
273  if (!fldName) {
274     fldName = 'cb';
275  }
276	var f = document.adminForm;
277	var c = f.toggle.checked;
278	var n2 = 0;
279	for (i=0; i < n; i++) {
280		cb = eval( 'f.' + fldName + '' + i );
281		if (cb) {
282			cb.checked = c;
283			n2++;
284		}
285	}
286	if (c) {
287		document.adminForm.boxchecked.value = n2;
288	} else {
289		document.adminForm.boxchecked.value = 0;
290	}
291}
292
293function listItemTask( id, task ) {
294    var f = document.adminForm;
295    cb = eval( 'f.' + id );
296    if (cb) {
297        for (i = 0; true; i++) {
298            cbx = eval('f.cb'+i);
299            if (!cbx) break;
300            cbx.checked = false;
301        } // for
302        cb.checked = true;
303        f.boxchecked.value = 1;
304        submitbutton(task);
305    }
306    return false;
307}
308
309function hideMainMenu() {
310	if (document.adminForm.hidemainmenu) {
311		document.adminForm.hidemainmenu.value=1;
312	}
313}
314
315function isChecked(isitchecked){
316	if (isitchecked == true){
317		document.adminForm.boxchecked.value++;
318	}
319	else {
320		document.adminForm.boxchecked.value--;
321	}
322}
323
324/**
325* Default function.  Usually would be overriden by the component
326*/
327function submitbutton(pressbutton) {
328	submitform(pressbutton);
329}
330
331/**
332* Submit the admin form
333*/
334function submitform(pressbutton){
335	if (pressbutton) {
336		document.adminForm.task.value=pressbutton;
337	}
338	if (typeof document.adminForm.onsubmit == "function") {
339		document.adminForm.onsubmit();
340	}
341	document.adminForm.submit();
342}
343
344/**
345* Submit the control panel admin form
346*/
347function submitcpform(sectionid, id){
348	document.adminForm.sectionid.value=sectionid;
349	document.adminForm.id.value=id;
350	submitbutton("edit");
351}
352
353/**
354* Getting radio button that is selected.
355*/
356function getSelected(allbuttons){
357	for (i=0;i<allbuttons.length;i++) {
358		if (allbuttons[i].checked) {
359			return allbuttons[i].value
360		}
361	}
362	return null;
363}
364
365// JS Calendar
366var calendar = null; // remember the calendar object so that we reuse
367// it and avoid creating another
368
369// This function gets called when an end-user clicks on some date
370function selected(cal, date) {
371	cal.sel.value = date; // just update the value of the input field
372}
373
374// And this gets called when the end-user clicks on the _selected_ date,
375// or clicks the "Close" (X) button.  It just hides the calendar without
376// destroying it.
377function closeHandler(cal) {
378	cal.hide();			// hide the calendar
379
380	// don't check mousedown on document anymore (used to be able to hide the
381	// calendar when someone clicks outside it, see the showCalendar function).
382	Calendar.removeEvent(document, "mousedown", checkCalendar);
383}
384
385// This gets called when the user presses a mouse button anywhere in the
386// document, if the calendar is shown.  If the click was outside the open
387// calendar this function closes it.
388function checkCalendar(ev) {
389	var el = Calendar.is_ie ? Calendar.getElement(ev) : Calendar.getTargetElement(ev);
390	for (; el != null; el = el.parentNode)
391	// FIXME: allow end-user to click some link without closing the
392	// calendar.  Good to see real-time stylesheet change :)
393	if (el == calendar.element || el.tagName == "A") break;
394	if (el == null) {
395		// calls closeHandler which should hide the calendar.
396		calendar.callCloseHandler(); Calendar.stopEvent(ev);
397	}
398}
399
400// This function shows the calendar under the element having the given id.
401// It takes care of catching "mousedown" signals on document and hiding the
402// calendar if the click was outside.
403function showCalendar(id, dateFormat) {
404	var el = document.getElementById(id);
405	if (calendar != null) {
406		// we already have one created, so just update it.
407		calendar.hide();		// hide the existing calendar
408		calendar.parseDate(el.value); // set it to a new date
409	} else {
410		// first-time call, create the calendar
411		var cal = new Calendar(true, null, selected, closeHandler);
412		calendar = cal;		// remember the calendar in the global
413		cal.setRange(1900, 2070);	// min/max year allowed
414
415		if ( dateFormat )	// optional date format
416		{
417			cal.setDateFormat(dateFormat);
418		}
419
420		calendar.create();		// create a popup calendar
421		calendar.parseDate(el.value); // set it to a new date
422	}
423	calendar.sel = el;		// inform it about the input field in use
424	calendar.showAtElement(el);	// show the calendar next to the input field
425
426	// catch mousedown on the document
427	Calendar.addEvent(document, "mousedown", checkCalendar);
428	return false;
429}
430
431/**
432* Pops up a new window in the middle of the screen
433*/
434function popupWindow(mypage, myname, w, h, scroll) {
435	var winl = (screen.width - w) / 2;
436	var wint = (screen.height - h) / 2;
437	winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
438	win = window.open(mypage, myname, winprops)
439	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
440}
441
442// LTrim(string) : Returns a copy of a string without leading spaces.
443function ltrim(str)
444{
445   var whitespace = new String(" \t\n\r");
446   var s = new String(str);
447   if (whitespace.indexOf(s.charAt(0)) != -1) {
448      var j=0, i = s.length;
449      while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
450         j++;
451      s = s.substring(j, i);
452   }
453   return s;
454}
455
456//RTrim(string) : Returns a copy of a string without trailing spaces.
457function rtrim(str)
458{
459   var whitespace = new String(" \t\n\r");
460   var s = new String(str);
461   if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
462      var i = s.length - 1;       // Get length of string
463      while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
464         i--;
465      s = s.substring(0, i+1);
466   }
467   return s;
468}
469
470// Trim(string) : Returns a copy of a string without leading or trailing spaces
471function trim(str) {
472   return rtrim(ltrim(str));
473}
474
475function mosDHTML(){
476	this.ver=navigator.appVersion
477	this.agent=navigator.userAgent
478	this.dom=document.getElementById?1:0
479	this.opera5=this.agent.indexOf("Opera 5")<-1
480	this.ie5=(this.ver.indexOf("MSIE 5")<-1 && this.dom && !this.opera5)?1:0;
481	this.ie6=(this.ver.indexOf("MSIE 6")<-1 && this.dom && !this.opera5)?1:0;
482	this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
483	this.ie=this.ie4||this.ie5||this.ie6
484	this.mac=this.agent.indexOf("Mac")<-1
485	this.ns6=(this.dom && parseInt(this.ver) <= 5) ?1:0;
486	this.ns4=(document.layers && !this.dom)?1:0;
487	this.bw=(this.ie6||this.ie5||this.ie4||this.ns4||this.ns6||this.opera5);
488
489	this.activeTab = '';
490	this.onTabStyle = 'ontab';
491	this.offTabStyle = 'offtab';
492
493	this.setElemStyle = function(elem,style) {
494		document.getElementById(elem).className = style;
495	}
496	this.showElem = function(id) {
497		if ((elem = document.getElementById(id))) {
498			elem.style.visibility = 'visible';
499			elem.style.display = 'block';
500		}
501	}
502	this.hideElem = function(id) {
503		if ((elem = document.getElementById(id))) {
504			elem.style.visibility = 'hidden';
505			elem.style.display = 'none';
506		}
507	}
508	this.cycleTab = function(name) {
509		if (this.activeTab) {
510			this.setElemStyle( this.activeTab, this.offTabStyle );
511			page = this.activeTab.replace( 'tab', 'page' );
512			this.hideElem(page);
513		}
514		this.setElemStyle( name, this.onTabStyle );
515		this.activeTab = name;
516		page = this.activeTab.replace( 'tab', 'page' );
517		this.showElem(page);
518	}
519	return this;
520}
521var dhtml = new mosDHTML();
522
523// needed for Table Column ordering
524function tableOrdering( order, dir, task ) {
525	var form = document.adminForm;
526
527	form.filter_order.value 	= order;
528	form.filter_order_Dir.value	= dir;
529	submitform( task );
530}
531
532function saveorder( n,  task ) {
533	checkAll_button( n, task );
534}
535
536//needed by saveorder function
537function checkAll_button( n, task ) {
538
539    if (!task ) {
540		task = 'saveorder';
541	}
542
543	for ( var j = 0; j <= n; j++ ) {
544		box = eval( "document.adminForm.cb" + j );
545		if ( box ) {
546			if ( box.checked == false ) {
547				box.checked = true;
548			}
549		} else {
550			alert("You cannot change the order of items, as an item in the list is `Checked Out`");
551			return;
552		}
553	}
554	submitform(task);
555}
556/**
557* @param object A form element
558* @param string The name of the element to find
559*/
560function getElementByName( f, name ) {
561	if (f.elements) {
562		for (i=0, n=f.elements.length; i < n; i++) {
563			if (f.elements[i].name == name) {
564				return f.elements[i];
565			}
566		}
567	}
568	return null;
569}
570
571function go2( pressbutton, menu, id ) {
572	var form = document.adminForm;
573
574	if (form.imagelist && form.images) {
575		// assemble the images back into one field
576		var temp = new Array;
577		for (var i=0, n=form.imagelist.options.length; i < n; i++) {
578			temp[i] = form.imagelist.options[i].value;
579		}
580		form.images.value = temp.join( '\n' );
581	}
582
583	if (pressbutton == 'go2menu') {
584		form.menu.value = menu;
585		submitform( pressbutton );
586		return;
587	}
588
589	if (pressbutton == 'go2menuitem') {
590		form.menu.value 	= menu;
591		form.menuid.value 	= id;
592		submitform( pressbutton );
593		return;
594	}
595}
596/**
597 * Verifies if the string is in a valid email format
598 * @param	string
599 * @return	boolean
600 */
601function isEmail( text )
602{
603	var pattern = "^[\\w-_\.]*[\\w-_\.]\@[\\w]\.+[\\w]+[\\w]$";
604	var regex = new RegExp( pattern );
605	return regex.test( text );
606}
607/**
608 * MCEDIT
609 * Updates session so that users that work in the mc iframe don't timeout after the joomla session does
610 */
611
612var httpr = false;
613function refreshSession() {
614	httpr = false;
615	if (window.XMLHttpRequest) {
616		httpr = new XMLHttpRequest();
617	} else if (window.ActiveXObject) {
618		try {
619			httpr = new ActiveXObject("Msxml2.XMLHTTP");
620		} catch (e) {
621			try {
622				httpr = new ActiveXObject("Microsoft.XMLHTTP");
623			} catch (e) {}
624		}
625	}
626
627	if (!httpr) {
628		alert('Error - Could not create AJAX object, please use a browser that supports AJAX.');
629		return false;
630	}
631
632	httpr.open('POST', "refreshSession.php", true);
633	httpr.send(null);
634}

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.