1// <?php !! This fools phpdocumentor into parsing this file 2// $Id: mambojavascript.js,v 1.14 2003/09/29 23:38:48 eddieajau Exp $ 3/** 4* Content code 5* @package Mambo Open Source 6* @Copyright (C) 2000 - 2003 Miro International Pty Ltd 7* @ All rights reserved 8* @ Mambo Open Source is Free Software 9* @ Released under GNU/GPL License : http://www.gnu.org/copyleft/gpl.html 10* @version $Revision: 1.14 $ 11**/ 12 13// general utility for browsing a named array or object 14function xshow(o) { 15 s = ''; 16 for(e in o) {s += e+'='+o[e]+'\n';} 17 alert( s ); 18} 19 20/** 21* Writes a dynamically generated list 22* @param string The parameters to insert into the <select> tag 23* @param array A javascript array of list options in the form [key,value,text] 24* @param string The key to display for the initial state of the list 25* @param string The original key that was selected 26* @param string The original item value that was selected 27*/ 28function writeDynaList( selectParams, source, key, orig_key, orig_val ) { 29 var html = '\n <select ' + selectParams + '>'; 30 var i = 0; 31 for (x in source) { 32 if (source[x][0] == key) { 33 var selected = ''; 34 if ((orig_key == key && orig_val == source[x][1]) || (i == 0 && orig_key != key)) { 35 selected = 'selected="selected"'; 36 } 37 html += '\n <option value="'+source[x][1]+'" '+selected+'>'+source[x][2]+'</option>'; 38 } 39 i++; 40 } 41 html += '\n </select>'; 42 43 document.writeln( html ); 44} 45 46/** 47* Changes a dynamically generated list 48* @param string The name of the list to change 49* @param array A javascript array of list options in the form [key,value,text] 50* @param string The key to display 51* @param string The original key that was selected 52* @param string The original item value that was selected 53*/ 54function changeDynaList( listname, source, key, orig_key, orig_val ) { 55 var list = eval( 'document.adminForm.' + listname ); 56 57 // empty the list 58 for (i in list.options.length) { 59 list.options[i] = null; 60 } 61 i = 0; 62 for (x in source) { 63 if (source[x][0] == key) { 64 opt = new Option(); 65 opt.value = source[x][1]; 66 opt.text = source[x][2]; 67 68 if ((orig_key == key && orig_val == opt.value) || i == 0) { 69 opt.selected = true; 70 } 71 list.options[i++] = opt; 72 } 73 } 74 list.length = i; 75} 76 77/** 78* Adds a select item(s) from one list to another 79*/ 80function addSelectedToList( frmName, srcListName, tgtListName ) { 81 var form = eval( 'document.' + frmName ); 82 var srcList = eval( 'form.' + srcListName ); 83 var tgtList = eval( 'form.' + tgtListName ); 84 85 var srcLen = srcList.length; 86 var tgtLen = tgtList.length; 87 var tgt = "x"; 88 89 //build array of target items 90 for (var i=tgtLen-1; i > -1; i--) { 91 tgt += "," + tgtList.options[i].value + "," 92 } 93 94 //Pull selected resources and add them to list 95 for (var i=srcLen-1; i > -1; i--) { 96 if (srcList.options[i].selected && tgt.indexOf( "," + srcList.options[i].value + "," ) == -1) { 97 opt = new Option( srcList.options[i].text, srcList.options[i].value ); 98 tgtList.options[tgtList.length] = opt; 99 } 100 } 101} 102 103function delSelectedFromList( frmName, srcListName ) { 104 var form = eval( 'document.' + frmName ); 105 var srcList = eval( 'form.' + srcListName ); 106 107 var srcLen = srcList.length; 108 109 for (var i=srcLen-1; i > -1; i--) { 110 if (srcList.options[i].selected) { 111 srcList.options[i] = null; 112 } 113 } 114} 115 116function moveInList( frmName, srcListName, index, to) { 117 var form = eval( 'document.' + frmName ); 118 var srcList = eval( 'form.' + srcListName ); 119 var total = srcList.options.length-1; 120 121 if (index == -1) { 122 return false; 123 } 124 if (to == +1 && index == total) { 125 return false; 126 } 127 if (to == -1 && index == 0) { 128 return false; 129 } 130 131 var items = new Array; 132 var values = new Array; 133 134 for (i=total; i >= 0; i--) { 135 items[i] = srcList.options[i].text; 136 values[i] = srcList.options[i].value; 137 } 138 for (i = total; i >= 0; i--) { 139 if (index == i) { 140 srcList.options[i + to] = new Option(items[i],values[i], 0, 1); 141 srcList.options[i] = new Option(items[i+to], values[i+to]); 142 i--; 143 } else { 144 srcList.options[i] = new Option(items[i], values[i]); 145 } 146 } 147 srcList.focus(); 148} 149 150function setSelectedValue( frmName, srcListName, value ) { 151 var form = eval( 'document.' + frmName ); 152 var srcList = eval( 'form.' + srcListName ); 153 154 var srcLen = srcList.length; 155 156 for (var i=0; i < srcLen; i++) { 157 srcList.options[i].selected = false;
158 if (srcList.options[i].value == value) { 159 srcList.options[i].selected = true; 160 } 161 } 162} 163 164function getSelectedValue( frmName, srcListName ) { 165 var form = eval( 'document.' + frmName ); 166 var srcList = eval( 'form.' + srcListName ); 167 168 i = srcList.selectedIndex; 169 if (i != null && i > -1) { 170 return srcList.options[i].value; 171 } else { 172 return null; 173 } 174} 175 176function getSelectedText( frmName, srcListName ) { 177 var form = eval( 'document.' + frmName ); 178 var srcList = eval( 'form.' + srcListName ); 179 180 i = srcList.selectedIndex; 181 if (i != null && i > -1) { 182 return srcList.options[i].text; 183 } else { 184 return null; 185 } 186} 187 188function chgSelectedValue( frmName, srcListName, value ) { 189 var form = eval( 'document.' + frmName ); 190 var srcList = eval( 'form.' + srcListName ); 191 192 i = srcList.selectedIndex; 193 if (i != null && i > -1) { 194 srcList.options[i].value = value; 195 return true; 196 } else { 197 return false; 198 } 199} 200 201// Form specific functions for editting content images 202 203function showImageProps(base_path) { 204 form = document.adminForm; 205 value = getSelectedValue( 'adminForm', 'imagelist' ); 206 parts = value.split( '|' ); 207 form._source.value = parts[0]; 208 setSelectedValue( 'adminForm', '_align', parts[1] || 'left' ); 209 form._alt.value = parts[2] || ''; 210 form._border.value = parts[3] || '0'; 211 212 previewImage( 'imagelist', 'view_imagelist', base_path ); 213} 214 215function applyImageProps() { 216 form = document.adminForm; 217 if (!getSelectedValue( 'adminForm', 'imagelist' )) { 218 alert( "Select and image from the list" ); 219 return; 220 } 221 value = form._source.value + '|' 222 + getSelectedValue( 'adminForm', '_align' ) + '|' 223 + form._alt.value + '|' 224 + parseInt( form._border.value ); 225 chgSelectedValue( 'adminForm', 'imagelist', value ); 226} 227 228function previewImage( list, image, base_path ) { 229 form = document.adminForm; 230 srcList = eval( "form." + list ); 231 srcImage = eval( "document." + image ); 232 var fileName = srcList.options[srcList.selectedIndex].text; 233 var fileName2 = srcList.options[srcList.selectedIndex].value; 234 if (fileName.length == 0 || fileName2.length == 0) { 235 srcImage.src = 'images/blank.gif'; 236 } else {
237 srcImage.src = base_path + fileName; 238 } 239} 240 241/** 242* Toggles the check state of a group of boxes 243* 244* Checkboxes must have an id attribute in the form cb0, cb1... 245* @param The number of box to 'check' 246*/ 247function checkAll( n ) { 248 var f = document.adminForm; 249 var c = f.toggle.checked; 250 var n2 = 0; 251 for (i=0; i < n; i++) { 252 cb = eval( 'f.cb' + i ); 253 if (cb) { 254 cb.checked = c; 255 n2++; 256 } 257 } 258 if (c) { 259 document.adminForm.boxchecked.value = n2; 260 } else { 261 document.adminForm.boxchecked.value = 0; 262 } 263} 264 265/** 266*/ 267function listItemTask( id, task ) { 268 var f = document.adminForm; 269 cb = eval( 'f.' + id ); 270 if (cb) { 271 cb.checked = true; 272 submitbutton(task); 273 } 274 return false; 275} 276 277function isChecked(isitchecked){ 278 if (isitchecked == true){ 279 document.adminForm.boxchecked.value++; 280 } 281 else { 282 document.adminForm.boxchecked.value--; 283 } 284} 285 286/** 287* Default function. Usually would be overriden by the component 288*/ 289function submitbutton(pressbutton) { 290 submitform(pressbutton); 291} 292 293/** 294* Submit the admin form 295*/ 296function submitform(pressbutton){ 297 document.adminForm.task.value=pressbutton; 298 try { 299 document.adminForm.onsubmit(); 300 } 301 catch(e){} 302 document.adminForm.submit(); 303} 304 305/** 306* Getting radio button that is selected. 307*/ 308function getSelected(allbuttons){ 309 for (i=0;i<allbuttons.length;i++) { 310 if (allbuttons[i].checked) { 311 return allbuttons[i].value 312 } 313 } 314} 315 316// JS Calendar 317var calendar = null; // remember the calendar object so that we reuse 318// it and avoid creating another 319 320// This function gets called when an end-user clicks on some date 321function selected(cal, date) { 322 cal.sel.value = date; // just update the value of the input field 323} 324 325// And this gets called when the end-user clicks on the _selected_ date, 326// or clicks the "Close" (X) button. It just hides the calendar without 327// destroying it. 328function closeHandler(cal) { 329 cal.hide(); // hide the calendar 330 331 // don't check mousedown on document anymore (used to be able to hide the 332 // calendar when someone clicks outside it, see the showCalendar function). 333 Calendar.removeEvent(document, "mousedown", checkCalendar); 334} 335 336// This gets called when the user presses a mouse button anywhere in the 337// document, if the calendar is shown. If the click was outside the open 338// calendar this function closes it. 339function checkCalendar(ev) { 340 var el = Calendar.is_ie ? Calendar.getElement(ev) : Calendar.getTargetElement(ev); 341 for (; el != null; el = el.parentNode) 342 // FIXME: allow end-user to click some link without closing the 343 // calendar. Good to see real-time stylesheet change :) 344 if (el == calendar.element || el.tagName == "A") break; 345 if (el == null) { 346 // calls closeHandler which should hide the calendar. 347 calendar.callCloseHandler(); Calendar.stopEvent(ev); 348 } 349} 350 351// This function shows the calendar under the element having the given id. 352// It takes care of catching "mousedown" signals on document and hiding the 353// calendar if the click was outside. 354function showCalendar(id) { 355 var el = document.getElementById(id); 356 if (calendar != null) { 357 // we already have one created, so just update it. 358 calendar.hide(); // hide the existing calendar 359 calendar.parseDate(el.value); // set it to a new date 360 } else { 361 // first-time call, create the calendar 362 var cal = new Calendar(true, null, selected, closeHandler); 363 calendar = cal; // remember the calendar in the global 364 cal.setRange(1900, 2070); // min/max year allowed 365 calendar.create(); // create a popup calendar 366 } 367 calendar.sel = el; // inform it about the input field in use 368 calendar.showAtElement(el); // show the calendar next to the input field 369 370 // catch mousedown on the document 371 Calendar.addEvent(document, "mousedown", checkCalendar); 372 return false; 373} 374 375/** 376* Pops up a new window in the middle of the screen 377*/ 378function popupWindow(mypage, myname, w, h, scroll) { 379 var winl = (screen.width - w) / 2; 380 var wint = (screen.height - h) / 2; 381 winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable' 382 win = window.open(mypage, myname, winprops) 383 if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); } 384}
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.