1// SpryWidget.js - version 0.16 - Spry Pre-Release 1.7 2// 3// Copyright (c) 2009. Adobe Systems Incorporated. 4// All rights reserved. 5// 6// Redistribution and use in source and binary forms, with or without 7// modification, are permitted provided that the following conditions are met: 8// 9// * Redistributions of source code must retain the above copyright notice, 10// this list of conditions and the following disclaimer. 11// * Redistributions in binary form must reproduce the above copyright notice, 12// this list of conditions and the following disclaimer in the documentation 13// and/or other materials provided with the distribution. 14// * Neither the name of Adobe Systems Incorporated nor the names of its 15// contributors may be used to endorse or promote products derived from this 16// software without specific prior written permission. 17// 18// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 22// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28// POSSIBILITY OF SUCH DAMAGE. 29 30(function() { // BeginSpryComponent 31 32if (typeof Spry == "undefined" || !Spry.Utils || !Spry.$$) 33{ 34 alert("SpryWidget.js requires SpryDOMUtils.js"); 35 return; 36} 37 38if (!Spry.Widget) Spry.Widget = {}; 39 40Spry.Widget.setOptions = function(obj, optionsObj, ignoreUndefinedProps) 41{ 42 if (obj && optionsObj) 43 { 44 for (var optionName in optionsObj) 45 { 46 var v = optionsObj[optionName]; 47 if (!ignoreUndefinedProps || v != undefined) 48 obj[optionName] = v; 49 } 50 } 51 return obj; 52}; 53 54Spry.Widget.onLoadDidFire = false; 55Spry.Widget.onLoadQueue = []; 56 57Spry.Widget.addCallbackToOnLoadQueue = function(callbackFunc, context) 58{ 59 if (callbackFunc) 60 { 61 if (context) 62 { 63 var cf = callbackFunc; 64 callbackFunc = function() { cf.call(context); }; 65 } 66 67 Spry.Widget.onLoadQueue.push(callbackFunc); 68 } 69}; 70 71Spry.Widget.triggerCallbackAfterOnLoad = function(callbackFunc, context) 72{ 73 if (Spry.Widget.onLoadDidFire) 74 callbackFunc.call(context); 75 else 76 Spry.Widget.addCallbackToOnLoadQueue(callbackFunc, context); 77 78}; 79 80Spry.Widget.processOnLoadQueue = function() 81{ 82 Spry.Widget.onLoadDidFire = true; 83 var q = Spry.Widget.onLoadQueue; 84 while (q.length) 85 (q.shift())(); 86}; 87 88Spry.Utils.addLoadListener(Spry.Widget.processOnLoadQueue); 89 90Spry.Widget.Base = function() 91{ 92 Spry.Widget.Base.Notifier.call(this); 93}; 94 95Spry.Widget.Base.Notifier = function() 96{ 97 this.observers = []; 98 this.suppressNotifications = 0; 99}; 100 101Spry.Widget.Base.Notifier.prototype.addObserver = function(observer) 102{ 103 if (!observer) 104 return; 105 106 // Make sure the observer isn't already on the list. 107 108 var len = this.observers.length; 109 for (var i = 0; i < len; i++) 110 { 111 if (this.observers[i] == observer) 112 return; 113 } 114 this.observers[len] = observer; 115}; 116 117Spry.Widget.Base.Notifier.prototype.removeObserver = function(observer) 118{ 119 if (!observer) 120 return; 121 122 for (var i = 0; i < this.observers.length; i++) 123 { 124 if (this.observers[i] == observer) 125 { 126 this.observers.splice(i, 1); 127 break; 128 } 129 } 130}; 131 132Spry.Widget.Base.Notifier.prototype.notifyObservers = function(methodName, data) 133{ 134 if (!methodName) 135 return; 136 137 if (!this.suppressNotifications) 138 { 139 var len = this.observers.length; 140 for (var i = 0; i < len; i++) 141 { 142 var obs = this.observers[i]; 143 if (obs) 144 { 145 if (typeof obs == "function") 146 obs(methodName, this, data); 147 else if (obs[methodName]) 148 obs[methodName](this, data); 149 } 150 } 151 } 152}; 153 154Spry.Widget.Base.Notifier.prototype.enableNotifications = function() 155{ 156 if (--this.suppressNotifications < 0) 157 { 158 this.suppressNotifications = 0; 159 Spry.Debug.reportError("Unbalanced enableNotifications() call!\n"); 160 } 161}; 162 163Spry.Widget.Base.Notifier.prototype.disableNotifications = function() 164{ 165 ++this.suppressNotifications; 166};
167 168Spry.Widget.Base.prototype = new Spry.Widget.Base.Notifier(); 169Spry.Widget.Base.prototype.constructor = Spry.Widget.Base; 170 171Spry.Widget.Base.getElement = function(ele) 172{ 173 return Spry.$(ele); 174}; 175 176Spry.Widget.Base.getElements = function(elements) 177{ 178 var eType = typeof elements; 179 if (eType == "string") 180 return Spry.$$(elements); 181 else if (eType == "object") 182 { 183 if (elements.constructor == Array) 184 { 185 var result = []; 186 for (var i = 0; i < elements.length; i++) 187 result = result.concat(Spry.Widget.Base.getElements(elements[i])); 188 return result; 189 } 190 else 191 return [elements]; 192 } 193 194 return []; 195}; 196 197Spry.Widget.Base.getElementsByClassName = function(root, className) 198{ 199 var results = []; 200 201 if (typeof root.getElementsByClassName != "undefined") 202 { 203 // Browser has a native getElementsByClassName(), so use it. 204 205 var nodeList = root.getElementsByClassName(className); 206 for (var i = 0; i < nodeList.length; i++) 207 results.push(nodeList.item(i)); 208 } 209 else 210 { 211 // Browser has no native getElementsByClassName() implementation 212 // so do a manual search. 213 214 var re = new RegExp("\\b" + className + "\\b"); 215 var nodeList = root.getElementsByTagName("*"); 216 for (var i = 0; i < nodeList.length; i++) 217 { 218 var ele = nodeList.item(i); 219 if (ele.className.search(re) != -1) 220 results.push(ele); 221 } 222 } 223 224 return results; 225}; 226 227Spry.Widget.Base.prototype.getElementChildren = function(element) 228{ 229 var children = []; 230 if (element) 231 { 232 var child = element.firstChild; 233 while (child) 234 { 235 if (child.nodeType == 1 /* Node.ELEMENT_NODE */) 236 children.push(child); 237 child = child.nextSibling; 238 } 239 } 240 return children; 241}; 242 243Spry.Widget.Base.prototype.groupContentByDelimeter = function(delimeterElements) 244{ 245 var results = new Array(); 246 247 var numDelims = delimeterElements.length; 248 for (var i = 0; i < numDelims; i++) 249 { 250 var delim = delimeterElements[i]; 251 var group = new Array(); 252 group.push(delim); 253 254 var nextDelim = delimeterElements[i+1]; 255 var sib = delim.nextSibling; 256 while (sib && sib != nextDelim) 257 { 258 group.push(sib); 259 sib = sib.nextSibling; 260 } 261 262 results.push(group); 263 } 264 265 return results; 266}; 267 268Spry.Widget.Base.prototype.createElement = function(elementName, className, parent, child) 269{ 270 var ele = document.createElement(elementName); 271 if (className) ele.className = className; 272 if (parent) parent.appendChild(ele); 273 if (child) ele.appendChild(child); 274 return ele; 275}; 276 277Spry.Widget.Base.prototype.sliceLeftClassStr = "Left"; 278Spry.Widget.Base.prototype.sliceRightClassStr = "Right"; 279Spry.Widget.Base.prototype.sliceCenterClassStr = "Center"; 280Spry.Widget.Base.prototype.sliceTopClassStr = "Top"; 281Spry.Widget.Base.prototype.sliceBottomClassStr = "Bottom"; 282 283Spry.Widget.Base.prototype.sliceFuncs = {}; 284 285Spry.Widget.Base.prototype.sliceFuncs["2slice"] = function(root, eleName, baseClassName) 286{ 287 var a = root ? root : document.createElement(eleName); 288 var b = document.createElement(eleName); 289 290 this.appendChildNodes(b, this.extractChildNodes(a)); // Transfer any children into the new content container. 291 292 a.appendChild(b); 293 294 this.addClassName(a, baseClassName + this.sliceLeftClassStr); 295 b.className = baseClassName + this.sliceRightClassStr; 296 297 a.contentContainer = b; 298 299 return a; 300}; 301 302Spry.Widget.Base.prototype.sliceFuncs["3slice"] = function(root, eleName, baseClassName) 303{ 304 var a = root ? root : document.createElement(eleName); 305 var b = document.createElement(eleName); 306 var c = document.createElement(eleName); 307 308 this.appendChildNodes(c, this.extractChildNodes(a)); // Transfer any children into the new content container. 309 310 a.appendChild(b); 311 b.appendChild(c); 312 313 this.addClassName(a, baseClassName + this.sliceLeftClassStr); 314 b.className = baseClassName + this.sliceRightClassStr; 315 c.className = baseClassName + this.sliceCenterClassStr; 316 317 a.contentContainer = c; 318 319 return a; 320}; 321 322Spry.Widget.Base.prototype.sliceFuncs["3sliceStacked"] = function(root, eleName, baseClassName) 323{ 324 root = root ? root : document.createElement(eleName); 325 326 var l = document.createElement(eleName); 327 var m = document.createElement(eleName); 328 var r = document.createElement(eleName); 329 330 this.appendChildNodes(m, this.extractChildNodes(root)); // Transfer any children into the new content container. 331 332 root.appendChild(l); 333 root.appendChild(m); 334 root.appendChild(r); 335 336 this.addClassName(root, baseClassName); 337 l.className = baseClassName + this.sliceLeftClassStr; 338 m.className = baseClassName + this.sliceCenterClassStr; 339 r.className = baseClassName + this.sliceRightClassStr; 340 341 root.contentContainer = m; 342 343 return root; 344}; 345 346Spry.Widget.Base.prototype.sliceFuncs["9slice"] = function(root, eleName, baseClassName) 347{ 348 if (!root) 349 root = document.createElement(eleName); 350 this.addClassName(root, baseClassName); 351 352 var t = this.create3SliceStructure(null, eleName, baseClassName + this.sliceTopClassStr); 353 var m = this.create3SliceStructure(null, eleName, baseClassName); 354 var b = this.create3SliceStructure(null, eleName, baseClassName + this.sliceBottomClassStr); 355 356 this.appendChildNodes(m.contentContainer, this.extractChildNodes(root)); // Transfer any children into the new content container. 357 358 root.appendChild(t); 359 root.appendChild(m); 360 root.appendChild(b); 361 362 var contentContainer = m.contentContainer; 363 root.contentContainer = contentContainer; 364 contentContainer.rootContainer = root; 365 366 return root; 367}; 368 369// XXX: REMOVE THESE AFTER WIDGETS HAVE BEEN CLEANED UP! 370Spry.Widget.Base.prototype.create3SliceStructure = Spry.Widget.Base.prototype.sliceFuncs["3slice"]; 371Spry.Widget.Base.prototype.create9SliceStructure = Spry.Widget.Base.prototype.sliceFuncs["9slice"]; 372// XXX 373 374Spry.Widget.Base.prototype.createOptionalSlicedStructure = function(root, eleName, className, sliceMap, childEleName) 375{ 376 // root - null or the dom element that will serve as the root of the sliced structure. 377 // If null, this function will create the root container using the element name specified. 378 // eleName - The tag to use when creating the sliced structure. 379 // className - The class names placed on each element within the sliced structure will be derived from this name. 380 // sliceMap - null or a dictionary of class name keys whose values are either "9slice", "3slice", or "none". 381 // If null, the widget's sliceMap property is used. 382 // childEleName - If specified, the eleName arg will only be used for the first element created within the structure. All 383 // other elements will be created with the specified childEleName. 384 385 if (!sliceMap) 386 sliceMap = this.sliceMap ? this.sliceMap : {}; 387 388 if (!childEleName) 389 childEleName = eleName; 390 391 var sliceType = sliceMap[className]; 392 sliceType = sliceType ? sliceType : "none"; 393 394 if (!root) 395 root = document.createElement(eleName); 396 this.addClassName(root, className); 397 398 var sliceFunc = this.sliceFuncs[sliceType]; 399 if (sliceFunc) 400 root = sliceFunc.call(this, root, childEleName, className); 401 else
402 root.contentContainer = root; 403 404 return root; 405}; 406 407Spry.Widget.Base.prototype.extractChildNodes = function(ele) 408{ 409 var children = []; 410 while (ele.firstChild) 411 { 412 var c = ele.firstChild; 413 children.push(c); 414 ele.removeChild(c); 415 } 416 return children; 417}; 418 419Spry.Widget.Base.prototype.appendChildNodes = function(ele, nodes) 420{ 421 for (var i = 0; i < nodes.length; i++) 422 ele.appendChild(nodes[i]); 423}; 424 425Spry.Widget.Base.prototype.setOptions = Spry.Widget.setOptions; 426Spry.Widget.Base.prototype.getOnLoadDidFire = function() { return Spry.Widget.onLoadDidFire; }; 427Spry.Widget.Base.prototype.addCallbackToOnLoadQueue = Spry.Widget.addCallbackToOnLoadQueue; 428Spry.Widget.Base.prototype.triggerCallbackAfterOnLoad = Spry.Widget.triggerCallbackAfterOnLoad; 429 430Spry.Widget.Base.prototype.getElement = Spry.Widget.Base.getElement; 431Spry.Widget.Base.prototype.getElements = Spry.Widget.Base.getElements; 432Spry.Widget.Base.prototype.addClassName = Spry.Utils.addClassName; 433Spry.Widget.Base.prototype.hasClassName = Spry.Utils.hasClassName; 434Spry.Widget.Base.prototype.removeClassName = Spry.Utils.removeClassName; 435Spry.Widget.Base.prototype.addEventListener = Spry.Utils.addEventListener; 436Spry.Widget.Base.prototype.removeEventListener = Spry.Utils.removeEventListener; 437 438Spry.Widget.Base.prototype.indexOf = function(a, v) 439{ 440 // IE6 doesn't support indexOf on Arrays so we need to check 441 // for built-in support first. If not found manually do the 442 // search. 443 if (a) 444 { 445 if (a.indexOf) 446 return a.indexOf(v); 447 for (var i = 0; i < a.length; i++) 448 if (a[i] == v) 449 return i; 450 } 451 return -1; 452}; 453 454Spry.Widget.Base.prototype.initializePlugIns = function(defaultPlugIns, widgetOpts) 455{ 456 var evt = new Spry.Widget.Event(this); 457 this.notifyObservers("onPreInitializePlugIns", evt); 458 if (!evt.performDefaultAction) 459 return; 460 461 // Both defaultPlugIns and widgetOpts are optional so make sure 462 // we have always have something to work with. 463 464 var opts = widgetOpts ? widgetOpts : {}; 465 var useDefaults = (typeof opts.useDefaultPlugIns == "undefined") ? true : opts.useDefaultPlugIns; 466 467 var dp = (useDefaults && defaultPlugIns) ? defaultPlugIns : []; 468 var np = opts.plugIns ? opts.plugIns : []; 469 470 // Build a list of unique plugins from the default and user-specified sets. 471 472 var plugIns = []; 473 var plist = dp.concat(np); 474 for (var i = 0; i < plist.length; i++) 475 { 476 var p = plist[i]; 477 if (this.indexOf(plugIns, p) < 0) 478 plugIns.push(p); 479 } 480 481 // Sort the resulting set of plugins based on priority. 482 483 plugIns = plugIns.sort(function(a, b) 484 { 485 var ap = (typeof a.priority == "undefined") ? 50 : a.priority; 486 var bp = (typeof b.priority == "undefined") ? 50 : b.priority; 487 return ap - bp; 488 }); 489 490 // Store the sorted list of plugins on the widget. 491 492 this.plugIns = plugIns; 493 494 // Instantiate each plugin. 495 496 for (var i = 0; plugIns && i < plugIns.length; i++) 497 { 498 if (plugIns[i].initialize) 499 plugIns[i].initialize(this); 500 } 501 502 this.notifyObservers("onPostInitializePlugIns", evt); 503}; 504 505Spry.Widget.Base.prototype.getClientPosition = function(ele) 506{ 507 var pos = new Object; 508 pos.x = ele.offsetLeft; 509 pos.y = ele.offsetTop; 510 var parent = ele.offsetParent; 511 while (parent) 512 { 513 pos.x += parent.offsetLeft; 514 pos.y += parent.offsetTop; 515 parent = parent.offsetParent; 516 } 517 return pos; 518}; 519 520Spry.Widget.Base.prototype.getStyleProp = function(element, prop) 521{ 522 var value; 523 var camelized = Spry.Utils.camelizeString(prop); 524 try 525 { 526 if (element.style) 527 value = element.style[camelized]; 528 529 if (!value) 530 { 531 if (document.defaultView && document.defaultView.getComputedStyle) 532 { 533 var css = document.defaultView.getComputedStyle(element, null); 534 value = css ? css.getPropertyValue(prop) : null; 535 } 536 else if (element.currentStyle) 537 { 538 value = element.currentStyle[camelized]; 539 } 540 } 541 } 542 catch (e) {} 543 544 return value == 'auto' ? null : value; 545}; 546 547Spry.Widget.Base.prototype.makePositioned = function(element) 548{ 549 var pos = this.getStyleProp(element, 'position'); 550 if (!pos || pos == 'static') 551 { 552 element.style.position = 'relative'; 553 554 // Opera returns the offset relative to the positioning context, when an 555 // element is position relative but top and left have not been defined 556 if (window.opera) 557 { 558 element.style.top = 0; 559 element.style.left = 0; 560 } 561 } 562}; 563 564Spry.Widget.Base.prototype.clearIEAlphaFilter = function(ele) 565{ 566 var filter = ele.style.filter; 567 568 // IE uses an alpha() filter for opacity. The filter style 569 // property can contain multiple commands, so the idea here 570 // is to just strip out the alpha(filter) and append a new
571 // one, leaving any other filters untouched. 572 573 if (filter) 574 { 575 filter = filter.replace(/alpha\([^\)]*\)/, ""); 576 filter = filter.replace(/^\s+|\s+$/, ""); 577 ele.style.filter = filter; 578 } 579 else 580 filter = ""; 581 582 return filter; 583}; 584 585Spry.Widget.Base.prototype.setOpacity = function(ele, opacity) 586{ 587 ele.style.opacity = "" + opacity; 588 589 var filter = this.clearIEAlphaFilter(ele); 590 if (filter) 591 filter += " "; 592 593 ele.style.filter = filter + "alpha(opacity=" + (opacity*100) + ")"; 594}; 595 596Spry.Widget.Event = function(widget, opts) 597{ 598 this.widget = widget; 599 Spry.Widget.setOptions(this, opts); 600 this.performDefaultAction = true; 601}; 602 603Spry.Widget.Event.prototype.preventDefault = function() { this.performDefaultAction = false; }; 604 605//////////////////////////////////////////////////////// 606 607Spry.Widget.Button = function(ele, opts) 608{ 609 Spry.Widget.Base.call(this); 610 611 this.element = Spry.$$(ele)[0]; 612 613 // Initialize the button object with the global defaults. 614 615 this.setOptions(this, Spry.Widget.Button.config); 616 617 // Override the defaults with any options passed into the constructor. 618 619 this.setOptions(this, opts); 620 621 var self = this; 622 623 this.addEventListener(this.element, "mousedown", function(e) { return self.handleMouseDown(e); }, false); 624 this.addEventListener(this.element, "mouseover", function(e) { return self.handleMouseOver(e); }, false); 625 this.addEventListener(this.element, "mouseout", function(e) { return self.handleMouseOut(e); }, false); 626 627 // XXX: IE doesn't allow the setting of tabindex dynamically. This means we can't 628 // rely on adding the tabindex attribute if it is missing to enable keyboard navigation 629 // by default. 630 631 // Find the first element within the tab container that has a tabindex or the first 632 // anchor tag. 633 this.focusElement = this.getFocusElement(this.element); 634 if (this.focusElement) 635 { 636 this.addEventListener(this.focusElement, "focus", function(e) { return self.handleFocus(e); }, false); 637 this.addEventListener(this.focusElement, "blur", function(e) { return self.handleBlur(e); }, false); 638 this.addEventListener(this.focusElement, "keydown", function(e) { return self.handleKeyDown(e); }, false); 639 } 640 641 // We need to eat the onclick event so that buttons made 642 // from links don't follow the link. 643 644 this.addEventListener(this.element, "click", function(e) { return false; }, false); 645 646 this.mouseUpCallback = function(evt) { return self.handleMouseUp(evt); }; 647}; 648 649Spry.Widget.Button.config = { 650 disabled: false, 651 mouseOutCancelsClick: true, 652 onclick: null, 653 downClass: "ButtonDown", 654 hoverClass: "ButtonHover", 655 disabledClass: "ButtonDisabled", 656 focusedClass: "ButtonFocused" 657}; 658 659 660Spry.Widget.Button.prototype = new Spry.Widget.Base(); 661Spry.Widget.Button.prototype.constructor = Spry.Widget.Button; 662 663Spry.Widget.Button.prototype.handleMouseDown = function(evt) 664{ 665 if (this.disabled) 666 return false; 667 668 this.addClassName(this.element, this.downClass); 669 this.addEventListener(document, "mouseup", this.mouseUpCallback, true); 670 671 this.notifyObservers("onButtonDown", { event: evt }); 672}; 673 674Spry.Widget.Button.prototype.handleMouseUp = function(evt) 675{ 676 if (this.disabled) 677 return false; 678 679 this.removeClassName(this.element, this.downClass); 680 this.removeEventListener(document, "mouseup", this.mouseUpCallback, true); 681 682 if (this.onclick) 683 this.onclick(evt); 684 685 this.notifyObservers("onButtonUp"); 686 this.notifyObservers("onButtonClick"); 687}; 688 689Spry.Widget.Button.prototype.handleMouseOver = function(evt) 690{ 691 if (this.disabled) 692 return false; 693 694 this.addClassName(this.element, this.hoverClass); 695 this.notifyObservers("onButtonEnter"); 696}; 697 698Spry.Widget.Button.prototype.handleMouseOut = function(evt) 699{ 700 if (this.disabled) 701 return false; 702 703 var ele = this.element; 704 this.removeClassName(ele, this.hoverClass); 705 706 if (this.mouseOutCancelsClick) 707 { 708 this.removeClassName(ele, this.downClass); 709 this.removeEventListener(document, "mouseup", this.mouseUpCallback, true); 710 } 711 712 this.notifyObservers("onButtonExit"); 713};
714 715Spry.Widget.Button.prototype.handleFocus = function(evt) 716{ 717 if (this.disabled) 718 return false; 719 720 this.addClassName(this.element, this.focusedClass); 721 this.notifyObservers("onButtonFocused"); 722}; 723 724Spry.Widget.Button.prototype.handleBlur = function(evt) 725{ 726 if (this.disabled) 727 return false; 728 729 this.removeClassName(this.element, this.focusedClass); 730 this.notifyObservers("onButtonBlur"); 731}; 732 733Spry.Widget.Button.prototype.handleKeyDown = function(evt) 734{ 735 if (this.disabled) 736 return false; 737 this.notifyObservers("onButtonKeyDown", {event: evt, element: this.element}); 738}; 739 740Spry.Widget.Button.prototype.getFocusElement = function(element) { 741 var focusElement = null; 742 var indexEle = null; 743 var anchorEle = null; 744 745 this.preorderTraversal(element, function(node) { 746 if (node.nodeType == 1 /* NODE.ELEMENT_NODE */) 747 { 748 var tabIndexAttr = element.attributes.getNamedItem("tabindex"); 749 if (tabIndexAttr) 750 { 751 indexEle = node; 752 return true; 753 } 754 if (!anchorEle && node.nodeName.toLowerCase() == "a") 755 anchorEle = node; 756 } 757 return false; 758 }); 759 760 if (indexEle) 761 focusElement = indexEle; 762 else if (anchorEle) 763 focusElement = anchorEle; 764 return focusElement; 765}; 766 767Spry.Widget.Button.prototype.preorderTraversal = function(root, func) 768{ 769 var stopTraversal = false; 770 if (root) 771 { 772 stopTraversal = func(root); 773 if (root.hasChildNodes()) 774 { 775 var child = root.firstChild; 776 while (!stopTraversal && child) 777 { 778 stopTraversal = this.preorderTraversal(child, func); 779 try { child = child.nextSibling; } catch (e) { child = null; } 780 } 781 } 782 } 783 return stopTraversal; 784}; 785 786Spry.Widget.Button.prototype.disable = function() 787{ 788 this.disabled = true; 789 this.removeClassName(this.element, this.downClass); 790 this.removeClassName(this.element, this.hoverClass); 791 this.addClassName(this.element, this.disabledClass); 792 this.removeEventListener(document, "mouseup", this.mouseUpCallback, true); 793}; 794 795Spry.Widget.Button.prototype.enable = function() 796{ 797 this.disabled = false; 798 this.removeClassName(this.element, this.disabledClass); 799}; 800 801Spry.Widget.Button.prototype.focus = function() 802{ 803 if (this.disabled) 804 return false; 805 806 if (this.focusElement) 807 this.focusElement.focus(); 808}; 809 810 811})(); // EndSpryComponent
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.