Forms JS Library Extensions
mu2.js- attaches extra functions to mu.js (docs). You may want to customize these (esp setWait).
- stripeTable(tableId or obj, alternate classname) - alternate rows (Tr) of the table are assigned the classname. Breaks if rowspan used or with nested tables.
| A1 |
B1 |
C1 |
| A2 |
B2 |
C2 |
| A3 |
B3 |
C3 |
| A4 |
B4 |
C4 |
| A5 |
B5 |
C5 |
- getWindowHeight - cross browser viewport height. Because height-100% isn't reliable.
- getHTMLDimensions - returns object with height and width properties for the html/body size. Used by setWait when covering the page with a mask.
- getViewPortDimensions = returns object with height and width properties for the viewport (window) size. Used by setWait when covering the page with a mask.
- setWait/ stopWait - attach this event to from submit to show a "Please Wait..." message with the form "greyed out" by a mask. If you cancel the submit, use stopWait to remove the message and mask.
The mask has a height of document.documentElement.scrollHeight and width of document.documentElement.scrollWidth
There's a lot of styles here that should be customized (and you may want to add images etc- note IE stops animations when submitting so setTimeout('document.images["wait"].src = "images/wait.gif"', 200); )
For ASP.Net Ajax UpdatePanels, use this: //ms ajax handler
var mgr = Sys.WebForms.PageRequestManager.getInstance();
//tell ms ajax to fire my events during partial postbacks
mgr.add_initializeRequest(initializeRequest);
mgr.add_endRequest(requestEnd);
var timeoutID; //waits 1/2 sec after postback before showing
function initializeRequest(sender, args)
{ //fired when postback submits.
timeoutID = setTimeout(timedWait, 1000);
}
function timedWait()
{ //starts the waiting message (after wait)
timeoutID = null;
mu.setWait();
}
function requestEnd(sender, args)
{ //fired when partial postback returns. If within timeout, don't do anything
if(timeoutID) clearTimeout(timeoutID);
else mu.stopWait(); //remove the waiting message
}
- addOption/ removeOption/ selectAll - for select boxes.
addOption(id, value) sets both the option text and value. The second argument can be a reference to another field (eg a textbox or another select box).
removeOption(id, value) removes either a specified option (= value argument) or (if no argument) all the selected options.
selectAll(id) - selects all options (if it's multiple-select).