PageSourceSearch

https://cald.org/wp-content/plugins/spider-event-calendar/elements/calendar_function.js?ver=1.5.62

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

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.