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

