[Rt-commit] r4375 - in rt/branches/3.7-EXPERIMENTAL: .
ruz at bestpractical.com
ruz at bestpractical.com
Thu Jan 12 00:23:54 EST 2006
Author: ruz
Date: Thu Jan 12 00:23:53 2006
New Revision: 4375
Modified:
rt/branches/3.7-EXPERIMENTAL/ (props changed)
rt/branches/3.7-EXPERIMENTAL/html/NoAuth/js/util.js
Log:
r1618 at cubic-pc: cubic | 2006-01-12 08:29:01 +0300
r1597 at cubic-pc: cubic | 2005-12-27 15:09:12 +0300
* JS fixes
Modified: rt/branches/3.7-EXPERIMENTAL/html/NoAuth/js/util.js
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/html/NoAuth/js/util.js (original)
+++ rt/branches/3.7-EXPERIMENTAL/html/NoAuth/js/util.js Thu Jan 12 00:23:53 2006
@@ -1,5 +1,9 @@
-// Stolen from Prototype
+/* $(...)
+ Returns DOM node or array of nodes (if more then one argument passed).
+ If argument is node object allready then do nothing.
+ // Stolen from Prototype
+*/
function $() {
var elements = new Array();
@@ -21,8 +25,8 @@
function show(id) { delClass( id, 'hidden' ) }
function hide(id) { addClass( id, 'hidden' ) }
-function hideshow(id) { toggleVisibility( id ) }
+function hideshow(id) { return toggleVisibility( id ) }
function toggleVisibility(id) {
var e = $(id);
@@ -53,14 +57,12 @@
var e = $(id);
if ( e.className.match( new RegExp('\b'+ value +'\b') ) )
return;
- if ( e.className )
- e.className += ' ';
- e.className += value;
+ e.className += e.className? ' '+value : value;
}
function delClass(id, value) {
var e = $(id);
- e.className = e.className.replace( new RegExp('\s?\b'+ value +'\b', 'g'), '' );
+ e.className = e.className.replace( new RegExp('\\s?\\b'+ value +'\\b', 'g'), '' );
}
/* Rollups */
@@ -84,14 +86,11 @@
if (e && e2) {
if (state == 'shown') {
show(e);
- e2.className = e2.className.replace(/\s?\brolled-up\b/, '');
+ delClass( e2, 'rolled-up' );
}
else if (state == 'hidden') {
hide(e);
- if (e2.className)
- e2.className += ' rolled-up';
- else
- e2.className = 'rolled-up';
+ addClass( e2, 'rolled-up' );
}
}
}
@@ -105,7 +104,7 @@
function onLoadHook(commandStr) {
if(typeof(commandStr) == "string") {
- onLoadStack[onLoadStack.length] = commandStr;
+ onLoadStack[ onLoadStack.length ] = commandStr;
return true;
}
return false;
@@ -182,7 +181,7 @@
}
}
-function addEvent(obj, sType, fn){
+function addEvent(obj, sType, fn) {
if (obj.addEventListener) {
obj.addEventListener(sType, fn, false);
} else if (obj.attachEvent) {
@@ -193,7 +192,7 @@
return true;
}
-function setCheckbox (form, name, val) {
+function setCheckbox(form, name, val) {
var myfield = form.getElementsByTagName('input');
for ( var i = 0; i < myfield.length; i++ ) {
if ( name && myfield[i].name != name ) continue;
More information about the Rt-commit
mailing list