element, 27 parallel effects, 429–430 Parallel( ) method, 430 parameters property, 398 :parent expression, 387 parentheses, 32–33 parentRule property, 69, 205, 430 parse error, 31 parseInt( ) method, 531 parseJSON( ) method, 299 :password element, 387 /path/to/faux-select.css file, 530 p.faux-value element, 527, 531 Phark method, 209 photo cropping and resizing tool, 249–281 editor objects, 254–281 adding event listeners to the editor objects, 270–272 creating editor markup and objects, 262–270 cropping image, 276–280 imageEditor load event, 260–262 566 incomplete image editor, 280–281 invoking imageEditor tool, 259–260 overview, 254–259 resizing image, 272–276 overview, 249 test files, 250–254 php5-APC folder, 351 png file, 351 point.lat( ) method, 465 point.lng( ) method, 465 popup class, 12 popup CSS selector, 12 popup( ) function, 10 popupLoadEvent.js script, 11 position property, 416 position:absolute element, 529 POST request, 288, 294, 346, 350, 362, 369, 488 postBody property, 398 preload( ) function, 44 prependChild( ) method, 116 preventDefault( ) method, 176, 188, 190 previousSibling property, 110 private members, 65, 67–68 privileged members, 65, 67–68 processAttribute( ) method, 136–146 ProcessingInstruction.nodeName object, 104 ProcessingInstruction.nodeValue object, 105 processNode( ) method, 136–146 product-item draggable, 446 progressBar element, 363 progressContainer class, 363 progressive enhancement, Prototype library, 379, 390 prototype property, 63–64, 70, 520 prototype.js file, 414 proxy scripts Basecamp, 491–495 Flickr buddy icons, 499–502 public methods, 64–65, 67–68, 80 PUT request, 294 px postfix, 259 Q queue option, 429 quotes, 31 R :radio element, 387 Range module, 95 reading event, 150 readyState property, 288–289 referencing, 40 referrer property, 126 RegExp object, 52 register( ) method, ADS.actionPager, 322–323 INDEX registering events, 178–185, 392–394 ADS.addEvent( ) method, 178–179 DOMAssistant way, 392 inline registration model, 178 jQuery way, 393–394 load events, 183–185 Microsoft-specific event model, 181 overview, 392 traditional event model, 179–180 W3C DOM2 Events model, 181–183 registerListener( ) function, 37 registerMultiStateAnchorListeners( ) function, 48 rel="stylesheet" attribute, 221 removeAttribute(name) method, 119 removeAttributeNode(oldAttr) method, 119 removeChild( ) method, 117, 119 removeClassName(element, class) method, 219 removeEvent( ) method, 24 removerEventListener( ) method, 182 removeStyleSheet( ) method, 229 removing extra markup, 210–213 style sheets, 228–229 repeat( ) method, 132 replaceImage( ) method, 237 replaces_join-state object, 519 replaces_something element, 526 representational state transfer (REST), 457 request property, 290 requestHeaders property, 398 requests asynchronous, 329–334 making, 287–288 :reset element, 387 reset events, 159–161, 177 resize events, 153, 177 resizing images, 272–276 resizing tool See photo cropping and resizing tool responseJSON property, 312 responses, acting on, 288–291 responseText property, 288–289, 296–297 responseXML property, 288–289, 297 REST (representational state transfer), 457 restorecolor option, 428 returnValue property, 176 reusable objects, 19–30, 51–87 ADS library, 20–21 ADS.$( ) method, 22–24 ADS.addEvent( ) method, 24–26 ADS.getElementsByClassName( ) method, 26–28 ADS.insertAfter( ) method, 28–29 ADS.isCompatible( ) method, 21–22 ADS.prependChild( ) method, 29–30 ADS.removeChildren( ) method, 29–30 ADS.removeEvent( ) method, 24–26 ADS.toggleDisplay( ) method, 28 catch control structure, 76–77 creating, 60–71 constructors, 61–63 object literal, 68–71 overview, 60–61 private members, 65, 67–68 privileged members, 65, 67–68 public methods, 64–65, 67–68 static methods, 63–64, 67–68 definition, 52–60 closures, 60 inheritance, 53 object members, 53–56 scope, 60 window objects, 56–60 example, 78–86 JavaScript logging object, 78 myLogger( ) object, 78–80 myLogger.createWindow( ) method, 80–82 myLogger.header( ) method, 85–86 myLogger.write( ) method, 85–86 myLogger.writeRaw( ) method, 82–85 exceptions, 76–77 overview, 51 this keyword, 71–76 apply( ) method, 73–76 call( ) method, 73–76 overview, 71–73 try control structure, 76–77 reusing effects, 417–418 revert option, 438 reverteffect option, 439 RewriteRule object, 337 rounded corners, 435–437 roundElement( ) method, 436 S saveClick( ) method, 395 saveHandle event listener, 280 sayGoodbye( ) method, 74, 76 scaleContent option, 427 scaleFrom option, 428 scaleFromCenter option, 427 scaleMode option, 428 scaleX option, 427 scaleY option, 427 scope, 34–38, 60 Scripaculous library, 429 element, 6, 11, 72, 306–307, 313, 348 Script.aculo.us, 414–415 drag and drop, 438–451 dragging anywhere, 438–439 droppables, 439–440 observers, 448–451 shopping carts, 440–448 visual effects with, 427–430 scroll events, 153, 177 567 INDEX scrollHeight property, 540 scrollTop property, 549 scrollWidth property, 540 select element, 507–553 behavioral modifications, 538–550 adjusting z index, 542–543 closing FauxSelect, 538–541 height, 549–550 keyboard controls, 543–549 classic, 508 clicking, 522–527 closing, 522–527 eliminating original, 551 improving, 509–510 opening, 522–527 overview, 507–508 strategy, 510–522 DOM elements, 518–522 FauxSelect objects, 512–514 files, 511 locating, 515–518 styling, 527–538 select event, 177 selectLI( ) method, 526, 544 selectorText attribute, 235 selectorText property, 235 semicolons (;), 32–33 ; (semicolons), 32–33 send( ) method, 287, 291, 303 separator property, 65–66 server-side APIs, 484–504 Basecamp, 488–498 account information, 489–490 DOM scripts, 495–498 proxy scripts, 491–495 Flickr buddy icons, 498–504 DOM scripts, 502–504 Flickr API key, 499 proxy scripts, 499–502 overview, 484–488 set( ) method, 415–417, 533 setActiveStyleSheet( ) function, 225 setAttribute( ) method, 119, 143 setAttributeNode(newAttr) method, 119 setInterval( ) method, 185, 348, 406, 431 setNumericStyle(element,dimensions,message) method, 259 setProperty( ) method, 214 setRequestHeader( ) method, 287, 291 setRoot( ) method, 477 setSiteRestrictions( ) method, 476 setStyleById( ) method, 214 setStylesByClassName( ) method, 214 setStylesByTagName( ) method, 214 setTimeout( ) method, 244, 369, 406, 431 shifting content, 412–413 shopping carts, 440–448 568 showNodeName property, 19 sibling selectors (+), 384 + (sibling selectors), 384 Simple Object Access Protocol (SOAP), 457 simplexml_load_file( ) method, 501 singleImageAnchors variable, 388 slideIn( ) method, 419 slideOut( ) method, 419 slider effects, 418–420 snap option, 438 SOAP (Simple Object Access Protocol), 457 sound variable, 73 source/chapter6/imageEditor-start folder, 250 tag, 207 src property, 47 srcElement property, 192 standards compliant, start( ) method, 415–418 startcolor option, 428 starteffect option, 439 stateChangeListener( ) method, 288–289 static methods, 63–64, 67–68 status property, 288–289, 312 statusText property, 288, 312 stop( ) method, 536 stopPropagation( ) method, 175–176, 188, 190 + (string concatenation operator), 32 string concatenation operator (+), 32 String object, 52, 56, 131 style attribute, 6, 144 style, modifying, 203–247 accessing computed style, 237–238 example, 244–246 Microsoft filter property, 239–244 modifying markup for style, 206–207, 213 separating style and markup, 213–237 W3C DOM2 Style specification, 203–206 style property, 76, 213–216 tags, 204 style.css file, 360 StyleSheets module, 94 styling, select element, 527–538 :submit element, 387 submit event, 166, 177, 365 switching style sheets, 220–229 alternative style sheets, 221–225 className switching on body tags, 225–228 loading, 228–229 removing, 228–229 sync option, 428 T tag elements, 383 tag filter, 27 tagA elements, 383 tagA > tagB elements, 384 INDEX tagA + tagB elements, 384 tag[attr] attribute, 383 tag[attr~=value] attribute, 383 tag[attr$=value] attribute, 383 tag[attr=value] attribute, 383 tag[attr|=value] attribute, 383 tag[attr!=value] attribute, 383 tagB elements, 383 tagC elements, 383 tag:checked selector, 384 tag.className elements, 383 tag:disabled selector, 384 tag:empty selector, 384 tag:enabled selector, 384 tag:first-child selector, 384 tag:first-of-type selector, 384 tag#id elements, 383 tag:last-child selector, 384 tag:last-of-type selector, 384 tag:not(s) selector, 384 tag:nth-child(n) selector, 384 tag:nth-last-child(n) selector, 384 tag:nth-last-of-type(n) selector, 384 tag:nth-of-type(n) selector, 384 tag:only-child selector, 384 tag:only-of-type selector, 384 tag:root selector, 384 Tamperdata, 98 Tango Icon Library, 347 target attribute, 8, 362 target property, 189–190 tb-rl property, 416 test.html file, 251, 259, 511 :text element, 387 Text nodes, 101, 116 TEXT_NODE nodes, 139 Text.nodeName object, 104 TEXT_NODES node, 141 Text.nodeValue object, 105 this keyword, 66, 71–76, 180, 190, 324 apply( ) method, 73–76 call( ) method, 73–76 overview, 71–73 this keyword method, 179 this.createWindow( ) method, 83 this.flip( ) method, 535 this.preventClose property, 549 this.select.getElementsByTagName( 'option' ) method, 520 this.value.appendChild( ) method, 520 timestamp property, 189 title property, 69, 126, 189, 221 to option, 428 todo argument, 494 toggle( ) method, 420 toString( ) method, 56, 194 traceroute request, 327 tracking location changes, 316–324 transition option, 428 transition property, 415 Traversal module, 95 traversing document trees, 122–124 trim( ) method, 132, 139 true property, 416 try/catch control, 77 try control structure, 76–77 type property, 69, 189, 221 U UIEvents module, 95 ul.faux-select element, 527–528, 531 unit property, 415 unload events, 151–152, 177 unobtrusive object, unobtrusiveRollovers.js script file, 45 updateFaux( ) method, 546 updateGalleryList( ) method, 343 updatePhoto( ) method, 343 updateProgressBar( ) method, 364, 369 uploader.js file, 352, 354, 357 URL property, 126 username file, 352 V val property, 522, 527 Validation module, 95 var example2 = function( ) syntax, 70 var keyword, 35, 65 verifyFileType( ) method, 359 version checking, 14–16 vertical option, 419 Views module, 94 visibility property, 413 visibility:hidden property, 413 :visible expression, 387 visual effects, 405–452 accessibility, 407–410 behavioral enhancements, 437–451 feedback, 411–413 overview, 411 shifting content, 412–413 Yellow Fade Technique (YFT), 411 libraries, 414–415, 437 Moo.fx, 414–415, 430, 434–435 rounded corners, 435–437 Script.aculo.us, 414–415, 427, 429–430 overview, 405–407 visual effects libraries, 414–415 569 INDEX W W3C DOM-specific events, 165–166 W3C DOM2 Style specification, 203, 206 browser support, 206 CSSStyleDeclaration objects, 205–206 CSSStyleRule objects, 204–205 CSSStyleSheet objects, 204 wait property, 415 waitListener property, 313 walkElementsLinear( ) method, 123 walkTheDom( ) function, 124 walkTheDOMRecursive( ) method, 124, 135 Web Developer toolbar, 98 “what you see is what you get” (WYSIWYG) editor, 30 width property, 416 window method, 19 window namespace, 379 window objects, 19, 35, 56–60, 73, 76, 151 window.alert( ) function, 59 window.document property, 121 window.location object, 316 window.location.href property, 315 window.onload function, 26 window.open( ) method, write( ) method, 79, 85–86 writeRaw( ) method, 79, 82, 84 writingMode property, 416 WYSIWYG (“what you see is what you get”) editor, 30 X X-ADS-Ajax-Request header, 304 X-JSON header, 398 X-Prototype-Version header, 398 X-Requested-With header, 398 XHTML (Extensible HyperText Markup Language), 4, 286 XML, 295–299 HTML, 296–297 JavaScript code, 297 JavaScript Object Notation (JSON), 298–299 overview, 295–296 plain text, 296 XML module, 94 XML-RPC (XML remote procedure calls), 457 XMLHttpRequest object, 286–295, 299, 306, 325, 345, 348, 398 acting on responses, 288–291 identifying Ajax requests, 291–293 making requests, 287–288 methods, 294–295 overview, 286–287 570 XMLHttpRequest onreadystatechange method, 246 XMLHttpRequest requests, 293 xmlResponseListener listener, 304 XPath, jQuery with, 385–387 XSS-HTTP-REQUEST-CALLBACK variable, 311 XssHttpRequest object, 312 Y Yahoo Libraries, 17 Yahoo! User Interface (YUI) library, 379–380, 390–391 YAHOO.util.Dom.getElementBy( ) method, 388 YAHOO.util.Dom.getRegion(String | HTMLElement | Array) method, 390 YAHOO.util.Region object, 390 Yellow Fade Technique (YFT), 411 YUI (Yahoo! User Interface) library, 379–380, 390–391 Z z index, 542–543 zindex option, 439 .. .AdvancED DOM Scripting Dynamic Web Design Techniques Jeffrey Sambells with Aaron Gustafson AdvancED DOM Scripting: Dynamic Web Design Techniques Copyright © 2007 by... and why these advanced concepts work—not just what they to your document Who this book is for AdvancED DOM Scripting: Dynamic Web Design Techniques is for any web developer or designer who’s... still work as expected: ➥ AdvancED DOM Scripting< /a>