[Rt-commit] r4390 - in rt/branches/3.5-TESTING/html: NoAuth/js
ruz at bestpractical.com
ruz at bestpractical.com
Fri Jan 13 06:41:23 EST 2006
Author: ruz
Date: Fri Jan 13 06:41:20 2006
New Revision: 4390
Modified:
rt/branches/3.5-TESTING/html/Elements/Submit
rt/branches/3.5-TESTING/html/NoAuth/js/cascaded.js
rt/branches/3.5-TESTING/html/NoAuth/js/combobox.js
rt/branches/3.5-TESTING/html/NoAuth/js/util.js
Log:
* addClass and delClass functions
* setVisibility util
* get rid of style.display=[none,block]
* setCheckbox(form, name, state) function that set all checkbox
inputs under the form element with defined name to the state.
* update Submit element according to new changes
Modified: rt/branches/3.5-TESTING/html/Elements/Submit
==============================================================================
--- rt/branches/3.5-TESTING/html/Elements/Submit (original)
+++ rt/branches/3.5-TESTING/html/Elements/Submit Fri Jan 13 06:41:20 2006
@@ -43,26 +43,13 @@
%# those contributions and any derivatives thereof.
%#
%# END BPS TAGGED BLOCK }}}
-% if ($CheckAll or $ClearAll) {
-<script type="text/javascript"><!--
-function set_checkbox (obj, val) {
- var i;
- var myfield = obj.form.getElementsByTagName('input');
- for (i = 0; i < myfield.length; i++) {
- if (myfield[i].type == 'checkbox') {
- myfield[i].checked = val;
- }
- }
-}
---></script>
-% }
<div class="submit">
<div class="extra-buttons">
% if ($CheckAll) {
- <input type="button" value="<%$CheckAllLabel%>" onclick="set_checkbox(this, true);return false;" class="button" />
+ <input type="button" value="<%$CheckAllLabel%>" onclick="setCheckbox(this.form, '<% $CheckboxName %>', true);return false;" class="button" />
% }
% if ($ClearAll) {
- <input type="button" value="<%$ClearAllLabel%>" onclick="set_checkbox(this, false);return false;" class="button" />
+ <input type="button" value="<%$ClearAllLabel%>" onclick="setCheckbox(this.form, '<% $CheckboxName %>', false);return false;" class="button" />
% }
% if ($Reset) {
<input type="reset" class="button" value="<%$ResetLabel%>" class="button" />
@@ -91,6 +78,7 @@
$CheckAllLabel => loc('Check All')
$ClearAll => undef
$ClearAllLabel => loc('Clear All')
+$CheckboxName => ''
$Reset => undef
$ResetLabel => loc('Reset')
</%ARGS>
Modified: rt/branches/3.5-TESTING/html/NoAuth/js/cascaded.js
==============================================================================
--- rt/branches/3.5-TESTING/html/NoAuth/js/cascaded.js (original)
+++ rt/branches/3.5-TESTING/html/NoAuth/js/cascaded.js Fri Jan 13 06:41:20 2006
@@ -4,16 +4,10 @@
var i;
var children = select.childNodes;
for (i in children) {
- var style = children[i].style;
- if (!style) { continue };
- if (val == '') {
- style.display = 'block';
+ if ( val == '' || children[i].label.substr(0, val.length) == val) {
+ show(children[i]);
continue;
}
- if (children[i].label.substr(0, val.length) == val) {
- style.display = 'block';
- continue;
- }
- style.display = 'none';
+ hide(children[i]);
}
}
Modified: rt/branches/3.5-TESTING/html/NoAuth/js/combobox.js
==============================================================================
--- rt/branches/3.5-TESTING/html/NoAuth/js/combobox.js (original)
+++ rt/branches/3.5-TESTING/html/NoAuth/js/combobox.js Fri Jan 13 06:41:20 2006
@@ -186,23 +186,8 @@
this.IsShowing = false;
}
}
-function ComboBox_SetVisibility(theList,isVisible) {
- var isIE = ( typeof( theList.dataSrc ) != "undefined" ); // dataSrc is an IE-only property which is unlikely to be supported elsewhere
- var ua = navigator.userAgent.toLowerCase();
- var isSafari = (ua.indexOf('safari') != - 1);
- if ( isIE || isSafari) {
- if ( isVisible ) {
- theList.style.visibility = "visible";
- } else {
- theList.style.visibility = "hidden";
- }
- } else {
- if ( isVisible ) {
- theList.style.display = "block";
- } else {
- theList.style.display = "none";
- }
- }
+function ComboBox_SetVisibility(theList, isVisible) {
+ setVisibility(theList, isVisible);
}
function ComboBox_RecursiveOffsetTop(thisObject,isFirst) {
if(thisObject.offsetParent) {
Modified: rt/branches/3.5-TESTING/html/NoAuth/js/util.js
==============================================================================
--- rt/branches/3.5-TESTING/html/NoAuth/js/util.js (original)
+++ rt/branches/3.5-TESTING/html/NoAuth/js/util.js Fri Jan 13 06:41:20 2006
@@ -1,21 +1,72 @@
-// 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();
+ var elements = new Array();
+
+ for (var i = 0; i < arguments.length; i++) {
+ var element = arguments[i];
+ if (typeof element == 'string')
+ element = document.getElementById(element);
+
+ if (arguments.length == 1)
+ return element;
+
+ elements.push(element);
+ }
+
+ return elements;
+}
- for (var i = 0; i < arguments.length; i++) {
- var element = arguments[i];
- if (typeof element == 'string')
- element = document.getElementById(element);
+/* Visibility */
- if (arguments.length == 1)
- return element;
+function show(id) { delClass( id, 'hidden' ) }
+function hide(id) { addClass( id, 'hidden' ) }
- elements.push(element);
- }
+function hideshow(id) { return toggleVisibility( id ) }
+function toggleVisibility(id) {
+ var e = $(id);
+
+ if ( e.className.match( /\bhidden\b/ ) )
+ show(e);
+ else
+ hide(e);
+
+ return false;
+}
- return elements;
+function setVisibility(id, visibility) {
+ if ( visibility ) show(id);
+ else hide(id);
}
+function switchVisibility(id1, id2) {
+ // Show both and then hide the one we want
+ show(id1);
+ show(id2);
+ hide(id2);
+ return false;
+}
+
+/* Classes */
+
+function addClass(id, value) {
+ var e = $(id);
+ if ( e.className.match( new RegExp('\b'+ value +'\b') ) )
+ return;
+ 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'), '' );
+}
+
+/* Rollups */
+
function rollup(id) {
var e = $(id);
var e2 = e.parentNode;
@@ -35,55 +86,56 @@
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' );
}
}
}
-function hideshow(id) {
- var e = $(id);
-
- if (e.className.match(/\bhidden\b/))
- show(e);
- else
- hide(e);
- return false;
-}
+/* onload handlers */
-function show(e) {
- e.className = e.className.replace(/\s?\bhidden\b/, '');
-}
+var onLoadStack = new Array();
+var onLoadLastStack = new Array();
+var onLoadExecuted = 0;
-function hide(e) {
- if (e.className)
- e.className += ' hidden';
- else
- e.className = 'hidden';
+function onLoadHook(commandStr) {
+ if(typeof(commandStr) == "string") {
+ onLoadStack[ onLoadStack.length ] = commandStr;
+ return true;
+ }
+ return false;
}
-function switchVisibility(id1, id2) {
- // Show both and then hide the one we want
- show($(id1));
- show($(id2));
-
- hide($(id2));
-
+// some things *really* need to be done after everything else
+function onLoadLastHook(commandStr) {
+ if(typeof(commandStr) == "string"){
+ onLoadLastStack[onLoadLastStack.length] = commandStr;
+ return true;
+ }
return false;
}
-function focusElementById(id) {
- var e = $(id);
- if (e) e.focus();
+function doOnLoadHooks() {
+ if(onLoadExecuted) return;
+
+ var i;
+ for ( i in onLoadStack ) {
+ eval( onLoadStack[i] );
+ }
+ for ( i in onLoadLastStack ) {
+ eval( onLoadLastStack[i] );
+ }
+ onLoadExecuted = 1;
}
+window.onload = doOnLoadHooks;
+
+/* calendar functions */
+
function openCalWindow(field) {
var objWindow = window.open('<%$RT::WebPath%>/Helpers/CalPopup.html?field='+field,
'RT_Calendar',
@@ -91,24 +143,6 @@
objWindow.focus();
}
-function updateParentField(field, value) {
- if (window.opener) {
- window.opener.$(field).value = value;
- window.close();
- }
-}
-
-function addEvent(obj, sType, fn){
- if (obj.addEventListener){
- obj.addEventListener(sType, fn, false);
- } else if (obj.attachEvent) {
- var r = obj.attachEvent("on"+sType, fn);
- } else {
- return false;
- }
- return true;
-}
-
function createCalendarLink(input) {
var e = $(input);
if (e) {
@@ -133,40 +167,38 @@
return false;
}
-// onload handlers
+/* other utils */
-var onLoadStack = new Array();
-var onLoadLastStack = new Array();
-var onLoadExecuted = 0;
+function focusElementById(id) {
+ var e = $(id);
+ if (e) e.focus();
+}
-function onLoadHook(commandStr) {
- if(typeof(commandStr) == "string") {
- onLoadStack[onLoadStack.length] = commandStr;
- return true;
+function updateParentField(field, value) {
+ if (window.opener) {
+ window.opener.$(field).value = value;
+ window.close();
}
- return false;
}
-// some things *really* need to be done after everything else
-function onLoadLastHook(commandStr) {
- if(typeof(commandStr) == "string"){
- onLoadLastStack[onLoadLastStack.length] = commandStr;
- return true;
+function addEvent(obj, sType, fn) {
+ if (obj.addEventListener) {
+ obj.addEventListener(sType, fn, false);
+ } else if (obj.attachEvent) {
+ var r = obj.attachEvent("on"+sType, fn);
+ } else {
+ return false;
}
- return false;
+ return true;
}
-function doOnLoadHooks() {
- if(onLoadExecuted) return;
-
- for (var x=0; x < onLoadStack.length; x++) {
- eval(onLoadStack[x]);
- }
- for (var x=0; x < onLoadLastStack.length; x++) {
- eval(onLoadLastStack[x]);
+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;
+ if ( myfield[i].type != 'checkbox' ) continue;
+
+ myfield[i].checked = val;
}
- onLoadExecuted = 1;
}
-window.onload = doOnLoadHooks;
-
More information about the Rt-commit
mailing list