[Rt-commit] r4351 - in rt/branches/3.7-EXPERIMENTAL: . html
html/NoAuth html/NoAuth/js
ruz at bestpractical.com
ruz at bestpractical.com
Sun Dec 25 04:12:21 EST 2005
Author: ruz
Date: Sun Dec 25 02:45:23 2005
New Revision: 4351
Removed:
rt/branches/3.7-EXPERIMENTAL/html/NoAuth/cascaded.js
rt/branches/3.7-EXPERIMENTAL/html/NoAuth/combobox.js
rt/branches/3.7-EXPERIMENTAL/html/rt.js
Modified:
rt/branches/3.7-EXPERIMENTAL/ (props changed)
rt/branches/3.7-EXPERIMENTAL/html/Elements/Submit
rt/branches/3.7-EXPERIMENTAL/html/NoAuth/js/cascaded.js
rt/branches/3.7-EXPERIMENTAL/html/NoAuth/js/combobox.js
rt/branches/3.7-EXPERIMENTAL/html/NoAuth/js/util.js
Log:
r1557 at cubic-pc: cubic | 2005-12-25 10:48:45 +0300
r1554 at cubic-pc: cubic | 2005-12-24 19:01:37 +0300
* delete duplicate .js files
* addClass and delClass functions
* setVisibility util
* get rid of style.display=[none,block]
* setCheckbox(form, name, state) function that set all checkbox
inputs under form element with defined name to the state.
* update Submit element according to new changes
Modified: rt/branches/3.7-EXPERIMENTAL/html/Elements/Submit
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/html/Elements/Submit (original)
+++ rt/branches/3.7-EXPERIMENTAL/html/Elements/Submit Sun Dec 25 02:45:23 2005
@@ -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.7-EXPERIMENTAL/html/NoAuth/js/cascaded.js
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/html/NoAuth/js/cascaded.js (original)
+++ rt/branches/3.7-EXPERIMENTAL/html/NoAuth/js/cascaded.js Sun Dec 25 02:45:23 2005
@@ -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.7-EXPERIMENTAL/html/NoAuth/js/combobox.js
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/html/NoAuth/js/combobox.js (original)
+++ rt/branches/3.7-EXPERIMENTAL/html/NoAuth/js/combobox.js Sun Dec 25 02:45:23 2005
@@ -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.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 Sun Dec 25 02:45:23 2005
@@ -1,21 +1,70 @@
+
// 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;
+}
+
+/* Visibility */
+
+function show(id) { delClass( id, 'hidden' ) }
+function hide(id) { addClass( id, 'hidden' ) }
+function hideshow(id) { toggleVisibility( id ) }
+
+function toggleVisibility(id) {
+ var e = $(id);
+
+ if ( e.className.match( /\bhidden\b/ ) )
+ show(e);
+ else
+ hide(e);
- for (var i = 0; i < arguments.length; i++) {
- var element = arguments[i];
- if (typeof element == 'string')
- element = document.getElementById(element);
+ return false;
+}
+
+function setVisibility(id, visibility) {
+ if ( visibility ) show(id);
+ else hide(id);
+}
- if (arguments.length == 1)
- return element;
+function switchVisibility(id1, id2) {
+ // Show both and then hide the one we want
+ show(id1);
+ show(id2);
+ hide(id2);
+ return false;
+}
- elements.push(element);
- }
+/* Classes */
- return elements;
+function addClass(id, value) {
+ var e = $(id);
+ if ( e.className.match( new RegExp('\b'+ value +'\b') ) )
+ return;
+ if ( e.className )
+ e.className += ' ';
+ e.className += 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;
@@ -47,43 +96,47 @@
}
}
-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 +144,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 +168,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