[jboss-svn-commits] JBoss Portal SVN: r5125 - in branches/tomek: . portal-dnd portal-dnd/dndRenderer.war portal-dnd/dndRenderer.war/WEB-INF portal-dnd/dndRenderer.war/WEB-INF/layout portal-dnd/dndRenderer.war/WEB-INF/theme portal-dnd/dndRenderer.war/js portal-dnd/dndRenderer.war/js/animation portal-dnd/dndRenderer.war/js/autocomplete portal-dnd/dndRenderer.war/js/calendar portal-dnd/dndRenderer.war/js/calendar/assets portal-dnd/dndRenderer.war/js/connection portal-dnd/dndRenderer.war/js/container portal-dnd/dndRenderer.war/js/container/assets portal-dnd/dndRenderer.war/js/dom portal-dnd/dndRenderer.war/js/dragdrop portal-dnd/dndRenderer.war/js/event portal-dnd/dndRenderer.war/js/fonts portal-dnd/dndRenderer.war/js/grids portal-dnd/dndRenderer.war/js/logger portal-dnd/dndRenderer.war/js/logger/assets portal-dnd/dndRenderer.war/js/menu portal-dnd/dndRenderer.war/js/menu/assets portal-dnd/dndRenderer.war/js/portal portal-dnd/dndRenderer.war/js/reset portal-dnd/dndRenderer.war/js/slider p! ortal-dnd/dndRenderer.war/js/treeview portal-dnd/dndRenderer.war/js/treeview/assets portal-dnd/dndRenderer.war/js/yahoo portal-dnd/jsunit portal-dnd/jsunit/app portal-dnd/jsunit/app/css portal-dnd/jsunit/bin portal-dnd/jsunit/bin/mac portal-dnd/jsunit/bin/unix portal-dnd/jsunit/css portal-dnd/jsunit/images portal-dnd/jsunit/java portal-dnd/jsunit/java/bin portal-dnd/jsunit/java/config portal-dnd/jsunit/java/lib portal-dnd/jsunit/java/source_core portal-dnd/jsunit/java/source_core/net portal-dnd/jsunit/java/source_core/net/jsunit portal-dnd/jsunit/java/source_core/net/jsunit/configuration portal-dnd/jsunit/java/source_core/net/jsunit/logging portal-dnd/jsunit/java/source_core/net/jsunit/model portal-dnd/jsunit/java/source_core/net/jsunit/utility portal-dnd/jsunit/java/source_core/net/jsunit/version portal-dnd/jsunit/java/source_server portal-dnd/jsunit/java/source_server/net portal-dnd/jsunit/java/source_server/net/jsunit portal-dnd/jsunit/java/source_server/net/jsunit/actio! n portal-dnd/jsunit/java/source_server/net/jsunit/interceptor portal-dnd/jsunit/java/testlib portal-dnd/jsunit/java/tests_core portal-dnd/jsunit/java/tests_core/net portal-dnd/jsunit/java/tests_core/net/jsunit portal-dnd/jsunit/java/tests_core/net/jsunit/configuration portal-dnd/jsunit/java/tests_core/net/jsunit/model portal
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Aug 31 11:24:26 EDT 2006
Author: szimano
Date: 2006-08-31 11:21:41 -0400 (Thu, 31 Aug 2006)
New Revision: 5125
Added:
branches/tomek/portal-dnd/
branches/tomek/portal-dnd/build.xml
branches/tomek/portal-dnd/dndRenderer.war/
branches/tomek/portal-dnd/dndRenderer.war/WEB-INF/
branches/tomek/portal-dnd/dndRenderer.war/WEB-INF/jboss-web.xml
branches/tomek/portal-dnd/dndRenderer.war/WEB-INF/layout/
branches/tomek/portal-dnd/dndRenderer.war/WEB-INF/layout/portal-renderSet.xml
branches/tomek/portal-dnd/dndRenderer.war/WEB-INF/theme/
branches/tomek/portal-dnd/dndRenderer.war/WEB-INF/theme/portal-layout.tld
branches/tomek/portal-dnd/dndRenderer.war/WEB-INF/web.xml
branches/tomek/portal-dnd/dndRenderer.war/dnd.properties
branches/tomek/portal-dnd/dndRenderer.war/js/
branches/tomek/portal-dnd/dndRenderer.war/js/animation/
branches/tomek/portal-dnd/dndRenderer.war/js/animation/README
branches/tomek/portal-dnd/dndRenderer.war/js/animation/animation-debug.js
branches/tomek/portal-dnd/dndRenderer.war/js/animation/animation-min.js
branches/tomek/portal-dnd/dndRenderer.war/js/animation/animation.js
branches/tomek/portal-dnd/dndRenderer.war/js/autocomplete/
branches/tomek/portal-dnd/dndRenderer.war/js/autocomplete/README
branches/tomek/portal-dnd/dndRenderer.war/js/autocomplete/autocomplete-debug.js
branches/tomek/portal-dnd/dndRenderer.war/js/autocomplete/autocomplete-min.js
branches/tomek/portal-dnd/dndRenderer.war/js/autocomplete/autocomplete.js
branches/tomek/portal-dnd/dndRenderer.war/js/calendar/
branches/tomek/portal-dnd/dndRenderer.war/js/calendar/README
branches/tomek/portal-dnd/dndRenderer.war/js/calendar/assets/
branches/tomek/portal-dnd/dndRenderer.war/js/calendar/assets/calendar.css
branches/tomek/portal-dnd/dndRenderer.war/js/calendar/assets/callt.gif
branches/tomek/portal-dnd/dndRenderer.war/js/calendar/assets/calrt.gif
branches/tomek/portal-dnd/dndRenderer.war/js/calendar/assets/calx.gif
branches/tomek/portal-dnd/dndRenderer.war/js/calendar/calendar-debug.js
branches/tomek/portal-dnd/dndRenderer.war/js/calendar/calendar-min.js
branches/tomek/portal-dnd/dndRenderer.war/js/calendar/calendar.js
branches/tomek/portal-dnd/dndRenderer.war/js/connection/
branches/tomek/portal-dnd/dndRenderer.war/js/connection/README
branches/tomek/portal-dnd/dndRenderer.war/js/connection/connection-debug.js
branches/tomek/portal-dnd/dndRenderer.war/js/connection/connection-min.js
branches/tomek/portal-dnd/dndRenderer.war/js/connection/connection.js
branches/tomek/portal-dnd/dndRenderer.war/js/container/
branches/tomek/portal-dnd/dndRenderer.war/js/container/README
branches/tomek/portal-dnd/dndRenderer.war/js/container/assets/
branches/tomek/portal-dnd/dndRenderer.war/js/container/assets/alrt16_1.gif
branches/tomek/portal-dnd/dndRenderer.war/js/container/assets/blck16_1.gif
branches/tomek/portal-dnd/dndRenderer.war/js/container/assets/close12_1.gif
branches/tomek/portal-dnd/dndRenderer.war/js/container/assets/container.css
branches/tomek/portal-dnd/dndRenderer.war/js/container/assets/hlp16_1.gif
branches/tomek/portal-dnd/dndRenderer.war/js/container/assets/info16_1.gif
branches/tomek/portal-dnd/dndRenderer.war/js/container/assets/tip16_1.gif
branches/tomek/portal-dnd/dndRenderer.war/js/container/assets/warn16_1.gif
branches/tomek/portal-dnd/dndRenderer.war/js/container/container-debug.js
branches/tomek/portal-dnd/dndRenderer.war/js/container/container-min.js
branches/tomek/portal-dnd/dndRenderer.war/js/container/container.js
branches/tomek/portal-dnd/dndRenderer.war/js/container/container_core-debug.js
branches/tomek/portal-dnd/dndRenderer.war/js/container/container_core-min.js
branches/tomek/portal-dnd/dndRenderer.war/js/container/container_core.js
branches/tomek/portal-dnd/dndRenderer.war/js/dom/
branches/tomek/portal-dnd/dndRenderer.war/js/dom/README
branches/tomek/portal-dnd/dndRenderer.war/js/dom/dom-debug.js
branches/tomek/portal-dnd/dndRenderer.war/js/dom/dom-min.js
branches/tomek/portal-dnd/dndRenderer.war/js/dom/dom.js
branches/tomek/portal-dnd/dndRenderer.war/js/dragdrop/
branches/tomek/portal-dnd/dndRenderer.war/js/dragdrop/README
branches/tomek/portal-dnd/dndRenderer.war/js/dragdrop/dragdrop-debug.js
branches/tomek/portal-dnd/dndRenderer.war/js/dragdrop/dragdrop-min.js
branches/tomek/portal-dnd/dndRenderer.war/js/dragdrop/dragdrop.js
branches/tomek/portal-dnd/dndRenderer.war/js/event/
branches/tomek/portal-dnd/dndRenderer.war/js/event/README
branches/tomek/portal-dnd/dndRenderer.war/js/event/event-debug.js
branches/tomek/portal-dnd/dndRenderer.war/js/event/event-min.js
branches/tomek/portal-dnd/dndRenderer.war/js/event/event.js
branches/tomek/portal-dnd/dndRenderer.war/js/fonts/
branches/tomek/portal-dnd/dndRenderer.war/js/fonts/README
branches/tomek/portal-dnd/dndRenderer.war/js/fonts/fonts-min.css
branches/tomek/portal-dnd/dndRenderer.war/js/fonts/fonts.css
branches/tomek/portal-dnd/dndRenderer.war/js/grids/
branches/tomek/portal-dnd/dndRenderer.war/js/grids/README
branches/tomek/portal-dnd/dndRenderer.war/js/grids/grids-min.css
branches/tomek/portal-dnd/dndRenderer.war/js/grids/grids.css
branches/tomek/portal-dnd/dndRenderer.war/js/logger/
branches/tomek/portal-dnd/dndRenderer.war/js/logger/README
branches/tomek/portal-dnd/dndRenderer.war/js/logger/assets/
branches/tomek/portal-dnd/dndRenderer.war/js/logger/assets/logger.css
branches/tomek/portal-dnd/dndRenderer.war/js/logger/logger-debug.js
branches/tomek/portal-dnd/dndRenderer.war/js/logger/logger-min.js
branches/tomek/portal-dnd/dndRenderer.war/js/logger/logger.js
branches/tomek/portal-dnd/dndRenderer.war/js/menu/
branches/tomek/portal-dnd/dndRenderer.war/js/menu/README
branches/tomek/portal-dnd/dndRenderer.war/js/menu/assets/
branches/tomek/portal-dnd/dndRenderer.war/js/menu/assets/menu.css
branches/tomek/portal-dnd/dndRenderer.war/js/menu/assets/menuarodwn8_dim_1.gif
branches/tomek/portal-dnd/dndRenderer.war/js/menu/assets/menuarodwn8_hov_1.gif
branches/tomek/portal-dnd/dndRenderer.war/js/menu/assets/menuarodwn8_nrm_1.gif
branches/tomek/portal-dnd/dndRenderer.war/js/menu/assets/menuarorght8_dim_1.gif
branches/tomek/portal-dnd/dndRenderer.war/js/menu/assets/menuarorght8_hov_1.gif
branches/tomek/portal-dnd/dndRenderer.war/js/menu/assets/menuarorght8_nrm_1.gif
branches/tomek/portal-dnd/dndRenderer.war/js/menu/assets/menuchk8_dim_1.gif
branches/tomek/portal-dnd/dndRenderer.war/js/menu/assets/menuchk8_hov_1.gif
branches/tomek/portal-dnd/dndRenderer.war/js/menu/assets/menuchk8_nrm_1.gif
branches/tomek/portal-dnd/dndRenderer.war/js/menu/menu-debug.js
branches/tomek/portal-dnd/dndRenderer.war/js/menu/menu-min.js
branches/tomek/portal-dnd/dndRenderer.war/js/menu/menu.js
branches/tomek/portal-dnd/dndRenderer.war/js/portal/
branches/tomek/portal-dnd/dndRenderer.war/js/portal/PortalDD.js
branches/tomek/portal-dnd/dndRenderer.war/js/reset/
branches/tomek/portal-dnd/dndRenderer.war/js/reset/README
branches/tomek/portal-dnd/dndRenderer.war/js/reset/reset-min.css
branches/tomek/portal-dnd/dndRenderer.war/js/reset/reset.css
branches/tomek/portal-dnd/dndRenderer.war/js/slider/
branches/tomek/portal-dnd/dndRenderer.war/js/slider/README
branches/tomek/portal-dnd/dndRenderer.war/js/slider/slider-debug.js
branches/tomek/portal-dnd/dndRenderer.war/js/slider/slider-min.js
branches/tomek/portal-dnd/dndRenderer.war/js/slider/slider.js
branches/tomek/portal-dnd/dndRenderer.war/js/treeview/
branches/tomek/portal-dnd/dndRenderer.war/js/treeview/README
branches/tomek/portal-dnd/dndRenderer.war/js/treeview/assets/
branches/tomek/portal-dnd/dndRenderer.war/js/treeview/assets/lm.gif
branches/tomek/portal-dnd/dndRenderer.war/js/treeview/assets/lmh.gif
branches/tomek/portal-dnd/dndRenderer.war/js/treeview/assets/ln.gif
branches/tomek/portal-dnd/dndRenderer.war/js/treeview/assets/loading.gif
branches/tomek/portal-dnd/dndRenderer.war/js/treeview/assets/lp.gif
branches/tomek/portal-dnd/dndRenderer.war/js/treeview/assets/lph.gif
branches/tomek/portal-dnd/dndRenderer.war/js/treeview/assets/tm.gif
branches/tomek/portal-dnd/dndRenderer.war/js/treeview/assets/tmh.gif
branches/tomek/portal-dnd/dndRenderer.war/js/treeview/assets/tn.gif
branches/tomek/portal-dnd/dndRenderer.war/js/treeview/assets/tp.gif
branches/tomek/portal-dnd/dndRenderer.war/js/treeview/assets/tph.gif
branches/tomek/portal-dnd/dndRenderer.war/js/treeview/assets/tree.css
branches/tomek/portal-dnd/dndRenderer.war/js/treeview/assets/vline.gif
branches/tomek/portal-dnd/dndRenderer.war/js/treeview/treeview-debug.js
branches/tomek/portal-dnd/dndRenderer.war/js/treeview/treeview-min.js
branches/tomek/portal-dnd/dndRenderer.war/js/treeview/treeview.js
branches/tomek/portal-dnd/dndRenderer.war/js/yahoo/
branches/tomek/portal-dnd/dndRenderer.war/js/yahoo/README
branches/tomek/portal-dnd/dndRenderer.war/js/yahoo/yahoo-debug.js
branches/tomek/portal-dnd/dndRenderer.war/js/yahoo/yahoo-min.js
branches/tomek/portal-dnd/dndRenderer.war/js/yahoo/yahoo.js
branches/tomek/portal-dnd/jsunit/
branches/tomek/portal-dnd/jsunit/app/
branches/tomek/portal-dnd/jsunit/app/css/
branches/tomek/portal-dnd/jsunit/app/css/jsUnitStyle.css
branches/tomek/portal-dnd/jsunit/app/css/readme
branches/tomek/portal-dnd/jsunit/app/emptyPage.html
branches/tomek/portal-dnd/jsunit/app/jsUnitCore.js
branches/tomek/portal-dnd/jsunit/app/jsUnitMockTimeout.js
branches/tomek/portal-dnd/jsunit/app/jsUnitTestManager.js
branches/tomek/portal-dnd/jsunit/app/jsUnitTestSuite.js
branches/tomek/portal-dnd/jsunit/app/jsUnitTracer.js
branches/tomek/portal-dnd/jsunit/app/jsUnitVersionCheck.js
branches/tomek/portal-dnd/jsunit/app/main-counts-errors.html
branches/tomek/portal-dnd/jsunit/app/main-counts-failures.html
branches/tomek/portal-dnd/jsunit/app/main-counts-runs.html
branches/tomek/portal-dnd/jsunit/app/main-counts.html
branches/tomek/portal-dnd/jsunit/app/main-data.html
branches/tomek/portal-dnd/jsunit/app/main-errors.html
branches/tomek/portal-dnd/jsunit/app/main-frame.html
branches/tomek/portal-dnd/jsunit/app/main-loader.html
branches/tomek/portal-dnd/jsunit/app/main-progress.html
branches/tomek/portal-dnd/jsunit/app/main-results.html
branches/tomek/portal-dnd/jsunit/app/main-status.html
branches/tomek/portal-dnd/jsunit/app/testContainer.html
branches/tomek/portal-dnd/jsunit/app/testContainerController.html
branches/tomek/portal-dnd/jsunit/app/xbDebug.js
branches/tomek/portal-dnd/jsunit/bin/
branches/tomek/portal-dnd/jsunit/bin/mac/
branches/tomek/portal-dnd/jsunit/bin/mac/readme.txt
branches/tomek/portal-dnd/jsunit/bin/mac/start-firefox.scpt
branches/tomek/portal-dnd/jsunit/bin/mac/start-firefox.sh
branches/tomek/portal-dnd/jsunit/bin/mac/start-safari.scpt
branches/tomek/portal-dnd/jsunit/bin/mac/start-safari.sh
branches/tomek/portal-dnd/jsunit/bin/mac/stop-firefox.scpt
branches/tomek/portal-dnd/jsunit/bin/mac/stop-firefox.sh
branches/tomek/portal-dnd/jsunit/bin/mac/stop-safari.scpt
branches/tomek/portal-dnd/jsunit/bin/mac/stop-safari.sh
branches/tomek/portal-dnd/jsunit/bin/unix/
branches/tomek/portal-dnd/jsunit/bin/unix/start-firefox.sh
branches/tomek/portal-dnd/jsunit/bin/unix/stop-firefox.sh
branches/tomek/portal-dnd/jsunit/build.xml
branches/tomek/portal-dnd/jsunit/changelog.txt
branches/tomek/portal-dnd/jsunit/css/
branches/tomek/portal-dnd/jsunit/css/jsUnitStyle.css
branches/tomek/portal-dnd/jsunit/images/
branches/tomek/portal-dnd/jsunit/images/green.gif
branches/tomek/portal-dnd/jsunit/images/logo_jsunit.gif
branches/tomek/portal-dnd/jsunit/images/powerby-transparent.gif
branches/tomek/portal-dnd/jsunit/images/red.gif
branches/tomek/portal-dnd/jsunit/index.jsp
branches/tomek/portal-dnd/jsunit/java/
branches/tomek/portal-dnd/jsunit/java/bin/
branches/tomek/portal-dnd/jsunit/java/bin/jsunit.jar
branches/tomek/portal-dnd/jsunit/java/config/
branches/tomek/portal-dnd/jsunit/java/config/farm_xwork.xml
branches/tomek/portal-dnd/jsunit/java/config/xwork.xml
branches/tomek/portal-dnd/jsunit/java/lib/
branches/tomek/portal-dnd/jsunit/java/lib/ant.jar
branches/tomek/portal-dnd/jsunit/java/lib/commons-el.jar
branches/tomek/portal-dnd/jsunit/java/lib/commons-logging.jar
branches/tomek/portal-dnd/jsunit/java/lib/jasper-compiler.jar
branches/tomek/portal-dnd/jsunit/java/lib/jasper-runtime.jar
branches/tomek/portal-dnd/jsunit/java/lib/javax.servlet.jar
branches/tomek/portal-dnd/jsunit/java/lib/jdom.jar
branches/tomek/portal-dnd/jsunit/java/lib/junit.jar
branches/tomek/portal-dnd/jsunit/java/lib/ognl.jar
branches/tomek/portal-dnd/jsunit/java/lib/org.mortbay.jetty.jar
branches/tomek/portal-dnd/jsunit/java/lib/oscore.jar
branches/tomek/portal-dnd/jsunit/java/lib/rife-continuations.jar
branches/tomek/portal-dnd/jsunit/java/lib/start.jar
branches/tomek/portal-dnd/jsunit/java/lib/stop.jar
branches/tomek/portal-dnd/jsunit/java/lib/webwork-2.2-beta-4.jar
branches/tomek/portal-dnd/jsunit/java/lib/xercesImpl-2.6.2.jar
branches/tomek/portal-dnd/jsunit/java/lib/xwork-1.1.jar
branches/tomek/portal-dnd/jsunit/java/source_core/
branches/tomek/portal-dnd/jsunit/java/source_core/net/
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/BrowserLaunchSpecification.java
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/BrowserTestRunner.java
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/ClientSideConnection.java
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/InvalidBrowserIdException.java
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/MessageReceiver.java
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/RemoteTestRunClient.java
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/ServerSideConnection.java
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/TestRunListener.java
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/TestRunNotifierServer.java
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/XmlRenderable.java
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/configuration/
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/configuration/ArgumentsConfigurationSource.java
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/configuration/CompositeConfigurationSource.java
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/configuration/Configuration.java
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/configuration/ConfigurationException.java
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/configuration/ConfigurationProperty.java
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/configuration/ConfigurationSource.java
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/configuration/DelegatingConfigurationSource.java
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/configuration/EnvironmentVariablesConfigurationSource.java
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/configuration/FarmConfiguration.java
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/configuration/FarmConfigurationSource.java
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/configuration/PropertiesFileConfigurationSource.java
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/configuration/ServerType.java
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/logging/
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/logging/BrowserResultRepository.java
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/logging/FileBrowserResultRepository.java
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/logging/StubBrowserResultRepository.java
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/AbstractResult.java
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/Browser.java
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/BrowserResult.java
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/BrowserResultBuilder.java
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/BrowserResultWriter.java
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/BrowserSource.java
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/DistributedTestRunResult.java
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/DistributedTestRunResultBuilder.java
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/Result.java
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/ResultType.java
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/TestCaseResult.java
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/TestCaseResultBuilder.java
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/TestCaseResultWriter.java
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/TestPageResult.java
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/TestRunResult.java
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/TestRunResultBuilder.java
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/utility/
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/utility/CollectionUtility.java
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/utility/FileUtility.java
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/utility/StreamUtility.java
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/utility/StringUtility.java
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/utility/SystemUtility.java
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/utility/XmlUtility.java
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/version/
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/version/JsUnitWebsiteVersionGrabber.java
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/version/VersionChecker.java
branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/version/VersionGrabber.java
branches/tomek/portal-dnd/jsunit/java/source_server/
branches/tomek/portal-dnd/jsunit/java/source_server/net/
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/AbstractJsUnitServer.java
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/BlowingUpProcessStarter.java
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/BrowserResultLogWriter.java
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/DefaultProcessStarter.java
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/DistributedTest.java
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/DistributedTestRunManager.java
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/DistributedTestSuiteBuilder.java
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/JsUnitFarmServer.java
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/JsUnitServer.java
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/JsUnitStandardServer.java
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/LaunchTestRunCommand.java
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/NoUrlSpecifiedException.java
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/PlatformType.java
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/ProcessStarter.java
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/RemoteConfigurationSource.java
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/RemoteMachineServerHitter.java
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/RemoteServerHitter.java
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/ServerRegistry.java
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/StandaloneTest.java
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/TestRunManager.java
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/TimeoutChecker.java
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/BrowserResultAware.java
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/BrowserTestRunnerConfigurationAction.java
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/DistributedTestRunnerAction.java
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/ErrorXmlRenderable.java
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/FarmServerConfigurationAction.java
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/IndexAction.java
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/JsUnitBrowserTestRunnerAction.java
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/JsUnitFarmServerAction.java
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/JsUnitServerAware.java
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/LatestVersionAction.java
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/LatestVersionResult.java
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/LatestVersionSource.java
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/RemoteRunnerHitterAware.java
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/RequestSourceAware.java
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/ResultAcceptorAction.java
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/ResultDisplayerAction.java
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/StandaloneTestAware.java
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/TestRunnerAction.java
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/VersionGrabberAware.java
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/XmlProducer.java
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/XmlResult.java
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/interceptor/
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/interceptor/BrowserResultInterceptor.java
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/interceptor/BrowserTestRunnerInterceptor.java
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/interceptor/BrowserTestRunnerSource.java
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/interceptor/DefaultBrowserTestRunnerSource.java
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/interceptor/FarmServerInterceptor.java
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/interceptor/JsUnitInterceptor.java
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/interceptor/RemoteRunnerHitterInterceptor.java
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/interceptor/RequestSourceInterceptor.java
branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/interceptor/VersionGrabberInterceptor.java
branches/tomek/portal-dnd/jsunit/java/testlib/
branches/tomek/portal-dnd/jsunit/java/testlib/ashcroft.jar
branches/tomek/portal-dnd/jsunit/java/testlib/httpunit-1.5.4.jar
branches/tomek/portal-dnd/jsunit/java/testlib/js-1.5R4.1.jar
branches/tomek/portal-dnd/jsunit/java/testlib/jwebunit-1.2.jar
branches/tomek/portal-dnd/jsunit/java/testlib/nekohtml-0.8.1.jar
branches/tomek/portal-dnd/jsunit/java/testlib/xml-apis-1.0.b2.jar
branches/tomek/portal-dnd/jsunit/java/tests_core/
branches/tomek/portal-dnd/jsunit/java/tests_core/net/
branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/
branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/BrowserLaunchSpecificationTest.java
branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/ClientServerConnectionTest.java
branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/ClientServerInteractionTest.java
branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/DistributedTestRunResultTest.java
branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/DummyBrowserResult.java
branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/MockBrowserTestRunner.java
branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/MockMessageReceiver.java
branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/MockTestRunListener.java
branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/RemoteTestRunClientTest.java
branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/StubConfigurationSource.java
branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/TestRunNotifierServerTest.java
branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/TestRunResultTest.java
branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/configuration/
branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/configuration/ArgumentsConfigurationSourceTest.java
branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/configuration/CompositeConfigurationSourceTest.java
branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/configuration/ConfigurationSourceResolutionTest.java
branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/configuration/ConfigurationTest.java
branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/configuration/EnvironmentVariablesConfigurationSourceTest.java
branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/configuration/PropertiesConfigurationSourceTest.java
branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/model/
branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/model/BrowserResultTest.java
branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/model/BrowserTest.java
branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/model/DistributedTestRunResultBuilderTest.java
branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/model/DummyBrowserSource.java
branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/model/ExternallyShutDownBrowserResultTest.java
branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/model/FailedToLaunchBrowserResultTest.java
branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/model/TestCaseResultTest.java
branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/model/TestPageResultTest.java
branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/model/TestRunResultBuilderTest.java
branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/model/TimedOutBrowerResultTest.java
branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/version/
branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/version/BlowingUpVersionGrabber.java
branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/version/MockVersionGrabber.java
branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/version/VersionCheckerTest.java
branches/tomek/portal-dnd/jsunit/java/tests_server/
branches/tomek/portal-dnd/jsunit/java/tests_server/net/
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/AcceptorFunctionalTest.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/BlowingUpRemoteServerHitter.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/BrowserResultLogWriterTest.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/ConfigurationFunctionalTest.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/DisplayerFunctionalTest.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/DistributedTestRunManagerTest.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/DistributedTestSuiteBuilderTest.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/DummyConfigurationSource.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/DummyFarmConfigurationSource.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/DummyHttpRequest.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/EndToEndTestCase.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/ExternallyShutDownStandaloneTestTest.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/FailedToLaunchBrowserStandaloneTestTest.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/FarmServerFunctionalTest.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/FarmServerFunctionalTestSuite.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/FarmServerLandingPageFunctionalTest.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/FunctionalTestCase.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/FunctionalTestConfigurationSource.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/FunctionalTestFarmConfigurationSource.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/FunctionalTestSuite.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/ImpureUnitTestSuite.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/InvalidRemoteMachinesDistributedTestTest.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/JsUnitFarmServerTest.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/JsUnitStandardServerTest.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/MockBrowserResultRepository.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/MockProcessStarter.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/MockRemoteServerHitter.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/OverrideURLDistributedTestTest.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/PureUnitTestSuite.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/RemoteConfigurationSourceFunctionalTest.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/RemoteConfigurationSourceTest.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/RemoteMachineRunnerHitterTest.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/ResultAcceptorTest.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/RunnerFunctionalTest.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/ServerLandingPageFunctionalTest.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/SpecificBrowserDistributedTestTest.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/SuccessfulStandaloneTestTest.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/TestPortManager.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/TestRunManagerTest.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/TimedOutBrowserStandaloneTestTest.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/TimeoutCheckerTest.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/TwoValidLocalhostsDistributedTestTest.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/UnitTestSuite.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/UrlOverrideStandaloneTestTest.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/action/
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/action/BlockingTestRunner.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/action/DistributedTestRunnerActionTest.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/action/ErrorXmlRenderableTest.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/action/FarmServerConfigurationActionTest.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/action/LatestVersionActionTest.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/action/ResultAcceptorActionTest.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/action/ResultDisplayerActionTest.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/action/TestRunnerActionSimultaneousRunBlockingTest.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/action/TestRunnerActionTest.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/interceptor/
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/interceptor/BrowserResultInterceptorTest.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/interceptor/BrowserTestRunnerInterceptorTest.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/interceptor/FarmServerInterceptorTest.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/interceptor/MockActionInvocation.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/interceptor/RemoteRunnerHitterInterceptorTest.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/interceptor/RequestSourceInterceptorTest.java
branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/interceptor/VersionGrabberInterceptorTest.java
branches/tomek/portal-dnd/jsunit/jsunit.properties.sample
branches/tomek/portal-dnd/jsunit/licenses/
branches/tomek/portal-dnd/jsunit/licenses/JDOM_license.txt
branches/tomek/portal-dnd/jsunit/licenses/Jetty_license.html
branches/tomek/portal-dnd/jsunit/licenses/MPL-1.1.txt
branches/tomek/portal-dnd/jsunit/licenses/gpl-2.txt
branches/tomek/portal-dnd/jsunit/licenses/index.html
branches/tomek/portal-dnd/jsunit/licenses/lgpl-2.1.txt
branches/tomek/portal-dnd/jsunit/licenses/mpl-tri-license-c.txt
branches/tomek/portal-dnd/jsunit/licenses/mpl-tri-license-html.txt
branches/tomek/portal-dnd/jsunit/logging.properties
branches/tomek/portal-dnd/jsunit/logs/
branches/tomek/portal-dnd/jsunit/readme.txt
branches/tomek/portal-dnd/jsunit/testRunner.html
branches/tomek/portal-dnd/jsunit/tests/
branches/tomek/portal-dnd/jsunit/tests/data/
branches/tomek/portal-dnd/jsunit/tests/data/data.html
branches/tomek/portal-dnd/jsunit/tests/data/staff.css
branches/tomek/portal-dnd/jsunit/tests/data/staff.dtd
branches/tomek/portal-dnd/jsunit/tests/data/staff.xml
branches/tomek/portal-dnd/jsunit/tests/jsUnitAssertionTests.html
branches/tomek/portal-dnd/jsunit/tests/jsUnitFrameworkUtilityTests.html
branches/tomek/portal-dnd/jsunit/tests/jsUnitMockTimeoutTest.html
branches/tomek/portal-dnd/jsunit/tests/jsUnitOnLoadTests.html
branches/tomek/portal-dnd/jsunit/tests/jsUnitRestoredHTMLDivTests.html
branches/tomek/portal-dnd/jsunit/tests/jsUnitSetUpTearDownTests.html
branches/tomek/portal-dnd/jsunit/tests/jsUnitTestLoadData.html
branches/tomek/portal-dnd/jsunit/tests/jsUnitTestLoadStaff.html
branches/tomek/portal-dnd/jsunit/tests/jsUnitTestSetUpPages.html
branches/tomek/portal-dnd/jsunit/tests/jsUnitTestSetUpPagesSuite.html
branches/tomek/portal-dnd/jsunit/tests/jsUnitTestSuite.html
branches/tomek/portal-dnd/jsunit/tests/jsUnitUtilityTests.html
branches/tomek/portal-dnd/jsunit/tests/jsUnitVersionCheckTests.html
branches/tomek/portal-dnd/lib/
branches/tomek/portal-dnd/lib/portal-api-lib.jar
branches/tomek/portal-dnd/lib/portal-common-lib.jar
branches/tomek/portal-dnd/lib/portal-core-lib.jar
branches/tomek/portal-dnd/lib/portal-theme-lib.jar
branches/tomek/portal-dnd/src/
branches/tomek/portal-dnd/src/java/
branches/tomek/portal-dnd/src/java/org/
branches/tomek/portal-dnd/src/java/org/jboss/
branches/tomek/portal-dnd/src/java/org/jboss/portal/
branches/tomek/portal-dnd/src/java/org/jboss/portal/core/
branches/tomek/portal-dnd/src/java/org/jboss/portal/core/theme/
branches/tomek/portal-dnd/src/java/org/jboss/portal/core/theme/render/
branches/tomek/portal-dnd/src/java/org/jboss/portal/core/theme/render/impl/
branches/tomek/portal-dnd/src/java/org/jboss/portal/core/theme/render/impl/DnDDecorationRenderer.java
branches/tomek/portal-dnd/src/java/org/jboss/portal/core/theme/render/impl/DnDPortletRenderer.java
branches/tomek/portal-dnd/src/java/org/jboss/portal/core/theme/render/impl/DnDRegionRenderer.java
branches/tomek/portal-dnd/src/java/org/jboss/portal/core/theme/render/impl/DnDTools.java
branches/tomek/portal-dnd/src/java/org/jboss/portal/core/theme/render/impl/DnDWindowRenderer.java
branches/tomek/portal-dnd/src/java/org/jboss/portal/dnd/
branches/tomek/portal-dnd/src/java/org/jboss/portal/dnd/DnDAjaxServlet.java
branches/tomek/portal-dnd/src/java/org/jboss/portal/dnd/DnDPersistance.java
branches/tomek/portal-dnd/src/java/org/jboss/portal/dnd/DnDPersistanceImpl.java
branches/tomek/portal-dnd/test/
branches/tomek/portal-dnd/test/ajaxAsserts.js
branches/tomek/portal-dnd/test/jsUnitCore.js
branches/tomek/portal-dnd/test/testPortletDrop.html
Log:
portal drag and drop sources
Added: branches/tomek/portal-dnd/build.xml
===================================================================
--- branches/tomek/portal-dnd/build.xml 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/build.xml 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project name="Packaging Generator" default="_packaging_generation_">
+
+ <target name="_packaging_generation_" depends="build, N65540, deploy" />
+
+ <target name="build">
+ <mkdir dir="target" />
+ <mkdir dir="target/classes" />
+ <javac srcdir="src/java" destdir="target/classes">
+ <classpath path=".:lib/portal-api-lib.jar:lib/portal-common-lib.jar:lib/portal-core-lib.jar:lib/portal-theme-lib.jar:lib/jboss-common.jar:lib/javax.servlet.jar" />
+ </javac>
+ </target>
+
+ <target name="N65540" description="dndRenderer.war">
+ <mkdir dir="target" />
+ <jar destfile="target/dndRenderer.war">
+ <zipfileset dir="dndRenderer.war" />
+ <zipfileset dir="target/classes" prefix="WEB-INF/classes" />
+ <zipfileset dir="jsunit" prefix="test" />
+ <zipfileset dir="test" prefix="test" />
+ </jar>
+ </target>
+
+ <target name="deploy">
+ <copy todir="" overwrite="true">
+ <fileset dir="target">
+ <include name="dndRenderer.war" />
+ </fileset>
+ </copy>
+ </target>
+</project>
Added: branches/tomek/portal-dnd/dndRenderer.war/WEB-INF/jboss-web.xml
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/WEB-INF/jboss-web.xml 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/WEB-INF/jboss-web.xml 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,3 @@
+<jboss-web>
+ <context-root>/dndRenderer</context-root>
+</jboss-web>
Added: branches/tomek/portal-dnd/dndRenderer.war/WEB-INF/layout/portal-renderSet.xml
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/WEB-INF/layout/portal-renderSet.xml 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/WEB-INF/layout/portal-renderSet.xml 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ JBoss, the OpenSource J2EE webOS
+ Distributable under LGPL license.
+ See terms of license at gnu.org.
+ -->
+<portal-renderSet>
+ <renderSet name="dndRenderer">
+ <set content-type="text/html">
+ <region-renderer>org.jboss.portal.core.theme.render.impl.DnDRegionRenderer</region-renderer>
+ <window-renderer>org.jboss.portal.core.theme.render.impl.DnDWindowRenderer</window-renderer>
+ <portlet-renderer>org.jboss.portal.core.theme.render.impl.DnDPortletRenderer</portlet-renderer>
+ <decoration-renderer>org.jboss.portal.core.theme.render.impl.DnDDecorationRenderer</decoration-renderer>
+ </set>
+ </renderSet>
+</portal-renderSet>
Added: branches/tomek/portal-dnd/dndRenderer.war/WEB-INF/theme/portal-layout.tld
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/WEB-INF/theme/portal-layout.tld 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/WEB-INF/theme/portal-layout.tld 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,37 @@
+<taglib
+ xmlns="http://java.sun.com/xml/ns/j2ee"
+ xmlns:xsi="http://www.w3c.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-jsptaglibrary_2_0.xsd"
+ version="2.0">
+ <!--
+ JBoss, the OpenSource J2EE webOS
+ Distributable under LGPL license.
+ See terms of license at gnu.org.
+ -->
+ <tlib-version>1.0</tlib-version>
+ <jsp-version>2.0</jsp-version>
+ <short-name></short-name>
+ <uri>http://www.jboss.org/portal</uri>
+ <tag>
+ <name>region</name>
+ <tag-class>org.jboss.portal.theme.tag.RegionTagHandler</tag-class>
+ <body-content>empty</body-content>
+ <attribute>
+ <name>orientation</name>
+ </attribute>
+ <attribute>
+ <name>regionName</name>
+ </attribute>
+ <attribute>
+ <name>regionID</name>
+ </attribute>
+ </tag>
+ <tag>
+ <name>theme</name>
+ <tag-class>org.jboss.portal.theme.tag.ThemeTagHandler</tag-class>
+ <body-content>empty</body-content>
+ <attribute>
+ <name>themeName</name>
+ </attribute>
+ </tag>
+</taglib>
Added: branches/tomek/portal-dnd/dndRenderer.war/WEB-INF/web.xml
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/WEB-INF/web.xml 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/WEB-INF/web.xml 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,15 @@
+<?xml version="1.0"?>
+<!DOCTYPE web-app PUBLIC
+ "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
+ "http://java.sun.com/dtd/web-app_2_3.dtd">
+<web-app>
+ <servlet>
+ <servlet-name>DnDAjaxServlet</servlet-name>
+ <servlet-class>org.jboss.portal.dnd.DnDAjaxServlet</servlet-class>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>DnDAjaxServlet</servlet-name>
+ <url-pattern>/ajax/*</url-pattern>
+ </servlet-mapping>
+</web-app>
Added: branches/tomek/portal-dnd/dndRenderer.war/dnd.properties
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/dnd.properties 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/dnd.properties 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,13 @@
+# specify rendere classes to use
+
+#Empty renderer - just for testing
+#decorationRenderer.class = org.jboss.portal.theme.impl.render.EmptyDecorationRenderer
+#portletRenderer.class = org.jboss.portal.theme.impl.render.EmptyPortletRenderer
+#regionRenderer.class = org.jboss.portal.theme.impl.render.EmptyRegionRenderer
+#windowRenderer.class = org.jboss.portal.theme.impl.render.EmptyWindowRenderer
+
+# DEFAULT DivDecorationRenderer
+decorationRenderer.class = org.jboss.portal.theme.impl.render.DivDecorationRenderer
+portletRenderer.class = org.jboss.portal.theme.impl.render.DivPortletRenderer
+regionRenderer.class = org.jboss.portal.theme.impl.render.DivRegionRenderer
+windowRenderer.class = org.jboss.portal.theme.impl.render.DivWindowRenderer
\ No newline at end of file
Added: branches/tomek/portal-dnd/dndRenderer.war/js/animation/README
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/animation/README 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/animation/README 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,24 @@
+Animation Release Notes
+
+*** version 0.11.1 ***
+
+* changed "prototype" shorthand to "proto" (workaround firefox < 1.5 scoping bug)
+
+*** version 0.11.0 ***
+
+* ColorAnim subclass added
+* Motion and Scroll now inherit from ColorAnim
+* getDefaultUnit method added
+* defaultUnit and defaultUnits deprecated
+* getDefault and setDefault methods deprecated
+
+*** version 0.10.0 ***
+
+* Scroll now handles relative ("by") animation correctly
+
+* Now converts "auto" values of "from" to appropriate initial values
+
+*** version 0.9.0 ***
+
+* Initial release
+
Added: branches/tomek/portal-dnd/dndRenderer.war/js/animation/animation-debug.js
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/animation/animation-debug.js 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/animation/animation-debug.js 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,1261 @@
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+Version: 0.11.1
+*/
+
+
+/**
+ *
+ * Base class for animated DOM objects.
+ * @class Base animation class that provides the interface for building animated effects.
+ * <p>Usage: var myAnim = new YAHOO.util.Anim(el, { width: { from: 10, to: 100 } }, 1, YAHOO.util.Easing.easeOut);</p>
+ * @requires YAHOO.util.AnimMgr
+ * @requires YAHOO.util.Easing
+ * @requires YAHOO.util.Dom
+ * @requires YAHOO.util.Event
+ * @requires YAHOO.util.CustomEvent
+ * @constructor
+ * @param {String or HTMLElement} el Reference to the element that will be animated
+ * @param {Object} attributes The attribute(s) to be animated.
+ * Each attribute is an object with at minimum a "to" or "by" member defined.
+ * Additional optional members are "from" (defaults to current value), "units" (defaults to "px").
+ * All attribute names use camelCase.
+ * @param {Number} duration (optional, defaults to 1 second) Length of animation (frames or seconds), defaults to time-based
+ * @param {Function} method (optional, defaults to YAHOO.util.Easing.easeNone) Computes the values that are applied to the attributes per frame (generally a YAHOO.util.Easing method)
+ */
+
+YAHOO.util.Anim = function(el, attributes, duration, method) {
+ if (el) {
+ this.init(el, attributes, duration, method);
+ }
+};
+
+YAHOO.util.Anim.prototype = {
+ /**
+ * toString method
+ * @return {String} string represenation of anim obj
+ */
+ toString: function() {
+ var el = this.getEl();
+ var id = el.id || el.tagName;
+ return ("Anim " + id);
+ },
+
+ patterns: { // cached for performance
+ noNegatives: /width|height|opacity|padding/i, // keep at zero or above
+ offsetAttribute: /^((width|height)|(top|left))$/, // use offsetValue as default
+ defaultUnit: /width|height|top$|bottom$|left$|right$/i, // use 'px' by default
+ offsetUnit: /\d+(em|%|en|ex|pt|in|cm|mm|pc)$/i // IE may return these, so convert these to offset
+ },
+
+ /**
+ * Returns the value computed by the animation's "method".
+ * @param {String} attr The name of the attribute.
+ * @param {Number} start The value this attribute should start from for this animation.
+ * @param {Number} end The value this attribute should end at for this animation.
+ * @return {Number} The Value to be applied to the attribute.
+ */
+ doMethod: function(attr, start, end) {
+ return this.method(this.currentFrame, start, end - start, this.totalFrames);
+ },
+
+ /**
+ * Applies a value to an attribute
+ * @param {String} attr The name of the attribute.
+ * @param {Number} val The value to be applied to the attribute.
+ * @param {String} unit The unit ('px', '%', etc.) of the value.
+ */
+ setAttribute: function(attr, val, unit) {
+ if ( this.patterns.noNegatives.test(attr) ) {
+ val = (val > 0) ? val : 0;
+ }
+
+ YAHOO.util.Dom.setStyle(this.getEl(), attr, val + unit);
+ },
+
+ /**
+ * Returns current value of the attribute.
+ * @param {String} attr The name of the attribute.
+ * @return {Number} val The current value of the attribute.
+ */
+ getAttribute: function(attr) {
+ var el = this.getEl();
+ var val = YAHOO.util.Dom.getStyle(el, attr);
+
+ if (val !== 'auto' && !this.patterns.offsetUnit.test(val)) {
+ return parseFloat(val);
+ }
+
+ var a = this.patterns.offsetAttribute.exec(attr) || [];
+ var pos = !!( a[3] ); // top or left
+ var box = !!( a[2] ); // width or height
+
+ // use offsets for width/height and abs pos top/left
+ if ( box || (YAHOO.util.Dom.getStyle(el, 'position') == 'absolute' && pos) ) {
+ val = el['offset' + a[0].charAt(0).toUpperCase() + a[0].substr(1)];
+ } else { // default to zero for other 'auto'
+ val = 0;
+ }
+
+ return val;
+ },
+
+ /**
+ * Returns the unit to use when none is supplied.
+ * Applies the "defaultUnit" test to decide whether to use pixels or not
+ * @param {attr} attr The name of the attribute.
+ * @return {String} The default unit to be used.
+ */
+ getDefaultUnit: function(attr) {
+ if ( this.patterns.defaultUnit.test(attr) ) {
+ return 'px';
+ }
+
+ return '';
+ },
+
+ /**
+ * Sets the actual values to be used during the animation.
+ * Should only be needed for subclass use.
+ * @param {Object} attr The attribute object
+ * @private
+ */
+ setRuntimeAttribute: function(attr) {
+ var start;
+ var end;
+ var attributes = this.attributes;
+
+ this.runtimeAttributes[attr] = {};
+
+ var isset = function(prop) {
+ return (typeof prop !== 'undefined');
+ };
+
+ if ( !isset(attributes[attr]['to']) && !isset(attributes[attr]['by']) ) {
+ return false; // note return; nothing to animate to
+ }
+
+ start = ( isset(attributes[attr]['from']) ) ? attributes[attr]['from'] : this.getAttribute(attr);
+
+ // To beats by, per SMIL 2.1 spec
+ if ( isset(attributes[attr]['to']) ) {
+ end = attributes[attr]['to'];
+ } else if ( isset(attributes[attr]['by']) ) {
+ if (start.constructor == Array) {
+ end = [];
+ for (var i = 0, len = start.length; i < len; ++i) {
+ end[i] = start[i] + attributes[attr]['by'][i];
+ }
+ } else {
+ end = start + attributes[attr]['by'];
+ }
+ }
+
+ this.runtimeAttributes[attr].start = start;
+ this.runtimeAttributes[attr].end = end;
+
+ // set units if needed
+ this.runtimeAttributes[attr].unit = ( isset(attributes[attr].unit) ) ? attributes[attr]['unit'] : this.getDefaultUnit(attr);
+ },
+
+ /**
+ * @param {String or HTMLElement} el Reference to the element that will be animated
+ * @param {Object} attributes The attribute(s) to be animated.
+ * Each attribute is an object with at minimum a "to" or "by" member defined.
+ * Additional optional members are "from" (defaults to current value), "units" (defaults to "px").
+ * All attribute names use camelCase.
+ * @param {Number} duration (optional, defaults to 1 second) Length of animation (frames or seconds), defaults to time-based
+ * @param {Function} method (optional, defaults to YAHOO.util.Easing.easeNone) Computes the values that are applied to the attributes per frame (generally a YAHOO.util.Easing method)
+ */
+ init: function(el, attributes, duration, method) {
+ /**
+ * Whether or not the animation is running.
+ * @private
+ * @type Boolean
+ */
+ var isAnimated = false;
+
+ /**
+ * A Date object that is created when the animation begins.
+ * @private
+ * @type Date
+ */
+ var startTime = null;
+
+ /**
+ * The number of frames this animation was able to execute.
+ * @private
+ * @type Int
+ */
+ var actualFrames = 0;
+
+ /**
+ * The element to be animated.
+ * @private
+ * @type HTMLElement
+ */
+ el = YAHOO.util.Dom.get(el);
+
+ /**
+ * The collection of attributes to be animated.
+ * Each attribute must have at least a "to" or "by" defined in order to animate.
+ * If "to" is supplied, the animation will end with the attribute at that value.
+ * If "by" is supplied, the animation will end at that value plus its starting value.
+ * If both are supplied, "to" is used, and "by" is ignored.
+ * @member YAHOO#util#Anim
+ * Optional additional member include "from" (the value the attribute should start animating from, defaults to current value), and "unit" (the units to apply to the values).
+ * @type Object
+ */
+ this.attributes = attributes || {};
+
+ /**
+ * The length of the animation. Defaults to "1" (second).
+ * @type Number
+ */
+ this.duration = duration || 1;
+
+ /**
+ * The method that will provide values to the attribute(s) during the animation.
+ * Defaults to "YAHOO.util.Easing.easeNone".
+ * @type Function
+ */
+ this.method = method || YAHOO.util.Easing.easeNone;
+
+ /**
+ * Whether or not the duration should be treated as seconds.
+ * Defaults to true.
+ * @type Boolean
+ */
+ this.useSeconds = true; // default to seconds
+
+ /**
+ * The location of the current animation on the timeline.
+ * In time-based animations, this is used by AnimMgr to ensure the animation finishes on time.
+ * @type Int
+ */
+ this.currentFrame = 0;
+
+ /**
+ * The total number of frames to be executed.
+ * In time-based animations, this is used by AnimMgr to ensure the animation finishes on time.
+ * @type Int
+ */
+ this.totalFrames = YAHOO.util.AnimMgr.fps;
+
+
+ /**
+ * Returns a reference to the animated element.
+ * @return {HTMLElement}
+ */
+ this.getEl = function() { return el; };
+
+ /**
+ * Checks whether the element is currently animated.
+ * @return {Boolean} current value of isAnimated.
+ */
+ this.isAnimated = function() {
+ return isAnimated;
+ };
+
+ /**
+ * Returns the animation start time.
+ * @return {Date} current value of startTime.
+ */
+ this.getStartTime = function() {
+ return startTime;
+ };
+
+ this.runtimeAttributes = {};
+
+ var logger = {};
+ logger.log = function() {YAHOO.log.apply(window, arguments)};
+
+ logger.log('creating new instance of ' + this);
+
+ /**
+ * Starts the animation by registering it with the animation manager.
+ */
+ this.animate = function() {
+ if ( this.isAnimated() ) { return false; }
+
+ this.currentFrame = 0;
+
+ this.totalFrames = ( this.useSeconds ) ? Math.ceil(YAHOO.util.AnimMgr.fps * this.duration) : this.duration;
+
+ YAHOO.util.AnimMgr.registerElement(this);
+ };
+
+ /**
+ * Stops the animation. Normally called by AnimMgr when animation completes.
+ */
+ this.stop = function() {
+ YAHOO.util.AnimMgr.stop(this);
+ };
+
+ var onStart = function() {
+ this.onStart.fire();
+ for (var attr in this.attributes) {
+ this.setRuntimeAttribute(attr);
+ }
+
+ isAnimated = true;
+ actualFrames = 0;
+ startTime = new Date();
+ };
+
+ /**
+ * Feeds the starting and ending values for each animated attribute to doMethod once per frame, then applies the resulting value to the attribute(s).
+ * @private
+ */
+
+ var onTween = function() {
+ var data = {
+ duration: new Date() - this.getStartTime(),
+ currentFrame: this.currentFrame
+ };
+
+ data.toString = function() {
+ return (
+ 'duration: ' + data.duration +
+ ', currentFrame: ' + data.currentFrame
+ );
+ };
+
+ this.onTween.fire(data);
+
+ var runtimeAttributes = this.runtimeAttributes;
+
+ for (var attr in runtimeAttributes) {
+ this.setAttribute(attr, this.doMethod(attr, runtimeAttributes[attr].start, runtimeAttributes[attr].end), runtimeAttributes[attr].unit);
+ }
+
+ actualFrames += 1;
+ };
+
+ var onComplete = function() {
+ var actual_duration = (new Date() - startTime) / 1000 ;
+
+ var data = {
+ duration: actual_duration,
+ frames: actualFrames,
+ fps: actualFrames / actual_duration
+ };
+
+ data.toString = function() {
+ return (
+ 'duration: ' + data.duration +
+ ', frames: ' + data.frames +
+ ', fps: ' + data.fps
+ );
+ };
+
+ isAnimated = false;
+ actualFrames = 0;
+ this.onComplete.fire(data);
+ };
+
+ /**
+ * Custom event that fires after onStart, useful in subclassing
+ * @private
+ */
+ this._onStart = new YAHOO.util.CustomEvent('_start', this, true);
+
+ /**
+ * Custom event that fires when animation begins
+ * Listen via subscribe method (e.g. myAnim.onStart.subscribe(someFunction)
+ */
+ this.onStart = new YAHOO.util.CustomEvent('start', this);
+
+ /**
+ * Custom event that fires between each frame
+ * Listen via subscribe method (e.g. myAnim.onTween.subscribe(someFunction)
+ */
+ this.onTween = new YAHOO.util.CustomEvent('tween', this);
+
+ /**
+ * Custom event that fires after onTween
+ * @private
+ */
+ this._onTween = new YAHOO.util.CustomEvent('_tween', this, true);
+
+ /**
+ * Custom event that fires when animation ends
+ * Listen via subscribe method (e.g. myAnim.onComplete.subscribe(someFunction)
+ */
+ this.onComplete = new YAHOO.util.CustomEvent('complete', this);
+ /**
+ * Custom event that fires after onComplete
+ * @private
+ */
+ this._onComplete = new YAHOO.util.CustomEvent('_complete', this, true);
+
+ this._onStart.subscribe(onStart);
+ this._onTween.subscribe(onTween);
+ this._onComplete.subscribe(onComplete);
+ }
+};
+
+/**
+ * @class Handles animation queueing and threading.
+ * Used by Anim and subclasses.
+ */
+YAHOO.util.AnimMgr = new function() {
+ /**
+ * Reference to the animation Interval
+ * @private
+ * @type Int
+ */
+ var thread = null;
+
+ /**
+ * The current queue of registered animation objects.
+ * @private
+ * @type Array
+ */
+ var queue = [];
+
+ /**
+ * The number of active animations.
+ * @private
+ * @type Int
+ */
+ var tweenCount = 0;
+
+ /**
+ * Base frame rate (frames per second).
+ * Arbitrarily high for better x-browser calibration (slower browsers drop more frames).
+ * @type Int
+ *
+ */
+ this.fps = 200;
+
+ /**
+ * Interval delay in milliseconds, defaults to fastest possible.
+ * @type Int
+ *
+ */
+ this.delay = 1;
+
+ /**
+ * Adds an animation instance to the animation queue.
+ * All animation instances must be registered in order to animate.
+ * @param {object} tween The Anim instance to be be registered
+ */
+ this.registerElement = function(tween) {
+ queue[queue.length] = tween;
+ tweenCount += 1;
+ tween._onStart.fire();
+ this.start();
+ };
+
+ this.unRegister = function(tween, index) {
+ tween._onComplete.fire();
+ index = index || getIndex(tween);
+ if (index != -1) { queue.splice(index, 1); }
+
+ tweenCount -= 1;
+ if (tweenCount <= 0) { this.stop(); }
+ };
+
+ /**
+ * Starts the animation thread.
+ * Only one thread can run at a time.
+ */
+ this.start = function() {
+ if (thread === null) { thread = setInterval(this.run, this.delay); }
+ };
+
+ /**
+ * Stops the animation thread or a specific animation instance.
+ * @param {object} tween A specific Anim instance to stop (optional)
+ * If no instance given, Manager stops thread and all animations.
+ */
+ this.stop = function(tween) {
+ if (!tween) {
+ clearInterval(thread);
+ for (var i = 0, len = queue.length; i < len; ++i) {
+ if (queue[i].isAnimated()) {
+ this.unRegister(tween, i);
+ }
+ }
+ queue = [];
+ thread = null;
+ tweenCount = 0;
+ }
+ else {
+ this.unRegister(tween);
+ }
+ };
+
+ /**
+ * Called per Interval to handle each animation frame.
+ */
+ this.run = function() {
+ for (var i = 0, len = queue.length; i < len; ++i) {
+ var tween = queue[i];
+ if ( !tween || !tween.isAnimated() ) { continue; }
+
+ if (tween.currentFrame < tween.totalFrames || tween.totalFrames === null)
+ {
+ tween.currentFrame += 1;
+
+ if (tween.useSeconds) {
+ correctFrame(tween);
+ }
+ tween._onTween.fire();
+ }
+ else { YAHOO.util.AnimMgr.stop(tween, i); }
+ }
+ };
+
+ var getIndex = function(anim) {
+ for (var i = 0, len = queue.length; i < len; ++i) {
+ if (queue[i] == anim) {
+ return i; // note return;
+ }
+ }
+ return -1;
+ };
+
+ /**
+ * On the fly frame correction to keep animation on time.
+ * @private
+ * @param {Object} tween The Anim instance being corrected.
+ */
+ var correctFrame = function(tween) {
+ var frames = tween.totalFrames;
+ var frame = tween.currentFrame;
+ var expected = (tween.currentFrame * tween.duration * 1000 / tween.totalFrames);
+ var elapsed = (new Date() - tween.getStartTime());
+ var tweak = 0;
+
+ if (elapsed < tween.duration * 1000) { // check if falling behind
+ tweak = Math.round((elapsed / expected - 1) * tween.currentFrame);
+ } else { // went over duration, so jump to end
+ tweak = frames - (frame + 1);
+ }
+ if (tweak > 0 && isFinite(tweak)) { // adjust if needed
+ if (tween.currentFrame + tweak >= frames) {// dont go past last frame
+ tweak = frames - (frame + 1);
+ }
+
+ tween.currentFrame += tweak;
+ }
+ };
+};
+/**
+ *
+ * @class Used to calculate Bezier splines for any number of control points.
+ *
+ */
+YAHOO.util.Bezier = new function()
+{
+ /**
+ * Get the current position of the animated element based on t.
+ * Each point is an array of "x" and "y" values (0 = x, 1 = y)
+ * At least 2 points are required (start and end).
+ * First point is start. Last point is end.
+ * Additional control points are optional.
+ * @param {Array} points An array containing Bezier points
+ * @param {Number} t A number between 0 and 1 which is the basis for determining current position
+ * @return {Array} An array containing int x and y member data
+ */
+ this.getPosition = function(points, t)
+ {
+ var n = points.length;
+ var tmp = [];
+
+ for (var i = 0; i < n; ++i){
+ tmp[i] = [points[i][0], points[i][1]]; // save input
+ }
+
+ for (var j = 1; j < n; ++j) {
+ for (i = 0; i < n - j; ++i) {
+ tmp[i][0] = (1 - t) * tmp[i][0] + t * tmp[parseInt(i + 1, 10)][0];
+ tmp[i][1] = (1 - t) * tmp[i][1] + t * tmp[parseInt(i + 1, 10)][1];
+ }
+ }
+
+ return [ tmp[0][0], tmp[0][1] ];
+
+ };
+};
+/**
+ * @class ColorAnim subclass for color fading
+ * <p>Usage: <code>var myAnim = new Y.ColorAnim(el, { backgroundColor: { from: '#FF0000', to: '#FFFFFF' } }, 1, Y.Easing.easeOut);</code></p>
+ * <p>Color values can be specified with either 112233, #112233, [255,255,255], or rgb(255,255,255)
+ * @requires YAHOO.util.Anim
+ * @requires YAHOO.util.AnimMgr
+ * @requires YAHOO.util.Easing
+ * @requires YAHOO.util.Bezier
+ * @requires YAHOO.util.Dom
+ * @requires YAHOO.util.Event
+ * @constructor
+ * @param {HTMLElement | String} el Reference to the element that will be animated
+ * @param {Object} attributes The attribute(s) to be animated.
+ * Each attribute is an object with at minimum a "to" or "by" member defined.
+ * Additional optional members are "from" (defaults to current value), "units" (defaults to "px").
+ * All attribute names use camelCase.
+ * @param {Number} duration (optional, defaults to 1 second) Length of animation (frames or seconds), defaults to time-based
+ * @param {Function} method (optional, defaults to YAHOO.util.Easing.easeNone) Computes the values that are applied to the attributes per frame (generally a YAHOO.util.Easing method)
+ */
+(function() {
+ YAHOO.util.ColorAnim = function(el, attributes, duration, method) {
+ YAHOO.util.ColorAnim.superclass.constructor.call(this, el, attributes, duration, method);
+ };
+
+ YAHOO.extend(YAHOO.util.ColorAnim, YAHOO.util.Anim);
+
+ // shorthand
+ var Y = YAHOO.util;
+ var superclass = Y.ColorAnim.superclass;
+ var proto = Y.ColorAnim.prototype;
+
+ /**
+ * toString method
+ * @return {String} string represenation of anim obj
+ */
+ proto.toString = function() {
+ var el = this.getEl();
+ var id = el.id || el.tagName;
+ return ("ColorAnim " + id);
+ };
+
+ /**
+ * Only certain attributes should be treated as colors.
+ * @type Object
+ */
+ proto.patterns.color = /color$/i;
+ proto.patterns.rgb = /^rgb\(([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\)$/i;
+ proto.patterns.hex = /^#?([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})$/i;
+ proto.patterns.hex3 = /^#?([0-9A-F]{1})([0-9A-F]{1})([0-9A-F]{1})$/i;
+
+ /**
+ * Attempts to parse the given string and return a 3-tuple.
+ * @param {String} s The string to parse.
+ * @return {Array} The 3-tuple of rgb values.
+ */
+ proto.parseColor = function(s) {
+ if (s.length == 3) { return s; }
+
+ var c = this.patterns.hex.exec(s);
+ if (c && c.length == 4) {
+ return [ parseInt(c[1], 16), parseInt(c[2], 16), parseInt(c[3], 16) ];
+ }
+
+ c = this.patterns.rgb.exec(s);
+ if (c && c.length == 4) {
+ return [ parseInt(c[1], 10), parseInt(c[2], 10), parseInt(c[3], 10) ];
+ }
+
+ c = this.patterns.hex3.exec(s);
+ if (c && c.length == 4) {
+ return [ parseInt(c[1] + c[1], 16), parseInt(c[2] + c[2], 16), parseInt(c[3] + c[3], 16) ];
+ }
+
+ return null;
+ };
+
+ /**
+ * Returns current value of the attribute.
+ * @param {String} attr The name of the attribute.
+ * @return {Number} val The current value of the attribute.
+ */
+ proto.getAttribute = function(attr) {
+ var el = this.getEl();
+ if ( this.patterns.color.test(attr) ) {
+ var val = YAHOO.util.Dom.getStyle(el, attr);
+
+ if (val == 'transparent') { // bgcolor default
+ var parent = el.parentNode; // try and get from an ancestor
+ val = Y.Dom.getStyle(parent, attr);
+
+ while (parent && val == 'transparent') {
+ parent = parent.parentNode;
+ val = Y.Dom.getStyle(parent, attr);
+ if (parent.tagName.toUpperCase() == 'HTML') {
+ val = 'ffffff';
+ }
+ }
+ }
+ } else {
+ val = superclass.getAttribute.call(this, attr);
+ }
+
+ return val;
+ };
+
+ /**
+ * Returns the value computed by the animation's "method".
+ * @param {String} attr The name of the attribute.
+ * @param {Number} start The value this attribute should start from for this animation.
+ * @param {Number} end The value this attribute should end at for this animation.
+ * @return {Number} The Value to be applied to the attribute.
+ */
+ proto.doMethod = function(attr, start, end) {
+ var val;
+
+ if ( this.patterns.color.test(attr) ) {
+ val = [];
+ for (var i = 0, len = start.length; i < len; ++i) {
+ val[i] = superclass.doMethod.call(this, attr, start[i], end[i]);
+ }
+
+ val = 'rgb('+Math.floor(val[0])+','+Math.floor(val[1])+','+Math.floor(val[2])+')';
+ }
+ else {
+ val = superclass.doMethod.call(this, attr, start, end);
+ }
+
+ return val;
+ };
+
+ /**
+ * Sets the actual values to be used during the animation.
+ * Should only be needed for subclass use.
+ * @param {Object} attr The attribute object
+ * @private
+ */
+ proto.setRuntimeAttribute = function(attr) {
+ superclass.setRuntimeAttribute.call(this, attr);
+
+ if ( this.patterns.color.test(attr) ) {
+ var attributes = this.attributes;
+ var start = this.parseColor(this.runtimeAttributes[attr].start);
+ var end = this.parseColor(this.runtimeAttributes[attr].end);
+ // fix colors if going "by"
+ if ( typeof attributes[attr]['to'] === 'undefined' && typeof attributes[attr]['by'] !== 'undefined' ) {
+ end = this.parseColor(attributes[attr].by);
+
+ for (var i = 0, len = start.length; i < len; ++i) {
+ end[i] = start[i] + end[i];
+ }
+ }
+
+ this.runtimeAttributes[attr].start = start;
+ this.runtimeAttributes[attr].end = end;
+ }
+ };
+})();/*
+TERMS OF USE - EASING EQUATIONS
+Open source under the BSD License.
+Copyright © 2001 Robert Penner All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+ * Neither the name of the author nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+*/
+
+YAHOO.util.Easing = {
+
+ /**
+ * Uniform speed between points.
+ * @param {Number} t Time value used to compute current value.
+ * @param {Number} b Starting value.
+ * @param {Number} c Delta between start and end values.
+ * @param {Number} d Total length of animation.
+ * @return {Number} The computed value for the current animation frame.
+ */
+ easeNone: function (t, b, c, d) {
+ return c*t/d + b;
+ },
+
+ /**
+ * Begins slowly and accelerates towards end. (quadratic)
+ * @param {Number} t Time value used to compute current value.
+ * @param {Number} b Starting value.
+ * @param {Number} c Delta between start and end values.
+ * @param {Number} d Total length of animation.
+ * @return {Number} The computed value for the current animation frame.
+ */
+ easeIn: function (t, b, c, d) {
+ return c*(t/=d)*t + b;
+ },
+
+ /**
+ * Begins quickly and decelerates towards end. (quadratic)
+ * @param {Number} t Time value used to compute current value.
+ * @param {Number} b Starting value.
+ * @param {Number} c Delta between start and end values.
+ * @param {Number} d Total length of animation.
+ * @return {Number} The computed value for the current animation frame.
+ */
+ easeOut: function (t, b, c, d) {
+ return -c *(t/=d)*(t-2) + b;
+ },
+
+ /**
+ * Begins slowly and decelerates towards end. (quadratic)
+ * @param {Number} t Time value used to compute current value.
+ * @param {Number} b Starting value.
+ * @param {Number} c Delta between start and end values.
+ * @param {Number} d Total length of animation.
+ * @return {Number} The computed value for the current animation frame.
+ */
+ easeBoth: function (t, b, c, d) {
+ if ((t/=d/2) < 1) return c/2*t*t + b;
+ return -c/2 * ((--t)*(t-2) - 1) + b;
+ },
+
+ /**
+ * Begins slowly and accelerates towards end. (quartic)
+ * @param {Number} t Time value used to compute current value.
+ * @param {Number} b Starting value.
+ * @param {Number} c Delta between start and end values.
+ * @param {Number} d Total length of animation.
+ * @return {Number} The computed value for the current animation frame.
+ */
+ easeInStrong: function (t, b, c, d) {
+ return c*(t/=d)*t*t*t + b;
+ },
+
+ /**
+ * Begins quickly and decelerates towards end. (quartic)
+ * @param {Number} t Time value used to compute current value.
+ * @param {Number} b Starting value.
+ * @param {Number} c Delta between start and end values.
+ * @param {Number} d Total length of animation.
+ * @return {Number} The computed value for the current animation frame.
+ */
+ easeOutStrong: function (t, b, c, d) {
+ return -c * ((t=t/d-1)*t*t*t - 1) + b;
+ },
+
+ /**
+ * Begins slowly and decelerates towards end. (quartic)
+ * @param {Number} t Time value used to compute current value.
+ * @param {Number} b Starting value.
+ * @param {Number} c Delta between start and end values.
+ * @param {Number} d Total length of animation.
+ * @return {Number} The computed value for the current animation frame.
+ */
+ easeBothStrong: function (t, b, c, d) {
+ if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
+ return -c/2 * ((t-=2)*t*t*t - 2) + b;
+ },
+
+ /**
+ * snap in elastic effect
+ * @param {Number} t Time value used to compute current value.
+ * @param {Number} b Starting value.
+ * @param {Number} c Delta between start and end values.
+ * @param {Number} d Total length of animation.
+ * @param {Number} p Period (optional)
+ * @return {Number} The computed value for the current animation frame.
+ */
+
+ elasticIn: function (t, b, c, d, a, p) {
+ if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
+ if (!a || a < Math.abs(c)) { a=c; var s=p/4; }
+ else var s = p/(2*Math.PI) * Math.asin (c/a);
+ return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
+ },
+
+ /**
+ * snap out elastic effect
+ * @param {Number} t Time value used to compute current value.
+ * @param {Number} b Starting value.
+ * @param {Number} c Delta between start and end values.
+ * @param {Number} d Total length of animation.
+ * @param {Number} p Period (optional)
+ * @return {Number} The computed value for the current animation frame.
+ */
+ elasticOut: function (t, b, c, d, a, p) {
+ if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
+ if (!a || a < Math.abs(c)) { a=c; var s=p/4; }
+ else var s = p/(2*Math.PI) * Math.asin (c/a);
+ return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
+ },
+
+ /**
+ * snap both elastic effect
+ * @param {Number} t Time value used to compute current value.
+ * @param {Number} b Starting value.
+ * @param {Number} c Delta between start and end values.
+ * @param {Number} d Total length of animation.
+ * @param {Number} p Period (optional)
+ * @return {Number} The computed value for the current animation frame.
+ */
+ elasticBoth: function (t, b, c, d, a, p) {
+ if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5);
+ if (!a || a < Math.abs(c)) { a=c; var s=p/4; }
+ else var s = p/(2*Math.PI) * Math.asin (c/a);
+ if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
+ return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
+ },
+
+
+ /**
+ * back easing in - backtracking slightly, then reversing direction and moving to target
+ * @param {Number} t Time value used to compute current value.
+ * @param {Number} b Starting value.
+ * @param {Number} c Delta between start and end values.
+ * @param {Number} d Total length of animation.
+ * @param {Number) s Overshoot (optional)
+ * @return {Number} The computed value for the current animation frame.
+ */
+ backIn: function (t, b, c, d, s) {
+ if (typeof s == 'undefined') s = 1.70158;
+ return c*(t/=d)*t*((s+1)*t - s) + b;
+ },
+
+ /**
+ * back easing out - moving towards target, overshooting it slightly,
+ * then reversing and coming back to target
+ * @param {Number} t Time value used to compute current value.
+ * @param {Number} b Starting value.
+ * @param {Number} c Delta between start and end values.
+ * @param {Number} d Total length of animation.
+ * @param {Number) s Overshoot (optional)
+ * @return {Number} The computed value for the current animation frame.
+ */
+ backOut: function (t, b, c, d, s) {
+ if (typeof s == 'undefined') s = 1.70158;
+ return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
+ },
+
+ /**
+ * back easing in/out - backtracking slightly, then reversing direction and moving to target,
+ * then overshooting target, reversing, and finally coming back to target
+ * @param {Number} t Time value used to compute current value.
+ * @param {Number} b Starting value.
+ * @param {Number} c Delta between start and end values.
+ * @param {Number} d Total length of animation.
+ * @param {Number) s Overshoot (optional)
+ * @return {Number} The computed value for the current animation frame.
+ */
+ backBoth: function (t, b, c, d, s) {
+ if (typeof s == 'undefined') s = 1.70158;
+ if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
+ return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
+ },
+
+ /**
+ * bounce in
+ * @param {Number} t Time value used to compute current value.
+ * @param {Number} b Starting value.
+ * @param {Number} c Delta between start and end values.
+ * @param {Number} d Total length of animation.
+ * @return {Number} The computed value for the current animation frame.
+ */
+ bounceIn: function (t, b, c, d) {
+ return c - YAHOO.util.Easing.bounceOut(d-t, 0, c, d) + b;
+ },
+
+ /**
+ * bounce out
+ * @param {Number} t Time value used to compute current value.
+ * @param {Number} b Starting value.
+ * @param {Number} c Delta between start and end values.
+ * @param {Number} d Total length of animation.
+ * @return {Number} The computed value for the current animation frame.
+ */
+ bounceOut: function (t, b, c, d) {
+ if ((t/=d) < (1/2.75)) {
+ return c*(7.5625*t*t) + b;
+ } else if (t < (2/2.75)) {
+ return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
+ } else if (t < (2.5/2.75)) {
+ return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
+ } else {
+ return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
+ }
+ },
+
+ /**
+ * bounce both
+ * @param {Number} t Time value used to compute current value.
+ * @param {Number} b Starting value.
+ * @param {Number} c Delta between start and end values.
+ * @param {Number} d Total length of animation.
+ * @return {Number} The computed value for the current animation frame.
+ */
+ bounceBoth: function (t, b, c, d) {
+ if (t < d/2) return YAHOO.util.Easing.bounceIn(t*2, 0, c, d) * .5 + b;
+ return YAHOO.util.Easing.bounceOut(t*2-d, 0, c, d) * .5 + c*.5 + b;
+ }
+};
+
+/**
+ * @class Anim subclass for moving elements along a path defined by the "points" member of "attributes". All "points" are arrays with x, y coordinates.
+ * <p>Usage: <code>var myAnim = new YAHOO.util.Motion(el, { points: { to: [800, 800] } }, 1, YAHOO.util.Easing.easeOut);</code></p>
+ * @requires YAHOO.util.Anim
+ * @requires YAHOO.util.AnimMgr
+ * @requires YAHOO.util.Easing
+ * @requires YAHOO.util.Bezier
+ * @requires YAHOO.util.Dom
+ * @requires YAHOO.util.Event
+ * @requires YAHOO.util.CustomEvent
+ * @constructor
+ * @param {String or HTMLElement} el Reference to the element that will be animated
+ * @param {Object} attributes The attribute(s) to be animated.
+ * Each attribute is an object with at minimum a "to" or "by" member defined.
+ * Additional optional members are "from" (defaults to current value), "units" (defaults to "px").
+ * All attribute names use camelCase.
+ * @param {Number} duration (optional, defaults to 1 second) Length of animation (frames or seconds), defaults to time-based
+ * @param {Function} method (optional, defaults to YAHOO.util.Easing.easeNone) Computes the values that are applied to the attributes per frame (generally a YAHOO.util.Easing method)
+ */
+(function() {
+ YAHOO.util.Motion = function(el, attributes, duration, method) {
+ if (el) { // dont break existing subclasses not using YAHOO.extend
+ YAHOO.util.Motion.superclass.constructor.call(this, el, attributes, duration, method);
+ }
+ };
+
+ YAHOO.extend(YAHOO.util.Motion, YAHOO.util.ColorAnim);
+
+ // shorthand
+ var Y = YAHOO.util;
+ var superclass = Y.Motion.superclass;
+ var proto = Y.Motion.prototype;
+
+ /**
+ * toString method
+ * @return {String} string represenation of anim obj
+ */
+ proto.toString = function() {
+ var el = this.getEl();
+ var id = el.id || el.tagName;
+ return ("Motion " + id);
+ };
+
+ proto.patterns.points = /^points$/i;
+
+ /**
+ * Applies a value to an attribute
+ * @param {String} attr The name of the attribute.
+ * @param {Number} val The value to be applied to the attribute.
+ * @param {String} unit The unit ('px', '%', etc.) of the value.
+ */
+ proto.setAttribute = function(attr, val, unit) {
+ if ( this.patterns.points.test(attr) ) {
+ unit = unit || 'px';
+ superclass.setAttribute.call(this, 'left', val[0], unit);
+ superclass.setAttribute.call(this, 'top', val[1], unit);
+ } else {
+ superclass.setAttribute.call(this, attr, val, unit);
+ }
+ };
+
+ /**
+ * Sets the default value to be used when "from" is not supplied.
+ * @param {String} attr The attribute being set.
+ * @param {Number} val The default value to be applied to the attribute.
+ */
+ proto.getAttribute = function(attr) {
+ if ( this.patterns.points.test(attr) ) {
+ var val = [
+ superclass.getAttribute.call(this, 'left'),
+ superclass.getAttribute.call(this, 'top')
+ ];
+ } else {
+ val = superclass.getAttribute.call(this, attr);
+ }
+
+ return val;
+ };
+
+ /**
+ * Returns the value computed by the animation's "method".
+ * @param {String} attr The name of the attribute.
+ * @param {Number} start The value this attribute should start from for this animation.
+ * @param {Number} end The value this attribute should end at for this animation.
+ * @return {Number} The Value to be applied to the attribute.
+ */
+ proto.doMethod = function(attr, start, end) {
+ var val = null;
+
+ if ( this.patterns.points.test(attr) ) {
+ var t = this.method(this.currentFrame, 0, 100, this.totalFrames) / 100;
+ val = Y.Bezier.getPosition(this.runtimeAttributes[attr], t);
+ } else {
+ val = superclass.doMethod.call(this, attr, start, end);
+ }
+ return val;
+ };
+
+ /**
+ * Sets the actual values to be used during the animation.
+ * Should only be needed for subclass use.
+ * @param {Object} attr The attribute object
+ * @private
+ */
+ proto.setRuntimeAttribute = function(attr) {
+ if ( this.patterns.points.test(attr) ) {
+ var el = this.getEl();
+ var attributes = this.attributes;
+ var start;
+ var control = attributes['points']['control'] || [];
+ var end;
+ var i, len;
+
+ if (control.length > 0 && !(control[0] instanceof Array) ) { // could be single point or array of points
+ control = [control];
+ } else { // break reference to attributes.points.control
+ var tmp = [];
+ for (i = 0, len = control.length; i< len; ++i) {
+ tmp[i] = control[i];
+ }
+ control = tmp;
+ }
+
+ if (Y.Dom.getStyle(el, 'position') == 'static') { // default to relative
+ Y.Dom.setStyle(el, 'position', 'relative');
+ }
+
+ if ( isset(attributes['points']['from']) ) {
+ Y.Dom.setXY(el, attributes['points']['from']); // set position to from point
+ }
+ else { Y.Dom.setXY( el, Y.Dom.getXY(el) ); } // set it to current position
+
+ start = this.getAttribute('points'); // get actual top & left
+
+ // TO beats BY, per SMIL 2.1 spec
+ if ( isset(attributes['points']['to']) ) {
+ end = translateValues.call(this, attributes['points']['to'], start);
+
+ var pageXY = Y.Dom.getXY(this.getEl());
+ for (i = 0, len = control.length; i < len; ++i) {
+ control[i] = translateValues.call(this, control[i], start);
+ }
+
+
+ } else if ( isset(attributes['points']['by']) ) {
+ end = [ start[0] + attributes['points']['by'][0], start[1] + attributes['points']['by'][1] ];
+
+ for (i = 0, len = control.length; i < len; ++i) {
+ control[i] = [ start[0] + control[i][0], start[1] + control[i][1] ];
+ }
+ }
+
+ this.runtimeAttributes[attr] = [start];
+
+ if (control.length > 0) {
+ this.runtimeAttributes[attr] = this.runtimeAttributes[attr].concat(control);
+ }
+
+ this.runtimeAttributes[attr][this.runtimeAttributes[attr].length] = end;
+ }
+ else {
+ superclass.setRuntimeAttribute.call(this, attr);
+ }
+ };
+
+ var translateValues = function(val, start) {
+ var pageXY = Y.Dom.getXY(this.getEl());
+ val = [ val[0] - pageXY[0] + start[0], val[1] - pageXY[1] + start[1] ];
+
+ return val;
+ };
+
+ var isset = function(prop) {
+ return (typeof prop !== 'undefined');
+ };
+})();
+/**
+ * @class Anim subclass for scrolling elements to a position defined by the "scroll" member of "attributes". All "scroll" members are arrays with x, y scroll positions.
+ * <p>Usage: <code>var myAnim = new YAHOO.util.Scroll(el, { scroll: { to: [0, 800] } }, 1, YAHOO.util.Easing.easeOut);</code></p>
+ * @requires YAHOO.util.Anim
+ * @requires YAHOO.util.AnimMgr
+ * @requires YAHOO.util.Easing
+ * @requires YAHOO.util.Bezier
+ * @requires YAHOO.util.Dom
+ * @requires YAHOO.util.Event
+ * @requires YAHOO.util.CustomEvent
+ * @constructor
+ * @param {String or HTMLElement} el Reference to the element that will be animated
+ * @param {Object} attributes The attribute(s) to be animated.
+ * Each attribute is an object with at minimum a "to" or "by" member defined.
+ * Additional optional members are "from" (defaults to current value), "units" (defaults to "px").
+ * All attribute names use camelCase.
+ * @param {Number} duration (optional, defaults to 1 second) Length of animation (frames or seconds), defaults to time-based
+ * @param {Function} method (optional, defaults to YAHOO.util.Easing.easeNone) Computes the values that are applied to the attributes per frame (generally a YAHOO.util.Easing method)
+ */
+(function() {
+ YAHOO.util.Scroll = function(el, attributes, duration, method) {
+ if (el) { // dont break existing subclasses not using YAHOO.extend
+ YAHOO.util.Scroll.superclass.constructor.call(this, el, attributes, duration, method);
+ }
+ };
+
+ YAHOO.extend(YAHOO.util.Scroll, YAHOO.util.ColorAnim);
+
+ // shorthand
+ var Y = YAHOO.util;
+ var superclass = Y.Scroll.superclass;
+ var proto = Y.Scroll.prototype;
+
+ /**
+ * toString method
+ * @return {String} string represenation of anim obj
+ */
+ proto.toString = function() {
+ var el = this.getEl();
+ var id = el.id || el.tagName;
+ return ("Scroll " + id);
+ };
+
+ /**
+ * Returns the value computed by the animation's "method".
+ * @param {String} attr The name of the attribute.
+ * @param {Number} start The value this attribute should start from for this animation.
+ * @param {Number} end The value this attribute should end at for this animation.
+ * @return {Number} The Value to be applied to the attribute.
+ */
+ proto.doMethod = function(attr, start, end) {
+ var val = null;
+
+ if (attr == 'scroll') {
+ val = [
+ this.method(this.currentFrame, start[0], end[0] - start[0], this.totalFrames),
+ this.method(this.currentFrame, start[1], end[1] - start[1], this.totalFrames)
+ ];
+
+ } else {
+ val = superclass.doMethod.call(this, attr, start, end);
+ }
+ return val;
+ };
+
+ /**
+ * Returns current value of the attribute.
+ * @param {String} attr The name of the attribute.
+ * @return {Number} val The current value of the attribute.
+ */
+ proto.getAttribute = function(attr) {
+ var val = null;
+ var el = this.getEl();
+
+ if (attr == 'scroll') {
+ val = [ el.scrollLeft, el.scrollTop ];
+ } else {
+ val = superclass.getAttribute.call(this, attr);
+ }
+
+ return val;
+ };
+
+ /**
+ * Applies a value to an attribute
+ * @param {String} attr The name of the attribute.
+ * @param {Number} val The value to be applied to the attribute.
+ * @param {String} unit The unit ('px', '%', etc.) of the value.
+ */
+ proto.setAttribute = function(attr, val, unit) {
+ var el = this.getEl();
+
+ if (attr == 'scroll') {
+ el.scrollLeft = val[0];
+ el.scrollTop = val[1];
+ } else {
+ superclass.setAttribute.call(this, attr, val, unit);
+ }
+ };
+})();
Added: branches/tomek/portal-dnd/dndRenderer.war/js/animation/animation-min.js
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/animation/animation-min.js 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/animation/animation-min.js 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1 @@
+/* Copyright (c) 2006, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.net/yui/license.txt Version: 0.11.1 */ YAHOO.util.Anim=function(el,attributes,duration,method){if(el){this.init(el,attributes,duration,method);}};YAHOO.util.Anim.prototype={toString:function(){var el=this.getEl();var id=el.id||el.tagName;return("Anim "+id);},patterns:{noNegatives:/width|height|opacity|padding/i,offsetAttribute:/^((width|height)|(top|left))$/,defaultUnit:/width|height|top$|bottom$|left$|right$/i,offsetUnit:/\d+(em|%|en|ex|pt|in|cm|mm|pc)$/i},doMethod:function(attr,start,end){return this.method(this.currentFrame,start,end-start,this.totalFrames);},setAttribute:function(attr,val,unit){if(this.patterns.noNegatives.test(attr)){val=(val>0)?val:0;}YAHOO.util.Dom.setStyle(this.getEl(),attr,val+unit);},getAttribute:function(attr){var el=this.getEl();var val=YAHOO.util.Dom.getStyle(el,attr);if(val!=='auto'&&!this.patterns.offsetUnit.test(val)){return p!
arseFloat(val);}var a=this.patterns.offsetAttribute.exec(attr)||[];var pos=!!(a[3]);var box=!!(a[2]);if(box||(YAHOO.util.Dom.getStyle(el,'position')=='absolute'&&pos)){val=el['offset'+a[0].charAt(0).toUpperCase()+a[0].substr(1)];}else{val=0;}return val;},getDefaultUnit:function(attr){if(this.patterns.defaultUnit.test(attr)){return'px';}return'';},setRuntimeAttribute:function(attr){var start;var end;var attributes=this.attributes;this.runtimeAttributes[attr]={};var isset=function(prop){return(typeof prop!=='undefined');};if(!isset(attributes[attr]['to'])&&!isset(attributes[attr]['by'])){return false;}start=(isset(attributes[attr]['from']))?attributes[attr]['from']:this.getAttribute(attr);if(isset(attributes[attr]['to'])){end=attributes[attr]['to'];}else if(isset(attributes[attr]['by'])){if(start.constructor==Array){end=[];for(var i=0,len=start.length;i<len;++i){end[i]=start[i]+attributes[attr]['by'][i];}}else{end=start+attributes[attr]['by'];}}this.runtimeAttributes[attr].st!
art=start;this.runtimeAttributes[attr].end=end;this.runtimeAttributes[
attr].unit=(isset(attributes[attr].unit))?attributes[attr]['unit']:this.getDefaultUnit(attr);},init:function(el,attributes,duration,method){var isAnimated=false;var startTime=null;var actualFrames=0;el=YAHOO.util.Dom.get(el);this.attributes=attributes||{};this.duration=duration||1;this.method=method||YAHOO.util.Easing.easeNone;this.useSeconds=true;this.currentFrame=0;this.totalFrames=YAHOO.util.AnimMgr.fps;this.getEl=function(){return el;};this.isAnimated=function(){return isAnimated;};this.getStartTime=function(){return startTime;};this.runtimeAttributes={};this.animate=function(){if(this.isAnimated()){return false;}this.currentFrame=0;this.totalFrames=(this.useSeconds)?Math.ceil(YAHOO.util.AnimMgr.fps*this.duration):this.duration;YAHOO.util.AnimMgr.registerElement(this);};this.stop=function(){YAHOO.util.AnimMgr.stop(this);};var onStart=function(){this.onStart.fire();for(var attr in this.attributes){this.setRuntimeAttribute(attr);}isAnimated=true;actualFrames=0;startTime=ne!
w Date();};var onTween=function(){var data={duration:new Date()-this.getStartTime(),currentFrame:this.currentFrame};data.toString=function(){return('duration: '+data.duration+', currentFrame: '+data.currentFrame);};this.onTween.fire(data);var runtimeAttributes=this.runtimeAttributes;for(var attr in runtimeAttributes){this.setAttribute(attr,this.doMethod(attr,runtimeAttributes[attr].start,runtimeAttributes[attr].end),runtimeAttributes[attr].unit);}actualFrames+=1;};var onComplete=function(){var actual_duration=(new Date()-startTime)/1000;var data={duration:actual_duration,frames:actualFrames,fps:actualFrames/actual_duration};data.toString=function(){return('duration: '+data.duration+', frames: '+data.frames+', fps: '+data.fps);};isAnimated=false;actualFrames=0;this.onComplete.fire(data);};this._onStart=new YAHOO.util.CustomEvent('_start',this,true);this.onStart=new YAHOO.util.CustomEvent('start',this);this.onTween=new YAHOO.util.CustomEvent('tween',this);this._onTween=new YA!
HOO.util.CustomEvent('_tween',this,true);this.onComplete=new YAHOO.uti
l.CustomEvent('complete',this);this._onComplete=new YAHOO.util.CustomEvent('_complete',this,true);this._onStart.subscribe(onStart);this._onTween.subscribe(onTween);this._onComplete.subscribe(onComplete);}};YAHOO.util.AnimMgr=new function(){var thread=null;var queue=[];var tweenCount=0;this.fps=200;this.delay=1;this.registerElement=function(tween){queue[queue.length]=tween;tweenCount+=1;tween._onStart.fire();this.start();};this.unRegister=function(tween,index){tween._onComplete.fire();index=index||getIndex(tween);if(index!=-1){queue.splice(index,1);}tweenCount-=1;if(tweenCount<=0){this.stop();}};this.start=function(){if(thread===null){thread=setInterval(this.run,this.delay);}};this.stop=function(tween){if(!tween){clearInterval(thread);for(var i=0,len=queue.length;i<len;++i){if(queue[i].isAnimated()){this.unRegister(tween,i);}}queue=[];thread=null;tweenCount=0;}else{this.unRegister(tween);}};this.run=function(){for(var i=0,len=queue.length;i<len;++i){var tween=queue[i];if(!twe!
en||!tween.isAnimated()){continue;}if(tween.currentFrame<tween.totalFrames||tween.totalFrames===null){tween.currentFrame+=1;if(tween.useSeconds){correctFrame(tween);}tween._onTween.fire();}else{YAHOO.util.AnimMgr.stop(tween,i);}}};var getIndex=function(anim){for(var i=0,len=queue.length;i<len;++i){if(queue[i]==anim){return i;}}return-1;};var correctFrame=function(tween){var frames=tween.totalFrames;var frame=tween.currentFrame;var expected=(tween.currentFrame*tween.duration*1000/tween.totalFrames);var elapsed=(new Date()-tween.getStartTime());var tweak=0;if(elapsed<tween.duration*1000){tweak=Math.round((elapsed/expected-1)*tween.currentFrame);}else{tweak=frames-(frame+1);}if(tweak>0&&isFinite(tweak)){if(tween.currentFrame+tweak>=frames){tweak=frames-(frame+1);}tween.currentFrame+=tweak;}};};YAHOO.util.Bezier=new function(){this.getPosition=function(points,t){var n=points.length;var tmp=[];for(var i=0;i<n;++i){tmp[i]=[points[i][0],points[i][1]];}for(var j=1;j<n;++j){for(i=0;!
i<n-j;++i){tmp[i][0]=(1-t)*tmp[i][0]+t*tmp[parseInt(i+1,10)][0];tmp[i]
[1]=(1-t)*tmp[i][1]+t*tmp[parseInt(i+1,10)][1];}}return[tmp[0][0],tmp[0][1]];};};(function(){YAHOO.util.ColorAnim=function(el,attributes,duration,method){YAHOO.util.ColorAnim.superclass.constructor.call(this,el,attributes,duration,method);};YAHOO.extend(YAHOO.util.ColorAnim,YAHOO.util.Anim);var Y=YAHOO.util;var superclass=Y.ColorAnim.superclass;var proto=Y.ColorAnim.prototype;proto.toString=function(){var el=this.getEl();var id=el.id||el.tagName;return("ColorAnim "+id);};proto.patterns.color=/color$/i;proto.patterns.rgb=/^rgb\(([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\)$/i;proto.patterns.hex=/^#?([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})$/i;proto.patterns.hex3=/^#?([0-9A-F]{1})([0-9A-F]{1})([0-9A-F]{1})$/i;proto.parseColor=function(s){if(s.length==3){return s;}var c=this.patterns.hex.exec(s);if(c&&c.length==4){return[parseInt(c[1],16),parseInt(c[2],16),parseInt(c[3],16)];}c=this.patterns.rgb.exec(s);if(c&&c.length==4){return[parseInt(c[1],10),parseInt(c[2],10),parseInt(c[3],10)];}!
c=this.patterns.hex3.exec(s);if(c&&c.length==4){return[parseInt(c[1]+c[1],16),parseInt(c[2]+c[2],16),parseInt(c[3]+c[3],16)];}return null;};proto.getAttribute=function(attr){var el=this.getEl();if(this.patterns.color.test(attr)){var val=YAHOO.util.Dom.getStyle(el,attr);if(val=='transparent'){var parent=el.parentNode;val=Y.Dom.getStyle(parent,attr);while(parent&&val=='transparent'){parent=parent.parentNode;val=Y.Dom.getStyle(parent,attr);if(parent.tagName.toUpperCase()=='HTML'){val='ffffff';}}}}else{val=superclass.getAttribute.call(this,attr);}return val;};proto.doMethod=function(attr,start,end){var val;if(this.patterns.color.test(attr)){val=[];for(var i=0,len=start.length;i<len;++i){val[i]=superclass.doMethod.call(this,attr,start[i],end[i]);}val='rgb('+Math.floor(val[0])+','+Math.floor(val[1])+','+Math.floor(val[2])+')';}else{val=superclass.doMethod.call(this,attr,start,end);}return val;};proto.setRuntimeAttribute=function(attr){superclass.setRuntimeAttribute.call(this,attr!
);if(this.patterns.color.test(attr)){var attributes=this.attributes;va
r start=this.parseColor(this.runtimeAttributes[attr].start);var end=this.parseColor(this.runtimeAttributes[attr].end);if(typeof attributes[attr]['to']==='undefined'&&typeof attributes[attr]['by']!=='undefined'){end=this.parseColor(attributes[attr].by);for(var i=0,len=start.length;i<len;++i){end[i]=start[i]+end[i];}}this.runtimeAttributes[attr].start=start;this.runtimeAttributes[attr].end=end;}};})();YAHOO.util.Easing={easeNone:function(t,b,c,d){return c*t/d+b;},easeIn:function(t,b,c,d){return c*(t/=d)*t+b;},easeOut:function(t,b,c,d){return-c*(t/=d)*(t-2)+b;},easeBoth:function(t,b,c,d){if((t/=d/2)<1)return c/2*t*t+b;return-c/2*((--t)*(t-2)-1)+b;},easeInStrong:function(t,b,c,d){return c*(t/=d)*t*t*t+b;},easeOutStrong:function(t,b,c,d){return-c*((t=t/d-1)*t*t*t-1)+b;},easeBothStrong:function(t,b,c,d){if((t/=d/2)<1)return c/2*t*t*t*t+b;return-c/2*((t-=2)*t*t*t-2)+b;},elasticIn:function(t,b,c,d,a,p){if(t==0)return b;if((t/=d)==1)return b+c;if(!p)p=d*.3;if(!a||a<Math.abs(c)){a=c;v!
ar s=p/4;}else var s=p/(2*Math.PI)*Math.asin(c/a);return-(a*Math.pow(2,10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p))+b;},elasticOut:function(t,b,c,d,a,p){if(t==0)return b;if((t/=d)==1)return b+c;if(!p)p=d*.3;if(!a||a<Math.abs(c)){a=c;var s=p/4;}else var s=p/(2*Math.PI)*Math.asin(c/a);return a*Math.pow(2,-10*t)*Math.sin((t*d-s)*(2*Math.PI)/p)+c+b;},elasticBoth:function(t,b,c,d,a,p){if(t==0)return b;if((t/=d/2)==2)return b+c;if(!p)p=d*(.3*1.5);if(!a||a<Math.abs(c)){a=c;var s=p/4;}else var s=p/(2*Math.PI)*Math.asin(c/a);if(t<1)return-.5*(a*Math.pow(2,10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p))+b;return a*Math.pow(2,-10*(t-=1))*Math.sin((t*d-s)*(2*Math.PI)/p)*.5+c+b;},backIn:function(t,b,c,d,s){if(typeof s=='undefined')s=1.70158;return c*(t/=d)*t*((s+1)*t-s)+b;},backOut:function(t,b,c,d,s){if(typeof s=='undefined')s=1.70158;return c*((t=t/d-1)*t*((s+1)*t+s)+1)+b;},backBoth:function(t,b,c,d,s){if(typeof s=='undefined')s=1.70158;if((t/=d/2)<1)return c/2*(t*t*(((s*=(1.525))+1)*t-s))!
+b;return c/2*((t-=2)*t*(((s*=(1.525))+1)*t+s)+2)+b;},bounceIn:functio
n(t,b,c,d){return c-YAHOO.util.Easing.bounceOut(d-t,0,c,d)+b;},bounceOut:function(t,b,c,d){if((t/=d)<(1/2.75)){return c*(7.5625*t*t)+b;}else if(t<(2/2.75)){return c*(7.5625*(t-=(1.5/2.75))*t+.75)+b;}else if(t<(2.5/2.75)){return c*(7.5625*(t-=(2.25/2.75))*t+.9375)+b;}else{return c*(7.5625*(t-=(2.625/2.75))*t+.984375)+b;}},bounceBoth:function(t,b,c,d){if(t<d/2)return YAHOO.util.Easing.bounceIn(t*2,0,c,d)*.5+b;return YAHOO.util.Easing.bounceOut(t*2-d,0,c,d)*.5+c*.5+b;}};(function(){YAHOO.util.Motion=function(el,attributes,duration,method){if(el){YAHOO.util.Motion.superclass.constructor.call(this,el,attributes,duration,method);}};YAHOO.extend(YAHOO.util.Motion,YAHOO.util.ColorAnim);var Y=YAHOO.util;var superclass=Y.Motion.superclass;var proto=Y.Motion.prototype;proto.toString=function(){var el=this.getEl();var id=el.id||el.tagName;return("Motion "+id);};proto.patterns.points=/^points$/i;proto.setAttribute=function(attr,val,unit){if(this.patterns.points.test(attr)){unit=unit||'px!
';superclass.setAttribute.call(this,'left',val[0],unit);superclass.setAttribute.call(this,'top',val[1],unit);}else{superclass.setAttribute.call(this,attr,val,unit);}};proto.getAttribute=function(attr){if(this.patterns.points.test(attr)){var val=[superclass.getAttribute.call(this,'left'),superclass.getAttribute.call(this,'top')];}else{val=superclass.getAttribute.call(this,attr);}return val;};proto.doMethod=function(attr,start,end){var val=null;if(this.patterns.points.test(attr)){var t=this.method(this.currentFrame,0,100,this.totalFrames)/100;val=Y.Bezier.getPosition(this.runtimeAttributes[attr],t);}else{val=superclass.doMethod.call(this,attr,start,end);}return val;};proto.setRuntimeAttribute=function(attr){if(this.patterns.points.test(attr)){var el=this.getEl();var attributes=this.attributes;var start;var control=attributes['points']['control']||[];var end;var i,len;if(control.length>0&&!(control[0]instanceof Array)){control=[control];}else{var tmp=[];for(i=0,len=control.len!
gth;i<len;++i){tmp[i]=control[i];}control=tmp;}if(Y.Dom.getStyle(el,'p
osition')=='static'){Y.Dom.setStyle(el,'position','relative');}if(isset(attributes['points']['from'])){Y.Dom.setXY(el,attributes['points']['from']);}else{Y.Dom.setXY(el,Y.Dom.getXY(el));}start=this.getAttribute('points');if(isset(attributes['points']['to'])){end=translateValues.call(this,attributes['points']['to'],start);var pageXY=Y.Dom.getXY(this.getEl());for(i=0,len=control.length;i<len;++i){control[i]=translateValues.call(this,control[i],start);}}else if(isset(attributes['points']['by'])){end=[start[0]+attributes['points']['by'][0],start[1]+attributes['points']['by'][1]];for(i=0,len=control.length;i<len;++i){control[i]=[start[0]+control[i][0],start[1]+control[i][1]];}}this.runtimeAttributes[attr]=[start];if(control.length>0){this.runtimeAttributes[attr]=this.runtimeAttributes[attr].concat(control);}this.runtimeAttributes[attr][this.runtimeAttributes[attr].length]=end;}else{superclass.setRuntimeAttribute.call(this,attr);}};var translateValues=function(val,start){var pageX!
Y=Y.Dom.getXY(this.getEl());val=[val[0]-pageXY[0]+start[0],val[1]-pageXY[1]+start[1]];return val;};var isset=function(prop){return(typeof prop!=='undefined');};})();(function(){YAHOO.util.Scroll=function(el,attributes,duration,method){if(el){YAHOO.util.Scroll.superclass.constructor.call(this,el,attributes,duration,method);}};YAHOO.extend(YAHOO.util.Scroll,YAHOO.util.ColorAnim);var Y=YAHOO.util;var superclass=Y.Scroll.superclass;var proto=Y.Scroll.prototype;proto.toString=function(){var el=this.getEl();var id=el.id||el.tagName;return("Scroll "+id);};proto.doMethod=function(attr,start,end){var val=null;if(attr=='scroll'){val=[this.method(this.currentFrame,start[0],end[0]-start[0],this.totalFrames),this.method(this.currentFrame,start[1],end[1]-start[1],this.totalFrames)];}else{val=superclass.doMethod.call(this,attr,start,end);}return val;};proto.getAttribute=function(attr){var val=null;var el=this.getEl();if(attr=='scroll'){val=[el.scrollLeft,el.scrollTop];}else{val=superclass!
.getAttribute.call(this,attr);}return val;};proto.setAttribute=functio
n(attr,val,unit){var el=this.getEl();if(attr=='scroll'){el.scrollLeft=val[0];el.scrollTop=val[1];}else{superclass.setAttribute.call(this,attr,val,unit);}};})();
Added: branches/tomek/portal-dnd/dndRenderer.war/js/animation/animation.js
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/animation/animation.js 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/animation/animation.js 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,1255 @@
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+Version: 0.11.1
+*/
+/**
+ *
+ * Base class for animated DOM objects.
+ * @class Base animation class that provides the interface for building animated effects.
+ * <p>Usage: var myAnim = new YAHOO.util.Anim(el, { width: { from: 10, to: 100 } }, 1, YAHOO.util.Easing.easeOut);</p>
+ * @requires YAHOO.util.AnimMgr
+ * @requires YAHOO.util.Easing
+ * @requires YAHOO.util.Dom
+ * @requires YAHOO.util.Event
+ * @requires YAHOO.util.CustomEvent
+ * @constructor
+ * @param {String or HTMLElement} el Reference to the element that will be animated
+ * @param {Object} attributes The attribute(s) to be animated.
+ * Each attribute is an object with at minimum a "to" or "by" member defined.
+ * Additional optional members are "from" (defaults to current value), "units" (defaults to "px").
+ * All attribute names use camelCase.
+ * @param {Number} duration (optional, defaults to 1 second) Length of animation (frames or seconds), defaults to time-based
+ * @param {Function} method (optional, defaults to YAHOO.util.Easing.easeNone) Computes the values that are applied to the attributes per frame (generally a YAHOO.util.Easing method)
+ */
+
+YAHOO.util.Anim = function(el, attributes, duration, method) {
+ if (el) {
+ this.init(el, attributes, duration, method);
+ }
+};
+
+YAHOO.util.Anim.prototype = {
+ /**
+ * toString method
+ * @return {String} string represenation of anim obj
+ */
+ toString: function() {
+ var el = this.getEl();
+ var id = el.id || el.tagName;
+ return ("Anim " + id);
+ },
+
+ patterns: { // cached for performance
+ noNegatives: /width|height|opacity|padding/i, // keep at zero or above
+ offsetAttribute: /^((width|height)|(top|left))$/, // use offsetValue as default
+ defaultUnit: /width|height|top$|bottom$|left$|right$/i, // use 'px' by default
+ offsetUnit: /\d+(em|%|en|ex|pt|in|cm|mm|pc)$/i // IE may return these, so convert these to offset
+ },
+
+ /**
+ * Returns the value computed by the animation's "method".
+ * @param {String} attr The name of the attribute.
+ * @param {Number} start The value this attribute should start from for this animation.
+ * @param {Number} end The value this attribute should end at for this animation.
+ * @return {Number} The Value to be applied to the attribute.
+ */
+ doMethod: function(attr, start, end) {
+ return this.method(this.currentFrame, start, end - start, this.totalFrames);
+ },
+
+ /**
+ * Applies a value to an attribute
+ * @param {String} attr The name of the attribute.
+ * @param {Number} val The value to be applied to the attribute.
+ * @param {String} unit The unit ('px', '%', etc.) of the value.
+ */
+ setAttribute: function(attr, val, unit) {
+ if ( this.patterns.noNegatives.test(attr) ) {
+ val = (val > 0) ? val : 0;
+ }
+
+ YAHOO.util.Dom.setStyle(this.getEl(), attr, val + unit);
+ },
+
+ /**
+ * Returns current value of the attribute.
+ * @param {String} attr The name of the attribute.
+ * @return {Number} val The current value of the attribute.
+ */
+ getAttribute: function(attr) {
+ var el = this.getEl();
+ var val = YAHOO.util.Dom.getStyle(el, attr);
+
+ if (val !== 'auto' && !this.patterns.offsetUnit.test(val)) {
+ return parseFloat(val);
+ }
+
+ var a = this.patterns.offsetAttribute.exec(attr) || [];
+ var pos = !!( a[3] ); // top or left
+ var box = !!( a[2] ); // width or height
+
+ // use offsets for width/height and abs pos top/left
+ if ( box || (YAHOO.util.Dom.getStyle(el, 'position') == 'absolute' && pos) ) {
+ val = el['offset' + a[0].charAt(0).toUpperCase() + a[0].substr(1)];
+ } else { // default to zero for other 'auto'
+ val = 0;
+ }
+
+ return val;
+ },
+
+ /**
+ * Returns the unit to use when none is supplied.
+ * Applies the "defaultUnit" test to decide whether to use pixels or not
+ * @param {attr} attr The name of the attribute.
+ * @return {String} The default unit to be used.
+ */
+ getDefaultUnit: function(attr) {
+ if ( this.patterns.defaultUnit.test(attr) ) {
+ return 'px';
+ }
+
+ return '';
+ },
+
+ /**
+ * Sets the actual values to be used during the animation.
+ * Should only be needed for subclass use.
+ * @param {Object} attr The attribute object
+ * @private
+ */
+ setRuntimeAttribute: function(attr) {
+ var start;
+ var end;
+ var attributes = this.attributes;
+
+ this.runtimeAttributes[attr] = {};
+
+ var isset = function(prop) {
+ return (typeof prop !== 'undefined');
+ };
+
+ if ( !isset(attributes[attr]['to']) && !isset(attributes[attr]['by']) ) {
+ return false; // note return; nothing to animate to
+ }
+
+ start = ( isset(attributes[attr]['from']) ) ? attributes[attr]['from'] : this.getAttribute(attr);
+
+ // To beats by, per SMIL 2.1 spec
+ if ( isset(attributes[attr]['to']) ) {
+ end = attributes[attr]['to'];
+ } else if ( isset(attributes[attr]['by']) ) {
+ if (start.constructor == Array) {
+ end = [];
+ for (var i = 0, len = start.length; i < len; ++i) {
+ end[i] = start[i] + attributes[attr]['by'][i];
+ }
+ } else {
+ end = start + attributes[attr]['by'];
+ }
+ }
+
+ this.runtimeAttributes[attr].start = start;
+ this.runtimeAttributes[attr].end = end;
+
+ // set units if needed
+ this.runtimeAttributes[attr].unit = ( isset(attributes[attr].unit) ) ? attributes[attr]['unit'] : this.getDefaultUnit(attr);
+ },
+
+ /**
+ * @param {String or HTMLElement} el Reference to the element that will be animated
+ * @param {Object} attributes The attribute(s) to be animated.
+ * Each attribute is an object with at minimum a "to" or "by" member defined.
+ * Additional optional members are "from" (defaults to current value), "units" (defaults to "px").
+ * All attribute names use camelCase.
+ * @param {Number} duration (optional, defaults to 1 second) Length of animation (frames or seconds), defaults to time-based
+ * @param {Function} method (optional, defaults to YAHOO.util.Easing.easeNone) Computes the values that are applied to the attributes per frame (generally a YAHOO.util.Easing method)
+ */
+ init: function(el, attributes, duration, method) {
+ /**
+ * Whether or not the animation is running.
+ * @private
+ * @type Boolean
+ */
+ var isAnimated = false;
+
+ /**
+ * A Date object that is created when the animation begins.
+ * @private
+ * @type Date
+ */
+ var startTime = null;
+
+ /**
+ * The number of frames this animation was able to execute.
+ * @private
+ * @type Int
+ */
+ var actualFrames = 0;
+
+ /**
+ * The element to be animated.
+ * @private
+ * @type HTMLElement
+ */
+ el = YAHOO.util.Dom.get(el);
+
+ /**
+ * The collection of attributes to be animated.
+ * Each attribute must have at least a "to" or "by" defined in order to animate.
+ * If "to" is supplied, the animation will end with the attribute at that value.
+ * If "by" is supplied, the animation will end at that value plus its starting value.
+ * If both are supplied, "to" is used, and "by" is ignored.
+ * @member YAHOO#util#Anim
+ * Optional additional member include "from" (the value the attribute should start animating from, defaults to current value), and "unit" (the units to apply to the values).
+ * @type Object
+ */
+ this.attributes = attributes || {};
+
+ /**
+ * The length of the animation. Defaults to "1" (second).
+ * @type Number
+ */
+ this.duration = duration || 1;
+
+ /**
+ * The method that will provide values to the attribute(s) during the animation.
+ * Defaults to "YAHOO.util.Easing.easeNone".
+ * @type Function
+ */
+ this.method = method || YAHOO.util.Easing.easeNone;
+
+ /**
+ * Whether or not the duration should be treated as seconds.
+ * Defaults to true.
+ * @type Boolean
+ */
+ this.useSeconds = true; // default to seconds
+
+ /**
+ * The location of the current animation on the timeline.
+ * In time-based animations, this is used by AnimMgr to ensure the animation finishes on time.
+ * @type Int
+ */
+ this.currentFrame = 0;
+
+ /**
+ * The total number of frames to be executed.
+ * In time-based animations, this is used by AnimMgr to ensure the animation finishes on time.
+ * @type Int
+ */
+ this.totalFrames = YAHOO.util.AnimMgr.fps;
+
+
+ /**
+ * Returns a reference to the animated element.
+ * @return {HTMLElement}
+ */
+ this.getEl = function() { return el; };
+
+ /**
+ * Checks whether the element is currently animated.
+ * @return {Boolean} current value of isAnimated.
+ */
+ this.isAnimated = function() {
+ return isAnimated;
+ };
+
+ /**
+ * Returns the animation start time.
+ * @return {Date} current value of startTime.
+ */
+ this.getStartTime = function() {
+ return startTime;
+ };
+
+ this.runtimeAttributes = {};
+
+
+
+ /**
+ * Starts the animation by registering it with the animation manager.
+ */
+ this.animate = function() {
+ if ( this.isAnimated() ) { return false; }
+
+ this.currentFrame = 0;
+
+ this.totalFrames = ( this.useSeconds ) ? Math.ceil(YAHOO.util.AnimMgr.fps * this.duration) : this.duration;
+
+ YAHOO.util.AnimMgr.registerElement(this);
+ };
+
+ /**
+ * Stops the animation. Normally called by AnimMgr when animation completes.
+ */
+ this.stop = function() {
+ YAHOO.util.AnimMgr.stop(this);
+ };
+
+ var onStart = function() {
+ this.onStart.fire();
+ for (var attr in this.attributes) {
+ this.setRuntimeAttribute(attr);
+ }
+
+ isAnimated = true;
+ actualFrames = 0;
+ startTime = new Date();
+ };
+
+ /**
+ * Feeds the starting and ending values for each animated attribute to doMethod once per frame, then applies the resulting value to the attribute(s).
+ * @private
+ */
+
+ var onTween = function() {
+ var data = {
+ duration: new Date() - this.getStartTime(),
+ currentFrame: this.currentFrame
+ };
+
+ data.toString = function() {
+ return (
+ 'duration: ' + data.duration +
+ ', currentFrame: ' + data.currentFrame
+ );
+ };
+
+ this.onTween.fire(data);
+
+ var runtimeAttributes = this.runtimeAttributes;
+
+ for (var attr in runtimeAttributes) {
+ this.setAttribute(attr, this.doMethod(attr, runtimeAttributes[attr].start, runtimeAttributes[attr].end), runtimeAttributes[attr].unit);
+ }
+
+ actualFrames += 1;
+ };
+
+ var onComplete = function() {
+ var actual_duration = (new Date() - startTime) / 1000 ;
+
+ var data = {
+ duration: actual_duration,
+ frames: actualFrames,
+ fps: actualFrames / actual_duration
+ };
+
+ data.toString = function() {
+ return (
+ 'duration: ' + data.duration +
+ ', frames: ' + data.frames +
+ ', fps: ' + data.fps
+ );
+ };
+
+ isAnimated = false;
+ actualFrames = 0;
+ this.onComplete.fire(data);
+ };
+
+ /**
+ * Custom event that fires after onStart, useful in subclassing
+ * @private
+ */
+ this._onStart = new YAHOO.util.CustomEvent('_start', this, true);
+
+ /**
+ * Custom event that fires when animation begins
+ * Listen via subscribe method (e.g. myAnim.onStart.subscribe(someFunction)
+ */
+ this.onStart = new YAHOO.util.CustomEvent('start', this);
+
+ /**
+ * Custom event that fires between each frame
+ * Listen via subscribe method (e.g. myAnim.onTween.subscribe(someFunction)
+ */
+ this.onTween = new YAHOO.util.CustomEvent('tween', this);
+
+ /**
+ * Custom event that fires after onTween
+ * @private
+ */
+ this._onTween = new YAHOO.util.CustomEvent('_tween', this, true);
+
+ /**
+ * Custom event that fires when animation ends
+ * Listen via subscribe method (e.g. myAnim.onComplete.subscribe(someFunction)
+ */
+ this.onComplete = new YAHOO.util.CustomEvent('complete', this);
+ /**
+ * Custom event that fires after onComplete
+ * @private
+ */
+ this._onComplete = new YAHOO.util.CustomEvent('_complete', this, true);
+
+ this._onStart.subscribe(onStart);
+ this._onTween.subscribe(onTween);
+ this._onComplete.subscribe(onComplete);
+ }
+};
+
+/**
+ * @class Handles animation queueing and threading.
+ * Used by Anim and subclasses.
+ */
+YAHOO.util.AnimMgr = new function() {
+ /**
+ * Reference to the animation Interval
+ * @private
+ * @type Int
+ */
+ var thread = null;
+
+ /**
+ * The current queue of registered animation objects.
+ * @private
+ * @type Array
+ */
+ var queue = [];
+
+ /**
+ * The number of active animations.
+ * @private
+ * @type Int
+ */
+ var tweenCount = 0;
+
+ /**
+ * Base frame rate (frames per second).
+ * Arbitrarily high for better x-browser calibration (slower browsers drop more frames).
+ * @type Int
+ *
+ */
+ this.fps = 200;
+
+ /**
+ * Interval delay in milliseconds, defaults to fastest possible.
+ * @type Int
+ *
+ */
+ this.delay = 1;
+
+ /**
+ * Adds an animation instance to the animation queue.
+ * All animation instances must be registered in order to animate.
+ * @param {object} tween The Anim instance to be be registered
+ */
+ this.registerElement = function(tween) {
+ queue[queue.length] = tween;
+ tweenCount += 1;
+ tween._onStart.fire();
+ this.start();
+ };
+
+ this.unRegister = function(tween, index) {
+ tween._onComplete.fire();
+ index = index || getIndex(tween);
+ if (index != -1) { queue.splice(index, 1); }
+
+ tweenCount -= 1;
+ if (tweenCount <= 0) { this.stop(); }
+ };
+
+ /**
+ * Starts the animation thread.
+ * Only one thread can run at a time.
+ */
+ this.start = function() {
+ if (thread === null) { thread = setInterval(this.run, this.delay); }
+ };
+
+ /**
+ * Stops the animation thread or a specific animation instance.
+ * @param {object} tween A specific Anim instance to stop (optional)
+ * If no instance given, Manager stops thread and all animations.
+ */
+ this.stop = function(tween) {
+ if (!tween) {
+ clearInterval(thread);
+ for (var i = 0, len = queue.length; i < len; ++i) {
+ if (queue[i].isAnimated()) {
+ this.unRegister(tween, i);
+ }
+ }
+ queue = [];
+ thread = null;
+ tweenCount = 0;
+ }
+ else {
+ this.unRegister(tween);
+ }
+ };
+
+ /**
+ * Called per Interval to handle each animation frame.
+ */
+ this.run = function() {
+ for (var i = 0, len = queue.length; i < len; ++i) {
+ var tween = queue[i];
+ if ( !tween || !tween.isAnimated() ) { continue; }
+
+ if (tween.currentFrame < tween.totalFrames || tween.totalFrames === null)
+ {
+ tween.currentFrame += 1;
+
+ if (tween.useSeconds) {
+ correctFrame(tween);
+ }
+ tween._onTween.fire();
+ }
+ else { YAHOO.util.AnimMgr.stop(tween, i); }
+ }
+ };
+
+ var getIndex = function(anim) {
+ for (var i = 0, len = queue.length; i < len; ++i) {
+ if (queue[i] == anim) {
+ return i; // note return;
+ }
+ }
+ return -1;
+ };
+
+ /**
+ * On the fly frame correction to keep animation on time.
+ * @private
+ * @param {Object} tween The Anim instance being corrected.
+ */
+ var correctFrame = function(tween) {
+ var frames = tween.totalFrames;
+ var frame = tween.currentFrame;
+ var expected = (tween.currentFrame * tween.duration * 1000 / tween.totalFrames);
+ var elapsed = (new Date() - tween.getStartTime());
+ var tweak = 0;
+
+ if (elapsed < tween.duration * 1000) { // check if falling behind
+ tweak = Math.round((elapsed / expected - 1) * tween.currentFrame);
+ } else { // went over duration, so jump to end
+ tweak = frames - (frame + 1);
+ }
+ if (tweak > 0 && isFinite(tweak)) { // adjust if needed
+ if (tween.currentFrame + tweak >= frames) {// dont go past last frame
+ tweak = frames - (frame + 1);
+ }
+
+ tween.currentFrame += tweak;
+ }
+ };
+};
+/**
+ *
+ * @class Used to calculate Bezier splines for any number of control points.
+ *
+ */
+YAHOO.util.Bezier = new function()
+{
+ /**
+ * Get the current position of the animated element based on t.
+ * Each point is an array of "x" and "y" values (0 = x, 1 = y)
+ * At least 2 points are required (start and end).
+ * First point is start. Last point is end.
+ * Additional control points are optional.
+ * @param {Array} points An array containing Bezier points
+ * @param {Number} t A number between 0 and 1 which is the basis for determining current position
+ * @return {Array} An array containing int x and y member data
+ */
+ this.getPosition = function(points, t)
+ {
+ var n = points.length;
+ var tmp = [];
+
+ for (var i = 0; i < n; ++i){
+ tmp[i] = [points[i][0], points[i][1]]; // save input
+ }
+
+ for (var j = 1; j < n; ++j) {
+ for (i = 0; i < n - j; ++i) {
+ tmp[i][0] = (1 - t) * tmp[i][0] + t * tmp[parseInt(i + 1, 10)][0];
+ tmp[i][1] = (1 - t) * tmp[i][1] + t * tmp[parseInt(i + 1, 10)][1];
+ }
+ }
+
+ return [ tmp[0][0], tmp[0][1] ];
+
+ };
+};
+/**
+ * @class ColorAnim subclass for color fading
+ * <p>Usage: <code>var myAnim = new Y.ColorAnim(el, { backgroundColor: { from: '#FF0000', to: '#FFFFFF' } }, 1, Y.Easing.easeOut);</code></p>
+ * <p>Color values can be specified with either 112233, #112233, [255,255,255], or rgb(255,255,255)
+ * @requires YAHOO.util.Anim
+ * @requires YAHOO.util.AnimMgr
+ * @requires YAHOO.util.Easing
+ * @requires YAHOO.util.Bezier
+ * @requires YAHOO.util.Dom
+ * @requires YAHOO.util.Event
+ * @constructor
+ * @param {HTMLElement | String} el Reference to the element that will be animated
+ * @param {Object} attributes The attribute(s) to be animated.
+ * Each attribute is an object with at minimum a "to" or "by" member defined.
+ * Additional optional members are "from" (defaults to current value), "units" (defaults to "px").
+ * All attribute names use camelCase.
+ * @param {Number} duration (optional, defaults to 1 second) Length of animation (frames or seconds), defaults to time-based
+ * @param {Function} method (optional, defaults to YAHOO.util.Easing.easeNone) Computes the values that are applied to the attributes per frame (generally a YAHOO.util.Easing method)
+ */
+(function() {
+ YAHOO.util.ColorAnim = function(el, attributes, duration, method) {
+ YAHOO.util.ColorAnim.superclass.constructor.call(this, el, attributes, duration, method);
+ };
+
+ YAHOO.extend(YAHOO.util.ColorAnim, YAHOO.util.Anim);
+
+ // shorthand
+ var Y = YAHOO.util;
+ var superclass = Y.ColorAnim.superclass;
+ var proto = Y.ColorAnim.prototype;
+
+ /**
+ * toString method
+ * @return {String} string represenation of anim obj
+ */
+ proto.toString = function() {
+ var el = this.getEl();
+ var id = el.id || el.tagName;
+ return ("ColorAnim " + id);
+ };
+
+ /**
+ * Only certain attributes should be treated as colors.
+ * @type Object
+ */
+ proto.patterns.color = /color$/i;
+ proto.patterns.rgb = /^rgb\(([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\)$/i;
+ proto.patterns.hex = /^#?([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})$/i;
+ proto.patterns.hex3 = /^#?([0-9A-F]{1})([0-9A-F]{1})([0-9A-F]{1})$/i;
+
+ /**
+ * Attempts to parse the given string and return a 3-tuple.
+ * @param {String} s The string to parse.
+ * @return {Array} The 3-tuple of rgb values.
+ */
+ proto.parseColor = function(s) {
+ if (s.length == 3) { return s; }
+
+ var c = this.patterns.hex.exec(s);
+ if (c && c.length == 4) {
+ return [ parseInt(c[1], 16), parseInt(c[2], 16), parseInt(c[3], 16) ];
+ }
+
+ c = this.patterns.rgb.exec(s);
+ if (c && c.length == 4) {
+ return [ parseInt(c[1], 10), parseInt(c[2], 10), parseInt(c[3], 10) ];
+ }
+
+ c = this.patterns.hex3.exec(s);
+ if (c && c.length == 4) {
+ return [ parseInt(c[1] + c[1], 16), parseInt(c[2] + c[2], 16), parseInt(c[3] + c[3], 16) ];
+ }
+
+ return null;
+ };
+
+ /**
+ * Returns current value of the attribute.
+ * @param {String} attr The name of the attribute.
+ * @return {Number} val The current value of the attribute.
+ */
+ proto.getAttribute = function(attr) {
+ var el = this.getEl();
+ if ( this.patterns.color.test(attr) ) {
+ var val = YAHOO.util.Dom.getStyle(el, attr);
+
+ if (val == 'transparent') { // bgcolor default
+ var parent = el.parentNode; // try and get from an ancestor
+ val = Y.Dom.getStyle(parent, attr);
+
+ while (parent && val == 'transparent') {
+ parent = parent.parentNode;
+ val = Y.Dom.getStyle(parent, attr);
+ if (parent.tagName.toUpperCase() == 'HTML') {
+ val = 'ffffff';
+ }
+ }
+ }
+ } else {
+ val = superclass.getAttribute.call(this, attr);
+ }
+
+ return val;
+ };
+
+ /**
+ * Returns the value computed by the animation's "method".
+ * @param {String} attr The name of the attribute.
+ * @param {Number} start The value this attribute should start from for this animation.
+ * @param {Number} end The value this attribute should end at for this animation.
+ * @return {Number} The Value to be applied to the attribute.
+ */
+ proto.doMethod = function(attr, start, end) {
+ var val;
+
+ if ( this.patterns.color.test(attr) ) {
+ val = [];
+ for (var i = 0, len = start.length; i < len; ++i) {
+ val[i] = superclass.doMethod.call(this, attr, start[i], end[i]);
+ }
+
+ val = 'rgb('+Math.floor(val[0])+','+Math.floor(val[1])+','+Math.floor(val[2])+')';
+ }
+ else {
+ val = superclass.doMethod.call(this, attr, start, end);
+ }
+
+ return val;
+ };
+
+ /**
+ * Sets the actual values to be used during the animation.
+ * Should only be needed for subclass use.
+ * @param {Object} attr The attribute object
+ * @private
+ */
+ proto.setRuntimeAttribute = function(attr) {
+ superclass.setRuntimeAttribute.call(this, attr);
+
+ if ( this.patterns.color.test(attr) ) {
+ var attributes = this.attributes;
+ var start = this.parseColor(this.runtimeAttributes[attr].start);
+ var end = this.parseColor(this.runtimeAttributes[attr].end);
+ // fix colors if going "by"
+ if ( typeof attributes[attr]['to'] === 'undefined' && typeof attributes[attr]['by'] !== 'undefined' ) {
+ end = this.parseColor(attributes[attr].by);
+
+ for (var i = 0, len = start.length; i < len; ++i) {
+ end[i] = start[i] + end[i];
+ }
+ }
+
+ this.runtimeAttributes[attr].start = start;
+ this.runtimeAttributes[attr].end = end;
+ }
+ };
+})();/*
+TERMS OF USE - EASING EQUATIONS
+Open source under the BSD License.
+Copyright © 2001 Robert Penner All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
+ * Neither the name of the author nor the names of contributors may be used to endorse or promote products derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+*/
+
+YAHOO.util.Easing = {
+
+ /**
+ * Uniform speed between points.
+ * @param {Number} t Time value used to compute current value.
+ * @param {Number} b Starting value.
+ * @param {Number} c Delta between start and end values.
+ * @param {Number} d Total length of animation.
+ * @return {Number} The computed value for the current animation frame.
+ */
+ easeNone: function (t, b, c, d) {
+ return c*t/d + b;
+ },
+
+ /**
+ * Begins slowly and accelerates towards end. (quadratic)
+ * @param {Number} t Time value used to compute current value.
+ * @param {Number} b Starting value.
+ * @param {Number} c Delta between start and end values.
+ * @param {Number} d Total length of animation.
+ * @return {Number} The computed value for the current animation frame.
+ */
+ easeIn: function (t, b, c, d) {
+ return c*(t/=d)*t + b;
+ },
+
+ /**
+ * Begins quickly and decelerates towards end. (quadratic)
+ * @param {Number} t Time value used to compute current value.
+ * @param {Number} b Starting value.
+ * @param {Number} c Delta between start and end values.
+ * @param {Number} d Total length of animation.
+ * @return {Number} The computed value for the current animation frame.
+ */
+ easeOut: function (t, b, c, d) {
+ return -c *(t/=d)*(t-2) + b;
+ },
+
+ /**
+ * Begins slowly and decelerates towards end. (quadratic)
+ * @param {Number} t Time value used to compute current value.
+ * @param {Number} b Starting value.
+ * @param {Number} c Delta between start and end values.
+ * @param {Number} d Total length of animation.
+ * @return {Number} The computed value for the current animation frame.
+ */
+ easeBoth: function (t, b, c, d) {
+ if ((t/=d/2) < 1) return c/2*t*t + b;
+ return -c/2 * ((--t)*(t-2) - 1) + b;
+ },
+
+ /**
+ * Begins slowly and accelerates towards end. (quartic)
+ * @param {Number} t Time value used to compute current value.
+ * @param {Number} b Starting value.
+ * @param {Number} c Delta between start and end values.
+ * @param {Number} d Total length of animation.
+ * @return {Number} The computed value for the current animation frame.
+ */
+ easeInStrong: function (t, b, c, d) {
+ return c*(t/=d)*t*t*t + b;
+ },
+
+ /**
+ * Begins quickly and decelerates towards end. (quartic)
+ * @param {Number} t Time value used to compute current value.
+ * @param {Number} b Starting value.
+ * @param {Number} c Delta between start and end values.
+ * @param {Number} d Total length of animation.
+ * @return {Number} The computed value for the current animation frame.
+ */
+ easeOutStrong: function (t, b, c, d) {
+ return -c * ((t=t/d-1)*t*t*t - 1) + b;
+ },
+
+ /**
+ * Begins slowly and decelerates towards end. (quartic)
+ * @param {Number} t Time value used to compute current value.
+ * @param {Number} b Starting value.
+ * @param {Number} c Delta between start and end values.
+ * @param {Number} d Total length of animation.
+ * @return {Number} The computed value for the current animation frame.
+ */
+ easeBothStrong: function (t, b, c, d) {
+ if ((t/=d/2) < 1) return c/2*t*t*t*t + b;
+ return -c/2 * ((t-=2)*t*t*t - 2) + b;
+ },
+
+ /**
+ * snap in elastic effect
+ * @param {Number} t Time value used to compute current value.
+ * @param {Number} b Starting value.
+ * @param {Number} c Delta between start and end values.
+ * @param {Number} d Total length of animation.
+ * @param {Number} p Period (optional)
+ * @return {Number} The computed value for the current animation frame.
+ */
+
+ elasticIn: function (t, b, c, d, a, p) {
+ if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
+ if (!a || a < Math.abs(c)) { a=c; var s=p/4; }
+ else var s = p/(2*Math.PI) * Math.asin (c/a);
+ return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
+ },
+
+ /**
+ * snap out elastic effect
+ * @param {Number} t Time value used to compute current value.
+ * @param {Number} b Starting value.
+ * @param {Number} c Delta between start and end values.
+ * @param {Number} d Total length of animation.
+ * @param {Number} p Period (optional)
+ * @return {Number} The computed value for the current animation frame.
+ */
+ elasticOut: function (t, b, c, d, a, p) {
+ if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3;
+ if (!a || a < Math.abs(c)) { a=c; var s=p/4; }
+ else var s = p/(2*Math.PI) * Math.asin (c/a);
+ return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b;
+ },
+
+ /**
+ * snap both elastic effect
+ * @param {Number} t Time value used to compute current value.
+ * @param {Number} b Starting value.
+ * @param {Number} c Delta between start and end values.
+ * @param {Number} d Total length of animation.
+ * @param {Number} p Period (optional)
+ * @return {Number} The computed value for the current animation frame.
+ */
+ elasticBoth: function (t, b, c, d, a, p) {
+ if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5);
+ if (!a || a < Math.abs(c)) { a=c; var s=p/4; }
+ else var s = p/(2*Math.PI) * Math.asin (c/a);
+ if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b;
+ return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b;
+ },
+
+ /**
+ * back easing in - backtracking slightly, then reversing direction and moving to target
+ * @param {Number} t Time value used to compute current value.
+ * @param {Number} b Starting value.
+ * @param {Number} c Delta between start and end values.
+ * @param {Number} d Total length of animation.
+ * @param {Number) s Overshoot (optional)
+ * @return {Number} The computed value for the current animation frame.
+ */
+ backIn: function (t, b, c, d, s) {
+ if (typeof s == 'undefined') s = 1.70158;
+ return c*(t/=d)*t*((s+1)*t - s) + b;
+ },
+
+ /**
+ * back easing out - moving towards target, overshooting it slightly,
+ * then reversing and coming back to target
+ * @param {Number} t Time value used to compute current value.
+ * @param {Number} b Starting value.
+ * @param {Number} c Delta between start and end values.
+ * @param {Number} d Total length of animation.
+ * @param {Number) s Overshoot (optional)
+ * @return {Number} The computed value for the current animation frame.
+ */
+ backOut: function (t, b, c, d, s) {
+ if (typeof s == 'undefined') s = 1.70158;
+ return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b;
+ },
+
+ /**
+ * back easing in/out - backtracking slightly, then reversing direction and moving to target,
+ * then overshooting target, reversing, and finally coming back to target
+ * @param {Number} t Time value used to compute current value.
+ * @param {Number} b Starting value.
+ * @param {Number} c Delta between start and end values.
+ * @param {Number} d Total length of animation.
+ * @param {Number) s Overshoot (optional)
+ * @return {Number} The computed value for the current animation frame.
+ */
+ backBoth: function (t, b, c, d, s) {
+ if (typeof s == 'undefined') s = 1.70158;
+ if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b;
+ return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b;
+ },
+
+ /**
+ * bounce in
+ * @param {Number} t Time value used to compute current value.
+ * @param {Number} b Starting value.
+ * @param {Number} c Delta between start and end values.
+ * @param {Number} d Total length of animation.
+ * @return {Number} The computed value for the current animation frame.
+ */
+ bounceIn: function (t, b, c, d) {
+ return c - YAHOO.util.Easing.bounceOut(d-t, 0, c, d) + b;
+ },
+
+ /**
+ * bounce out
+ * @param {Number} t Time value used to compute current value.
+ * @param {Number} b Starting value.
+ * @param {Number} c Delta between start and end values.
+ * @param {Number} d Total length of animation.
+ * @return {Number} The computed value for the current animation frame.
+ */
+ bounceOut: function (t, b, c, d) {
+ if ((t/=d) < (1/2.75)) {
+ return c*(7.5625*t*t) + b;
+ } else if (t < (2/2.75)) {
+ return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b;
+ } else if (t < (2.5/2.75)) {
+ return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b;
+ } else {
+ return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b;
+ }
+ },
+
+ /**
+ * bounce both
+ * @param {Number} t Time value used to compute current value.
+ * @param {Number} b Starting value.
+ * @param {Number} c Delta between start and end values.
+ * @param {Number} d Total length of animation.
+ * @return {Number} The computed value for the current animation frame.
+ */
+ bounceBoth: function (t, b, c, d) {
+ if (t < d/2) return YAHOO.util.Easing.bounceIn(t*2, 0, c, d) * .5 + b;
+ return YAHOO.util.Easing.bounceOut(t*2-d, 0, c, d) * .5 + c*.5 + b;
+ }
+};
+
+/**
+ * @class Anim subclass for moving elements along a path defined by the "points" member of "attributes". All "points" are arrays with x, y coordinates.
+ * <p>Usage: <code>var myAnim = new YAHOO.util.Motion(el, { points: { to: [800, 800] } }, 1, YAHOO.util.Easing.easeOut);</code></p>
+ * @requires YAHOO.util.Anim
+ * @requires YAHOO.util.AnimMgr
+ * @requires YAHOO.util.Easing
+ * @requires YAHOO.util.Bezier
+ * @requires YAHOO.util.Dom
+ * @requires YAHOO.util.Event
+ * @requires YAHOO.util.CustomEvent
+ * @constructor
+ * @param {String or HTMLElement} el Reference to the element that will be animated
+ * @param {Object} attributes The attribute(s) to be animated.
+ * Each attribute is an object with at minimum a "to" or "by" member defined.
+ * Additional optional members are "from" (defaults to current value), "units" (defaults to "px").
+ * All attribute names use camelCase.
+ * @param {Number} duration (optional, defaults to 1 second) Length of animation (frames or seconds), defaults to time-based
+ * @param {Function} method (optional, defaults to YAHOO.util.Easing.easeNone) Computes the values that are applied to the attributes per frame (generally a YAHOO.util.Easing method)
+ */
+(function() {
+ YAHOO.util.Motion = function(el, attributes, duration, method) {
+ if (el) { // dont break existing subclasses not using YAHOO.extend
+ YAHOO.util.Motion.superclass.constructor.call(this, el, attributes, duration, method);
+ }
+ };
+
+ YAHOO.extend(YAHOO.util.Motion, YAHOO.util.ColorAnim);
+
+ // shorthand
+ var Y = YAHOO.util;
+ var superclass = Y.Motion.superclass;
+ var proto = Y.Motion.prototype;
+
+ /**
+ * toString method
+ * @return {String} string represenation of anim obj
+ */
+ proto.toString = function() {
+ var el = this.getEl();
+ var id = el.id || el.tagName;
+ return ("Motion " + id);
+ };
+
+ proto.patterns.points = /^points$/i;
+
+ /**
+ * Applies a value to an attribute
+ * @param {String} attr The name of the attribute.
+ * @param {Number} val The value to be applied to the attribute.
+ * @param {String} unit The unit ('px', '%', etc.) of the value.
+ */
+ proto.setAttribute = function(attr, val, unit) {
+ if ( this.patterns.points.test(attr) ) {
+ unit = unit || 'px';
+ superclass.setAttribute.call(this, 'left', val[0], unit);
+ superclass.setAttribute.call(this, 'top', val[1], unit);
+ } else {
+ superclass.setAttribute.call(this, attr, val, unit);
+ }
+ };
+
+ /**
+ * Sets the default value to be used when "from" is not supplied.
+ * @param {String} attr The attribute being set.
+ * @param {Number} val The default value to be applied to the attribute.
+ */
+ proto.getAttribute = function(attr) {
+ if ( this.patterns.points.test(attr) ) {
+ var val = [
+ superclass.getAttribute.call(this, 'left'),
+ superclass.getAttribute.call(this, 'top')
+ ];
+ } else {
+ val = superclass.getAttribute.call(this, attr);
+ }
+
+ return val;
+ };
+
+ /**
+ * Returns the value computed by the animation's "method".
+ * @param {String} attr The name of the attribute.
+ * @param {Number} start The value this attribute should start from for this animation.
+ * @param {Number} end The value this attribute should end at for this animation.
+ * @return {Number} The Value to be applied to the attribute.
+ */
+ proto.doMethod = function(attr, start, end) {
+ var val = null;
+
+ if ( this.patterns.points.test(attr) ) {
+ var t = this.method(this.currentFrame, 0, 100, this.totalFrames) / 100;
+ val = Y.Bezier.getPosition(this.runtimeAttributes[attr], t);
+ } else {
+ val = superclass.doMethod.call(this, attr, start, end);
+ }
+ return val;
+ };
+
+ /**
+ * Sets the actual values to be used during the animation.
+ * Should only be needed for subclass use.
+ * @param {Object} attr The attribute object
+ * @private
+ */
+ proto.setRuntimeAttribute = function(attr) {
+ if ( this.patterns.points.test(attr) ) {
+ var el = this.getEl();
+ var attributes = this.attributes;
+ var start;
+ var control = attributes['points']['control'] || [];
+ var end;
+ var i, len;
+
+ if (control.length > 0 && !(control[0] instanceof Array) ) { // could be single point or array of points
+ control = [control];
+ } else { // break reference to attributes.points.control
+ var tmp = [];
+ for (i = 0, len = control.length; i< len; ++i) {
+ tmp[i] = control[i];
+ }
+ control = tmp;
+ }
+
+ if (Y.Dom.getStyle(el, 'position') == 'static') { // default to relative
+ Y.Dom.setStyle(el, 'position', 'relative');
+ }
+
+ if ( isset(attributes['points']['from']) ) {
+ Y.Dom.setXY(el, attributes['points']['from']); // set position to from point
+ }
+ else { Y.Dom.setXY( el, Y.Dom.getXY(el) ); } // set it to current position
+
+ start = this.getAttribute('points'); // get actual top & left
+
+ // TO beats BY, per SMIL 2.1 spec
+ if ( isset(attributes['points']['to']) ) {
+ end = translateValues.call(this, attributes['points']['to'], start);
+
+ var pageXY = Y.Dom.getXY(this.getEl());
+ for (i = 0, len = control.length; i < len; ++i) {
+ control[i] = translateValues.call(this, control[i], start);
+ }
+
+
+ } else if ( isset(attributes['points']['by']) ) {
+ end = [ start[0] + attributes['points']['by'][0], start[1] + attributes['points']['by'][1] ];
+
+ for (i = 0, len = control.length; i < len; ++i) {
+ control[i] = [ start[0] + control[i][0], start[1] + control[i][1] ];
+ }
+ }
+
+ this.runtimeAttributes[attr] = [start];
+
+ if (control.length > 0) {
+ this.runtimeAttributes[attr] = this.runtimeAttributes[attr].concat(control);
+ }
+
+ this.runtimeAttributes[attr][this.runtimeAttributes[attr].length] = end;
+ }
+ else {
+ superclass.setRuntimeAttribute.call(this, attr);
+ }
+ };
+
+ var translateValues = function(val, start) {
+ var pageXY = Y.Dom.getXY(this.getEl());
+ val = [ val[0] - pageXY[0] + start[0], val[1] - pageXY[1] + start[1] ];
+
+ return val;
+ };
+
+ var isset = function(prop) {
+ return (typeof prop !== 'undefined');
+ };
+})();
+/**
+ * @class Anim subclass for scrolling elements to a position defined by the "scroll" member of "attributes". All "scroll" members are arrays with x, y scroll positions.
+ * <p>Usage: <code>var myAnim = new YAHOO.util.Scroll(el, { scroll: { to: [0, 800] } }, 1, YAHOO.util.Easing.easeOut);</code></p>
+ * @requires YAHOO.util.Anim
+ * @requires YAHOO.util.AnimMgr
+ * @requires YAHOO.util.Easing
+ * @requires YAHOO.util.Bezier
+ * @requires YAHOO.util.Dom
+ * @requires YAHOO.util.Event
+ * @requires YAHOO.util.CustomEvent
+ * @constructor
+ * @param {String or HTMLElement} el Reference to the element that will be animated
+ * @param {Object} attributes The attribute(s) to be animated.
+ * Each attribute is an object with at minimum a "to" or "by" member defined.
+ * Additional optional members are "from" (defaults to current value), "units" (defaults to "px").
+ * All attribute names use camelCase.
+ * @param {Number} duration (optional, defaults to 1 second) Length of animation (frames or seconds), defaults to time-based
+ * @param {Function} method (optional, defaults to YAHOO.util.Easing.easeNone) Computes the values that are applied to the attributes per frame (generally a YAHOO.util.Easing method)
+ */
+(function() {
+ YAHOO.util.Scroll = function(el, attributes, duration, method) {
+ if (el) { // dont break existing subclasses not using YAHOO.extend
+ YAHOO.util.Scroll.superclass.constructor.call(this, el, attributes, duration, method);
+ }
+ };
+
+ YAHOO.extend(YAHOO.util.Scroll, YAHOO.util.ColorAnim);
+
+ // shorthand
+ var Y = YAHOO.util;
+ var superclass = Y.Scroll.superclass;
+ var proto = Y.Scroll.prototype;
+
+ /**
+ * toString method
+ * @return {String} string represenation of anim obj
+ */
+ proto.toString = function() {
+ var el = this.getEl();
+ var id = el.id || el.tagName;
+ return ("Scroll " + id);
+ };
+
+ /**
+ * Returns the value computed by the animation's "method".
+ * @param {String} attr The name of the attribute.
+ * @param {Number} start The value this attribute should start from for this animation.
+ * @param {Number} end The value this attribute should end at for this animation.
+ * @return {Number} The Value to be applied to the attribute.
+ */
+ proto.doMethod = function(attr, start, end) {
+ var val = null;
+
+ if (attr == 'scroll') {
+ val = [
+ this.method(this.currentFrame, start[0], end[0] - start[0], this.totalFrames),
+ this.method(this.currentFrame, start[1], end[1] - start[1], this.totalFrames)
+ ];
+
+ } else {
+ val = superclass.doMethod.call(this, attr, start, end);
+ }
+ return val;
+ };
+
+ /**
+ * Returns current value of the attribute.
+ * @param {String} attr The name of the attribute.
+ * @return {Number} val The current value of the attribute.
+ */
+ proto.getAttribute = function(attr) {
+ var val = null;
+ var el = this.getEl();
+
+ if (attr == 'scroll') {
+ val = [ el.scrollLeft, el.scrollTop ];
+ } else {
+ val = superclass.getAttribute.call(this, attr);
+ }
+
+ return val;
+ };
+
+ /**
+ * Applies a value to an attribute
+ * @param {String} attr The name of the attribute.
+ * @param {Number} val The value to be applied to the attribute.
+ * @param {String} unit The unit ('px', '%', etc.) of the value.
+ */
+ proto.setAttribute = function(attr, val, unit) {
+ var el = this.getEl();
+
+ if (attr == 'scroll') {
+ el.scrollLeft = val[0];
+ el.scrollTop = val[1];
+ } else {
+ superclass.setAttribute.call(this, attr, val, unit);
+ }
+ };
+})();
Added: branches/tomek/portal-dnd/dndRenderer.war/js/autocomplete/README
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/autocomplete/README 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/autocomplete/README 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,30 @@
+AutoComplete Release Notes
+
+*** version 0.11.0 ***
+
+* The method getListIds() has been deprecated for getListItems(), which returns
+an array of DOM references.
+
+* All classnames have been prefixed with "yui-ac-".
+
+* Container elements should no longer have CSS property "display" set to "none".
+
+* The useIFrame property can now be set after instantiation.
+
+* On some browsers, the unmatchedItemSelectEvent may not be fired properly when
+delimiter characters are defined.
+
+* On some browsers, defining delimiter characters while enabling forceSelection
+may result in unexpected behavior.
+
+
+
+*** version 0.10.0 ***
+
+* Initial release
+
+* In order to enable the useIFrame property, it should be set in the
+constructor.
+
+* On some browsers, defining delimiter characters while enabling forceSelection
+may result in unexpected behavior.
Added: branches/tomek/portal-dnd/dndRenderer.war/js/autocomplete/autocomplete-debug.js
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/autocomplete/autocomplete-debug.js 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/autocomplete/autocomplete-debug.js 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,2784 @@
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.com/yui/license.txt
+version: 0.11.0
+*/
+
+/****************************************************************************/
+/****************************************************************************/
+/****************************************************************************/
+
+/**
+ * Class providing the customizable functionality of a plug-and-play DHTML
+ * auto complete widget. Some key features:
+ * <ul>
+ * <li>Navigate with up/down arrow keys and/or mouse to pick a selection</li>
+ * <li>The drop down container can "roll down" or "fly out" via configurable
+ * animation</li>
+ * <li>UI look-and-feel customizable through CSS, including container
+ * attributes, borders, position, fonts, etc</li>
+ * </ul>
+ *
+ * requires YAHOO.util.Dom Dom utility
+ * requires YAHOO.util.Event Event utility
+ * requires YAHOO.widget.DataSource Data source class
+ * see YAHOO.util.Animation Animation utility
+ * see JSON JSON library
+ *
+ * @constructor
+ * @param {element | string} inputEl DOM element reference or string ID of the auto complete input field
+ * @param {element | string} containerEl DOM element reference or string ID of the auto complete <div>
+ * container
+ * @param {object} oDataSource Instance of YAHOO.widget.DataSource for query/results
+ * @param {object} oConfigs Optional object literal of config params
+ */
+YAHOO.widget.AutoComplete = function(inputEl,containerEl,oDataSource,oConfigs) {
+ if(inputEl && containerEl && oDataSource) {
+ // Validate data source
+ if (oDataSource && (oDataSource instanceof YAHOO.widget.DataSource)) {
+ this.dataSource = oDataSource;
+ }
+ else {
+ YAHOO.log("Could not instantiate AutoComplete due to an invalid DataSource", "error", this.toString());
+ return;
+ }
+
+ // Validate input element
+ if(YAHOO.util.Dom.inDocument(inputEl)) {
+ if(typeof inputEl == "string") {
+ this._sName = "instance" + YAHOO.widget.AutoComplete._nIndex + " " + inputEl;
+ this._oTextbox = document.getElementById(inputEl);
+ }
+ else {
+ this._sName = (inputEl.id) ?
+ "instance" + YAHOO.widget.AutoComplete._nIndex + " " + inputEl.id:
+ "instance" + YAHOO.widget.AutoComplete._nIndex;
+ this._oTextbox = inputEl;
+ }
+ }
+ else {
+ YAHOO.log("Could not instantiate AutoComplete due to an invalid input element", "error", this.toString());
+ return;
+ }
+
+ // Validate container element
+ if(YAHOO.util.Dom.inDocument(containerEl)) {
+ if(typeof containerEl == "string") {
+ this._oContainer = document.getElementById(containerEl);
+ }
+ else {
+ this._oContainer = containerEl;
+ }
+ if(this._oContainer.style.display == "none") {
+ YAHOO.log("The container may not display properly if display is set to \"none\" in CSS", "warn", this.toString());
+ }
+ }
+ else {
+ YAHOO.log("Could not instantiate AutoComplete due to an invalid container element", "error", this.toString());
+ return;
+ }
+
+ // Set any config params passed in to override defaults
+ if (typeof oConfigs == "object") {
+ for(var sConfig in oConfigs) {
+ if (sConfig) {
+ this[sConfig] = oConfigs[sConfig];
+ }
+ }
+ }
+
+ // Initialization sequence
+ this._initContainer();
+ this._initProps();
+ this._initList();
+ this._initContainerHelpers();
+
+ // Set up events
+ var oSelf = this;
+ var oTextbox = this._oTextbox;
+ // Events are actually for the content module within the container
+ var oContent = this._oContainer._oContent;
+
+ // Dom events
+ YAHOO.util.Event.addListener(oTextbox,"keyup",oSelf._onTextboxKeyUp,oSelf);
+ YAHOO.util.Event.addListener(oTextbox,"keydown",oSelf._onTextboxKeyDown,oSelf);
+ YAHOO.util.Event.addListener(oTextbox,"keypress",oSelf._onTextboxKeyPress,oSelf);
+ YAHOO.util.Event.addListener(oTextbox,"focus",oSelf._onTextboxFocus,oSelf);
+ YAHOO.util.Event.addListener(oTextbox,"blur",oSelf._onTextboxBlur,oSelf);
+ YAHOO.util.Event.addListener(oContent,"mouseover",oSelf._onContainerMouseover,oSelf);
+ YAHOO.util.Event.addListener(oContent,"mouseout",oSelf._onContainerMouseout,oSelf);
+ YAHOO.util.Event.addListener(oContent,"scroll",oSelf._onContainerScroll,oSelf);
+ YAHOO.util.Event.addListener(oContent,"resize",oSelf._onContainerResize,oSelf);
+ if(oTextbox.form) {
+ YAHOO.util.Event.addListener(oTextbox.form,"submit",oSelf._onFormSubmit,oSelf);
+ }
+
+ // Custom events
+ this.textboxFocusEvent = new YAHOO.util.CustomEvent("textboxFocus", this);
+ this.textboxKeyEvent = new YAHOO.util.CustomEvent("textboxKey", this);
+ this.dataRequestEvent = new YAHOO.util.CustomEvent("dataRequest", this);
+ this.dataReturnEvent = new YAHOO.util.CustomEvent("dataReturn", this);
+ this.dataErrorEvent = new YAHOO.util.CustomEvent("dataError", this);
+ this.containerExpandEvent = new YAHOO.util.CustomEvent("containerExpand", this);
+ this.typeAheadEvent = new YAHOO.util.CustomEvent("typeAhead", this);
+ this.itemMouseOverEvent = new YAHOO.util.CustomEvent("itemMouseOver", this);
+ this.itemMouseOutEvent = new YAHOO.util.CustomEvent("itemMouseOut", this);
+ this.itemArrowToEvent = new YAHOO.util.CustomEvent("itemArrowTo", this);
+ this.itemArrowFromEvent = new YAHOO.util.CustomEvent("itemArrowFrom", this);
+ this.itemSelectEvent = new YAHOO.util.CustomEvent("itemSelect", this);
+ this.unmatchedItemSelectEvent = new YAHOO.util.CustomEvent("unmatchedItemSelect", this);
+ this.selectionEnforceEvent = new YAHOO.util.CustomEvent("selectionEnforce", this);
+ this.containerCollapseEvent = new YAHOO.util.CustomEvent("containerCollapse", this);
+ this.textboxBlurEvent = new YAHOO.util.CustomEvent("textboxBlur", this);
+
+ // Finish up
+ oTextbox.setAttribute("autocomplete","off");
+ YAHOO.widget.AutoComplete._nIndex++;
+ YAHOO.log("AutoComplete initialized","info",this.toString());
+ }
+ // Required arguments were not found
+ else {
+ YAHOO.log("Could not instantiate AutoComplete due invalid arguments", "error", this.toString());
+ }
+};
+
+/***************************************************************************
+ * Public member variables
+ ***************************************************************************/
+/**
+ * The data source object that encapsulates the data used for auto completion.
+ * This object should be an inherited object from YAHOO.widget.DataSource.
+ *
+ * @type object
+ */
+YAHOO.widget.AutoComplete.prototype.dataSource = null;
+
+/**
+ * Number of characters that must be entered before querying for results.
+ * Default: 1.
+ *
+ * @type number
+ */
+YAHOO.widget.AutoComplete.prototype.minQueryLength = 1;
+
+/**
+ * Maximum number of results to display in auto complete container. Default: 10.
+ *
+ * @type number
+ */
+YAHOO.widget.AutoComplete.prototype.maxResultsDisplayed = 10;
+
+/**
+ * Number of seconds to delay before submitting a query request. If a query
+ * request is received before a previous one has completed its delay, the
+ * previous request is cancelled and the new request is set to the delay.
+ * Default: 0.5.
+ *
+ * @type number
+ */
+YAHOO.widget.AutoComplete.prototype.queryDelay = 0.5;
+
+/**
+ * Class name of a highlighted item within the auto complete container.
+ * Default: "yui-ac-highlight".
+ *
+ * @type string
+ */
+YAHOO.widget.AutoComplete.prototype.highlightClassName = "yui-ac-highlight";
+
+/**
+ * Class name of a pre-highlighted item within the auto complete container.
+ * Default: null.
+ *
+ * @type string
+ */
+YAHOO.widget.AutoComplete.prototype.prehighlightClassName = null;
+
+/**
+ * Query delimiter. A single character separator for multiple delimited
+ * selections. Multiple delimiter characteres may be defined as an array of
+ * strings. A null value or empty string indicates that query results cannot
+ * be delimited. This feature is not recommended if you need forceSelection to
+ * be true. Default: null.
+ *
+ * @type string or array
+ */
+YAHOO.widget.AutoComplete.prototype.delimChar = null;
+
+/**
+ * Whether or not the first item in the auto complete container should be
+ * automatically highlighted on expand. Default: true.
+ *
+ * @type boolean
+ */
+YAHOO.widget.AutoComplete.prototype.autoHighlight = true;
+
+/**
+ * Whether or not the auto complete input field should be automatically updated
+ * with the first query result as the user types, auto-selecting the substring
+ * that the user has not typed. Default: false.
+ *
+ * @type boolean
+ */
+YAHOO.widget.AutoComplete.prototype.typeAhead = false;
+
+/**
+ * Whether or not to animate the expansion/collapse of the auto complete
+ * container in the horizontal direction. Default: false.
+ *
+ * @type boolean
+ */
+YAHOO.widget.AutoComplete.prototype.animHoriz = false;
+
+/**
+ * Whether or not to animate the expansion/collapse of the auto complete
+ * container in the vertical direction. Default: true.
+ *
+ * @type boolean
+ */
+YAHOO.widget.AutoComplete.prototype.animVert = true;
+
+/**
+ * Speed of container expand/collapse animation, in seconds. Default: 0.3.
+ *
+ * @type number
+ */
+YAHOO.widget.AutoComplete.prototype.animSpeed = 0.3;
+
+/**
+ * Whether or not to force the user's selection to match one of the query
+ * results. Enabling this feature essentially transforms the auto complete form
+ * input field into a <select> field. This feature is not recommended
+ * with delimiter character(s) defined. Default: false.
+ *
+ * @type boolean
+ */
+YAHOO.widget.AutoComplete.prototype.forceSelection = false;
+
+/**
+ * Whether or not to allow browsers to cache user-typed input in the input
+ * field. Disabling this feature will prevent the widget from setting the
+ * autocomplete="off" on the auto complete input field. When autocomplete="off"
+ * and users click the back button after form submission, user-typed input can
+ * be prefilled by the browser from its cache. This caching of user input may
+ * not be desired for sensitive data, such as credit card numbers, in which
+ * case, implementers should consider setting allowBrowserAutocomplete to false.
+ * Default: true.
+ *
+ * @type boolean
+ */
+YAHOO.widget.AutoComplete.prototype.allowBrowserAutocomplete = true;
+
+/**
+ * Whether or not the auto complete container should always be displayed.
+ * Enabling this feature prevents the toggling of the container to a collapsed
+ * state. Default: false.
+ *
+ * @type boolean
+ */
+YAHOO.widget.AutoComplete.prototype.alwaysShowContainer = false;
+
+/**
+ * Whether or not to use an iFrame to layer over Windows form elements in
+ * IE. Set to true only when the auto complete container will be on top of a
+ * <select> field in IE and thus exposed to the IE z-index bug (i.e.,
+ * 5.5 < IE < 7). Default:false.
+ *
+ * @type boolean
+ */
+YAHOO.widget.AutoComplete.prototype.useIFrame = false;
+
+/**
+ * Configurable iFrame src used when useIFrame = true. Implementations over SSL
+ * should set this parameter to an appropriate https location in order to avoid
+ * security-related browser errors. Default:"about:blank".
+ *
+ * @type boolean
+ */
+YAHOO.widget.AutoComplete.prototype.iFrameSrc = "about:blank";
+
+/**
+ * Whether or not the auto complete container should have a shadow. Default:false.
+ *
+ * @type boolean
+ */
+YAHOO.widget.AutoComplete.prototype.useShadow = false;
+
+/***************************************************************************
+ * Public methods
+ ***************************************************************************/
+ /**
+ * Public accessor to the unique name of the auto complete instance.
+ *
+ * @return {string} Unique name of the auto complete instance
+ */
+YAHOO.widget.AutoComplete.prototype.getName = function() {
+ return this._sName;
+};
+
+ /**
+ * Public accessor to the unique name of the auto complete instance.
+ *
+ * @return {string} Unique name of the auto complete instance
+ */
+YAHOO.widget.AutoComplete.prototype.toString = function() {
+ return "AutoComplete " + this._sName;
+};
+
+/**
+ * Public accessor to the internal array of DOM <li> elements that
+ * display query results within the auto complete container.
+ *
+ * @return {array} Array of <li> elements within the auto complete
+ * container
+ */
+YAHOO.widget.AutoComplete.prototype.getListItems = function() {
+ return this._aListItems;
+};
+
+/**
+ * Public accessor to the data held in an <li> element of the
+ * auto complete container.
+ *
+ * @return {object or array} Object or array of result data or null
+ */
+YAHOO.widget.AutoComplete.prototype.getListItemData = function(oListItem) {
+ if(oListItem._oResultData) {
+ return oListItem._oResultData;
+ }
+ else {
+ return false;
+ }
+};
+
+/**
+ * Sets HTML markup for the auto complete container header. This markup will be
+ * inserted within a <div> tag with a class of "ac_hd".
+ *
+ * @param {string} sHeader HTML markup for container header
+ */
+YAHOO.widget.AutoComplete.prototype.setHeader = function(sHeader) {
+ if(sHeader) {
+ if(this._oContainer._oContent._oHeader) {
+ this._oContainer._oContent._oHeader.innerHTML = sHeader;
+ this._oContainer._oContent._oHeader.style.display = "block";
+ }
+ }
+ else {
+ this._oContainer._oContent._oHeader.innerHTML = "";
+ this._oContainer._oContent._oHeader.style.display = "none";
+ }
+};
+
+/**
+ * Sets HTML markup for the auto complete container footer. This markup will be
+ * inserted within a <div> tag with a class of "ac_ft".
+ *
+ * @param {string} sFooter HTML markup for container footer
+ */
+YAHOO.widget.AutoComplete.prototype.setFooter = function(sFooter) {
+ if(sFooter) {
+ if(this._oContainer._oContent._oFooter) {
+ this._oContainer._oContent._oFooter.innerHTML = sFooter;
+ this._oContainer._oContent._oFooter.style.display = "block";
+ }
+ }
+ else {
+ this._oContainer._oContent._oFooter.innerHTML = "";
+ this._oContainer._oContent._oFooter.style.display = "none";
+ }
+};
+
+/**
+ * Sets HTML markup for the auto complete container body. This markup will be
+ * inserted within a <div> tag with a class of "ac_bd".
+ *
+ * @param {string} sHeader HTML markup for container body
+ */
+YAHOO.widget.AutoComplete.prototype.setBody = function(sBody) {
+ if(sBody) {
+ if(this._oContainer._oContent._oBody) {
+ this._oContainer._oContent._oBody.innerHTML = sBody;
+ this._oContainer._oContent._oBody.style.display = "block";
+ this._oContainer._oContent.style.display = "block";
+ }
+ }
+ else {
+ this._oContainer._oContent._oBody.innerHTML = "";
+ this._oContainer._oContent.style.display = "none";
+ }
+ this._maxResultsDisplayed = 0;
+};
+
+/**
+ * Overridable method that converts a result item object into HTML markup
+ * for display. Return data values are accessible via the oResultItem object,
+ * and the key return value will always be oResultItem[0]. Markup will be
+ * displayed within <li> element tags in the container.
+ *
+ * @param {object} oResultItem Result item object representing one query result
+ * @param {string} sQuery The current query string
+ * @return {string} HTML markup of formatted result data
+ */
+YAHOO.widget.AutoComplete.prototype.formatResult = function(oResultItem, sQuery) {
+ var sResult = oResultItem[0];
+ if(sResult) {
+ return sResult;
+ }
+ else {
+ return "";
+ }
+};
+
+/**
+ * Makes query request to the data source.
+ *
+ * @param {string} sQuery Query string.
+ */
+YAHOO.widget.AutoComplete.prototype.sendQuery = function(sQuery) {
+ if(sQuery) {
+ this._sendQuery(sQuery);
+ }
+ else {
+ YAHOO.log("Query could not be sent because the string value was empty or null.","warn",this.toString());
+ return;
+ }
+};
+
+/***************************************************************************
+ * Events
+ ***************************************************************************/
+/**
+ * Fired when the auto complete text input box receives focus. Subscribers
+ * receive the following array:<br>
+ * - args[0] The auto complete object instance
+ */
+YAHOO.widget.AutoComplete.prototype.textboxFocusEvent = null;
+
+/**
+ * Fired when the auto complete text input box receives key input. Subscribers
+ * receive the following array:<br>
+ * - args[0] The auto complete object instance
+ * - args[1] The keycode number
+ */
+YAHOO.widget.AutoComplete.prototype.textboxKeyEvent = null;
+
+/**
+ * Fired when the auto complete instance makes a query to the data source.
+ * Subscribers receive the following array:<br>
+ * - args[0] The auto complete object instance
+ * - args[1] The query string
+ */
+YAHOO.widget.AutoComplete.prototype.dataRequestEvent = null;
+
+/**
+ * Fired when the auto complete instance receives query results from the data
+ * source. Subscribers receive the following array:<br>
+ * - args[0] The auto complete object instance
+ * - args[1] The query string
+ * - args[2] Results array
+ */
+YAHOO.widget.AutoComplete.prototype.dataReturnEvent = null;
+
+/**
+ * Fired when the auto complete instance does not receive query results from the
+ * data source due to an error. Subscribers receive the following array:<br>
+ * - args[0] The auto complete object instance
+ * - args[1] The query string
+ */
+YAHOO.widget.AutoComplete.prototype.dataErrorEvent = null;
+
+/**
+ * Fired when the auto complete container is expanded. If alwaysShowContainer is
+ * enabled, then containerExpandEvent will be fired when the container is
+ * populated with results. Subscribers receive the following array:<br>
+ * - args[0] The auto complete object instance
+ */
+YAHOO.widget.AutoComplete.prototype.containerExpandEvent = null;
+
+/**
+ * Fired when the auto complete textbox has been prefilled by the type-ahead
+ * feature. Subscribers receive the following array:<br>
+ * - args[0] The auto complete object instance
+ * - args[1] The query string
+ * - args[2] The prefill string
+ */
+YAHOO.widget.AutoComplete.prototype.typeAheadEvent = null;
+
+/**
+ * Fired when result item has been moused over. Subscribers receive the following
+ * array:<br>
+ * - args[0] The auto complete object instance
+ * - args[1] The <li> element item moused to
+ */
+YAHOO.widget.AutoComplete.prototype.itemMouseOverEvent = null;
+
+/**
+ * Fired when result item has been moused out. Subscribers receive the
+ * following array:<br>
+ * - args[0] The auto complete object instance
+ * - args[1] The <li> element item moused from
+ */
+YAHOO.widget.AutoComplete.prototype.itemMouseOutEvent = null;
+
+/**
+ * Fired when result item has been arrowed to. Subscribers receive the following
+ * array:<br>
+ * - args[0] The auto complete object instance
+ * - args[1] The <li> element item arrowed to
+ */
+YAHOO.widget.AutoComplete.prototype.itemArrowToEvent = null;
+
+/**
+ * Fired when result item has been arrowed away from. Subscribers receive the
+ * following array:<br>
+ * - args[0] The auto complete object instance
+ * - args[1] The <li> element item arrowed from
+ */
+YAHOO.widget.AutoComplete.prototype.itemArrowFromEvent = null;
+
+/**
+ * Fired when an item is selected via mouse click, ENTER key, or TAB key.
+ * Subscribers receive the following array:<br>
+ * - args[0] The auto complete object instance
+ * - args[1] The selected <li> element item
+ * - args[2] The data returned for the item, either as an object, or mapped from the schema into an array
+ */
+YAHOO.widget.AutoComplete.prototype.itemSelectEvent = null;
+
+/**
+ * Fired when an user selection does not match any of the displayed result items.
+ * Note that this event may not behave as expected when delimiter characters
+ * have been defined. Subscribers receive the following array:<br>
+ * - args[0] The auto complete object instance
+ * - args[1] The user selection
+ */
+YAHOO.widget.AutoComplete.prototype.unmatchedItemSelectEvent = null;
+
+/**
+ * Fired if forceSelection is enabled and the user's input has been cleared
+ * because it did not match one of the returned query results. Subscribers
+ * receive the following array:<br>
+ * - args[0] The auto complete object instance
+ */
+YAHOO.widget.AutoComplete.prototype.selectionEnforceEvent = null;
+
+/**
+ * Fired when the auto complete container is collapsed. If alwaysShowContainer is
+ * enabled, then containerCollapseEvent will be fired when the container is
+ * cleared of results. Subscribers receive the following array:<br>
+ * - args[0] The auto complete object instance
+ */
+YAHOO.widget.AutoComplete.prototype.containerCollapseEvent = null;
+
+/**
+ * Fired when the auto complete text input box loses focus. Subscribers receive
+ * an array of the following array:<br>
+ * - args[0] The auto complete object instance
+ */
+YAHOO.widget.AutoComplete.prototype.textboxBlurEvent = null;
+
+/***************************************************************************
+ * Private member variables
+ ***************************************************************************/
+/**
+ * Internal class variable to index multiple auto complete instances.
+ *
+ * @type number
+ * @private
+ */
+YAHOO.widget.AutoComplete._nIndex = 0;
+
+/**
+ * Name of auto complete instance.
+ *
+ * @type string
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._sName = null;
+
+/**
+ * Text input box DOM element.
+ *
+ * @type object
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._oTextbox = null;
+
+/**
+ * Whether or not the textbox is currently in focus. If query results come back
+ * but the user has already moved on, do not proceed with auto complete behavior.
+ *
+ * @type boolean
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._bFocused = true;
+
+/**
+ * Animation instance for container expand/collapse.
+ *
+ * @type boolean
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._oAnim = null;
+
+/**
+ * Container DOM element.
+ *
+ * @type object
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._oContainer = null;
+
+/**
+ * Whether or not the auto complete container is currently open.
+ *
+ * @type boolean
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._bContainerOpen = false;
+
+/**
+ * Whether or not the mouse is currently over the auto complete
+ * container. This is necessary in order to prevent clicks on container items
+ * from being text input box blur events.
+ *
+ * @type boolean
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._bOverContainer = false;
+
+/**
+ * Array of <li> elements references that contain query results within the
+ * auto complete container.
+ *
+ * @type array
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._aListItems = null;
+
+/**
+ * Number of <li> elements currently displayed in auto complete container.
+ *
+ * @type number
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._nDisplayedItems = 0;
+
+/**
+ * Internal count of <li> elements displayed and hidden in auto complete container.
+ *
+ * @type number
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._maxResultsDisplayed = 0;
+
+/**
+ * Current query string
+ *
+ * @type string
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._sCurQuery = null;
+
+/**
+ * Past queries this session (for saving delimited queries).
+ *
+ * @type string
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._sSavedQuery = null;
+
+/**
+ * Pointer to the currently highlighted <li> element in the container.
+ *
+ * @type object
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._oCurItem = null;
+
+/**
+ * Whether or not an item has been selected since the container was populated
+ * with results. Reset to false by _populateList, and set to true when item is
+ * selected.
+ *
+ * @type boolean
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._bItemSelected = false;
+
+/**
+ * Key code of the last key pressed in textbox.
+ *
+ * @type number
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._nKeyCode = null;
+
+/**
+ * Delay timeout ID.
+ *
+ * @type number
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._nDelayID = -1;
+
+/***************************************************************************
+ * Private methods
+ ***************************************************************************/
+/**
+ * Updates and validates latest public config properties.
+ *
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._initProps = function() {
+ // Correct any invalid values
+ var minQueryLength = this.minQueryLength;
+ if(isNaN(minQueryLength) || (minQueryLength < 1)) {
+ minQueryLength = 1;
+ }
+ var maxResultsDisplayed = this.maxResultsDisplayed;
+ if(isNaN(this.maxResultsDisplayed) || (this.maxResultsDisplayed < 1)) {
+ this.maxResultsDisplayed = 10;
+ }
+ var queryDelay = this.queryDelay;
+ if(isNaN(this.queryDelay) || (this.queryDelay < 0)) {
+ this.queryDelay = 0.5;
+ }
+ var aDelimChar = (this.delimChar) ? this.delimChar : null;
+ if(aDelimChar) {
+ if(typeof aDelimChar == "string") {
+ this.delimChar = [aDelimChar];
+ }
+ else if(aDelimChar.constructor != Array) {
+ this.delimChar = null;
+ }
+ }
+ var animSpeed = this.animSpeed;
+ if((this.animHoriz || this.animVert) && YAHOO.util.Anim) {
+ if(isNaN(animSpeed) || (animSpeed < 0)) {
+ animSpeed = 0.3;
+ }
+ if(!this._oAnim ) {
+ oAnim = new YAHOO.util.Anim(this._oContainer._oContent, {}, this.animSpeed);
+ this._oAnim = oAnim;
+ }
+ else {
+ this._oAnim.duration = animSpeed;
+ }
+ }
+ if(this.forceSelection && this.delimChar) {
+ YAHOO.log("The forceSelection feature has been enabled with delimChar defined.","warn", this.toString());
+ }
+ if(this.alwaysShowContainer && (this.useShadow || this.useIFrame)) {
+ YAHOO.log("The features useShadow and useIFrame are not compatible with the alwaysShowContainer feature.","warn", this.toString());
+ }
+
+ if(this.alwaysShowContainer) {
+ this._bContainerOpen = true;
+ }
+};
+
+/**
+ * Initializes the auto complete container helpers if they are enabled and do
+ * not exist
+ *
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._initContainerHelpers = function() {
+ if(this.useShadow && !this._oContainer._oShadow) {
+ var oShadow = document.createElement("div");
+ oShadow.className = "yui-ac-shadow";
+ this._oContainer._oShadow = this._oContainer.appendChild(oShadow);
+ }
+ if(this.useIFrame && !this._oContainer._oIFrame) {
+ var oIFrame = document.createElement("iframe");
+ oIFrame.src = this.iFrameSrc;
+ oIFrame.frameBorder = 0;
+ oIFrame.scrolling = "no";
+ oIFrame.style.position = "absolute";
+ oIFrame.style.width = "100%";
+ oIFrame.style.height = "100%";
+ this._oContainer._oIFrame = this._oContainer.appendChild(oIFrame);
+ }
+};
+
+/**
+ * Initializes the auto complete container once at object creation
+ *
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._initContainer = function() {
+ if(!this._oContainer._oContent) {
+ // The oContent div helps size the iframe and shadow properly
+ var oContent = document.createElement("div");
+ oContent.className = "yui-ac-content";
+ oContent.style.display = "none";
+ this._oContainer._oContent = this._oContainer.appendChild(oContent);
+
+ var oHeader = document.createElement("div");
+ oHeader.className = "yui-ac-hd";
+ oHeader.style.display = "none";
+ this._oContainer._oContent._oHeader = this._oContainer._oContent.appendChild(oHeader);
+
+ var oBody = document.createElement("div");
+ oBody.className = "yui-ac-bd";
+ this._oContainer._oContent._oBody = this._oContainer._oContent.appendChild(oBody);
+
+ var oFooter = document.createElement("div");
+ oFooter.className = "yui-ac-ft";
+ oFooter.style.display = "none";
+ this._oContainer._oContent._oFooter = this._oContainer._oContent.appendChild(oFooter);
+ }
+ else {
+ YAHOO.log("Could not initialize the container","warn",this.toString());
+ }
+};
+
+/**
+ * Clears out contents of container body and creates up to
+ * YAHOO.widget.AutoComplete#maxResultsDisplayed <li> elements in an
+ * <ul> element.
+ *
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._initList = function() {
+ this._aListItems = [];
+ while(this._oContainer._oContent._oBody.hasChildNodes()) {
+ var oldListItems = this.getListItems();
+ if(oldListItems) {
+ for(var oldi = oldListItems.length-1; oldi >= 0; i--) {
+ oldListItems[oldi] = null;
+ }
+ }
+ this._oContainer._oContent._oBody.innerHTML = "";
+ }
+
+ var oList = document.createElement("ul");
+ oList = this._oContainer._oContent._oBody.appendChild(oList);
+ for(var i=0; i<this.maxResultsDisplayed; i++) {
+ var oItem = document.createElement("li");
+ oItem = oList.appendChild(oItem);
+ this._aListItems[i] = oItem;
+ this._initListItem(oItem, i);
+ }
+ this._maxResultsDisplayed = this.maxResultsDisplayed;
+};
+
+/**
+ * Initializes each <li> element in the container list.
+ *
+ * @param {object} oItem The <li> DOM element
+ * @param {number} nItemIndex The index of the element
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._initListItem = function(oItem, nItemIndex) {
+ var oSelf = this;
+ oItem.style.display = "none";
+ oItem._nItemIndex = nItemIndex;
+
+ oItem.mouseover = oItem.mouseout = oItem.onclick = null;
+ YAHOO.util.Event.addListener(oItem,"mouseover",oSelf._onItemMouseover,oSelf);
+ YAHOO.util.Event.addListener(oItem,"mouseout",oSelf._onItemMouseout,oSelf);
+ YAHOO.util.Event.addListener(oItem,"click",oSelf._onItemMouseclick,oSelf);
+};
+
+/**
+ * Handles <li> element mouseover events in the container.
+ *
+ * @param {event} v The mouseover event
+ * @param {object} oSelf The auto complete instance
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._onItemMouseover = function(v,oSelf) {
+ if(oSelf.prehighlightClassName) {
+ oSelf._togglePrehighlight(this,"mouseover");
+ }
+ else {
+ oSelf._toggleHighlight(this,"to");
+ }
+
+ oSelf.itemMouseOverEvent.fire(oSelf, this);
+};
+
+/**
+ * Handles <li> element mouseout events in the container.
+ *
+ * @param {event} v The mouseout event
+ * @param {object} oSelf The auto complete instance
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._onItemMouseout = function(v,oSelf) {
+ if(oSelf.prehighlightClassName) {
+ oSelf._togglePrehighlight(this,"mouseout");
+ }
+ else {
+ oSelf._toggleHighlight(this,"from");
+ }
+
+ oSelf.itemMouseOutEvent.fire(oSelf, this);
+};
+
+/**
+ * Handles <li> element click events in the container.
+ *
+ * @param {event} v The click event
+ * @param {object} oSelf The auto complete instance
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._onItemMouseclick = function(v,oSelf) {
+ // In case item has not been moused over
+ oSelf._toggleHighlight(this,"to");
+ oSelf._selectItem(this);
+};
+
+/**
+ * Handles container mouseover events.
+ *
+ * @param {event} v The mouseover event
+ * @param {object} oSelf The auto complete instance
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._onContainerMouseover = function(v,oSelf) {
+ oSelf._bOverContainer = true;
+};
+
+/**
+ * Handles container mouseout events.
+ *
+ * @param {event} v The mouseout event
+ * @param {object} oSelf The auto complete instance
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._onContainerMouseout = function(v,oSelf) {
+ oSelf._bOverContainer = false;
+ // If container is still active
+ if(oSelf._oCurItem) {
+ oSelf._toggleHighlight(oSelf._oCurItem,"to");
+ }
+};
+
+/**
+ * Handles container scroll events.
+ *
+ * @param {event} v The scroll event
+ * @param {object} oSelf The auto complete instance
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._onContainerScroll = function(v,oSelf) {
+ oSelf._oTextbox.focus();
+};
+
+/**
+ * Handles container resize events.
+ *
+ * @param {event} v The resize event
+ * @param {object} oSelf The auto complete instance
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._onContainerResize = function(v,oSelf) {
+ oSelf._toggleContainerHelpers(oSelf._bContainerOpen);
+};
+
+
+/**
+ * Handles textbox keydown events of functional keys, mainly for UI behavior.
+ *
+ * @param {event} v The keydown event
+ * @param {object} oSelf The auto complete instance
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._onTextboxKeyDown = function(v,oSelf) {
+ var nKeyCode = v.keyCode;
+
+ switch (nKeyCode) {
+ case 9: // tab
+ if(oSelf.delimChar && (oSelf._nKeyCode != nKeyCode)) {
+ if(oSelf._bContainerOpen) {
+ YAHOO.util.Event.stopEvent(v);
+ }
+ }
+ // select an item or clear out
+ if(oSelf._oCurItem) {
+ oSelf._selectItem(oSelf._oCurItem);
+ }
+ else {
+ oSelf._clearList();
+ }
+ break;
+ case 13: // enter
+ if(oSelf._nKeyCode != nKeyCode) {
+ if(oSelf._bContainerOpen) {
+ YAHOO.util.Event.stopEvent(v);
+ }
+ }
+ if(oSelf._oCurItem) {
+ oSelf._selectItem(oSelf._oCurItem);
+ }
+ else {
+ oSelf._clearList();
+ }
+ break;
+ case 27: // esc
+ oSelf._clearList();
+ return;
+ case 39: // right
+ oSelf._jumpSelection();
+ break;
+ case 38: // up
+ YAHOO.util.Event.stopEvent(v);
+ oSelf._moveSelection(nKeyCode);
+ break;
+ case 40: // down
+ YAHOO.util.Event.stopEvent(v);
+ oSelf._moveSelection(nKeyCode);
+ break;
+ default:
+ break;
+ }
+};
+
+/**
+ * Handles textbox keypress events, mainly for stopEvent in Safari.
+ *
+ * @param {event} v The keyup event
+ * @param {object} oSelf The auto complete instance
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._onTextboxKeyPress = function(v,oSelf) {
+ var nKeyCode = v.keyCode;
+
+ switch (nKeyCode) {
+ case 9: // tab
+ case 13: // enter
+ if((oSelf._nKeyCode != nKeyCode)) {
+ YAHOO.util.Event.stopEvent(v);
+ }
+ break;
+ case 38: // up
+ case 40: // down
+ YAHOO.util.Event.stopEvent(v);
+ break;
+ default:
+ break;
+ }
+};
+
+/**
+ * Handles textbox keyup events that trigger queries.
+ *
+ * @param {event} v The keyup event
+ * @param {object} oSelf The auto complete instance
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._onTextboxKeyUp = function(v,oSelf) {
+ // Check to see if any of the public properties have been updated
+ oSelf._initProps();
+
+ var nKeyCode = v.keyCode;
+ oSelf._nKeyCode = nKeyCode;
+ var sChar = String.fromCharCode(nKeyCode);
+ var sText = this.value; //string in textbox
+
+ // Filter out chars that don't trigger queries
+ if (oSelf._isIgnoreKey(nKeyCode) || (sText.toLowerCase() == oSelf._sCurQuery)) {
+ return;
+ }
+ else {
+ oSelf.textboxKeyEvent.fire(oSelf, nKeyCode);
+ }
+
+ // Set timeout on the request
+ if (oSelf.queryDelay > 0) {
+ var nDelayID =
+ setTimeout(function(){oSelf._sendQuery(sText);},(oSelf.queryDelay * 1000));
+
+ if (oSelf._nDelayID != -1) {
+ clearTimeout(oSelf._nDelayID);
+ }
+
+ oSelf._nDelayID = nDelayID;
+ }
+ else {
+ // No delay so send request immediately
+ oSelf._sendQuery(sText);
+ }
+};
+
+/**
+ * Whether or not key is functional or should be ignored. Note that the right
+ * arrow key is NOT an ignored key since it triggers queries for certain intl
+ * charsets.
+ *
+ * @param {number} nKeycode Code of key pressed
+ * @return {boolean} Whether or not to be ignore key
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._isIgnoreKey = function(nKeyCode) {
+ if ((nKeyCode == 9) || (nKeyCode == 13) || // tab, enter
+ (nKeyCode == 16) || (nKeyCode == 17) || // shift, ctl
+ (nKeyCode >= 18 && nKeyCode <= 20) || // alt,pause/break,caps lock
+ (nKeyCode == 27) || // esc
+ (nKeyCode >= 33 && nKeyCode <= 35) || // page up,page down,end
+ (nKeyCode >= 36 && nKeyCode <= 38) || // home,left,up
+ (nKeyCode == 40) || // down
+ (nKeyCode >= 44 && nKeyCode <= 45)) { // print screen,insert
+ return true;
+ }
+ return false;
+};
+
+/**
+ * Handles text input box receiving focus.
+ *
+ * @param {event} v The focus event
+ * @param {object} oSelf The auto complete instance
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._onTextboxFocus = function (v,oSelf) {
+ oSelf._oTextbox.setAttribute("autocomplete","off");
+ oSelf._bFocused = true;
+ oSelf.textboxFocusEvent.fire(oSelf);
+};
+
+/**
+ * Handles text input box losing focus.
+ *
+ * @param {event} v The focus event
+ * @param {object} oSelf The auto complete instance
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._onTextboxBlur = function (v,oSelf) {
+ // Don't treat as a blur if it was a selection via mouse click
+ if(!oSelf._bOverContainer || (oSelf._nKeyCode == 9)) {
+ // Current query needs to be validated
+ if(!oSelf._bItemSelected) {
+ if(!oSelf._bContainerOpen || (oSelf._bContainerOpen && !oSelf._textMatchesOption())) {
+ if(oSelf.forceSelection) {
+ oSelf._clearSelection();
+ }
+ else {
+ oSelf.unmatchedItemSelectEvent.fire(oSelf, oSelf._sCurQuery);
+ }
+ }
+ }
+
+ if(oSelf._bContainerOpen) {
+ oSelf._clearList();
+ }
+ oSelf._bFocused = false;
+ oSelf.textboxBlurEvent.fire(oSelf);
+ }
+};
+
+/**
+ * Handles form submission event.
+ *
+ * @param {event} v The submit event
+ * @param {object} oSelf The auto complete instance
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._onFormSubmit = function(v,oSelf) {
+ if(oSelf.allowBrowserAutocomplete) {
+ oSelf._oTextbox.setAttribute("autocomplete","on");
+ }
+ else {
+ oSelf._oTextbox.setAttribute("autocomplete","off");
+ }
+};
+
+/**
+ * Makes query request to the data source.
+ *
+ * @param {string} sQuery Query string.
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._sendQuery = function(sQuery) {
+ // Delimiter has been enabled
+ var aDelimChar = (this.delimChar) ? this.delimChar : null;
+ if(aDelimChar) {
+ // Loop through all possible delimiters and find the latest one
+ // A " " may be a false positive if they are defined as delimiters AND
+ // are used to separate delimited queries
+ var nDelimIndex = -1;
+ for(var i = aDelimChar.length-1; i >= 0; i--) {
+ var nNewIndex = sQuery.lastIndexOf(aDelimChar[i]);
+ if(nNewIndex > nDelimIndex) {
+ nDelimIndex = nNewIndex;
+ }
+ }
+ // If we think the last delimiter is a space (" "), make sure it is NOT
+ // a false positive by also checking the char directly before it
+ if(aDelimChar[i] == " ") {
+ for (var j = aDelimChar.length-1; j >= 0; j--) {
+ if(sQuery[nDelimIndex - 1] == aDelimChar[j]) {
+ nDelimIndex--;
+ break;
+ }
+ }
+ }
+ // A delimiter has been found so extract the latest query
+ if (nDelimIndex > -1) {
+ var nQueryStart = nDelimIndex + 1;
+ // Trim any white space from the beginning...
+ while(sQuery.charAt(nQueryStart) == " ") {
+ nQueryStart += 1;
+ }
+ // ...and save the rest of the string for later
+ this._sSavedQuery = sQuery.substring(0,nQueryStart);
+ // Here is the query itself
+ sQuery = sQuery.substr(nQueryStart);
+ }
+ else if(sQuery.indexOf(this._sSavedQuery) < 0){
+ this._sSavedQuery = null;
+ }
+ }
+
+ // Don't search queries that are too short
+ if (sQuery.length < this.minQueryLength) {
+ if (this._nDelayID != -1) {
+ clearTimeout(this._nDelayID);
+ }
+ this._clearList();
+ return;
+ }
+
+ sQuery = encodeURIComponent(sQuery);
+ this._nDelayID = -1; // Reset timeout ID because request has been made
+ this.dataRequestEvent.fire(this, sQuery);
+ this.dataSource.getResults(this._populateList, sQuery, this);
+};
+
+/**
+ * Hides all visuals related to the array of <li> elements in the container.
+ *
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._clearList = function() {
+ this._oContainer._oContent.scrollTop = 0;
+ var aItems = this._aListItems;
+
+ if(aItems && (aItems.length > 0)) {
+ for(var i = aItems.length-1; i >= 0 ; i--) {
+ aItems[i].style.display = "none";
+ }
+ }
+
+ if (this._oCurItem) {
+ this._toggleHighlight(this._oCurItem,"from");
+ }
+
+ this._oCurItem = null;
+ this._nDisplayedItems = 0;
+ this._sCurQuery = null;
+ this._toggleContainer(false);
+};
+
+/**
+ * Populates the array of <li> elements in the container with query
+ * results. This method is passed to YAHOO.widget.DataSource#getResults as a
+ * callback function so results from the datasource are returned to the
+ * auto complete instance.
+ *
+ * @param {string} sQuery The query string
+ * @param {object} aResults An array of query result objects from the data source
+ * @param {string} oSelf The auto complete instance
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._populateList = function(sQuery, aResults, oSelf) {
+ if(aResults === null) {
+ oSelf.dataErrorEvent.fire(oSelf, sQuery);
+ }
+ if (!oSelf._bFocused || !aResults) {
+ return;
+ }
+
+ var isOpera = (navigator.userAgent.toLowerCase().indexOf("opera") != -1);
+ var contentStyle = oSelf._oContainer._oContent.style;
+ contentStyle.width = (!isOpera) ? null : "";
+ contentStyle.height = (!isOpera) ? null : "";
+
+ var sCurQuery = decodeURIComponent(sQuery);
+ oSelf._sCurQuery = sCurQuery;
+ oSelf._bItemSelected = false;
+
+ if(oSelf._maxResultsDisplayed != oSelf.maxResultsDisplayed) {
+ oSelf._initList();
+ }
+
+ var nItems = Math.min(aResults.length,oSelf.maxResultsDisplayed);
+ oSelf._nDisplayedItems = nItems;
+ if (nItems > 0) {
+ oSelf._initContainerHelpers();
+ var aItems = oSelf._aListItems;
+
+ // Fill items with data
+ for(var i = nItems-1; i >= 0; i--) {
+ var oItemi = aItems[i];
+ var oResultItemi = aResults[i];
+ oItemi.innerHTML = oSelf.formatResult(oResultItemi, sCurQuery);
+ oItemi.style.display = "list-item";
+ oItemi._sResultKey = oResultItemi[0];
+ oItemi._oResultData = oResultItemi;
+
+ }
+
+ // Empty out remaining items if any
+ for(var j = aItems.length-1; j >= nItems ; j--) {
+ var oItemj = aItems[j];
+ oItemj.innerHTML = null;
+ oItemj.style.display = "none";
+ oItemj._sResultKey = null;
+ oItemj._oResultData = null;
+ }
+
+ if(oSelf.autoHighlight) {
+ // Go to the first item
+ var oFirstItem = aItems[0];
+ oSelf._toggleHighlight(oFirstItem,"to");
+ oSelf.itemArrowToEvent.fire(oSelf, oFirstItem);
+ oSelf._typeAhead(oFirstItem,sQuery);
+ }
+ else {
+ oSelf._oCurItem = null;
+ }
+
+ // Expand the container
+ oSelf._toggleContainer(true);
+ }
+ else {
+ oSelf._clearList();
+ }
+ oSelf.dataReturnEvent.fire(oSelf, sQuery, aResults);
+};
+
+/**
+ * When YAHOO.widget.AutoComplete#bForceSelection is true and the user attempts
+ * leave the text input box without selecting an item from the query results,
+ * the user selection is cleared.
+ *
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._clearSelection = function() {
+ var sValue = this._oTextbox.value;
+ var sChar = (this.delimChar) ? this.delimChar[0] : null;
+ var nIndex = (sChar) ? sValue.lastIndexOf(sChar, sValue.length-2) : -1;
+ if(nIndex > -1) {
+ this._oTextbox.value = sValue.substring(0,nIndex);
+ }
+ else {
+ this._oTextbox.value = "";
+ }
+ this._sSavedQuery = this._oTextbox.value;
+
+ // Fire custom event
+ this.selectionEnforceEvent.fire(this);
+};
+
+/**
+ * Whether or not user-typed value in the text input box matches any of the
+ * query results.
+ *
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._textMatchesOption = function() {
+ var foundMatch = false;
+
+ for(var i = this._nDisplayedItems-1; i >= 0 ; i--) {
+ var oItem = this._aListItems[i];
+ var sMatch = oItem._sResultKey.toLowerCase();
+ if (sMatch == this._sCurQuery.toLowerCase()) {
+ foundMatch = true;
+ break;
+ }
+ }
+ return(foundMatch);
+};
+
+/**
+ * Updates in the text input box with the first query result as the user types,
+ * selecting the substring that the user has not typed.
+ *
+ * @param {object} oItem The <li> element item whose data populates the input field
+ * @param {string} sQuery Query string
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._typeAhead = function(oItem, sQuery) {
+ // Don't update if turned off
+ if (!this.typeAhead) {
+ return;
+ }
+
+ var oTextbox = this._oTextbox;
+ var sValue = this._oTextbox.value; // any saved queries plus what user has typed
+
+ // Don't update with type-ahead if text selection is not supported
+ if(!oTextbox.setSelectionRange && !oTextbox.createTextRange) {
+ return;
+ }
+
+ // Select the portion of text that the user has not typed
+ var nStart = sValue.length;
+ this._updateValue(oItem);
+ var nEnd = oTextbox.value.length;
+ this._selectText(oTextbox,nStart,nEnd);
+ var sPrefill = oTextbox.value.substr(nStart,nEnd);
+ this.typeAheadEvent.fire(this,sQuery,sPrefill);
+};
+
+/**
+ * Selects text in a text input box.
+ *
+ * @param {object} oTextbox Text input box element in which to select text
+ * @param {number} nStart Starting index of text string to select
+ * @param {number} nEnd Ending index of text selection
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._selectText = function(oTextbox, nStart, nEnd) {
+ if (oTextbox.setSelectionRange) { // For Mozilla
+ oTextbox.setSelectionRange(nStart,nEnd);
+ }
+ else if (oTextbox.createTextRange) { // For IE
+ var oTextRange = oTextbox.createTextRange();
+ oTextRange.moveStart("character", nStart);
+ oTextRange.moveEnd("character", nEnd-oTextbox.value.length);
+ oTextRange.select();
+ }
+ else {
+ oTextbox.select();
+ }
+};
+
+/**
+ * Syncs auto complete container with its helpers.
+ *
+ * @param {boolean} bShow True if container is expanded, false if collapsed
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._toggleContainerHelpers = function(bShow) {
+ var bFireEvent = false;
+ var width = this._oContainer._oContent.offsetWidth + "px";
+ var height = this._oContainer._oContent.offsetHeight + "px";
+
+ if(this.useIFrame && this._oContainer._oIFrame) {
+ bFireEvent = true;
+ if(this.alwaysShowContainer || bShow) {
+ this._oContainer._oIFrame.style.width = width;
+ this._oContainer._oIFrame.style.height = height;
+ }
+ else {
+ this._oContainer._oIFrame.style.width = 0;
+ this._oContainer._oIFrame.style.height = 0;
+ }
+ }
+ if(this.useShadow && this._oContainer._oShadow) {
+ bFireEvent = true;
+ if(this.alwaysShowContainer || bShow) {
+ this._oContainer._oShadow.style.width = width;
+ this._oContainer._oShadow.style.height = height;
+ }
+ else {
+ this._oContainer._oShadow.style.width = 0;
+ this._oContainer._oShadow.style.height = 0;
+ }
+ }
+};
+
+/**
+ * Animates expansion or collapse of the container.
+ *
+ * @param {boolean} bShow True if container should be expanded, false if
+ * container should be collapsed
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._toggleContainer = function(bShow) {
+ // Implementer has container always open so don't mess with it
+ if(this.alwaysShowContainer) {
+ // Fire these events to give implementers a hook into the container
+ // being populated and being emptied
+ if(bShow) {
+ this.containerExpandEvent.fire(this);
+ }
+ else {
+ this.containerCollapseEvent.fire(this);
+ }
+ this._bContainerOpen = bShow;
+ return;
+ }
+
+ var oContainer = this._oContainer;
+ // Container is already closed
+ if (!bShow && !this._bContainerOpen) {
+ oContainer._oContent.style.display = "none";
+ return;
+ }
+
+ // If animation is enabled...
+ var oAnim = this._oAnim;
+ if (oAnim && oAnim.getEl() && (this.animHoriz || this.animVert)) {
+ // If helpers need to be collapsed, do it right away...
+ // but if helpers need to be expanded, wait until after the container expands
+ if(!bShow) {
+ this._toggleContainerHelpers(bShow);
+ }
+
+ if(oAnim.isAnimated()) {
+ oAnim.stop();
+ }
+
+ // Clone container to grab current size offscreen
+ var oClone = oContainer._oContent.cloneNode(true);
+ oContainer.appendChild(oClone);
+ oClone.style.top = "-9000px";
+ oClone.style.display = "block";
+
+ // Current size of the container is the EXPANDED size
+ var wExp = oClone.offsetWidth;
+ var hExp = oClone.offsetHeight;
+
+ // Calculate COLLAPSED sizes based on horiz and vert anim
+ var wColl = (this.animHoriz) ? 0 : wExp;
+ var hColl = (this.animVert) ? 0 : hExp;
+
+ // Set animation sizes
+ oAnim.attributes = (bShow) ?
+ {width: { to: wExp }, height: { to: hExp }} :
+ {width: { to: wColl}, height: { to: hColl }};
+
+ // If opening anew, set to a collapsed size...
+ if(bShow && !this._bContainerOpen) {
+ oContainer._oContent.style.width = wColl+"px";
+ oContainer._oContent.style.height = hColl+"px";
+ }
+ // Else, set it to its last known size.
+ else {
+ oContainer._oContent.style.width = wExp+"px";
+ oContainer._oContent.style.height = hExp+"px";
+ }
+
+ oContainer.removeChild(oClone);
+ oClone = null;
+
+ var oSelf = this;
+ var onAnimComplete = function() {
+ // Finish the collapse
+ oAnim.onComplete.unsubscribeAll();
+
+ if(bShow) {
+ oSelf.containerExpandEvent.fire(oSelf);
+ }
+ else {
+ oContainer._oContent.style.display = "none";
+ oSelf.containerCollapseEvent.fire(oSelf);
+ }
+ oSelf._toggleContainerHelpers(bShow);
+ };
+
+ // Display container and animate it
+ oContainer._oContent.style.display = "block";
+ oAnim.onComplete.subscribe(onAnimComplete);
+ oAnim.animate();
+ this._bContainerOpen = bShow;
+ }
+ // Else don't animate, just show or hide
+ else {
+ if(bShow) {
+ oContainer._oContent.style.display = "block";
+ this.containerExpandEvent.fire(this);
+ }
+ else {
+ oContainer._oContent.style.display = "none";
+ this.containerCollapseEvent.fire(this);
+ }
+ this._toggleContainerHelpers(bShow);
+ this._bContainerOpen = bShow;
+ }
+
+};
+
+/**
+ * Toggles the highlight on or off for an item in the container, and also cleans
+ * up highlighting of any previous item.
+ *
+ * @param {object} oNewItem New The <li> element item to receive highlight
+ * behavior
+ * @param {string} sType "mouseover" will toggle highlight on, and "mouseout"
+ * will toggle highlight off.
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._toggleHighlight = function(oNewItem, sType) {
+ var sHighlight = this.highlightClassName;
+ if(this._oCurItem) {
+ // Remove highlight from old item
+ YAHOO.util.Dom.removeClass(this._oCurItem, sHighlight);
+ }
+
+ if((sType == "to") && sHighlight) {
+ // Apply highlight to new item
+ YAHOO.util.Dom.addClass(oNewItem, sHighlight);
+ this._oCurItem = oNewItem;
+ }
+};
+
+/**
+ * Toggles the pre-highlight on or off for an item in the container.
+ *
+ * @param {object} oNewItem New The <li> element item to receive highlight
+ * behavior
+ * @param {string} sType "mouseover" will toggle highlight on, and "mouseout"
+ * will toggle highlight off.
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._togglePrehighlight = function(oNewItem, sType) {
+ if(oNewItem == this._oCurItem) {
+ return;
+ }
+
+ var sPrehighlight = this.prehighlightClassName;
+ if((sType == "mouseover") && sPrehighlight) {
+ // Apply prehighlight to new item
+ YAHOO.util.Dom.addClass(oNewItem, sPrehighlight);
+ }
+ else {
+ // Remove prehighlight from old item
+ YAHOO.util.Dom.removeClass(oNewItem, sPrehighlight);
+ }
+};
+
+/**
+ * Updates the text input box value with selected query result. If a delimiter
+ * has been defined, then the value gets appended with the delimiter.
+ *
+ * @param {object} oItem The <li> element item with which to update the value
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._updateValue = function(oItem) {
+ var oTextbox = this._oTextbox;
+ var sDelimChar = (this.delimChar) ? this.delimChar[0] : null;
+ var sSavedQuery = this._sSavedQuery;
+ var sResultKey = oItem._sResultKey;
+ oTextbox.focus();
+
+ // First clear text field
+ oTextbox.value = "";
+ // Grab data to put into text field
+ if(sDelimChar) {
+ if(sSavedQuery) {
+ oTextbox.value = sSavedQuery;
+ }
+ oTextbox.value += sResultKey + sDelimChar;
+ if(sDelimChar != " ") {
+ oTextbox.value += " ";
+ }
+ }
+ else { oTextbox.value = sResultKey; }
+
+ // scroll to bottom of textarea if necessary
+ if(oTextbox.type == "textarea") {
+ oTextbox.scrollTop = oTextbox.scrollHeight;
+ }
+
+ // move cursor to end
+ var end = oTextbox.value.length;
+ this._selectText(oTextbox,end,end);
+
+ this._oCurItem = oItem;
+};
+
+/**
+ * Selects a result item from the container
+ *
+ * @param {object} oItem The selected <li> element item
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._selectItem = function(oItem) {
+ this._bItemSelected = true;
+ this._updateValue(oItem);
+ this.itemSelectEvent.fire(this, oItem, oItem._oResultData);
+ this._clearList();
+};
+
+/**
+ * For values updated by type-ahead, the right arrow key jumps to the end
+ * of the textbox, otherwise the container is closed.
+ *
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._jumpSelection = function() {
+ if(!this.typeAhead) {
+ return;
+ }
+ else {
+ this._clearList();
+ }
+};
+
+/**
+ * Triggered by up and down arrow keys, changes the current highlighted
+ * <li> element item. Scrolls container if necessary.
+ *
+ * @param {number} nKeyCode Code of key pressed
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._moveSelection = function(nKeyCode) {
+ if(this._bContainerOpen) {
+ // Determine current item's id number
+ var oCurItem = this._oCurItem;
+ var nCurItemIndex = -1;
+
+ if (oCurItem) {
+ nCurItemIndex = oCurItem._nItemIndex;
+ }
+
+ var nNewItemIndex = (nKeyCode == 40) ?
+ (nCurItemIndex + 1) : (nCurItemIndex - 1);
+
+ // Out of bounds
+ if (nNewItemIndex < -2 || nNewItemIndex >= this._nDisplayedItems) {
+ return;
+ }
+
+ if (oCurItem) {
+ // Unhighlight current item
+ this._toggleHighlight(oCurItem, "from");
+ this.itemArrowFromEvent.fire(this, oCurItem);
+ }
+ if (nNewItemIndex == -1) {
+ // Go back to query (remove type-ahead string)
+ if(this.delimChar && this._sSavedQuery) {
+ if (!this._textMatchesOption()) {
+ this._oTextbox.value = this._sSavedQuery;
+ }
+ else {
+ this._oTextbox.value = this._sSavedQuery + this._sCurQuery;
+ }
+ }
+ else {
+ this._oTextbox.value = this._sCurQuery;
+ }
+ this._oCurItem = null;
+ return;
+ }
+ if (nNewItemIndex == -2) {
+ // Close container
+ this._clearList();
+ return;
+ }
+
+ var oNewItem = this._aListItems[nNewItemIndex];
+
+ // Scroll the container if necessary
+ if((YAHOO.util.Dom.getStyle(this._oContainer._oContent,"overflow") == "auto") &&
+ (nNewItemIndex > -1) && (nNewItemIndex < this._nDisplayedItems)) {
+ // User is keying down
+ if(nKeyCode == 40) {
+ // Bottom of selected item is below scroll area...
+ if((oNewItem.offsetTop+oNewItem.offsetHeight) > (this._oContainer._oContent.scrollTop + this._oContainer._oContent.offsetHeight)) {
+ // Set bottom of scroll area to bottom of selected item
+ this._oContainer._oContent.scrollTop = (oNewItem.offsetTop+oNewItem.offsetHeight) - this._oContainer._oContent.offsetHeight;
+ }
+ // Bottom of selected item is above scroll area...
+ else if((oNewItem.offsetTop+oNewItem.offsetHeight) < this._oContainer._oContent.scrollTop) {
+ // Set top of selected item to top of scroll area
+ this._oContainer._oContent.scrollTop = oNewItem.offsetTop;
+
+ }
+ }
+ // User is keying up
+ else {
+ // Top of selected item is above scroll area
+ if(oNewItem.offsetTop < this._oContainer._oContent.scrollTop) {
+ // Set top of scroll area to top of selected item
+ this._oContainer._oContent.scrollTop = oNewItem.offsetTop;
+ }
+ // Top of selected item is below scroll area
+ else if(oNewItem.offsetTop > (this._oContainer._oContent.scrollTop + this._oContainer._oContent.offsetHeight)) {
+ // Set bottom of selected item to bottom of scroll area
+ this._oContainer._oContent.scrollTop = (oNewItem.offsetTop+oNewItem.offsetHeight) - this._oContainer._oContent.offsetHeight;
+ }
+ }
+ }
+
+ this._toggleHighlight(oNewItem, "to");
+ this.itemArrowToEvent.fire(this, oNewItem);
+ if(this.typeAhead) {
+ this._updateValue(oNewItem);
+ }
+ }
+};
+
+/****************************************************************************/
+/****************************************************************************/
+/****************************************************************************/
+
+/**
+ * Class providing encapsulation of a data source.
+ *
+ * @constructor
+ *
+ */
+YAHOO.widget.DataSource = function() {
+ /* abstract class */
+};
+
+
+/***************************************************************************
+ * Public constants
+ ***************************************************************************/
+/**
+ * Error message for null data responses.
+ *
+ * @type constant
+ * @final
+ */
+YAHOO.widget.DataSource.prototype.ERROR_DATANULL = "Response data was null";
+
+/**
+ * Error message for data responses with parsing errors.
+ *
+ * @type constant
+ * @final
+ */
+YAHOO.widget.DataSource.prototype.ERROR_DATAPARSE = "Response data could not be parsed";
+
+
+/***************************************************************************
+ * Public member variables
+ ***************************************************************************/
+/**
+ * Max size of the local cache. Set to 0 to turn off caching. Caching is
+ * useful to reduce the number of server connections. Recommended only for data
+ * sources that return comprehensive results for queries or when stale data is
+ * not an issue. Default: 15.
+ *
+ * @type number
+ */
+YAHOO.widget.DataSource.prototype.maxCacheEntries = 15;
+
+/**
+ * Use this to equate cache matching with the type of matching done by your live
+ * data source. If caching is on and queryMatchContains is true, the cache
+ * returns results that "contain" the query string. By default,
+ * queryMatchContains is set to false, meaning the cache only returns results
+ * that "start with" the query string. Default: false.
+ *
+ * @type boolean
+ */
+YAHOO.widget.DataSource.prototype.queryMatchContains = false;
+
+/**
+ * Data source query subset matching. If caching is on and queryMatchSubset is
+ * true, substrings of queries will return matching cached results. For
+ * instance, if the first query is for "abc" susequent queries that start with
+ * "abc", like "abcd", will be queried against the cache, and not the live data
+ * source. Recommended only for data sources that return comprehensive results
+ * for queries with very few characters. Default: false.
+ *
+ * @type boolean
+ */
+YAHOO.widget.DataSource.prototype.queryMatchSubset = false;
+
+/**
+ * Data source query case-sensitivity matching. If caching is on and
+ * queryMatchCase is true, queries will only return results for case-sensitive
+ * matches. Default: false.
+ *
+ * @type boolean
+ */
+YAHOO.widget.DataSource.prototype.queryMatchCase = false;
+
+
+/***************************************************************************
+ * Public methods
+ ***************************************************************************/
+ /**
+ * Public accessor to the unique name of the data source instance.
+ *
+ * @return {string} Unique name of the data source instance
+ */
+YAHOO.widget.DataSource.prototype.getName = function() {
+ return this._sName;
+};
+
+ /**
+ * Public accessor to the unique name of the data source instance.
+ *
+ * @return {string} Unique name of the data source instance
+ */
+YAHOO.widget.DataSource.prototype.toString = function() {
+ return "DataSource " + this._sName;
+};
+
+/**
+ * Retrieves query results, first checking the local cache, then making the
+ * query request to the live data source as defined by the function doQuery.
+ *
+ * @param {object} oCallbackFn Callback function defined by oParent object to
+ * which to return results
+ * @param {string} sQuery Query string
+ * @param {object} oParent The object instance that has requested data
+ */
+YAHOO.widget.DataSource.prototype.getResults = function(oCallbackFn, sQuery, oParent) {
+
+ // First look in cache
+ var aResults = this._doQueryCache(oCallbackFn,sQuery,oParent);
+
+ // Not in cache, so get results from server
+ if(aResults.length === 0) {
+ this.queryEvent.fire(this, oParent, sQuery);
+ this.doQuery(oCallbackFn, sQuery, oParent);
+ }
+};
+
+/**
+ * Abstract method implemented by subclasses to make a query to the live data
+ * source. Must call the callback function with the response returned from the
+ * query. Populates cache (if enabled).
+ *
+ * @param {object} oCallbackFn Callback function implemented by oParent to
+ * which to return results
+ * @param {string} sQuery Query string
+ * @param {object} oParent The object instance that has requested data
+ */
+YAHOO.widget.DataSource.prototype.doQuery = function(oCallbackFn, sQuery, oParent) {
+ /* override this */
+};
+
+/**
+ * Flushes cache.
+ */
+YAHOO.widget.DataSource.prototype.flushCache = function() {
+ if(this._aCache) {
+ this._aCache = [];
+ }
+ if(this._aCacheHelper) {
+ this._aCacheHelper = [];
+ }
+ this.cacheFlushEvent.fire(this);
+};
+
+/***************************************************************************
+ * Events
+ ***************************************************************************/
+/**
+ * Fired when a query is made to the live data source. Subscribers receive the
+ * following array:<br>
+ * - args[0] The data source instance
+ * - args[1] The requesting object
+ * - args[2] The query string
+ */
+YAHOO.widget.DataSource.prototype.queryEvent = null;
+
+/**
+ * Fired when a query is made to the local cache. Subscribers receive the
+ * following array:<br>
+ * - args[0] The data source instance
+ * - args[1] The requesting object
+ * - args[2] The query string
+ */
+YAHOO.widget.DataSource.prototype.cacheQueryEvent = null;
+
+/**
+ * Fired when data is retrieved from the live data source. Subscribers receive
+ * the following array:<br>
+ * - args[0] The data source instance
+ * - args[1] The requesting object
+ * - args[2] The query string
+ * - args[3] Array of result objects
+ */
+YAHOO.widget.DataSource.prototype.getResultsEvent = null;
+
+/**
+ * Fired when data is retrieved from the local cache. Subscribers receive the
+ * following array :<br>
+ * - args[0] The data source instance
+ * - args[1] The requesting object
+ * - args[2] The query string
+ * - args[3] Array of result objects
+ */
+YAHOO.widget.DataSource.prototype.getCachedResultsEvent = null;
+
+/**
+ * Fired when an error is encountered with the live data source. Subscribers
+ * receive the following array:<br>
+ * - args[0] The data source instance
+ * - args[1] The requesting object
+ * - args[2] The query string
+ * - args[3] Error message string
+ */
+YAHOO.widget.DataSource.prototype.dataErrorEvent = null;
+
+/**
+ * Fired when the local cache is flushed. Subscribers receive the following
+ * array :<br>
+ * - args[0] The data source instance
+ */
+YAHOO.widget.DataSource.prototype.cacheFlushEvent = null;
+
+/***************************************************************************
+ * Private member variables
+ ***************************************************************************/
+/**
+ * Internal class variable to index multiple data source instances.
+ *
+ * @type number
+ * @private
+ */
+YAHOO.widget.DataSource._nIndex = 0;
+
+/**
+ * Name of data source instance.
+ *
+ * @type string
+ * @private
+ */
+YAHOO.widget.DataSource.prototype._sName = null;
+
+/**
+ * Local cache of data result objects indexed chronologically.
+ *
+ * @type array
+ * @private
+ */
+YAHOO.widget.DataSource.prototype._aCache = null;
+
+
+/***************************************************************************
+ * Private methods
+ ***************************************************************************/
+/**
+ * Initializes data source instance.
+ *
+ * @private
+ */
+YAHOO.widget.DataSource.prototype._init = function() {
+ // Validate and initialize public configs
+ var maxCacheEntries = this.maxCacheEntries;
+ if(isNaN(maxCacheEntries) || (maxCacheEntries < 0)) {
+ maxCacheEntries = 0;
+ }
+ // Initialize local cache
+ if(maxCacheEntries > 0 && !this._aCache) {
+ this._aCache = [];
+ }
+
+ this._sName = "instance" + YAHOO.widget.DataSource._nIndex;
+ YAHOO.widget.DataSource._nIndex++;
+
+ this.queryEvent = new YAHOO.util.CustomEvent("query", this);
+ this.cacheQueryEvent = new YAHOO.util.CustomEvent("cacheQuery", this);
+ this.getResultsEvent = new YAHOO.util.CustomEvent("getResults", this);
+ this.getCachedResultsEvent = new YAHOO.util.CustomEvent("getCachedResults", this);
+ this.dataErrorEvent = new YAHOO.util.CustomEvent("dataError", this);
+ this.cacheFlushEvent = new YAHOO.util.CustomEvent("cacheFlush", this);
+};
+
+/**
+ * Adds a result object to the local cache, evicting the oldest element if the
+ * cache is full. Newer items will have higher indexes, the oldest item will have
+ * index of 0.
+ *
+ * @param {object} resultObj Object literal of data results, including internal
+ * properties and an array of result objects
+ * @private
+ */
+YAHOO.widget.DataSource.prototype._addCacheElem = function(resultObj) {
+ var aCache = this._aCache;
+ // Don't add if anything important is missing.
+ if(!aCache || !resultObj || !resultObj.query || !resultObj.results) {
+ return;
+ }
+
+ // If the cache is full, make room by removing from index=0
+ if(aCache.length >= this.maxCacheEntries) {
+ aCache.shift();
+ }
+
+ // Add to cache, at the end of the array
+ aCache.push(resultObj);
+};
+
+/**
+ * Queries the local cache for results. If query has been cached, the callback
+ * function is called with the results, and the cached is refreshed so that it
+ * is now the newest element.
+ *
+ * @param {object} oCallbackFn Callback function defined by oParent object to
+ * which to return results
+ * @param {string} sQuery Query string
+ * @param {object} oParent The object instance that has requested data
+ * @return {array} aResults Result object from local cache if found, otherwise
+ * null
+ * @private
+ */
+YAHOO.widget.DataSource.prototype._doQueryCache = function(oCallbackFn, sQuery, oParent) {
+ var aResults = [];
+ var bMatchFound = false;
+ var aCache = this._aCache;
+ var nCacheLength = (aCache) ? aCache.length : 0;
+ var bMatchContains = this.queryMatchContains;
+
+ // If cache is enabled...
+ if((this.maxCacheEntries > 0) && aCache && (nCacheLength > 0)) {
+ this.cacheQueryEvent.fire(this, oParent, sQuery);
+ // If case is unimportant, normalize query now instead of in loops
+ if(!this.queryMatchCase) {
+ var sOrigQuery = sQuery;
+ sQuery = sQuery.toLowerCase();
+ }
+
+ // Loop through each cached element's query property...
+ for(var i = nCacheLength-1; i >= 0; i--) {
+ var resultObj = aCache[i];
+ var aAllResultItems = resultObj.results;
+ // If case is unimportant, normalize match key for comparison
+ var matchKey = (!this.queryMatchCase) ?
+ encodeURIComponent(resultObj.query.toLowerCase()):
+ encodeURIComponent(resultObj.query);
+
+ // If a cached match key exactly matches the query...
+ if(matchKey == sQuery) {
+ // Stash all result objects into aResult[] and stop looping through the cache.
+ bMatchFound = true;
+ aResults = aAllResultItems;
+
+ // The matching cache element was not the most recent,
+ // so now we need to refresh the cache.
+ if(i != nCacheLength-1) {
+ // Remove element from its original location
+ aCache.splice(i,1);
+ // Add element as newest
+ this._addCacheElem(resultObj);
+ }
+ break;
+ }
+ // Else if this query is not an exact match and subset matching is enabled...
+ else if(this.queryMatchSubset) {
+ // Loop through substrings of each cached element's query property...
+ for(var j = sQuery.length-1; j >= 0 ; j--) {
+ var subQuery = sQuery.substr(0,j);
+
+ // If a substring of a cached sQuery exactly matches the query...
+ if(matchKey == subQuery) {
+ bMatchFound = true;
+
+ // Go through each cached result object to match against the query...
+ for(var k = aAllResultItems.length-1; k >= 0; k--) {
+ var aRecord = aAllResultItems[k];
+ var sKeyIndex = (this.queryMatchCase) ?
+ encodeURIComponent(aRecord[0]).indexOf(sQuery):
+ encodeURIComponent(aRecord[0]).toLowerCase().indexOf(sQuery);
+
+ // A STARTSWITH match is when the query is found at the beginning of the key string...
+ if((!bMatchContains && (sKeyIndex === 0)) ||
+ // A CONTAINS match is when the query is found anywhere within the key string...
+ (bMatchContains && (sKeyIndex > -1))) {
+ // Stash a match into aResults[].
+ aResults.unshift(aRecord);
+ }
+ }
+
+ // Add the subset match result set object as the newest element to cache,
+ // and stop looping through the cache.
+ resultObj = {};
+ resultObj.query = sQuery;
+ resultObj.results = aResults;
+ this._addCacheElem(resultObj);
+ break;
+ }
+ }
+ if(bMatchFound) {
+ break;
+ }
+ }
+ }
+
+ // If there was a match, send along the results.
+ if(bMatchFound) {
+ this.getCachedResultsEvent.fire(this, oParent, sOrigQuery, aResults);
+ oCallbackFn(sOrigQuery, aResults, oParent);
+ }
+ }
+ return aResults;
+};
+
+
+/****************************************************************************/
+/****************************************************************************/
+/****************************************************************************/
+
+/**
+ * Implementation of YAHOO.widget.DataSource using XML HTTP requests that return
+ * query results.
+ * requires YAHOO.util.Connect XMLHTTPRequest library
+ * extends YAHOO.widget.DataSource
+ *
+ * @constructor
+ * @param {string} sScriptURI Absolute or relative URI to script that returns
+ * query results as JSON, XML, or delimited flat data
+ * @param {array} aSchema Data schema definition of results
+ * @param {object} oConfigs Optional object literal of config params
+ */
+YAHOO.widget.DS_XHR = function(sScriptURI, aSchema, oConfigs) {
+ // Set any config params passed in to override defaults
+ if(typeof oConfigs == "object") {
+ for(var sConfig in oConfigs) {
+ this[sConfig] = oConfigs[sConfig];
+ }
+ }
+
+ // Initialization sequence
+ if(!aSchema || (aSchema.constructor != Array)) {
+ YAHOO.log("Could not instantiate XHR DataSource due to invalid arguments", "error", this.toString());
+ return;
+ }
+ else {
+ this.schema = aSchema;
+ }
+ this.scriptURI = sScriptURI;
+ this._init();
+ YAHOO.log("XHR DataSource initialized","info",this.toString());
+};
+
+YAHOO.widget.DS_XHR.prototype = new YAHOO.widget.DataSource();
+
+/***************************************************************************
+ * Public constants
+ ***************************************************************************/
+/**
+ * JSON data type
+ *
+ * @type constant
+ * @final
+ */
+YAHOO.widget.DS_XHR.prototype.TYPE_JSON = 0;
+
+/**
+ * XML data type
+ *
+ * @type constant
+ * @final
+ */
+YAHOO.widget.DS_XHR.prototype.TYPE_XML = 1;
+
+/**
+ * Flat file data type
+ *
+ * @type constant
+ * @final
+ */
+YAHOO.widget.DS_XHR.prototype.TYPE_FLAT = 2;
+
+/**
+ * Error message for XHR failure.
+ *
+ * @type constant
+ * @final
+ */
+YAHOO.widget.DS_XHR.prototype.ERROR_DATAXHR = "XHR response failed";
+
+/***************************************************************************
+ * Public member variables
+ ***************************************************************************/
+/**
+ * Number of milliseconds the XHR connection will wait for a server response. A
+ * a value of zero indicates the XHR connection will wait forever. Any value
+ * greater than zero will use the Connection utility's Auto-Abort feature.
+ * Default: 0.
+ *
+ * @type number
+ */
+YAHOO.widget.DS_XHR.prototype.connTimeout = 0;
+
+
+/**
+ * Absolute or relative URI to script that returns query results. For instance,
+ * queries will be sent to
+ * <scriptURI>?<scriptQueryParam>=userinput
+ *
+ * @type string
+ */
+YAHOO.widget.DS_XHR.prototype.scriptURI = null;
+
+/**
+ * Query string parameter name sent to scriptURI. For instance, queries will be
+ * sent to
+ * <scriptURI>?<scriptQueryParam>=userinput
+ * Default: "query".
+ *
+ * @type string
+ */
+YAHOO.widget.DS_XHR.prototype.scriptQueryParam = "query";
+
+/**
+ * String of key/value pairs to append to requests made to scriptURI. Define
+ * this string when you want to send additional query parameters to your script.
+ * When defined, queries will be sent to
+ * <scriptURI>?<scriptQueryParam>=userinput&<scriptQueryAppend>
+ * Default: "".
+ *
+ * @type string
+ */
+YAHOO.widget.DS_XHR.prototype.scriptQueryAppend = "";
+
+/**
+ * XHR response data type. Other types that may be defined are TYPE_XML and
+ * TYPE_FLAT. Default: TYPE_JSON.
+ *
+ * @type type
+ */
+YAHOO.widget.DS_XHR.prototype.responseType = YAHOO.widget.DS_XHR.prototype.TYPE_JSON;
+
+/**
+ * String after which to strip results. If the results from the XHR are sent
+ * back as HTML, the gzip HTML comment appears at the end of the data and should
+ * be ignored. Default: "\n<!--"
+ *
+ * @type string
+ */
+YAHOO.widget.DS_XHR.prototype.responseStripAfter = "\n<!--";
+
+/***************************************************************************
+ * Public methods
+ ***************************************************************************/
+/**
+ * Queries the live data source defined by scriptURI for results. Results are
+ * passed back to a callback function.
+ *
+ * @param {object} oCallbackFn Callback function defined by oParent object to
+ * which to return results
+ * @param {string} sQuery Query string
+ * @param {object} oParent The object instance that has requested data
+ */
+YAHOO.widget.DS_XHR.prototype.doQuery = function(oCallbackFn, sQuery, oParent) {
+ var isXML = (this.responseType == this.TYPE_XML);
+ var sUri = this.scriptURI+"?"+this.scriptQueryParam+"="+sQuery;
+ if(this.scriptQueryAppend.length > 0) {
+ sUri += "&" + this.scriptQueryAppend;
+ }
+ YAHOO.log("Data source is querying URL " + sUri, "info", this.toString());
+ var oResponse = null;
+
+ var oSelf = this;
+ /**
+ * Sets up ajax request callback
+ *
+ * @param {object} oReq HTTPXMLRequest object
+ * @private
+ */
+ var responseSuccess = function(oResp) {
+ // Response ID does not match last made request ID.
+ if(!oSelf._oConn || (oResp.tId != oSelf._oConn.tId)) {
+ oSelf.dataErrorEvent.fire(oSelf, oParent, sQuery, oSelf.ERROR_DATANULL);
+ YAHOO.log(oSelf.ERROR_DATANULL, "error", this.toString());
+ return;
+ }
+//DEBUG
+/*YAHOO.log(oResp.responseXML.getElementsByTagName("Result"),'warn');
+for(var foo in oResp) {
+ YAHOO.log(foo + ": "+oResp[foo],'warn');
+}
+YAHOO.log('responseXML.xml: '+oResp.responseXML.xml,'warn');*/
+ if(!isXML) {
+ oResp = oResp.responseText;
+ }
+ else {
+ oResp = oResp.responseXML;
+ }
+ if(oResp === null) {
+ oSelf.dataErrorEvent.fire(oSelf, oParent, sQuery, oSelf.ERROR_DATANULL);
+ YAHOO.log(oSelf.ERROR_DATANULL, "error", oSelf.toString());
+ return;
+ }
+
+ var aResults = oSelf.parseResponse(sQuery, oResp, oParent);
+ var resultObj = {};
+ resultObj.query = decodeURIComponent(sQuery);
+ resultObj.results = aResults;
+ if(aResults === null) {
+ oSelf.dataErrorEvent.fire(oSelf, oParent, sQuery, oSelf.ERROR_DATAPARSE);
+ YAHOO.log(oSelf.ERROR_DATAPARSE, "error", oSelf.toString());
+ return;
+ }
+ else {
+ oSelf.getResultsEvent.fire(oSelf, oParent, sQuery, aResults);
+ oSelf._addCacheElem(resultObj);
+ oCallbackFn(sQuery, aResults, oParent);
+ }
+ };
+
+ var responseFailure = function(oResp) {
+ oSelf.dataErrorEvent.fire(oSelf, oParent, sQuery, oSelf.ERROR_DATAXHR);
+ YAHOO.log(oSelf.ERROR_DATAXHR + ": " + oResp.statusText, "error", oSelf.toString());
+ return;
+ };
+
+ var oCallback = {
+ success:responseSuccess,
+ failure:responseFailure
+ };
+
+ if(!isNaN(this.connTimeout) && this.connTimeout > 0) {
+ oCallback.timeout = this.connTimeout;
+ }
+
+ if(this._oConn) {
+ YAHOO.util.Connect.abort(this._oConn);
+ }
+
+ oSelf._oConn = YAHOO.util.Connect.asyncRequest("GET", sUri, oCallback, null);
+};
+
+/**
+ * Parses raw response data into an array of result objects. The result data key
+ * is always stashed in the [0] element of each result object.
+ *
+ * @param {string} sQuery Query string
+ * @param {object} oResponse The raw response data to parse
+ * @param {object} oParent The object instance that has requested data
+ * @returns {array} Array of result objects
+ */
+YAHOO.widget.DS_XHR.prototype.parseResponse = function(sQuery, oResponse, oParent) {
+ var aSchema = this.schema;
+ var aResults = [];
+ var bError = false;
+
+ // Strip out comment at the end of results
+ var nEnd = ((this.responseStripAfter !== "") && (oResponse.indexOf)) ?
+ oResponse.indexOf(this.responseStripAfter) : -1;
+ if(nEnd != -1) {
+ oResponse = oResponse.substring(0,nEnd);
+ }
+
+ switch (this.responseType) {
+ case this.TYPE_JSON:
+ var jsonList;
+ // Divert KHTML clients from JSON lib
+ if(window.JSON && (navigator.userAgent.toLowerCase().indexOf('khtml')== -1)) {
+ // Use the JSON utility if available
+ var jsonObjParsed = JSON.parse(oResponse);
+ if(!jsonObjParsed) {
+ bError = true;
+ break;
+ }
+ else {
+ // eval is necessary here since aSchema[0] is of unknown depth
+ jsonList = eval("jsonObjParsed." + aSchema[0]);
+ }
+ }
+ else {
+ // Parse the JSON response as a string
+ try {
+ // Trim leading spaces
+ while (oResponse.substring(0,1) == " ") {
+ oResponse = oResponse.substring(1, oResponse.length);
+ }
+
+ // Invalid JSON response
+ if(oResponse.indexOf("{") < 0) {
+ bError = true;
+ break;
+ }
+
+ // Empty (but not invalid) JSON response
+ if(oResponse.indexOf("{}") === 0) {
+ break;
+ }
+
+ // Turn the string into an object literal...
+ // ...eval is necessary here
+ var jsonObjRaw = eval("(" + oResponse + ")");
+ if(!jsonObjRaw) {
+ bError = true;
+ break;
+ }
+
+ // Grab the object member that contains an array of all reponses...
+ // ...eval is necessary here since aSchema[0] is of unknown depth
+ jsonList = eval("(jsonObjRaw." + aSchema[0]+")");
+ }
+ catch(e) {
+ bError = true;
+ break;
+ }
+ }
+
+ if(!jsonList) {
+ bError = true;
+ break;
+ }
+
+ // Loop through the array of all responses...
+ for(var i = jsonList.length-1; i >= 0 ; i--) {
+ var aResultItem = [];
+ var jsonResult = jsonList[i];
+ // ...and loop through each data field value of each response
+ for(var j = aSchema.length-1; j >= 1 ; j--) {
+ // ...and capture data into an array mapped according to the schema...
+ var dataFieldValue = jsonResult[aSchema[j]];
+ if(!dataFieldValue) {
+ dataFieldValue = "";
+ }
+ //YAHOO.log("data: " + i + " value:" +j+" = "+dataFieldValue,"debug",this.toString());
+ aResultItem.unshift(dataFieldValue);
+ }
+ // Capture the array of data field values in an array of results
+ aResults.unshift(aResultItem);
+ }
+ break;
+ case this.TYPE_XML:
+ // Get the collection of results
+ var xmlList = oResponse.getElementsByTagName(aSchema[0]);
+ if(!xmlList) {
+ bError = true;
+ break;
+ }
+ // Loop through each result
+ for(var k = xmlList.length-1; k >= 0 ; k--) {
+ var result = xmlList.item(k);
+ //YAHOO.log("Result"+k+" is "+result.attributes.item(0).firstChild.nodeValue,"debug",this.toString());
+ var aFieldSet = [];
+ // Loop through each data field in each result using the schema
+ for(var m = aSchema.length-1; m >= 1 ; m--) {
+ //YAHOO.log(aSchema[m]+" is "+result.attributes.getNamedItem(aSchema[m]).firstChild.nodeValue);
+ var sValue = null;
+ // Values may be held in an attribute...
+ var xmlAttr = result.attributes.getNamedItem(aSchema[m]);
+ if(xmlAttr) {
+ sValue = xmlAttr.value;
+ //YAHOO.log("Attr value is "+sValue,"debug",this.toString());
+ }
+ // ...or in a node
+ else{
+ var xmlNode = result.getElementsByTagName(aSchema[m]);
+ if(xmlNode && xmlNode.item(0) && xmlNode.item(0).firstChild) {
+ sValue = xmlNode.item(0).firstChild.nodeValue;
+ //YAHOO.log("Node value is "+sValue,"debug",this.toString());
+ }
+ else {
+ sValue = "";
+ //YAHOO.log("Value not found","debug",this.toString());
+ }
+ }
+ // Capture the schema-mapped data field values into an array
+ aFieldSet.unshift(sValue);
+ }
+ // Capture each array of values into an array of results
+ aResults.unshift(aFieldSet);
+ }
+ break;
+ case this.TYPE_FLAT:
+ if(oResponse.length > 0) {
+ // Delete the last line delimiter at the end of the data if it exists
+ var newLength = oResponse.length-aSchema[0].length;
+ if(oResponse.substr(newLength) == aSchema[0]) {
+ oResponse = oResponse.substr(0, newLength);
+ }
+ var aRecords = oResponse.split(aSchema[0]);
+ for(var n = aRecords.length-1; n >= 0; n--) {
+ aResults[n] = aRecords[n].split(aSchema[1]);
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ sQuery = null;
+ oResponse = null;
+ oParent = null;
+ if(bError) {
+ return null;
+ }
+ else {
+ return aResults;
+ }
+};
+
+
+/***************************************************************************
+ * Private member variables
+ ***************************************************************************/
+/**
+ * XHR connection object.
+ *
+ * @type object
+ * @private
+ */
+YAHOO.widget.DS_XHR.prototype._oConn = null;
+
+
+/****************************************************************************/
+/****************************************************************************/
+/****************************************************************************/
+
+/**
+ * Implementation of YAHOO.widget.DataSource using a native Javascript struct as
+ * its live data source.
+ *
+ * @constructor
+ * extends YAHOO.widget.DataSource
+ *
+ * @param {string} oFunction In-memory Javascript function that returns query
+ * results as an array of objects
+ * @param {object} oConfigs Optional object literal of config params
+ */
+YAHOO.widget.DS_JSFunction = function(oFunction, oConfigs) {
+ // Set any config params passed in to override defaults
+ if(typeof oConfigs == "object") {
+ for(var sConfig in oConfigs) {
+ this[sConfig] = oConfigs[sConfig];
+ }
+ }
+
+ // Initialization sequence
+ if(!oFunction || (oFunction.constructor != Function)) {
+ YAHOO.log("Could not instantiate JSFunction DataSource due to invalid arguments", "error", this.toString());
+ return;
+ }
+ else {
+ this.dataFunction = oFunction;
+ this._init();
+ YAHOO.log("JS Function DataSource initialized","info",this.toString());
+ }
+};
+
+YAHOO.widget.DS_JSFunction.prototype = new YAHOO.widget.DataSource();
+
+/***************************************************************************
+ * Public member variables
+ ***************************************************************************/
+/**
+ * In-memory Javascript function that returns query results.
+ *
+ * @type function
+ */
+YAHOO.widget.DS_JSFunction.prototype.dataFunction = null;
+
+
+/***************************************************************************
+ * Public methods
+ ***************************************************************************/
+/**
+ * Queries the live data source defined by function for results. Results are
+ * passed back to a callback function.
+ *
+ * @param {object} oCallbackFn Callback function defined by oParent object to
+ * which to return results
+ * @param {string} sQuery Query string
+ * @param {object} oParent The object instance that has requested data
+ */
+YAHOO.widget.DS_JSFunction.prototype.doQuery = function(oCallbackFn, sQuery, oParent) {
+ var oFunction = this.dataFunction;
+ var aResults = [];
+
+ aResults = oFunction(sQuery);
+ if(aResults === null) {
+ this.dataErrorEvent.fire(this, oParent, sQuery, this.ERROR_DATANULL);
+ YAHOO.log(oSelf.ERROR_DATANULL, "error", this.toString());
+ return;
+ }
+
+ var resultObj = {};
+ resultObj.query = decodeURIComponent(sQuery);
+ resultObj.results = aResults;
+ this._addCacheElem(resultObj);
+
+ this.getResultsEvent.fire(this, oParent, sQuery, aResults);
+ oCallbackFn(sQuery, aResults, oParent);
+ return;
+};
+
+/****************************************************************************/
+/****************************************************************************/
+/****************************************************************************/
+
+/**
+ * Implementation of YAHOO.widget.DataSource using a native Javascript array as
+ * its live data source.
+ *
+ * @constructor
+ * extends YAHOO.widget.DataSource
+ *
+ * @param {string} aData In-memory Javascript array of simple string data
+ * @param {object} oConfigs Optional object literal of config params
+ */
+YAHOO.widget.DS_JSArray = function(aData, oConfigs) {
+ // Set any config params passed in to override defaults
+ if(typeof oConfigs == "object") {
+ for(var sConfig in oConfigs) {
+ this[sConfig] = oConfigs[sConfig];
+ }
+ }
+
+ // Initialization sequence
+ if(!aData || (aData.constructor != Array)) {
+ YAHOO.log("Could not instantiate JSArray DataSource due to invalid arguments", "error", this.toString());
+ return;
+ }
+ else {
+ this.data = aData;
+ this._init();
+ YAHOO.log("JS Array DataSource initialized","info",this.toString());
+ }
+};
+
+YAHOO.widget.DS_JSArray.prototype = new YAHOO.widget.DataSource();
+
+/***************************************************************************
+ * Public member variables
+ ***************************************************************************/
+/**
+ * In-memory Javascript array of strings.
+ *
+ * @type array
+ */
+YAHOO.widget.DS_JSArray.prototype.data = null;
+
+/***************************************************************************
+ * Public methods
+ ***************************************************************************/
+/**
+ * Queries the live data source defined by data for results. Results are passed
+ * back to a callback function.
+ *
+ * @param {object} oCallbackFn Callback function defined by oParent object to
+ * which to return results
+ * @param {string} sQuery Query string
+ * @param {object} oParent The object instance that has requested data
+ */
+YAHOO.widget.DS_JSArray.prototype.doQuery = function(oCallbackFn, sQuery, oParent) {
+ var aData = this.data;
+ var aResults = [];
+ var bMatchFound = false;
+ var bMatchContains = this.queryMatchContains;
+ if(!this.queryMatchCase) {
+ sQuery = sQuery.toLowerCase();
+ }
+
+ // Loop through each element of the array...
+ for(var i = aData.length-1; i >= 0; i--) {
+ var aDataset = [];
+ if(typeof aData[i] == "string") {
+ aDataset[0] = aData[i];
+ }
+ else {
+ aDataset = aData[i];
+ }
+
+ var sKeyIndex = (this.queryMatchCase) ?
+ encodeURIComponent(aDataset[0]).indexOf(sQuery):
+ encodeURIComponent(aDataset[0]).toLowerCase().indexOf(sQuery);
+
+ // A STARTSWITH match is when the query is found at the beginning of the key string...
+ if((!bMatchContains && (sKeyIndex === 0)) ||
+ // A CONTAINS match is when the query is found anywhere within the key string...
+ (bMatchContains && (sKeyIndex > -1))) {
+ // Stash a match into aResults[].
+ aResults.unshift(aDataset);
+ }
+ }
+
+ this.getResultsEvent.fire(this, oParent, sQuery, aResults);
+ oCallbackFn(sQuery, aResults, oParent);
+};
Added: branches/tomek/portal-dnd/dndRenderer.war/js/autocomplete/autocomplete-min.js
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/autocomplete/autocomplete-min.js 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/autocomplete/autocomplete-min.js 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,181 @@
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.com/yui/license.txt
+version: 0.11.0
+*/
+
+
+YAHOO.widget.AutoComplete=function(inputEl,containerEl,oDataSource,oConfigs){if(inputEl&&containerEl&&oDataSource){if(oDataSource&&(oDataSource instanceof YAHOO.widget.DataSource)){this.dataSource=oDataSource;}
+else{return;}
+if(YAHOO.util.Dom.inDocument(inputEl)){if(typeof inputEl=="string"){this._sName="instance"+YAHOO.widget.AutoComplete._nIndex+" "+inputEl;this._oTextbox=document.getElementById(inputEl);}
+else{this._sName=(inputEl.id)?"instance"+YAHOO.widget.AutoComplete._nIndex+" "+inputEl.id:"instance"+YAHOO.widget.AutoComplete._nIndex;this._oTextbox=inputEl;}}
+else{return;}
+if(YAHOO.util.Dom.inDocument(containerEl)){if(typeof containerEl=="string"){this._oContainer=document.getElementById(containerEl);}
+else{this._oContainer=containerEl;}
+if(this._oContainer.style.display=="none"){}}
+else{return;}
+if(typeof oConfigs=="object"){for(var sConfig in oConfigs){if(sConfig){this[sConfig]=oConfigs[sConfig];}}}
+this._initContainer();this._initProps();this._initList();this._initContainerHelpers();var oSelf=this;var oTextbox=this._oTextbox;var oContent=this._oContainer._oContent;YAHOO.util.Event.addListener(oTextbox,"keyup",oSelf._onTextboxKeyUp,oSelf);YAHOO.util.Event.addListener(oTextbox,"keydown",oSelf._onTextboxKeyDown,oSelf);YAHOO.util.Event.addListener(oTextbox,"keypress",oSelf._onTextboxKeyPress,oSelf);YAHOO.util.Event.addListener(oTextbox,"focus",oSelf._onTextboxFocus,oSelf);YAHOO.util.Event.addListener(oTextbox,"blur",oSelf._onTextboxBlur,oSelf);YAHOO.util.Event.addListener(oContent,"mouseover",oSelf._onContainerMouseover,oSelf);YAHOO.util.Event.addListener(oContent,"mouseout",oSelf._onContainerMouseout,oSelf);YAHOO.util.Event.addListener(oContent,"scroll",oSelf._onContainerScroll,oSelf);YAHOO.util.Event.addListener(oContent,"resize",oSelf._onContainerResize,oSelf);if(oTextbox.form){YAHOO.util.Event.addListener(oTextbox.form,"submit",oSelf._onFormSubmit,oSelf);}
+this.textboxFocusEvent=new YAHOO.util.CustomEvent("textboxFocus",this);this.textboxKeyEvent=new YAHOO.util.CustomEvent("textboxKey",this);this.dataRequestEvent=new YAHOO.util.CustomEvent("dataRequest",this);this.dataReturnEvent=new YAHOO.util.CustomEvent("dataReturn",this);this.dataErrorEvent=new YAHOO.util.CustomEvent("dataError",this);this.containerExpandEvent=new YAHOO.util.CustomEvent("containerExpand",this);this.typeAheadEvent=new YAHOO.util.CustomEvent("typeAhead",this);this.itemMouseOverEvent=new YAHOO.util.CustomEvent("itemMouseOver",this);this.itemMouseOutEvent=new YAHOO.util.CustomEvent("itemMouseOut",this);this.itemArrowToEvent=new YAHOO.util.CustomEvent("itemArrowTo",this);this.itemArrowFromEvent=new YAHOO.util.CustomEvent("itemArrowFrom",this);this.itemSelectEvent=new YAHOO.util.CustomEvent("itemSelect",this);this.unmatchedItemSelectEvent=new YAHOO.util.CustomEvent("unmatchedItemSelect",this);this.selectionEnforceEvent=new YAHOO.util.CustomEvent("selectionEnfor!
ce",this);this.containerCollapseEvent=new YAHOO.util.CustomEvent("containerCollapse",this);this.textboxBlurEvent=new YAHOO.util.CustomEvent("textboxBlur",this);oTextbox.setAttribute("autocomplete","off");YAHOO.widget.AutoComplete._nIndex++;}
+else{}};YAHOO.widget.AutoComplete.prototype.dataSource=null;YAHOO.widget.AutoComplete.prototype.minQueryLength=1;YAHOO.widget.AutoComplete.prototype.maxResultsDisplayed=10;YAHOO.widget.AutoComplete.prototype.queryDelay=0.5;YAHOO.widget.AutoComplete.prototype.highlightClassName="yui-ac-highlight";YAHOO.widget.AutoComplete.prototype.prehighlightClassName=null;YAHOO.widget.AutoComplete.prototype.delimChar=null;YAHOO.widget.AutoComplete.prototype.autoHighlight=true;YAHOO.widget.AutoComplete.prototype.typeAhead=false;YAHOO.widget.AutoComplete.prototype.animHoriz=false;YAHOO.widget.AutoComplete.prototype.animVert=true;YAHOO.widget.AutoComplete.prototype.animSpeed=0.3;YAHOO.widget.AutoComplete.prototype.forceSelection=false;YAHOO.widget.AutoComplete.prototype.allowBrowserAutocomplete=true;YAHOO.widget.AutoComplete.prototype.alwaysShowContainer=false;YAHOO.widget.AutoComplete.prototype.useIFrame=false;YAHOO.widget.AutoComplete.prototype.iFrameSrc="about:blank";YAHOO.widget.AutoComp!
lete.prototype.useShadow=false;YAHOO.widget.AutoComplete.prototype.getName=function(){return this._sName;};YAHOO.widget.AutoComplete.prototype.toString=function(){return"AutoComplete "+this._sName;};YAHOO.widget.AutoComplete.prototype.getListItems=function(){return this._aListItems;};YAHOO.widget.AutoComplete.prototype.getListItemData=function(oListItem){if(oListItem._oResultData){return oListItem._oResultData;}
+else{return false;}};YAHOO.widget.AutoComplete.prototype.setHeader=function(sHeader){if(sHeader){if(this._oContainer._oContent._oHeader){this._oContainer._oContent._oHeader.innerHTML=sHeader;this._oContainer._oContent._oHeader.style.display="block";}}
+else{this._oContainer._oContent._oHeader.innerHTML="";this._oContainer._oContent._oHeader.style.display="none";}};YAHOO.widget.AutoComplete.prototype.setFooter=function(sFooter){if(sFooter){if(this._oContainer._oContent._oFooter){this._oContainer._oContent._oFooter.innerHTML=sFooter;this._oContainer._oContent._oFooter.style.display="block";}}
+else{this._oContainer._oContent._oFooter.innerHTML="";this._oContainer._oContent._oFooter.style.display="none";}};YAHOO.widget.AutoComplete.prototype.setBody=function(sBody){if(sBody){if(this._oContainer._oContent._oBody){this._oContainer._oContent._oBody.innerHTML=sBody;this._oContainer._oContent._oBody.style.display="block";this._oContainer._oContent.style.display="block";}}
+else{this._oContainer._oContent._oBody.innerHTML="";this._oContainer._oContent.style.display="none";}
+this._maxResultsDisplayed=0;};YAHOO.widget.AutoComplete.prototype.formatResult=function(oResultItem,sQuery){var sResult=oResultItem[0];if(sResult){return sResult;}
+else{return"";}};YAHOO.widget.AutoComplete.prototype.sendQuery=function(sQuery){if(sQuery){this._sendQuery(sQuery);}
+else{return;}};YAHOO.widget.AutoComplete.prototype.textboxFocusEvent=null;YAHOO.widget.AutoComplete.prototype.textboxKeyEvent=null;YAHOO.widget.AutoComplete.prototype.dataRequestEvent=null;YAHOO.widget.AutoComplete.prototype.dataReturnEvent=null;YAHOO.widget.AutoComplete.prototype.dataErrorEvent=null;YAHOO.widget.AutoComplete.prototype.containerExpandEvent=null;YAHOO.widget.AutoComplete.prototype.typeAheadEvent=null;YAHOO.widget.AutoComplete.prototype.itemMouseOverEvent=null;YAHOO.widget.AutoComplete.prototype.itemMouseOutEvent=null;YAHOO.widget.AutoComplete.prototype.itemArrowToEvent=null;YAHOO.widget.AutoComplete.prototype.itemArrowFromEvent=null;YAHOO.widget.AutoComplete.prototype.itemSelectEvent=null;YAHOO.widget.AutoComplete.prototype.unmatchedItemSelectEvent=null;YAHOO.widget.AutoComplete.prototype.selectionEnforceEvent=null;YAHOO.widget.AutoComplete.prototype.containerCollapseEvent=null;YAHOO.widget.AutoComplete.prototype.textboxBlurEvent=null;YAHOO.widget.AutoComple!
te._nIndex=0;YAHOO.widget.AutoComplete.prototype._sName=null;YAHOO.widget.AutoComplete.prototype._oTextbox=null;YAHOO.widget.AutoComplete.prototype._bFocused=true;YAHOO.widget.AutoComplete.prototype._oAnim=null;YAHOO.widget.AutoComplete.prototype._oContainer=null;YAHOO.widget.AutoComplete.prototype._bContainerOpen=false;YAHOO.widget.AutoComplete.prototype._bOverContainer=false;YAHOO.widget.AutoComplete.prototype._aListItems=null;YAHOO.widget.AutoComplete.prototype._nDisplayedItems=0;YAHOO.widget.AutoComplete.prototype._maxResultsDisplayed=0;YAHOO.widget.AutoComplete.prototype._sCurQuery=null;YAHOO.widget.AutoComplete.prototype._sSavedQuery=null;YAHOO.widget.AutoComplete.prototype._oCurItem=null;YAHOO.widget.AutoComplete.prototype._bItemSelected=false;YAHOO.widget.AutoComplete.prototype._nKeyCode=null;YAHOO.widget.AutoComplete.prototype._nDelayID=-1;YAHOO.widget.AutoComplete.prototype._initProps=function(){var minQueryLength=this.minQueryLength;if(isNaN(minQueryLength)||(min!
QueryLength<1)){minQueryLength=1;}
+var maxResultsDisplayed=this.maxResultsDisplayed;if(isNaN(this.maxResultsDisplayed)||(this.maxResultsDisplayed<1)){this.maxResultsDisplayed=10;}
+var queryDelay=this.queryDelay;if(isNaN(this.queryDelay)||(this.queryDelay<0)){this.queryDelay=0.5;}
+var aDelimChar=(this.delimChar)?this.delimChar:null;if(aDelimChar){if(typeof aDelimChar=="string"){this.delimChar=[aDelimChar];}
+else if(aDelimChar.constructor!=Array){this.delimChar=null;}}
+var animSpeed=this.animSpeed;if((this.animHoriz||this.animVert)&&YAHOO.util.Anim){if(isNaN(animSpeed)||(animSpeed<0)){animSpeed=0.3;}
+if(!this._oAnim){oAnim=new YAHOO.util.Anim(this._oContainer._oContent,{},this.animSpeed);this._oAnim=oAnim;}
+else{this._oAnim.duration=animSpeed;}}
+if(this.forceSelection&&this.delimChar){}
+if(this.alwaysShowContainer&&(this.useShadow||this.useIFrame)){}
+if(this.alwaysShowContainer){this._bContainerOpen=true;}};YAHOO.widget.AutoComplete.prototype._initContainerHelpers=function(){if(this.useShadow&&!this._oContainer._oShadow){var oShadow=document.createElement("div");oShadow.className="yui-ac-shadow";this._oContainer._oShadow=this._oContainer.appendChild(oShadow);}
+if(this.useIFrame&&!this._oContainer._oIFrame){var oIFrame=document.createElement("iframe");oIFrame.src=this.iFrameSrc;oIFrame.frameBorder=0;oIFrame.scrolling="no";oIFrame.style.position="absolute";oIFrame.style.width="100%";oIFrame.style.height="100%";this._oContainer._oIFrame=this._oContainer.appendChild(oIFrame);}};YAHOO.widget.AutoComplete.prototype._initContainer=function(){if(!this._oContainer._oContent){var oContent=document.createElement("div");oContent.className="yui-ac-content";oContent.style.display="none";this._oContainer._oContent=this._oContainer.appendChild(oContent);var oHeader=document.createElement("div");oHeader.className="yui-ac-hd";oHeader.style.display="none";this._oContainer._oContent._oHeader=this._oContainer._oContent.appendChild(oHeader);var oBody=document.createElement("div");oBody.className="yui-ac-bd";this._oContainer._oContent._oBody=this._oContainer._oContent.appendChild(oBody);var oFooter=document.createElement("div");oFooter.className="yui-a!
c-ft";oFooter.style.display="none";this._oContainer._oContent._oFooter=this._oContainer._oContent.appendChild(oFooter);}
+else{}};YAHOO.widget.AutoComplete.prototype._initList=function(){this._aListItems=[];while(this._oContainer._oContent._oBody.hasChildNodes()){var oldListItems=this.getListItems();if(oldListItems){for(var oldi=oldListItems.length-1;oldi>=0;i--){oldListItems[oldi]=null;}}
+this._oContainer._oContent._oBody.innerHTML="";}
+var oList=document.createElement("ul");oList=this._oContainer._oContent._oBody.appendChild(oList);for(var i=0;i<this.maxResultsDisplayed;i++){var oItem=document.createElement("li");oItem=oList.appendChild(oItem);this._aListItems[i]=oItem;this._initListItem(oItem,i);}
+this._maxResultsDisplayed=this.maxResultsDisplayed;};YAHOO.widget.AutoComplete.prototype._initListItem=function(oItem,nItemIndex){var oSelf=this;oItem.style.display="none";oItem._nItemIndex=nItemIndex;oItem.mouseover=oItem.mouseout=oItem.onclick=null;YAHOO.util.Event.addListener(oItem,"mouseover",oSelf._onItemMouseover,oSelf);YAHOO.util.Event.addListener(oItem,"mouseout",oSelf._onItemMouseout,oSelf);YAHOO.util.Event.addListener(oItem,"click",oSelf._onItemMouseclick,oSelf);};YAHOO.widget.AutoComplete.prototype._onItemMouseover=function(v,oSelf){if(oSelf.prehighlightClassName){oSelf._togglePrehighlight(this,"mouseover");}
+else{oSelf._toggleHighlight(this,"to");}
+oSelf.itemMouseOverEvent.fire(oSelf,this);};YAHOO.widget.AutoComplete.prototype._onItemMouseout=function(v,oSelf){if(oSelf.prehighlightClassName){oSelf._togglePrehighlight(this,"mouseout");}
+else{oSelf._toggleHighlight(this,"from");}
+oSelf.itemMouseOutEvent.fire(oSelf,this);};YAHOO.widget.AutoComplete.prototype._onItemMouseclick=function(v,oSelf){oSelf._toggleHighlight(this,"to");oSelf._selectItem(this);};YAHOO.widget.AutoComplete.prototype._onContainerMouseover=function(v,oSelf){oSelf._bOverContainer=true;};YAHOO.widget.AutoComplete.prototype._onContainerMouseout=function(v,oSelf){oSelf._bOverContainer=false;if(oSelf._oCurItem){oSelf._toggleHighlight(oSelf._oCurItem,"to");}};YAHOO.widget.AutoComplete.prototype._onContainerScroll=function(v,oSelf){oSelf._oTextbox.focus();};YAHOO.widget.AutoComplete.prototype._onContainerResize=function(v,oSelf){oSelf._toggleContainerHelpers(oSelf._bContainerOpen);};YAHOO.widget.AutoComplete.prototype._onTextboxKeyDown=function(v,oSelf){var nKeyCode=v.keyCode;switch(nKeyCode){case 9:if(oSelf.delimChar&&(oSelf._nKeyCode!=nKeyCode)){if(oSelf._bContainerOpen){YAHOO.util.Event.stopEvent(v);}}
+if(oSelf._oCurItem){oSelf._selectItem(oSelf._oCurItem);}
+else{oSelf._clearList();}
+break;case 13:if(oSelf._nKeyCode!=nKeyCode){if(oSelf._bContainerOpen){YAHOO.util.Event.stopEvent(v);}}
+if(oSelf._oCurItem){oSelf._selectItem(oSelf._oCurItem);}
+else{oSelf._clearList();}
+break;case 27:oSelf._clearList();return;case 39:oSelf._jumpSelection();break;case 38:YAHOO.util.Event.stopEvent(v);oSelf._moveSelection(nKeyCode);break;case 40:YAHOO.util.Event.stopEvent(v);oSelf._moveSelection(nKeyCode);break;default:break;}};YAHOO.widget.AutoComplete.prototype._onTextboxKeyPress=function(v,oSelf){var nKeyCode=v.keyCode;switch(nKeyCode){case 9:case 13:if((oSelf._nKeyCode!=nKeyCode)){YAHOO.util.Event.stopEvent(v);}
+break;case 38:case 40:YAHOO.util.Event.stopEvent(v);break;default:break;}};YAHOO.widget.AutoComplete.prototype._onTextboxKeyUp=function(v,oSelf){oSelf._initProps();var nKeyCode=v.keyCode;oSelf._nKeyCode=nKeyCode;var sChar=String.fromCharCode(nKeyCode);var sText=this.value;if(oSelf._isIgnoreKey(nKeyCode)||(sText.toLowerCase()==oSelf._sCurQuery)){return;}
+else{oSelf.textboxKeyEvent.fire(oSelf,nKeyCode);}
+if(oSelf.queryDelay>0){var nDelayID=setTimeout(function(){oSelf._sendQuery(sText);},(oSelf.queryDelay*1000));if(oSelf._nDelayID!=-1){clearTimeout(oSelf._nDelayID);}
+oSelf._nDelayID=nDelayID;}
+else{oSelf._sendQuery(sText);}};YAHOO.widget.AutoComplete.prototype._isIgnoreKey=function(nKeyCode){if((nKeyCode==9)||(nKeyCode==13)||(nKeyCode==16)||(nKeyCode==17)||(nKeyCode>=18&&nKeyCode<=20)||(nKeyCode==27)||(nKeyCode>=33&&nKeyCode<=35)||(nKeyCode>=36&&nKeyCode<=38)||(nKeyCode==40)||(nKeyCode>=44&&nKeyCode<=45)){return true;}
+return false;};YAHOO.widget.AutoComplete.prototype._onTextboxFocus=function(v,oSelf){oSelf._oTextbox.setAttribute("autocomplete","off");oSelf._bFocused=true;oSelf.textboxFocusEvent.fire(oSelf);};YAHOO.widget.AutoComplete.prototype._onTextboxBlur=function(v,oSelf){if(!oSelf._bOverContainer||(oSelf._nKeyCode==9)){if(!oSelf._bItemSelected){if(!oSelf._bContainerOpen||(oSelf._bContainerOpen&&!oSelf._textMatchesOption())){if(oSelf.forceSelection){oSelf._clearSelection();}
+else{oSelf.unmatchedItemSelectEvent.fire(oSelf,oSelf._sCurQuery);}}}
+if(oSelf._bContainerOpen){oSelf._clearList();}
+oSelf._bFocused=false;oSelf.textboxBlurEvent.fire(oSelf);}};YAHOO.widget.AutoComplete.prototype._onFormSubmit=function(v,oSelf){if(oSelf.allowBrowserAutocomplete){oSelf._oTextbox.setAttribute("autocomplete","on");}
+else{oSelf._oTextbox.setAttribute("autocomplete","off");}};YAHOO.widget.AutoComplete.prototype._sendQuery=function(sQuery){var aDelimChar=(this.delimChar)?this.delimChar:null;if(aDelimChar){var nDelimIndex=-1;for(var i=aDelimChar.length-1;i>=0;i--){var nNewIndex=sQuery.lastIndexOf(aDelimChar[i]);if(nNewIndex>nDelimIndex){nDelimIndex=nNewIndex;}}
+if(aDelimChar[i]==" "){for(var j=aDelimChar.length-1;j>=0;j--){if(sQuery[nDelimIndex-1]==aDelimChar[j]){nDelimIndex--;break;}}}
+if(nDelimIndex>-1){var nQueryStart=nDelimIndex+1;while(sQuery.charAt(nQueryStart)==" "){nQueryStart+=1;}
+this._sSavedQuery=sQuery.substring(0,nQueryStart);sQuery=sQuery.substr(nQueryStart);}
+else if(sQuery.indexOf(this._sSavedQuery)<0){this._sSavedQuery=null;}}
+if(sQuery.length<this.minQueryLength){if(this._nDelayID!=-1){clearTimeout(this._nDelayID);}
+this._clearList();return;}
+sQuery=encodeURIComponent(sQuery);this._nDelayID=-1;this.dataRequestEvent.fire(this,sQuery);this.dataSource.getResults(this._populateList,sQuery,this);};YAHOO.widget.AutoComplete.prototype._clearList=function(){this._oContainer._oContent.scrollTop=0;var aItems=this._aListItems;if(aItems&&(aItems.length>0)){for(var i=aItems.length-1;i>=0;i--){aItems[i].style.display="none";}}
+if(this._oCurItem){this._toggleHighlight(this._oCurItem,"from");}
+this._oCurItem=null;this._nDisplayedItems=0;this._sCurQuery=null;this._toggleContainer(false);};YAHOO.widget.AutoComplete.prototype._populateList=function(sQuery,aResults,oSelf){if(aResults===null){oSelf.dataErrorEvent.fire(oSelf,sQuery);}
+if(!oSelf._bFocused||!aResults){return;}
+var isOpera=(navigator.userAgent.toLowerCase().indexOf("opera")!=-1);var contentStyle=oSelf._oContainer._oContent.style;contentStyle.width=(!isOpera)?null:"";contentStyle.height=(!isOpera)?null:"";var sCurQuery=decodeURIComponent(sQuery);oSelf._sCurQuery=sCurQuery;oSelf._bItemSelected=false;if(oSelf._maxResultsDisplayed!=oSelf.maxResultsDisplayed){oSelf._initList();}
+var nItems=Math.min(aResults.length,oSelf.maxResultsDisplayed);oSelf._nDisplayedItems=nItems;if(nItems>0){oSelf._initContainerHelpers();var aItems=oSelf._aListItems;for(var i=nItems-1;i>=0;i--){var oItemi=aItems[i];var oResultItemi=aResults[i];oItemi.innerHTML=oSelf.formatResult(oResultItemi,sCurQuery);oItemi.style.display="list-item";oItemi._sResultKey=oResultItemi[0];oItemi._oResultData=oResultItemi;}
+for(var j=aItems.length-1;j>=nItems;j--){var oItemj=aItems[j];oItemj.innerHTML=null;oItemj.style.display="none";oItemj._sResultKey=null;oItemj._oResultData=null;}
+if(oSelf.autoHighlight){var oFirstItem=aItems[0];oSelf._toggleHighlight(oFirstItem,"to");oSelf.itemArrowToEvent.fire(oSelf,oFirstItem);oSelf._typeAhead(oFirstItem,sQuery);}
+else{oSelf._oCurItem=null;}
+oSelf._toggleContainer(true);}
+else{oSelf._clearList();}
+oSelf.dataReturnEvent.fire(oSelf,sQuery,aResults);};YAHOO.widget.AutoComplete.prototype._clearSelection=function(){var sValue=this._oTextbox.value;var sChar=(this.delimChar)?this.delimChar[0]:null;var nIndex=(sChar)?sValue.lastIndexOf(sChar,sValue.length-2):-1;if(nIndex>-1){this._oTextbox.value=sValue.substring(0,nIndex);}
+else{this._oTextbox.value="";}
+this._sSavedQuery=this._oTextbox.value;this.selectionEnforceEvent.fire(this);};YAHOO.widget.AutoComplete.prototype._textMatchesOption=function(){var foundMatch=false;for(var i=this._nDisplayedItems-1;i>=0;i--){var oItem=this._aListItems[i];var sMatch=oItem._sResultKey.toLowerCase();if(sMatch==this._sCurQuery.toLowerCase()){foundMatch=true;break;}}
+return(foundMatch);};YAHOO.widget.AutoComplete.prototype._typeAhead=function(oItem,sQuery){if(!this.typeAhead){return;}
+var oTextbox=this._oTextbox;var sValue=this._oTextbox.value;if(!oTextbox.setSelectionRange&&!oTextbox.createTextRange){return;}
+var nStart=sValue.length;this._updateValue(oItem);var nEnd=oTextbox.value.length;this._selectText(oTextbox,nStart,nEnd);var sPrefill=oTextbox.value.substr(nStart,nEnd);this.typeAheadEvent.fire(this,sQuery,sPrefill);};YAHOO.widget.AutoComplete.prototype._selectText=function(oTextbox,nStart,nEnd){if(oTextbox.setSelectionRange){oTextbox.setSelectionRange(nStart,nEnd);}
+else if(oTextbox.createTextRange){var oTextRange=oTextbox.createTextRange();oTextRange.moveStart("character",nStart);oTextRange.moveEnd("character",nEnd-oTextbox.value.length);oTextRange.select();}
+else{oTextbox.select();}};YAHOO.widget.AutoComplete.prototype._toggleContainerHelpers=function(bShow){var bFireEvent=false;var width=this._oContainer._oContent.offsetWidth+"px";var height=this._oContainer._oContent.offsetHeight+"px";if(this.useIFrame&&this._oContainer._oIFrame){bFireEvent=true;if(this.alwaysShowContainer||bShow){this._oContainer._oIFrame.style.width=width;this._oContainer._oIFrame.style.height=height;}
+else{this._oContainer._oIFrame.style.width=0;this._oContainer._oIFrame.style.height=0;}}
+if(this.useShadow&&this._oContainer._oShadow){bFireEvent=true;if(this.alwaysShowContainer||bShow){this._oContainer._oShadow.style.width=width;this._oContainer._oShadow.style.height=height;}
+else{this._oContainer._oShadow.style.width=0;this._oContainer._oShadow.style.height=0;}}};YAHOO.widget.AutoComplete.prototype._toggleContainer=function(bShow){if(this.alwaysShowContainer){if(bShow){this.containerExpandEvent.fire(this);}
+else{this.containerCollapseEvent.fire(this);}
+this._bContainerOpen=bShow;return;}
+var oContainer=this._oContainer;if(!bShow&&!this._bContainerOpen){oContainer._oContent.style.display="none";return;}
+var oAnim=this._oAnim;if(oAnim&&oAnim.getEl()&&(this.animHoriz||this.animVert)){if(!bShow){this._toggleContainerHelpers(bShow);}
+if(oAnim.isAnimated()){oAnim.stop();}
+var oClone=oContainer._oContent.cloneNode(true);oContainer.appendChild(oClone);oClone.style.top="-9000px";oClone.style.display="block";var wExp=oClone.offsetWidth;var hExp=oClone.offsetHeight;var wColl=(this.animHoriz)?0:wExp;var hColl=(this.animVert)?0:hExp;oAnim.attributes=(bShow)?{width:{to:wExp},height:{to:hExp}}:{width:{to:wColl},height:{to:hColl}};if(bShow&&!this._bContainerOpen){oContainer._oContent.style.width=wColl+"px";oContainer._oContent.style.height=hColl+"px";}
+else{oContainer._oContent.style.width=wExp+"px";oContainer._oContent.style.height=hExp+"px";}
+oContainer.removeChild(oClone);oClone=null;var oSelf=this;var onAnimComplete=function(){oAnim.onComplete.unsubscribeAll();if(bShow){oSelf.containerExpandEvent.fire(oSelf);}
+else{oContainer._oContent.style.display="none";oSelf.containerCollapseEvent.fire(oSelf);}
+oSelf._toggleContainerHelpers(bShow);};oContainer._oContent.style.display="block";oAnim.onComplete.subscribe(onAnimComplete);oAnim.animate();this._bContainerOpen=bShow;}
+else{if(bShow){oContainer._oContent.style.display="block";this.containerExpandEvent.fire(this);}
+else{oContainer._oContent.style.display="none";this.containerCollapseEvent.fire(this);}
+this._toggleContainerHelpers(bShow);this._bContainerOpen=bShow;}};YAHOO.widget.AutoComplete.prototype._toggleHighlight=function(oNewItem,sType){var sHighlight=this.highlightClassName;if(this._oCurItem){YAHOO.util.Dom.removeClass(this._oCurItem,sHighlight);}
+if((sType=="to")&&sHighlight){YAHOO.util.Dom.addClass(oNewItem,sHighlight);this._oCurItem=oNewItem;}};YAHOO.widget.AutoComplete.prototype._togglePrehighlight=function(oNewItem,sType){if(oNewItem==this._oCurItem){return;}
+var sPrehighlight=this.prehighlightClassName;if((sType=="mouseover")&&sPrehighlight){YAHOO.util.Dom.addClass(oNewItem,sPrehighlight);}
+else{YAHOO.util.Dom.removeClass(oNewItem,sPrehighlight);}};YAHOO.widget.AutoComplete.prototype._updateValue=function(oItem){var oTextbox=this._oTextbox;var sDelimChar=(this.delimChar)?this.delimChar[0]:null;var sSavedQuery=this._sSavedQuery;var sResultKey=oItem._sResultKey;oTextbox.focus();oTextbox.value="";if(sDelimChar){if(sSavedQuery){oTextbox.value=sSavedQuery;}
+oTextbox.value+=sResultKey+sDelimChar;if(sDelimChar!=" "){oTextbox.value+=" ";}}
+else{oTextbox.value=sResultKey;}
+if(oTextbox.type=="textarea"){oTextbox.scrollTop=oTextbox.scrollHeight;}
+var end=oTextbox.value.length;this._selectText(oTextbox,end,end);this._oCurItem=oItem;};YAHOO.widget.AutoComplete.prototype._selectItem=function(oItem){this._bItemSelected=true;this._updateValue(oItem);this.itemSelectEvent.fire(this,oItem,oItem._oResultData);this._clearList();};YAHOO.widget.AutoComplete.prototype._jumpSelection=function(){if(!this.typeAhead){return;}
+else{this._clearList();}};YAHOO.widget.AutoComplete.prototype._moveSelection=function(nKeyCode){if(this._bContainerOpen){var oCurItem=this._oCurItem;var nCurItemIndex=-1;if(oCurItem){nCurItemIndex=oCurItem._nItemIndex;}
+var nNewItemIndex=(nKeyCode==40)?(nCurItemIndex+1):(nCurItemIndex-1);if(nNewItemIndex<-2||nNewItemIndex>=this._nDisplayedItems){return;}
+if(oCurItem){this._toggleHighlight(oCurItem,"from");this.itemArrowFromEvent.fire(this,oCurItem);}
+if(nNewItemIndex==-1){if(this.delimChar&&this._sSavedQuery){if(!this._textMatchesOption()){this._oTextbox.value=this._sSavedQuery;}
+else{this._oTextbox.value=this._sSavedQuery+this._sCurQuery;}}
+else{this._oTextbox.value=this._sCurQuery;}
+this._oCurItem=null;return;}
+if(nNewItemIndex==-2){this._clearList();return;}
+var oNewItem=this._aListItems[nNewItemIndex];if((YAHOO.util.Dom.getStyle(this._oContainer._oContent,"overflow")=="auto")&&(nNewItemIndex>-1)&&(nNewItemIndex<this._nDisplayedItems)){if(nKeyCode==40){if((oNewItem.offsetTop+oNewItem.offsetHeight)>(this._oContainer._oContent.scrollTop+this._oContainer._oContent.offsetHeight)){this._oContainer._oContent.scrollTop=(oNewItem.offsetTop+oNewItem.offsetHeight)-this._oContainer._oContent.offsetHeight;}
+else if((oNewItem.offsetTop+oNewItem.offsetHeight)<this._oContainer._oContent.scrollTop){this._oContainer._oContent.scrollTop=oNewItem.offsetTop;}}
+else{if(oNewItem.offsetTop<this._oContainer._oContent.scrollTop){this._oContainer._oContent.scrollTop=oNewItem.offsetTop;}
+else if(oNewItem.offsetTop>(this._oContainer._oContent.scrollTop+this._oContainer._oContent.offsetHeight)){this._oContainer._oContent.scrollTop=(oNewItem.offsetTop+oNewItem.offsetHeight)-this._oContainer._oContent.offsetHeight;}}}
+this._toggleHighlight(oNewItem,"to");this.itemArrowToEvent.fire(this,oNewItem);if(this.typeAhead){this._updateValue(oNewItem);}}};YAHOO.widget.DataSource=function(){};YAHOO.widget.DataSource.prototype.ERROR_DATANULL="Response data was null";YAHOO.widget.DataSource.prototype.ERROR_DATAPARSE="Response data could not be parsed";YAHOO.widget.DataSource.prototype.maxCacheEntries=15;YAHOO.widget.DataSource.prototype.queryMatchContains=false;YAHOO.widget.DataSource.prototype.queryMatchSubset=false;YAHOO.widget.DataSource.prototype.queryMatchCase=false;YAHOO.widget.DataSource.prototype.getName=function(){return this._sName;};YAHOO.widget.DataSource.prototype.toString=function(){return"DataSource "+this._sName;};YAHOO.widget.DataSource.prototype.getResults=function(oCallbackFn,sQuery,oParent){var aResults=this._doQueryCache(oCallbackFn,sQuery,oParent);if(aResults.length===0){this.queryEvent.fire(this,oParent,sQuery);this.doQuery(oCallbackFn,sQuery,oParent);}};YAHOO.widget.DataSource!
.prototype.doQuery=function(oCallbackFn,sQuery,oParent){};YAHOO.widget.DataSource.prototype.flushCache=function(){if(this._aCache){this._aCache=[];}
+if(this._aCacheHelper){this._aCacheHelper=[];}
+this.cacheFlushEvent.fire(this);};YAHOO.widget.DataSource.prototype.queryEvent=null;YAHOO.widget.DataSource.prototype.cacheQueryEvent=null;YAHOO.widget.DataSource.prototype.getResultsEvent=null;YAHOO.widget.DataSource.prototype.getCachedResultsEvent=null;YAHOO.widget.DataSource.prototype.dataErrorEvent=null;YAHOO.widget.DataSource.prototype.cacheFlushEvent=null;YAHOO.widget.DataSource._nIndex=0;YAHOO.widget.DataSource.prototype._sName=null;YAHOO.widget.DataSource.prototype._aCache=null;YAHOO.widget.DataSource.prototype._init=function(){var maxCacheEntries=this.maxCacheEntries;if(isNaN(maxCacheEntries)||(maxCacheEntries<0)){maxCacheEntries=0;}
+if(maxCacheEntries>0&&!this._aCache){this._aCache=[];}
+this._sName="instance"+YAHOO.widget.DataSource._nIndex;YAHOO.widget.DataSource._nIndex++;this.queryEvent=new YAHOO.util.CustomEvent("query",this);this.cacheQueryEvent=new YAHOO.util.CustomEvent("cacheQuery",this);this.getResultsEvent=new YAHOO.util.CustomEvent("getResults",this);this.getCachedResultsEvent=new YAHOO.util.CustomEvent("getCachedResults",this);this.dataErrorEvent=new YAHOO.util.CustomEvent("dataError",this);this.cacheFlushEvent=new YAHOO.util.CustomEvent("cacheFlush",this);};YAHOO.widget.DataSource.prototype._addCacheElem=function(resultObj){var aCache=this._aCache;if(!aCache||!resultObj||!resultObj.query||!resultObj.results){return;}
+if(aCache.length>=this.maxCacheEntries){aCache.shift();}
+aCache.push(resultObj);};YAHOO.widget.DataSource.prototype._doQueryCache=function(oCallbackFn,sQuery,oParent){var aResults=[];var bMatchFound=false;var aCache=this._aCache;var nCacheLength=(aCache)?aCache.length:0;var bMatchContains=this.queryMatchContains;if((this.maxCacheEntries>0)&&aCache&&(nCacheLength>0)){this.cacheQueryEvent.fire(this,oParent,sQuery);if(!this.queryMatchCase){var sOrigQuery=sQuery;sQuery=sQuery.toLowerCase();}
+for(var i=nCacheLength-1;i>=0;i--){var resultObj=aCache[i];var aAllResultItems=resultObj.results;var matchKey=(!this.queryMatchCase)?encodeURIComponent(resultObj.query.toLowerCase()):encodeURIComponent(resultObj.query);if(matchKey==sQuery){bMatchFound=true;aResults=aAllResultItems;if(i!=nCacheLength-1){aCache.splice(i,1);this._addCacheElem(resultObj);}
+break;}
+else if(this.queryMatchSubset){for(var j=sQuery.length-1;j>=0;j--){var subQuery=sQuery.substr(0,j);if(matchKey==subQuery){bMatchFound=true;for(var k=aAllResultItems.length-1;k>=0;k--){var aRecord=aAllResultItems[k];var sKeyIndex=(this.queryMatchCase)?encodeURIComponent(aRecord[0]).indexOf(sQuery):encodeURIComponent(aRecord[0]).toLowerCase().indexOf(sQuery);if((!bMatchContains&&(sKeyIndex===0))||(bMatchContains&&(sKeyIndex>-1))){aResults.unshift(aRecord);}}
+resultObj={};resultObj.query=sQuery;resultObj.results=aResults;this._addCacheElem(resultObj);break;}}
+if(bMatchFound){break;}}}
+if(bMatchFound){this.getCachedResultsEvent.fire(this,oParent,sOrigQuery,aResults);oCallbackFn(sOrigQuery,aResults,oParent);}}
+return aResults;};YAHOO.widget.DS_XHR=function(sScriptURI,aSchema,oConfigs){if(typeof oConfigs=="object"){for(var sConfig in oConfigs){this[sConfig]=oConfigs[sConfig];}}
+if(!aSchema||(aSchema.constructor!=Array)){return;}
+else{this.schema=aSchema;}
+this.scriptURI=sScriptURI;this._init();};YAHOO.widget.DS_XHR.prototype=new YAHOO.widget.DataSource();YAHOO.widget.DS_XHR.prototype.TYPE_JSON=0;YAHOO.widget.DS_XHR.prototype.TYPE_XML=1;YAHOO.widget.DS_XHR.prototype.TYPE_FLAT=2;YAHOO.widget.DS_XHR.prototype.ERROR_DATAXHR="XHR response failed";YAHOO.widget.DS_XHR.prototype.connTimeout=0;YAHOO.widget.DS_XHR.prototype.scriptURI=null;YAHOO.widget.DS_XHR.prototype.scriptQueryParam="query";YAHOO.widget.DS_XHR.prototype.scriptQueryAppend="";YAHOO.widget.DS_XHR.prototype.responseType=YAHOO.widget.DS_XHR.prototype.TYPE_JSON;YAHOO.widget.DS_XHR.prototype.responseStripAfter="\n<!--";YAHOO.widget.DS_XHR.prototype.doQuery=function(oCallbackFn,sQuery,oParent){var isXML=(this.responseType==this.TYPE_XML);var sUri=this.scriptURI+"?"+this.scriptQueryParam+"="+sQuery;if(this.scriptQueryAppend.length>0){sUri+="&"+this.scriptQueryAppend;}
+var oResponse=null;var oSelf=this;var responseSuccess=function(oResp){if(!oSelf._oConn||(oResp.tId!=oSelf._oConn.tId)){oSelf.dataErrorEvent.fire(oSelf,oParent,sQuery,oSelf.ERROR_DATANULL);return;}
+for(var foo in oResp){}
+if(!isXML){oResp=oResp.responseText;}
+else{oResp=oResp.responseXML;}
+if(oResp===null){oSelf.dataErrorEvent.fire(oSelf,oParent,sQuery,oSelf.ERROR_DATANULL);return;}
+var aResults=oSelf.parseResponse(sQuery,oResp,oParent);var resultObj={};resultObj.query=decodeURIComponent(sQuery);resultObj.results=aResults;if(aResults===null){oSelf.dataErrorEvent.fire(oSelf,oParent,sQuery,oSelf.ERROR_DATAPARSE);return;}
+else{oSelf.getResultsEvent.fire(oSelf,oParent,sQuery,aResults);oSelf._addCacheElem(resultObj);oCallbackFn(sQuery,aResults,oParent);}};var responseFailure=function(oResp){oSelf.dataErrorEvent.fire(oSelf,oParent,sQuery,oSelf.ERROR_DATAXHR);return;};var oCallback={success:responseSuccess,failure:responseFailure};if(!isNaN(this.connTimeout)&&this.connTimeout>0){oCallback.timeout=this.connTimeout;}
+if(this._oConn){YAHOO.util.Connect.abort(this._oConn);}
+oSelf._oConn=YAHOO.util.Connect.asyncRequest("GET",sUri,oCallback,null);};YAHOO.widget.DS_XHR.prototype.parseResponse=function(sQuery,oResponse,oParent){var aSchema=this.schema;var aResults=[];var bError=false;var nEnd=((this.responseStripAfter!=="")&&(oResponse.indexOf))?oResponse.indexOf(this.responseStripAfter):-1;if(nEnd!=-1){oResponse=oResponse.substring(0,nEnd);}
+switch(this.responseType){case this.TYPE_JSON:var jsonList;if(window.JSON&&(navigator.userAgent.toLowerCase().indexOf('khtml')==-1)){var jsonObjParsed=JSON.parse(oResponse);if(!jsonObjParsed){bError=true;break;}
+else{jsonList=eval("jsonObjParsed."+aSchema[0]);}}
+else{try{while(oResponse.substring(0,1)==" "){oResponse=oResponse.substring(1,oResponse.length);}
+if(oResponse.indexOf("{")<0){bError=true;break;}
+if(oResponse.indexOf("{}")===0){break;}
+var jsonObjRaw=eval("("+oResponse+")");if(!jsonObjRaw){bError=true;break;}
+jsonList=eval("(jsonObjRaw."+aSchema[0]+")");}
+catch(e){bError=true;break;}}
+if(!jsonList){bError=true;break;}
+for(var i=jsonList.length-1;i>=0;i--){var aResultItem=[];var jsonResult=jsonList[i];for(var j=aSchema.length-1;j>=1;j--){var dataFieldValue=jsonResult[aSchema[j]];if(!dataFieldValue){dataFieldValue="";}
+aResultItem.unshift(dataFieldValue);}
+aResults.unshift(aResultItem);}
+break;case this.TYPE_XML:var xmlList=oResponse.getElementsByTagName(aSchema[0]);if(!xmlList){bError=true;break;}
+for(var k=xmlList.length-1;k>=0;k--){var result=xmlList.item(k);var aFieldSet=[];for(var m=aSchema.length-1;m>=1;m--){var sValue=null;var xmlAttr=result.attributes.getNamedItem(aSchema[m]);if(xmlAttr){sValue=xmlAttr.value;}
+else{var xmlNode=result.getElementsByTagName(aSchema[m]);if(xmlNode&&xmlNode.item(0)&&xmlNode.item(0).firstChild){sValue=xmlNode.item(0).firstChild.nodeValue;}
+else{sValue="";}}
+aFieldSet.unshift(sValue);}
+aResults.unshift(aFieldSet);}
+break;case this.TYPE_FLAT:if(oResponse.length>0){var newLength=oResponse.length-aSchema[0].length;if(oResponse.substr(newLength)==aSchema[0]){oResponse=oResponse.substr(0,newLength);}
+var aRecords=oResponse.split(aSchema[0]);for(var n=aRecords.length-1;n>=0;n--){aResults[n]=aRecords[n].split(aSchema[1]);}}
+break;default:break;}
+sQuery=null;oResponse=null;oParent=null;if(bError){return null;}
+else{return aResults;}};YAHOO.widget.DS_XHR.prototype._oConn=null;YAHOO.widget.DS_JSFunction=function(oFunction,oConfigs){if(typeof oConfigs=="object"){for(var sConfig in oConfigs){this[sConfig]=oConfigs[sConfig];}}
+if(!oFunction||(oFunction.constructor!=Function)){return;}
+else{this.dataFunction=oFunction;this._init();}};YAHOO.widget.DS_JSFunction.prototype=new YAHOO.widget.DataSource();YAHOO.widget.DS_JSFunction.prototype.dataFunction=null;YAHOO.widget.DS_JSFunction.prototype.doQuery=function(oCallbackFn,sQuery,oParent){var oFunction=this.dataFunction;var aResults=[];aResults=oFunction(sQuery);if(aResults===null){this.dataErrorEvent.fire(this,oParent,sQuery,this.ERROR_DATANULL);return;}
+var resultObj={};resultObj.query=decodeURIComponent(sQuery);resultObj.results=aResults;this._addCacheElem(resultObj);this.getResultsEvent.fire(this,oParent,sQuery,aResults);oCallbackFn(sQuery,aResults,oParent);return;};YAHOO.widget.DS_JSArray=function(aData,oConfigs){if(typeof oConfigs=="object"){for(var sConfig in oConfigs){this[sConfig]=oConfigs[sConfig];}}
+if(!aData||(aData.constructor!=Array)){return;}
+else{this.data=aData;this._init();}};YAHOO.widget.DS_JSArray.prototype=new YAHOO.widget.DataSource();YAHOO.widget.DS_JSArray.prototype.data=null;YAHOO.widget.DS_JSArray.prototype.doQuery=function(oCallbackFn,sQuery,oParent){var aData=this.data;var aResults=[];var bMatchFound=false;var bMatchContains=this.queryMatchContains;if(!this.queryMatchCase){sQuery=sQuery.toLowerCase();}
+for(var i=aData.length-1;i>=0;i--){var aDataset=[];if(typeof aData[i]=="string"){aDataset[0]=aData[i];}
+else{aDataset=aData[i];}
+var sKeyIndex=(this.queryMatchCase)?encodeURIComponent(aDataset[0]).indexOf(sQuery):encodeURIComponent(aDataset[0]).toLowerCase().indexOf(sQuery);if((!bMatchContains&&(sKeyIndex===0))||(bMatchContains&&(sKeyIndex>-1))){aResults.unshift(aDataset);}}
+this.getResultsEvent.fire(this,oParent,sQuery,aResults);oCallbackFn(sQuery,aResults,oParent);};
Added: branches/tomek/portal-dnd/dndRenderer.war/js/autocomplete/autocomplete.js
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/autocomplete/autocomplete.js 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/autocomplete/autocomplete.js 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,2752 @@
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.com/yui/license.txt
+version: 0.11.0
+*/
+
+/****************************************************************************/
+/****************************************************************************/
+/****************************************************************************/
+
+/**
+ * Class providing the customizable functionality of a plug-and-play DHTML
+ * auto complete widget. Some key features:
+ * <ul>
+ * <li>Navigate with up/down arrow keys and/or mouse to pick a selection</li>
+ * <li>The drop down container can "roll down" or "fly out" via configurable
+ * animation</li>
+ * <li>UI look-and-feel customizable through CSS, including container
+ * attributes, borders, position, fonts, etc</li>
+ * </ul>
+ *
+ * requires YAHOO.util.Dom Dom utility
+ * requires YAHOO.util.Event Event utility
+ * requires YAHOO.widget.DataSource Data source class
+ * see YAHOO.util.Animation Animation utility
+ * see JSON JSON library
+ *
+ * @constructor
+ * @param {element | string} inputEl DOM element reference or string ID of the auto complete input field
+ * @param {element | string} containerEl DOM element reference or string ID of the auto complete <div>
+ * container
+ * @param {object} oDataSource Instance of YAHOO.widget.DataSource for query/results
+ * @param {object} oConfigs Optional object literal of config params
+ */
+YAHOO.widget.AutoComplete = function(inputEl,containerEl,oDataSource,oConfigs) {
+ if(inputEl && containerEl && oDataSource) {
+ // Validate data source
+ if (oDataSource && (oDataSource instanceof YAHOO.widget.DataSource)) {
+ this.dataSource = oDataSource;
+ }
+ else {
+ return;
+ }
+
+ // Validate input element
+ if(YAHOO.util.Dom.inDocument(inputEl)) {
+ if(typeof inputEl == "string") {
+ this._sName = "instance" + YAHOO.widget.AutoComplete._nIndex + " " + inputEl;
+ this._oTextbox = document.getElementById(inputEl);
+ }
+ else {
+ this._sName = (inputEl.id) ?
+ "instance" + YAHOO.widget.AutoComplete._nIndex + " " + inputEl.id:
+ "instance" + YAHOO.widget.AutoComplete._nIndex;
+ this._oTextbox = inputEl;
+ }
+ }
+ else {
+ return;
+ }
+
+ // Validate container element
+ if(YAHOO.util.Dom.inDocument(containerEl)) {
+ if(typeof containerEl == "string") {
+ this._oContainer = document.getElementById(containerEl);
+ }
+ else {
+ this._oContainer = containerEl;
+ }
+ if(this._oContainer.style.display == "none") {
+ }
+ }
+ else {
+ return;
+ }
+
+ // Set any config params passed in to override defaults
+ if (typeof oConfigs == "object") {
+ for(var sConfig in oConfigs) {
+ if (sConfig) {
+ this[sConfig] = oConfigs[sConfig];
+ }
+ }
+ }
+
+ // Initialization sequence
+ this._initContainer();
+ this._initProps();
+ this._initList();
+ this._initContainerHelpers();
+
+ // Set up events
+ var oSelf = this;
+ var oTextbox = this._oTextbox;
+ // Events are actually for the content module within the container
+ var oContent = this._oContainer._oContent;
+
+ // Dom events
+ YAHOO.util.Event.addListener(oTextbox,"keyup",oSelf._onTextboxKeyUp,oSelf);
+ YAHOO.util.Event.addListener(oTextbox,"keydown",oSelf._onTextboxKeyDown,oSelf);
+ YAHOO.util.Event.addListener(oTextbox,"keypress",oSelf._onTextboxKeyPress,oSelf);
+ YAHOO.util.Event.addListener(oTextbox,"focus",oSelf._onTextboxFocus,oSelf);
+ YAHOO.util.Event.addListener(oTextbox,"blur",oSelf._onTextboxBlur,oSelf);
+ YAHOO.util.Event.addListener(oContent,"mouseover",oSelf._onContainerMouseover,oSelf);
+ YAHOO.util.Event.addListener(oContent,"mouseout",oSelf._onContainerMouseout,oSelf);
+ YAHOO.util.Event.addListener(oContent,"scroll",oSelf._onContainerScroll,oSelf);
+ YAHOO.util.Event.addListener(oContent,"resize",oSelf._onContainerResize,oSelf);
+ if(oTextbox.form) {
+ YAHOO.util.Event.addListener(oTextbox.form,"submit",oSelf._onFormSubmit,oSelf);
+ }
+
+ // Custom events
+ this.textboxFocusEvent = new YAHOO.util.CustomEvent("textboxFocus", this);
+ this.textboxKeyEvent = new YAHOO.util.CustomEvent("textboxKey", this);
+ this.dataRequestEvent = new YAHOO.util.CustomEvent("dataRequest", this);
+ this.dataReturnEvent = new YAHOO.util.CustomEvent("dataReturn", this);
+ this.dataErrorEvent = new YAHOO.util.CustomEvent("dataError", this);
+ this.containerExpandEvent = new YAHOO.util.CustomEvent("containerExpand", this);
+ this.typeAheadEvent = new YAHOO.util.CustomEvent("typeAhead", this);
+ this.itemMouseOverEvent = new YAHOO.util.CustomEvent("itemMouseOver", this);
+ this.itemMouseOutEvent = new YAHOO.util.CustomEvent("itemMouseOut", this);
+ this.itemArrowToEvent = new YAHOO.util.CustomEvent("itemArrowTo", this);
+ this.itemArrowFromEvent = new YAHOO.util.CustomEvent("itemArrowFrom", this);
+ this.itemSelectEvent = new YAHOO.util.CustomEvent("itemSelect", this);
+ this.unmatchedItemSelectEvent = new YAHOO.util.CustomEvent("unmatchedItemSelect", this);
+ this.selectionEnforceEvent = new YAHOO.util.CustomEvent("selectionEnforce", this);
+ this.containerCollapseEvent = new YAHOO.util.CustomEvent("containerCollapse", this);
+ this.textboxBlurEvent = new YAHOO.util.CustomEvent("textboxBlur", this);
+
+ // Finish up
+ oTextbox.setAttribute("autocomplete","off");
+ YAHOO.widget.AutoComplete._nIndex++;
+ }
+ // Required arguments were not found
+ else {
+ }
+};
+
+/***************************************************************************
+ * Public member variables
+ ***************************************************************************/
+/**
+ * The data source object that encapsulates the data used for auto completion.
+ * This object should be an inherited object from YAHOO.widget.DataSource.
+ *
+ * @type object
+ */
+YAHOO.widget.AutoComplete.prototype.dataSource = null;
+
+/**
+ * Number of characters that must be entered before querying for results.
+ * Default: 1.
+ *
+ * @type number
+ */
+YAHOO.widget.AutoComplete.prototype.minQueryLength = 1;
+
+/**
+ * Maximum number of results to display in auto complete container. Default: 10.
+ *
+ * @type number
+ */
+YAHOO.widget.AutoComplete.prototype.maxResultsDisplayed = 10;
+
+/**
+ * Number of seconds to delay before submitting a query request. If a query
+ * request is received before a previous one has completed its delay, the
+ * previous request is cancelled and the new request is set to the delay.
+ * Default: 0.5.
+ *
+ * @type number
+ */
+YAHOO.widget.AutoComplete.prototype.queryDelay = 0.5;
+
+/**
+ * Class name of a highlighted item within the auto complete container.
+ * Default: "yui-ac-highlight".
+ *
+ * @type string
+ */
+YAHOO.widget.AutoComplete.prototype.highlightClassName = "yui-ac-highlight";
+
+/**
+ * Class name of a pre-highlighted item within the auto complete container.
+ * Default: null.
+ *
+ * @type string
+ */
+YAHOO.widget.AutoComplete.prototype.prehighlightClassName = null;
+
+/**
+ * Query delimiter. A single character separator for multiple delimited
+ * selections. Multiple delimiter characteres may be defined as an array of
+ * strings. A null value or empty string indicates that query results cannot
+ * be delimited. This feature is not recommended if you need forceSelection to
+ * be true. Default: null.
+ *
+ * @type string or array
+ */
+YAHOO.widget.AutoComplete.prototype.delimChar = null;
+
+/**
+ * Whether or not the first item in the auto complete container should be
+ * automatically highlighted on expand. Default: true.
+ *
+ * @type boolean
+ */
+YAHOO.widget.AutoComplete.prototype.autoHighlight = true;
+
+/**
+ * Whether or not the auto complete input field should be automatically updated
+ * with the first query result as the user types, auto-selecting the substring
+ * that the user has not typed. Default: false.
+ *
+ * @type boolean
+ */
+YAHOO.widget.AutoComplete.prototype.typeAhead = false;
+
+/**
+ * Whether or not to animate the expansion/collapse of the auto complete
+ * container in the horizontal direction. Default: false.
+ *
+ * @type boolean
+ */
+YAHOO.widget.AutoComplete.prototype.animHoriz = false;
+
+/**
+ * Whether or not to animate the expansion/collapse of the auto complete
+ * container in the vertical direction. Default: true.
+ *
+ * @type boolean
+ */
+YAHOO.widget.AutoComplete.prototype.animVert = true;
+
+/**
+ * Speed of container expand/collapse animation, in seconds. Default: 0.3.
+ *
+ * @type number
+ */
+YAHOO.widget.AutoComplete.prototype.animSpeed = 0.3;
+
+/**
+ * Whether or not to force the user's selection to match one of the query
+ * results. Enabling this feature essentially transforms the auto complete form
+ * input field into a <select> field. This feature is not recommended
+ * with delimiter character(s) defined. Default: false.
+ *
+ * @type boolean
+ */
+YAHOO.widget.AutoComplete.prototype.forceSelection = false;
+
+/**
+ * Whether or not to allow browsers to cache user-typed input in the input
+ * field. Disabling this feature will prevent the widget from setting the
+ * autocomplete="off" on the auto complete input field. When autocomplete="off"
+ * and users click the back button after form submission, user-typed input can
+ * be prefilled by the browser from its cache. This caching of user input may
+ * not be desired for sensitive data, such as credit card numbers, in which
+ * case, implementers should consider setting allowBrowserAutocomplete to false.
+ * Default: true.
+ *
+ * @type boolean
+ */
+YAHOO.widget.AutoComplete.prototype.allowBrowserAutocomplete = true;
+
+/**
+ * Whether or not the auto complete container should always be displayed.
+ * Enabling this feature prevents the toggling of the container to a collapsed
+ * state. Default: false.
+ *
+ * @type boolean
+ */
+YAHOO.widget.AutoComplete.prototype.alwaysShowContainer = false;
+
+/**
+ * Whether or not to use an iFrame to layer over Windows form elements in
+ * IE. Set to true only when the auto complete container will be on top of a
+ * <select> field in IE and thus exposed to the IE z-index bug (i.e.,
+ * 5.5 < IE < 7). Default:false.
+ *
+ * @type boolean
+ */
+YAHOO.widget.AutoComplete.prototype.useIFrame = false;
+
+/**
+ * Configurable iFrame src used when useIFrame = true. Implementations over SSL
+ * should set this parameter to an appropriate https location in order to avoid
+ * security-related browser errors. Default:"about:blank".
+ *
+ * @type boolean
+ */
+YAHOO.widget.AutoComplete.prototype.iFrameSrc = "about:blank";
+
+/**
+ * Whether or not the auto complete container should have a shadow. Default:false.
+ *
+ * @type boolean
+ */
+YAHOO.widget.AutoComplete.prototype.useShadow = false;
+
+/***************************************************************************
+ * Public methods
+ ***************************************************************************/
+ /**
+ * Public accessor to the unique name of the auto complete instance.
+ *
+ * @return {string} Unique name of the auto complete instance
+ */
+YAHOO.widget.AutoComplete.prototype.getName = function() {
+ return this._sName;
+};
+
+ /**
+ * Public accessor to the unique name of the auto complete instance.
+ *
+ * @return {string} Unique name of the auto complete instance
+ */
+YAHOO.widget.AutoComplete.prototype.toString = function() {
+ return "AutoComplete " + this._sName;
+};
+
+/**
+ * Public accessor to the internal array of DOM <li> elements that
+ * display query results within the auto complete container.
+ *
+ * @return {array} Array of <li> elements within the auto complete
+ * container
+ */
+YAHOO.widget.AutoComplete.prototype.getListItems = function() {
+ return this._aListItems;
+};
+
+/**
+ * Public accessor to the data held in an <li> element of the
+ * auto complete container.
+ *
+ * @return {object or array} Object or array of result data or null
+ */
+YAHOO.widget.AutoComplete.prototype.getListItemData = function(oListItem) {
+ if(oListItem._oResultData) {
+ return oListItem._oResultData;
+ }
+ else {
+ return false;
+ }
+};
+
+/**
+ * Sets HTML markup for the auto complete container header. This markup will be
+ * inserted within a <div> tag with a class of "ac_hd".
+ *
+ * @param {string} sHeader HTML markup for container header
+ */
+YAHOO.widget.AutoComplete.prototype.setHeader = function(sHeader) {
+ if(sHeader) {
+ if(this._oContainer._oContent._oHeader) {
+ this._oContainer._oContent._oHeader.innerHTML = sHeader;
+ this._oContainer._oContent._oHeader.style.display = "block";
+ }
+ }
+ else {
+ this._oContainer._oContent._oHeader.innerHTML = "";
+ this._oContainer._oContent._oHeader.style.display = "none";
+ }
+};
+
+/**
+ * Sets HTML markup for the auto complete container footer. This markup will be
+ * inserted within a <div> tag with a class of "ac_ft".
+ *
+ * @param {string} sFooter HTML markup for container footer
+ */
+YAHOO.widget.AutoComplete.prototype.setFooter = function(sFooter) {
+ if(sFooter) {
+ if(this._oContainer._oContent._oFooter) {
+ this._oContainer._oContent._oFooter.innerHTML = sFooter;
+ this._oContainer._oContent._oFooter.style.display = "block";
+ }
+ }
+ else {
+ this._oContainer._oContent._oFooter.innerHTML = "";
+ this._oContainer._oContent._oFooter.style.display = "none";
+ }
+};
+
+/**
+ * Sets HTML markup for the auto complete container body. This markup will be
+ * inserted within a <div> tag with a class of "ac_bd".
+ *
+ * @param {string} sHeader HTML markup for container body
+ */
+YAHOO.widget.AutoComplete.prototype.setBody = function(sBody) {
+ if(sBody) {
+ if(this._oContainer._oContent._oBody) {
+ this._oContainer._oContent._oBody.innerHTML = sBody;
+ this._oContainer._oContent._oBody.style.display = "block";
+ this._oContainer._oContent.style.display = "block";
+ }
+ }
+ else {
+ this._oContainer._oContent._oBody.innerHTML = "";
+ this._oContainer._oContent.style.display = "none";
+ }
+ this._maxResultsDisplayed = 0;
+};
+
+/**
+ * Overridable method that converts a result item object into HTML markup
+ * for display. Return data values are accessible via the oResultItem object,
+ * and the key return value will always be oResultItem[0]. Markup will be
+ * displayed within <li> element tags in the container.
+ *
+ * @param {object} oResultItem Result item object representing one query result
+ * @param {string} sQuery The current query string
+ * @return {string} HTML markup of formatted result data
+ */
+YAHOO.widget.AutoComplete.prototype.formatResult = function(oResultItem, sQuery) {
+ var sResult = oResultItem[0];
+ if(sResult) {
+ return sResult;
+ }
+ else {
+ return "";
+ }
+};
+
+/**
+ * Makes query request to the data source.
+ *
+ * @param {string} sQuery Query string.
+ */
+YAHOO.widget.AutoComplete.prototype.sendQuery = function(sQuery) {
+ if(sQuery) {
+ this._sendQuery(sQuery);
+ }
+ else {
+ return;
+ }
+};
+
+/***************************************************************************
+ * Events
+ ***************************************************************************/
+/**
+ * Fired when the auto complete text input box receives focus. Subscribers
+ * receive the following array:<br>
+ * - args[0] The auto complete object instance
+ */
+YAHOO.widget.AutoComplete.prototype.textboxFocusEvent = null;
+
+/**
+ * Fired when the auto complete text input box receives key input. Subscribers
+ * receive the following array:<br>
+ * - args[0] The auto complete object instance
+ * - args[1] The keycode number
+ */
+YAHOO.widget.AutoComplete.prototype.textboxKeyEvent = null;
+
+/**
+ * Fired when the auto complete instance makes a query to the data source.
+ * Subscribers receive the following array:<br>
+ * - args[0] The auto complete object instance
+ * - args[1] The query string
+ */
+YAHOO.widget.AutoComplete.prototype.dataRequestEvent = null;
+
+/**
+ * Fired when the auto complete instance receives query results from the data
+ * source. Subscribers receive the following array:<br>
+ * - args[0] The auto complete object instance
+ * - args[1] The query string
+ * - args[2] Results array
+ */
+YAHOO.widget.AutoComplete.prototype.dataReturnEvent = null;
+
+/**
+ * Fired when the auto complete instance does not receive query results from the
+ * data source due to an error. Subscribers receive the following array:<br>
+ * - args[0] The auto complete object instance
+ * - args[1] The query string
+ */
+YAHOO.widget.AutoComplete.prototype.dataErrorEvent = null;
+
+/**
+ * Fired when the auto complete container is expanded. If alwaysShowContainer is
+ * enabled, then containerExpandEvent will be fired when the container is
+ * populated with results. Subscribers receive the following array:<br>
+ * - args[0] The auto complete object instance
+ */
+YAHOO.widget.AutoComplete.prototype.containerExpandEvent = null;
+
+/**
+ * Fired when the auto complete textbox has been prefilled by the type-ahead
+ * feature. Subscribers receive the following array:<br>
+ * - args[0] The auto complete object instance
+ * - args[1] The query string
+ * - args[2] The prefill string
+ */
+YAHOO.widget.AutoComplete.prototype.typeAheadEvent = null;
+
+/**
+ * Fired when result item has been moused over. Subscribers receive the following
+ * array:<br>
+ * - args[0] The auto complete object instance
+ * - args[1] The <li> element item moused to
+ */
+YAHOO.widget.AutoComplete.prototype.itemMouseOverEvent = null;
+
+/**
+ * Fired when result item has been moused out. Subscribers receive the
+ * following array:<br>
+ * - args[0] The auto complete object instance
+ * - args[1] The <li> element item moused from
+ */
+YAHOO.widget.AutoComplete.prototype.itemMouseOutEvent = null;
+
+/**
+ * Fired when result item has been arrowed to. Subscribers receive the following
+ * array:<br>
+ * - args[0] The auto complete object instance
+ * - args[1] The <li> element item arrowed to
+ */
+YAHOO.widget.AutoComplete.prototype.itemArrowToEvent = null;
+
+/**
+ * Fired when result item has been arrowed away from. Subscribers receive the
+ * following array:<br>
+ * - args[0] The auto complete object instance
+ * - args[1] The <li> element item arrowed from
+ */
+YAHOO.widget.AutoComplete.prototype.itemArrowFromEvent = null;
+
+/**
+ * Fired when an item is selected via mouse click, ENTER key, or TAB key.
+ * Subscribers receive the following array:<br>
+ * - args[0] The auto complete object instance
+ * - args[1] The selected <li> element item
+ * - args[2] The data returned for the item, either as an object, or mapped from the schema into an array
+ */
+YAHOO.widget.AutoComplete.prototype.itemSelectEvent = null;
+
+/**
+ * Fired when an user selection does not match any of the displayed result items.
+ * Note that this event may not behave as expected when delimiter characters
+ * have been defined. Subscribers receive the following array:<br>
+ * - args[0] The auto complete object instance
+ * - args[1] The user selection
+ */
+YAHOO.widget.AutoComplete.prototype.unmatchedItemSelectEvent = null;
+
+/**
+ * Fired if forceSelection is enabled and the user's input has been cleared
+ * because it did not match one of the returned query results. Subscribers
+ * receive the following array:<br>
+ * - args[0] The auto complete object instance
+ */
+YAHOO.widget.AutoComplete.prototype.selectionEnforceEvent = null;
+
+/**
+ * Fired when the auto complete container is collapsed. If alwaysShowContainer is
+ * enabled, then containerCollapseEvent will be fired when the container is
+ * cleared of results. Subscribers receive the following array:<br>
+ * - args[0] The auto complete object instance
+ */
+YAHOO.widget.AutoComplete.prototype.containerCollapseEvent = null;
+
+/**
+ * Fired when the auto complete text input box loses focus. Subscribers receive
+ * an array of the following array:<br>
+ * - args[0] The auto complete object instance
+ */
+YAHOO.widget.AutoComplete.prototype.textboxBlurEvent = null;
+
+/***************************************************************************
+ * Private member variables
+ ***************************************************************************/
+/**
+ * Internal class variable to index multiple auto complete instances.
+ *
+ * @type number
+ * @private
+ */
+YAHOO.widget.AutoComplete._nIndex = 0;
+
+/**
+ * Name of auto complete instance.
+ *
+ * @type string
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._sName = null;
+
+/**
+ * Text input box DOM element.
+ *
+ * @type object
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._oTextbox = null;
+
+/**
+ * Whether or not the textbox is currently in focus. If query results come back
+ * but the user has already moved on, do not proceed with auto complete behavior.
+ *
+ * @type boolean
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._bFocused = true;
+
+/**
+ * Animation instance for container expand/collapse.
+ *
+ * @type boolean
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._oAnim = null;
+
+/**
+ * Container DOM element.
+ *
+ * @type object
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._oContainer = null;
+
+/**
+ * Whether or not the auto complete container is currently open.
+ *
+ * @type boolean
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._bContainerOpen = false;
+
+/**
+ * Whether or not the mouse is currently over the auto complete
+ * container. This is necessary in order to prevent clicks on container items
+ * from being text input box blur events.
+ *
+ * @type boolean
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._bOverContainer = false;
+
+/**
+ * Array of <li> elements references that contain query results within the
+ * auto complete container.
+ *
+ * @type array
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._aListItems = null;
+
+/**
+ * Number of <li> elements currently displayed in auto complete container.
+ *
+ * @type number
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._nDisplayedItems = 0;
+
+/**
+ * Internal count of <li> elements displayed and hidden in auto complete container.
+ *
+ * @type number
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._maxResultsDisplayed = 0;
+
+/**
+ * Current query string
+ *
+ * @type string
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._sCurQuery = null;
+
+/**
+ * Past queries this session (for saving delimited queries).
+ *
+ * @type string
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._sSavedQuery = null;
+
+/**
+ * Pointer to the currently highlighted <li> element in the container.
+ *
+ * @type object
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._oCurItem = null;
+
+/**
+ * Whether or not an item has been selected since the container was populated
+ * with results. Reset to false by _populateList, and set to true when item is
+ * selected.
+ *
+ * @type boolean
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._bItemSelected = false;
+
+/**
+ * Key code of the last key pressed in textbox.
+ *
+ * @type number
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._nKeyCode = null;
+
+/**
+ * Delay timeout ID.
+ *
+ * @type number
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._nDelayID = -1;
+
+/***************************************************************************
+ * Private methods
+ ***************************************************************************/
+/**
+ * Updates and validates latest public config properties.
+ *
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._initProps = function() {
+ // Correct any invalid values
+ var minQueryLength = this.minQueryLength;
+ if(isNaN(minQueryLength) || (minQueryLength < 1)) {
+ minQueryLength = 1;
+ }
+ var maxResultsDisplayed = this.maxResultsDisplayed;
+ if(isNaN(this.maxResultsDisplayed) || (this.maxResultsDisplayed < 1)) {
+ this.maxResultsDisplayed = 10;
+ }
+ var queryDelay = this.queryDelay;
+ if(isNaN(this.queryDelay) || (this.queryDelay < 0)) {
+ this.queryDelay = 0.5;
+ }
+ var aDelimChar = (this.delimChar) ? this.delimChar : null;
+ if(aDelimChar) {
+ if(typeof aDelimChar == "string") {
+ this.delimChar = [aDelimChar];
+ }
+ else if(aDelimChar.constructor != Array) {
+ this.delimChar = null;
+ }
+ }
+ var animSpeed = this.animSpeed;
+ if((this.animHoriz || this.animVert) && YAHOO.util.Anim) {
+ if(isNaN(animSpeed) || (animSpeed < 0)) {
+ animSpeed = 0.3;
+ }
+ if(!this._oAnim ) {
+ oAnim = new YAHOO.util.Anim(this._oContainer._oContent, {}, this.animSpeed);
+ this._oAnim = oAnim;
+ }
+ else {
+ this._oAnim.duration = animSpeed;
+ }
+ }
+ if(this.forceSelection && this.delimChar) {
+ }
+ if(this.alwaysShowContainer && (this.useShadow || this.useIFrame)) {
+ }
+
+ if(this.alwaysShowContainer) {
+ this._bContainerOpen = true;
+ }
+};
+
+/**
+ * Initializes the auto complete container helpers if they are enabled and do
+ * not exist
+ *
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._initContainerHelpers = function() {
+ if(this.useShadow && !this._oContainer._oShadow) {
+ var oShadow = document.createElement("div");
+ oShadow.className = "yui-ac-shadow";
+ this._oContainer._oShadow = this._oContainer.appendChild(oShadow);
+ }
+ if(this.useIFrame && !this._oContainer._oIFrame) {
+ var oIFrame = document.createElement("iframe");
+ oIFrame.src = this.iFrameSrc;
+ oIFrame.frameBorder = 0;
+ oIFrame.scrolling = "no";
+ oIFrame.style.position = "absolute";
+ oIFrame.style.width = "100%";
+ oIFrame.style.height = "100%";
+ this._oContainer._oIFrame = this._oContainer.appendChild(oIFrame);
+ }
+};
+
+/**
+ * Initializes the auto complete container once at object creation
+ *
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._initContainer = function() {
+ if(!this._oContainer._oContent) {
+ // The oContent div helps size the iframe and shadow properly
+ var oContent = document.createElement("div");
+ oContent.className = "yui-ac-content";
+ oContent.style.display = "none";
+ this._oContainer._oContent = this._oContainer.appendChild(oContent);
+
+ var oHeader = document.createElement("div");
+ oHeader.className = "yui-ac-hd";
+ oHeader.style.display = "none";
+ this._oContainer._oContent._oHeader = this._oContainer._oContent.appendChild(oHeader);
+
+ var oBody = document.createElement("div");
+ oBody.className = "yui-ac-bd";
+ this._oContainer._oContent._oBody = this._oContainer._oContent.appendChild(oBody);
+
+ var oFooter = document.createElement("div");
+ oFooter.className = "yui-ac-ft";
+ oFooter.style.display = "none";
+ this._oContainer._oContent._oFooter = this._oContainer._oContent.appendChild(oFooter);
+ }
+ else {
+ }
+};
+
+/**
+ * Clears out contents of container body and creates up to
+ * YAHOO.widget.AutoComplete#maxResultsDisplayed <li> elements in an
+ * <ul> element.
+ *
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._initList = function() {
+ this._aListItems = [];
+ while(this._oContainer._oContent._oBody.hasChildNodes()) {
+ var oldListItems = this.getListItems();
+ if(oldListItems) {
+ for(var oldi = oldListItems.length-1; oldi >= 0; i--) {
+ oldListItems[oldi] = null;
+ }
+ }
+ this._oContainer._oContent._oBody.innerHTML = "";
+ }
+
+ var oList = document.createElement("ul");
+ oList = this._oContainer._oContent._oBody.appendChild(oList);
+ for(var i=0; i<this.maxResultsDisplayed; i++) {
+ var oItem = document.createElement("li");
+ oItem = oList.appendChild(oItem);
+ this._aListItems[i] = oItem;
+ this._initListItem(oItem, i);
+ }
+ this._maxResultsDisplayed = this.maxResultsDisplayed;
+};
+
+/**
+ * Initializes each <li> element in the container list.
+ *
+ * @param {object} oItem The <li> DOM element
+ * @param {number} nItemIndex The index of the element
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._initListItem = function(oItem, nItemIndex) {
+ var oSelf = this;
+ oItem.style.display = "none";
+ oItem._nItemIndex = nItemIndex;
+
+ oItem.mouseover = oItem.mouseout = oItem.onclick = null;
+ YAHOO.util.Event.addListener(oItem,"mouseover",oSelf._onItemMouseover,oSelf);
+ YAHOO.util.Event.addListener(oItem,"mouseout",oSelf._onItemMouseout,oSelf);
+ YAHOO.util.Event.addListener(oItem,"click",oSelf._onItemMouseclick,oSelf);
+};
+
+/**
+ * Handles <li> element mouseover events in the container.
+ *
+ * @param {event} v The mouseover event
+ * @param {object} oSelf The auto complete instance
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._onItemMouseover = function(v,oSelf) {
+ if(oSelf.prehighlightClassName) {
+ oSelf._togglePrehighlight(this,"mouseover");
+ }
+ else {
+ oSelf._toggleHighlight(this,"to");
+ }
+
+ oSelf.itemMouseOverEvent.fire(oSelf, this);
+};
+
+/**
+ * Handles <li> element mouseout events in the container.
+ *
+ * @param {event} v The mouseout event
+ * @param {object} oSelf The auto complete instance
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._onItemMouseout = function(v,oSelf) {
+ if(oSelf.prehighlightClassName) {
+ oSelf._togglePrehighlight(this,"mouseout");
+ }
+ else {
+ oSelf._toggleHighlight(this,"from");
+ }
+
+ oSelf.itemMouseOutEvent.fire(oSelf, this);
+};
+
+/**
+ * Handles <li> element click events in the container.
+ *
+ * @param {event} v The click event
+ * @param {object} oSelf The auto complete instance
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._onItemMouseclick = function(v,oSelf) {
+ // In case item has not been moused over
+ oSelf._toggleHighlight(this,"to");
+ oSelf._selectItem(this);
+};
+
+/**
+ * Handles container mouseover events.
+ *
+ * @param {event} v The mouseover event
+ * @param {object} oSelf The auto complete instance
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._onContainerMouseover = function(v,oSelf) {
+ oSelf._bOverContainer = true;
+};
+
+/**
+ * Handles container mouseout events.
+ *
+ * @param {event} v The mouseout event
+ * @param {object} oSelf The auto complete instance
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._onContainerMouseout = function(v,oSelf) {
+ oSelf._bOverContainer = false;
+ // If container is still active
+ if(oSelf._oCurItem) {
+ oSelf._toggleHighlight(oSelf._oCurItem,"to");
+ }
+};
+
+/**
+ * Handles container scroll events.
+ *
+ * @param {event} v The scroll event
+ * @param {object} oSelf The auto complete instance
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._onContainerScroll = function(v,oSelf) {
+ oSelf._oTextbox.focus();
+};
+
+/**
+ * Handles container resize events.
+ *
+ * @param {event} v The resize event
+ * @param {object} oSelf The auto complete instance
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._onContainerResize = function(v,oSelf) {
+ oSelf._toggleContainerHelpers(oSelf._bContainerOpen);
+};
+
+/**
+ * Handles textbox keydown events of functional keys, mainly for UI behavior.
+ *
+ * @param {event} v The keydown event
+ * @param {object} oSelf The auto complete instance
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._onTextboxKeyDown = function(v,oSelf) {
+ var nKeyCode = v.keyCode;
+
+ switch (nKeyCode) {
+ case 9: // tab
+ if(oSelf.delimChar && (oSelf._nKeyCode != nKeyCode)) {
+ if(oSelf._bContainerOpen) {
+ YAHOO.util.Event.stopEvent(v);
+ }
+ }
+ // select an item or clear out
+ if(oSelf._oCurItem) {
+ oSelf._selectItem(oSelf._oCurItem);
+ }
+ else {
+ oSelf._clearList();
+ }
+ break;
+ case 13: // enter
+ if(oSelf._nKeyCode != nKeyCode) {
+ if(oSelf._bContainerOpen) {
+ YAHOO.util.Event.stopEvent(v);
+ }
+ }
+ if(oSelf._oCurItem) {
+ oSelf._selectItem(oSelf._oCurItem);
+ }
+ else {
+ oSelf._clearList();
+ }
+ break;
+ case 27: // esc
+ oSelf._clearList();
+ return;
+ case 39: // right
+ oSelf._jumpSelection();
+ break;
+ case 38: // up
+ YAHOO.util.Event.stopEvent(v);
+ oSelf._moveSelection(nKeyCode);
+ break;
+ case 40: // down
+ YAHOO.util.Event.stopEvent(v);
+ oSelf._moveSelection(nKeyCode);
+ break;
+ default:
+ break;
+ }
+};
+
+/**
+ * Handles textbox keypress events, mainly for stopEvent in Safari.
+ *
+ * @param {event} v The keyup event
+ * @param {object} oSelf The auto complete instance
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._onTextboxKeyPress = function(v,oSelf) {
+ var nKeyCode = v.keyCode;
+
+ switch (nKeyCode) {
+ case 9: // tab
+ case 13: // enter
+ if((oSelf._nKeyCode != nKeyCode)) {
+ YAHOO.util.Event.stopEvent(v);
+ }
+ break;
+ case 38: // up
+ case 40: // down
+ YAHOO.util.Event.stopEvent(v);
+ break;
+ default:
+ break;
+ }
+};
+
+/**
+ * Handles textbox keyup events that trigger queries.
+ *
+ * @param {event} v The keyup event
+ * @param {object} oSelf The auto complete instance
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._onTextboxKeyUp = function(v,oSelf) {
+ // Check to see if any of the public properties have been updated
+ oSelf._initProps();
+
+ var nKeyCode = v.keyCode;
+ oSelf._nKeyCode = nKeyCode;
+ var sChar = String.fromCharCode(nKeyCode);
+ var sText = this.value; //string in textbox
+
+ // Filter out chars that don't trigger queries
+ if (oSelf._isIgnoreKey(nKeyCode) || (sText.toLowerCase() == oSelf._sCurQuery)) {
+ return;
+ }
+ else {
+ oSelf.textboxKeyEvent.fire(oSelf, nKeyCode);
+ }
+
+ // Set timeout on the request
+ if (oSelf.queryDelay > 0) {
+ var nDelayID =
+ setTimeout(function(){oSelf._sendQuery(sText);},(oSelf.queryDelay * 1000));
+
+ if (oSelf._nDelayID != -1) {
+ clearTimeout(oSelf._nDelayID);
+ }
+
+ oSelf._nDelayID = nDelayID;
+ }
+ else {
+ // No delay so send request immediately
+ oSelf._sendQuery(sText);
+ }
+};
+
+/**
+ * Whether or not key is functional or should be ignored. Note that the right
+ * arrow key is NOT an ignored key since it triggers queries for certain intl
+ * charsets.
+ *
+ * @param {number} nKeycode Code of key pressed
+ * @return {boolean} Whether or not to be ignore key
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._isIgnoreKey = function(nKeyCode) {
+ if ((nKeyCode == 9) || (nKeyCode == 13) || // tab, enter
+ (nKeyCode == 16) || (nKeyCode == 17) || // shift, ctl
+ (nKeyCode >= 18 && nKeyCode <= 20) || // alt,pause/break,caps lock
+ (nKeyCode == 27) || // esc
+ (nKeyCode >= 33 && nKeyCode <= 35) || // page up,page down,end
+ (nKeyCode >= 36 && nKeyCode <= 38) || // home,left,up
+ (nKeyCode == 40) || // down
+ (nKeyCode >= 44 && nKeyCode <= 45)) { // print screen,insert
+ return true;
+ }
+ return false;
+};
+
+/**
+ * Handles text input box receiving focus.
+ *
+ * @param {event} v The focus event
+ * @param {object} oSelf The auto complete instance
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._onTextboxFocus = function (v,oSelf) {
+ oSelf._oTextbox.setAttribute("autocomplete","off");
+ oSelf._bFocused = true;
+ oSelf.textboxFocusEvent.fire(oSelf);
+};
+
+/**
+ * Handles text input box losing focus.
+ *
+ * @param {event} v The focus event
+ * @param {object} oSelf The auto complete instance
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._onTextboxBlur = function (v,oSelf) {
+ // Don't treat as a blur if it was a selection via mouse click
+ if(!oSelf._bOverContainer || (oSelf._nKeyCode == 9)) {
+ // Current query needs to be validated
+ if(!oSelf._bItemSelected) {
+ if(!oSelf._bContainerOpen || (oSelf._bContainerOpen && !oSelf._textMatchesOption())) {
+ if(oSelf.forceSelection) {
+ oSelf._clearSelection();
+ }
+ else {
+ oSelf.unmatchedItemSelectEvent.fire(oSelf, oSelf._sCurQuery);
+ }
+ }
+ }
+
+ if(oSelf._bContainerOpen) {
+ oSelf._clearList();
+ }
+ oSelf._bFocused = false;
+ oSelf.textboxBlurEvent.fire(oSelf);
+ }
+};
+
+/**
+ * Handles form submission event.
+ *
+ * @param {event} v The submit event
+ * @param {object} oSelf The auto complete instance
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._onFormSubmit = function(v,oSelf) {
+ if(oSelf.allowBrowserAutocomplete) {
+ oSelf._oTextbox.setAttribute("autocomplete","on");
+ }
+ else {
+ oSelf._oTextbox.setAttribute("autocomplete","off");
+ }
+};
+
+/**
+ * Makes query request to the data source.
+ *
+ * @param {string} sQuery Query string.
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._sendQuery = function(sQuery) {
+ // Delimiter has been enabled
+ var aDelimChar = (this.delimChar) ? this.delimChar : null;
+ if(aDelimChar) {
+ // Loop through all possible delimiters and find the latest one
+ // A " " may be a false positive if they are defined as delimiters AND
+ // are used to separate delimited queries
+ var nDelimIndex = -1;
+ for(var i = aDelimChar.length-1; i >= 0; i--) {
+ var nNewIndex = sQuery.lastIndexOf(aDelimChar[i]);
+ if(nNewIndex > nDelimIndex) {
+ nDelimIndex = nNewIndex;
+ }
+ }
+ // If we think the last delimiter is a space (" "), make sure it is NOT
+ // a false positive by also checking the char directly before it
+ if(aDelimChar[i] == " ") {
+ for (var j = aDelimChar.length-1; j >= 0; j--) {
+ if(sQuery[nDelimIndex - 1] == aDelimChar[j]) {
+ nDelimIndex--;
+ break;
+ }
+ }
+ }
+ // A delimiter has been found so extract the latest query
+ if (nDelimIndex > -1) {
+ var nQueryStart = nDelimIndex + 1;
+ // Trim any white space from the beginning...
+ while(sQuery.charAt(nQueryStart) == " ") {
+ nQueryStart += 1;
+ }
+ // ...and save the rest of the string for later
+ this._sSavedQuery = sQuery.substring(0,nQueryStart);
+ // Here is the query itself
+ sQuery = sQuery.substr(nQueryStart);
+ }
+ else if(sQuery.indexOf(this._sSavedQuery) < 0){
+ this._sSavedQuery = null;
+ }
+ }
+
+ // Don't search queries that are too short
+ if (sQuery.length < this.minQueryLength) {
+ if (this._nDelayID != -1) {
+ clearTimeout(this._nDelayID);
+ }
+ this._clearList();
+ return;
+ }
+
+ sQuery = encodeURIComponent(sQuery);
+ this._nDelayID = -1; // Reset timeout ID because request has been made
+ this.dataRequestEvent.fire(this, sQuery);
+ this.dataSource.getResults(this._populateList, sQuery, this);
+};
+
+/**
+ * Hides all visuals related to the array of <li> elements in the container.
+ *
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._clearList = function() {
+ this._oContainer._oContent.scrollTop = 0;
+ var aItems = this._aListItems;
+
+ if(aItems && (aItems.length > 0)) {
+ for(var i = aItems.length-1; i >= 0 ; i--) {
+ aItems[i].style.display = "none";
+ }
+ }
+
+ if (this._oCurItem) {
+ this._toggleHighlight(this._oCurItem,"from");
+ }
+
+ this._oCurItem = null;
+ this._nDisplayedItems = 0;
+ this._sCurQuery = null;
+ this._toggleContainer(false);
+};
+
+/**
+ * Populates the array of <li> elements in the container with query
+ * results. This method is passed to YAHOO.widget.DataSource#getResults as a
+ * callback function so results from the datasource are returned to the
+ * auto complete instance.
+ *
+ * @param {string} sQuery The query string
+ * @param {object} aResults An array of query result objects from the data source
+ * @param {string} oSelf The auto complete instance
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._populateList = function(sQuery, aResults, oSelf) {
+ if(aResults === null) {
+ oSelf.dataErrorEvent.fire(oSelf, sQuery);
+ }
+ if (!oSelf._bFocused || !aResults) {
+ return;
+ }
+
+ var isOpera = (navigator.userAgent.toLowerCase().indexOf("opera") != -1);
+ var contentStyle = oSelf._oContainer._oContent.style;
+ contentStyle.width = (!isOpera) ? null : "";
+ contentStyle.height = (!isOpera) ? null : "";
+
+ var sCurQuery = decodeURIComponent(sQuery);
+ oSelf._sCurQuery = sCurQuery;
+ oSelf._bItemSelected = false;
+
+ if(oSelf._maxResultsDisplayed != oSelf.maxResultsDisplayed) {
+ oSelf._initList();
+ }
+
+ var nItems = Math.min(aResults.length,oSelf.maxResultsDisplayed);
+ oSelf._nDisplayedItems = nItems;
+ if (nItems > 0) {
+ oSelf._initContainerHelpers();
+ var aItems = oSelf._aListItems;
+
+ // Fill items with data
+ for(var i = nItems-1; i >= 0; i--) {
+ var oItemi = aItems[i];
+ var oResultItemi = aResults[i];
+ oItemi.innerHTML = oSelf.formatResult(oResultItemi, sCurQuery);
+ oItemi.style.display = "list-item";
+ oItemi._sResultKey = oResultItemi[0];
+ oItemi._oResultData = oResultItemi;
+
+ }
+
+ // Empty out remaining items if any
+ for(var j = aItems.length-1; j >= nItems ; j--) {
+ var oItemj = aItems[j];
+ oItemj.innerHTML = null;
+ oItemj.style.display = "none";
+ oItemj._sResultKey = null;
+ oItemj._oResultData = null;
+ }
+
+ if(oSelf.autoHighlight) {
+ // Go to the first item
+ var oFirstItem = aItems[0];
+ oSelf._toggleHighlight(oFirstItem,"to");
+ oSelf.itemArrowToEvent.fire(oSelf, oFirstItem);
+ oSelf._typeAhead(oFirstItem,sQuery);
+ }
+ else {
+ oSelf._oCurItem = null;
+ }
+
+ // Expand the container
+ oSelf._toggleContainer(true);
+ }
+ else {
+ oSelf._clearList();
+ }
+ oSelf.dataReturnEvent.fire(oSelf, sQuery, aResults);
+};
+
+/**
+ * When YAHOO.widget.AutoComplete#bForceSelection is true and the user attempts
+ * leave the text input box without selecting an item from the query results,
+ * the user selection is cleared.
+ *
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._clearSelection = function() {
+ var sValue = this._oTextbox.value;
+ var sChar = (this.delimChar) ? this.delimChar[0] : null;
+ var nIndex = (sChar) ? sValue.lastIndexOf(sChar, sValue.length-2) : -1;
+ if(nIndex > -1) {
+ this._oTextbox.value = sValue.substring(0,nIndex);
+ }
+ else {
+ this._oTextbox.value = "";
+ }
+ this._sSavedQuery = this._oTextbox.value;
+
+ // Fire custom event
+ this.selectionEnforceEvent.fire(this);
+};
+
+/**
+ * Whether or not user-typed value in the text input box matches any of the
+ * query results.
+ *
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._textMatchesOption = function() {
+ var foundMatch = false;
+
+ for(var i = this._nDisplayedItems-1; i >= 0 ; i--) {
+ var oItem = this._aListItems[i];
+ var sMatch = oItem._sResultKey.toLowerCase();
+ if (sMatch == this._sCurQuery.toLowerCase()) {
+ foundMatch = true;
+ break;
+ }
+ }
+ return(foundMatch);
+};
+
+/**
+ * Updates in the text input box with the first query result as the user types,
+ * selecting the substring that the user has not typed.
+ *
+ * @param {object} oItem The <li> element item whose data populates the input field
+ * @param {string} sQuery Query string
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._typeAhead = function(oItem, sQuery) {
+ // Don't update if turned off
+ if (!this.typeAhead) {
+ return;
+ }
+
+ var oTextbox = this._oTextbox;
+ var sValue = this._oTextbox.value; // any saved queries plus what user has typed
+
+ // Don't update with type-ahead if text selection is not supported
+ if(!oTextbox.setSelectionRange && !oTextbox.createTextRange) {
+ return;
+ }
+
+ // Select the portion of text that the user has not typed
+ var nStart = sValue.length;
+ this._updateValue(oItem);
+ var nEnd = oTextbox.value.length;
+ this._selectText(oTextbox,nStart,nEnd);
+ var sPrefill = oTextbox.value.substr(nStart,nEnd);
+ this.typeAheadEvent.fire(this,sQuery,sPrefill);
+};
+
+/**
+ * Selects text in a text input box.
+ *
+ * @param {object} oTextbox Text input box element in which to select text
+ * @param {number} nStart Starting index of text string to select
+ * @param {number} nEnd Ending index of text selection
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._selectText = function(oTextbox, nStart, nEnd) {
+ if (oTextbox.setSelectionRange) { // For Mozilla
+ oTextbox.setSelectionRange(nStart,nEnd);
+ }
+ else if (oTextbox.createTextRange) { // For IE
+ var oTextRange = oTextbox.createTextRange();
+ oTextRange.moveStart("character", nStart);
+ oTextRange.moveEnd("character", nEnd-oTextbox.value.length);
+ oTextRange.select();
+ }
+ else {
+ oTextbox.select();
+ }
+};
+
+/**
+ * Syncs auto complete container with its helpers.
+ *
+ * @param {boolean} bShow True if container is expanded, false if collapsed
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._toggleContainerHelpers = function(bShow) {
+ var bFireEvent = false;
+ var width = this._oContainer._oContent.offsetWidth + "px";
+ var height = this._oContainer._oContent.offsetHeight + "px";
+
+ if(this.useIFrame && this._oContainer._oIFrame) {
+ bFireEvent = true;
+ if(this.alwaysShowContainer || bShow) {
+ this._oContainer._oIFrame.style.width = width;
+ this._oContainer._oIFrame.style.height = height;
+ }
+ else {
+ this._oContainer._oIFrame.style.width = 0;
+ this._oContainer._oIFrame.style.height = 0;
+ }
+ }
+ if(this.useShadow && this._oContainer._oShadow) {
+ bFireEvent = true;
+ if(this.alwaysShowContainer || bShow) {
+ this._oContainer._oShadow.style.width = width;
+ this._oContainer._oShadow.style.height = height;
+ }
+ else {
+ this._oContainer._oShadow.style.width = 0;
+ this._oContainer._oShadow.style.height = 0;
+ }
+ }
+};
+
+/**
+ * Animates expansion or collapse of the container.
+ *
+ * @param {boolean} bShow True if container should be expanded, false if
+ * container should be collapsed
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._toggleContainer = function(bShow) {
+ // Implementer has container always open so don't mess with it
+ if(this.alwaysShowContainer) {
+ // Fire these events to give implementers a hook into the container
+ // being populated and being emptied
+ if(bShow) {
+ this.containerExpandEvent.fire(this);
+ }
+ else {
+ this.containerCollapseEvent.fire(this);
+ }
+ this._bContainerOpen = bShow;
+ return;
+ }
+
+ var oContainer = this._oContainer;
+ // Container is already closed
+ if (!bShow && !this._bContainerOpen) {
+ oContainer._oContent.style.display = "none";
+ return;
+ }
+
+ // If animation is enabled...
+ var oAnim = this._oAnim;
+ if (oAnim && oAnim.getEl() && (this.animHoriz || this.animVert)) {
+ // If helpers need to be collapsed, do it right away...
+ // but if helpers need to be expanded, wait until after the container expands
+ if(!bShow) {
+ this._toggleContainerHelpers(bShow);
+ }
+
+ if(oAnim.isAnimated()) {
+ oAnim.stop();
+ }
+
+ // Clone container to grab current size offscreen
+ var oClone = oContainer._oContent.cloneNode(true);
+ oContainer.appendChild(oClone);
+ oClone.style.top = "-9000px";
+ oClone.style.display = "block";
+
+ // Current size of the container is the EXPANDED size
+ var wExp = oClone.offsetWidth;
+ var hExp = oClone.offsetHeight;
+
+ // Calculate COLLAPSED sizes based on horiz and vert anim
+ var wColl = (this.animHoriz) ? 0 : wExp;
+ var hColl = (this.animVert) ? 0 : hExp;
+
+ // Set animation sizes
+ oAnim.attributes = (bShow) ?
+ {width: { to: wExp }, height: { to: hExp }} :
+ {width: { to: wColl}, height: { to: hColl }};
+
+ // If opening anew, set to a collapsed size...
+ if(bShow && !this._bContainerOpen) {
+ oContainer._oContent.style.width = wColl+"px";
+ oContainer._oContent.style.height = hColl+"px";
+ }
+ // Else, set it to its last known size.
+ else {
+ oContainer._oContent.style.width = wExp+"px";
+ oContainer._oContent.style.height = hExp+"px";
+ }
+
+ oContainer.removeChild(oClone);
+ oClone = null;
+
+ var oSelf = this;
+ var onAnimComplete = function() {
+ // Finish the collapse
+ oAnim.onComplete.unsubscribeAll();
+
+ if(bShow) {
+ oSelf.containerExpandEvent.fire(oSelf);
+ }
+ else {
+ oContainer._oContent.style.display = "none";
+ oSelf.containerCollapseEvent.fire(oSelf);
+ }
+ oSelf._toggleContainerHelpers(bShow);
+ };
+
+ // Display container and animate it
+ oContainer._oContent.style.display = "block";
+ oAnim.onComplete.subscribe(onAnimComplete);
+ oAnim.animate();
+ this._bContainerOpen = bShow;
+ }
+ // Else don't animate, just show or hide
+ else {
+ if(bShow) {
+ oContainer._oContent.style.display = "block";
+ this.containerExpandEvent.fire(this);
+ }
+ else {
+ oContainer._oContent.style.display = "none";
+ this.containerCollapseEvent.fire(this);
+ }
+ this._toggleContainerHelpers(bShow);
+ this._bContainerOpen = bShow;
+ }
+
+};
+
+/**
+ * Toggles the highlight on or off for an item in the container, and also cleans
+ * up highlighting of any previous item.
+ *
+ * @param {object} oNewItem New The <li> element item to receive highlight
+ * behavior
+ * @param {string} sType "mouseover" will toggle highlight on, and "mouseout"
+ * will toggle highlight off.
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._toggleHighlight = function(oNewItem, sType) {
+ var sHighlight = this.highlightClassName;
+ if(this._oCurItem) {
+ // Remove highlight from old item
+ YAHOO.util.Dom.removeClass(this._oCurItem, sHighlight);
+ }
+
+ if((sType == "to") && sHighlight) {
+ // Apply highlight to new item
+ YAHOO.util.Dom.addClass(oNewItem, sHighlight);
+ this._oCurItem = oNewItem;
+ }
+};
+
+/**
+ * Toggles the pre-highlight on or off for an item in the container.
+ *
+ * @param {object} oNewItem New The <li> element item to receive highlight
+ * behavior
+ * @param {string} sType "mouseover" will toggle highlight on, and "mouseout"
+ * will toggle highlight off.
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._togglePrehighlight = function(oNewItem, sType) {
+ if(oNewItem == this._oCurItem) {
+ return;
+ }
+
+ var sPrehighlight = this.prehighlightClassName;
+ if((sType == "mouseover") && sPrehighlight) {
+ // Apply prehighlight to new item
+ YAHOO.util.Dom.addClass(oNewItem, sPrehighlight);
+ }
+ else {
+ // Remove prehighlight from old item
+ YAHOO.util.Dom.removeClass(oNewItem, sPrehighlight);
+ }
+};
+
+/**
+ * Updates the text input box value with selected query result. If a delimiter
+ * has been defined, then the value gets appended with the delimiter.
+ *
+ * @param {object} oItem The <li> element item with which to update the value
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._updateValue = function(oItem) {
+ var oTextbox = this._oTextbox;
+ var sDelimChar = (this.delimChar) ? this.delimChar[0] : null;
+ var sSavedQuery = this._sSavedQuery;
+ var sResultKey = oItem._sResultKey;
+ oTextbox.focus();
+
+ // First clear text field
+ oTextbox.value = "";
+ // Grab data to put into text field
+ if(sDelimChar) {
+ if(sSavedQuery) {
+ oTextbox.value = sSavedQuery;
+ }
+ oTextbox.value += sResultKey + sDelimChar;
+ if(sDelimChar != " ") {
+ oTextbox.value += " ";
+ }
+ }
+ else { oTextbox.value = sResultKey; }
+
+ // scroll to bottom of textarea if necessary
+ if(oTextbox.type == "textarea") {
+ oTextbox.scrollTop = oTextbox.scrollHeight;
+ }
+
+ // move cursor to end
+ var end = oTextbox.value.length;
+ this._selectText(oTextbox,end,end);
+
+ this._oCurItem = oItem;
+};
+
+/**
+ * Selects a result item from the container
+ *
+ * @param {object} oItem The selected <li> element item
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._selectItem = function(oItem) {
+ this._bItemSelected = true;
+ this._updateValue(oItem);
+ this.itemSelectEvent.fire(this, oItem, oItem._oResultData);
+ this._clearList();
+};
+
+/**
+ * For values updated by type-ahead, the right arrow key jumps to the end
+ * of the textbox, otherwise the container is closed.
+ *
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._jumpSelection = function() {
+ if(!this.typeAhead) {
+ return;
+ }
+ else {
+ this._clearList();
+ }
+};
+
+/**
+ * Triggered by up and down arrow keys, changes the current highlighted
+ * <li> element item. Scrolls container if necessary.
+ *
+ * @param {number} nKeyCode Code of key pressed
+ * @private
+ */
+YAHOO.widget.AutoComplete.prototype._moveSelection = function(nKeyCode) {
+ if(this._bContainerOpen) {
+ // Determine current item's id number
+ var oCurItem = this._oCurItem;
+ var nCurItemIndex = -1;
+
+ if (oCurItem) {
+ nCurItemIndex = oCurItem._nItemIndex;
+ }
+
+ var nNewItemIndex = (nKeyCode == 40) ?
+ (nCurItemIndex + 1) : (nCurItemIndex - 1);
+
+ // Out of bounds
+ if (nNewItemIndex < -2 || nNewItemIndex >= this._nDisplayedItems) {
+ return;
+ }
+
+ if (oCurItem) {
+ // Unhighlight current item
+ this._toggleHighlight(oCurItem, "from");
+ this.itemArrowFromEvent.fire(this, oCurItem);
+ }
+ if (nNewItemIndex == -1) {
+ // Go back to query (remove type-ahead string)
+ if(this.delimChar && this._sSavedQuery) {
+ if (!this._textMatchesOption()) {
+ this._oTextbox.value = this._sSavedQuery;
+ }
+ else {
+ this._oTextbox.value = this._sSavedQuery + this._sCurQuery;
+ }
+ }
+ else {
+ this._oTextbox.value = this._sCurQuery;
+ }
+ this._oCurItem = null;
+ return;
+ }
+ if (nNewItemIndex == -2) {
+ // Close container
+ this._clearList();
+ return;
+ }
+
+ var oNewItem = this._aListItems[nNewItemIndex];
+
+ // Scroll the container if necessary
+ if((YAHOO.util.Dom.getStyle(this._oContainer._oContent,"overflow") == "auto") &&
+ (nNewItemIndex > -1) && (nNewItemIndex < this._nDisplayedItems)) {
+ // User is keying down
+ if(nKeyCode == 40) {
+ // Bottom of selected item is below scroll area...
+ if((oNewItem.offsetTop+oNewItem.offsetHeight) > (this._oContainer._oContent.scrollTop + this._oContainer._oContent.offsetHeight)) {
+ // Set bottom of scroll area to bottom of selected item
+ this._oContainer._oContent.scrollTop = (oNewItem.offsetTop+oNewItem.offsetHeight) - this._oContainer._oContent.offsetHeight;
+ }
+ // Bottom of selected item is above scroll area...
+ else if((oNewItem.offsetTop+oNewItem.offsetHeight) < this._oContainer._oContent.scrollTop) {
+ // Set top of selected item to top of scroll area
+ this._oContainer._oContent.scrollTop = oNewItem.offsetTop;
+
+ }
+ }
+ // User is keying up
+ else {
+ // Top of selected item is above scroll area
+ if(oNewItem.offsetTop < this._oContainer._oContent.scrollTop) {
+ // Set top of scroll area to top of selected item
+ this._oContainer._oContent.scrollTop = oNewItem.offsetTop;
+ }
+ // Top of selected item is below scroll area
+ else if(oNewItem.offsetTop > (this._oContainer._oContent.scrollTop + this._oContainer._oContent.offsetHeight)) {
+ // Set bottom of selected item to bottom of scroll area
+ this._oContainer._oContent.scrollTop = (oNewItem.offsetTop+oNewItem.offsetHeight) - this._oContainer._oContent.offsetHeight;
+ }
+ }
+ }
+
+ this._toggleHighlight(oNewItem, "to");
+ this.itemArrowToEvent.fire(this, oNewItem);
+ if(this.typeAhead) {
+ this._updateValue(oNewItem);
+ }
+ }
+};
+
+/****************************************************************************/
+/****************************************************************************/
+/****************************************************************************/
+
+/**
+ * Class providing encapsulation of a data source.
+ *
+ * @constructor
+ *
+ */
+YAHOO.widget.DataSource = function() {
+ /* abstract class */
+};
+
+
+/***************************************************************************
+ * Public constants
+ ***************************************************************************/
+/**
+ * Error message for null data responses.
+ *
+ * @type constant
+ * @final
+ */
+YAHOO.widget.DataSource.prototype.ERROR_DATANULL = "Response data was null";
+
+/**
+ * Error message for data responses with parsing errors.
+ *
+ * @type constant
+ * @final
+ */
+YAHOO.widget.DataSource.prototype.ERROR_DATAPARSE = "Response data could not be parsed";
+
+
+/***************************************************************************
+ * Public member variables
+ ***************************************************************************/
+/**
+ * Max size of the local cache. Set to 0 to turn off caching. Caching is
+ * useful to reduce the number of server connections. Recommended only for data
+ * sources that return comprehensive results for queries or when stale data is
+ * not an issue. Default: 15.
+ *
+ * @type number
+ */
+YAHOO.widget.DataSource.prototype.maxCacheEntries = 15;
+
+/**
+ * Use this to equate cache matching with the type of matching done by your live
+ * data source. If caching is on and queryMatchContains is true, the cache
+ * returns results that "contain" the query string. By default,
+ * queryMatchContains is set to false, meaning the cache only returns results
+ * that "start with" the query string. Default: false.
+ *
+ * @type boolean
+ */
+YAHOO.widget.DataSource.prototype.queryMatchContains = false;
+
+/**
+ * Data source query subset matching. If caching is on and queryMatchSubset is
+ * true, substrings of queries will return matching cached results. For
+ * instance, if the first query is for "abc" susequent queries that start with
+ * "abc", like "abcd", will be queried against the cache, and not the live data
+ * source. Recommended only for data sources that return comprehensive results
+ * for queries with very few characters. Default: false.
+ *
+ * @type boolean
+ */
+YAHOO.widget.DataSource.prototype.queryMatchSubset = false;
+
+/**
+ * Data source query case-sensitivity matching. If caching is on and
+ * queryMatchCase is true, queries will only return results for case-sensitive
+ * matches. Default: false.
+ *
+ * @type boolean
+ */
+YAHOO.widget.DataSource.prototype.queryMatchCase = false;
+
+
+/***************************************************************************
+ * Public methods
+ ***************************************************************************/
+ /**
+ * Public accessor to the unique name of the data source instance.
+ *
+ * @return {string} Unique name of the data source instance
+ */
+YAHOO.widget.DataSource.prototype.getName = function() {
+ return this._sName;
+};
+
+ /**
+ * Public accessor to the unique name of the data source instance.
+ *
+ * @return {string} Unique name of the data source instance
+ */
+YAHOO.widget.DataSource.prototype.toString = function() {
+ return "DataSource " + this._sName;
+};
+
+/**
+ * Retrieves query results, first checking the local cache, then making the
+ * query request to the live data source as defined by the function doQuery.
+ *
+ * @param {object} oCallbackFn Callback function defined by oParent object to
+ * which to return results
+ * @param {string} sQuery Query string
+ * @param {object} oParent The object instance that has requested data
+ */
+YAHOO.widget.DataSource.prototype.getResults = function(oCallbackFn, sQuery, oParent) {
+
+ // First look in cache
+ var aResults = this._doQueryCache(oCallbackFn,sQuery,oParent);
+
+ // Not in cache, so get results from server
+ if(aResults.length === 0) {
+ this.queryEvent.fire(this, oParent, sQuery);
+ this.doQuery(oCallbackFn, sQuery, oParent);
+ }
+};
+
+/**
+ * Abstract method implemented by subclasses to make a query to the live data
+ * source. Must call the callback function with the response returned from the
+ * query. Populates cache (if enabled).
+ *
+ * @param {object} oCallbackFn Callback function implemented by oParent to
+ * which to return results
+ * @param {string} sQuery Query string
+ * @param {object} oParent The object instance that has requested data
+ */
+YAHOO.widget.DataSource.prototype.doQuery = function(oCallbackFn, sQuery, oParent) {
+ /* override this */
+};
+
+/**
+ * Flushes cache.
+ */
+YAHOO.widget.DataSource.prototype.flushCache = function() {
+ if(this._aCache) {
+ this._aCache = [];
+ }
+ if(this._aCacheHelper) {
+ this._aCacheHelper = [];
+ }
+ this.cacheFlushEvent.fire(this);
+};
+
+/***************************************************************************
+ * Events
+ ***************************************************************************/
+/**
+ * Fired when a query is made to the live data source. Subscribers receive the
+ * following array:<br>
+ * - args[0] The data source instance
+ * - args[1] The requesting object
+ * - args[2] The query string
+ */
+YAHOO.widget.DataSource.prototype.queryEvent = null;
+
+/**
+ * Fired when a query is made to the local cache. Subscribers receive the
+ * following array:<br>
+ * - args[0] The data source instance
+ * - args[1] The requesting object
+ * - args[2] The query string
+ */
+YAHOO.widget.DataSource.prototype.cacheQueryEvent = null;
+
+/**
+ * Fired when data is retrieved from the live data source. Subscribers receive
+ * the following array:<br>
+ * - args[0] The data source instance
+ * - args[1] The requesting object
+ * - args[2] The query string
+ * - args[3] Array of result objects
+ */
+YAHOO.widget.DataSource.prototype.getResultsEvent = null;
+
+/**
+ * Fired when data is retrieved from the local cache. Subscribers receive the
+ * following array :<br>
+ * - args[0] The data source instance
+ * - args[1] The requesting object
+ * - args[2] The query string
+ * - args[3] Array of result objects
+ */
+YAHOO.widget.DataSource.prototype.getCachedResultsEvent = null;
+
+/**
+ * Fired when an error is encountered with the live data source. Subscribers
+ * receive the following array:<br>
+ * - args[0] The data source instance
+ * - args[1] The requesting object
+ * - args[2] The query string
+ * - args[3] Error message string
+ */
+YAHOO.widget.DataSource.prototype.dataErrorEvent = null;
+
+/**
+ * Fired when the local cache is flushed. Subscribers receive the following
+ * array :<br>
+ * - args[0] The data source instance
+ */
+YAHOO.widget.DataSource.prototype.cacheFlushEvent = null;
+
+/***************************************************************************
+ * Private member variables
+ ***************************************************************************/
+/**
+ * Internal class variable to index multiple data source instances.
+ *
+ * @type number
+ * @private
+ */
+YAHOO.widget.DataSource._nIndex = 0;
+
+/**
+ * Name of data source instance.
+ *
+ * @type string
+ * @private
+ */
+YAHOO.widget.DataSource.prototype._sName = null;
+
+/**
+ * Local cache of data result objects indexed chronologically.
+ *
+ * @type array
+ * @private
+ */
+YAHOO.widget.DataSource.prototype._aCache = null;
+
+
+/***************************************************************************
+ * Private methods
+ ***************************************************************************/
+/**
+ * Initializes data source instance.
+ *
+ * @private
+ */
+YAHOO.widget.DataSource.prototype._init = function() {
+ // Validate and initialize public configs
+ var maxCacheEntries = this.maxCacheEntries;
+ if(isNaN(maxCacheEntries) || (maxCacheEntries < 0)) {
+ maxCacheEntries = 0;
+ }
+ // Initialize local cache
+ if(maxCacheEntries > 0 && !this._aCache) {
+ this._aCache = [];
+ }
+
+ this._sName = "instance" + YAHOO.widget.DataSource._nIndex;
+ YAHOO.widget.DataSource._nIndex++;
+
+ this.queryEvent = new YAHOO.util.CustomEvent("query", this);
+ this.cacheQueryEvent = new YAHOO.util.CustomEvent("cacheQuery", this);
+ this.getResultsEvent = new YAHOO.util.CustomEvent("getResults", this);
+ this.getCachedResultsEvent = new YAHOO.util.CustomEvent("getCachedResults", this);
+ this.dataErrorEvent = new YAHOO.util.CustomEvent("dataError", this);
+ this.cacheFlushEvent = new YAHOO.util.CustomEvent("cacheFlush", this);
+};
+
+/**
+ * Adds a result object to the local cache, evicting the oldest element if the
+ * cache is full. Newer items will have higher indexes, the oldest item will have
+ * index of 0.
+ *
+ * @param {object} resultObj Object literal of data results, including internal
+ * properties and an array of result objects
+ * @private
+ */
+YAHOO.widget.DataSource.prototype._addCacheElem = function(resultObj) {
+ var aCache = this._aCache;
+ // Don't add if anything important is missing.
+ if(!aCache || !resultObj || !resultObj.query || !resultObj.results) {
+ return;
+ }
+
+ // If the cache is full, make room by removing from index=0
+ if(aCache.length >= this.maxCacheEntries) {
+ aCache.shift();
+ }
+
+ // Add to cache, at the end of the array
+ aCache.push(resultObj);
+};
+
+/**
+ * Queries the local cache for results. If query has been cached, the callback
+ * function is called with the results, and the cached is refreshed so that it
+ * is now the newest element.
+ *
+ * @param {object} oCallbackFn Callback function defined by oParent object to
+ * which to return results
+ * @param {string} sQuery Query string
+ * @param {object} oParent The object instance that has requested data
+ * @return {array} aResults Result object from local cache if found, otherwise
+ * null
+ * @private
+ */
+YAHOO.widget.DataSource.prototype._doQueryCache = function(oCallbackFn, sQuery, oParent) {
+ var aResults = [];
+ var bMatchFound = false;
+ var aCache = this._aCache;
+ var nCacheLength = (aCache) ? aCache.length : 0;
+ var bMatchContains = this.queryMatchContains;
+
+ // If cache is enabled...
+ if((this.maxCacheEntries > 0) && aCache && (nCacheLength > 0)) {
+ this.cacheQueryEvent.fire(this, oParent, sQuery);
+ // If case is unimportant, normalize query now instead of in loops
+ if(!this.queryMatchCase) {
+ var sOrigQuery = sQuery;
+ sQuery = sQuery.toLowerCase();
+ }
+
+ // Loop through each cached element's query property...
+ for(var i = nCacheLength-1; i >= 0; i--) {
+ var resultObj = aCache[i];
+ var aAllResultItems = resultObj.results;
+ // If case is unimportant, normalize match key for comparison
+ var matchKey = (!this.queryMatchCase) ?
+ encodeURIComponent(resultObj.query.toLowerCase()):
+ encodeURIComponent(resultObj.query);
+
+ // If a cached match key exactly matches the query...
+ if(matchKey == sQuery) {
+ // Stash all result objects into aResult[] and stop looping through the cache.
+ bMatchFound = true;
+ aResults = aAllResultItems;
+
+ // The matching cache element was not the most recent,
+ // so now we need to refresh the cache.
+ if(i != nCacheLength-1) {
+ // Remove element from its original location
+ aCache.splice(i,1);
+ // Add element as newest
+ this._addCacheElem(resultObj);
+ }
+ break;
+ }
+ // Else if this query is not an exact match and subset matching is enabled...
+ else if(this.queryMatchSubset) {
+ // Loop through substrings of each cached element's query property...
+ for(var j = sQuery.length-1; j >= 0 ; j--) {
+ var subQuery = sQuery.substr(0,j);
+
+ // If a substring of a cached sQuery exactly matches the query...
+ if(matchKey == subQuery) {
+ bMatchFound = true;
+
+ // Go through each cached result object to match against the query...
+ for(var k = aAllResultItems.length-1; k >= 0; k--) {
+ var aRecord = aAllResultItems[k];
+ var sKeyIndex = (this.queryMatchCase) ?
+ encodeURIComponent(aRecord[0]).indexOf(sQuery):
+ encodeURIComponent(aRecord[0]).toLowerCase().indexOf(sQuery);
+
+ // A STARTSWITH match is when the query is found at the beginning of the key string...
+ if((!bMatchContains && (sKeyIndex === 0)) ||
+ // A CONTAINS match is when the query is found anywhere within the key string...
+ (bMatchContains && (sKeyIndex > -1))) {
+ // Stash a match into aResults[].
+ aResults.unshift(aRecord);
+ }
+ }
+
+ // Add the subset match result set object as the newest element to cache,
+ // and stop looping through the cache.
+ resultObj = {};
+ resultObj.query = sQuery;
+ resultObj.results = aResults;
+ this._addCacheElem(resultObj);
+ break;
+ }
+ }
+ if(bMatchFound) {
+ break;
+ }
+ }
+ }
+
+ // If there was a match, send along the results.
+ if(bMatchFound) {
+ this.getCachedResultsEvent.fire(this, oParent, sOrigQuery, aResults);
+ oCallbackFn(sOrigQuery, aResults, oParent);
+ }
+ }
+ return aResults;
+};
+
+
+/****************************************************************************/
+/****************************************************************************/
+/****************************************************************************/
+
+/**
+ * Implementation of YAHOO.widget.DataSource using XML HTTP requests that return
+ * query results.
+ * requires YAHOO.util.Connect XMLHTTPRequest library
+ * extends YAHOO.widget.DataSource
+ *
+ * @constructor
+ * @param {string} sScriptURI Absolute or relative URI to script that returns
+ * query results as JSON, XML, or delimited flat data
+ * @param {array} aSchema Data schema definition of results
+ * @param {object} oConfigs Optional object literal of config params
+ */
+YAHOO.widget.DS_XHR = function(sScriptURI, aSchema, oConfigs) {
+ // Set any config params passed in to override defaults
+ if(typeof oConfigs == "object") {
+ for(var sConfig in oConfigs) {
+ this[sConfig] = oConfigs[sConfig];
+ }
+ }
+
+ // Initialization sequence
+ if(!aSchema || (aSchema.constructor != Array)) {
+ return;
+ }
+ else {
+ this.schema = aSchema;
+ }
+ this.scriptURI = sScriptURI;
+ this._init();
+};
+
+YAHOO.widget.DS_XHR.prototype = new YAHOO.widget.DataSource();
+
+/***************************************************************************
+ * Public constants
+ ***************************************************************************/
+/**
+ * JSON data type
+ *
+ * @type constant
+ * @final
+ */
+YAHOO.widget.DS_XHR.prototype.TYPE_JSON = 0;
+
+/**
+ * XML data type
+ *
+ * @type constant
+ * @final
+ */
+YAHOO.widget.DS_XHR.prototype.TYPE_XML = 1;
+
+/**
+ * Flat file data type
+ *
+ * @type constant
+ * @final
+ */
+YAHOO.widget.DS_XHR.prototype.TYPE_FLAT = 2;
+
+/**
+ * Error message for XHR failure.
+ *
+ * @type constant
+ * @final
+ */
+YAHOO.widget.DS_XHR.prototype.ERROR_DATAXHR = "XHR response failed";
+
+/***************************************************************************
+ * Public member variables
+ ***************************************************************************/
+/**
+ * Number of milliseconds the XHR connection will wait for a server response. A
+ * a value of zero indicates the XHR connection will wait forever. Any value
+ * greater than zero will use the Connection utility's Auto-Abort feature.
+ * Default: 0.
+ *
+ * @type number
+ */
+YAHOO.widget.DS_XHR.prototype.connTimeout = 0;
+
+
+/**
+ * Absolute or relative URI to script that returns query results. For instance,
+ * queries will be sent to
+ * <scriptURI>?<scriptQueryParam>=userinput
+ *
+ * @type string
+ */
+YAHOO.widget.DS_XHR.prototype.scriptURI = null;
+
+/**
+ * Query string parameter name sent to scriptURI. For instance, queries will be
+ * sent to
+ * <scriptURI>?<scriptQueryParam>=userinput
+ * Default: "query".
+ *
+ * @type string
+ */
+YAHOO.widget.DS_XHR.prototype.scriptQueryParam = "query";
+
+/**
+ * String of key/value pairs to append to requests made to scriptURI. Define
+ * this string when you want to send additional query parameters to your script.
+ * When defined, queries will be sent to
+ * <scriptURI>?<scriptQueryParam>=userinput&<scriptQueryAppend>
+ * Default: "".
+ *
+ * @type string
+ */
+YAHOO.widget.DS_XHR.prototype.scriptQueryAppend = "";
+
+/**
+ * XHR response data type. Other types that may be defined are TYPE_XML and
+ * TYPE_FLAT. Default: TYPE_JSON.
+ *
+ * @type type
+ */
+YAHOO.widget.DS_XHR.prototype.responseType = YAHOO.widget.DS_XHR.prototype.TYPE_JSON;
+
+/**
+ * String after which to strip results. If the results from the XHR are sent
+ * back as HTML, the gzip HTML comment appears at the end of the data and should
+ * be ignored. Default: "\n<!--"
+ *
+ * @type string
+ */
+YAHOO.widget.DS_XHR.prototype.responseStripAfter = "\n<!--";
+
+/***************************************************************************
+ * Public methods
+ ***************************************************************************/
+/**
+ * Queries the live data source defined by scriptURI for results. Results are
+ * passed back to a callback function.
+ *
+ * @param {object} oCallbackFn Callback function defined by oParent object to
+ * which to return results
+ * @param {string} sQuery Query string
+ * @param {object} oParent The object instance that has requested data
+ */
+YAHOO.widget.DS_XHR.prototype.doQuery = function(oCallbackFn, sQuery, oParent) {
+ var isXML = (this.responseType == this.TYPE_XML);
+ var sUri = this.scriptURI+"?"+this.scriptQueryParam+"="+sQuery;
+ if(this.scriptQueryAppend.length > 0) {
+ sUri += "&" + this.scriptQueryAppend;
+ }
+ var oResponse = null;
+
+ var oSelf = this;
+ /**
+ * Sets up ajax request callback
+ *
+ * @param {object} oReq HTTPXMLRequest object
+ * @private
+ */
+ var responseSuccess = function(oResp) {
+ // Response ID does not match last made request ID.
+ if(!oSelf._oConn || (oResp.tId != oSelf._oConn.tId)) {
+ oSelf.dataErrorEvent.fire(oSelf, oParent, sQuery, oSelf.ERROR_DATANULL);
+ return;
+ }
+//DEBUG
+for(var foo in oResp) {
+}
+ if(!isXML) {
+ oResp = oResp.responseText;
+ }
+ else {
+ oResp = oResp.responseXML;
+ }
+ if(oResp === null) {
+ oSelf.dataErrorEvent.fire(oSelf, oParent, sQuery, oSelf.ERROR_DATANULL);
+ return;
+ }
+
+ var aResults = oSelf.parseResponse(sQuery, oResp, oParent);
+ var resultObj = {};
+ resultObj.query = decodeURIComponent(sQuery);
+ resultObj.results = aResults;
+ if(aResults === null) {
+ oSelf.dataErrorEvent.fire(oSelf, oParent, sQuery, oSelf.ERROR_DATAPARSE);
+ return;
+ }
+ else {
+ oSelf.getResultsEvent.fire(oSelf, oParent, sQuery, aResults);
+ oSelf._addCacheElem(resultObj);
+ oCallbackFn(sQuery, aResults, oParent);
+ }
+ };
+
+ var responseFailure = function(oResp) {
+ oSelf.dataErrorEvent.fire(oSelf, oParent, sQuery, oSelf.ERROR_DATAXHR);
+ return;
+ };
+
+ var oCallback = {
+ success:responseSuccess,
+ failure:responseFailure
+ };
+
+ if(!isNaN(this.connTimeout) && this.connTimeout > 0) {
+ oCallback.timeout = this.connTimeout;
+ }
+
+ if(this._oConn) {
+ YAHOO.util.Connect.abort(this._oConn);
+ }
+
+ oSelf._oConn = YAHOO.util.Connect.asyncRequest("GET", sUri, oCallback, null);
+};
+
+/**
+ * Parses raw response data into an array of result objects. The result data key
+ * is always stashed in the [0] element of each result object.
+ *
+ * @param {string} sQuery Query string
+ * @param {object} oResponse The raw response data to parse
+ * @param {object} oParent The object instance that has requested data
+ * @returns {array} Array of result objects
+ */
+YAHOO.widget.DS_XHR.prototype.parseResponse = function(sQuery, oResponse, oParent) {
+ var aSchema = this.schema;
+ var aResults = [];
+ var bError = false;
+
+ // Strip out comment at the end of results
+ var nEnd = ((this.responseStripAfter !== "") && (oResponse.indexOf)) ?
+ oResponse.indexOf(this.responseStripAfter) : -1;
+ if(nEnd != -1) {
+ oResponse = oResponse.substring(0,nEnd);
+ }
+
+ switch (this.responseType) {
+ case this.TYPE_JSON:
+ var jsonList;
+ // Divert KHTML clients from JSON lib
+ if(window.JSON && (navigator.userAgent.toLowerCase().indexOf('khtml')== -1)) {
+ // Use the JSON utility if available
+ var jsonObjParsed = JSON.parse(oResponse);
+ if(!jsonObjParsed) {
+ bError = true;
+ break;
+ }
+ else {
+ // eval is necessary here since aSchema[0] is of unknown depth
+ jsonList = eval("jsonObjParsed." + aSchema[0]);
+ }
+ }
+ else {
+ // Parse the JSON response as a string
+ try {
+ // Trim leading spaces
+ while (oResponse.substring(0,1) == " ") {
+ oResponse = oResponse.substring(1, oResponse.length);
+ }
+
+ // Invalid JSON response
+ if(oResponse.indexOf("{") < 0) {
+ bError = true;
+ break;
+ }
+
+ // Empty (but not invalid) JSON response
+ if(oResponse.indexOf("{}") === 0) {
+ break;
+ }
+
+ // Turn the string into an object literal...
+ // ...eval is necessary here
+ var jsonObjRaw = eval("(" + oResponse + ")");
+ if(!jsonObjRaw) {
+ bError = true;
+ break;
+ }
+
+ // Grab the object member that contains an array of all reponses...
+ // ...eval is necessary here since aSchema[0] is of unknown depth
+ jsonList = eval("(jsonObjRaw." + aSchema[0]+")");
+ }
+ catch(e) {
+ bError = true;
+ break;
+ }
+ }
+
+ if(!jsonList) {
+ bError = true;
+ break;
+ }
+
+ // Loop through the array of all responses...
+ for(var i = jsonList.length-1; i >= 0 ; i--) {
+ var aResultItem = [];
+ var jsonResult = jsonList[i];
+ // ...and loop through each data field value of each response
+ for(var j = aSchema.length-1; j >= 1 ; j--) {
+ // ...and capture data into an array mapped according to the schema...
+ var dataFieldValue = jsonResult[aSchema[j]];
+ if(!dataFieldValue) {
+ dataFieldValue = "";
+ }
+ aResultItem.unshift(dataFieldValue);
+ }
+ // Capture the array of data field values in an array of results
+ aResults.unshift(aResultItem);
+ }
+ break;
+ case this.TYPE_XML:
+ // Get the collection of results
+ var xmlList = oResponse.getElementsByTagName(aSchema[0]);
+ if(!xmlList) {
+ bError = true;
+ break;
+ }
+ // Loop through each result
+ for(var k = xmlList.length-1; k >= 0 ; k--) {
+ var result = xmlList.item(k);
+ var aFieldSet = [];
+ // Loop through each data field in each result using the schema
+ for(var m = aSchema.length-1; m >= 1 ; m--) {
+ var sValue = null;
+ // Values may be held in an attribute...
+ var xmlAttr = result.attributes.getNamedItem(aSchema[m]);
+ if(xmlAttr) {
+ sValue = xmlAttr.value;
+ }
+ // ...or in a node
+ else{
+ var xmlNode = result.getElementsByTagName(aSchema[m]);
+ if(xmlNode && xmlNode.item(0) && xmlNode.item(0).firstChild) {
+ sValue = xmlNode.item(0).firstChild.nodeValue;
+ }
+ else {
+ sValue = "";
+ }
+ }
+ // Capture the schema-mapped data field values into an array
+ aFieldSet.unshift(sValue);
+ }
+ // Capture each array of values into an array of results
+ aResults.unshift(aFieldSet);
+ }
+ break;
+ case this.TYPE_FLAT:
+ if(oResponse.length > 0) {
+ // Delete the last line delimiter at the end of the data if it exists
+ var newLength = oResponse.length-aSchema[0].length;
+ if(oResponse.substr(newLength) == aSchema[0]) {
+ oResponse = oResponse.substr(0, newLength);
+ }
+ var aRecords = oResponse.split(aSchema[0]);
+ for(var n = aRecords.length-1; n >= 0; n--) {
+ aResults[n] = aRecords[n].split(aSchema[1]);
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ sQuery = null;
+ oResponse = null;
+ oParent = null;
+ if(bError) {
+ return null;
+ }
+ else {
+ return aResults;
+ }
+};
+
+
+/***************************************************************************
+ * Private member variables
+ ***************************************************************************/
+/**
+ * XHR connection object.
+ *
+ * @type object
+ * @private
+ */
+YAHOO.widget.DS_XHR.prototype._oConn = null;
+
+
+/****************************************************************************/
+/****************************************************************************/
+/****************************************************************************/
+
+/**
+ * Implementation of YAHOO.widget.DataSource using a native Javascript struct as
+ * its live data source.
+ *
+ * @constructor
+ * extends YAHOO.widget.DataSource
+ *
+ * @param {string} oFunction In-memory Javascript function that returns query
+ * results as an array of objects
+ * @param {object} oConfigs Optional object literal of config params
+ */
+YAHOO.widget.DS_JSFunction = function(oFunction, oConfigs) {
+ // Set any config params passed in to override defaults
+ if(typeof oConfigs == "object") {
+ for(var sConfig in oConfigs) {
+ this[sConfig] = oConfigs[sConfig];
+ }
+ }
+
+ // Initialization sequence
+ if(!oFunction || (oFunction.constructor != Function)) {
+ return;
+ }
+ else {
+ this.dataFunction = oFunction;
+ this._init();
+ }
+};
+
+YAHOO.widget.DS_JSFunction.prototype = new YAHOO.widget.DataSource();
+
+/***************************************************************************
+ * Public member variables
+ ***************************************************************************/
+/**
+ * In-memory Javascript function that returns query results.
+ *
+ * @type function
+ */
+YAHOO.widget.DS_JSFunction.prototype.dataFunction = null;
+
+
+/***************************************************************************
+ * Public methods
+ ***************************************************************************/
+/**
+ * Queries the live data source defined by function for results. Results are
+ * passed back to a callback function.
+ *
+ * @param {object} oCallbackFn Callback function defined by oParent object to
+ * which to return results
+ * @param {string} sQuery Query string
+ * @param {object} oParent The object instance that has requested data
+ */
+YAHOO.widget.DS_JSFunction.prototype.doQuery = function(oCallbackFn, sQuery, oParent) {
+ var oFunction = this.dataFunction;
+ var aResults = [];
+
+ aResults = oFunction(sQuery);
+ if(aResults === null) {
+ this.dataErrorEvent.fire(this, oParent, sQuery, this.ERROR_DATANULL);
+ return;
+ }
+
+ var resultObj = {};
+ resultObj.query = decodeURIComponent(sQuery);
+ resultObj.results = aResults;
+ this._addCacheElem(resultObj);
+
+ this.getResultsEvent.fire(this, oParent, sQuery, aResults);
+ oCallbackFn(sQuery, aResults, oParent);
+ return;
+};
+
+/****************************************************************************/
+/****************************************************************************/
+/****************************************************************************/
+
+/**
+ * Implementation of YAHOO.widget.DataSource using a native Javascript array as
+ * its live data source.
+ *
+ * @constructor
+ * extends YAHOO.widget.DataSource
+ *
+ * @param {string} aData In-memory Javascript array of simple string data
+ * @param {object} oConfigs Optional object literal of config params
+ */
+YAHOO.widget.DS_JSArray = function(aData, oConfigs) {
+ // Set any config params passed in to override defaults
+ if(typeof oConfigs == "object") {
+ for(var sConfig in oConfigs) {
+ this[sConfig] = oConfigs[sConfig];
+ }
+ }
+
+ // Initialization sequence
+ if(!aData || (aData.constructor != Array)) {
+ return;
+ }
+ else {
+ this.data = aData;
+ this._init();
+ }
+};
+
+YAHOO.widget.DS_JSArray.prototype = new YAHOO.widget.DataSource();
+
+/***************************************************************************
+ * Public member variables
+ ***************************************************************************/
+/**
+ * In-memory Javascript array of strings.
+ *
+ * @type array
+ */
+YAHOO.widget.DS_JSArray.prototype.data = null;
+
+/***************************************************************************
+ * Public methods
+ ***************************************************************************/
+/**
+ * Queries the live data source defined by data for results. Results are passed
+ * back to a callback function.
+ *
+ * @param {object} oCallbackFn Callback function defined by oParent object to
+ * which to return results
+ * @param {string} sQuery Query string
+ * @param {object} oParent The object instance that has requested data
+ */
+YAHOO.widget.DS_JSArray.prototype.doQuery = function(oCallbackFn, sQuery, oParent) {
+ var aData = this.data;
+ var aResults = [];
+ var bMatchFound = false;
+ var bMatchContains = this.queryMatchContains;
+ if(!this.queryMatchCase) {
+ sQuery = sQuery.toLowerCase();
+ }
+
+ // Loop through each element of the array...
+ for(var i = aData.length-1; i >= 0; i--) {
+ var aDataset = [];
+ if(typeof aData[i] == "string") {
+ aDataset[0] = aData[i];
+ }
+ else {
+ aDataset = aData[i];
+ }
+
+ var sKeyIndex = (this.queryMatchCase) ?
+ encodeURIComponent(aDataset[0]).indexOf(sQuery):
+ encodeURIComponent(aDataset[0]).toLowerCase().indexOf(sQuery);
+
+ // A STARTSWITH match is when the query is found at the beginning of the key string...
+ if((!bMatchContains && (sKeyIndex === 0)) ||
+ // A CONTAINS match is when the query is found anywhere within the key string...
+ (bMatchContains && (sKeyIndex > -1))) {
+ // Stash a match into aResults[].
+ aResults.unshift(aDataset);
+ }
+ }
+
+ this.getResultsEvent.fire(this, oParent, sQuery, aResults);
+ oCallbackFn(sQuery, aResults, oParent);
+};
Added: branches/tomek/portal-dnd/dndRenderer.war/js/calendar/README
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/calendar/README 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/calendar/README 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,24 @@
+Calendar Release Notes
+
+*** version 0.11.0 ***
+
+ - DateMath: DateMath.add now properly adds weeks
+ - DateMath: between() function added
+ - DateMath: getWeekNumber() fixed to take starting day of week into account
+ - All references to Calendar's built in CSS class handlers are removed, replaced with calls to Dom utility (addClass, removeClass)
+ - Several CSS class constants now have clearer names
+ - All CSS classes are now properly namespaced to avoid CSS conflicts
+ - Fixed table:hover bug in CSS
+ - Calendar no longer requires the container ID and variable name to match in order for month navigation to function properly
+ - Calendar month navigation arrows are now represented as background images
+
+*** version 0.10.0 ***
+
+ - Major performance improvements from attaching DOM events to associated table cells only once, when the Calendar shell is built
+ - DOM events for mouseover/mouseout are now fired for all browsers (not just Internet Explorer)
+ - Reset functionality bug fixed for 2-up Calendar view
+
+*** version 0.9.0 ***
+
+* Initial release
+
Added: branches/tomek/portal-dnd/dndRenderer.war/js/calendar/assets/calendar.css
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/calendar/assets/calendar.css 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/calendar/assets/calendar.css 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,169 @@
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+Version 0.11.0
+*/
+
+.yui-cal2upwrapper {*height:1%;} /* IE */
+.yui-cal2upwrapper:after {content:'.';clear:both;display:block;visibility:hidden;height:0;} /* others */
+
+.yui-calcontainer {
+ float:left;
+ padding:5px;
+ background-color:#F7F9FB;
+ border:1px solid #7B9EBD;
+}
+
+.yui-calcontainer .title {
+ font:100% sans-serif;
+ color:#000;
+ font-weight:bold;
+ margin-bottom:5px;
+ height:auto;
+ width:304px;
+ position:relative;
+}
+
+.yui-calcontainer .title .close-icon {
+ position:absolute;
+ right:0;
+ top:0;
+ border:none;
+}
+
+.yui-calcontainer .cal2up {
+ float:left;
+}
+
+.yui-calendar .calnavleft {
+ position:absolute;
+ background-repeat:no-repeat;
+ cursor:pointer;
+ top:2px;
+ bottom:0;
+ width:9px;
+ height:12px;
+ left:2px;
+}
+
+.yui-calendar .calnavright {
+ position:absolute;
+ background-repeat:no-repeat;
+ cursor:pointer;
+ top:2px;
+ bottom:0;
+ width:9px;
+ height:12px;
+ right:2px;
+}
+
+/* Calendar element styles */
+
+.yui-calendar {
+ font:100% sans-serif;
+ text-align:center;
+ border-spacing:0;
+ border-collapse:separate;
+}
+
+.yui-calendar td.calcell {
+ width:1.5em;
+ height:1em;
+ border:1px solid #E0E0E0;
+ background-color:#FFF;
+}
+
+.yui-calendar td.calcell a {
+ color:#003DB8;
+ text-decoration:none;
+}
+
+.yui-calendar td.calcell.today {
+ border:1px solid #000;
+}
+
+.yui-calendar td.calcell.oom {
+ cursor:default;
+ color:#999;
+ background-color:#EEE;
+ border:1px solid #E0E0E0;
+}
+
+.yui-calendar td.calcell.selected {
+ color:#003DB8;
+ background-color:#FFF19F;
+ border:1px solid #FF9900;
+}
+
+.yui-calendar td.calcell.calcellhover {
+ cursor:pointer;
+ color:#FFF;
+ background-color:#FF9900;
+ border:1px solid #FF9900;
+}
+
+/* Added to perform some correction for Opera 8.5
+ hover redraw bug */
+table.yui-calendar:hover {
+ background-color:#FFF;
+}
+
+.yui-calendar td.calcell.calcellhover a {
+ color:#FFF;
+}
+
+.yui-calendar td.calcell.restricted {
+ text-decoration:line-through;
+}
+
+.yui-calendar td.calcell.previous {
+ color:#CCC;
+}
+
+.yui-calendar td.calcell.highlight1 { background-color:#CCFF99; }
+.yui-calendar td.calcell.highlight2 { background-color:#99CCFF; }
+.yui-calendar td.calcell.highlight3 { background-color:#FFCCCC; }
+.yui-calendar td.calcell.highlight4 { background-color:#CCFF99; }
+
+
+.yui-calendar .calhead {
+ border:1px solid #E0E0E0;
+ vertical-align:middle;
+ background-color:#FFF;
+}
+
+.yui-calendar .calheader {
+ position:relative;
+ width:100%;
+ text-align:center;
+}
+
+.yui-calendar .calheader img {
+ border:none;
+}
+
+.yui-calendar .calweekdaycell {
+ color:#666;
+ font-weight:normal;
+}
+
+.yui-calendar .calfoot {
+ background-color:#EEE;
+}
+
+.yui-calendar .calrowhead, .yui-calendar .calrowfoot {
+ color:#666;
+ font-size:9px;
+ font-style:italic;
+ font-weight:normal;
+ width:15px;
+}
+
+.yui-calendar .calrowhead {
+ border-right-width:2px;
+}
+
+/*Specific changes for calendar running under fonts/reset */
+.yui-calendar a:hover {background:inherit;}
+p#clear {clear:left; padding-top:10px;}
Added: branches/tomek/portal-dnd/dndRenderer.war/js/calendar/assets/callt.gif
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/dndRenderer.war/js/calendar/assets/callt.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/dndRenderer.war/js/calendar/assets/calrt.gif
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/dndRenderer.war/js/calendar/assets/calrt.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/dndRenderer.war/js/calendar/assets/calx.gif
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/dndRenderer.war/js/calendar/assets/calx.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/dndRenderer.war/js/calendar/calendar-debug.js
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/calendar/calendar-debug.js 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/calendar/calendar-debug.js 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,2918 @@
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+Version 0.11.0
+*/
+
+/**
+* @class
+* <p>YAHOO.widget.DateMath is used for simple date manipulation. The class is a static utility
+* used for adding, subtracting, and comparing dates.</p>
+*/
+YAHOO.widget.DateMath = new function() {
+
+ /**
+ * Constant field representing Day
+ * @type String
+ */
+ this.DAY = "D";
+
+ /**
+ * Constant field representing Week
+ * @type String
+ */
+ this.WEEK = "W";
+
+ /**
+ * Constant field representing Year
+ * @type String
+ */
+ this.YEAR = "Y";
+
+ /**
+ * Constant field representing Month
+ * @type String
+ */
+ this.MONTH = "M";
+
+ /**
+ * Constant field representing one day, in milliseconds
+ * @type Integer
+ */
+ this.ONE_DAY_MS = 1000*60*60*24;
+
+ /**
+ * Adds the specified amount of time to the this instance.
+ * @param {Date} date The JavaScript Date object to perform addition on
+ * @param {string} field The this field constant to be used for performing addition.
+ * @param {Integer} amount The number of units (measured in the field constant) to add to the date.
+ */
+ this.add = function(date, field, amount) {
+ var d = new Date(date.getTime());
+ switch (field) {
+ case this.MONTH:
+ var newMonth = date.getMonth() + amount;
+ var years = 0;
+
+
+ if (newMonth < 0) {
+ while (newMonth < 0) {
+ newMonth += 12;
+ years -= 1;
+ }
+ } else if (newMonth > 11) {
+ while (newMonth > 11) {
+ newMonth -= 12;
+ years += 1;
+ }
+ }
+
+ d.setMonth(newMonth);
+ d.setFullYear(date.getFullYear() + years);
+ break;
+ case this.DAY:
+ d.setDate(date.getDate() + amount);
+ break;
+ case this.YEAR:
+ d.setFullYear(date.getFullYear() + amount);
+ break;
+ case this.WEEK:
+ d.setDate(date.getDate() + (amount * 7));
+ break;
+ }
+ return d;
+ };
+
+ /**
+ * Subtracts the specified amount of time from the this instance.
+ * @param {Date} date The JavaScript Date object to perform subtraction on
+ * @param {Integer} field The this field constant to be used for performing subtraction.
+ * @param {Integer} amount The number of units (measured in the field constant) to subtract from the date.
+ */
+ this.subtract = function(date, field, amount) {
+ return this.add(date, field, (amount*-1));
+ };
+
+ /**
+ * Determines whether a given date is before another date on the calendar.
+ * @param {Date} date The Date object to compare with the compare argument
+ * @param {Date} compareTo The Date object to use for the comparison
+ * @return {Boolean} true if the date occurs before the compared date; false if not.
+ */
+ this.before = function(date, compareTo) {
+ var ms = compareTo.getTime();
+ if (date.getTime() < ms) {
+ return true;
+ } else {
+ return false;
+ }
+ };
+
+ /**
+ * Determines whether a given date is after another date on the calendar.
+ * @param {Date} date The Date object to compare with the compare argument
+ * @param {Date} compareTo The Date object to use for the comparison
+ * @return {Boolean} true if the date occurs after the compared date; false if not.
+ */
+ this.after = function(date, compareTo) {
+ var ms = compareTo.getTime();
+ if (date.getTime() > ms) {
+ return true;
+ } else {
+ return false;
+ }
+ };
+
+ /**
+ * Determines whether a given date is between two other dates on the calendar.
+ * @param {Date} date The date to check for
+ * @param {Date} dateBegin The start of the range
+ * @param {Date} dateEnd The end of the range
+ * @return {Boolean} true if the date occurs between the compared dates; false if not.
+ */
+ this.between = function(date, dateBegin, dateEnd) {
+ if (this.after(date, dateBegin) && this.before(date, dateEnd)) {
+ return true;
+ } else {
+ return false;
+ }
+ };
+
+ /**
+ * Retrieves a JavaScript Date object representing January 1 of any given year.
+ * @param {Integer} calendarYear The calendar year for which to retrieve January 1
+ * @return {Date} January 1 of the calendar year specified.
+ */
+ this.getJan1 = function(calendarYear) {
+ return new Date(calendarYear,0,1);
+ };
+
+ /**
+ * Calculates the number of days the specified date is from January 1 of the specified calendar year.
+ * Passing January 1 to this function would return an offset value of zero.
+ * @param {Date} date The JavaScript date for which to find the offset
+ * @param {Integer} calendarYear The calendar year to use for determining the offset
+ * @return {Integer} The number of days since January 1 of the given year
+ */
+ this.getDayOffset = function(date, calendarYear) {
+ var beginYear = this.getJan1(calendarYear); // Find the start of the year. This will be in week 1.
+
+ // Find the number of days the passed in date is away from the calendar year start
+ var dayOffset = Math.ceil((date.getTime()-beginYear.getTime()) / this.ONE_DAY_MS);
+ return dayOffset;
+ };
+
+ /**
+ * Calculates the week number for the given date. This function assumes that week 1 is the
+ * week in which January 1 appears, regardless of whether the week consists of a full 7 days.
+ * The calendar year can be specified to help find what a the week number would be for a given
+ * date if the date overlaps years. For instance, a week may be considered week 1 of 2005, or
+ * week 53 of 2004. Specifying the optional calendarYear allows one to make this distinction
+ * easily.
+ * @param {Date} date The JavaScript date for which to find the week number
+ * @param {Integer} calendarYear OPTIONAL - The calendar year to use for determining the week number. Default is
+ * the calendar year of parameter "date".
+ * @param {Integer} weekStartsOn OPTIONAL - The integer (0-6) representing which day a week begins on. Default is 0 (for Sunday).
+ * @return {Integer} The week number of the given date.
+ */
+ this.getWeekNumber = function(date, calendarYear, weekStartsOn) {
+ date.setHours(12,0,0,0);
+
+ if (! weekStartsOn) {
+ weekStartsOn = 0;
+ }
+ if (! calendarYear) {
+ calendarYear = date.getFullYear();
+ }
+
+ var weekNum = -1;
+
+ var jan1 = this.getJan1(calendarYear);
+
+ var jan1Offset = jan1.getDay() - weekStartsOn;
+ var jan1DayOfWeek = (jan1Offset >= 0 ? jan1Offset : (7 + jan1Offset));
+
+ var endOfWeek1 = this.add(jan1, this.DAY, (6 - jan1DayOfWeek));
+ endOfWeek1.setHours(23,59,59,999);
+
+ var month = date.getMonth();
+ var day = date.getDate();
+ var year = date.getFullYear();
+
+ var dayOffset = this.getDayOffset(date, calendarYear); // Days since Jan 1, Calendar Year
+
+ if (dayOffset < 0 || this.before(date, endOfWeek1)) {
+ weekNum = 1;
+ } else {
+ weekNum = 2;
+ var weekBegin = new Date(endOfWeek1.getTime() + 1);
+ var weekEnd = this.add(weekBegin, this.WEEK, 1);
+
+ while (! this.between(date, weekBegin, weekEnd)) {
+ weekBegin = this.add(weekBegin, this.WEEK, 1);
+ weekEnd = this.add(weekEnd, this.WEEK, 1);
+ weekNum += 1;
+ }
+ }
+
+ return weekNum;
+ };
+
+ /**
+ * Determines if a given week overlaps two different years.
+ * @param {Date} weekBeginDate The JavaScript Date representing the first day of the week.
+ * @return {Boolean} true if the date overlaps two different years.
+ */
+ this.isYearOverlapWeek = function(weekBeginDate) {
+ var overlaps = false;
+ var nextWeek = this.add(weekBeginDate, this.DAY, 6);
+ if (nextWeek.getFullYear() != weekBeginDate.getFullYear()) {
+ overlaps = true;
+ }
+ return overlaps;
+ };
+
+ /**
+ * Determines if a given week overlaps two different months.
+ * @param {Date} weekBeginDate The JavaScript Date representing the first day of the week.
+ * @return {Boolean} true if the date overlaps two different months.
+ */
+ this.isMonthOverlapWeek = function(weekBeginDate) {
+ var overlaps = false;
+ var nextWeek = this.add(weekBeginDate, this.DAY, 6);
+ if (nextWeek.getMonth() != weekBeginDate.getMonth()) {
+ overlaps = true;
+ }
+ return overlaps;
+ };
+
+ /**
+ * Gets the first day of a month containing a given date.
+ * @param {Date} date The JavaScript Date used to calculate the month start
+ * @return {Date} The JavaScript Date representing the first day of the month
+ */
+ this.findMonthStart = function(date) {
+ var start = new Date(date.getFullYear(), date.getMonth(), 1);
+ return start;
+ };
+
+ /**
+ * Gets the last day of a month containing a given date.
+ * @param {Date} date The JavaScript Date used to calculate the month end
+ * @return {Date} The JavaScript Date representing the last day of the month
+ */
+ this.findMonthEnd = function(date) {
+ var start = this.findMonthStart(date);
+ var nextMonth = this.add(start, this.MONTH, 1);
+ var end = this.subtract(nextMonth, this.DAY, 1);
+ return end;
+ };
+
+ /**
+ * Clears the time fields from a given date, effectively setting the time to midnight.
+ * @param {Date} date The JavaScript Date for which the time fields will be cleared
+ * @return {Date} The JavaScript Date cleared of all time fields
+ */
+ this.clearTime = function(date) {
+ date.setHours(0,0,0,0);
+ return date;
+ };
+}/**
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+**/
+
+/**
+* @class
+* <p>Calendar_Core is the base class for the Calendar widget. In its most basic
+* implementation, it has the ability to render a calendar widget on the page
+* that can be manipulated to select a single date, move back and forth between
+* months and years.</p>
+* <p>To construct the placeholder for the calendar widget, the code is as
+* follows:
+* <xmp>
+* <div id="cal1Container"></div>
+* </xmp>
+* Note that the table can be replaced with any kind of element.
+* </p>
+* @constructor
+* @param {String} id The id of the table element that will represent the calendar widget
+* @param {String} containerId The id of the container element that will contain the calendar table
+* @param {String} monthyear The month/year string used to set the current calendar page
+* @param {String} selected A string of date values formatted using the date parser. The built-in
+ default date format is MM/DD/YYYY. Ranges are defined using
+ MM/DD/YYYY-MM/DD/YYYY. Month/day combinations are defined using MM/DD.
+ Any combination of these can be combined by delimiting the string with
+ commas. Example: "12/24/2005,12/25,1/18/2006-1/21/2006"
+*/
+YAHOO.widget.Calendar_Core = function(id, containerId, monthyear, selected) {
+ if (arguments.length > 0) {
+ if (! id) {
+ YAHOO.log("No ID specified", "error");
+ }
+ if (! containerId) {
+ YAHOO.log("No container ID specified", "error");
+ }
+ this.init(id, containerId, monthyear, selected);
+ }
+}
+
+/**
+* The path to be used for images loaded for the Calendar
+* @type String
+*/
+YAHOO.widget.Calendar_Core.IMG_ROOT = (window.location.href.toLowerCase().indexOf("https") == 0 ? "https://a248.e.akamai.net/sec.yimg.com/i/" : "http://us.i1.yimg.com/us.yimg.com/i/");
+
+/**
+* Type constant used for renderers to represent an individual date (M/D/Y)
+* @final
+* @type String
+*/
+YAHOO.widget.Calendar_Core.DATE = "D";
+
+/**
+* Type constant used for renderers to represent an individual date across any year (M/D)
+* @final
+* @type String
+*/
+YAHOO.widget.Calendar_Core.MONTH_DAY = "MD";
+
+/**
+* Type constant used for renderers to represent a weekday
+* @final
+* @type String
+*/
+YAHOO.widget.Calendar_Core.WEEKDAY = "WD";
+
+/**
+* Type constant used for renderers to represent a range of individual dates (M/D/Y-M/D/Y)
+* @final
+* @type String
+*/
+YAHOO.widget.Calendar_Core.RANGE = "R";
+
+/**
+* Type constant used for renderers to represent a month across any year
+* @final
+* @type String
+*/
+YAHOO.widget.Calendar_Core.MONTH = "M";
+
+/**
+* Constant that represents the total number of date cells that are displayed in a given month
+* including
+* @final
+* @type Integer
+*/
+YAHOO.widget.Calendar_Core.DISPLAY_DAYS = 42;
+
+/**
+* Constant used for halting the execution of the remainder of the render stack
+* @final
+* @type String
+*/
+YAHOO.widget.Calendar_Core.STOP_RENDER = "S";
+
+YAHOO.widget.Calendar_Core.prototype = {
+
+ /**
+ * The configuration object used to set up the calendars various locale and style options.
+ * @type Object
+ */
+ Config : null,
+
+ /**
+ * The parent CalendarGroup, only to be set explicitly by the parent group
+ * @type CalendarGroup
+ */
+ parent : null,
+
+ /**
+ * The index of this item in the parent group
+ * @type Integer
+ */
+ index : -1,
+
+ /**
+ * The collection of calendar table cells
+ * @type HTMLTableCellElement[]
+ */
+ cells : null,
+
+ /**
+ * The collection of calendar week header cells
+ * @type HTMLTableCellElement[]
+ */
+ weekHeaderCells : null,
+
+ /**
+ * The collection of calendar week footer cells
+ * @type HTMLTableCellElement[]
+ */
+ weekFooterCells : null,
+
+ /**
+ * The collection of calendar cell dates that is parallel to the cells collection. The array contains dates field arrays in the format of [YYYY, M, D].
+ * @type Array[](Integer[])
+ */
+ cellDates : null,
+
+ /**
+ * The id that uniquely identifies this calendar. This id should match the id of the placeholder element on the page.
+ * @type String
+ */
+ id : null,
+
+ /**
+ * The DOM element reference that points to this calendar's container element. The calendar will be inserted into this element when the shell is rendered.
+ * @type HTMLElement
+ */
+ oDomContainer : null,
+
+ /**
+ * A Date object representing today's date.
+ * @type Date
+ */
+ today : null,
+
+ /**
+ * The list of render functions, along with required parameters, used to render cells.
+ * @type Array[]
+ */
+ renderStack : null,
+
+ /**
+ * A copy of the initial render functions created before rendering.
+ * @type Array
+ * @private
+ */
+ _renderStack : null,
+
+ /**
+ * A Date object representing the month/year that the calendar is currently set to
+ * @type Date
+ */
+ pageDate : null,
+
+ /**
+ * A Date object representing the month/year that the calendar is initially set to
+ * @type Date
+ * @private
+ */
+ _pageDate : null,
+
+ /**
+ * A Date object representing the minimum selectable date
+ * @type Date
+ */
+ minDate : null,
+
+ /**
+ * A Date object representing the maximum selectable date
+ * @type Date
+ */
+ maxDate : null,
+
+ /**
+ * The list of currently selected dates. The data format for this local collection is
+ * an array of date field arrays, e.g:
+ * [
+ * [2004,5,25],
+ * [2004,5,26]
+ * ]
+ * @type Array[](Integer[])
+ */
+ selectedDates : null,
+
+ /**
+ * The private list of initially selected dates.
+ * @type Array
+ * @private
+ */
+ _selectedDates : null,
+
+ /**
+ * A boolean indicating whether the shell of the calendar has already been rendered to the page
+ * @type Boolean
+ */
+ shellRendered : false,
+
+ /**
+ * The HTML table element that represents this calendar
+ * @type HTMLTableElement
+ */
+ table : null,
+
+ /**
+ * The HTML cell element that represents the main header cell TH used in the calendar table
+ * @type HTMLTableCellElement
+ */
+ headerCell : null
+};
+
+
+
+/**
+* Initializes the calendar widget. This method must be called by all subclass constructors.
+* @param {String} id The id of the table element that will represent the calendar widget
+* @param {String} containerId The id of the container element that will contain the calendar table
+* @param {String} monthyear The month/year string used to set the current calendar page
+* @param {String} selected A string of date values formatted using the date parser. The built-in
+ default date format is MM/DD/YYYY. Ranges are defined using
+ MM/DD/YYYY-MM/DD/YYYY. Month/day combinations are defined using MM/DD.
+ Any combination of these can be combined by delimiting the string with
+ commas. Example: "12/24/2005,12/25,1/18/2006-1/21/2006"
+*/
+YAHOO.widget.Calendar_Core.prototype.init = function(id, containerId, monthyear, selected) {
+
+ this.logger = new YAHOO.widget.LogWriter("Calendar_Core " + id);
+
+ this.setupConfig();
+
+ this.id = id;
+
+ this.cellDates = new Array();
+
+ this.cells = new Array();
+
+ this.renderStack = new Array();
+ this._renderStack = new Array();
+
+ this.oDomContainer = document.getElementById(containerId);
+
+ if (! this.oDomContainer) {
+ this.logger.log("No valid container present.", "error");
+ }
+
+ this.today = new Date();
+ YAHOO.widget.DateMath.clearTime(this.today);
+
+ var month;
+ var year;
+
+ if (monthyear) {
+ var aMonthYear = monthyear.split(this.Locale.DATE_FIELD_DELIMITER);
+ month = parseInt(aMonthYear[this.Locale.MY_MONTH_POSITION-1]);
+ year = parseInt(aMonthYear[this.Locale.MY_YEAR_POSITION-1]);
+ } else {
+ month = this.today.getMonth()+1;
+ year = this.today.getFullYear();
+ }
+
+ this.logger.log("Initialized with month/year of " + month + "/" + year, "info");
+
+ this.pageDate = new Date(year, month-1, 1);
+ this._pageDate = new Date(this.pageDate.getTime());
+
+ if (selected) {
+ this.selectedDates = this._parseDates(selected);
+ this._selectedDates = this.selectedDates.concat();
+ } else {
+ this.selectedDates = new Array();
+ this._selectedDates = new Array();
+ }
+
+ this.wireDefaultEvents();
+ this.wireCustomEvents();
+};
+
+
+/**
+* Wires the local DOM events for the Calendar, including cell selection, hover, and
+* default navigation that is used for moving back and forth between calendar pages.
+*/
+YAHOO.widget.Calendar_Core.prototype.wireDefaultEvents = function() {
+
+ /**
+ * The default event function that is attached to a date link within a calendar cell
+ * when the calendar is rendered.
+ * @param e The event
+ * @param cal A reference to the calendar passed by the Event utility
+ */
+ this.doSelectCell = function(e, cal) {
+ var cell = this;
+ var index = cell.index;
+
+ cal.logger.log("Selecting cell " + index + " via click", "info");
+
+ var d = cal.cellDates[index];
+ var date = new Date(d[0],d[1]-1,d[2]);
+
+ if (! cal.isDateOOM(date) && ! YAHOO.util.Dom.hasClass(cell, cal.Style.CSS_CELL_RESTRICTED) && ! YAHOO.util.Dom.hasClass(cell, cal.Style.CSS_CELL_OOB)) {
+ if (cal.Options.MULTI_SELECT) {
+ var link = cell.getElementsByTagName("A")[0];
+ link.blur();
+
+ var cellDate = cal.cellDates[index];
+ var cellDateIndex = cal._indexOfSelectedFieldArray(cellDate);
+
+ if (cellDateIndex > -1) {
+ cal.deselectCell(index);
+ } else {
+ cal.selectCell(index);
+ }
+
+ } else {
+ var link = cell.getElementsByTagName("A")[0];
+ link.blur()
+ cal.selectCell(index);
+ }
+ }
+ }
+
+ /**
+ * The event that is executed when the user hovers over a cell
+ * @param e The event
+ * @param cal A reference to the calendar passed by the Event utility
+ * @private
+ */
+ this.doCellMouseOver = function(e, cal) {
+ var cell = this;
+ var index = cell.index;
+ var d = cal.cellDates[index];
+ var date = new Date(d[0],d[1]-1,d[2]);
+
+ if (! cal.isDateOOM(date) && ! YAHOO.util.Dom.hasClass(cell, cal.Style.CSS_CELL_RESTRICTED) && ! YAHOO.util.Dom.hasClass(cell, cal.Style.CSS_CELL_OOB)) {
+ YAHOO.util.Dom.addClass(cell, cal.Style.CSS_CELL_HOVER);
+ }
+ }
+
+ /**
+ * The event that is executed when the user moves the mouse out of a cell
+ * @param e The event
+ * @param cal A reference to the calendar passed by the Event utility
+ * @private
+ */
+ this.doCellMouseOut = function(e, cal) {
+ YAHOO.util.Dom.removeClass(this, cal.Style.CSS_CELL_HOVER);
+ }
+
+ /**
+ * A wrapper event that executes the nextMonth method through a DOM event
+ * @param e The event
+ * @param cal A reference to the calendar passed by the Event utility
+ * @private
+ */
+ this.doNextMonth = function(e, cal) {
+ cal.nextMonth();
+ }
+
+ /**
+ * A wrapper event that executes the previousMonth method through a DOM event
+ * @param e The event
+ * @param cal A reference to the calendar passed by the Event utility
+ * @private
+ */
+ this.doPreviousMonth = function(e, cal) {
+ cal.previousMonth();
+ }
+}
+
+/**
+* This function can be extended by subclasses to attach additional DOM events to
+* the calendar. By default, this method is unimplemented.
+*/
+YAHOO.widget.Calendar_Core.prototype.wireCustomEvents = function() { }
+
+/**
+This method is called to initialize the widget configuration variables, including
+style, localization, and other display and behavioral options.
+<p>Config: Container for the CSS style configuration variables.</p>
+<p><strong>Config.Style</strong> - Defines the CSS classes used for different calendar elements</p>
+<blockquote>
+ <div><em>CSS_CALENDAR</em> : Container table</div>
+ <div><em>CSS_HEADER</em> : </div>
+ <div><em>CSS_HEADER_TEXT</em> : Calendar header</div>
+ <div><em>CSS_FOOTER</em> : Calendar footer</div>
+ <div><em>CSS_CELL</em> : Calendar day cell</div>
+ <div><em>CSS_CELL_OOM</em> : Calendar OOM (out of month) cell</div>
+ <div><em>CSS_CELL_SELECTED</em> : Calendar selected cell</div>
+ <div><em>CSS_CELL_RESTRICTED</em> : Calendar restricted cell</div>
+ <div><em>CSS_CELL_TODAY</em> : Calendar cell for today's date</div>
+ <div><em>CSS_ROW_HEADER</em> : The cell preceding a row (used for week number by default)</div>
+ <div><em>CSS_ROW_FOOTER</em> : The cell following a row (not implemented by default)</div>
+ <div><em>CSS_WEEKDAY_CELL</em> : The cells used for labeling weekdays</div>
+ <div><em>CSS_WEEKDAY_ROW</em> : The row containing the weekday label cells</div>
+ <div><em>CSS_CONTAINER</em> : The border style used for the default UED rendering</div>
+ <div><em>CSS_2UPWRAPPER</em> : Special container class used to properly adjust the sizing and float</div>
+ <div><em>CSS_NAV_LEFT</em> : Left navigation arrow</div>
+ <div><em>CSS_NAV_RIGHT</em> : Right navigation arrow</div>
+ <div><em>CSS_CELL_TOP</em> : Outlying cell along the top row</div>
+ <div><em>CSS_CELL_LEFT</em> : Outlying cell along the left row</div>
+ <div><em>CSS_CELL_RIGHT</em> : Outlying cell along the right row</div>
+ <div><em>CSS_CELL_BOTTOM</em> : Outlying cell along the bottom row</div>
+ <div><em>CSS_CELL_HOVER</em> : Cell hover style</div>
+ <div><em>CSS_CELL_HIGHLIGHT1</em> : Highlight color 1 for styling cells</div>
+ <div><em>CSS_CELL_HIGHLIGHT2</em> : Highlight color 2 for styling cells</div>
+ <div><em>CSS_CELL_HIGHLIGHT3</em> : Highlight color 3 for styling cells</div>
+ <div><em>CSS_CELL_HIGHLIGHT4</em> : Highlight color 4 for styling cells</div>
+
+</blockquote>
+<p><strong>Config.Locale</strong> - Defines the locale string arrays used for localization</p>
+<blockquote>
+ <div><em>MONTHS_SHORT</em> : Array of 12 months in short format ("Jan", "Feb", etc.)</div>
+ <div><em>MONTHS_LONG</em> : Array of 12 months in short format ("Jan", "Feb", etc.)</div>
+ <div><em>WEEKDAYS_1CHAR</em> : Array of 7 days in 1-character format ("S", "M", etc.)</div>
+ <div><em>WEEKDAYS_SHORT</em> : Array of 7 days in short format ("Su", "Mo", etc.)</div>
+ <div><em>WEEKDAYS_MEDIUM</em> : Array of 7 days in medium format ("Sun", "Mon", etc.)</div>
+ <div><em>WEEKDAYS_LONG</em> : Array of 7 days in long format ("Sunday", "Monday", etc.)</div>
+ <div><em>DATE_DELIMITER</em> : The value used to delimit series of multiple dates (Default: ",")</div>
+ <div><em>DATE_FIELD_DELIMITER</em> : The value used to delimit date fields (Default: "/")</div>
+ <div><em>DATE_RANGE_DELIMITER</em> : The value used to delimit date fields (Default: "-")</div>
+ <div><em>MY_MONTH_POSITION</em> : The value used to determine the position of the month in a month/year combo (e.g. 12/2005) (Default: 1)</div>
+ <div><em>MY_YEAR_POSITION</em> : The value used to determine the position of the year in a month/year combo (e.g. 12/2005) (Default: 2)</div>
+ <div><em>MD_MONTH_POSITION</em> : The value used to determine the position of the month in a month/day combo (e.g. 12/25) (Default: 1)</div>
+ <div><em>MD_DAY_POSITION</em> : The value used to determine the position of the day in a month/day combo (e.g. 12/25) (Default: 2)</div>
+ <div><em>MDY_MONTH_POSITION</em> : The value used to determine the position of the month in a month/day/year combo (e.g. 12/25/2005) (Default: 1)</div>
+ <div><em>MDY_DAY_POSITION</em> : The value used to determine the position of the day in a month/day/year combo (e.g. 12/25/2005) (Default: 2)</div>
+ <div><em>MDY_YEAR_POSITION</em> : The value used to determine the position of the year in a month/day/year combo (e.g. 12/25/2005) (Default: 3)</div>
+</blockquote>
+<p><strong>Config.Options</strong> - Defines other configurable calendar widget options</p>
+<blockquote>
+ <div><em>SHOW_WEEKDAYS</em> : Boolean, determines whether to display the weekday headers (defaults to true)</div>
+ <div><em>LOCALE_MONTHS</em> : Array, points to the desired Config.Locale array (defaults to Config.Locale.MONTHS_LONG)</div>
+ <div><em>LOCALE_WEEKDAYS</em> : Array, points to the desired Config.Locale array (defaults to Config.Locale.WEEKDAYS_SHORT)</div>
+ <div><em>START_WEEKDAY</em> : Integer, 0-6, representing the day that a week begins on</div>
+ <div><em>SHOW_WEEK_HEADER</em> : Boolean, determines whether to display row headers</div>
+ <div><em>SHOW_WEEK_FOOTER</em> : Boolean, determines whether to display row footers</div>
+ <div><em>HIDE_BLANK_WEEKS</em> : Boolean, determines whether to hide extra weeks that are completely OOM</div>
+ <div><em>NAV_ARROW_LEFT</em> : String, the image path used for the left navigation arrow</div>
+ <div><em>NAV_ARROW_RIGHT</em> : String, the image path used for the right navigation arrow</div>
+</blockquote>
+*/
+YAHOO.widget.Calendar_Core.prototype.setupConfig = function() {
+ /**
+ * Container for the CSS style configuration variables.
+ */
+ this.Config = new Object();
+
+ this.Config.Style = {
+ // Style variables
+ CSS_ROW_HEADER: "calrowhead",
+ CSS_ROW_FOOTER: "calrowfoot",
+ CSS_CELL : "calcell",
+ CSS_CELL_SELECTED : "selected",
+ CSS_CELL_RESTRICTED : "restricted",
+ CSS_CELL_TODAY : "today",
+ CSS_CELL_OOM : "oom",
+ CSS_CELL_OOB : "previous",
+ CSS_HEADER : "calheader",
+ CSS_HEADER_TEXT : "calhead",
+ CSS_WEEKDAY_CELL : "calweekdaycell",
+ CSS_WEEKDAY_ROW : "calweekdayrow",
+ CSS_FOOTER : "calfoot",
+ CSS_CALENDAR : "yui-calendar",
+ CSS_CONTAINER : "yui-calcontainer",
+ CSS_2UPWRAPPER : "yui-cal2upwrapper",
+ CSS_NAV_LEFT : "calnavleft",
+ CSS_NAV_RIGHT : "calnavright",
+ CSS_CELL_TOP : "calcelltop",
+ CSS_CELL_LEFT : "calcellleft",
+ CSS_CELL_RIGHT : "calcellright",
+ CSS_CELL_BOTTOM : "calcellbottom",
+ CSS_CELL_HOVER : "calcellhover",
+ CSS_CELL_HIGHLIGHT1 : "highlight1",
+ CSS_CELL_HIGHLIGHT2 : "highlight2",
+ CSS_CELL_HIGHLIGHT3 : "highlight3",
+ CSS_CELL_HIGHLIGHT4 : "highlight4"
+ };
+
+ this.Style = this.Config.Style;
+
+ this.Config.Locale = {
+ // Locale definition
+ MONTHS_SHORT : ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
+ MONTHS_LONG : ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
+ WEEKDAYS_1CHAR : ["S", "M", "T", "W", "T", "F", "S"],
+ WEEKDAYS_SHORT : ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
+ WEEKDAYS_MEDIUM : ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
+ WEEKDAYS_LONG : ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
+ DATE_DELIMITER : ",",
+ DATE_FIELD_DELIMITER : "/",
+ DATE_RANGE_DELIMITER : "-",
+ MY_MONTH_POSITION : 1,
+ MY_YEAR_POSITION : 2,
+ MD_MONTH_POSITION : 1,
+ MD_DAY_POSITION : 2,
+ MDY_MONTH_POSITION : 1,
+ MDY_DAY_POSITION : 2,
+ MDY_YEAR_POSITION : 3
+ };
+
+ this.Locale = this.Config.Locale;
+
+ this.Config.Options = {
+ // Configuration variables
+ MULTI_SELECT : false,
+ SHOW_WEEKDAYS : true,
+ START_WEEKDAY : 0,
+ SHOW_WEEK_HEADER : false,
+ SHOW_WEEK_FOOTER : false,
+ HIDE_BLANK_WEEKS : false,
+ NAV_ARROW_LEFT : YAHOO.widget.Calendar_Core.IMG_ROOT + "us/tr/callt.gif",
+ NAV_ARROW_RIGHT : YAHOO.widget.Calendar_Core.IMG_ROOT + "us/tr/calrt.gif"
+ };
+
+ this.Options = this.Config.Options;
+
+ this.customConfig();
+
+ if (! this.Options.LOCALE_MONTHS) {
+ this.Options.LOCALE_MONTHS=this.Locale.MONTHS_LONG;
+ }
+ if (! this.Options.LOCALE_WEEKDAYS) {
+ this.Options.LOCALE_WEEKDAYS=this.Locale.WEEKDAYS_SHORT;
+ }
+
+ // If true, reconfigure weekday arrays to place Mondays first
+ if (this.Options.START_WEEKDAY > 0) {
+ for (var w=0;w<this.Options.START_WEEKDAY;++w) {
+ this.Locale.WEEKDAYS_SHORT.push(this.Locale.WEEKDAYS_SHORT.shift());
+ this.Locale.WEEKDAYS_MEDIUM.push(this.Locale.WEEKDAYS_MEDIUM.shift());
+ this.Locale.WEEKDAYS_LONG.push(this.Locale.WEEKDAYS_LONG.shift());
+ }
+ }
+};
+
+/**
+* This method is called when subclasses need to override configuration variables
+* or create new ones. Values can be explicitly set as follows:
+* <blockquote><code>
+* this.Config.Style.CSS_CELL = "newcalcell";
+* this.Config.Locale.MONTHS_SHORT = ["Jan", "Fv", "Mars", "Avr", "Mai", "Juin", "Juil", "Aot", "Sept", "Oct", "Nov", "Dc"];
+* </code></blockquote>
+*/
+YAHOO.widget.Calendar_Core.prototype.customConfig = function() { };
+
+/**
+* Builds the date label that will be displayed in the calendar header or
+* footer, depending on configuration.
+* @return The formatted calendar month label
+* @type String
+*/
+YAHOO.widget.Calendar_Core.prototype.buildMonthLabel = function() {
+ var text = this.Options.LOCALE_MONTHS[this.pageDate.getMonth()] + " " + this.pageDate.getFullYear();
+ return text;
+};
+
+/**
+* Builds the date digit that will be displayed in calendar cells
+* @return The formatted day label
+* @type String
+*/
+YAHOO.widget.Calendar_Core.prototype.buildDayLabel = function(workingDate) {
+ var day = workingDate.getDate();
+ return day;
+};
+
+
+
+/**
+* Builds the calendar table shell that will be filled in with dates and formatting.
+* This method calls buildShellHeader, buildShellBody, and buildShellFooter (in that order)
+* to construct the pieces of the calendar table. The construction of the shell should
+* only happen one time when the calendar is initialized.
+*/
+YAHOO.widget.Calendar_Core.prototype.buildShell = function() {
+
+ this.table = document.createElement("TABLE");
+ this.table.cellSpacing = 0;
+ YAHOO.widget.Calendar_Core.setCssClasses(this.table, [this.Style.CSS_CALENDAR]);
+
+ this.table.id = this.id;
+
+ this.buildShellHeader();
+ this.buildShellBody();
+ this.buildShellFooter();
+
+ YAHOO.util.Event.addListener(window, "unload", this._unload, this);
+};
+
+/**
+* Builds the calendar shell header by inserting a THEAD into the local calendar table.
+*/
+YAHOO.widget.Calendar_Core.prototype.buildShellHeader = function() {
+ var head = document.createElement("THEAD");
+ var headRow = document.createElement("TR");
+
+ var headerCell = document.createElement("TH");
+
+ var colSpan = 7;
+ if (this.Config.Options.SHOW_WEEK_HEADER) {
+ this.weekHeaderCells = new Array();
+ colSpan += 1;
+ }
+ if (this.Config.Options.SHOW_WEEK_FOOTER) {
+ this.weekFooterCells = new Array();
+ colSpan += 1;
+ }
+
+ headerCell.colSpan = colSpan;
+
+ YAHOO.widget.Calendar_Core.setCssClasses(headerCell,[this.Style.CSS_HEADER_TEXT]);
+
+ this.headerCell = headerCell;
+
+ headRow.appendChild(headerCell);
+ head.appendChild(headRow);
+
+ // Append day labels, if needed
+ if (this.Options.SHOW_WEEKDAYS) {
+ var row = document.createElement("TR");
+ var fillerCell;
+
+ YAHOO.widget.Calendar_Core.setCssClasses(row,[this.Style.CSS_WEEKDAY_ROW]);
+
+ if (this.Config.Options.SHOW_WEEK_HEADER) {
+ fillerCell = document.createElement("TH");
+ YAHOO.widget.Calendar_Core.setCssClasses(fillerCell,[this.Style.CSS_WEEKDAY_CELL]);
+ row.appendChild(fillerCell);
+ }
+
+ for(var i=0;i<this.Options.LOCALE_WEEKDAYS.length;++i) {
+ var cell = document.createElement("TH");
+ YAHOO.widget.Calendar_Core.setCssClasses(cell,[this.Style.CSS_WEEKDAY_CELL]);
+ cell.innerHTML=this.Options.LOCALE_WEEKDAYS[i];
+ row.appendChild(cell);
+ }
+
+ if (this.Config.Options.SHOW_WEEK_FOOTER) {
+ fillerCell = document.createElement("TH");
+ YAHOO.widget.Calendar_Core.setCssClasses(fillerCell,[this.Style.CSS_WEEKDAY_CELL]);
+ row.appendChild(fillerCell);
+ }
+
+ head.appendChild(row);
+ }
+
+ this.table.appendChild(head);
+};
+
+/**
+* Builds the calendar shell body (6 weeks by 7 days)
+*/
+YAHOO.widget.Calendar_Core.prototype.buildShellBody = function() {
+ // This should only get executed once
+ this.tbody = document.createElement("TBODY");
+
+ for (var r=0;r<6;++r) {
+ var row = document.createElement("TR");
+
+ for (var c=0;c<this.headerCell.colSpan;++c) {
+ var cell;
+ if (this.Config.Options.SHOW_WEEK_HEADER && c===0) { // Row header
+ cell = document.createElement("TH");
+ this.weekHeaderCells[this.weekHeaderCells.length] = cell;
+ } else if (this.Config.Options.SHOW_WEEK_FOOTER && c==(this.headerCell.colSpan-1)){ // Row footer
+ cell = document.createElement("TH");
+ this.weekFooterCells[this.weekFooterCells.length] = cell;
+ } else {
+ cell = document.createElement("TD");
+ this.cells[this.cells.length] = cell;
+ YAHOO.widget.Calendar_Core.setCssClasses(cell, [this.Style.CSS_CELL]);
+ YAHOO.util.Event.addListener(cell, "click", this.doSelectCell, this);
+
+ YAHOO.util.Event.addListener(cell, "mouseover", this.doCellMouseOver, this);
+ YAHOO.util.Event.addListener(cell, "mouseout", this.doCellMouseOut, this);
+ }
+ row.appendChild(cell);
+ }
+ this.tbody.appendChild(row);
+ }
+
+ this.table.appendChild(this.tbody);
+};
+
+/**
+* Builds the calendar shell footer. In the default implementation, there is
+* no footer.
+*/
+YAHOO.widget.Calendar_Core.prototype.buildShellFooter = function() { };
+
+/**
+* Outputs the calendar shell to the DOM, inserting it into the placeholder element.
+*/
+YAHOO.widget.Calendar_Core.prototype.renderShell = function() {
+ this.oDomContainer.appendChild(this.table);
+ this.shellRendered = true;
+};
+
+/**
+* Renders the calendar after it has been configured. The render() method has a specific call chain that will execute
+* when the method is called: renderHeader, renderBody, renderFooter.
+* Refer to the documentation for those methods for information on
+* individual render tasks.
+*/
+YAHOO.widget.Calendar_Core.prototype.render = function() {
+ if (! this.shellRendered) {
+ this.buildShell();
+ this.renderShell();
+ }
+
+ this.resetRenderers();
+
+ this.cellDates.length = 0;
+
+ // Find starting day of the current month
+ var workingDate = YAHOO.widget.DateMath.findMonthStart(this.pageDate);
+
+ this.renderHeader();
+ this.renderBody(workingDate);
+ this.renderFooter();
+
+ this.onRender();
+};
+
+
+
+/**
+* Appends the header contents into the widget header.
+*/
+YAHOO.widget.Calendar_Core.prototype.renderHeader = function() {
+ this.logger.log("Rendering header", "info");
+
+ this.headerCell.innerHTML = "";
+
+ var headerContainer = document.createElement("DIV");
+ headerContainer.className = this.Style.CSS_HEADER;
+
+ headerContainer.appendChild(document.createTextNode(this.buildMonthLabel()));
+
+ this.headerCell.appendChild(headerContainer);
+};
+
+/**
+* Appends the calendar body. The default implementation calculates the number of
+* OOM (out of month) cells that need to be rendered at the start of the month, renders those,
+* and renders all the day cells using the built-in cell rendering methods.
+*
+* While iterating through all of the cells, the calendar checks for renderers in the
+* local render stack that match the date of the current cell, and then applies styles
+* as necessary.
+*
+* @param {Date} workingDate The current working Date object being used to generate the calendar
+*/
+YAHOO.widget.Calendar_Core.prototype.renderBody = function(workingDate) {
+ this.logger.log("Rendering body", "info");
+
+ this.preMonthDays = workingDate.getDay();
+ if (this.Options.START_WEEKDAY > 0) {
+ this.preMonthDays -= this.Options.START_WEEKDAY;
+ }
+ if (this.preMonthDays < 0) {
+ this.preMonthDays += 7;
+ }
+
+ this.logger.log(this.preMonthDays + " preciding out-of-month days", "info");
+
+ this.monthDays = YAHOO.widget.DateMath.findMonthEnd(workingDate).getDate();
+ this.logger.log(this.monthDays + " month days", "info");
+
+ this.postMonthDays = YAHOO.widget.Calendar_Core.DISPLAY_DAYS-this.preMonthDays-this.monthDays;
+ this.logger.log(this.postMonthDays + " post-month days", "info");
+
+ workingDate = YAHOO.widget.DateMath.subtract(workingDate, YAHOO.widget.DateMath.DAY, this.preMonthDays);
+ this.logger.log("Calendar page starts on " + workingDate, "info");
+
+ var weekRowIndex = 0;
+
+ for (var c=0;c<this.cells.length;++c) {
+ var cellRenderers = new Array();
+
+ var cell = this.cells[c];
+ this.clearElement(cell);
+
+ cell.index = c;
+ cell.id = this.id + "_cell" + c;
+
+ this.cellDates[this.cellDates.length]=[workingDate.getFullYear(),workingDate.getMonth()+1,workingDate.getDate()]; // Add this date to cellDates
+
+ if (workingDate.getDay() == this.Options.START_WEEKDAY) {
+ var rowHeaderCell = null;
+ var rowFooterCell = null;
+
+ if (this.Options.SHOW_WEEK_HEADER) {
+ rowHeaderCell = this.weekHeaderCells[weekRowIndex];
+ this.clearElement(rowHeaderCell);
+ }
+
+ if (this.Options.SHOW_WEEK_FOOTER) {
+ rowFooterCell = this.weekFooterCells[weekRowIndex];
+ this.clearElement(rowFooterCell);
+ }
+
+ if (this.Options.HIDE_BLANK_WEEKS && this.isDateOOM(workingDate) && ! YAHOO.widget.DateMath.isMonthOverlapWeek(workingDate)) {
+ // The first day of the week is not in this month, and it's not an overlap week
+ continue;
+ } else {
+ if (rowHeaderCell) {
+ this.renderRowHeader(workingDate, rowHeaderCell);
+ }
+ if (rowFooterCell) {
+ this.renderRowFooter(workingDate, rowFooterCell);
+ }
+ }
+ }
+
+ this.logger.log("Rendering cell " + cell.id + " (" + workingDate.getFullYear() + "-" + (workingDate.getMonth()+1) + "-" + workingDate.getDate() + ")", "cellrender");
+
+ var renderer = null;
+
+ if (workingDate.getFullYear() == this.today.getFullYear() &&
+ workingDate.getMonth() == this.today.getMonth() &&
+ workingDate.getDate() == this.today.getDate()) {
+ cellRenderers[cellRenderers.length]=this.renderCellStyleToday;
+ }
+
+ if (this.isDateOOM(workingDate)) {
+ cellRenderers[cellRenderers.length]=this.renderCellNotThisMonth;
+ } else {
+ for (var r=0;r<this.renderStack.length;++r) {
+ var rArray = this.renderStack[r];
+ var type = rArray[0];
+
+ var month;
+ var day;
+ var year;
+
+ switch (type) {
+ case YAHOO.widget.Calendar_Core.DATE:
+ month = rArray[1][1];
+ day = rArray[1][2];
+ year = rArray[1][0];
+
+ if (workingDate.getMonth()+1 == month && workingDate.getDate() == day && workingDate.getFullYear() == year) {
+ renderer = rArray[2];
+ this.renderStack.splice(r,1);
+ }
+ break;
+ case YAHOO.widget.Calendar_Core.MONTH_DAY:
+ month = rArray[1][0];
+ day = rArray[1][1];
+
+ if (workingDate.getMonth()+1 == month && workingDate.getDate() == day) {
+ renderer = rArray[2];
+ this.renderStack.splice(r,1);
+ }
+ break;
+ case YAHOO.widget.Calendar_Core.RANGE:
+ var date1 = rArray[1][0];
+ var date2 = rArray[1][1];
+
+ var d1month = date1[1];
+ var d1day = date1[2];
+ var d1year = date1[0];
+
+ var d1 = new Date(d1year, d1month-1, d1day);
+
+ var d2month = date2[1];
+ var d2day = date2[2];
+ var d2year = date2[0];
+
+ var d2 = new Date(d2year, d2month-1, d2day);
+
+ if (workingDate.getTime() >= d1.getTime() && workingDate.getTime() <= d2.getTime()) {
+ renderer = rArray[2];
+
+ if (workingDate.getTime()==d2.getTime()) {
+ this.renderStack.splice(r,1);
+ }
+ }
+ break;
+ case YAHOO.widget.Calendar_Core.WEEKDAY:
+
+ var weekday = rArray[1][0];
+ if (workingDate.getDay()+1 == weekday) {
+ renderer = rArray[2];
+ }
+ break;
+ case YAHOO.widget.Calendar_Core.MONTH:
+
+ month = rArray[1][0];
+ if (workingDate.getMonth()+1 == month) {
+ renderer = rArray[2];
+ }
+ break;
+ }
+
+ if (renderer) {
+ cellRenderers[cellRenderers.length]=renderer;
+ }
+ }
+
+ }
+
+ if (this._indexOfSelectedFieldArray([workingDate.getFullYear(),workingDate.getMonth()+1,workingDate.getDate()]) > -1) {
+ cellRenderers[cellRenderers.length]=this.renderCellStyleSelected;
+ }
+
+ if (this.minDate) {
+ this.minDate = YAHOO.widget.DateMath.clearTime(this.minDate);
+ }
+ if (this.maxDate) {
+ this.maxDate = YAHOO.widget.DateMath.clearTime(this.maxDate);
+ }
+
+ if (
+ (this.minDate && (workingDate.getTime() < this.minDate.getTime())) ||
+ (this.maxDate && (workingDate.getTime() > this.maxDate.getTime()))
+ ) {
+ cellRenderers[cellRenderers.length]=this.renderOutOfBoundsDate;
+ } else {
+ cellRenderers[cellRenderers.length]=this.renderCellDefault;
+ }
+
+ for (var x=0;x<cellRenderers.length;++x) {
+ var ren = cellRenderers[x];
+ this.logger.log("renderer[" + x + "] for (" + workingDate.getFullYear() + "-" + (workingDate.getMonth()+1) + "-" + workingDate.getDate() + ")", "cellrender");
+
+ if (ren.call(this,workingDate,cell) == YAHOO.widget.Calendar_Core.STOP_RENDER) {
+ break;
+ }
+ }
+
+ workingDate = YAHOO.widget.DateMath.add(workingDate, YAHOO.widget.DateMath.DAY, 1); // Go to the next day
+ if (workingDate.getDay() == this.Options.START_WEEKDAY) {
+ weekRowIndex += 1;
+ }
+
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL);
+
+ if (c >= 0 && c <= 6) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_TOP);
+ }
+ if ((c % 7) == 0) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_LEFT);
+ }
+ if (((c+1) % 7) == 0) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_RIGHT);
+ }
+
+ var postDays = this.postMonthDays;
+ if (postDays >= 7 && this.Options.HIDE_BLANK_WEEKS) {
+ var blankWeeks = Math.floor(postDays/7);
+ for (var p=0;p<blankWeeks;++p) {
+ postDays -= 7;
+ }
+ }
+
+ if (c >= ((this.preMonthDays+postDays+this.monthDays)-7)) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_BOTTOM);
+ }
+
+ this.logger.log("Final styles for (" + workingDate.getFullYear() + "-" + (workingDate.getMonth()+1) + "-" + workingDate.getDate() + "): " + cell.className, "cellrender");
+
+ }
+
+};
+
+/**
+* Appends the contents of the calendar widget footer into the shell. By default,
+* the calendar does not contain a footer, and this method must be implemented by
+* subclassing the widget.
+*/
+YAHOO.widget.Calendar_Core.prototype.renderFooter = function() { };
+
+/**
+* @private
+*/
+YAHOO.widget.Calendar_Core.prototype._unload = function(e, cal) {
+ for (var c in cal.cells) {
+ c = null;
+ }
+
+ cal.cells = null;
+
+ cal.tbody = null;
+ cal.oDomContainer = null;
+ cal.table = null;
+ cal.headerCell = null;
+
+ cal = null;
+};
+
+
+/****************** BEGIN BUILT-IN TABLE CELL RENDERERS ************************************/
+
+YAHOO.widget.Calendar_Core.prototype.renderOutOfBoundsDate = function(workingDate, cell) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_OOB);
+ cell.innerHTML = workingDate.getDate();
+ return YAHOO.widget.Calendar_Core.STOP_RENDER;
+}
+
+/**
+* Renders the row header for a week. The date passed in should be
+* the first date of the given week.
+* @param {Date} workingDate The current working Date object (beginning of the week) being used to generate the calendar
+* @param {HTMLTableCellElement} cell The current working cell in the calendar
+*/
+YAHOO.widget.Calendar_Core.prototype.renderRowHeader = function(workingDate, cell) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_ROW_HEADER);
+
+ var useYear = this.pageDate.getFullYear();
+
+ if (! YAHOO.widget.DateMath.isYearOverlapWeek(workingDate)) {
+ useYear = workingDate.getFullYear();
+ }
+
+ var weekNum = YAHOO.widget.DateMath.getWeekNumber(workingDate, useYear, this.Options.START_WEEKDAY);
+ cell.innerHTML = weekNum;
+
+ if (this.isDateOOM(workingDate) && ! YAHOO.widget.DateMath.isMonthOverlapWeek(workingDate)) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_OOM);
+ }
+};
+
+/**
+* Renders the row footer for a week. The date passed in should be
+* the first date of the given week.
+* @param {Date} workingDate The current working Date object (beginning of the week) being used to generate the calendar
+* @param {HTMLTableCellElement} cell The current working cell in the calendar
+*/
+YAHOO.widget.Calendar_Core.prototype.renderRowFooter = function(workingDate, cell) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_ROW_FOOTER);
+
+ if (this.isDateOOM(workingDate) && ! YAHOO.widget.DateMath.isMonthOverlapWeek(workingDate)) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_OOM);
+ }
+};
+
+/**
+* Renders a single standard calendar cell in the calendar widget table.
+* All logic for determining how a standard default cell will be rendered is
+* encapsulated in this method, and must be accounted for when extending the
+* widget class.
+* @param {Date} workingDate The current working Date object being used to generate the calendar
+* @param {HTMLTableCellElement} cell The current working cell in the calendar
+* @return YAHOO.widget.Calendar_Core.STOP_RENDER if rendering should stop with this style, null or nothing if rendering
+* should not be terminated
+* @type String
+*/
+YAHOO.widget.Calendar_Core.prototype.renderCellDefault = function(workingDate, cell) {
+ cell.innerHTML = "";
+ var link = document.createElement("a");
+
+ link.href="javascript:void(null);";
+ link.name=this.id+"__"+workingDate.getFullYear()+"_"+(workingDate.getMonth()+1)+"_"+workingDate.getDate();
+
+ link.appendChild(document.createTextNode(this.buildDayLabel(workingDate)));
+ cell.appendChild(link);
+};
+
+/**
+* Renders a single standard calendar cell using the CSS hightlight1 style
+* @param {Date} workingDate The current working Date object being used to generate the calendar
+* @param {HTMLTableCellElement} cell The current working cell in the calendar
+* @return YAHOO.widget.Calendar_Core.STOP_RENDER if rendering should stop with this style, null or nothing if rendering
+* should not be terminated
+* @type String
+*/
+YAHOO.widget.Calendar_Core.prototype.renderCellStyleHighlight1 = function(workingDate, cell) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_HIGHLIGHT1);
+};
+
+/**
+* Renders a single standard calendar cell using the CSS hightlight2 style
+* @param {Date} workingDate The current working Date object being used to generate the calendar
+* @param {HTMLTableCellElement} cell The current working cell in the calendar
+* @return YAHOO.widget.Calendar_Core.STOP_RENDER if rendering should stop with this style, null or nothing if rendering
+* should not be terminated
+* @type String
+*/
+YAHOO.widget.Calendar_Core.prototype.renderCellStyleHighlight2 = function(workingDate, cell) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_HIGHLIGHT2);
+};
+
+/**
+* Renders a single standard calendar cell using the CSS hightlight3 style
+* @param {Date} workingDate The current working Date object being used to generate the calendar
+* @param {HTMLTableCellElement} cell The current working cell in the calendar
+* @return YAHOO.widget.Calendar_Core.STOP_RENDER if rendering should stop with this style, null or nothing if rendering
+* should not be terminated
+* @type String
+*/
+YAHOO.widget.Calendar_Core.prototype.renderCellStyleHighlight3 = function(workingDate, cell) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_HIGHLIGHT3);
+};
+
+/**
+* Renders a single standard calendar cell using the CSS hightlight4 style
+* @param {Date} workingDate The current working Date object being used to generate the calendar
+* @param {HTMLTableCellElement} cell The current working cell in the calendar
+* @return YAHOO.widget.Calendar_Core.STOP_RENDER if rendering should stop with this style, null or nothing if rendering
+* should not be terminated
+* @type String
+*/
+YAHOO.widget.Calendar_Core.prototype.renderCellStyleHighlight4 = function(workingDate, cell) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_HIGHLIGHT4);
+};
+
+/**
+* Applies the default style used for rendering today's date to the current calendar cell
+* @param {Date} workingDate The current working Date object being used to generate the calendar
+* @param {HTMLTableCellElement} cell The current working cell in the calendar
+* @return YAHOO.widget.Calendar_Core.STOP_RENDER if rendering should stop with this style, null or nothing if rendering
+* should not be terminated
+* @type String
+*/
+YAHOO.widget.Calendar_Core.prototype.renderCellStyleToday = function(workingDate, cell) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_TODAY);
+};
+
+/**
+* Applies the default style used for rendering selected dates to the current calendar cell
+* @param {Date} workingDate The current working Date object being used to generate the calendar
+* @param {HTMLTableCellElement} cell The current working cell in the calendar
+* @return YAHOO.widget.Calendar_Core.STOP_RENDER if rendering should stop with this style, null or nothing if rendering
+* should not be terminated
+* @type String
+*/
+YAHOO.widget.Calendar_Core.prototype.renderCellStyleSelected = function(workingDate, cell) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_SELECTED);
+};
+
+/**
+* Applies the default style used for rendering dates that are not a part of the current
+* month (preceding or trailing the cells for the current month)
+* @param {Date} workingDate The current working Date object being used to generate the calendar
+* @param {HTMLTableCellElement} cell The current working cell in the calendar
+* @return YAHOO.widget.Calendar_Core.STOP_RENDER if rendering should stop with this style, null or nothing if rendering
+* should not be terminated
+* @type String
+*/
+YAHOO.widget.Calendar_Core.prototype.renderCellNotThisMonth = function(workingDate, cell) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_OOM);
+ cell.innerHTML=workingDate.getDate();
+ return YAHOO.widget.Calendar_Core.STOP_RENDER;
+};
+
+/**
+* Renders the current calendar cell as a non-selectable "black-out" date using the default
+* restricted style.
+* @param {Date} workingDate The current working Date object being used to generate the calendar
+* @param {HTMLTableCellElement} cell The current working cell in the calendar
+* @return YAHOO.widget.Calendar_Core.STOP_RENDER if rendering should stop with this style, null or nothing if rendering
+* should not be terminated
+* @type String
+*/
+YAHOO.widget.Calendar_Core.prototype.renderBodyCellRestricted = function(workingDate, cell) {
+ YAHOO.widget.Calendar_Core.setCssClasses(cell, [this.Style.CSS_CELL,this.Style.CSS_CELL_RESTRICTED]);
+ cell.innerHTML=workingDate.getDate();
+ return YAHOO.widget.Calendar_Core.STOP_RENDER;
+};
+/******************** END BUILT-IN TABLE CELL RENDERERS ************************************/
+
+/******************** BEGIN MONTH NAVIGATION METHODS ************************************/
+/**
+* Adds the designated number of months to the current calendar month, and sets the current
+* calendar page date to the new month.
+* @param {Integer} count The number of months to add to the current calendar
+*/
+YAHOO.widget.Calendar_Core.prototype.addMonths = function(count) {
+ this.pageDate = YAHOO.widget.DateMath.add(this.pageDate, YAHOO.widget.DateMath.MONTH, count);
+ this.resetRenderers();
+ this.onChangePage();
+};
+
+/**
+* Subtracts the designated number of months from the current calendar month, and sets the current
+* calendar page date to the new month.
+* @param {Integer} count The number of months to subtract from the current calendar
+*/
+YAHOO.widget.Calendar_Core.prototype.subtractMonths = function(count) {
+ this.pageDate = YAHOO.widget.DateMath.subtract(this.pageDate, YAHOO.widget.DateMath.MONTH, count);
+ this.resetRenderers();
+ this.onChangePage();
+};
+
+/**
+* Adds the designated number of years to the current calendar, and sets the current
+* calendar page date to the new month.
+* @param {Integer} count The number of years to add to the current calendar
+*/
+YAHOO.widget.Calendar_Core.prototype.addYears = function(count) {
+ this.pageDate = YAHOO.widget.DateMath.add(this.pageDate, YAHOO.widget.DateMath.YEAR, count);
+ this.resetRenderers();
+ this.onChangePage();
+};
+
+/**
+* Subtcats the designated number of years from the current calendar, and sets the current
+* calendar page date to the new month.
+* @param {Integer} count The number of years to subtract from the current calendar
+*/
+YAHOO.widget.Calendar_Core.prototype.subtractYears = function(count) {
+ this.pageDate = YAHOO.widget.DateMath.subtract(this.pageDate, YAHOO.widget.DateMath.YEAR, count);
+ this.resetRenderers();
+ this.onChangePage();
+};
+
+/**
+* Navigates to the next month page in the calendar widget.
+*/
+YAHOO.widget.Calendar_Core.prototype.nextMonth = function() {
+ this.addMonths(1);
+};
+
+/**
+* Navigates to the previous month page in the calendar widget.
+*/
+YAHOO.widget.Calendar_Core.prototype.previousMonth = function() {
+ this.subtractMonths(1);
+};
+
+/**
+* Navigates to the next year in the currently selected month in the calendar widget.
+*/
+YAHOO.widget.Calendar_Core.prototype.nextYear = function() {
+ this.addYears(1);
+};
+
+/**
+* Navigates to the previous year in the currently selected month in the calendar widget.
+*/
+YAHOO.widget.Calendar_Core.prototype.previousYear = function() {
+ this.subtractYears(1);
+};
+
+/****************** END MONTH NAVIGATION METHODS ************************************/
+
+/************* BEGIN SELECTION METHODS *************************************************************/
+
+/**
+* Resets the calendar widget to the originally selected month and year, and
+* sets the calendar to the initial selection(s).
+*/
+YAHOO.widget.Calendar_Core.prototype.reset = function() {
+ this.selectedDates.length = 0;
+ this.selectedDates = this._selectedDates.concat();
+
+ this.pageDate = new Date(this._pageDate.getTime());
+ this.onReset();
+};
+
+/**
+* Clears the selected dates in the current calendar widget and sets the calendar
+* to the current month and year.
+*/
+YAHOO.widget.Calendar_Core.prototype.clear = function() {
+ this.selectedDates.length = 0;
+ this.pageDate = new Date(this.today.getTime());
+ this.onClear();
+};
+
+/**
+* Selects a date or a collection of dates on the current calendar. This method, by default,
+* does not call the render method explicitly. Once selection has completed, render must be
+* called for the changes to be reflected visually.
+* @param {String/Date/Date[]} date The date string of dates to select in the current calendar. Valid formats are
+* individual date(s) (12/24/2005,12/26/2005) or date range(s) (12/24/2005-1/1/2006).
+* Multiple comma-delimited dates can also be passed to this method (12/24/2005,12/11/2005-12/13/2005).
+* This method can also take a JavaScript Date object or an array of Date objects.
+* @return Array of JavaScript Date objects representing all individual dates that are currently selected.
+* @type Date[]
+*/
+YAHOO.widget.Calendar_Core.prototype.select = function(date) {
+ this.onBeforeSelect();
+ this.logger.log("Select: " + date, "info");
+
+ var aToBeSelected = this._toFieldArray(date);
+ this.logger.log("Selection field array: " + aToBeSelected, "info");
+
+ for (var a=0;a<aToBeSelected.length;++a) {
+ var toSelect = aToBeSelected[a]; // For each date item in the list of dates we're trying to select
+ if (this._indexOfSelectedFieldArray(toSelect) == -1) { // not already selected?
+ this.selectedDates[this.selectedDates.length]=toSelect;
+ }
+ }
+
+ if (this.parent) {
+ this.parent.sync(this);
+ }
+
+ this.onSelect();
+
+ return this.getSelectedDates();
+};
+
+/**
+* Selects a date on the current calendar by referencing the index of the cell that should be selected.
+* This method is used to easily select a single cell (usually with a mouse click) without having to do
+* a full render. The selected style is applied to the cell directly.
+* @param {Integer} cellIndex The index of the cell to select in the current calendar.
+* @return Array of JavaScript Date objects representing all individual dates that are currently selected.
+* @type Date[]
+*/
+YAHOO.widget.Calendar_Core.prototype.selectCell = function(cellIndex) {
+ this.onBeforeSelect();
+
+ this.cells = this.tbody.getElementsByTagName("TD");
+
+ var cell = this.cells[cellIndex];
+ var cellDate = this.cellDates[cellIndex];
+
+ var dCellDate = this._toDate(cellDate);
+ this.logger.log("Select: " + dCellDate, "info");
+
+ var selectDate = cellDate.concat();
+
+ this.selectedDates.push(selectDate);
+
+ if (this.parent) {
+ this.parent.sync(this);
+ }
+
+ this.renderCellStyleSelected(dCellDate,cell);
+
+ this.onSelect();
+ this.doCellMouseOut.call(cell, null, this);
+
+ return this.getSelectedDates();
+};
+
+/**
+* Deselects a date or a collection of dates on the current calendar. This method, by default,
+* does not call the render method explicitly. Once deselection has completed, render must be
+* called for the changes to be reflected visually.
+* @param {String/Date/Date[]} date The date string of dates to deselect in the current calendar. Valid formats are
+* individual date(s) (12/24/2005,12/26/2005) or date range(s) (12/24/2005-1/1/2006).
+* Multiple comma-delimited dates can also be passed to this method (12/24/2005,12/11/2005-12/13/2005).
+* This method can also take a JavaScript Date object or an array of Date objects.
+* @return Array of JavaScript Date objects representing all individual dates that are currently selected.
+* @type Date[]
+*/
+YAHOO.widget.Calendar_Core.prototype.deselect = function(date) {
+ this.onBeforeDeselect();
+
+ var aToBeSelected = this._toFieldArray(date);
+
+ this.logger.log("Select: " + aToBeSelected, "info");
+
+ for (var a=0;a<aToBeSelected.length;++a) {
+ var toSelect = aToBeSelected[a]; // For each date item in the list of dates we're trying to select
+ var index = this._indexOfSelectedFieldArray(toSelect);
+
+ if (index != -1) {
+ this.selectedDates.splice(index,1);
+ }
+ }
+
+ if (this.parent) {
+ this.parent.sync(this);
+ }
+
+ this.onDeselect();
+ return this.getSelectedDates();
+};
+
+/**
+* Deselects a date on the current calendar by referencing the index of the cell that should be deselected.
+* This method is used to easily deselect a single cell (usually with a mouse click) without having to do
+* a full render. The selected style is removed from the cell directly.
+* @param {Integer} cellIndex The index of the cell to deselect in the current calendar.
+* @return Array of JavaScript Date objects representing all individual dates that are currently selected.
+* @type Date[]
+*/
+YAHOO.widget.Calendar_Core.prototype.deselectCell = function(i) {
+ this.onBeforeDeselect();
+ this.cells = this.tbody.getElementsByTagName("TD");
+
+ var cell = this.cells[i];
+ var cellDate = this.cellDates[i];
+ var cellDateIndex = this._indexOfSelectedFieldArray(cellDate);
+
+ var dCellDate = this._toDate(cellDate);
+ this.logger.log("Deselect: " + dCellDate, "info");
+
+ var selectDate = cellDate.concat();
+
+ if (cellDateIndex > -1) {
+ if (this.pageDate.getMonth() == dCellDate.getMonth() &&
+ this.pageDate.getFullYear() == dCellDate.getFullYear()) {
+ YAHOO.util.Dom.removeClass(cell, this.Style.CSS_CELL_SELECTED);
+ }
+
+ this.selectedDates.splice(cellDateIndex, 1);
+ }
+
+
+ if (this.parent) {
+ this.parent.sync(this);
+ }
+
+ this.onDeselect();
+ return this.getSelectedDates();
+};
+
+/**
+* Deselects all dates on the current calendar.
+* @return Array of JavaScript Date objects representing all individual dates that are currently selected.
+* Assuming that this function executes properly, the return value should be an empty array.
+* However, the empty array is returned for the sake of being able to check the selection status
+* of the calendar.
+* @type Date[]
+*/
+YAHOO.widget.Calendar_Core.prototype.deselectAll = function() {
+ this.onBeforeDeselect();
+ var count = this.selectedDates.length;
+ this.selectedDates.length = 0;
+
+ if (this.parent) {
+ this.parent.sync(this);
+ }
+
+ if (count > 0) {
+ this.onDeselect();
+ }
+
+ return this.getSelectedDates();
+};
+/************* END SELECTION METHODS *************************************************************/
+
+
+/************* BEGIN TYPE CONVERSION METHODS ****************************************************/
+
+/**
+* Converts a date (either a JavaScript Date object, or a date string) to the internal data structure
+* used to represent dates: [[yyyy,mm,dd],[yyyy,mm,dd]].
+* @private
+* @param {String/Date/Date[]} date The date string of dates to deselect in the current calendar. Valid formats are
+* individual date(s) (12/24/2005,12/26/2005) or date range(s) (12/24/2005-1/1/2006).
+* Multiple comma-delimited dates can also be passed to this method (12/24/2005,12/11/2005-12/13/2005).
+* This method can also take a JavaScript Date object or an array of Date objects.
+* @return Array of date field arrays
+* @type Array[](Integer[])
+*/
+YAHOO.widget.Calendar_Core.prototype._toFieldArray = function(date) {
+ var returnDate = new Array();
+
+ if (date instanceof Date) {
+ returnDate = [[date.getFullYear(), date.getMonth()+1, date.getDate()]];
+ } else if (typeof date == 'string') {
+ returnDate = this._parseDates(date);
+ } else if (date instanceof Array) {
+ for (var i=0;i<date.length;++i) {
+ var d = date[i];
+ returnDate[returnDate.length] = [d.getFullYear(),d.getMonth()+1,d.getDate()];
+ }
+ }
+
+ return returnDate;
+};
+
+/**
+* Converts a date field array [yyyy,mm,dd] to a JavaScript Date object.
+* @private
+* @param {Integer[]} dateFieldArray The date field array to convert to a JavaScript Date.
+* @return JavaScript Date object representing the date field array
+* @type Date
+*/
+YAHOO.widget.Calendar_Core.prototype._toDate = function(dateFieldArray) {
+ if (dateFieldArray instanceof Date) {
+ return dateFieldArray;
+ } else {
+ return new Date(dateFieldArray[0],dateFieldArray[1]-1,dateFieldArray[2]);
+ }
+};
+/************* END TYPE CONVERSION METHODS ******************************************************/
+
+
+/************* BEGIN UTILITY METHODS ****************************************************/
+/**
+* Converts a date field array [yyyy,mm,dd] to a JavaScript Date object.
+* @private
+* @param {Integer[]} array1 The first date field array to compare
+* @param {Integer[]} array2 The first date field array to compare
+* @return The boolean that represents the equality of the two arrays
+* @type Boolean
+*/
+YAHOO.widget.Calendar_Core.prototype._fieldArraysAreEqual = function(array1, array2) {
+ var match = false;
+
+ if (array1[0]==array2[0]&&array1[1]==array2[1]&&array1[2]==array2[2]) {
+ match=true;
+ }
+
+ return match;
+};
+
+/**
+* Gets the index of a date field array [yyyy,mm,dd] in the current list of selected dates.
+* @private
+* @param {Integer[]} find The date field array to search for
+* @return The index of the date field array within the collection of selected dates.
+* -1 will be returned if the date is not found.
+* @type Integer
+*/
+YAHOO.widget.Calendar_Core.prototype._indexOfSelectedFieldArray = function(find) {
+ var selected = -1;
+
+ for (var s=0;s<this.selectedDates.length;++s) {
+ var sArray = this.selectedDates[s];
+ if (find[0]==sArray[0]&&find[1]==sArray[1]&&find[2]==sArray[2]) {
+ selected = s;
+ break;
+ }
+ }
+
+ return selected;
+};
+
+/**
+* Determines whether a given date is OOM (out of month).
+* @param {Date} date The JavaScript Date object for which to check the OOM status
+* @return {Boolean} true if the date is OOM
+*/
+YAHOO.widget.Calendar_Core.prototype.isDateOOM = function(date) {
+ var isOOM = false;
+ if (date.getMonth() != this.pageDate.getMonth()) {
+ isOOM = true;
+ }
+ return isOOM;
+};
+
+/************* END UTILITY METHODS *******************************************************/
+
+/************* BEGIN EVENT HANDLERS ******************************************************/
+
+/**
+* Event executed before a date is selected in the calendar widget.
+*/
+YAHOO.widget.Calendar_Core.prototype.onBeforeSelect = function() {
+ if (! this.Options.MULTI_SELECT) {
+ this.clearAllBodyCellStyles(this.Style.CSS_CELL_SELECTED);
+ this.deselectAll();
+ }
+};
+
+/**
+* Event executed when a date is selected in the calendar widget.
+*/
+YAHOO.widget.Calendar_Core.prototype.onSelect = function() { };
+
+/**
+* Event executed before a date is deselected in the calendar widget.
+*/
+YAHOO.widget.Calendar_Core.prototype.onBeforeDeselect = function() { };
+
+/**
+* Event executed when a date is deselected in the calendar widget.
+*/
+YAHOO.widget.Calendar_Core.prototype.onDeselect = function() { };
+
+/**
+* Event executed when the user navigates to a different calendar page.
+*/
+YAHOO.widget.Calendar_Core.prototype.onChangePage = function() {
+ var me = this;
+
+ this.renderHeader();
+ if (this.renderProcId) {
+ clearTimeout(this.renderProcId);
+ }
+ this.renderProcId = setTimeout(function() {
+ me.render();
+ me.renderProcId = null;
+ }, 1);
+};
+
+/**
+* Event executed when the calendar widget is rendered.
+*/
+YAHOO.widget.Calendar_Core.prototype.onRender = function() { };
+
+/**
+* Event executed when the calendar widget is reset to its original state.
+*/
+YAHOO.widget.Calendar_Core.prototype.onReset = function() { this.render(); };
+
+/**
+* Event executed when the calendar widget is completely cleared to the current month with no selections.
+*/
+YAHOO.widget.Calendar_Core.prototype.onClear = function() { this.render(); };
+
+/**
+* Validates the calendar widget. This method has no default implementation
+* and must be extended by subclassing the widget.
+* @return Should return true if the widget validates, and false if
+* it doesn't.
+* @type Boolean
+*/
+YAHOO.widget.Calendar_Core.prototype.validate = function() { return true; };
+
+/************* END EVENT HANDLERS *********************************************************/
+
+
+/************* BEGIN DATE PARSE METHODS ***************************************************/
+
+
+/**
+* Converts a date string to a date field array
+* @private
+* @param {String} sDate Date string. Valid formats are mm/dd and mm/dd/yyyy.
+* @return A date field array representing the string passed to the method
+* @type Array[](Integer[])
+*/
+YAHOO.widget.Calendar_Core.prototype._parseDate = function(sDate) {
+ var aDate = sDate.split(this.Locale.DATE_FIELD_DELIMITER);
+ var rArray;
+
+ if (aDate.length == 2) {
+ rArray = [aDate[this.Locale.MD_MONTH_POSITION-1],aDate[this.Locale.MD_DAY_POSITION-1]];
+ rArray.type = YAHOO.widget.Calendar_Core.MONTH_DAY;
+ } else {
+ rArray = [aDate[this.Locale.MDY_YEAR_POSITION-1],aDate[this.Locale.MDY_MONTH_POSITION-1],aDate[this.Locale.MDY_DAY_POSITION-1]];
+ rArray.type = YAHOO.widget.Calendar_Core.DATE;
+ }
+ return rArray;
+};
+
+/**
+* Converts a multi or single-date string to an array of date field arrays
+* @private
+* @param {String} sDates Date string with one or more comma-delimited dates. Valid formats are mm/dd, mm/dd/yyyy, mm/dd/yyyy-mm/dd/yyyy
+* @return An array of date field arrays
+* @type Array[](Integer[])
+*/
+YAHOO.widget.Calendar_Core.prototype._parseDates = function(sDates) {
+ var aReturn = new Array();
+
+ var aDates = sDates.split(this.Locale.DATE_DELIMITER);
+
+ for (var d=0;d<aDates.length;++d) {
+ var sDate = aDates[d];
+
+ if (sDate.indexOf(this.Locale.DATE_RANGE_DELIMITER) != -1) {
+ // This is a range
+ var aRange = sDate.split(this.Locale.DATE_RANGE_DELIMITER);
+
+ var dateStart = this._parseDate(aRange[0]);
+ var dateEnd = this._parseDate(aRange[1]);
+
+ var fullRange = this._parseRange(dateStart, dateEnd);
+ aReturn = aReturn.concat(fullRange);
+ } else {
+ // This is not a range
+ var aDate = this._parseDate(sDate);
+ aReturn.push(aDate);
+ }
+ }
+ return aReturn;
+};
+
+/**
+* Converts a date range to the full list of included dates
+* @private
+* @param {Integer[]} startDate Date field array representing the first date in the range
+* @param {Integer[]} endDate Date field array representing the last date in the range
+* @return An array of date field arrays
+* @type Array[](Integer[])
+*/
+YAHOO.widget.Calendar_Core.prototype._parseRange = function(startDate, endDate) {
+ var dStart = new Date(startDate[0],startDate[1]-1,startDate[2]);
+ var dCurrent = YAHOO.widget.DateMath.add(new Date(startDate[0],startDate[1]-1,startDate[2]),YAHOO.widget.DateMath.DAY,1);
+ var dEnd = new Date(endDate[0], endDate[1]-1, endDate[2]);
+
+ var results = new Array();
+ results.push(startDate);
+ while (dCurrent.getTime() <= dEnd.getTime()) {
+ results.push([dCurrent.getFullYear(),dCurrent.getMonth()+1,dCurrent.getDate()]);
+ dCurrent = YAHOO.widget.DateMath.add(dCurrent,YAHOO.widget.DateMath.DAY,1);
+ }
+ return results;
+};
+
+/************* END DATE PARSE METHODS *****************************************************/
+
+/************* BEGIN RENDERER METHODS *****************************************************/
+
+/**
+* Resets the render stack of the current calendar to its original pre-render value.
+*/
+YAHOO.widget.Calendar_Core.prototype.resetRenderers = function() {
+ this.renderStack = this._renderStack.concat();
+};
+
+/**
+* Clears the inner HTML, CSS class and style information from the specified cell.
+* @param {HTMLTableCellElement} The cell to clear
+*/
+YAHOO.widget.Calendar_Core.prototype.clearElement = function(cell) {
+ cell.innerHTML = " ";
+ cell.className="";
+};
+
+/**
+* Adds a renderer to the render stack. The function reference passed to this method will be executed
+* when a date cell matches the conditions specified in the date string for this renderer.
+* @param {String} sDates A date string to associate with the specified renderer. Valid formats
+* include date (12/24/2005), month/day (12/24), and range (12/1/2004-1/1/2005)
+* @param {Function} fnRender The function executed to render cells that match the render rules for this renderer.
+*/
+YAHOO.widget.Calendar_Core.prototype.addRenderer = function(sDates, fnRender) {
+ var aDates = this._parseDates(sDates);
+ for (var i=0;i<aDates.length;++i) {
+ var aDate = aDates[i];
+
+ if (aDate.length == 2) { // this is either a range or a month/day combo
+ if (aDate[0] instanceof Array) { // this is a range
+ this._addRenderer(YAHOO.widget.Calendar_Core.RANGE,aDate,fnRender);
+ } else { // this is a month/day combo
+ this._addRenderer(YAHOO.widget.Calendar_Core.MONTH_DAY,aDate,fnRender);
+ }
+ } else if (aDate.length == 3) {
+ this._addRenderer(YAHOO.widget.Calendar_Core.DATE,aDate,fnRender);
+ }
+ }
+};
+
+/**
+* The private method used for adding cell renderers to the local render stack.
+* This method is called by other methods that set the renderer type prior to the method call.
+* @private
+* @param {String} type The type string that indicates the type of date renderer being added.
+* Values are YAHOO.widget.Calendar_Core.DATE, YAHOO.widget.Calendar_Core.MONTH_DAY, YAHOO.widget.Calendar_Core.WEEKDAY,
+* YAHOO.widget.Calendar_Core.RANGE, YAHOO.widget.Calendar_Core.MONTH
+* @param {Array} aDates An array of dates used to construct the renderer. The format varies based
+* on the renderer type
+* @param {Function} fnRender The function executed to render cells that match the render rules for this renderer.
+*/
+YAHOO.widget.Calendar_Core.prototype._addRenderer = function(type, aDates, fnRender) {
+ var add = [type,aDates,fnRender];
+ this.renderStack.unshift(add);
+
+ this._renderStack = this.renderStack.concat();
+};
+
+/**
+* Adds a month to the render stack. The function reference passed to this method will be executed
+* when a date cell matches the month passed to this method.
+* @param {Integer} month The month (1-12) to associate with this renderer
+* @param {Function} fnRender The function executed to render cells that match the render rules for this renderer.
+*/
+YAHOO.widget.Calendar_Core.prototype.addMonthRenderer = function(month, fnRender) {
+ this._addRenderer(YAHOO.widget.Calendar_Core.MONTH,[month],fnRender);
+};
+
+/**
+* Adds a weekday to the render stack. The function reference passed to this method will be executed
+* when a date cell matches the weekday passed to this method.
+* @param {Integer} weekay The weekday (1-7) to associate with this renderer
+* @param {Function} fnRender The function executed to render cells that match the render rules for this renderer.
+*/
+YAHOO.widget.Calendar_Core.prototype.addWeekdayRenderer = function(weekday, fnRender) {
+ this._addRenderer(YAHOO.widget.Calendar_Core.WEEKDAY,[weekday],fnRender);
+};
+//// END RENDERER METHODS ////
+
+//// BEGIN CSS METHODS ////
+
+/**
+* Sets the specified array of CSS classes into the referenced element
+* @param {HTMLElement} element The element to set the CSS classes into
+* @param {String[]} aStyles An array of CSS class names
+*/
+YAHOO.widget.Calendar_Core.setCssClasses = function(element, aStyles) {
+ element.className = "";
+ var className = aStyles.join(" ");
+ element.className = className;
+};
+
+/**
+* Removes all styles from all body cells in the current calendar table.
+* @param {style} The CSS class name to remove from all calendar body cells
+*/
+YAHOO.widget.Calendar_Core.prototype.clearAllBodyCellStyles = function(style) {
+ for (var c=0;c<this.cells.length;++c) {
+ YAHOO.util.Dom.removeClass(this.cells[c],style);
+ }
+};
+
+//// END CSS METHODS ////
+
+//// BEGIN GETTER/SETTER METHODS ////
+/**
+* Sets the calendar's month explicitly.
+* @param {Integer} month The numeric month, from 1 (January) to 12 (December)
+*/
+YAHOO.widget.Calendar_Core.prototype.setMonth = function(month) {
+ this.pageDate.setMonth(month);
+};
+
+/**
+* Sets the calendar's year explicitly.
+* @param {Integer} year The numeric 4-digit year
+*/
+YAHOO.widget.Calendar_Core.prototype.setYear = function(year) {
+ this.pageDate.setFullYear(year);
+};
+
+/**
+* Gets the list of currently selected dates from the calendar.
+* @return An array of currently selected JavaScript Date objects.
+* @type Date[]
+*/
+YAHOO.widget.Calendar_Core.prototype.getSelectedDates = function() {
+ var returnDates = new Array();
+
+ for (var d=0;d<this.selectedDates.length;++d) {
+ var dateArray = this.selectedDates[d];
+
+ var date = new Date(dateArray[0],dateArray[1]-1,dateArray[2]);
+ returnDates.push(date);
+ }
+
+ returnDates.sort();
+ return returnDates;
+};
+
+/// END GETTER/SETTER METHODS ///
+
+/**
+* Returns a string representing the current browser.
+* @type String
+*/
+YAHOO.widget.Calendar_Core._getBrowser = function() {
+ /**
+ * UserAgent
+ * @private
+ * @type String
+ */
+ var ua = navigator.userAgent.toLowerCase();
+
+ if (ua.indexOf('opera')!=-1) // Opera (check first in case of spoof)
+ return 'opera';
+ else if (ua.indexOf('msie')!=-1) // IE
+ return 'ie';
+ else if (ua.indexOf('safari')!=-1) // Safari (check before Gecko because it includes "like Gecko")
+ return 'safari';
+ else if (ua.indexOf('gecko') != -1) // Gecko
+ return 'gecko';
+ else
+ return false;
+}
+
+/**
+* Returns a string representation of the object.
+* @type string
+*/
+YAHOO.widget.Calendar_Core.prototype.toString = function() {
+ return "Calendar_Core " + this.id;
+}
+
+YAHOO.widget.Cal_Core = YAHOO.widget.Calendar_Core;/**
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+**/
+
+/**
+* @class
+* Calendar is the default implementation of the YAHOO.widget.Calendar_Core base class.
+* This class is the UED-approved version of the calendar selector widget. For all documentation
+* on the implemented methods listed here, see the documentation for YAHOO.widget.Calendar_Core.
+* @constructor
+* @param {String} id The id of the table element that will represent the calendar widget
+* @param {String} containerId The id of the container element that will contain the calendar table
+* @param {String} monthyear The month/year string used to set the current calendar page
+* @param {String} selected A string of date values formatted using the date parser. The built-in
+ default date format is MM/DD/YYYY. Ranges are defined using
+ MM/DD/YYYY-MM/DD/YYYY. Month/day combinations are defined using MM/DD.
+ Any combination of these can be combined by delimiting the string with
+ commas. Example: "12/24/2005,12/25,1/18/2006-1/21/2006"
+*/
+YAHOO.widget.Calendar = function(id, containerId, monthyear, selected) {
+ if (arguments.length > 0) {
+ this.init(id, containerId, monthyear, selected);
+ }
+}
+
+YAHOO.widget.Calendar.prototype = new YAHOO.widget.Calendar_Core();
+
+YAHOO.widget.Calendar.prototype.buildShell = function() {
+ this.border = document.createElement("DIV");
+ this.border.className = this.Style.CSS_CONTAINER;
+
+ this.table = document.createElement("TABLE");
+ this.table.cellSpacing = 0;
+
+ YAHOO.widget.Calendar_Core.setCssClasses(this.table, [this.Style.CSS_CALENDAR]);
+
+ this.border.id = this.id;
+
+ this.buildShellHeader();
+ this.buildShellBody();
+ this.buildShellFooter();
+};
+
+YAHOO.widget.Calendar.prototype.renderShell = function() {
+ this.border.appendChild(this.table);
+ this.oDomContainer.appendChild(this.border);
+ this.shellRendered = true;
+};
+
+YAHOO.widget.Calendar.prototype.renderHeader = function() {
+ this.headerCell.innerHTML = "";
+
+ var headerContainer = document.createElement("DIV");
+ headerContainer.className = this.Style.CSS_HEADER;
+
+ if (this.linkLeft) {
+ YAHOO.util.Event.removeListener(this.linkLeft, "mousedown", this.previousMonth);
+ }
+ this.linkLeft = document.createElement("A");
+ this.linkLeft.innerHTML = " ";
+ YAHOO.util.Event.addListener(this.linkLeft, "mousedown", this.previousMonth, this, true);
+ this.linkLeft.style.backgroundImage = "url(" + this.Options.NAV_ARROW_LEFT + ")";
+ this.linkLeft.className = this.Style.CSS_NAV_LEFT;
+
+ if (this.linkRight) {
+ YAHOO.util.Event.removeListener(this.linkRight, "mousedown", this.nextMonth);
+ }
+ this.linkRight = document.createElement("A");
+ this.linkRight.innerHTML = " ";
+ YAHOO.util.Event.addListener(this.linkRight, "mousedown", this.nextMonth, this, true);
+ this.linkRight.style.backgroundImage = "url(" + this.Options.NAV_ARROW_RIGHT + ")";
+ this.linkRight.className = this.Style.CSS_NAV_RIGHT;
+
+ headerContainer.appendChild(this.linkLeft);
+ headerContainer.appendChild(document.createTextNode(this.buildMonthLabel()));
+ headerContainer.appendChild(this.linkRight);
+
+ this.headerCell.appendChild(headerContainer);
+};
+
+YAHOO.widget.Cal = YAHOO.widget.Calendar;/**
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+**/
+
+/**
+* @class
+* <p>YAHOO.widget.CalendarGroup is a special container class for YAHOO.widget.Calendar_Core. This class facilitates
+* the ability to have multi-page calendar views that share a single dataset and are
+* dependent on each other.</p>
+*
+* <p>The calendar group instance will refer to each of its elements using a 0-based index.
+* For example, to construct the placeholder for a calendar group widget with id "cal1" and
+* containerId of "cal1Container", the markup would be as follows:
+* <xmp>
+* <div id="cal1Container_0"></div>
+* <div id="cal1Container_1"></div>
+* </xmp>
+* The tables for the calendars ("cal1_0" and "cal1_1") will be inserted into those containers.
+* </p>
+* @constructor
+* @param {Integer} pageCount The number of pages that this calendar should display.
+* @param {String} id The id of the element that will be inserted into the DOM.
+* @param {String} containerId The id of the container element that the calendar will be inserted into.
+* @param {String} monthyear The month/year string used to set the current calendar page
+* @param {String} selected A string of date values formatted using the date parser. The built-in
+ default date format is MM/DD/YYYY. Ranges are defined using
+ MM/DD/YYYY-MM/DD/YYYY. Month/day combinations are defined using MM/DD.
+ Any combination of these can be combined by delimiting the string with
+ commas. Example: "12/24/2005,12/25,1/18/2006-1/21/2006"
+*/
+YAHOO.widget.CalendarGroup = function(pageCount, id, containerId, monthyear, selected) {
+ if (arguments.length > 0) {
+ this.init(pageCount, id, containerId, monthyear, selected);
+ }
+}
+
+/**
+* Initializes the calendar group. All subclasses must call this method in order for the
+* group to be initialized properly.
+* @param {Integer} pageCount The number of pages that this calendar should display.
+* @param {String} id The id of the element that will be inserted into the DOM.
+* @param {String} containerId The id of the container element that the calendar will be inserted into.
+* @param {String} monthyear The month/year string used to set the current calendar page
+* @param {String} selected A string of date values formatted using the date parser. The built-in
+ default date format is MM/DD/YYYY. Ranges are defined using
+ MM/DD/YYYY-MM/DD/YYYY. Month/day combinations are defined using MM/DD.
+ Any combination of these can be combined by delimiting the string with
+ commas. Example: "12/24/2005,12/25,1/18/2006-1/21/2006"
+*/
+YAHOO.widget.CalendarGroup.prototype.init = function(pageCount, id, containerId, monthyear, selected) {
+ this.logger = new YAHOO.widget.LogWriter("CalendarGroup " + id);
+
+ this.id = id;
+ this.selectedDates = new Array();
+ this.containerId = containerId;
+
+ this.pageCount = pageCount;
+
+ this.pages = new Array();
+
+ for (var p=0;p<pageCount;++p) {
+ var cal = this.constructChild(id + "_" + p, this.containerId + "_" + p , monthyear, selected);
+
+ cal.parent = this;
+
+ cal.index = p;
+
+ cal.pageDate.setMonth(cal.pageDate.getMonth()+p);
+ cal._pageDate = new Date(cal.pageDate.getFullYear(),cal.pageDate.getMonth(),cal.pageDate.getDate());
+ this.pages.push(cal);
+ }
+
+ this.doNextMonth = function(e, calGroup) {
+ calGroup.nextMonth();
+ };
+
+ this.doPreviousMonth = function(e, calGroup) {
+ calGroup.previousMonth();
+ };
+
+ this.logger.log("Initialized " + pageCount + "-page CalendarGroup", "info");
+};
+
+/**
+* Adds a function to all child Calendars within this CalendarGroup.
+* @param {String} fnName The name of the function
+* @param {Function} fn The function to apply to each Calendar page object
+*/
+YAHOO.widget.CalendarGroup.prototype.setChildFunction = function(fnName, fn) {
+ for (var p=0;p<this.pageCount;++p) {
+ this.pages[p][fnName] = fn;
+ }
+}
+
+/**
+* Calls a function within all child Calendars within this CalendarGroup.
+* @param {String} fnName The name of the function
+* @param {Array} args The arguments to pass to the function
+*/
+YAHOO.widget.CalendarGroup.prototype.callChildFunction = function(fnName, args) {
+ for (var p=0;p<this.pageCount;++p) {
+ var page = this.pages[p];
+ if (page[fnName]) {
+ var fn = page[fnName];
+ fn.call(page, args);
+ }
+ }
+}
+
+/**
+* Constructs a child calendar. This method can be overridden if a subclassed version of the default
+* calendar is to be used.
+* @param {String} id The id of the element that will be inserted into the DOM.
+* @param {String} containerId The id of the container element that the calendar will be inserted into.
+* @param {String} monthyear The month/year string used to set the current calendar page
+* @param {String} selected A string of date values formatted using the date parser. The built-in
+ default date format is MM/DD/YYYY. Ranges are defined using
+ MM/DD/YYYY-MM/DD/YYYY. Month/day combinations are defined using MM/DD.
+ Any combination of these can be combined by delimiting the string with
+ commas. Example: "12/24/2005,12/25,1/18/2006-1/21/2006"
+* @return The YAHOO.widget.Calendar_Core instance that is constructed
+* @type YAHOO.widget.Calendar_Core
+*/
+YAHOO.widget.CalendarGroup.prototype.constructChild = function(id,containerId,monthyear,selected) {
+ return new YAHOO.widget.Calendar_Core(id,containerId,monthyear,selected);
+};
+
+
+/**
+* Sets the calendar group's month explicitly. This month will be set into the first
+* page of the multi-page calendar, and all other months will be iterated appropriately.
+* @param {Integer} month The numeric month, from 1 (January) to 12 (December)
+*/
+YAHOO.widget.CalendarGroup.prototype.setMonth = function(month) {
+ for (var p=0;p<this.pages.length;++p)
+ {
+ var cal = this.pages[p];
+ cal.setMonth(month+p);
+ }
+};
+
+/**
+* Sets the calendar group's year explicitly. This year will be set into the first
+* page of the multi-page calendar, and all other months will be iterated appropriately.
+* @param {Integer} year The numeric 4-digit year
+*/
+YAHOO.widget.CalendarGroup.prototype.setYear = function(year) {
+ for (var p=0;p<this.pages.length;++p)
+ {
+ var cal = this.pages[p];
+ if ((cal.pageDate.getMonth()+1) == 1 && p>0)
+ {
+ year+=1;
+ }
+ cal.setYear(year);
+ }
+};
+
+/**
+* Calls the render function of all child calendars within the group.
+*/
+YAHOO.widget.CalendarGroup.prototype.render = function() {
+ for (var p=0;p<this.pages.length;++p)
+ {
+ var cal = this.pages[p];
+ cal.render();
+ }
+};
+
+/**
+* Calls the select function of all child calendars within the group.
+*/
+YAHOO.widget.CalendarGroup.prototype.select = function(date) {
+ var ret;
+ for (var p=0;p<this.pages.length;++p)
+ {
+ var cal = this.pages[p];
+ ret = cal.select(date);
+ }
+ return ret;
+};
+
+/**
+* Calls the selectCell function of all child calendars within the group.
+*/
+YAHOO.widget.CalendarGroup.prototype.selectCell = function(cellIndex) {
+ var ret;
+ for (var p=0;p<this.pages.length;++p)
+ {
+ var cal = this.pages[p];
+ ret = cal.selectCell(cellIndex);
+ }
+ return ret;
+};
+
+/**
+* Calls the deselect function of all child calendars within the group.
+*/
+YAHOO.widget.CalendarGroup.prototype.deselect = function(date) {
+ var ret;
+ for (var p=0;p<this.pages.length;++p)
+ {
+ var cal = this.pages[p];
+ ret = cal.deselect(date);
+ }
+ return ret;
+};
+
+/**
+* Calls the deselectAll function of all child calendars within the group.
+*/
+YAHOO.widget.CalendarGroup.prototype.deselectAll = function() {
+ var ret;
+ for (var p=0;p<this.pages.length;++p)
+ {
+ var cal = this.pages[p];
+ ret = cal.deselectAll();
+ }
+ return ret;
+};
+
+/**
+* Calls the deselectAll function of all child calendars within the group.
+*/
+YAHOO.widget.CalendarGroup.prototype.deselectCell = function(cellIndex) {
+ for (var p=0;p<this.pages.length;++p)
+ {
+ var cal = this.pages[p];
+ cal.deselectCell(cellIndex);
+ }
+ return this.getSelectedDates();
+};
+
+/**
+* Calls the reset function of all child calendars within the group.
+*/
+YAHOO.widget.CalendarGroup.prototype.reset = function() {
+ for (var p=0;p<this.pages.length;++p)
+ {
+ var cal = this.pages[p];
+ cal.reset();
+ }
+};
+
+/**
+* Calls the clear function of all child calendars within the group.
+*/
+YAHOO.widget.CalendarGroup.prototype.clear = function() {
+ for (var p=0;p<this.pages.length;++p)
+ {
+ var cal = this.pages[p];
+ cal.clear();
+ }
+};
+
+/**
+* Calls the nextMonth function of all child calendars within the group.
+*/
+YAHOO.widget.CalendarGroup.prototype.nextMonth = function() {
+ for (var p=0;p<this.pages.length;++p)
+ {
+ var cal = this.pages[p];
+ cal.nextMonth();
+ }
+};
+
+/**
+* Calls the previousMonth function of all child calendars within the group.
+*/
+YAHOO.widget.CalendarGroup.prototype.previousMonth = function() {
+ for (var p=this.pages.length-1;p>=0;--p)
+ {
+ var cal = this.pages[p];
+ cal.previousMonth();
+ }
+};
+
+/**
+* Calls the nextYear function of all child calendars within the group.
+*/
+YAHOO.widget.CalendarGroup.prototype.nextYear = function() {
+ for (var p=0;p<this.pages.length;++p)
+ {
+ var cal = this.pages[p];
+ cal.nextYear();
+ }
+};
+
+/**
+* Calls the previousYear function of all child calendars within the group.
+*/
+YAHOO.widget.CalendarGroup.prototype.previousYear = function() {
+ for (var p=0;p<this.pages.length;++p)
+ {
+ var cal = this.pages[p];
+ cal.previousYear();
+ }
+};
+
+/**
+* Synchronizes the data values for all child calendars within the group. If the sync
+* method is called passing in the caller object, the values of all children will be set
+* to the values of the caller. If the argument is ommitted, the values from all children
+* will be combined into one distinct list and set into each child.
+* @param {YAHOO.widget.Calendar_Core} caller The YAHOO.widget.Calendar_Core that is initiating the call to sync().
+* @return Array of selected dates, in JavaScript Date object form.
+* @type Date[]
+*/
+YAHOO.widget.CalendarGroup.prototype.sync = function(caller) {
+ var calendar;
+
+ if (caller)
+ {
+ this.selectedDates = caller.selectedDates.concat();
+ } else {
+ var hash = new Object();
+ var combinedDates = new Array();
+
+ for (var p=0;p<this.pages.length;++p)
+ {
+ calendar = this.pages[p];
+
+ var values = calendar.selectedDates;
+
+ for (var v=0;v<values.length;++v)
+ {
+ var valueArray = values[v];
+ hash[valueArray.toString()] = valueArray;
+ }
+ }
+
+ for (var val in hash)
+ {
+ combinedDates[combinedDates.length]=hash[val];
+ }
+
+ this.selectedDates = combinedDates.concat();
+ }
+
+ // Set all the values into the children
+ for (p=0;p<this.pages.length;++p)
+ {
+ calendar = this.pages[p];
+ if (! calendar.Options.MULTI_SELECT) {
+ calendar.clearAllBodyCellStyles(calendar.Config.Style.CSS_CELL_SELECTED);
+ }
+ calendar.selectedDates = this.selectedDates.concat();
+
+ }
+
+ return this.getSelectedDates();
+};
+
+/**
+* Gets the list of currently selected dates from the calendar.
+* @return An array of currently selected JavaScript Date objects.
+* @type Date[]
+*/
+YAHOO.widget.CalendarGroup.prototype.getSelectedDates = function() {
+ var returnDates = new Array();
+
+ for (var d=0;d<this.selectedDates.length;++d)
+ {
+ var dateArray = this.selectedDates[d];
+
+ var date = new Date(dateArray[0],dateArray[1]-1,dateArray[2]);
+ returnDates.push(date);
+ }
+
+ returnDates.sort();
+ return returnDates;
+};
+
+/**
+* Calls the addRenderer function of all child calendars within the group.
+*/
+YAHOO.widget.CalendarGroup.prototype.addRenderer = function(sDates, fnRender) {
+ for (var p=0;p<this.pages.length;++p)
+ {
+ var cal = this.pages[p];
+ cal.addRenderer(sDates, fnRender);
+ }
+};
+
+/**
+* Calls the addMonthRenderer function of all child calendars within the group.
+*/
+YAHOO.widget.CalendarGroup.prototype.addMonthRenderer = function(month, fnRender) {
+ for (var p=0;p<this.pages.length;++p)
+ {
+ var cal = this.pages[p];
+ cal.addMonthRenderer(month, fnRender);
+ }
+};
+
+/**
+* Calls the addWeekdayRenderer function of all child calendars within the group.
+*/
+YAHOO.widget.CalendarGroup.prototype.addWeekdayRenderer = function(weekday, fnRender) {
+ for (var p=0;p<this.pages.length;++p)
+ {
+ var cal = this.pages[p];
+ cal.addWeekdayRenderer(weekday, fnRender);
+ }
+};
+
+/**
+* Sets an event handler universally across all child calendars within the group. For instance,
+* to set the onSelect handler for all child calendars to a function called fnSelect, the call would be:
+* <code>
+* calGroup.wireEvent("onSelect", fnSelect);
+* </code>
+* @param {String} eventName The name of the event to handler to set within all child calendars.
+* @param {Function} fn The function to set into the specified event handler.
+*/
+YAHOO.widget.CalendarGroup.prototype.wireEvent = function(eventName, fn) {
+ for (var p=0;p<this.pages.length;++p)
+ {
+ var cal = this.pages[p];
+ cal[eventName] = fn;
+ }
+};
+
+/**
+* Returns a string representation of the object.
+* @type string
+*/
+YAHOO.widget.CalendarGroup.prototype.toString = function() {
+ return "CalendarGroup " + this.id;
+}
+
+YAHOO.widget.CalGrp = YAHOO.widget.CalendarGroup;/**
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+**/
+
+/**
+* @class
+* Calendar2up_Cal is the default implementation of the Calendar_Core base class, when used
+* in a 2-up view. This class is the UED-approved version of the calendar selector widget. For all documentation
+* on the implemented methods listed here, see the documentation for Calendar_Core. This class
+* has some special attributes that only apply to calendars rendered within the calendar group implementation.
+* There should be no reason to instantiate this class directly.
+* @constructor
+* @param {String} id The id of the table element that will represent the calendar widget
+* @param {String} containerId The id of the container element that will contain the calendar table
+* @param {String} monthyear The month/year string used to set the current calendar page
+* @param {String} selected A string of date values formatted using the date parser. The built-in
+ default date format is MM/DD/YYYY. Ranges are defined using
+ MM/DD/YYYY-MM/DD/YYYY. Month/day combinations are defined using MM/DD.
+ Any combination of these can be combined by delimiting the string with
+ commas. Example: "12/24/2005,12/25,1/18/2006-1/21/2006"
+*/
+YAHOO.widget.Calendar2up_Cal = function(id, containerId, monthyear, selected) {
+ if (arguments.length > 0)
+ {
+ this.init(id, containerId, monthyear, selected);
+ }
+}
+
+YAHOO.widget.Calendar2up_Cal.prototype = new YAHOO.widget.Calendar_Core();
+
+/**
+* Renders the header for each individual calendar in the 2-up view. More
+* specifically, this method handles the placement of left and right arrows for
+* navigating between calendar pages.
+*/
+YAHOO.widget.Calendar2up_Cal.prototype.renderHeader = function() {
+ this.headerCell.innerHTML = "";
+
+ var headerContainer = document.createElement("DIV");
+ headerContainer.className = this.Style.CSS_HEADER;
+
+ if (this.index == 0) {
+
+ if (this.linkLeft) {
+ YAHOO.util.Event.removeListener(this.linkLeft, "mousedown", this.parent.doPreviousMonth);
+ }
+ this.linkLeft = document.createElement("A");
+ this.linkLeft.innerHTML = " ";
+ this.linkLeft.style.backgroundImage = "url(" + this.Options.NAV_ARROW_LEFT + ")";
+ this.linkLeft.className = this.Style.CSS_NAV_LEFT;
+
+ YAHOO.util.Event.addListener(this.linkLeft, "mousedown", this.parent.doPreviousMonth, this.parent);
+ headerContainer.appendChild(this.linkLeft);
+ }
+
+ headerContainer.appendChild(document.createTextNode(this.buildMonthLabel()));
+
+ if (this.index == 1) {
+
+ if (this.linkRight) {
+ YAHOO.util.Event.removeListener(this.linkRight, "mousedown", this.parent.doNextMonth);
+ }
+ this.linkRight = document.createElement("A");
+ this.linkRight.innerHTML = " ";
+ this.linkRight.style.backgroundImage = "url(" + this.Options.NAV_ARROW_RIGHT + ")";
+ this.linkRight.className = this.Style.CSS_NAV_RIGHT;
+
+ YAHOO.util.Event.addListener(this.linkRight, "mousedown", this.parent.doNextMonth, this.parent);
+ headerContainer.appendChild(this.linkRight);
+ }
+
+ this.headerCell.appendChild(headerContainer);
+};
+
+
+
+
+/**
+* @class
+* Calendar2up is the default implementation of the CalendarGroup base class, when used
+* in a 2-up view. This class is the UED-approved version of the 2-up calendar selector widget. For all documentation
+* on the implemented methods listed here, see the documentation for CalendarGroup.
+* @constructor
+* @param {String} id The id of the table element that will represent the calendar widget
+* @param {String} containerId The id of the container element that will contain the calendar table
+* @param {String} monthyear The month/year string used to set the current calendar page
+* @param {String} selected A string of date values formatted using the date parser. The built-in
+ default date format is MM/DD/YYYY. Ranges are defined using
+ MM/DD/YYYY-MM/DD/YYYY. Month/day combinations are defined using MM/DD.
+ Any combination of these can be combined by delimiting the string with
+ commas. Example: "12/24/2005,12/25,1/18/2006-1/21/2006"
+*/
+YAHOO.widget.Calendar2up = function(id, containerId, monthyear, selected) {
+ if (arguments.length > 0)
+ {
+ this.buildWrapper(containerId);
+ this.init(2, id, containerId, monthyear, selected);
+ }
+}
+
+YAHOO.widget.Calendar2up.prototype = new YAHOO.widget.CalendarGroup();
+
+/**
+* CSS class representing the wrapper for the 2-up calendar
+* @type string
+*/
+YAHOO.widget.Calendar2up.CSS_2UPWRAPPER = "yui-cal2upwrapper";
+
+/**
+* CSS class representing the container for the calendar
+* @type string
+*/
+YAHOO.widget.Calendar2up.CSS_CONTAINER = "yui-calcontainer";
+
+/**
+* CSS class representing the container for the 2-up calendar
+* @type string
+*/
+YAHOO.widget.Calendar2up.CSS_2UPCONTAINER = "cal2up";
+
+/**
+* CSS class representing the title for the 2-up calendar
+* @type string
+*/
+YAHOO.widget.Calendar2up.CSS_2UPTITLE = "title";
+
+/**
+* CSS class representing the close icon for the 2-up calendar
+* @type string
+*/
+YAHOO.widget.Calendar2up.CSS_2UPCLOSE = "close-icon";
+
+/**
+* Implementation of CalendarGroup.constructChild that ensures that child calendars of
+* Calendar2up will be of type Calendar2up_Cal.
+*/
+YAHOO.widget.Calendar2up.prototype.constructChild = function(id,containerId,monthyear,selected) {
+ var cal = new YAHOO.widget.Calendar2up_Cal(id,containerId,monthyear,selected);
+ return cal;
+};
+
+/**
+* Builds the wrapper container for the 2-up calendar.
+* @param {String} containerId The id of the outer container element.
+*/
+YAHOO.widget.Calendar2up.prototype.buildWrapper = function(containerId) {
+ var outerContainer = document.getElementById(containerId);
+
+ outerContainer.className = YAHOO.widget.Calendar2up.CSS_2UPWRAPPER;
+
+ var innerContainer = document.createElement("DIV");
+ innerContainer.className = YAHOO.widget.Calendar2up.CSS_CONTAINER;
+ innerContainer.id = containerId + "_inner";
+
+ var cal1Container = document.createElement("DIV");
+ cal1Container.id = containerId + "_0";
+ cal1Container.className = YAHOO.widget.Calendar2up.CSS_2UPCONTAINER;
+ cal1Container.style.marginRight = "10px";
+
+ var cal2Container = document.createElement("DIV");
+ cal2Container.id = containerId + "_1";
+ cal2Container.className = YAHOO.widget.Calendar2up.CSS_2UPCONTAINER;
+
+ outerContainer.appendChild(innerContainer);
+ innerContainer.appendChild(cal1Container);
+ innerContainer.appendChild(cal2Container);
+
+ this.innerContainer = innerContainer;
+ this.outerContainer = outerContainer;
+}
+
+/**
+* Renders the 2-up calendar.
+*/
+YAHOO.widget.Calendar2up.prototype.render = function() {
+ this.renderHeader();
+ YAHOO.widget.CalendarGroup.prototype.render.call(this);
+ this.renderFooter();
+};
+
+/**
+* Renders the header located at the top of the container for the 2-up calendar.
+*/
+YAHOO.widget.Calendar2up.prototype.renderHeader = function() {
+ if (! this.title) {
+ this.title = "";
+ }
+ if (! this.titleDiv)
+ {
+ this.titleDiv = document.createElement("DIV");
+ if (this.title == "")
+ {
+ this.titleDiv.style.display="none";
+ }
+ }
+
+ this.titleDiv.className = YAHOO.widget.Calendar2up.CSS_2UPTITLE;
+ this.titleDiv.innerHTML = this.title;
+
+ if (this.outerContainer.style.position == "absolute")
+ {
+ var linkClose = document.createElement("A");
+ linkClose.href = "javascript:void(null)";
+ YAHOO.util.Event.addListener(linkClose, "click", this.hide, this);
+
+ var imgClose = document.createElement("IMG");
+ imgClose.src = YAHOO.widget.Calendar_Core.IMG_ROOT + "us/my/bn/x_d.gif";
+ imgClose.className = YAHOO.widget.Calendar2up.CSS_2UPCLOSE;
+
+ linkClose.appendChild(imgClose);
+
+ this.linkClose = linkClose;
+
+ this.titleDiv.appendChild(linkClose);
+ }
+
+ this.innerContainer.insertBefore(this.titleDiv, this.innerContainer.firstChild);
+}
+
+/**
+* Hides the 2-up calendar's outer container from view.
+*/
+YAHOO.widget.Calendar2up.prototype.hide = function(e, cal) {
+ if (! cal)
+ {
+ cal = this;
+ }
+ cal.outerContainer.style.display = "none";
+}
+
+/**
+* Renders a footer for the 2-up calendar container. By default, this method is
+* unimplemented.
+*/
+YAHOO.widget.Calendar2up.prototype.renderFooter = function() {}
+
+YAHOO.widget.Cal2up = YAHOO.widget.Calendar2up;
\ No newline at end of file
Added: branches/tomek/portal-dnd/dndRenderer.war/js/calendar/calendar-min.js
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/calendar/calendar-min.js 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/calendar/calendar-min.js 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,155 @@
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 0.11.0
+*/
+YAHOO.widget.DateMath=new function(){this.DAY="D";this.WEEK="W";this.YEAR="Y";this.MONTH="M";this.ONE_DAY_MS=1000*60*60*24;this.add=function(date,field,amount){var d=new Date(date.getTime());switch(field){case this.MONTH:var newMonth=date.getMonth()+amount;var years=0;if(newMonth<0){while(newMonth<0){newMonth+=12;years-=1;}}else if(newMonth>11){while(newMonth>11){newMonth-=12;years+=1;}}
+d.setMonth(newMonth);d.setFullYear(date.getFullYear()+years);break;case this.DAY:d.setDate(date.getDate()+amount);break;case this.YEAR:d.setFullYear(date.getFullYear()+amount);break;case this.WEEK:d.setDate(date.getDate()+(amount*7));break;}
+return d;};this.subtract=function(date,field,amount){return this.add(date,field,(amount*-1));};this.before=function(date,compareTo){var ms=compareTo.getTime();if(date.getTime()<ms){return true;}else{return false;}};this.after=function(date,compareTo){var ms=compareTo.getTime();if(date.getTime()>ms){return true;}else{return false;}};this.between=function(date,dateBegin,dateEnd){if(this.after(date,dateBegin)&&this.before(date,dateEnd)){return true;}else{return false;}};this.getJan1=function(calendarYear){return new Date(calendarYear,0,1);};this.getDayOffset=function(date,calendarYear){var beginYear=this.getJan1(calendarYear);var dayOffset=Math.ceil((date.getTime()-beginYear.getTime())/this.ONE_DAY_MS);return dayOffset;};this.getWeekNumber=function(date,calendarYear,weekStartsOn){date.setHours(12,0,0,0);if(!weekStartsOn){weekStartsOn=0;}
+if(!calendarYear){calendarYear=date.getFullYear();}
+var weekNum=-1;var jan1=this.getJan1(calendarYear);var jan1Offset=jan1.getDay()-weekStartsOn;var jan1DayOfWeek=(jan1Offset>=0?jan1Offset:(7+jan1Offset));var endOfWeek1=this.add(jan1,this.DAY,(6-jan1DayOfWeek));endOfWeek1.setHours(23,59,59,999);var month=date.getMonth();var day=date.getDate();var year=date.getFullYear();var dayOffset=this.getDayOffset(date,calendarYear);if(dayOffset<0||this.before(date,endOfWeek1)){weekNum=1;}else{weekNum=2;var weekBegin=new Date(endOfWeek1.getTime()+1);var weekEnd=this.add(weekBegin,this.WEEK,1);while(!this.between(date,weekBegin,weekEnd)){weekBegin=this.add(weekBegin,this.WEEK,1);weekEnd=this.add(weekEnd,this.WEEK,1);weekNum+=1;}}
+return weekNum;};this.isYearOverlapWeek=function(weekBeginDate){var overlaps=false;var nextWeek=this.add(weekBeginDate,this.DAY,6);if(nextWeek.getFullYear()!=weekBeginDate.getFullYear()){overlaps=true;}
+return overlaps;};this.isMonthOverlapWeek=function(weekBeginDate){var overlaps=false;var nextWeek=this.add(weekBeginDate,this.DAY,6);if(nextWeek.getMonth()!=weekBeginDate.getMonth()){overlaps=true;}
+return overlaps;};this.findMonthStart=function(date){var start=new Date(date.getFullYear(),date.getMonth(),1);return start;};this.findMonthEnd=function(date){var start=this.findMonthStart(date);var nextMonth=this.add(start,this.MONTH,1);var end=this.subtract(nextMonth,this.DAY,1);return end;};this.clearTime=function(date){date.setHours(0,0,0,0);return date;};}
+YAHOO.widget.Calendar_Core=function(id,containerId,monthyear,selected){if(arguments.length>0){this.init(id,containerId,monthyear,selected);}}
+YAHOO.widget.Calendar_Core.IMG_ROOT=(window.location.href.toLowerCase().indexOf("https")==0?"https://a248.e.akamai.net/sec.yimg.com/i/":"http://us.i1.yimg.com/us.yimg.com/i/");YAHOO.widget.Calendar_Core.DATE="D";YAHOO.widget.Calendar_Core.MONTH_DAY="MD";YAHOO.widget.Calendar_Core.WEEKDAY="WD";YAHOO.widget.Calendar_Core.RANGE="R";YAHOO.widget.Calendar_Core.MONTH="M";YAHOO.widget.Calendar_Core.DISPLAY_DAYS=42;YAHOO.widget.Calendar_Core.STOP_RENDER="S";YAHOO.widget.Calendar_Core.prototype={Config:null,parent:null,index:-1,cells:null,weekHeaderCells:null,weekFooterCells:null,cellDates:null,id:null,oDomContainer:null,today:null,renderStack:null,_renderStack:null,pageDate:null,_pageDate:null,minDate:null,maxDate:null,selectedDates:null,_selectedDates:null,shellRendered:false,table:null,headerCell:null};YAHOO.widget.Calendar_Core.prototype.init=function(id,containerId,monthyear,selected){this.setupConfig();this.id=id;this.cellDates=new Array();this.cells=new Array();this.renderSta!
ck=new Array();this._renderStack=new Array();this.oDomContainer=document.getElementById(containerId);this.today=new Date();YAHOO.widget.DateMath.clearTime(this.today);var month;var year;if(monthyear){var aMonthYear=monthyear.split(this.Locale.DATE_FIELD_DELIMITER);month=parseInt(aMonthYear[this.Locale.MY_MONTH_POSITION-1]);year=parseInt(aMonthYear[this.Locale.MY_YEAR_POSITION-1]);}else{month=this.today.getMonth()+1;year=this.today.getFullYear();}
+this.pageDate=new Date(year,month-1,1);this._pageDate=new Date(this.pageDate.getTime());if(selected){this.selectedDates=this._parseDates(selected);this._selectedDates=this.selectedDates.concat();}else{this.selectedDates=new Array();this._selectedDates=new Array();}
+this.wireDefaultEvents();this.wireCustomEvents();};YAHOO.widget.Calendar_Core.prototype.wireDefaultEvents=function(){this.doSelectCell=function(e,cal){var cell=this;var index=cell.index;var d=cal.cellDates[index];var date=new Date(d[0],d[1]-1,d[2]);if(!cal.isDateOOM(date)&&!YAHOO.util.Dom.hasClass(cell,cal.Style.CSS_CELL_RESTRICTED)&&!YAHOO.util.Dom.hasClass(cell,cal.Style.CSS_CELL_OOB)){if(cal.Options.MULTI_SELECT){var link=cell.getElementsByTagName("A")[0];link.blur();var cellDate=cal.cellDates[index];var cellDateIndex=cal._indexOfSelectedFieldArray(cellDate);if(cellDateIndex>-1){cal.deselectCell(index);}else{cal.selectCell(index);}}else{var link=cell.getElementsByTagName("A")[0];link.blur()
+cal.selectCell(index);}}}
+this.doCellMouseOver=function(e,cal){var cell=this;var index=cell.index;var d=cal.cellDates[index];var date=new Date(d[0],d[1]-1,d[2]);if(!cal.isDateOOM(date)&&!YAHOO.util.Dom.hasClass(cell,cal.Style.CSS_CELL_RESTRICTED)&&!YAHOO.util.Dom.hasClass(cell,cal.Style.CSS_CELL_OOB)){YAHOO.util.Dom.addClass(cell,cal.Style.CSS_CELL_HOVER);}}
+this.doCellMouseOut=function(e,cal){YAHOO.util.Dom.removeClass(this,cal.Style.CSS_CELL_HOVER);}
+this.doNextMonth=function(e,cal){cal.nextMonth();}
+this.doPreviousMonth=function(e,cal){cal.previousMonth();}}
+YAHOO.widget.Calendar_Core.prototype.wireCustomEvents=function(){}
+YAHOO.widget.Calendar_Core.prototype.setupConfig=function(){this.Config=new Object();this.Config.Style={CSS_ROW_HEADER:"calrowhead",CSS_ROW_FOOTER:"calrowfoot",CSS_CELL:"calcell",CSS_CELL_SELECTED:"selected",CSS_CELL_RESTRICTED:"restricted",CSS_CELL_TODAY:"today",CSS_CELL_OOM:"oom",CSS_CELL_OOB:"previous",CSS_HEADER:"calheader",CSS_HEADER_TEXT:"calhead",CSS_WEEKDAY_CELL:"calweekdaycell",CSS_WEEKDAY_ROW:"calweekdayrow",CSS_FOOTER:"calfoot",CSS_CALENDAR:"yui-calendar",CSS_CONTAINER:"yui-calcontainer",CSS_2UPWRAPPER:"yui-cal2upwrapper",CSS_NAV_LEFT:"calnavleft",CSS_NAV_RIGHT:"calnavright",CSS_CELL_TOP:"calcelltop",CSS_CELL_LEFT:"calcellleft",CSS_CELL_RIGHT:"calcellright",CSS_CELL_BOTTOM:"calcellbottom",CSS_CELL_HOVER:"calcellhover",CSS_CELL_HIGHLIGHT1:"highlight1",CSS_CELL_HIGHLIGHT2:"highlight2",CSS_CELL_HIGHLIGHT3:"highlight3",CSS_CELL_HIGHLIGHT4:"highlight4"};this.Style=this.Config.Style;this.Config.Locale={MONTHS_SHORT:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep"!
,"Oct","Nov","Dec"],MONTHS_LONG:["January","February","March","April","May","June","July","August","September","October","November","December"],WEEKDAYS_1CHAR:["S","M","T","W","T","F","S"],WEEKDAYS_SHORT:["Su","Mo","Tu","We","Th","Fr","Sa"],WEEKDAYS_MEDIUM:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],WEEKDAYS_LONG:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],DATE_DELIMITER:",",DATE_FIELD_DELIMITER:"/",DATE_RANGE_DELIMITER:"-",MY_MONTH_POSITION:1,MY_YEAR_POSITION:2,MD_MONTH_POSITION:1,MD_DAY_POSITION:2,MDY_MONTH_POSITION:1,MDY_DAY_POSITION:2,MDY_YEAR_POSITION:3};this.Locale=this.Config.Locale;this.Config.Options={MULTI_SELECT:false,SHOW_WEEKDAYS:true,START_WEEKDAY:0,SHOW_WEEK_HEADER:false,SHOW_WEEK_FOOTER:false,HIDE_BLANK_WEEKS:false,NAV_ARROW_LEFT:YAHOO.widget.Calendar_Core.IMG_ROOT+"us/tr/callt.gif",NAV_ARROW_RIGHT:YAHOO.widget.Calendar_Core.IMG_ROOT+"us/tr/calrt.gif"};this.Options=this.Config.Options;this.customConfig();if(!this.Options.LOCALE_M!
ONTHS){this.Options.LOCALE_MONTHS=this.Locale.MONTHS_LONG;}
+if(!this.Options.LOCALE_WEEKDAYS){this.Options.LOCALE_WEEKDAYS=this.Locale.WEEKDAYS_SHORT;}
+if(this.Options.START_WEEKDAY>0){for(var w=0;w<this.Options.START_WEEKDAY;++w){this.Locale.WEEKDAYS_SHORT.push(this.Locale.WEEKDAYS_SHORT.shift());this.Locale.WEEKDAYS_MEDIUM.push(this.Locale.WEEKDAYS_MEDIUM.shift());this.Locale.WEEKDAYS_LONG.push(this.Locale.WEEKDAYS_LONG.shift());}}};YAHOO.widget.Calendar_Core.prototype.customConfig=function(){};YAHOO.widget.Calendar_Core.prototype.buildMonthLabel=function(){var text=this.Options.LOCALE_MONTHS[this.pageDate.getMonth()]+" "+this.pageDate.getFullYear();return text;};YAHOO.widget.Calendar_Core.prototype.buildDayLabel=function(workingDate){var day=workingDate.getDate();return day;};YAHOO.widget.Calendar_Core.prototype.buildShell=function(){this.table=document.createElement("TABLE");this.table.cellSpacing=0;YAHOO.widget.Calendar_Core.setCssClasses(this.table,[this.Style.CSS_CALENDAR]);this.table.id=this.id;this.buildShellHeader();this.buildShellBody();this.buildShellFooter();YAHOO.util.Event.addListener(window,"unload",this._u!
nload,this);};YAHOO.widget.Calendar_Core.prototype.buildShellHeader=function(){var head=document.createElement("THEAD");var headRow=document.createElement("TR");var headerCell=document.createElement("TH");var colSpan=7;if(this.Config.Options.SHOW_WEEK_HEADER){this.weekHeaderCells=new Array();colSpan+=1;}
+if(this.Config.Options.SHOW_WEEK_FOOTER){this.weekFooterCells=new Array();colSpan+=1;}
+headerCell.colSpan=colSpan;YAHOO.widget.Calendar_Core.setCssClasses(headerCell,[this.Style.CSS_HEADER_TEXT]);this.headerCell=headerCell;headRow.appendChild(headerCell);head.appendChild(headRow);if(this.Options.SHOW_WEEKDAYS){var row=document.createElement("TR");var fillerCell;YAHOO.widget.Calendar_Core.setCssClasses(row,[this.Style.CSS_WEEKDAY_ROW]);if(this.Config.Options.SHOW_WEEK_HEADER){fillerCell=document.createElement("TH");YAHOO.widget.Calendar_Core.setCssClasses(fillerCell,[this.Style.CSS_WEEKDAY_CELL]);row.appendChild(fillerCell);}
+for(var i=0;i<this.Options.LOCALE_WEEKDAYS.length;++i){var cell=document.createElement("TH");YAHOO.widget.Calendar_Core.setCssClasses(cell,[this.Style.CSS_WEEKDAY_CELL]);cell.innerHTML=this.Options.LOCALE_WEEKDAYS[i];row.appendChild(cell);}
+if(this.Config.Options.SHOW_WEEK_FOOTER){fillerCell=document.createElement("TH");YAHOO.widget.Calendar_Core.setCssClasses(fillerCell,[this.Style.CSS_WEEKDAY_CELL]);row.appendChild(fillerCell);}
+head.appendChild(row);}
+this.table.appendChild(head);};YAHOO.widget.Calendar_Core.prototype.buildShellBody=function(){this.tbody=document.createElement("TBODY");for(var r=0;r<6;++r){var row=document.createElement("TR");for(var c=0;c<this.headerCell.colSpan;++c){var cell;if(this.Config.Options.SHOW_WEEK_HEADER&&c===0){cell=document.createElement("TH");this.weekHeaderCells[this.weekHeaderCells.length]=cell;}else if(this.Config.Options.SHOW_WEEK_FOOTER&&c==(this.headerCell.colSpan-1)){cell=document.createElement("TH");this.weekFooterCells[this.weekFooterCells.length]=cell;}else{cell=document.createElement("TD");this.cells[this.cells.length]=cell;YAHOO.widget.Calendar_Core.setCssClasses(cell,[this.Style.CSS_CELL]);YAHOO.util.Event.addListener(cell,"click",this.doSelectCell,this);YAHOO.util.Event.addListener(cell,"mouseover",this.doCellMouseOver,this);YAHOO.util.Event.addListener(cell,"mouseout",this.doCellMouseOut,this);}
+row.appendChild(cell);}
+this.tbody.appendChild(row);}
+this.table.appendChild(this.tbody);};YAHOO.widget.Calendar_Core.prototype.buildShellFooter=function(){};YAHOO.widget.Calendar_Core.prototype.renderShell=function(){this.oDomContainer.appendChild(this.table);this.shellRendered=true;};YAHOO.widget.Calendar_Core.prototype.render=function(){if(!this.shellRendered){this.buildShell();this.renderShell();}
+this.resetRenderers();this.cellDates.length=0;var workingDate=YAHOO.widget.DateMath.findMonthStart(this.pageDate);this.renderHeader();this.renderBody(workingDate);this.renderFooter();this.onRender();};YAHOO.widget.Calendar_Core.prototype.renderHeader=function(){this.headerCell.innerHTML="";var headerContainer=document.createElement("DIV");headerContainer.className=this.Style.CSS_HEADER;headerContainer.appendChild(document.createTextNode(this.buildMonthLabel()));this.headerCell.appendChild(headerContainer);};YAHOO.widget.Calendar_Core.prototype.renderBody=function(workingDate){this.preMonthDays=workingDate.getDay();if(this.Options.START_WEEKDAY>0){this.preMonthDays-=this.Options.START_WEEKDAY;}
+if(this.preMonthDays<0){this.preMonthDays+=7;}
+this.monthDays=YAHOO.widget.DateMath.findMonthEnd(workingDate).getDate();this.postMonthDays=YAHOO.widget.Calendar_Core.DISPLAY_DAYS-this.preMonthDays-this.monthDays;workingDate=YAHOO.widget.DateMath.subtract(workingDate,YAHOO.widget.DateMath.DAY,this.preMonthDays);var weekRowIndex=0;for(var c=0;c<this.cells.length;++c){var cellRenderers=new Array();var cell=this.cells[c];this.clearElement(cell);cell.index=c;cell.id=this.id+"_cell"+c;this.cellDates[this.cellDates.length]=[workingDate.getFullYear(),workingDate.getMonth()+1,workingDate.getDate()];if(workingDate.getDay()==this.Options.START_WEEKDAY){var rowHeaderCell=null;var rowFooterCell=null;if(this.Options.SHOW_WEEK_HEADER){rowHeaderCell=this.weekHeaderCells[weekRowIndex];this.clearElement(rowHeaderCell);}
+if(this.Options.SHOW_WEEK_FOOTER){rowFooterCell=this.weekFooterCells[weekRowIndex];this.clearElement(rowFooterCell);}
+if(this.Options.HIDE_BLANK_WEEKS&&this.isDateOOM(workingDate)&&!YAHOO.widget.DateMath.isMonthOverlapWeek(workingDate)){continue;}else{if(rowHeaderCell){this.renderRowHeader(workingDate,rowHeaderCell);}
+if(rowFooterCell){this.renderRowFooter(workingDate,rowFooterCell);}}}
+var renderer=null;if(workingDate.getFullYear()==this.today.getFullYear()&&workingDate.getMonth()==this.today.getMonth()&&workingDate.getDate()==this.today.getDate()){cellRenderers[cellRenderers.length]=this.renderCellStyleToday;}
+if(this.isDateOOM(workingDate)){cellRenderers[cellRenderers.length]=this.renderCellNotThisMonth;}else{for(var r=0;r<this.renderStack.length;++r){var rArray=this.renderStack[r];var type=rArray[0];var month;var day;var year;switch(type){case YAHOO.widget.Calendar_Core.DATE:month=rArray[1][1];day=rArray[1][2];year=rArray[1][0];if(workingDate.getMonth()+1==month&&workingDate.getDate()==day&&workingDate.getFullYear()==year){renderer=rArray[2];this.renderStack.splice(r,1);}
+break;case YAHOO.widget.Calendar_Core.MONTH_DAY:month=rArray[1][0];day=rArray[1][1];if(workingDate.getMonth()+1==month&&workingDate.getDate()==day){renderer=rArray[2];this.renderStack.splice(r,1);}
+break;case YAHOO.widget.Calendar_Core.RANGE:var date1=rArray[1][0];var date2=rArray[1][1];var d1month=date1[1];var d1day=date1[2];var d1year=date1[0];var d1=new Date(d1year,d1month-1,d1day);var d2month=date2[1];var d2day=date2[2];var d2year=date2[0];var d2=new Date(d2year,d2month-1,d2day);if(workingDate.getTime()>=d1.getTime()&&workingDate.getTime()<=d2.getTime()){renderer=rArray[2];if(workingDate.getTime()==d2.getTime()){this.renderStack.splice(r,1);}}
+break;case YAHOO.widget.Calendar_Core.WEEKDAY:var weekday=rArray[1][0];if(workingDate.getDay()+1==weekday){renderer=rArray[2];}
+break;case YAHOO.widget.Calendar_Core.MONTH:month=rArray[1][0];if(workingDate.getMonth()+1==month){renderer=rArray[2];}
+break;}
+if(renderer){cellRenderers[cellRenderers.length]=renderer;}}}
+if(this._indexOfSelectedFieldArray([workingDate.getFullYear(),workingDate.getMonth()+1,workingDate.getDate()])>-1){cellRenderers[cellRenderers.length]=this.renderCellStyleSelected;}
+if(this.minDate){this.minDate=YAHOO.widget.DateMath.clearTime(this.minDate);}
+if(this.maxDate){this.maxDate=YAHOO.widget.DateMath.clearTime(this.maxDate);}
+if((this.minDate&&(workingDate.getTime()<this.minDate.getTime()))||(this.maxDate&&(workingDate.getTime()>this.maxDate.getTime()))){cellRenderers[cellRenderers.length]=this.renderOutOfBoundsDate;}else{cellRenderers[cellRenderers.length]=this.renderCellDefault;}
+for(var x=0;x<cellRenderers.length;++x){var ren=cellRenderers[x];if(ren.call(this,workingDate,cell)==YAHOO.widget.Calendar_Core.STOP_RENDER){break;}}
+workingDate=YAHOO.widget.DateMath.add(workingDate,YAHOO.widget.DateMath.DAY,1);if(workingDate.getDay()==this.Options.START_WEEKDAY){weekRowIndex+=1;}
+YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL);if(c>=0&&c<=6){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_TOP);}
+if((c%7)==0){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_LEFT);}
+if(((c+1)%7)==0){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_RIGHT);}
+var postDays=this.postMonthDays;if(postDays>=7&&this.Options.HIDE_BLANK_WEEKS){var blankWeeks=Math.floor(postDays/7);for(var p=0;p<blankWeeks;++p){postDays-=7;}}
+if(c>=((this.preMonthDays+postDays+this.monthDays)-7)){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_BOTTOM);}}};YAHOO.widget.Calendar_Core.prototype.renderFooter=function(){};YAHOO.widget.Calendar_Core.prototype._unload=function(e,cal){for(var c in cal.cells){c=null;}
+cal.cells=null;cal.tbody=null;cal.oDomContainer=null;cal.table=null;cal.headerCell=null;cal=null;};YAHOO.widget.Calendar_Core.prototype.renderOutOfBoundsDate=function(workingDate,cell){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_OOB);cell.innerHTML=workingDate.getDate();return YAHOO.widget.Calendar_Core.STOP_RENDER;}
+YAHOO.widget.Calendar_Core.prototype.renderRowHeader=function(workingDate,cell){YAHOO.util.Dom.addClass(cell,this.Style.CSS_ROW_HEADER);var useYear=this.pageDate.getFullYear();if(!YAHOO.widget.DateMath.isYearOverlapWeek(workingDate)){useYear=workingDate.getFullYear();}
+var weekNum=YAHOO.widget.DateMath.getWeekNumber(workingDate,useYear,this.Options.START_WEEKDAY);cell.innerHTML=weekNum;if(this.isDateOOM(workingDate)&&!YAHOO.widget.DateMath.isMonthOverlapWeek(workingDate)){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_OOM);}};YAHOO.widget.Calendar_Core.prototype.renderRowFooter=function(workingDate,cell){YAHOO.util.Dom.addClass(cell,this.Style.CSS_ROW_FOOTER);if(this.isDateOOM(workingDate)&&!YAHOO.widget.DateMath.isMonthOverlapWeek(workingDate)){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_OOM);}};YAHOO.widget.Calendar_Core.prototype.renderCellDefault=function(workingDate,cell){cell.innerHTML="";var link=document.createElement("a");link.href="javascript:void(null);";link.name=this.id+"__"+workingDate.getFullYear()+"_"+(workingDate.getMonth()+1)+"_"+workingDate.getDate();link.appendChild(document.createTextNode(this.buildDayLabel(workingDate)));cell.appendChild(link);};YAHOO.widget.Calendar_Core.prototype.renderCellStyleHighlight1=fu!
nction(workingDate,cell){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_HIGHLIGHT1);};YAHOO.widget.Calendar_Core.prototype.renderCellStyleHighlight2=function(workingDate,cell){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_HIGHLIGHT2);};YAHOO.widget.Calendar_Core.prototype.renderCellStyleHighlight3=function(workingDate,cell){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_HIGHLIGHT3);};YAHOO.widget.Calendar_Core.prototype.renderCellStyleHighlight4=function(workingDate,cell){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_HIGHLIGHT4);};YAHOO.widget.Calendar_Core.prototype.renderCellStyleToday=function(workingDate,cell){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_TODAY);};YAHOO.widget.Calendar_Core.prototype.renderCellStyleSelected=function(workingDate,cell){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_SELECTED);};YAHOO.widget.Calendar_Core.prototype.renderCellNotThisMonth=function(workingDate,cell){YAHOO.util.Dom.addClass(cell,this.Style.CSS_CELL_OOM);cell.inn!
erHTML=workingDate.getDate();return YAHOO.widget.Calendar_Core.STOP_RE
NDER;};YAHOO.widget.Calendar_Core.prototype.renderBodyCellRestricted=function(workingDate,cell){YAHOO.widget.Calendar_Core.setCssClasses(cell,[this.Style.CSS_CELL,this.Style.CSS_CELL_RESTRICTED]);cell.innerHTML=workingDate.getDate();return YAHOO.widget.Calendar_Core.STOP_RENDER;};YAHOO.widget.Calendar_Core.prototype.addMonths=function(count){this.pageDate=YAHOO.widget.DateMath.add(this.pageDate,YAHOO.widget.DateMath.MONTH,count);this.resetRenderers();this.onChangePage();};YAHOO.widget.Calendar_Core.prototype.subtractMonths=function(count){this.pageDate=YAHOO.widget.DateMath.subtract(this.pageDate,YAHOO.widget.DateMath.MONTH,count);this.resetRenderers();this.onChangePage();};YAHOO.widget.Calendar_Core.prototype.addYears=function(count){this.pageDate=YAHOO.widget.DateMath.add(this.pageDate,YAHOO.widget.DateMath.YEAR,count);this.resetRenderers();this.onChangePage();};YAHOO.widget.Calendar_Core.prototype.subtractYears=function(count){this.pageDate=YAHOO.widget.DateMath.subtract(!
this.pageDate,YAHOO.widget.DateMath.YEAR,count);this.resetRenderers();this.onChangePage();};YAHOO.widget.Calendar_Core.prototype.nextMonth=function(){this.addMonths(1);};YAHOO.widget.Calendar_Core.prototype.previousMonth=function(){this.subtractMonths(1);};YAHOO.widget.Calendar_Core.prototype.nextYear=function(){this.addYears(1);};YAHOO.widget.Calendar_Core.prototype.previousYear=function(){this.subtractYears(1);};YAHOO.widget.Calendar_Core.prototype.reset=function(){this.selectedDates.length=0;this.selectedDates=this._selectedDates.concat();this.pageDate=new Date(this._pageDate.getTime());this.onReset();};YAHOO.widget.Calendar_Core.prototype.clear=function(){this.selectedDates.length=0;this.pageDate=new Date(this.today.getTime());this.onClear();};YAHOO.widget.Calendar_Core.prototype.select=function(date){this.onBeforeSelect();var aToBeSelected=this._toFieldArray(date);for(var a=0;a<aToBeSelected.length;++a){var toSelect=aToBeSelected[a];if(this._indexOfSelectedFieldArray(t!
oSelect)==-1){this.selectedDates[this.selectedDates.length]=toSelect;}
}
+if(this.parent){this.parent.sync(this);}
+this.onSelect();return this.getSelectedDates();};YAHOO.widget.Calendar_Core.prototype.selectCell=function(cellIndex){this.onBeforeSelect();this.cells=this.tbody.getElementsByTagName("TD");var cell=this.cells[cellIndex];var cellDate=this.cellDates[cellIndex];var dCellDate=this._toDate(cellDate);var selectDate=cellDate.concat();this.selectedDates.push(selectDate);if(this.parent){this.parent.sync(this);}
+this.renderCellStyleSelected(dCellDate,cell);this.onSelect();this.doCellMouseOut.call(cell,null,this);return this.getSelectedDates();};YAHOO.widget.Calendar_Core.prototype.deselect=function(date){this.onBeforeDeselect();var aToBeSelected=this._toFieldArray(date);for(var a=0;a<aToBeSelected.length;++a){var toSelect=aToBeSelected[a];var index=this._indexOfSelectedFieldArray(toSelect);if(index!=-1){this.selectedDates.splice(index,1);}}
+if(this.parent){this.parent.sync(this);}
+this.onDeselect();return this.getSelectedDates();};YAHOO.widget.Calendar_Core.prototype.deselectCell=function(i){this.onBeforeDeselect();this.cells=this.tbody.getElementsByTagName("TD");var cell=this.cells[i];var cellDate=this.cellDates[i];var cellDateIndex=this._indexOfSelectedFieldArray(cellDate);var dCellDate=this._toDate(cellDate);var selectDate=cellDate.concat();if(cellDateIndex>-1){if(this.pageDate.getMonth()==dCellDate.getMonth()&&this.pageDate.getFullYear()==dCellDate.getFullYear()){YAHOO.util.Dom.removeClass(cell,this.Style.CSS_CELL_SELECTED);}
+this.selectedDates.splice(cellDateIndex,1);}
+if(this.parent){this.parent.sync(this);}
+this.onDeselect();return this.getSelectedDates();};YAHOO.widget.Calendar_Core.prototype.deselectAll=function(){this.onBeforeDeselect();var count=this.selectedDates.length;this.selectedDates.length=0;if(this.parent){this.parent.sync(this);}
+if(count>0){this.onDeselect();}
+return this.getSelectedDates();};YAHOO.widget.Calendar_Core.prototype._toFieldArray=function(date){var returnDate=new Array();if(date instanceof Date){returnDate=[[date.getFullYear(),date.getMonth()+1,date.getDate()]];}else if(typeof date=='string'){returnDate=this._parseDates(date);}else if(date instanceof Array){for(var i=0;i<date.length;++i){var d=date[i];returnDate[returnDate.length]=[d.getFullYear(),d.getMonth()+1,d.getDate()];}}
+return returnDate;};YAHOO.widget.Calendar_Core.prototype._toDate=function(dateFieldArray){if(dateFieldArray instanceof Date){return dateFieldArray;}else{return new Date(dateFieldArray[0],dateFieldArray[1]-1,dateFieldArray[2]);}};YAHOO.widget.Calendar_Core.prototype._fieldArraysAreEqual=function(array1,array2){var match=false;if(array1[0]==array2[0]&&array1[1]==array2[1]&&array1[2]==array2[2]){match=true;}
+return match;};YAHOO.widget.Calendar_Core.prototype._indexOfSelectedFieldArray=function(find){var selected=-1;for(var s=0;s<this.selectedDates.length;++s){var sArray=this.selectedDates[s];if(find[0]==sArray[0]&&find[1]==sArray[1]&&find[2]==sArray[2]){selected=s;break;}}
+return selected;};YAHOO.widget.Calendar_Core.prototype.isDateOOM=function(date){var isOOM=false;if(date.getMonth()!=this.pageDate.getMonth()){isOOM=true;}
+return isOOM;};YAHOO.widget.Calendar_Core.prototype.onBeforeSelect=function(){if(!this.Options.MULTI_SELECT){this.clearAllBodyCellStyles(this.Style.CSS_CELL_SELECTED);this.deselectAll();}};YAHOO.widget.Calendar_Core.prototype.onSelect=function(){};YAHOO.widget.Calendar_Core.prototype.onBeforeDeselect=function(){};YAHOO.widget.Calendar_Core.prototype.onDeselect=function(){};YAHOO.widget.Calendar_Core.prototype.onChangePage=function(){var me=this;this.renderHeader();if(this.renderProcId){clearTimeout(this.renderProcId);}
+this.renderProcId=setTimeout(function(){me.render();me.renderProcId=null;},1);};YAHOO.widget.Calendar_Core.prototype.onRender=function(){};YAHOO.widget.Calendar_Core.prototype.onReset=function(){this.render();};YAHOO.widget.Calendar_Core.prototype.onClear=function(){this.render();};YAHOO.widget.Calendar_Core.prototype.validate=function(){return true;};YAHOO.widget.Calendar_Core.prototype._parseDate=function(sDate){var aDate=sDate.split(this.Locale.DATE_FIELD_DELIMITER);var rArray;if(aDate.length==2){rArray=[aDate[this.Locale.MD_MONTH_POSITION-1],aDate[this.Locale.MD_DAY_POSITION-1]];rArray.type=YAHOO.widget.Calendar_Core.MONTH_DAY;}else{rArray=[aDate[this.Locale.MDY_YEAR_POSITION-1],aDate[this.Locale.MDY_MONTH_POSITION-1],aDate[this.Locale.MDY_DAY_POSITION-1]];rArray.type=YAHOO.widget.Calendar_Core.DATE;}
+return rArray;};YAHOO.widget.Calendar_Core.prototype._parseDates=function(sDates){var aReturn=new Array();var aDates=sDates.split(this.Locale.DATE_DELIMITER);for(var d=0;d<aDates.length;++d){var sDate=aDates[d];if(sDate.indexOf(this.Locale.DATE_RANGE_DELIMITER)!=-1){var aRange=sDate.split(this.Locale.DATE_RANGE_DELIMITER);var dateStart=this._parseDate(aRange[0]);var dateEnd=this._parseDate(aRange[1]);var fullRange=this._parseRange(dateStart,dateEnd);aReturn=aReturn.concat(fullRange);}else{var aDate=this._parseDate(sDate);aReturn.push(aDate);}}
+return aReturn;};YAHOO.widget.Calendar_Core.prototype._parseRange=function(startDate,endDate){var dStart=new Date(startDate[0],startDate[1]-1,startDate[2]);var dCurrent=YAHOO.widget.DateMath.add(new Date(startDate[0],startDate[1]-1,startDate[2]),YAHOO.widget.DateMath.DAY,1);var dEnd=new Date(endDate[0],endDate[1]-1,endDate[2]);var results=new Array();results.push(startDate);while(dCurrent.getTime()<=dEnd.getTime()){results.push([dCurrent.getFullYear(),dCurrent.getMonth()+1,dCurrent.getDate()]);dCurrent=YAHOO.widget.DateMath.add(dCurrent,YAHOO.widget.DateMath.DAY,1);}
+return results;};YAHOO.widget.Calendar_Core.prototype.resetRenderers=function(){this.renderStack=this._renderStack.concat();};YAHOO.widget.Calendar_Core.prototype.clearElement=function(cell){cell.innerHTML=" ";cell.className="";};YAHOO.widget.Calendar_Core.prototype.addRenderer=function(sDates,fnRender){var aDates=this._parseDates(sDates);for(var i=0;i<aDates.length;++i){var aDate=aDates[i];if(aDate.length==2){if(aDate[0]instanceof Array){this._addRenderer(YAHOO.widget.Calendar_Core.RANGE,aDate,fnRender);}else{this._addRenderer(YAHOO.widget.Calendar_Core.MONTH_DAY,aDate,fnRender);}}else if(aDate.length==3){this._addRenderer(YAHOO.widget.Calendar_Core.DATE,aDate,fnRender);}}};YAHOO.widget.Calendar_Core.prototype._addRenderer=function(type,aDates,fnRender){var add=[type,aDates,fnRender];this.renderStack.unshift(add);this._renderStack=this.renderStack.concat();};YAHOO.widget.Calendar_Core.prototype.addMonthRenderer=function(month,fnRender){this._addRenderer(YAHOO.widget.C!
alendar_Core.MONTH,[month],fnRender);};YAHOO.widget.Calendar_Core.prototype.addWeekdayRenderer=function(weekday,fnRender){this._addRenderer(YAHOO.widget.Calendar_Core.WEEKDAY,[weekday],fnRender);};YAHOO.widget.Calendar_Core.setCssClasses=function(element,aStyles){element.className="";var className=aStyles.join(" ");element.className=className;};YAHOO.widget.Calendar_Core.prototype.clearAllBodyCellStyles=function(style){for(var c=0;c<this.cells.length;++c){YAHOO.util.Dom.removeClass(this.cells[c],style);}};YAHOO.widget.Calendar_Core.prototype.setMonth=function(month){this.pageDate.setMonth(month);};YAHOO.widget.Calendar_Core.prototype.setYear=function(year){this.pageDate.setFullYear(year);};YAHOO.widget.Calendar_Core.prototype.getSelectedDates=function(){var returnDates=new Array();for(var d=0;d<this.selectedDates.length;++d){var dateArray=this.selectedDates[d];var date=new Date(dateArray[0],dateArray[1]-1,dateArray[2]);returnDates.push(date);}
+returnDates.sort();return returnDates;};YAHOO.widget.Calendar_Core._getBrowser=function(){var ua=navigator.userAgent.toLowerCase();if(ua.indexOf('opera')!=-1)
+return'opera';else if(ua.indexOf('msie')!=-1)
+return'ie';else if(ua.indexOf('safari')!=-1)
+return'safari';else if(ua.indexOf('gecko')!=-1)
+return'gecko';else
+return false;}
+YAHOO.widget.Calendar_Core.prototype.toString=function(){return"Calendar_Core "+this.id;}
+YAHOO.widget.Cal_Core=YAHOO.widget.Calendar_Core;YAHOO.widget.Calendar=function(id,containerId,monthyear,selected){if(arguments.length>0){this.init(id,containerId,monthyear,selected);}}
+YAHOO.widget.Calendar.prototype=new YAHOO.widget.Calendar_Core();YAHOO.widget.Calendar.prototype.buildShell=function(){this.border=document.createElement("DIV");this.border.className=this.Style.CSS_CONTAINER;this.table=document.createElement("TABLE");this.table.cellSpacing=0;YAHOO.widget.Calendar_Core.setCssClasses(this.table,[this.Style.CSS_CALENDAR]);this.border.id=this.id;this.buildShellHeader();this.buildShellBody();this.buildShellFooter();};YAHOO.widget.Calendar.prototype.renderShell=function(){this.border.appendChild(this.table);this.oDomContainer.appendChild(this.border);this.shellRendered=true;};YAHOO.widget.Calendar.prototype.renderHeader=function(){this.headerCell.innerHTML="";var headerContainer=document.createElement("DIV");headerContainer.className=this.Style.CSS_HEADER;if(this.linkLeft){YAHOO.util.Event.removeListener(this.linkLeft,"mousedown",this.previousMonth);}
+this.linkLeft=document.createElement("A");this.linkLeft.innerHTML=" ";YAHOO.util.Event.addListener(this.linkLeft,"mousedown",this.previousMonth,this,true);this.linkLeft.style.backgroundImage="url("+this.Options.NAV_ARROW_LEFT+")";this.linkLeft.className=this.Style.CSS_NAV_LEFT;if(this.linkRight){YAHOO.util.Event.removeListener(this.linkRight,"mousedown",this.nextMonth);}
+this.linkRight=document.createElement("A");this.linkRight.innerHTML=" ";YAHOO.util.Event.addListener(this.linkRight,"mousedown",this.nextMonth,this,true);this.linkRight.style.backgroundImage="url("+this.Options.NAV_ARROW_RIGHT+")";this.linkRight.className=this.Style.CSS_NAV_RIGHT;headerContainer.appendChild(this.linkLeft);headerContainer.appendChild(document.createTextNode(this.buildMonthLabel()));headerContainer.appendChild(this.linkRight);this.headerCell.appendChild(headerContainer);};YAHOO.widget.Cal=YAHOO.widget.Calendar;YAHOO.widget.CalendarGroup=function(pageCount,id,containerId,monthyear,selected){if(arguments.length>0){this.init(pageCount,id,containerId,monthyear,selected);}}
+YAHOO.widget.CalendarGroup.prototype.init=function(pageCount,id,containerId,monthyear,selected){this.id=id;this.selectedDates=new Array();this.containerId=containerId;this.pageCount=pageCount;this.pages=new Array();for(var p=0;p<pageCount;++p){var cal=this.constructChild(id+"_"+p,this.containerId+"_"+p,monthyear,selected);cal.parent=this;cal.index=p;cal.pageDate.setMonth(cal.pageDate.getMonth()+p);cal._pageDate=new Date(cal.pageDate.getFullYear(),cal.pageDate.getMonth(),cal.pageDate.getDate());this.pages.push(cal);}
+this.doNextMonth=function(e,calGroup){calGroup.nextMonth();};this.doPreviousMonth=function(e,calGroup){calGroup.previousMonth();};};YAHOO.widget.CalendarGroup.prototype.setChildFunction=function(fnName,fn){for(var p=0;p<this.pageCount;++p){this.pages[p][fnName]=fn;}}
+YAHOO.widget.CalendarGroup.prototype.callChildFunction=function(fnName,args){for(var p=0;p<this.pageCount;++p){var page=this.pages[p];if(page[fnName]){var fn=page[fnName];fn.call(page,args);}}}
+YAHOO.widget.CalendarGroup.prototype.constructChild=function(id,containerId,monthyear,selected){return new YAHOO.widget.Calendar_Core(id,containerId,monthyear,selected);};YAHOO.widget.CalendarGroup.prototype.setMonth=function(month){for(var p=0;p<this.pages.length;++p)
+{var cal=this.pages[p];cal.setMonth(month+p);}};YAHOO.widget.CalendarGroup.prototype.setYear=function(year){for(var p=0;p<this.pages.length;++p)
+{var cal=this.pages[p];if((cal.pageDate.getMonth()+1)==1&&p>0)
+{year+=1;}
+cal.setYear(year);}};YAHOO.widget.CalendarGroup.prototype.render=function(){for(var p=0;p<this.pages.length;++p)
+{var cal=this.pages[p];cal.render();}};YAHOO.widget.CalendarGroup.prototype.select=function(date){var ret;for(var p=0;p<this.pages.length;++p)
+{var cal=this.pages[p];ret=cal.select(date);}
+return ret;};YAHOO.widget.CalendarGroup.prototype.selectCell=function(cellIndex){var ret;for(var p=0;p<this.pages.length;++p)
+{var cal=this.pages[p];ret=cal.selectCell(cellIndex);}
+return ret;};YAHOO.widget.CalendarGroup.prototype.deselect=function(date){var ret;for(var p=0;p<this.pages.length;++p)
+{var cal=this.pages[p];ret=cal.deselect(date);}
+return ret;};YAHOO.widget.CalendarGroup.prototype.deselectAll=function(){var ret;for(var p=0;p<this.pages.length;++p)
+{var cal=this.pages[p];ret=cal.deselectAll();}
+return ret;};YAHOO.widget.CalendarGroup.prototype.deselectCell=function(cellIndex){for(var p=0;p<this.pages.length;++p)
+{var cal=this.pages[p];cal.deselectCell(cellIndex);}
+return this.getSelectedDates();};YAHOO.widget.CalendarGroup.prototype.reset=function(){for(var p=0;p<this.pages.length;++p)
+{var cal=this.pages[p];cal.reset();}};YAHOO.widget.CalendarGroup.prototype.clear=function(){for(var p=0;p<this.pages.length;++p)
+{var cal=this.pages[p];cal.clear();}};YAHOO.widget.CalendarGroup.prototype.nextMonth=function(){for(var p=0;p<this.pages.length;++p)
+{var cal=this.pages[p];cal.nextMonth();}};YAHOO.widget.CalendarGroup.prototype.previousMonth=function(){for(var p=this.pages.length-1;p>=0;--p)
+{var cal=this.pages[p];cal.previousMonth();}};YAHOO.widget.CalendarGroup.prototype.nextYear=function(){for(var p=0;p<this.pages.length;++p)
+{var cal=this.pages[p];cal.nextYear();}};YAHOO.widget.CalendarGroup.prototype.previousYear=function(){for(var p=0;p<this.pages.length;++p)
+{var cal=this.pages[p];cal.previousYear();}};YAHOO.widget.CalendarGroup.prototype.sync=function(caller){var calendar;if(caller)
+{this.selectedDates=caller.selectedDates.concat();}else{var hash=new Object();var combinedDates=new Array();for(var p=0;p<this.pages.length;++p)
+{calendar=this.pages[p];var values=calendar.selectedDates;for(var v=0;v<values.length;++v)
+{var valueArray=values[v];hash[valueArray.toString()]=valueArray;}}
+for(var val in hash)
+{combinedDates[combinedDates.length]=hash[val];}
+this.selectedDates=combinedDates.concat();}
+for(p=0;p<this.pages.length;++p)
+{calendar=this.pages[p];if(!calendar.Options.MULTI_SELECT){calendar.clearAllBodyCellStyles(calendar.Config.Style.CSS_CELL_SELECTED);}
+calendar.selectedDates=this.selectedDates.concat();}
+return this.getSelectedDates();};YAHOO.widget.CalendarGroup.prototype.getSelectedDates=function(){var returnDates=new Array();for(var d=0;d<this.selectedDates.length;++d)
+{var dateArray=this.selectedDates[d];var date=new Date(dateArray[0],dateArray[1]-1,dateArray[2]);returnDates.push(date);}
+returnDates.sort();return returnDates;};YAHOO.widget.CalendarGroup.prototype.addRenderer=function(sDates,fnRender){for(var p=0;p<this.pages.length;++p)
+{var cal=this.pages[p];cal.addRenderer(sDates,fnRender);}};YAHOO.widget.CalendarGroup.prototype.addMonthRenderer=function(month,fnRender){for(var p=0;p<this.pages.length;++p)
+{var cal=this.pages[p];cal.addMonthRenderer(month,fnRender);}};YAHOO.widget.CalendarGroup.prototype.addWeekdayRenderer=function(weekday,fnRender){for(var p=0;p<this.pages.length;++p)
+{var cal=this.pages[p];cal.addWeekdayRenderer(weekday,fnRender);}};YAHOO.widget.CalendarGroup.prototype.wireEvent=function(eventName,fn){for(var p=0;p<this.pages.length;++p)
+{var cal=this.pages[p];cal[eventName]=fn;}};YAHOO.widget.CalendarGroup.prototype.toString=function(){return"CalendarGroup "+this.id;}
+YAHOO.widget.CalGrp=YAHOO.widget.CalendarGroup;YAHOO.widget.Calendar2up_Cal=function(id,containerId,monthyear,selected){if(arguments.length>0)
+{this.init(id,containerId,monthyear,selected);}}
+YAHOO.widget.Calendar2up_Cal.prototype=new YAHOO.widget.Calendar_Core();YAHOO.widget.Calendar2up_Cal.prototype.renderHeader=function(){this.headerCell.innerHTML="";var headerContainer=document.createElement("DIV");headerContainer.className=this.Style.CSS_HEADER;if(this.index==0){if(this.linkLeft){YAHOO.util.Event.removeListener(this.linkLeft,"mousedown",this.parent.doPreviousMonth);}
+this.linkLeft=document.createElement("A");this.linkLeft.innerHTML=" ";this.linkLeft.style.backgroundImage="url("+this.Options.NAV_ARROW_LEFT+")";this.linkLeft.className=this.Style.CSS_NAV_LEFT;YAHOO.util.Event.addListener(this.linkLeft,"mousedown",this.parent.doPreviousMonth,this.parent);headerContainer.appendChild(this.linkLeft);}
+headerContainer.appendChild(document.createTextNode(this.buildMonthLabel()));if(this.index==1){if(this.linkRight){YAHOO.util.Event.removeListener(this.linkRight,"mousedown",this.parent.doNextMonth);}
+this.linkRight=document.createElement("A");this.linkRight.innerHTML=" ";this.linkRight.style.backgroundImage="url("+this.Options.NAV_ARROW_RIGHT+")";this.linkRight.className=this.Style.CSS_NAV_RIGHT;YAHOO.util.Event.addListener(this.linkRight,"mousedown",this.parent.doNextMonth,this.parent);headerContainer.appendChild(this.linkRight);}
+this.headerCell.appendChild(headerContainer);};YAHOO.widget.Calendar2up=function(id,containerId,monthyear,selected){if(arguments.length>0)
+{this.buildWrapper(containerId);this.init(2,id,containerId,monthyear,selected);}}
+YAHOO.widget.Calendar2up.prototype=new YAHOO.widget.CalendarGroup();YAHOO.widget.Calendar2up.CSS_2UPWRAPPER="yui-cal2upwrapper";YAHOO.widget.Calendar2up.CSS_CONTAINER="yui-calcontainer";YAHOO.widget.Calendar2up.CSS_2UPCONTAINER="cal2up";YAHOO.widget.Calendar2up.CSS_2UPTITLE="title";YAHOO.widget.Calendar2up.CSS_2UPCLOSE="close-icon";YAHOO.widget.Calendar2up.prototype.constructChild=function(id,containerId,monthyear,selected){var cal=new YAHOO.widget.Calendar2up_Cal(id,containerId,monthyear,selected);return cal;};YAHOO.widget.Calendar2up.prototype.buildWrapper=function(containerId){var outerContainer=document.getElementById(containerId);outerContainer.className=YAHOO.widget.Calendar2up.CSS_2UPWRAPPER;var innerContainer=document.createElement("DIV");innerContainer.className=YAHOO.widget.Calendar2up.CSS_CONTAINER;innerContainer.id=containerId+"_inner";var cal1Container=document.createElement("DIV");cal1Container.id=containerId+"_0";cal1Container.className=YAHOO.widget.Calendar2!
up.CSS_2UPCONTAINER;cal1Container.style.marginRight="10px";var cal2Container=document.createElement("DIV");cal2Container.id=containerId+"_1";cal2Container.className=YAHOO.widget.Calendar2up.CSS_2UPCONTAINER;outerContainer.appendChild(innerContainer);innerContainer.appendChild(cal1Container);innerContainer.appendChild(cal2Container);this.innerContainer=innerContainer;this.outerContainer=outerContainer;}
+YAHOO.widget.Calendar2up.prototype.render=function(){this.renderHeader();YAHOO.widget.CalendarGroup.prototype.render.call(this);this.renderFooter();};YAHOO.widget.Calendar2up.prototype.renderHeader=function(){if(!this.title){this.title="";}
+if(!this.titleDiv)
+{this.titleDiv=document.createElement("DIV");if(this.title=="")
+{this.titleDiv.style.display="none";}}
+this.titleDiv.className=YAHOO.widget.Calendar2up.CSS_2UPTITLE;this.titleDiv.innerHTML=this.title;if(this.outerContainer.style.position=="absolute")
+{var linkClose=document.createElement("A");linkClose.href="javascript:void(null)";YAHOO.util.Event.addListener(linkClose,"click",this.hide,this);var imgClose=document.createElement("IMG");imgClose.src=YAHOO.widget.Calendar_Core.IMG_ROOT+"us/my/bn/x_d.gif";imgClose.className=YAHOO.widget.Calendar2up.CSS_2UPCLOSE;linkClose.appendChild(imgClose);this.linkClose=linkClose;this.titleDiv.appendChild(linkClose);}
+this.innerContainer.insertBefore(this.titleDiv,this.innerContainer.firstChild);}
+YAHOO.widget.Calendar2up.prototype.hide=function(e,cal){if(!cal)
+{cal=this;}
+cal.outerContainer.style.display="none";}
+YAHOO.widget.Calendar2up.prototype.renderFooter=function(){}
+YAHOO.widget.Cal2up=YAHOO.widget.Calendar2up;
Added: branches/tomek/portal-dnd/dndRenderer.war/js/calendar/calendar.js
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/calendar/calendar.js 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/calendar/calendar.js 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,2876 @@
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+Version 0.11.0
+*/
+
+/**
+* @class
+* <p>YAHOO.widget.DateMath is used for simple date manipulation. The class is a static utility
+* used for adding, subtracting, and comparing dates.</p>
+*/
+YAHOO.widget.DateMath = new function() {
+
+ /**
+ * Constant field representing Day
+ * @type String
+ */
+ this.DAY = "D";
+
+ /**
+ * Constant field representing Week
+ * @type String
+ */
+ this.WEEK = "W";
+
+ /**
+ * Constant field representing Year
+ * @type String
+ */
+ this.YEAR = "Y";
+
+ /**
+ * Constant field representing Month
+ * @type String
+ */
+ this.MONTH = "M";
+
+ /**
+ * Constant field representing one day, in milliseconds
+ * @type Integer
+ */
+ this.ONE_DAY_MS = 1000*60*60*24;
+
+ /**
+ * Adds the specified amount of time to the this instance.
+ * @param {Date} date The JavaScript Date object to perform addition on
+ * @param {string} field The this field constant to be used for performing addition.
+ * @param {Integer} amount The number of units (measured in the field constant) to add to the date.
+ */
+ this.add = function(date, field, amount) {
+ var d = new Date(date.getTime());
+ switch (field) {
+ case this.MONTH:
+ var newMonth = date.getMonth() + amount;
+ var years = 0;
+
+
+ if (newMonth < 0) {
+ while (newMonth < 0) {
+ newMonth += 12;
+ years -= 1;
+ }
+ } else if (newMonth > 11) {
+ while (newMonth > 11) {
+ newMonth -= 12;
+ years += 1;
+ }
+ }
+
+ d.setMonth(newMonth);
+ d.setFullYear(date.getFullYear() + years);
+ break;
+ case this.DAY:
+ d.setDate(date.getDate() + amount);
+ break;
+ case this.YEAR:
+ d.setFullYear(date.getFullYear() + amount);
+ break;
+ case this.WEEK:
+ d.setDate(date.getDate() + (amount * 7));
+ break;
+ }
+ return d;
+ };
+
+ /**
+ * Subtracts the specified amount of time from the this instance.
+ * @param {Date} date The JavaScript Date object to perform subtraction on
+ * @param {Integer} field The this field constant to be used for performing subtraction.
+ * @param {Integer} amount The number of units (measured in the field constant) to subtract from the date.
+ */
+ this.subtract = function(date, field, amount) {
+ return this.add(date, field, (amount*-1));
+ };
+
+ /**
+ * Determines whether a given date is before another date on the calendar.
+ * @param {Date} date The Date object to compare with the compare argument
+ * @param {Date} compareTo The Date object to use for the comparison
+ * @return {Boolean} true if the date occurs before the compared date; false if not.
+ */
+ this.before = function(date, compareTo) {
+ var ms = compareTo.getTime();
+ if (date.getTime() < ms) {
+ return true;
+ } else {
+ return false;
+ }
+ };
+
+ /**
+ * Determines whether a given date is after another date on the calendar.
+ * @param {Date} date The Date object to compare with the compare argument
+ * @param {Date} compareTo The Date object to use for the comparison
+ * @return {Boolean} true if the date occurs after the compared date; false if not.
+ */
+ this.after = function(date, compareTo) {
+ var ms = compareTo.getTime();
+ if (date.getTime() > ms) {
+ return true;
+ } else {
+ return false;
+ }
+ };
+
+ /**
+ * Determines whether a given date is between two other dates on the calendar.
+ * @param {Date} date The date to check for
+ * @param {Date} dateBegin The start of the range
+ * @param {Date} dateEnd The end of the range
+ * @return {Boolean} true if the date occurs between the compared dates; false if not.
+ */
+ this.between = function(date, dateBegin, dateEnd) {
+ if (this.after(date, dateBegin) && this.before(date, dateEnd)) {
+ return true;
+ } else {
+ return false;
+ }
+ };
+
+ /**
+ * Retrieves a JavaScript Date object representing January 1 of any given year.
+ * @param {Integer} calendarYear The calendar year for which to retrieve January 1
+ * @return {Date} January 1 of the calendar year specified.
+ */
+ this.getJan1 = function(calendarYear) {
+ return new Date(calendarYear,0,1);
+ };
+
+ /**
+ * Calculates the number of days the specified date is from January 1 of the specified calendar year.
+ * Passing January 1 to this function would return an offset value of zero.
+ * @param {Date} date The JavaScript date for which to find the offset
+ * @param {Integer} calendarYear The calendar year to use for determining the offset
+ * @return {Integer} The number of days since January 1 of the given year
+ */
+ this.getDayOffset = function(date, calendarYear) {
+ var beginYear = this.getJan1(calendarYear); // Find the start of the year. This will be in week 1.
+
+ // Find the number of days the passed in date is away from the calendar year start
+ var dayOffset = Math.ceil((date.getTime()-beginYear.getTime()) / this.ONE_DAY_MS);
+ return dayOffset;
+ };
+
+ /**
+ * Calculates the week number for the given date. This function assumes that week 1 is the
+ * week in which January 1 appears, regardless of whether the week consists of a full 7 days.
+ * The calendar year can be specified to help find what a the week number would be for a given
+ * date if the date overlaps years. For instance, a week may be considered week 1 of 2005, or
+ * week 53 of 2004. Specifying the optional calendarYear allows one to make this distinction
+ * easily.
+ * @param {Date} date The JavaScript date for which to find the week number
+ * @param {Integer} calendarYear OPTIONAL - The calendar year to use for determining the week number. Default is
+ * the calendar year of parameter "date".
+ * @param {Integer} weekStartsOn OPTIONAL - The integer (0-6) representing which day a week begins on. Default is 0 (for Sunday).
+ * @return {Integer} The week number of the given date.
+ */
+ this.getWeekNumber = function(date, calendarYear, weekStartsOn) {
+ date.setHours(12,0,0,0);
+
+ if (! weekStartsOn) {
+ weekStartsOn = 0;
+ }
+ if (! calendarYear) {
+ calendarYear = date.getFullYear();
+ }
+
+ var weekNum = -1;
+
+ var jan1 = this.getJan1(calendarYear);
+
+ var jan1Offset = jan1.getDay() - weekStartsOn;
+ var jan1DayOfWeek = (jan1Offset >= 0 ? jan1Offset : (7 + jan1Offset));
+
+ var endOfWeek1 = this.add(jan1, this.DAY, (6 - jan1DayOfWeek));
+ endOfWeek1.setHours(23,59,59,999);
+
+ var month = date.getMonth();
+ var day = date.getDate();
+ var year = date.getFullYear();
+
+ var dayOffset = this.getDayOffset(date, calendarYear); // Days since Jan 1, Calendar Year
+
+ if (dayOffset < 0 || this.before(date, endOfWeek1)) {
+ weekNum = 1;
+ } else {
+ weekNum = 2;
+ var weekBegin = new Date(endOfWeek1.getTime() + 1);
+ var weekEnd = this.add(weekBegin, this.WEEK, 1);
+
+ while (! this.between(date, weekBegin, weekEnd)) {
+ weekBegin = this.add(weekBegin, this.WEEK, 1);
+ weekEnd = this.add(weekEnd, this.WEEK, 1);
+ weekNum += 1;
+ }
+ }
+
+ return weekNum;
+ };
+
+ /**
+ * Determines if a given week overlaps two different years.
+ * @param {Date} weekBeginDate The JavaScript Date representing the first day of the week.
+ * @return {Boolean} true if the date overlaps two different years.
+ */
+ this.isYearOverlapWeek = function(weekBeginDate) {
+ var overlaps = false;
+ var nextWeek = this.add(weekBeginDate, this.DAY, 6);
+ if (nextWeek.getFullYear() != weekBeginDate.getFullYear()) {
+ overlaps = true;
+ }
+ return overlaps;
+ };
+
+ /**
+ * Determines if a given week overlaps two different months.
+ * @param {Date} weekBeginDate The JavaScript Date representing the first day of the week.
+ * @return {Boolean} true if the date overlaps two different months.
+ */
+ this.isMonthOverlapWeek = function(weekBeginDate) {
+ var overlaps = false;
+ var nextWeek = this.add(weekBeginDate, this.DAY, 6);
+ if (nextWeek.getMonth() != weekBeginDate.getMonth()) {
+ overlaps = true;
+ }
+ return overlaps;
+ };
+
+ /**
+ * Gets the first day of a month containing a given date.
+ * @param {Date} date The JavaScript Date used to calculate the month start
+ * @return {Date} The JavaScript Date representing the first day of the month
+ */
+ this.findMonthStart = function(date) {
+ var start = new Date(date.getFullYear(), date.getMonth(), 1);
+ return start;
+ };
+
+ /**
+ * Gets the last day of a month containing a given date.
+ * @param {Date} date The JavaScript Date used to calculate the month end
+ * @return {Date} The JavaScript Date representing the last day of the month
+ */
+ this.findMonthEnd = function(date) {
+ var start = this.findMonthStart(date);
+ var nextMonth = this.add(start, this.MONTH, 1);
+ var end = this.subtract(nextMonth, this.DAY, 1);
+ return end;
+ };
+
+ /**
+ * Clears the time fields from a given date, effectively setting the time to midnight.
+ * @param {Date} date The JavaScript Date for which the time fields will be cleared
+ * @return {Date} The JavaScript Date cleared of all time fields
+ */
+ this.clearTime = function(date) {
+ date.setHours(0,0,0,0);
+ return date;
+ };
+}/**
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+**/
+
+/**
+* @class
+* <p>Calendar_Core is the base class for the Calendar widget. In its most basic
+* implementation, it has the ability to render a calendar widget on the page
+* that can be manipulated to select a single date, move back and forth between
+* months and years.</p>
+* <p>To construct the placeholder for the calendar widget, the code is as
+* follows:
+* <xmp>
+* <div id="cal1Container"></div>
+* </xmp>
+* Note that the table can be replaced with any kind of element.
+* </p>
+* @constructor
+* @param {String} id The id of the table element that will represent the calendar widget
+* @param {String} containerId The id of the container element that will contain the calendar table
+* @param {String} monthyear The month/year string used to set the current calendar page
+* @param {String} selected A string of date values formatted using the date parser. The built-in
+ default date format is MM/DD/YYYY. Ranges are defined using
+ MM/DD/YYYY-MM/DD/YYYY. Month/day combinations are defined using MM/DD.
+ Any combination of these can be combined by delimiting the string with
+ commas. Example: "12/24/2005,12/25,1/18/2006-1/21/2006"
+*/
+YAHOO.widget.Calendar_Core = function(id, containerId, monthyear, selected) {
+ if (arguments.length > 0) {
+ this.init(id, containerId, monthyear, selected);
+ }
+}
+
+/**
+* The path to be used for images loaded for the Calendar
+* @type String
+*/
+YAHOO.widget.Calendar_Core.IMG_ROOT = (window.location.href.toLowerCase().indexOf("https") == 0 ? "https://a248.e.akamai.net/sec.yimg.com/i/" : "http://us.i1.yimg.com/us.yimg.com/i/");
+
+/**
+* Type constant used for renderers to represent an individual date (M/D/Y)
+* @final
+* @type String
+*/
+YAHOO.widget.Calendar_Core.DATE = "D";
+
+/**
+* Type constant used for renderers to represent an individual date across any year (M/D)
+* @final
+* @type String
+*/
+YAHOO.widget.Calendar_Core.MONTH_DAY = "MD";
+
+/**
+* Type constant used for renderers to represent a weekday
+* @final
+* @type String
+*/
+YAHOO.widget.Calendar_Core.WEEKDAY = "WD";
+
+/**
+* Type constant used for renderers to represent a range of individual dates (M/D/Y-M/D/Y)
+* @final
+* @type String
+*/
+YAHOO.widget.Calendar_Core.RANGE = "R";
+
+/**
+* Type constant used for renderers to represent a month across any year
+* @final
+* @type String
+*/
+YAHOO.widget.Calendar_Core.MONTH = "M";
+
+/**
+* Constant that represents the total number of date cells that are displayed in a given month
+* including
+* @final
+* @type Integer
+*/
+YAHOO.widget.Calendar_Core.DISPLAY_DAYS = 42;
+
+/**
+* Constant used for halting the execution of the remainder of the render stack
+* @final
+* @type String
+*/
+YAHOO.widget.Calendar_Core.STOP_RENDER = "S";
+
+YAHOO.widget.Calendar_Core.prototype = {
+
+ /**
+ * The configuration object used to set up the calendars various locale and style options.
+ * @type Object
+ */
+ Config : null,
+
+ /**
+ * The parent CalendarGroup, only to be set explicitly by the parent group
+ * @type CalendarGroup
+ */
+ parent : null,
+
+ /**
+ * The index of this item in the parent group
+ * @type Integer
+ */
+ index : -1,
+
+ /**
+ * The collection of calendar table cells
+ * @type HTMLTableCellElement[]
+ */
+ cells : null,
+
+ /**
+ * The collection of calendar week header cells
+ * @type HTMLTableCellElement[]
+ */
+ weekHeaderCells : null,
+
+ /**
+ * The collection of calendar week footer cells
+ * @type HTMLTableCellElement[]
+ */
+ weekFooterCells : null,
+
+ /**
+ * The collection of calendar cell dates that is parallel to the cells collection. The array contains dates field arrays in the format of [YYYY, M, D].
+ * @type Array[](Integer[])
+ */
+ cellDates : null,
+
+ /**
+ * The id that uniquely identifies this calendar. This id should match the id of the placeholder element on the page.
+ * @type String
+ */
+ id : null,
+
+ /**
+ * The DOM element reference that points to this calendar's container element. The calendar will be inserted into this element when the shell is rendered.
+ * @type HTMLElement
+ */
+ oDomContainer : null,
+
+ /**
+ * A Date object representing today's date.
+ * @type Date
+ */
+ today : null,
+
+ /**
+ * The list of render functions, along with required parameters, used to render cells.
+ * @type Array[]
+ */
+ renderStack : null,
+
+ /**
+ * A copy of the initial render functions created before rendering.
+ * @type Array
+ * @private
+ */
+ _renderStack : null,
+
+ /**
+ * A Date object representing the month/year that the calendar is currently set to
+ * @type Date
+ */
+ pageDate : null,
+
+ /**
+ * A Date object representing the month/year that the calendar is initially set to
+ * @type Date
+ * @private
+ */
+ _pageDate : null,
+
+ /**
+ * A Date object representing the minimum selectable date
+ * @type Date
+ */
+ minDate : null,
+
+ /**
+ * A Date object representing the maximum selectable date
+ * @type Date
+ */
+ maxDate : null,
+
+ /**
+ * The list of currently selected dates. The data format for this local collection is
+ * an array of date field arrays, e.g:
+ * [
+ * [2004,5,25],
+ * [2004,5,26]
+ * ]
+ * @type Array[](Integer[])
+ */
+ selectedDates : null,
+
+ /**
+ * The private list of initially selected dates.
+ * @type Array
+ * @private
+ */
+ _selectedDates : null,
+
+ /**
+ * A boolean indicating whether the shell of the calendar has already been rendered to the page
+ * @type Boolean
+ */
+ shellRendered : false,
+
+ /**
+ * The HTML table element that represents this calendar
+ * @type HTMLTableElement
+ */
+ table : null,
+
+ /**
+ * The HTML cell element that represents the main header cell TH used in the calendar table
+ * @type HTMLTableCellElement
+ */
+ headerCell : null
+};
+
+
+
+/**
+* Initializes the calendar widget. This method must be called by all subclass constructors.
+* @param {String} id The id of the table element that will represent the calendar widget
+* @param {String} containerId The id of the container element that will contain the calendar table
+* @param {String} monthyear The month/year string used to set the current calendar page
+* @param {String} selected A string of date values formatted using the date parser. The built-in
+ default date format is MM/DD/YYYY. Ranges are defined using
+ MM/DD/YYYY-MM/DD/YYYY. Month/day combinations are defined using MM/DD.
+ Any combination of these can be combined by delimiting the string with
+ commas. Example: "12/24/2005,12/25,1/18/2006-1/21/2006"
+*/
+YAHOO.widget.Calendar_Core.prototype.init = function(id, containerId, monthyear, selected) {
+ this.setupConfig();
+
+ this.id = id;
+
+ this.cellDates = new Array();
+
+ this.cells = new Array();
+
+ this.renderStack = new Array();
+ this._renderStack = new Array();
+
+ this.oDomContainer = document.getElementById(containerId);
+
+ this.today = new Date();
+ YAHOO.widget.DateMath.clearTime(this.today);
+
+ var month;
+ var year;
+
+ if (monthyear) {
+ var aMonthYear = monthyear.split(this.Locale.DATE_FIELD_DELIMITER);
+ month = parseInt(aMonthYear[this.Locale.MY_MONTH_POSITION-1]);
+ year = parseInt(aMonthYear[this.Locale.MY_YEAR_POSITION-1]);
+ } else {
+ month = this.today.getMonth()+1;
+ year = this.today.getFullYear();
+ }
+
+ this.pageDate = new Date(year, month-1, 1);
+ this._pageDate = new Date(this.pageDate.getTime());
+
+ if (selected) {
+ this.selectedDates = this._parseDates(selected);
+ this._selectedDates = this.selectedDates.concat();
+ } else {
+ this.selectedDates = new Array();
+ this._selectedDates = new Array();
+ }
+
+ this.wireDefaultEvents();
+ this.wireCustomEvents();
+};
+
+
+/**
+* Wires the local DOM events for the Calendar, including cell selection, hover, and
+* default navigation that is used for moving back and forth between calendar pages.
+*/
+YAHOO.widget.Calendar_Core.prototype.wireDefaultEvents = function() {
+
+ /**
+ * The default event function that is attached to a date link within a calendar cell
+ * when the calendar is rendered.
+ * @param e The event
+ * @param cal A reference to the calendar passed by the Event utility
+ */
+ this.doSelectCell = function(e, cal) {
+ var cell = this;
+ var index = cell.index;
+ var d = cal.cellDates[index];
+ var date = new Date(d[0],d[1]-1,d[2]);
+
+ if (! cal.isDateOOM(date) && ! YAHOO.util.Dom.hasClass(cell, cal.Style.CSS_CELL_RESTRICTED) && ! YAHOO.util.Dom.hasClass(cell, cal.Style.CSS_CELL_OOB)) {
+ if (cal.Options.MULTI_SELECT) {
+ var link = cell.getElementsByTagName("A")[0];
+ link.blur();
+
+ var cellDate = cal.cellDates[index];
+ var cellDateIndex = cal._indexOfSelectedFieldArray(cellDate);
+
+ if (cellDateIndex > -1) {
+ cal.deselectCell(index);
+ } else {
+ cal.selectCell(index);
+ }
+
+ } else {
+ var link = cell.getElementsByTagName("A")[0];
+ link.blur()
+ cal.selectCell(index);
+ }
+ }
+ }
+
+ /**
+ * The event that is executed when the user hovers over a cell
+ * @param e The event
+ * @param cal A reference to the calendar passed by the Event utility
+ * @private
+ */
+ this.doCellMouseOver = function(e, cal) {
+ var cell = this;
+ var index = cell.index;
+ var d = cal.cellDates[index];
+ var date = new Date(d[0],d[1]-1,d[2]);
+
+ if (! cal.isDateOOM(date) && ! YAHOO.util.Dom.hasClass(cell, cal.Style.CSS_CELL_RESTRICTED) && ! YAHOO.util.Dom.hasClass(cell, cal.Style.CSS_CELL_OOB)) {
+ YAHOO.util.Dom.addClass(cell, cal.Style.CSS_CELL_HOVER);
+ }
+ }
+
+ /**
+ * The event that is executed when the user moves the mouse out of a cell
+ * @param e The event
+ * @param cal A reference to the calendar passed by the Event utility
+ * @private
+ */
+ this.doCellMouseOut = function(e, cal) {
+ YAHOO.util.Dom.removeClass(this, cal.Style.CSS_CELL_HOVER);
+ }
+
+ /**
+ * A wrapper event that executes the nextMonth method through a DOM event
+ * @param e The event
+ * @param cal A reference to the calendar passed by the Event utility
+ * @private
+ */
+ this.doNextMonth = function(e, cal) {
+ cal.nextMonth();
+ }
+
+ /**
+ * A wrapper event that executes the previousMonth method through a DOM event
+ * @param e The event
+ * @param cal A reference to the calendar passed by the Event utility
+ * @private
+ */
+ this.doPreviousMonth = function(e, cal) {
+ cal.previousMonth();
+ }
+}
+
+/**
+* This function can be extended by subclasses to attach additional DOM events to
+* the calendar. By default, this method is unimplemented.
+*/
+YAHOO.widget.Calendar_Core.prototype.wireCustomEvents = function() { }
+
+/**
+This method is called to initialize the widget configuration variables, including
+style, localization, and other display and behavioral options.
+<p>Config: Container for the CSS style configuration variables.</p>
+<p><strong>Config.Style</strong> - Defines the CSS classes used for different calendar elements</p>
+<blockquote>
+ <div><em>CSS_CALENDAR</em> : Container table</div>
+ <div><em>CSS_HEADER</em> : </div>
+ <div><em>CSS_HEADER_TEXT</em> : Calendar header</div>
+ <div><em>CSS_FOOTER</em> : Calendar footer</div>
+ <div><em>CSS_CELL</em> : Calendar day cell</div>
+ <div><em>CSS_CELL_OOM</em> : Calendar OOM (out of month) cell</div>
+ <div><em>CSS_CELL_SELECTED</em> : Calendar selected cell</div>
+ <div><em>CSS_CELL_RESTRICTED</em> : Calendar restricted cell</div>
+ <div><em>CSS_CELL_TODAY</em> : Calendar cell for today's date</div>
+ <div><em>CSS_ROW_HEADER</em> : The cell preceding a row (used for week number by default)</div>
+ <div><em>CSS_ROW_FOOTER</em> : The cell following a row (not implemented by default)</div>
+ <div><em>CSS_WEEKDAY_CELL</em> : The cells used for labeling weekdays</div>
+ <div><em>CSS_WEEKDAY_ROW</em> : The row containing the weekday label cells</div>
+ <div><em>CSS_CONTAINER</em> : The border style used for the default UED rendering</div>
+ <div><em>CSS_2UPWRAPPER</em> : Special container class used to properly adjust the sizing and float</div>
+ <div><em>CSS_NAV_LEFT</em> : Left navigation arrow</div>
+ <div><em>CSS_NAV_RIGHT</em> : Right navigation arrow</div>
+ <div><em>CSS_CELL_TOP</em> : Outlying cell along the top row</div>
+ <div><em>CSS_CELL_LEFT</em> : Outlying cell along the left row</div>
+ <div><em>CSS_CELL_RIGHT</em> : Outlying cell along the right row</div>
+ <div><em>CSS_CELL_BOTTOM</em> : Outlying cell along the bottom row</div>
+ <div><em>CSS_CELL_HOVER</em> : Cell hover style</div>
+ <div><em>CSS_CELL_HIGHLIGHT1</em> : Highlight color 1 for styling cells</div>
+ <div><em>CSS_CELL_HIGHLIGHT2</em> : Highlight color 2 for styling cells</div>
+ <div><em>CSS_CELL_HIGHLIGHT3</em> : Highlight color 3 for styling cells</div>
+ <div><em>CSS_CELL_HIGHLIGHT4</em> : Highlight color 4 for styling cells</div>
+
+</blockquote>
+<p><strong>Config.Locale</strong> - Defines the locale string arrays used for localization</p>
+<blockquote>
+ <div><em>MONTHS_SHORT</em> : Array of 12 months in short format ("Jan", "Feb", etc.)</div>
+ <div><em>MONTHS_LONG</em> : Array of 12 months in short format ("Jan", "Feb", etc.)</div>
+ <div><em>WEEKDAYS_1CHAR</em> : Array of 7 days in 1-character format ("S", "M", etc.)</div>
+ <div><em>WEEKDAYS_SHORT</em> : Array of 7 days in short format ("Su", "Mo", etc.)</div>
+ <div><em>WEEKDAYS_MEDIUM</em> : Array of 7 days in medium format ("Sun", "Mon", etc.)</div>
+ <div><em>WEEKDAYS_LONG</em> : Array of 7 days in long format ("Sunday", "Monday", etc.)</div>
+ <div><em>DATE_DELIMITER</em> : The value used to delimit series of multiple dates (Default: ",")</div>
+ <div><em>DATE_FIELD_DELIMITER</em> : The value used to delimit date fields (Default: "/")</div>
+ <div><em>DATE_RANGE_DELIMITER</em> : The value used to delimit date fields (Default: "-")</div>
+ <div><em>MY_MONTH_POSITION</em> : The value used to determine the position of the month in a month/year combo (e.g. 12/2005) (Default: 1)</div>
+ <div><em>MY_YEAR_POSITION</em> : The value used to determine the position of the year in a month/year combo (e.g. 12/2005) (Default: 2)</div>
+ <div><em>MD_MONTH_POSITION</em> : The value used to determine the position of the month in a month/day combo (e.g. 12/25) (Default: 1)</div>
+ <div><em>MD_DAY_POSITION</em> : The value used to determine the position of the day in a month/day combo (e.g. 12/25) (Default: 2)</div>
+ <div><em>MDY_MONTH_POSITION</em> : The value used to determine the position of the month in a month/day/year combo (e.g. 12/25/2005) (Default: 1)</div>
+ <div><em>MDY_DAY_POSITION</em> : The value used to determine the position of the day in a month/day/year combo (e.g. 12/25/2005) (Default: 2)</div>
+ <div><em>MDY_YEAR_POSITION</em> : The value used to determine the position of the year in a month/day/year combo (e.g. 12/25/2005) (Default: 3)</div>
+</blockquote>
+<p><strong>Config.Options</strong> - Defines other configurable calendar widget options</p>
+<blockquote>
+ <div><em>SHOW_WEEKDAYS</em> : Boolean, determines whether to display the weekday headers (defaults to true)</div>
+ <div><em>LOCALE_MONTHS</em> : Array, points to the desired Config.Locale array (defaults to Config.Locale.MONTHS_LONG)</div>
+ <div><em>LOCALE_WEEKDAYS</em> : Array, points to the desired Config.Locale array (defaults to Config.Locale.WEEKDAYS_SHORT)</div>
+ <div><em>START_WEEKDAY</em> : Integer, 0-6, representing the day that a week begins on</div>
+ <div><em>SHOW_WEEK_HEADER</em> : Boolean, determines whether to display row headers</div>
+ <div><em>SHOW_WEEK_FOOTER</em> : Boolean, determines whether to display row footers</div>
+ <div><em>HIDE_BLANK_WEEKS</em> : Boolean, determines whether to hide extra weeks that are completely OOM</div>
+ <div><em>NAV_ARROW_LEFT</em> : String, the image path used for the left navigation arrow</div>
+ <div><em>NAV_ARROW_RIGHT</em> : String, the image path used for the right navigation arrow</div>
+</blockquote>
+*/
+YAHOO.widget.Calendar_Core.prototype.setupConfig = function() {
+ /**
+ * Container for the CSS style configuration variables.
+ */
+ this.Config = new Object();
+
+ this.Config.Style = {
+ // Style variables
+ CSS_ROW_HEADER: "calrowhead",
+ CSS_ROW_FOOTER: "calrowfoot",
+ CSS_CELL : "calcell",
+ CSS_CELL_SELECTED : "selected",
+ CSS_CELL_RESTRICTED : "restricted",
+ CSS_CELL_TODAY : "today",
+ CSS_CELL_OOM : "oom",
+ CSS_CELL_OOB : "previous",
+ CSS_HEADER : "calheader",
+ CSS_HEADER_TEXT : "calhead",
+ CSS_WEEKDAY_CELL : "calweekdaycell",
+ CSS_WEEKDAY_ROW : "calweekdayrow",
+ CSS_FOOTER : "calfoot",
+ CSS_CALENDAR : "yui-calendar",
+ CSS_CONTAINER : "yui-calcontainer",
+ CSS_2UPWRAPPER : "yui-cal2upwrapper",
+ CSS_NAV_LEFT : "calnavleft",
+ CSS_NAV_RIGHT : "calnavright",
+ CSS_CELL_TOP : "calcelltop",
+ CSS_CELL_LEFT : "calcellleft",
+ CSS_CELL_RIGHT : "calcellright",
+ CSS_CELL_BOTTOM : "calcellbottom",
+ CSS_CELL_HOVER : "calcellhover",
+ CSS_CELL_HIGHLIGHT1 : "highlight1",
+ CSS_CELL_HIGHLIGHT2 : "highlight2",
+ CSS_CELL_HIGHLIGHT3 : "highlight3",
+ CSS_CELL_HIGHLIGHT4 : "highlight4"
+ };
+
+ this.Style = this.Config.Style;
+
+ this.Config.Locale = {
+ // Locale definition
+ MONTHS_SHORT : ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"],
+ MONTHS_LONG : ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"],
+ WEEKDAYS_1CHAR : ["S", "M", "T", "W", "T", "F", "S"],
+ WEEKDAYS_SHORT : ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
+ WEEKDAYS_MEDIUM : ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
+ WEEKDAYS_LONG : ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"],
+ DATE_DELIMITER : ",",
+ DATE_FIELD_DELIMITER : "/",
+ DATE_RANGE_DELIMITER : "-",
+ MY_MONTH_POSITION : 1,
+ MY_YEAR_POSITION : 2,
+ MD_MONTH_POSITION : 1,
+ MD_DAY_POSITION : 2,
+ MDY_MONTH_POSITION : 1,
+ MDY_DAY_POSITION : 2,
+ MDY_YEAR_POSITION : 3
+ };
+
+ this.Locale = this.Config.Locale;
+
+ this.Config.Options = {
+ // Configuration variables
+ MULTI_SELECT : false,
+ SHOW_WEEKDAYS : true,
+ START_WEEKDAY : 0,
+ SHOW_WEEK_HEADER : false,
+ SHOW_WEEK_FOOTER : false,
+ HIDE_BLANK_WEEKS : false,
+ NAV_ARROW_LEFT : YAHOO.widget.Calendar_Core.IMG_ROOT + "us/tr/callt.gif",
+ NAV_ARROW_RIGHT : YAHOO.widget.Calendar_Core.IMG_ROOT + "us/tr/calrt.gif"
+ };
+
+ this.Options = this.Config.Options;
+
+ this.customConfig();
+
+ if (! this.Options.LOCALE_MONTHS) {
+ this.Options.LOCALE_MONTHS=this.Locale.MONTHS_LONG;
+ }
+ if (! this.Options.LOCALE_WEEKDAYS) {
+ this.Options.LOCALE_WEEKDAYS=this.Locale.WEEKDAYS_SHORT;
+ }
+
+ // If true, reconfigure weekday arrays to place Mondays first
+ if (this.Options.START_WEEKDAY > 0) {
+ for (var w=0;w<this.Options.START_WEEKDAY;++w) {
+ this.Locale.WEEKDAYS_SHORT.push(this.Locale.WEEKDAYS_SHORT.shift());
+ this.Locale.WEEKDAYS_MEDIUM.push(this.Locale.WEEKDAYS_MEDIUM.shift());
+ this.Locale.WEEKDAYS_LONG.push(this.Locale.WEEKDAYS_LONG.shift());
+ }
+ }
+};
+
+/**
+* This method is called when subclasses need to override configuration variables
+* or create new ones. Values can be explicitly set as follows:
+* <blockquote><code>
+* this.Config.Style.CSS_CELL = "newcalcell";
+* this.Config.Locale.MONTHS_SHORT = ["Jan", "Fv", "Mars", "Avr", "Mai", "Juin", "Juil", "Aot", "Sept", "Oct", "Nov", "Dc"];
+* </code></blockquote>
+*/
+YAHOO.widget.Calendar_Core.prototype.customConfig = function() { };
+
+/**
+* Builds the date label that will be displayed in the calendar header or
+* footer, depending on configuration.
+* @return The formatted calendar month label
+* @type String
+*/
+YAHOO.widget.Calendar_Core.prototype.buildMonthLabel = function() {
+ var text = this.Options.LOCALE_MONTHS[this.pageDate.getMonth()] + " " + this.pageDate.getFullYear();
+ return text;
+};
+
+/**
+* Builds the date digit that will be displayed in calendar cells
+* @return The formatted day label
+* @type String
+*/
+YAHOO.widget.Calendar_Core.prototype.buildDayLabel = function(workingDate) {
+ var day = workingDate.getDate();
+ return day;
+};
+
+
+
+/**
+* Builds the calendar table shell that will be filled in with dates and formatting.
+* This method calls buildShellHeader, buildShellBody, and buildShellFooter (in that order)
+* to construct the pieces of the calendar table. The construction of the shell should
+* only happen one time when the calendar is initialized.
+*/
+YAHOO.widget.Calendar_Core.prototype.buildShell = function() {
+
+ this.table = document.createElement("TABLE");
+ this.table.cellSpacing = 0;
+ YAHOO.widget.Calendar_Core.setCssClasses(this.table, [this.Style.CSS_CALENDAR]);
+
+ this.table.id = this.id;
+
+ this.buildShellHeader();
+ this.buildShellBody();
+ this.buildShellFooter();
+
+ YAHOO.util.Event.addListener(window, "unload", this._unload, this);
+};
+
+/**
+* Builds the calendar shell header by inserting a THEAD into the local calendar table.
+*/
+YAHOO.widget.Calendar_Core.prototype.buildShellHeader = function() {
+ var head = document.createElement("THEAD");
+ var headRow = document.createElement("TR");
+
+ var headerCell = document.createElement("TH");
+
+ var colSpan = 7;
+ if (this.Config.Options.SHOW_WEEK_HEADER) {
+ this.weekHeaderCells = new Array();
+ colSpan += 1;
+ }
+ if (this.Config.Options.SHOW_WEEK_FOOTER) {
+ this.weekFooterCells = new Array();
+ colSpan += 1;
+ }
+
+ headerCell.colSpan = colSpan;
+
+ YAHOO.widget.Calendar_Core.setCssClasses(headerCell,[this.Style.CSS_HEADER_TEXT]);
+
+ this.headerCell = headerCell;
+
+ headRow.appendChild(headerCell);
+ head.appendChild(headRow);
+
+ // Append day labels, if needed
+ if (this.Options.SHOW_WEEKDAYS) {
+ var row = document.createElement("TR");
+ var fillerCell;
+
+ YAHOO.widget.Calendar_Core.setCssClasses(row,[this.Style.CSS_WEEKDAY_ROW]);
+
+ if (this.Config.Options.SHOW_WEEK_HEADER) {
+ fillerCell = document.createElement("TH");
+ YAHOO.widget.Calendar_Core.setCssClasses(fillerCell,[this.Style.CSS_WEEKDAY_CELL]);
+ row.appendChild(fillerCell);
+ }
+
+ for(var i=0;i<this.Options.LOCALE_WEEKDAYS.length;++i) {
+ var cell = document.createElement("TH");
+ YAHOO.widget.Calendar_Core.setCssClasses(cell,[this.Style.CSS_WEEKDAY_CELL]);
+ cell.innerHTML=this.Options.LOCALE_WEEKDAYS[i];
+ row.appendChild(cell);
+ }
+
+ if (this.Config.Options.SHOW_WEEK_FOOTER) {
+ fillerCell = document.createElement("TH");
+ YAHOO.widget.Calendar_Core.setCssClasses(fillerCell,[this.Style.CSS_WEEKDAY_CELL]);
+ row.appendChild(fillerCell);
+ }
+
+ head.appendChild(row);
+ }
+
+ this.table.appendChild(head);
+};
+
+/**
+* Builds the calendar shell body (6 weeks by 7 days)
+*/
+YAHOO.widget.Calendar_Core.prototype.buildShellBody = function() {
+ // This should only get executed once
+ this.tbody = document.createElement("TBODY");
+
+ for (var r=0;r<6;++r) {
+ var row = document.createElement("TR");
+
+ for (var c=0;c<this.headerCell.colSpan;++c) {
+ var cell;
+ if (this.Config.Options.SHOW_WEEK_HEADER && c===0) { // Row header
+ cell = document.createElement("TH");
+ this.weekHeaderCells[this.weekHeaderCells.length] = cell;
+ } else if (this.Config.Options.SHOW_WEEK_FOOTER && c==(this.headerCell.colSpan-1)){ // Row footer
+ cell = document.createElement("TH");
+ this.weekFooterCells[this.weekFooterCells.length] = cell;
+ } else {
+ cell = document.createElement("TD");
+ this.cells[this.cells.length] = cell;
+ YAHOO.widget.Calendar_Core.setCssClasses(cell, [this.Style.CSS_CELL]);
+ YAHOO.util.Event.addListener(cell, "click", this.doSelectCell, this);
+
+ YAHOO.util.Event.addListener(cell, "mouseover", this.doCellMouseOver, this);
+ YAHOO.util.Event.addListener(cell, "mouseout", this.doCellMouseOut, this);
+ }
+ row.appendChild(cell);
+ }
+ this.tbody.appendChild(row);
+ }
+
+ this.table.appendChild(this.tbody);
+};
+
+/**
+* Builds the calendar shell footer. In the default implementation, there is
+* no footer.
+*/
+YAHOO.widget.Calendar_Core.prototype.buildShellFooter = function() { };
+
+/**
+* Outputs the calendar shell to the DOM, inserting it into the placeholder element.
+*/
+YAHOO.widget.Calendar_Core.prototype.renderShell = function() {
+ this.oDomContainer.appendChild(this.table);
+ this.shellRendered = true;
+};
+
+/**
+* Renders the calendar after it has been configured. The render() method has a specific call chain that will execute
+* when the method is called: renderHeader, renderBody, renderFooter.
+* Refer to the documentation for those methods for information on
+* individual render tasks.
+*/
+YAHOO.widget.Calendar_Core.prototype.render = function() {
+ if (! this.shellRendered) {
+ this.buildShell();
+ this.renderShell();
+ }
+
+ this.resetRenderers();
+
+ this.cellDates.length = 0;
+
+ // Find starting day of the current month
+ var workingDate = YAHOO.widget.DateMath.findMonthStart(this.pageDate);
+
+ this.renderHeader();
+ this.renderBody(workingDate);
+ this.renderFooter();
+
+ this.onRender();
+};
+
+
+
+/**
+* Appends the header contents into the widget header.
+*/
+YAHOO.widget.Calendar_Core.prototype.renderHeader = function() {
+ this.headerCell.innerHTML = "";
+
+ var headerContainer = document.createElement("DIV");
+ headerContainer.className = this.Style.CSS_HEADER;
+
+ headerContainer.appendChild(document.createTextNode(this.buildMonthLabel()));
+
+ this.headerCell.appendChild(headerContainer);
+};
+
+/**
+* Appends the calendar body. The default implementation calculates the number of
+* OOM (out of month) cells that need to be rendered at the start of the month, renders those,
+* and renders all the day cells using the built-in cell rendering methods.
+*
+* While iterating through all of the cells, the calendar checks for renderers in the
+* local render stack that match the date of the current cell, and then applies styles
+* as necessary.
+*
+* @param {Date} workingDate The current working Date object being used to generate the calendar
+*/
+YAHOO.widget.Calendar_Core.prototype.renderBody = function(workingDate) {
+
+ this.preMonthDays = workingDate.getDay();
+ if (this.Options.START_WEEKDAY > 0) {
+ this.preMonthDays -= this.Options.START_WEEKDAY;
+ }
+ if (this.preMonthDays < 0) {
+ this.preMonthDays += 7;
+ }
+
+ this.monthDays = YAHOO.widget.DateMath.findMonthEnd(workingDate).getDate();
+ this.postMonthDays = YAHOO.widget.Calendar_Core.DISPLAY_DAYS-this.preMonthDays-this.monthDays;
+
+ workingDate = YAHOO.widget.DateMath.subtract(workingDate, YAHOO.widget.DateMath.DAY, this.preMonthDays);
+
+ var weekRowIndex = 0;
+
+ for (var c=0;c<this.cells.length;++c) {
+ var cellRenderers = new Array();
+
+ var cell = this.cells[c];
+ this.clearElement(cell);
+
+ cell.index = c;
+ cell.id = this.id + "_cell" + c;
+
+ this.cellDates[this.cellDates.length]=[workingDate.getFullYear(),workingDate.getMonth()+1,workingDate.getDate()]; // Add this date to cellDates
+
+ if (workingDate.getDay() == this.Options.START_WEEKDAY) {
+ var rowHeaderCell = null;
+ var rowFooterCell = null;
+
+ if (this.Options.SHOW_WEEK_HEADER) {
+ rowHeaderCell = this.weekHeaderCells[weekRowIndex];
+ this.clearElement(rowHeaderCell);
+ }
+
+ if (this.Options.SHOW_WEEK_FOOTER) {
+ rowFooterCell = this.weekFooterCells[weekRowIndex];
+ this.clearElement(rowFooterCell);
+ }
+
+ if (this.Options.HIDE_BLANK_WEEKS && this.isDateOOM(workingDate) && ! YAHOO.widget.DateMath.isMonthOverlapWeek(workingDate)) {
+ // The first day of the week is not in this month, and it's not an overlap week
+ continue;
+ } else {
+ if (rowHeaderCell) {
+ this.renderRowHeader(workingDate, rowHeaderCell);
+ }
+ if (rowFooterCell) {
+ this.renderRowFooter(workingDate, rowFooterCell);
+ }
+ }
+ }
+
+
+
+ var renderer = null;
+
+ if (workingDate.getFullYear() == this.today.getFullYear() &&
+ workingDate.getMonth() == this.today.getMonth() &&
+ workingDate.getDate() == this.today.getDate()) {
+ cellRenderers[cellRenderers.length]=this.renderCellStyleToday;
+ }
+
+ if (this.isDateOOM(workingDate)) {
+ cellRenderers[cellRenderers.length]=this.renderCellNotThisMonth;
+ } else {
+ for (var r=0;r<this.renderStack.length;++r) {
+ var rArray = this.renderStack[r];
+ var type = rArray[0];
+
+ var month;
+ var day;
+ var year;
+
+ switch (type) {
+ case YAHOO.widget.Calendar_Core.DATE:
+ month = rArray[1][1];
+ day = rArray[1][2];
+ year = rArray[1][0];
+
+ if (workingDate.getMonth()+1 == month && workingDate.getDate() == day && workingDate.getFullYear() == year) {
+ renderer = rArray[2];
+ this.renderStack.splice(r,1);
+ }
+ break;
+ case YAHOO.widget.Calendar_Core.MONTH_DAY:
+ month = rArray[1][0];
+ day = rArray[1][1];
+
+ if (workingDate.getMonth()+1 == month && workingDate.getDate() == day) {
+ renderer = rArray[2];
+ this.renderStack.splice(r,1);
+ }
+ break;
+ case YAHOO.widget.Calendar_Core.RANGE:
+ var date1 = rArray[1][0];
+ var date2 = rArray[1][1];
+
+ var d1month = date1[1];
+ var d1day = date1[2];
+ var d1year = date1[0];
+
+ var d1 = new Date(d1year, d1month-1, d1day);
+
+ var d2month = date2[1];
+ var d2day = date2[2];
+ var d2year = date2[0];
+
+ var d2 = new Date(d2year, d2month-1, d2day);
+
+ if (workingDate.getTime() >= d1.getTime() && workingDate.getTime() <= d2.getTime()) {
+ renderer = rArray[2];
+
+ if (workingDate.getTime()==d2.getTime()) {
+ this.renderStack.splice(r,1);
+ }
+ }
+ break;
+ case YAHOO.widget.Calendar_Core.WEEKDAY:
+
+ var weekday = rArray[1][0];
+ if (workingDate.getDay()+1 == weekday) {
+ renderer = rArray[2];
+ }
+ break;
+ case YAHOO.widget.Calendar_Core.MONTH:
+
+ month = rArray[1][0];
+ if (workingDate.getMonth()+1 == month) {
+ renderer = rArray[2];
+ }
+ break;
+ }
+
+ if (renderer) {
+ cellRenderers[cellRenderers.length]=renderer;
+ }
+ }
+
+ }
+
+ if (this._indexOfSelectedFieldArray([workingDate.getFullYear(),workingDate.getMonth()+1,workingDate.getDate()]) > -1) {
+ cellRenderers[cellRenderers.length]=this.renderCellStyleSelected;
+ }
+
+ if (this.minDate) {
+ this.minDate = YAHOO.widget.DateMath.clearTime(this.minDate);
+ }
+ if (this.maxDate) {
+ this.maxDate = YAHOO.widget.DateMath.clearTime(this.maxDate);
+ }
+
+ if (
+ (this.minDate && (workingDate.getTime() < this.minDate.getTime())) ||
+ (this.maxDate && (workingDate.getTime() > this.maxDate.getTime()))
+ ) {
+ cellRenderers[cellRenderers.length]=this.renderOutOfBoundsDate;
+ } else {
+ cellRenderers[cellRenderers.length]=this.renderCellDefault;
+ }
+
+ for (var x=0;x<cellRenderers.length;++x) {
+ var ren = cellRenderers[x];
+ if (ren.call(this,workingDate,cell) == YAHOO.widget.Calendar_Core.STOP_RENDER) {
+ break;
+ }
+ }
+
+ workingDate = YAHOO.widget.DateMath.add(workingDate, YAHOO.widget.DateMath.DAY, 1); // Go to the next day
+ if (workingDate.getDay() == this.Options.START_WEEKDAY) {
+ weekRowIndex += 1;
+ }
+
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL);
+
+ if (c >= 0 && c <= 6) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_TOP);
+ }
+ if ((c % 7) == 0) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_LEFT);
+ }
+ if (((c+1) % 7) == 0) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_RIGHT);
+ }
+
+ var postDays = this.postMonthDays;
+ if (postDays >= 7 && this.Options.HIDE_BLANK_WEEKS) {
+ var blankWeeks = Math.floor(postDays/7);
+ for (var p=0;p<blankWeeks;++p) {
+ postDays -= 7;
+ }
+ }
+
+ if (c >= ((this.preMonthDays+postDays+this.monthDays)-7)) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_BOTTOM);
+ }
+ }
+
+};
+
+/**
+* Appends the contents of the calendar widget footer into the shell. By default,
+* the calendar does not contain a footer, and this method must be implemented by
+* subclassing the widget.
+*/
+YAHOO.widget.Calendar_Core.prototype.renderFooter = function() { };
+
+/**
+* @private
+*/
+YAHOO.widget.Calendar_Core.prototype._unload = function(e, cal) {
+ for (var c in cal.cells) {
+ c = null;
+ }
+
+ cal.cells = null;
+
+ cal.tbody = null;
+ cal.oDomContainer = null;
+ cal.table = null;
+ cal.headerCell = null;
+
+ cal = null;
+};
+
+
+/****************** BEGIN BUILT-IN TABLE CELL RENDERERS ************************************/
+
+YAHOO.widget.Calendar_Core.prototype.renderOutOfBoundsDate = function(workingDate, cell) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_OOB);
+ cell.innerHTML = workingDate.getDate();
+ return YAHOO.widget.Calendar_Core.STOP_RENDER;
+}
+
+/**
+* Renders the row header for a week. The date passed in should be
+* the first date of the given week.
+* @param {Date} workingDate The current working Date object (beginning of the week) being used to generate the calendar
+* @param {HTMLTableCellElement} cell The current working cell in the calendar
+*/
+YAHOO.widget.Calendar_Core.prototype.renderRowHeader = function(workingDate, cell) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_ROW_HEADER);
+
+ var useYear = this.pageDate.getFullYear();
+
+ if (! YAHOO.widget.DateMath.isYearOverlapWeek(workingDate)) {
+ useYear = workingDate.getFullYear();
+ }
+
+ var weekNum = YAHOO.widget.DateMath.getWeekNumber(workingDate, useYear, this.Options.START_WEEKDAY);
+ cell.innerHTML = weekNum;
+
+ if (this.isDateOOM(workingDate) && ! YAHOO.widget.DateMath.isMonthOverlapWeek(workingDate)) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_OOM);
+ }
+};
+
+/**
+* Renders the row footer for a week. The date passed in should be
+* the first date of the given week.
+* @param {Date} workingDate The current working Date object (beginning of the week) being used to generate the calendar
+* @param {HTMLTableCellElement} cell The current working cell in the calendar
+*/
+YAHOO.widget.Calendar_Core.prototype.renderRowFooter = function(workingDate, cell) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_ROW_FOOTER);
+
+ if (this.isDateOOM(workingDate) && ! YAHOO.widget.DateMath.isMonthOverlapWeek(workingDate)) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_OOM);
+ }
+};
+
+/**
+* Renders a single standard calendar cell in the calendar widget table.
+* All logic for determining how a standard default cell will be rendered is
+* encapsulated in this method, and must be accounted for when extending the
+* widget class.
+* @param {Date} workingDate The current working Date object being used to generate the calendar
+* @param {HTMLTableCellElement} cell The current working cell in the calendar
+* @return YAHOO.widget.Calendar_Core.STOP_RENDER if rendering should stop with this style, null or nothing if rendering
+* should not be terminated
+* @type String
+*/
+YAHOO.widget.Calendar_Core.prototype.renderCellDefault = function(workingDate, cell) {
+ cell.innerHTML = "";
+ var link = document.createElement("a");
+
+ link.href="javascript:void(null);";
+ link.name=this.id+"__"+workingDate.getFullYear()+"_"+(workingDate.getMonth()+1)+"_"+workingDate.getDate();
+
+ link.appendChild(document.createTextNode(this.buildDayLabel(workingDate)));
+ cell.appendChild(link);
+};
+
+/**
+* Renders a single standard calendar cell using the CSS hightlight1 style
+* @param {Date} workingDate The current working Date object being used to generate the calendar
+* @param {HTMLTableCellElement} cell The current working cell in the calendar
+* @return YAHOO.widget.Calendar_Core.STOP_RENDER if rendering should stop with this style, null or nothing if rendering
+* should not be terminated
+* @type String
+*/
+YAHOO.widget.Calendar_Core.prototype.renderCellStyleHighlight1 = function(workingDate, cell) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_HIGHLIGHT1);
+};
+
+/**
+* Renders a single standard calendar cell using the CSS hightlight2 style
+* @param {Date} workingDate The current working Date object being used to generate the calendar
+* @param {HTMLTableCellElement} cell The current working cell in the calendar
+* @return YAHOO.widget.Calendar_Core.STOP_RENDER if rendering should stop with this style, null or nothing if rendering
+* should not be terminated
+* @type String
+*/
+YAHOO.widget.Calendar_Core.prototype.renderCellStyleHighlight2 = function(workingDate, cell) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_HIGHLIGHT2);
+};
+
+/**
+* Renders a single standard calendar cell using the CSS hightlight3 style
+* @param {Date} workingDate The current working Date object being used to generate the calendar
+* @param {HTMLTableCellElement} cell The current working cell in the calendar
+* @return YAHOO.widget.Calendar_Core.STOP_RENDER if rendering should stop with this style, null or nothing if rendering
+* should not be terminated
+* @type String
+*/
+YAHOO.widget.Calendar_Core.prototype.renderCellStyleHighlight3 = function(workingDate, cell) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_HIGHLIGHT3);
+};
+
+/**
+* Renders a single standard calendar cell using the CSS hightlight4 style
+* @param {Date} workingDate The current working Date object being used to generate the calendar
+* @param {HTMLTableCellElement} cell The current working cell in the calendar
+* @return YAHOO.widget.Calendar_Core.STOP_RENDER if rendering should stop with this style, null or nothing if rendering
+* should not be terminated
+* @type String
+*/
+YAHOO.widget.Calendar_Core.prototype.renderCellStyleHighlight4 = function(workingDate, cell) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_HIGHLIGHT4);
+};
+
+/**
+* Applies the default style used for rendering today's date to the current calendar cell
+* @param {Date} workingDate The current working Date object being used to generate the calendar
+* @param {HTMLTableCellElement} cell The current working cell in the calendar
+* @return YAHOO.widget.Calendar_Core.STOP_RENDER if rendering should stop with this style, null or nothing if rendering
+* should not be terminated
+* @type String
+*/
+YAHOO.widget.Calendar_Core.prototype.renderCellStyleToday = function(workingDate, cell) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_TODAY);
+};
+
+/**
+* Applies the default style used for rendering selected dates to the current calendar cell
+* @param {Date} workingDate The current working Date object being used to generate the calendar
+* @param {HTMLTableCellElement} cell The current working cell in the calendar
+* @return YAHOO.widget.Calendar_Core.STOP_RENDER if rendering should stop with this style, null or nothing if rendering
+* should not be terminated
+* @type String
+*/
+YAHOO.widget.Calendar_Core.prototype.renderCellStyleSelected = function(workingDate, cell) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_SELECTED);
+};
+
+/**
+* Applies the default style used for rendering dates that are not a part of the current
+* month (preceding or trailing the cells for the current month)
+* @param {Date} workingDate The current working Date object being used to generate the calendar
+* @param {HTMLTableCellElement} cell The current working cell in the calendar
+* @return YAHOO.widget.Calendar_Core.STOP_RENDER if rendering should stop with this style, null or nothing if rendering
+* should not be terminated
+* @type String
+*/
+YAHOO.widget.Calendar_Core.prototype.renderCellNotThisMonth = function(workingDate, cell) {
+ YAHOO.util.Dom.addClass(cell, this.Style.CSS_CELL_OOM);
+ cell.innerHTML=workingDate.getDate();
+ return YAHOO.widget.Calendar_Core.STOP_RENDER;
+};
+
+/**
+* Renders the current calendar cell as a non-selectable "black-out" date using the default
+* restricted style.
+* @param {Date} workingDate The current working Date object being used to generate the calendar
+* @param {HTMLTableCellElement} cell The current working cell in the calendar
+* @return YAHOO.widget.Calendar_Core.STOP_RENDER if rendering should stop with this style, null or nothing if rendering
+* should not be terminated
+* @type String
+*/
+YAHOO.widget.Calendar_Core.prototype.renderBodyCellRestricted = function(workingDate, cell) {
+ YAHOO.widget.Calendar_Core.setCssClasses(cell, [this.Style.CSS_CELL,this.Style.CSS_CELL_RESTRICTED]);
+ cell.innerHTML=workingDate.getDate();
+ return YAHOO.widget.Calendar_Core.STOP_RENDER;
+};
+/******************** END BUILT-IN TABLE CELL RENDERERS ************************************/
+
+/******************** BEGIN MONTH NAVIGATION METHODS ************************************/
+/**
+* Adds the designated number of months to the current calendar month, and sets the current
+* calendar page date to the new month.
+* @param {Integer} count The number of months to add to the current calendar
+*/
+YAHOO.widget.Calendar_Core.prototype.addMonths = function(count) {
+ this.pageDate = YAHOO.widget.DateMath.add(this.pageDate, YAHOO.widget.DateMath.MONTH, count);
+ this.resetRenderers();
+ this.onChangePage();
+};
+
+/**
+* Subtracts the designated number of months from the current calendar month, and sets the current
+* calendar page date to the new month.
+* @param {Integer} count The number of months to subtract from the current calendar
+*/
+YAHOO.widget.Calendar_Core.prototype.subtractMonths = function(count) {
+ this.pageDate = YAHOO.widget.DateMath.subtract(this.pageDate, YAHOO.widget.DateMath.MONTH, count);
+ this.resetRenderers();
+ this.onChangePage();
+};
+
+/**
+* Adds the designated number of years to the current calendar, and sets the current
+* calendar page date to the new month.
+* @param {Integer} count The number of years to add to the current calendar
+*/
+YAHOO.widget.Calendar_Core.prototype.addYears = function(count) {
+ this.pageDate = YAHOO.widget.DateMath.add(this.pageDate, YAHOO.widget.DateMath.YEAR, count);
+ this.resetRenderers();
+ this.onChangePage();
+};
+
+/**
+* Subtcats the designated number of years from the current calendar, and sets the current
+* calendar page date to the new month.
+* @param {Integer} count The number of years to subtract from the current calendar
+*/
+YAHOO.widget.Calendar_Core.prototype.subtractYears = function(count) {
+ this.pageDate = YAHOO.widget.DateMath.subtract(this.pageDate, YAHOO.widget.DateMath.YEAR, count);
+ this.resetRenderers();
+ this.onChangePage();
+};
+
+/**
+* Navigates to the next month page in the calendar widget.
+*/
+YAHOO.widget.Calendar_Core.prototype.nextMonth = function() {
+ this.addMonths(1);
+};
+
+/**
+* Navigates to the previous month page in the calendar widget.
+*/
+YAHOO.widget.Calendar_Core.prototype.previousMonth = function() {
+ this.subtractMonths(1);
+};
+
+/**
+* Navigates to the next year in the currently selected month in the calendar widget.
+*/
+YAHOO.widget.Calendar_Core.prototype.nextYear = function() {
+ this.addYears(1);
+};
+
+/**
+* Navigates to the previous year in the currently selected month in the calendar widget.
+*/
+YAHOO.widget.Calendar_Core.prototype.previousYear = function() {
+ this.subtractYears(1);
+};
+
+/****************** END MONTH NAVIGATION METHODS ************************************/
+
+/************* BEGIN SELECTION METHODS *************************************************************/
+
+/**
+* Resets the calendar widget to the originally selected month and year, and
+* sets the calendar to the initial selection(s).
+*/
+YAHOO.widget.Calendar_Core.prototype.reset = function() {
+ this.selectedDates.length = 0;
+ this.selectedDates = this._selectedDates.concat();
+
+ this.pageDate = new Date(this._pageDate.getTime());
+ this.onReset();
+};
+
+/**
+* Clears the selected dates in the current calendar widget and sets the calendar
+* to the current month and year.
+*/
+YAHOO.widget.Calendar_Core.prototype.clear = function() {
+ this.selectedDates.length = 0;
+ this.pageDate = new Date(this.today.getTime());
+ this.onClear();
+};
+
+/**
+* Selects a date or a collection of dates on the current calendar. This method, by default,
+* does not call the render method explicitly. Once selection has completed, render must be
+* called for the changes to be reflected visually.
+* @param {String/Date/Date[]} date The date string of dates to select in the current calendar. Valid formats are
+* individual date(s) (12/24/2005,12/26/2005) or date range(s) (12/24/2005-1/1/2006).
+* Multiple comma-delimited dates can also be passed to this method (12/24/2005,12/11/2005-12/13/2005).
+* This method can also take a JavaScript Date object or an array of Date objects.
+* @return Array of JavaScript Date objects representing all individual dates that are currently selected.
+* @type Date[]
+*/
+YAHOO.widget.Calendar_Core.prototype.select = function(date) {
+ this.onBeforeSelect();
+
+ var aToBeSelected = this._toFieldArray(date);
+
+ for (var a=0;a<aToBeSelected.length;++a) {
+ var toSelect = aToBeSelected[a]; // For each date item in the list of dates we're trying to select
+ if (this._indexOfSelectedFieldArray(toSelect) == -1) { // not already selected?
+ this.selectedDates[this.selectedDates.length]=toSelect;
+ }
+ }
+
+ if (this.parent) {
+ this.parent.sync(this);
+ }
+
+ this.onSelect();
+
+ return this.getSelectedDates();
+};
+
+/**
+* Selects a date on the current calendar by referencing the index of the cell that should be selected.
+* This method is used to easily select a single cell (usually with a mouse click) without having to do
+* a full render. The selected style is applied to the cell directly.
+* @param {Integer} cellIndex The index of the cell to select in the current calendar.
+* @return Array of JavaScript Date objects representing all individual dates that are currently selected.
+* @type Date[]
+*/
+YAHOO.widget.Calendar_Core.prototype.selectCell = function(cellIndex) {
+ this.onBeforeSelect();
+
+ this.cells = this.tbody.getElementsByTagName("TD");
+
+ var cell = this.cells[cellIndex];
+ var cellDate = this.cellDates[cellIndex];
+
+ var dCellDate = this._toDate(cellDate);
+
+ var selectDate = cellDate.concat();
+
+ this.selectedDates.push(selectDate);
+
+ if (this.parent) {
+ this.parent.sync(this);
+ }
+
+ this.renderCellStyleSelected(dCellDate,cell);
+
+ this.onSelect();
+ this.doCellMouseOut.call(cell, null, this);
+
+ return this.getSelectedDates();
+};
+
+/**
+* Deselects a date or a collection of dates on the current calendar. This method, by default,
+* does not call the render method explicitly. Once deselection has completed, render must be
+* called for the changes to be reflected visually.
+* @param {String/Date/Date[]} date The date string of dates to deselect in the current calendar. Valid formats are
+* individual date(s) (12/24/2005,12/26/2005) or date range(s) (12/24/2005-1/1/2006).
+* Multiple comma-delimited dates can also be passed to this method (12/24/2005,12/11/2005-12/13/2005).
+* This method can also take a JavaScript Date object or an array of Date objects.
+* @return Array of JavaScript Date objects representing all individual dates that are currently selected.
+* @type Date[]
+*/
+YAHOO.widget.Calendar_Core.prototype.deselect = function(date) {
+ this.onBeforeDeselect();
+
+ var aToBeSelected = this._toFieldArray(date);
+
+ for (var a=0;a<aToBeSelected.length;++a) {
+ var toSelect = aToBeSelected[a]; // For each date item in the list of dates we're trying to select
+ var index = this._indexOfSelectedFieldArray(toSelect);
+
+ if (index != -1) {
+ this.selectedDates.splice(index,1);
+ }
+ }
+
+ if (this.parent) {
+ this.parent.sync(this);
+ }
+
+ this.onDeselect();
+ return this.getSelectedDates();
+};
+
+/**
+* Deselects a date on the current calendar by referencing the index of the cell that should be deselected.
+* This method is used to easily deselect a single cell (usually with a mouse click) without having to do
+* a full render. The selected style is removed from the cell directly.
+* @param {Integer} cellIndex The index of the cell to deselect in the current calendar.
+* @return Array of JavaScript Date objects representing all individual dates that are currently selected.
+* @type Date[]
+*/
+YAHOO.widget.Calendar_Core.prototype.deselectCell = function(i) {
+ this.onBeforeDeselect();
+ this.cells = this.tbody.getElementsByTagName("TD");
+
+ var cell = this.cells[i];
+ var cellDate = this.cellDates[i];
+ var cellDateIndex = this._indexOfSelectedFieldArray(cellDate);
+
+ var dCellDate = this._toDate(cellDate);
+
+ var selectDate = cellDate.concat();
+
+ if (cellDateIndex > -1) {
+ if (this.pageDate.getMonth() == dCellDate.getMonth() &&
+ this.pageDate.getFullYear() == dCellDate.getFullYear()) {
+ YAHOO.util.Dom.removeClass(cell, this.Style.CSS_CELL_SELECTED);
+ }
+
+ this.selectedDates.splice(cellDateIndex, 1);
+ }
+
+
+ if (this.parent) {
+ this.parent.sync(this);
+ }
+
+ this.onDeselect();
+ return this.getSelectedDates();
+};
+
+/**
+* Deselects all dates on the current calendar.
+* @return Array of JavaScript Date objects representing all individual dates that are currently selected.
+* Assuming that this function executes properly, the return value should be an empty array.
+* However, the empty array is returned for the sake of being able to check the selection status
+* of the calendar.
+* @type Date[]
+*/
+YAHOO.widget.Calendar_Core.prototype.deselectAll = function() {
+ this.onBeforeDeselect();
+ var count = this.selectedDates.length;
+ this.selectedDates.length = 0;
+
+ if (this.parent) {
+ this.parent.sync(this);
+ }
+
+ if (count > 0) {
+ this.onDeselect();
+ }
+
+ return this.getSelectedDates();
+};
+/************* END SELECTION METHODS *************************************************************/
+
+
+/************* BEGIN TYPE CONVERSION METHODS ****************************************************/
+
+/**
+* Converts a date (either a JavaScript Date object, or a date string) to the internal data structure
+* used to represent dates: [[yyyy,mm,dd],[yyyy,mm,dd]].
+* @private
+* @param {String/Date/Date[]} date The date string of dates to deselect in the current calendar. Valid formats are
+* individual date(s) (12/24/2005,12/26/2005) or date range(s) (12/24/2005-1/1/2006).
+* Multiple comma-delimited dates can also be passed to this method (12/24/2005,12/11/2005-12/13/2005).
+* This method can also take a JavaScript Date object or an array of Date objects.
+* @return Array of date field arrays
+* @type Array[](Integer[])
+*/
+YAHOO.widget.Calendar_Core.prototype._toFieldArray = function(date) {
+ var returnDate = new Array();
+
+ if (date instanceof Date) {
+ returnDate = [[date.getFullYear(), date.getMonth()+1, date.getDate()]];
+ } else if (typeof date == 'string') {
+ returnDate = this._parseDates(date);
+ } else if (date instanceof Array) {
+ for (var i=0;i<date.length;++i) {
+ var d = date[i];
+ returnDate[returnDate.length] = [d.getFullYear(),d.getMonth()+1,d.getDate()];
+ }
+ }
+
+ return returnDate;
+};
+
+/**
+* Converts a date field array [yyyy,mm,dd] to a JavaScript Date object.
+* @private
+* @param {Integer[]} dateFieldArray The date field array to convert to a JavaScript Date.
+* @return JavaScript Date object representing the date field array
+* @type Date
+*/
+YAHOO.widget.Calendar_Core.prototype._toDate = function(dateFieldArray) {
+ if (dateFieldArray instanceof Date) {
+ return dateFieldArray;
+ } else {
+ return new Date(dateFieldArray[0],dateFieldArray[1]-1,dateFieldArray[2]);
+ }
+};
+/************* END TYPE CONVERSION METHODS ******************************************************/
+
+
+/************* BEGIN UTILITY METHODS ****************************************************/
+/**
+* Converts a date field array [yyyy,mm,dd] to a JavaScript Date object.
+* @private
+* @param {Integer[]} array1 The first date field array to compare
+* @param {Integer[]} array2 The first date field array to compare
+* @return The boolean that represents the equality of the two arrays
+* @type Boolean
+*/
+YAHOO.widget.Calendar_Core.prototype._fieldArraysAreEqual = function(array1, array2) {
+ var match = false;
+
+ if (array1[0]==array2[0]&&array1[1]==array2[1]&&array1[2]==array2[2]) {
+ match=true;
+ }
+
+ return match;
+};
+
+/**
+* Gets the index of a date field array [yyyy,mm,dd] in the current list of selected dates.
+* @private
+* @param {Integer[]} find The date field array to search for
+* @return The index of the date field array within the collection of selected dates.
+* -1 will be returned if the date is not found.
+* @type Integer
+*/
+YAHOO.widget.Calendar_Core.prototype._indexOfSelectedFieldArray = function(find) {
+ var selected = -1;
+
+ for (var s=0;s<this.selectedDates.length;++s) {
+ var sArray = this.selectedDates[s];
+ if (find[0]==sArray[0]&&find[1]==sArray[1]&&find[2]==sArray[2]) {
+ selected = s;
+ break;
+ }
+ }
+
+ return selected;
+};
+
+/**
+* Determines whether a given date is OOM (out of month).
+* @param {Date} date The JavaScript Date object for which to check the OOM status
+* @return {Boolean} true if the date is OOM
+*/
+YAHOO.widget.Calendar_Core.prototype.isDateOOM = function(date) {
+ var isOOM = false;
+ if (date.getMonth() != this.pageDate.getMonth()) {
+ isOOM = true;
+ }
+ return isOOM;
+};
+
+/************* END UTILITY METHODS *******************************************************/
+
+/************* BEGIN EVENT HANDLERS ******************************************************/
+
+/**
+* Event executed before a date is selected in the calendar widget.
+*/
+YAHOO.widget.Calendar_Core.prototype.onBeforeSelect = function() {
+ if (! this.Options.MULTI_SELECT) {
+ this.clearAllBodyCellStyles(this.Style.CSS_CELL_SELECTED);
+ this.deselectAll();
+ }
+};
+
+/**
+* Event executed when a date is selected in the calendar widget.
+*/
+YAHOO.widget.Calendar_Core.prototype.onSelect = function() { };
+
+/**
+* Event executed before a date is deselected in the calendar widget.
+*/
+YAHOO.widget.Calendar_Core.prototype.onBeforeDeselect = function() { };
+
+/**
+* Event executed when a date is deselected in the calendar widget.
+*/
+YAHOO.widget.Calendar_Core.prototype.onDeselect = function() { };
+
+/**
+* Event executed when the user navigates to a different calendar page.
+*/
+YAHOO.widget.Calendar_Core.prototype.onChangePage = function() {
+ var me = this;
+
+ this.renderHeader();
+ if (this.renderProcId) {
+ clearTimeout(this.renderProcId);
+ }
+ this.renderProcId = setTimeout(function() {
+ me.render();
+ me.renderProcId = null;
+ }, 1);
+};
+
+/**
+* Event executed when the calendar widget is rendered.
+*/
+YAHOO.widget.Calendar_Core.prototype.onRender = function() { };
+
+/**
+* Event executed when the calendar widget is reset to its original state.
+*/
+YAHOO.widget.Calendar_Core.prototype.onReset = function() { this.render(); };
+
+/**
+* Event executed when the calendar widget is completely cleared to the current month with no selections.
+*/
+YAHOO.widget.Calendar_Core.prototype.onClear = function() { this.render(); };
+
+/**
+* Validates the calendar widget. This method has no default implementation
+* and must be extended by subclassing the widget.
+* @return Should return true if the widget validates, and false if
+* it doesn't.
+* @type Boolean
+*/
+YAHOO.widget.Calendar_Core.prototype.validate = function() { return true; };
+
+/************* END EVENT HANDLERS *********************************************************/
+
+
+/************* BEGIN DATE PARSE METHODS ***************************************************/
+
+
+/**
+* Converts a date string to a date field array
+* @private
+* @param {String} sDate Date string. Valid formats are mm/dd and mm/dd/yyyy.
+* @return A date field array representing the string passed to the method
+* @type Array[](Integer[])
+*/
+YAHOO.widget.Calendar_Core.prototype._parseDate = function(sDate) {
+ var aDate = sDate.split(this.Locale.DATE_FIELD_DELIMITER);
+ var rArray;
+
+ if (aDate.length == 2) {
+ rArray = [aDate[this.Locale.MD_MONTH_POSITION-1],aDate[this.Locale.MD_DAY_POSITION-1]];
+ rArray.type = YAHOO.widget.Calendar_Core.MONTH_DAY;
+ } else {
+ rArray = [aDate[this.Locale.MDY_YEAR_POSITION-1],aDate[this.Locale.MDY_MONTH_POSITION-1],aDate[this.Locale.MDY_DAY_POSITION-1]];
+ rArray.type = YAHOO.widget.Calendar_Core.DATE;
+ }
+ return rArray;
+};
+
+/**
+* Converts a multi or single-date string to an array of date field arrays
+* @private
+* @param {String} sDates Date string with one or more comma-delimited dates. Valid formats are mm/dd, mm/dd/yyyy, mm/dd/yyyy-mm/dd/yyyy
+* @return An array of date field arrays
+* @type Array[](Integer[])
+*/
+YAHOO.widget.Calendar_Core.prototype._parseDates = function(sDates) {
+ var aReturn = new Array();
+
+ var aDates = sDates.split(this.Locale.DATE_DELIMITER);
+
+ for (var d=0;d<aDates.length;++d) {
+ var sDate = aDates[d];
+
+ if (sDate.indexOf(this.Locale.DATE_RANGE_DELIMITER) != -1) {
+ // This is a range
+ var aRange = sDate.split(this.Locale.DATE_RANGE_DELIMITER);
+
+ var dateStart = this._parseDate(aRange[0]);
+ var dateEnd = this._parseDate(aRange[1]);
+
+ var fullRange = this._parseRange(dateStart, dateEnd);
+ aReturn = aReturn.concat(fullRange);
+ } else {
+ // This is not a range
+ var aDate = this._parseDate(sDate);
+ aReturn.push(aDate);
+ }
+ }
+ return aReturn;
+};
+
+/**
+* Converts a date range to the full list of included dates
+* @private
+* @param {Integer[]} startDate Date field array representing the first date in the range
+* @param {Integer[]} endDate Date field array representing the last date in the range
+* @return An array of date field arrays
+* @type Array[](Integer[])
+*/
+YAHOO.widget.Calendar_Core.prototype._parseRange = function(startDate, endDate) {
+ var dStart = new Date(startDate[0],startDate[1]-1,startDate[2]);
+ var dCurrent = YAHOO.widget.DateMath.add(new Date(startDate[0],startDate[1]-1,startDate[2]),YAHOO.widget.DateMath.DAY,1);
+ var dEnd = new Date(endDate[0], endDate[1]-1, endDate[2]);
+
+ var results = new Array();
+ results.push(startDate);
+ while (dCurrent.getTime() <= dEnd.getTime()) {
+ results.push([dCurrent.getFullYear(),dCurrent.getMonth()+1,dCurrent.getDate()]);
+ dCurrent = YAHOO.widget.DateMath.add(dCurrent,YAHOO.widget.DateMath.DAY,1);
+ }
+ return results;
+};
+
+/************* END DATE PARSE METHODS *****************************************************/
+
+/************* BEGIN RENDERER METHODS *****************************************************/
+
+/**
+* Resets the render stack of the current calendar to its original pre-render value.
+*/
+YAHOO.widget.Calendar_Core.prototype.resetRenderers = function() {
+ this.renderStack = this._renderStack.concat();
+};
+
+/**
+* Clears the inner HTML, CSS class and style information from the specified cell.
+* @param {HTMLTableCellElement} The cell to clear
+*/
+YAHOO.widget.Calendar_Core.prototype.clearElement = function(cell) {
+ cell.innerHTML = " ";
+ cell.className="";
+};
+
+/**
+* Adds a renderer to the render stack. The function reference passed to this method will be executed
+* when a date cell matches the conditions specified in the date string for this renderer.
+* @param {String} sDates A date string to associate with the specified renderer. Valid formats
+* include date (12/24/2005), month/day (12/24), and range (12/1/2004-1/1/2005)
+* @param {Function} fnRender The function executed to render cells that match the render rules for this renderer.
+*/
+YAHOO.widget.Calendar_Core.prototype.addRenderer = function(sDates, fnRender) {
+ var aDates = this._parseDates(sDates);
+ for (var i=0;i<aDates.length;++i) {
+ var aDate = aDates[i];
+
+ if (aDate.length == 2) { // this is either a range or a month/day combo
+ if (aDate[0] instanceof Array) { // this is a range
+ this._addRenderer(YAHOO.widget.Calendar_Core.RANGE,aDate,fnRender);
+ } else { // this is a month/day combo
+ this._addRenderer(YAHOO.widget.Calendar_Core.MONTH_DAY,aDate,fnRender);
+ }
+ } else if (aDate.length == 3) {
+ this._addRenderer(YAHOO.widget.Calendar_Core.DATE,aDate,fnRender);
+ }
+ }
+};
+
+/**
+* The private method used for adding cell renderers to the local render stack.
+* This method is called by other methods that set the renderer type prior to the method call.
+* @private
+* @param {String} type The type string that indicates the type of date renderer being added.
+* Values are YAHOO.widget.Calendar_Core.DATE, YAHOO.widget.Calendar_Core.MONTH_DAY, YAHOO.widget.Calendar_Core.WEEKDAY,
+* YAHOO.widget.Calendar_Core.RANGE, YAHOO.widget.Calendar_Core.MONTH
+* @param {Array} aDates An array of dates used to construct the renderer. The format varies based
+* on the renderer type
+* @param {Function} fnRender The function executed to render cells that match the render rules for this renderer.
+*/
+YAHOO.widget.Calendar_Core.prototype._addRenderer = function(type, aDates, fnRender) {
+ var add = [type,aDates,fnRender];
+ this.renderStack.unshift(add);
+
+ this._renderStack = this.renderStack.concat();
+};
+
+/**
+* Adds a month to the render stack. The function reference passed to this method will be executed
+* when a date cell matches the month passed to this method.
+* @param {Integer} month The month (1-12) to associate with this renderer
+* @param {Function} fnRender The function executed to render cells that match the render rules for this renderer.
+*/
+YAHOO.widget.Calendar_Core.prototype.addMonthRenderer = function(month, fnRender) {
+ this._addRenderer(YAHOO.widget.Calendar_Core.MONTH,[month],fnRender);
+};
+
+/**
+* Adds a weekday to the render stack. The function reference passed to this method will be executed
+* when a date cell matches the weekday passed to this method.
+* @param {Integer} weekay The weekday (1-7) to associate with this renderer
+* @param {Function} fnRender The function executed to render cells that match the render rules for this renderer.
+*/
+YAHOO.widget.Calendar_Core.prototype.addWeekdayRenderer = function(weekday, fnRender) {
+ this._addRenderer(YAHOO.widget.Calendar_Core.WEEKDAY,[weekday],fnRender);
+};
+//// END RENDERER METHODS ////
+
+//// BEGIN CSS METHODS ////
+
+/**
+* Sets the specified array of CSS classes into the referenced element
+* @param {HTMLElement} element The element to set the CSS classes into
+* @param {String[]} aStyles An array of CSS class names
+*/
+YAHOO.widget.Calendar_Core.setCssClasses = function(element, aStyles) {
+ element.className = "";
+ var className = aStyles.join(" ");
+ element.className = className;
+};
+
+/**
+* Removes all styles from all body cells in the current calendar table.
+* @param {style} The CSS class name to remove from all calendar body cells
+*/
+YAHOO.widget.Calendar_Core.prototype.clearAllBodyCellStyles = function(style) {
+ for (var c=0;c<this.cells.length;++c) {
+ YAHOO.util.Dom.removeClass(this.cells[c],style);
+ }
+};
+
+//// END CSS METHODS ////
+
+//// BEGIN GETTER/SETTER METHODS ////
+/**
+* Sets the calendar's month explicitly.
+* @param {Integer} month The numeric month, from 1 (January) to 12 (December)
+*/
+YAHOO.widget.Calendar_Core.prototype.setMonth = function(month) {
+ this.pageDate.setMonth(month);
+};
+
+/**
+* Sets the calendar's year explicitly.
+* @param {Integer} year The numeric 4-digit year
+*/
+YAHOO.widget.Calendar_Core.prototype.setYear = function(year) {
+ this.pageDate.setFullYear(year);
+};
+
+/**
+* Gets the list of currently selected dates from the calendar.
+* @return An array of currently selected JavaScript Date objects.
+* @type Date[]
+*/
+YAHOO.widget.Calendar_Core.prototype.getSelectedDates = function() {
+ var returnDates = new Array();
+
+ for (var d=0;d<this.selectedDates.length;++d) {
+ var dateArray = this.selectedDates[d];
+
+ var date = new Date(dateArray[0],dateArray[1]-1,dateArray[2]);
+ returnDates.push(date);
+ }
+
+ returnDates.sort();
+ return returnDates;
+};
+
+/// END GETTER/SETTER METHODS ///
+
+/**
+* Returns a string representing the current browser.
+* @type String
+*/
+YAHOO.widget.Calendar_Core._getBrowser = function() {
+ /**
+ * UserAgent
+ * @private
+ * @type String
+ */
+ var ua = navigator.userAgent.toLowerCase();
+
+ if (ua.indexOf('opera')!=-1) // Opera (check first in case of spoof)
+ return 'opera';
+ else if (ua.indexOf('msie')!=-1) // IE
+ return 'ie';
+ else if (ua.indexOf('safari')!=-1) // Safari (check before Gecko because it includes "like Gecko")
+ return 'safari';
+ else if (ua.indexOf('gecko') != -1) // Gecko
+ return 'gecko';
+ else
+ return false;
+}
+
+/**
+* Returns a string representation of the object.
+* @type string
+*/
+YAHOO.widget.Calendar_Core.prototype.toString = function() {
+ return "Calendar_Core " + this.id;
+}
+
+YAHOO.widget.Cal_Core = YAHOO.widget.Calendar_Core;/**
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+**/
+
+/**
+* @class
+* Calendar is the default implementation of the YAHOO.widget.Calendar_Core base class.
+* This class is the UED-approved version of the calendar selector widget. For all documentation
+* on the implemented methods listed here, see the documentation for YAHOO.widget.Calendar_Core.
+* @constructor
+* @param {String} id The id of the table element that will represent the calendar widget
+* @param {String} containerId The id of the container element that will contain the calendar table
+* @param {String} monthyear The month/year string used to set the current calendar page
+* @param {String} selected A string of date values formatted using the date parser. The built-in
+ default date format is MM/DD/YYYY. Ranges are defined using
+ MM/DD/YYYY-MM/DD/YYYY. Month/day combinations are defined using MM/DD.
+ Any combination of these can be combined by delimiting the string with
+ commas. Example: "12/24/2005,12/25,1/18/2006-1/21/2006"
+*/
+YAHOO.widget.Calendar = function(id, containerId, monthyear, selected) {
+ if (arguments.length > 0) {
+ this.init(id, containerId, monthyear, selected);
+ }
+}
+
+YAHOO.widget.Calendar.prototype = new YAHOO.widget.Calendar_Core();
+
+YAHOO.widget.Calendar.prototype.buildShell = function() {
+ this.border = document.createElement("DIV");
+ this.border.className = this.Style.CSS_CONTAINER;
+
+ this.table = document.createElement("TABLE");
+ this.table.cellSpacing = 0;
+
+ YAHOO.widget.Calendar_Core.setCssClasses(this.table, [this.Style.CSS_CALENDAR]);
+
+ this.border.id = this.id;
+
+ this.buildShellHeader();
+ this.buildShellBody();
+ this.buildShellFooter();
+};
+
+YAHOO.widget.Calendar.prototype.renderShell = function() {
+ this.border.appendChild(this.table);
+ this.oDomContainer.appendChild(this.border);
+ this.shellRendered = true;
+};
+
+YAHOO.widget.Calendar.prototype.renderHeader = function() {
+ this.headerCell.innerHTML = "";
+
+ var headerContainer = document.createElement("DIV");
+ headerContainer.className = this.Style.CSS_HEADER;
+
+ if (this.linkLeft) {
+ YAHOO.util.Event.removeListener(this.linkLeft, "mousedown", this.previousMonth);
+ }
+ this.linkLeft = document.createElement("A");
+ this.linkLeft.innerHTML = " ";
+ YAHOO.util.Event.addListener(this.linkLeft, "mousedown", this.previousMonth, this, true);
+ this.linkLeft.style.backgroundImage = "url(" + this.Options.NAV_ARROW_LEFT + ")";
+ this.linkLeft.className = this.Style.CSS_NAV_LEFT;
+
+ if (this.linkRight) {
+ YAHOO.util.Event.removeListener(this.linkRight, "mousedown", this.nextMonth);
+ }
+ this.linkRight = document.createElement("A");
+ this.linkRight.innerHTML = " ";
+ YAHOO.util.Event.addListener(this.linkRight, "mousedown", this.nextMonth, this, true);
+ this.linkRight.style.backgroundImage = "url(" + this.Options.NAV_ARROW_RIGHT + ")";
+ this.linkRight.className = this.Style.CSS_NAV_RIGHT;
+
+ headerContainer.appendChild(this.linkLeft);
+ headerContainer.appendChild(document.createTextNode(this.buildMonthLabel()));
+ headerContainer.appendChild(this.linkRight);
+
+ this.headerCell.appendChild(headerContainer);
+};
+
+YAHOO.widget.Cal = YAHOO.widget.Calendar;/**
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+**/
+
+/**
+* @class
+* <p>YAHOO.widget.CalendarGroup is a special container class for YAHOO.widget.Calendar_Core. This class facilitates
+* the ability to have multi-page calendar views that share a single dataset and are
+* dependent on each other.</p>
+*
+* <p>The calendar group instance will refer to each of its elements using a 0-based index.
+* For example, to construct the placeholder for a calendar group widget with id "cal1" and
+* containerId of "cal1Container", the markup would be as follows:
+* <xmp>
+* <div id="cal1Container_0"></div>
+* <div id="cal1Container_1"></div>
+* </xmp>
+* The tables for the calendars ("cal1_0" and "cal1_1") will be inserted into those containers.
+* </p>
+* @constructor
+* @param {Integer} pageCount The number of pages that this calendar should display.
+* @param {String} id The id of the element that will be inserted into the DOM.
+* @param {String} containerId The id of the container element that the calendar will be inserted into.
+* @param {String} monthyear The month/year string used to set the current calendar page
+* @param {String} selected A string of date values formatted using the date parser. The built-in
+ default date format is MM/DD/YYYY. Ranges are defined using
+ MM/DD/YYYY-MM/DD/YYYY. Month/day combinations are defined using MM/DD.
+ Any combination of these can be combined by delimiting the string with
+ commas. Example: "12/24/2005,12/25,1/18/2006-1/21/2006"
+*/
+YAHOO.widget.CalendarGroup = function(pageCount, id, containerId, monthyear, selected) {
+ if (arguments.length > 0) {
+ this.init(pageCount, id, containerId, monthyear, selected);
+ }
+}
+
+/**
+* Initializes the calendar group. All subclasses must call this method in order for the
+* group to be initialized properly.
+* @param {Integer} pageCount The number of pages that this calendar should display.
+* @param {String} id The id of the element that will be inserted into the DOM.
+* @param {String} containerId The id of the container element that the calendar will be inserted into.
+* @param {String} monthyear The month/year string used to set the current calendar page
+* @param {String} selected A string of date values formatted using the date parser. The built-in
+ default date format is MM/DD/YYYY. Ranges are defined using
+ MM/DD/YYYY-MM/DD/YYYY. Month/day combinations are defined using MM/DD.
+ Any combination of these can be combined by delimiting the string with
+ commas. Example: "12/24/2005,12/25,1/18/2006-1/21/2006"
+*/
+YAHOO.widget.CalendarGroup.prototype.init = function(pageCount, id, containerId, monthyear, selected) {
+ this.id = id;
+ this.selectedDates = new Array();
+ this.containerId = containerId;
+
+ this.pageCount = pageCount;
+
+ this.pages = new Array();
+
+ for (var p=0;p<pageCount;++p) {
+ var cal = this.constructChild(id + "_" + p, this.containerId + "_" + p , monthyear, selected);
+
+ cal.parent = this;
+
+ cal.index = p;
+
+ cal.pageDate.setMonth(cal.pageDate.getMonth()+p);
+ cal._pageDate = new Date(cal.pageDate.getFullYear(),cal.pageDate.getMonth(),cal.pageDate.getDate());
+ this.pages.push(cal);
+ }
+
+ this.doNextMonth = function(e, calGroup) {
+ calGroup.nextMonth();
+ };
+
+ this.doPreviousMonth = function(e, calGroup) {
+ calGroup.previousMonth();
+ };
+};
+
+/**
+* Adds a function to all child Calendars within this CalendarGroup.
+* @param {String} fnName The name of the function
+* @param {Function} fn The function to apply to each Calendar page object
+*/
+YAHOO.widget.CalendarGroup.prototype.setChildFunction = function(fnName, fn) {
+ for (var p=0;p<this.pageCount;++p) {
+ this.pages[p][fnName] = fn;
+ }
+}
+
+/**
+* Calls a function within all child Calendars within this CalendarGroup.
+* @param {String} fnName The name of the function
+* @param {Array} args The arguments to pass to the function
+*/
+YAHOO.widget.CalendarGroup.prototype.callChildFunction = function(fnName, args) {
+ for (var p=0;p<this.pageCount;++p) {
+ var page = this.pages[p];
+ if (page[fnName]) {
+ var fn = page[fnName];
+ fn.call(page, args);
+ }
+ }
+}
+
+/**
+* Constructs a child calendar. This method can be overridden if a subclassed version of the default
+* calendar is to be used.
+* @param {String} id The id of the element that will be inserted into the DOM.
+* @param {String} containerId The id of the container element that the calendar will be inserted into.
+* @param {String} monthyear The month/year string used to set the current calendar page
+* @param {String} selected A string of date values formatted using the date parser. The built-in
+ default date format is MM/DD/YYYY. Ranges are defined using
+ MM/DD/YYYY-MM/DD/YYYY. Month/day combinations are defined using MM/DD.
+ Any combination of these can be combined by delimiting the string with
+ commas. Example: "12/24/2005,12/25,1/18/2006-1/21/2006"
+* @return The YAHOO.widget.Calendar_Core instance that is constructed
+* @type YAHOO.widget.Calendar_Core
+*/
+YAHOO.widget.CalendarGroup.prototype.constructChild = function(id,containerId,monthyear,selected) {
+ return new YAHOO.widget.Calendar_Core(id,containerId,monthyear,selected);
+};
+
+
+/**
+* Sets the calendar group's month explicitly. This month will be set into the first
+* page of the multi-page calendar, and all other months will be iterated appropriately.
+* @param {Integer} month The numeric month, from 1 (January) to 12 (December)
+*/
+YAHOO.widget.CalendarGroup.prototype.setMonth = function(month) {
+ for (var p=0;p<this.pages.length;++p)
+ {
+ var cal = this.pages[p];
+ cal.setMonth(month+p);
+ }
+};
+
+/**
+* Sets the calendar group's year explicitly. This year will be set into the first
+* page of the multi-page calendar, and all other months will be iterated appropriately.
+* @param {Integer} year The numeric 4-digit year
+*/
+YAHOO.widget.CalendarGroup.prototype.setYear = function(year) {
+ for (var p=0;p<this.pages.length;++p)
+ {
+ var cal = this.pages[p];
+ if ((cal.pageDate.getMonth()+1) == 1 && p>0)
+ {
+ year+=1;
+ }
+ cal.setYear(year);
+ }
+};
+
+/**
+* Calls the render function of all child calendars within the group.
+*/
+YAHOO.widget.CalendarGroup.prototype.render = function() {
+ for (var p=0;p<this.pages.length;++p)
+ {
+ var cal = this.pages[p];
+ cal.render();
+ }
+};
+
+/**
+* Calls the select function of all child calendars within the group.
+*/
+YAHOO.widget.CalendarGroup.prototype.select = function(date) {
+ var ret;
+ for (var p=0;p<this.pages.length;++p)
+ {
+ var cal = this.pages[p];
+ ret = cal.select(date);
+ }
+ return ret;
+};
+
+/**
+* Calls the selectCell function of all child calendars within the group.
+*/
+YAHOO.widget.CalendarGroup.prototype.selectCell = function(cellIndex) {
+ var ret;
+ for (var p=0;p<this.pages.length;++p)
+ {
+ var cal = this.pages[p];
+ ret = cal.selectCell(cellIndex);
+ }
+ return ret;
+};
+
+/**
+* Calls the deselect function of all child calendars within the group.
+*/
+YAHOO.widget.CalendarGroup.prototype.deselect = function(date) {
+ var ret;
+ for (var p=0;p<this.pages.length;++p)
+ {
+ var cal = this.pages[p];
+ ret = cal.deselect(date);
+ }
+ return ret;
+};
+
+/**
+* Calls the deselectAll function of all child calendars within the group.
+*/
+YAHOO.widget.CalendarGroup.prototype.deselectAll = function() {
+ var ret;
+ for (var p=0;p<this.pages.length;++p)
+ {
+ var cal = this.pages[p];
+ ret = cal.deselectAll();
+ }
+ return ret;
+};
+
+/**
+* Calls the deselectAll function of all child calendars within the group.
+*/
+YAHOO.widget.CalendarGroup.prototype.deselectCell = function(cellIndex) {
+ for (var p=0;p<this.pages.length;++p)
+ {
+ var cal = this.pages[p];
+ cal.deselectCell(cellIndex);
+ }
+ return this.getSelectedDates();
+};
+
+/**
+* Calls the reset function of all child calendars within the group.
+*/
+YAHOO.widget.CalendarGroup.prototype.reset = function() {
+ for (var p=0;p<this.pages.length;++p)
+ {
+ var cal = this.pages[p];
+ cal.reset();
+ }
+};
+
+/**
+* Calls the clear function of all child calendars within the group.
+*/
+YAHOO.widget.CalendarGroup.prototype.clear = function() {
+ for (var p=0;p<this.pages.length;++p)
+ {
+ var cal = this.pages[p];
+ cal.clear();
+ }
+};
+
+/**
+* Calls the nextMonth function of all child calendars within the group.
+*/
+YAHOO.widget.CalendarGroup.prototype.nextMonth = function() {
+ for (var p=0;p<this.pages.length;++p)
+ {
+ var cal = this.pages[p];
+ cal.nextMonth();
+ }
+};
+
+/**
+* Calls the previousMonth function of all child calendars within the group.
+*/
+YAHOO.widget.CalendarGroup.prototype.previousMonth = function() {
+ for (var p=this.pages.length-1;p>=0;--p)
+ {
+ var cal = this.pages[p];
+ cal.previousMonth();
+ }
+};
+
+/**
+* Calls the nextYear function of all child calendars within the group.
+*/
+YAHOO.widget.CalendarGroup.prototype.nextYear = function() {
+ for (var p=0;p<this.pages.length;++p)
+ {
+ var cal = this.pages[p];
+ cal.nextYear();
+ }
+};
+
+/**
+* Calls the previousYear function of all child calendars within the group.
+*/
+YAHOO.widget.CalendarGroup.prototype.previousYear = function() {
+ for (var p=0;p<this.pages.length;++p)
+ {
+ var cal = this.pages[p];
+ cal.previousYear();
+ }
+};
+
+/**
+* Synchronizes the data values for all child calendars within the group. If the sync
+* method is called passing in the caller object, the values of all children will be set
+* to the values of the caller. If the argument is ommitted, the values from all children
+* will be combined into one distinct list and set into each child.
+* @param {YAHOO.widget.Calendar_Core} caller The YAHOO.widget.Calendar_Core that is initiating the call to sync().
+* @return Array of selected dates, in JavaScript Date object form.
+* @type Date[]
+*/
+YAHOO.widget.CalendarGroup.prototype.sync = function(caller) {
+ var calendar;
+
+ if (caller)
+ {
+ this.selectedDates = caller.selectedDates.concat();
+ } else {
+ var hash = new Object();
+ var combinedDates = new Array();
+
+ for (var p=0;p<this.pages.length;++p)
+ {
+ calendar = this.pages[p];
+
+ var values = calendar.selectedDates;
+
+ for (var v=0;v<values.length;++v)
+ {
+ var valueArray = values[v];
+ hash[valueArray.toString()] = valueArray;
+ }
+ }
+
+ for (var val in hash)
+ {
+ combinedDates[combinedDates.length]=hash[val];
+ }
+
+ this.selectedDates = combinedDates.concat();
+ }
+
+ // Set all the values into the children
+ for (p=0;p<this.pages.length;++p)
+ {
+ calendar = this.pages[p];
+ if (! calendar.Options.MULTI_SELECT) {
+ calendar.clearAllBodyCellStyles(calendar.Config.Style.CSS_CELL_SELECTED);
+ }
+ calendar.selectedDates = this.selectedDates.concat();
+
+ }
+
+ return this.getSelectedDates();
+};
+
+/**
+* Gets the list of currently selected dates from the calendar.
+* @return An array of currently selected JavaScript Date objects.
+* @type Date[]
+*/
+YAHOO.widget.CalendarGroup.prototype.getSelectedDates = function() {
+ var returnDates = new Array();
+
+ for (var d=0;d<this.selectedDates.length;++d)
+ {
+ var dateArray = this.selectedDates[d];
+
+ var date = new Date(dateArray[0],dateArray[1]-1,dateArray[2]);
+ returnDates.push(date);
+ }
+
+ returnDates.sort();
+ return returnDates;
+};
+
+/**
+* Calls the addRenderer function of all child calendars within the group.
+*/
+YAHOO.widget.CalendarGroup.prototype.addRenderer = function(sDates, fnRender) {
+ for (var p=0;p<this.pages.length;++p)
+ {
+ var cal = this.pages[p];
+ cal.addRenderer(sDates, fnRender);
+ }
+};
+
+/**
+* Calls the addMonthRenderer function of all child calendars within the group.
+*/
+YAHOO.widget.CalendarGroup.prototype.addMonthRenderer = function(month, fnRender) {
+ for (var p=0;p<this.pages.length;++p)
+ {
+ var cal = this.pages[p];
+ cal.addMonthRenderer(month, fnRender);
+ }
+};
+
+/**
+* Calls the addWeekdayRenderer function of all child calendars within the group.
+*/
+YAHOO.widget.CalendarGroup.prototype.addWeekdayRenderer = function(weekday, fnRender) {
+ for (var p=0;p<this.pages.length;++p)
+ {
+ var cal = this.pages[p];
+ cal.addWeekdayRenderer(weekday, fnRender);
+ }
+};
+
+/**
+* Sets an event handler universally across all child calendars within the group. For instance,
+* to set the onSelect handler for all child calendars to a function called fnSelect, the call would be:
+* <code>
+* calGroup.wireEvent("onSelect", fnSelect);
+* </code>
+* @param {String} eventName The name of the event to handler to set within all child calendars.
+* @param {Function} fn The function to set into the specified event handler.
+*/
+YAHOO.widget.CalendarGroup.prototype.wireEvent = function(eventName, fn) {
+ for (var p=0;p<this.pages.length;++p)
+ {
+ var cal = this.pages[p];
+ cal[eventName] = fn;
+ }
+};
+
+/**
+* Returns a string representation of the object.
+* @type string
+*/
+YAHOO.widget.CalendarGroup.prototype.toString = function() {
+ return "CalendarGroup " + this.id;
+}
+
+YAHOO.widget.CalGrp = YAHOO.widget.CalendarGroup;/**
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+**/
+
+/**
+* @class
+* Calendar2up_Cal is the default implementation of the Calendar_Core base class, when used
+* in a 2-up view. This class is the UED-approved version of the calendar selector widget. For all documentation
+* on the implemented methods listed here, see the documentation for Calendar_Core. This class
+* has some special attributes that only apply to calendars rendered within the calendar group implementation.
+* There should be no reason to instantiate this class directly.
+* @constructor
+* @param {String} id The id of the table element that will represent the calendar widget
+* @param {String} containerId The id of the container element that will contain the calendar table
+* @param {String} monthyear The month/year string used to set the current calendar page
+* @param {String} selected A string of date values formatted using the date parser. The built-in
+ default date format is MM/DD/YYYY. Ranges are defined using
+ MM/DD/YYYY-MM/DD/YYYY. Month/day combinations are defined using MM/DD.
+ Any combination of these can be combined by delimiting the string with
+ commas. Example: "12/24/2005,12/25,1/18/2006-1/21/2006"
+*/
+YAHOO.widget.Calendar2up_Cal = function(id, containerId, monthyear, selected) {
+ if (arguments.length > 0)
+ {
+ this.init(id, containerId, monthyear, selected);
+ }
+}
+
+YAHOO.widget.Calendar2up_Cal.prototype = new YAHOO.widget.Calendar_Core();
+
+/**
+* Renders the header for each individual calendar in the 2-up view. More
+* specifically, this method handles the placement of left and right arrows for
+* navigating between calendar pages.
+*/
+YAHOO.widget.Calendar2up_Cal.prototype.renderHeader = function() {
+ this.headerCell.innerHTML = "";
+
+ var headerContainer = document.createElement("DIV");
+ headerContainer.className = this.Style.CSS_HEADER;
+
+ if (this.index == 0) {
+
+ if (this.linkLeft) {
+ YAHOO.util.Event.removeListener(this.linkLeft, "mousedown", this.parent.doPreviousMonth);
+ }
+ this.linkLeft = document.createElement("A");
+ this.linkLeft.innerHTML = " ";
+ this.linkLeft.style.backgroundImage = "url(" + this.Options.NAV_ARROW_LEFT + ")";
+ this.linkLeft.className = this.Style.CSS_NAV_LEFT;
+
+ YAHOO.util.Event.addListener(this.linkLeft, "mousedown", this.parent.doPreviousMonth, this.parent);
+ headerContainer.appendChild(this.linkLeft);
+ }
+
+ headerContainer.appendChild(document.createTextNode(this.buildMonthLabel()));
+
+ if (this.index == 1) {
+
+ if (this.linkRight) {
+ YAHOO.util.Event.removeListener(this.linkRight, "mousedown", this.parent.doNextMonth);
+ }
+ this.linkRight = document.createElement("A");
+ this.linkRight.innerHTML = " ";
+ this.linkRight.style.backgroundImage = "url(" + this.Options.NAV_ARROW_RIGHT + ")";
+ this.linkRight.className = this.Style.CSS_NAV_RIGHT;
+
+ YAHOO.util.Event.addListener(this.linkRight, "mousedown", this.parent.doNextMonth, this.parent);
+ headerContainer.appendChild(this.linkRight);
+ }
+
+ this.headerCell.appendChild(headerContainer);
+};
+
+
+
+
+/**
+* @class
+* Calendar2up is the default implementation of the CalendarGroup base class, when used
+* in a 2-up view. This class is the UED-approved version of the 2-up calendar selector widget. For all documentation
+* on the implemented methods listed here, see the documentation for CalendarGroup.
+* @constructor
+* @param {String} id The id of the table element that will represent the calendar widget
+* @param {String} containerId The id of the container element that will contain the calendar table
+* @param {String} monthyear The month/year string used to set the current calendar page
+* @param {String} selected A string of date values formatted using the date parser. The built-in
+ default date format is MM/DD/YYYY. Ranges are defined using
+ MM/DD/YYYY-MM/DD/YYYY. Month/day combinations are defined using MM/DD.
+ Any combination of these can be combined by delimiting the string with
+ commas. Example: "12/24/2005,12/25,1/18/2006-1/21/2006"
+*/
+YAHOO.widget.Calendar2up = function(id, containerId, monthyear, selected) {
+ if (arguments.length > 0)
+ {
+ this.buildWrapper(containerId);
+ this.init(2, id, containerId, monthyear, selected);
+ }
+}
+
+YAHOO.widget.Calendar2up.prototype = new YAHOO.widget.CalendarGroup();
+
+/**
+* CSS class representing the wrapper for the 2-up calendar
+* @type string
+*/
+YAHOO.widget.Calendar2up.CSS_2UPWRAPPER = "yui-cal2upwrapper";
+
+/**
+* CSS class representing the container for the calendar
+* @type string
+*/
+YAHOO.widget.Calendar2up.CSS_CONTAINER = "yui-calcontainer";
+
+/**
+* CSS class representing the container for the 2-up calendar
+* @type string
+*/
+YAHOO.widget.Calendar2up.CSS_2UPCONTAINER = "cal2up";
+
+/**
+* CSS class representing the title for the 2-up calendar
+* @type string
+*/
+YAHOO.widget.Calendar2up.CSS_2UPTITLE = "title";
+
+/**
+* CSS class representing the close icon for the 2-up calendar
+* @type string
+*/
+YAHOO.widget.Calendar2up.CSS_2UPCLOSE = "close-icon";
+
+/**
+* Implementation of CalendarGroup.constructChild that ensures that child calendars of
+* Calendar2up will be of type Calendar2up_Cal.
+*/
+YAHOO.widget.Calendar2up.prototype.constructChild = function(id,containerId,monthyear,selected) {
+ var cal = new YAHOO.widget.Calendar2up_Cal(id,containerId,monthyear,selected);
+ return cal;
+};
+
+/**
+* Builds the wrapper container for the 2-up calendar.
+* @param {String} containerId The id of the outer container element.
+*/
+YAHOO.widget.Calendar2up.prototype.buildWrapper = function(containerId) {
+ var outerContainer = document.getElementById(containerId);
+
+ outerContainer.className = YAHOO.widget.Calendar2up.CSS_2UPWRAPPER;
+
+ var innerContainer = document.createElement("DIV");
+ innerContainer.className = YAHOO.widget.Calendar2up.CSS_CONTAINER;
+ innerContainer.id = containerId + "_inner";
+
+ var cal1Container = document.createElement("DIV");
+ cal1Container.id = containerId + "_0";
+ cal1Container.className = YAHOO.widget.Calendar2up.CSS_2UPCONTAINER;
+ cal1Container.style.marginRight = "10px";
+
+ var cal2Container = document.createElement("DIV");
+ cal2Container.id = containerId + "_1";
+ cal2Container.className = YAHOO.widget.Calendar2up.CSS_2UPCONTAINER;
+
+ outerContainer.appendChild(innerContainer);
+ innerContainer.appendChild(cal1Container);
+ innerContainer.appendChild(cal2Container);
+
+ this.innerContainer = innerContainer;
+ this.outerContainer = outerContainer;
+}
+
+/**
+* Renders the 2-up calendar.
+*/
+YAHOO.widget.Calendar2up.prototype.render = function() {
+ this.renderHeader();
+ YAHOO.widget.CalendarGroup.prototype.render.call(this);
+ this.renderFooter();
+};
+
+/**
+* Renders the header located at the top of the container for the 2-up calendar.
+*/
+YAHOO.widget.Calendar2up.prototype.renderHeader = function() {
+ if (! this.title) {
+ this.title = "";
+ }
+ if (! this.titleDiv)
+ {
+ this.titleDiv = document.createElement("DIV");
+ if (this.title == "")
+ {
+ this.titleDiv.style.display="none";
+ }
+ }
+
+ this.titleDiv.className = YAHOO.widget.Calendar2up.CSS_2UPTITLE;
+ this.titleDiv.innerHTML = this.title;
+
+ if (this.outerContainer.style.position == "absolute")
+ {
+ var linkClose = document.createElement("A");
+ linkClose.href = "javascript:void(null)";
+ YAHOO.util.Event.addListener(linkClose, "click", this.hide, this);
+
+ var imgClose = document.createElement("IMG");
+ imgClose.src = YAHOO.widget.Calendar_Core.IMG_ROOT + "us/my/bn/x_d.gif";
+ imgClose.className = YAHOO.widget.Calendar2up.CSS_2UPCLOSE;
+
+ linkClose.appendChild(imgClose);
+
+ this.linkClose = linkClose;
+
+ this.titleDiv.appendChild(linkClose);
+ }
+
+ this.innerContainer.insertBefore(this.titleDiv, this.innerContainer.firstChild);
+}
+
+/**
+* Hides the 2-up calendar's outer container from view.
+*/
+YAHOO.widget.Calendar2up.prototype.hide = function(e, cal) {
+ if (! cal)
+ {
+ cal = this;
+ }
+ cal.outerContainer.style.display = "none";
+}
+
+/**
+* Renders a footer for the 2-up calendar container. By default, this method is
+* unimplemented.
+*/
+YAHOO.widget.Calendar2up.prototype.renderFooter = function() {}
+
+YAHOO.widget.Cal2up = YAHOO.widget.Calendar2up;
\ No newline at end of file
Added: branches/tomek/portal-dnd/dndRenderer.war/js/connection/README
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/connection/README 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/connection/README 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,80 @@
+Connection Manager Release Notes
+
+*** version 0.11.1 ***
+
+* uploadFile() now verifies the existence of callback.upload before invoking
+callback, with or without object scope.
+
+*** version 0.11.0 ***
+
+* Each transactions can be defined with a timeout threshold, in milliseconds,
+through the callback object. If the threshold is reached, and the transaction
+hasn't completed, the transaction will call abort().
+
+* abort() will now accept a callback object as the second argument. The
+failure callback will receive a response object to indicate the transaction was
+aborted.
+
+* setForm() will now support file uploads by setting the second argument to
+true (e.g., YAHOO.util.Connect.setForm(formObject, true). File upload does not
+use the callback success or failure handler. Instead, it uses a new callback
+object handler: upload.
+
+* HTML form submit will no longer submit form fields without a defined name
+attribute.
+
+* The default POST header of 'Content-Type','application/x-www-form-urlencoded'
+can be overridden by calling setDefaultPostHeader(false). This
+will remove the default header from non-HTML form, POST submissions.
+
+* setHeader() now enumerates through the _http_header object with
+propertyIsEnumerable to prevent collisions with members added to Object via
+prototype.
+
+*** version 0.10.0 ***
+
+* handleTransactionResponse() now treats the full HTTP 2xx range as a success
+case, instead of just HTTP 200.
+
+* To accommodate multiple field values in Mozilla/Firefox, multiple initHeader
+calls with the same label will now result in the values concatenated to a
+comma- delimited string value.
+Example:
+Setting Content-Type:'application/x-www-form-urlencoded' and Content-
+Type:'text/xml' will result in Content-Type:'application/x-www-form-urlencoded,
+text/xml'.
+
+* Default polling interval lowered to 50ms.
+
+* YAHOO.util.Connect.setPollingInterval() will allow you to set a polling
+interval -- in milliseconds -- to override the default value.
+
+* YAHOO.util.Connect.getResponseHeader[headerLabel] now supported as a response
+object property to provide symmetry with the native XHR object's property.
+Example:
+YAHOO.util.Connect.getResponseHeader['Content-Length'] will return the value
+for the Content-Length header, if the header is available.
+
+* YAHOO.util.Connect.allResponseHeaders property renamed to
+getAllResponseHeaders to provide symmetry with the native XHR object's
+property.
+
+* YAHOO.util.Connect.setForm() now supports HTTP GET as well as HTTP POST.
+
+* YAHOO.util.Connect.setForm() now accepts an HTML form object as well as its
+name attribute value.
+
+* YAHOO.util.Connect.setForm() will not submit HTML form fields that are
+disabled or do not have a name attribute value.
+
+* [FIXED] Response exceptions result in infinite callback loop in
+Mozilla/Firefox.
+
+* [FIXED] YAHOO.util.Connect.abort() now properly clears polling interval.
+
+* [FIXED] isCallInProgress() now verifies whether XHR instance still exists,
+and returns false if the connection object is no longer available.
+
+*** version 0.9.0 ***
+
+* Initial release
Added: branches/tomek/portal-dnd/dndRenderer.war/js/connection/connection-debug.js
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/connection/connection-debug.js 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/connection/connection-debug.js 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,803 @@
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 0.11.1
+*/
+
+/**
+ * The Connection Manager provides a simplified interface to the XMLHttpRequest
+ * object. It handles cross-browser instantiantion of XMLHttpRequest, negotiates the
+ * interactive states and server response, returning the results to a pre-defined
+ * callback you create.
+ * @ class
+ */
+YAHOO.util.Connect =
+{
+/**
+ * Array of MSFT ActiveX ids for XMLHttpRequest.
+ * @private
+ * @type array
+ */
+ _msxml_progid:[
+ 'MSXML2.XMLHTTP.3.0',
+ 'MSXML2.XMLHTTP',
+ 'Microsoft.XMLHTTP'
+ ],
+
+ /**
+ * Object literal of HTTP header(s)
+ * @private
+ * @type object
+ */
+ _http_header:{},
+
+ /**
+ * Determines if HTTP headers are set.
+ * @private
+ * @type boolean
+ */
+ _has_http_headers:false,
+
+ /**
+ * Property that that determines if a default header of
+ * Content-Type of 'application/x-www-form-urlencoded'
+ * will be added to any client HTTP headers sent.
+ * @private
+ * @type boolean
+ */
+ _default_post_header:true,
+
+ /**
+ * Property modified by setForm() to determine if the data
+ * should be submitted as an HTML form.
+ * @private
+ * @type boolean
+ */
+ _isFormSubmit:false,
+
+ /**
+ * Property modified by setForm() to determine if a file(s)
+ * upload is expected.
+ * @private
+ * @type boolean
+ */
+ _isFileUpload:false,
+
+ /**
+ * Property modified by setForm() to set a reference to the HTML
+ * form node if the desired action is file upload.
+ * @private
+ * @type object
+ */
+ _formNode:null,
+
+ /**
+ * Property modified by setForm() to set the HTML form data
+ * for each transaction.
+ * @private
+ * @type string
+ */
+ _sFormData:null,
+
+ /**
+ * Collection of polling references to the polling mechanism in handleReadyState.
+ * @private
+ * @type string
+ */
+ _poll:[],
+
+ /**
+ * Queue of timeout references for each transaction with a defined timeout value.
+ * @private
+ * @type string
+ */
+ _timeOut:[],
+
+ /**
+ * The polling frequency, in milliseconds, for HandleReadyState.
+ * when attempting to determine a transaction's XHR readyState.
+ * The default is 50 milliseconds.
+ * @private
+ * @type int
+ */
+ _polling_interval:50,
+
+ /**
+ * A transaction counter that increments the transaction id for each transaction.
+ * @private
+ * @type int
+ */
+ _transaction_id:0,
+
+ /**
+ * Member to add an ActiveX id to the existing xml_progid array.
+ * In the event(unlikely) a new ActiveX id is introduced, it can be added
+ * without internal code modifications.
+ * @public
+ * @param string id The ActiveX id to be added to initialize the XHR object.
+ * @return void
+ */
+ setProgId:function(id)
+ {
+ this._msxml_progid.unshift(id);
+ YAHOO.log('ActiveX Program Id ' + id + ' added to _msxml_progid.', 'info', 'Connection');
+ },
+
+ /**
+ * Member to enable or disable the default POST header.
+ * @public
+ * @param boolean b Use default header - true or false .
+ * @return void
+ */
+ setDefaultPostHeader:function(b)
+ {
+ YAHOO.log('Default POST header set to ' + b, 'info', 'Connection');
+ this._default_post_header = b;
+ },
+
+ /**
+ * Member to modify the default polling interval.
+ * @public
+ * @param {int} i The polling interval in milliseconds.
+ * @return void
+ */
+ setPollingInterval:function(i)
+ {
+ if(typeof i == 'number' && isFinite(i)){
+ this._polling_interval = i;
+ YAHOO.log('Default polling interval set to ' + i, 'info', 'Connection');
+ }
+ },
+
+ /**
+ * Instantiates a XMLHttpRequest object and returns an object with two properties:
+ * the XMLHttpRequest instance and the transaction id.
+ * @private
+ * @param {int} transactionId Property containing the transaction id for this transaction.
+ * @return connection object
+ */
+ createXhrObject:function(transactionId)
+ {
+ var obj,http;
+ try
+ {
+ // Instantiates XMLHttpRequest in non-IE browsers and assigns to http.
+ http = new XMLHttpRequest();
+ // Object literal with http and tId properties
+ obj = { conn:http, tId:transactionId };
+ YAHOO.log('XHR object created for transaction ' + transactionId, 'info', 'Connection');
+ }
+ catch(e)
+ {
+ for(var i=0; i<this._msxml_progid.length; ++i){
+ try
+ {
+ // Instantiates XMLHttpRequest for IE and assign to http.
+ http = new ActiveXObject(this._msxml_progid[i]);
+ // Object literal with http and tId properties
+ obj = { conn:http, tId:transactionId };
+ YAHOO.log('ActiveX XHR object created for transaction ' + transactionId, 'info', 'Connection');
+ break;
+ }
+ catch(e){}
+ }
+ }
+ finally
+ {
+ return obj;
+ }
+ },
+
+ /**
+ * This method is called by asyncRequest to create a
+ * valid connection object for the transaction. It also passes a
+ * transaction id and increments the transaction id counter.
+ * @private
+ * @return object
+ */
+ getConnectionObject:function()
+ {
+ var o;
+ var tId = this._transaction_id;
+
+ try
+ {
+ o = this.createXhrObject(tId);
+ if(o){
+ this._transaction_id++;
+ }
+ }
+ catch(e){}
+ finally
+ {
+ return o;
+ }
+ },
+
+ /**
+ * Method for initiating an asynchronous request via the XHR object.
+ * @public
+ * @param {string} method HTTP transaction method
+ * @param {string} uri Fully qualified path of resource
+ * @param callback User-defined callback function or object
+ * @param {string} postData POST body
+ * @return {object} Returns the connection object
+ */
+ asyncRequest:function(method, uri, callback, postData)
+ {
+ var o = this.getConnectionObject();
+
+ if(!o){
+ YAHOO.log('Unable to create connection object.', 'error', 'Connection');
+ return null;
+ }
+ else{
+ if(this._isFormSubmit){
+ if(this._isFileUpload){
+ this.uploadFile(o.tId, callback, uri);
+ this.releaseObject(o);
+ return;
+ }
+
+ //If the specified HTTP method is GET, setForm() will return an
+ //encoded string that is concatenated to the uri to
+ //create a querystring.
+ if(method == 'GET'){
+ uri += "?" + this._sFormData;
+ }
+ else if(method == 'POST'){
+ postData = this._sFormData;
+ }
+ this._sFormData = '';
+ }
+
+ o.conn.open(method, uri, true);
+
+ if(this._isFormSubmit || (postData && this._default_post_header)){
+ this.initHeader('Content-Type','application/x-www-form-urlencoded');
+ YAHOO.log('Initialize default header Content-Type to application/x-www-form-urlencoded.', 'info', 'Connection');
+ if(this._isFormSubmit){
+ this._isFormSubmit = false;
+ }
+ }
+
+ //Verify whether the transaction has any user-defined HTTP headers
+ //and set them.
+ if(this._has_http_headers){
+ this.setHeader(o);
+ }
+
+ this.handleReadyState(o, callback);
+ postData?o.conn.send(postData):o.conn.send(null);
+
+ return o;
+ }
+ },
+
+ /**
+ * This method serves as a timer that polls the XHR object's readyState
+ * property during a transaction, instead of binding a callback to the
+ * onreadystatechange event. Upon readyState 4, handleTransactionResponse
+ * will process the response, and the timer will be cleared.
+ *
+ * @private
+ * @param {object} o The connection object
+ * @param callback User-defined callback object
+ * @return void
+ */
+ handleReadyState:function(o, callback)
+ {
+ var timeOut = callback.timeout;
+ var oConn = this;
+
+ try
+ {
+ if(timeOut !== undefined){
+ this._timeOut[o.tId] = window.setTimeout(function(){ oConn.abort(o, callback, true) }, timeOut);
+ }
+ this._poll[o.tId] = window.setInterval(
+ function(){
+ if(o.conn && o.conn.readyState == 4){
+ window.clearInterval(oConn._poll[o.tId]);
+ oConn._poll.splice(o.tId);
+ if(timeOut){
+ oConn._timeOut.splice(o.tId);
+ }
+
+ oConn.handleTransactionResponse(o, callback);
+ }
+ }
+ ,this._polling_interval);
+ }
+ catch(e)
+ {
+ window.clearInterval(oConn._poll[o.tId]);
+ oConn._poll.splice(o.tId);
+ if(timeOut){
+ oConn._timeOut.splice(o.tId);
+ }
+
+ oConn.handleTransactionResponse(o, callback);
+ }
+ },
+
+ /**
+ * This method attempts to interpret the server response and
+ * determine whether the transaction was successful, or if an error or
+ * exception was encountered.
+ *
+ * @private
+ * @param {object} o The connection object
+ * @param {object} callback - User-defined callback object
+ * @param {boolean} determines if the transaction was aborted.
+ * @return void
+ */
+ handleTransactionResponse:function(o, callback, isAbort)
+ {
+ // If no valid callback is provided, then do not process any callback handling.
+ if(!callback){
+ this.releaseObject(o);
+ YAHOO.log('No callback object to process. Transaction complete.', 'warn', 'Connection');
+ return;
+ }
+
+ var httpStatus, responseObject;
+
+ try
+ {
+ if(o.conn.status !== undefined && o.conn.status != 0){
+ httpStatus = o.conn.status;
+ }
+ else{
+ httpStatus = 13030;
+ }
+ }
+ catch(e){
+ // 13030 is the custom code to indicate the condition -- in Mozilla/FF --
+ // when the o object's status and statusText properties are
+ // unavailable, and a query attempt throws an exception.
+ httpStatus = 13030;
+ }
+
+ if(httpStatus >= 200 && httpStatus < 300){
+ responseObject = this.createResponseObject(o, callback.argument);
+ if(callback.success){
+ if(!callback.scope){
+ callback.success(responseObject);
+ YAHOO.log('Success callback. HTTP code is ' + httpStatus, 'info', 'Connection');
+ }
+ else{
+ // If a scope property is defined, the callback will be fired from
+ // the context of the object.
+ callback.success.apply(callback.scope, [responseObject]);
+ YAHOO.log('Success callback with scope. HTTP code is ' + httpStatus, 'info', 'Connection');
+ }
+ }
+ }
+ else{
+ switch(httpStatus){
+ // The following case labels are wininet.dll error codes that may be encountered.
+ // Server timeout
+ case 12002:
+ // 12029 to 12031 correspond to dropped connections.
+ case 12029:
+ case 12030:
+ case 12031:
+ // Connection closed by server.
+ case 12152:
+ // See above comments for variable status.
+ case 13030:
+ responseObject = this.createExceptionObject(o.tId, callback.argument, isAbort);
+ if(callback.failure){
+ if(!callback.scope){
+ callback.failure(responseObject);
+ YAHOO.log('Failure callback. Exception detected. Status code is ' + httpStatus, 'warn', 'Connection');
+ }
+ else{
+ callback.failure.apply(callback.scope,[responseObject]);
+ YAHOO.log('Failure callback with scope. Exception detected. Status code is ' + httpStatus, 'warn', 'Connection');
+ }
+ }
+ break;
+ default:
+ responseObject = this.createResponseObject(o, callback.argument);
+ if(callback.failure){
+ if(!callback.scope){
+ callback.failure(responseObject);
+ YAHOO.log('Failure callback. HTTP status code is ' + httpStatus, 'warn', 'Connection');
+ }
+ else{
+ callback.failure.apply(callback.scope,[responseObject]);
+ YAHOO.log('Failure callback with scope. HTTP status code is ' + httpStatus, 'warn', 'Connection');
+ }
+ }
+ }
+ }
+
+ this.releaseObject(o);
+ },
+
+ /**
+ * This method evaluates the server response, creates and returns the results via
+ * its properties. Success and failure cases will differ in the response
+ * object's property values.
+ * @private
+ * @param {object} o The connection object
+ * @param {} callbackArg User-defined argument or arguments to be passed to the callback
+ * @return object
+ */
+ createResponseObject:function(o, callbackArg)
+ {
+ var obj = {};
+ var headerObj = {};
+
+ try
+ {
+ var headerStr = o.conn.getAllResponseHeaders();
+ var header = headerStr.split('\n');
+ for(var i=0; i < header.length; i++){
+ var delimitPos = header[i].indexOf(':');
+ if(delimitPos != -1){
+ headerObj[header[i].substring(0,delimitPos)] = header[i].substring(delimitPos + 2);
+ }
+ }
+ }
+ catch(e){}
+
+ obj.tId = o.tId;
+ obj.status = o.conn.status;
+ obj.statusText = o.conn.statusText;
+ obj.getResponseHeader = headerObj;
+ obj.getAllResponseHeaders = headerStr;
+ obj.responseText = o.conn.responseText;
+ obj.responseXML = o.conn.responseXML;
+
+ if(typeof callbackArg !== undefined){
+ obj.argument = callbackArg;
+ }
+
+ return obj;
+ },
+
+ /**
+ * If a transaction cannot be completed due to dropped or closed connections,
+ * there may be not be enough information to build a full response object.
+ * The failure callback will be fired and this specific condition can be identified
+ * by a status property value of 0.
+ *
+ * If an abort was successful, the status property will report a value of -1.
+ *
+ * @private
+ * @param {int} tId Transaction Id
+ * @param callbackArg The user-defined arguments
+ * @param isAbort Determines if the exception is an abort.
+ * @return object
+ */
+ createExceptionObject:function(tId, callbackArg, isAbort)
+ {
+ var COMM_CODE = 0;
+ var COMM_ERROR = 'communication failure';
+ var ABORT_CODE = -1;
+ var ABORT_ERROR = 'transaction aborted';
+
+ var obj = {};
+
+ obj.tId = tId;
+ if(isAbort){
+ obj.status = ABORT_CODE;
+ obj.statusText = ABORT_ERROR;
+ }
+ else{
+ obj.status = COMM_CODE;
+ obj.statusText = COMM_ERROR;
+ }
+
+ if(callbackArg){
+ obj.argument = callbackArg;
+ }
+
+ return obj;
+ },
+
+ /**
+ * Public method that stores the custom HTTP headers for each transaction.
+ * @public
+ * @param {string} label The HTTP header label
+ * @param {string} value The HTTP header value
+ * @return void
+ */
+ initHeader:function(label,value)
+ {
+ if(this._http_header[label] === undefined){
+ this._http_header[label] = value;
+ }
+ else{
+ this._http_header[label] = value + "," + this._http_header[label];
+ }
+
+ this._has_http_headers = true;
+ },
+
+ /**
+ * Accessor that sets the HTTP headers for each transaction.
+ * @private
+ * @param {object} o The connection object for the transaction.
+ * @return void
+ */
+ setHeader:function(o)
+ {
+ for(var prop in this._http_header){
+ if(this._http_header.propertyIsEnumerable){
+ o.conn.setRequestHeader(prop, this._http_header[prop]);
+ YAHOO.log('HTTP header ' + prop + ' set with value of ' + this._http_header[prop], 'info', 'Connection');
+ }
+ }
+ delete this._http_header;
+
+ this._http_header = {};
+ this._has_http_headers = false;
+ },
+
+ /**
+ * This method assembles the form label and value pairs and
+ * constructs an encoded string.
+ * asyncRequest() will automatically initialize the
+ * transaction with a HTTP header Content-Type of
+ * application/x-www-form-urlencoded.
+ * @public
+ * @param {string || object} form id or name attribute, or form object.
+ * @param {string} optional boolean to indicate SSL environment.
+ * @param {string} optional qualified path of iframe resource for SSL in IE.
+ * @return void
+ */
+ setForm:function(formId, isUpload, secureUri)
+ {
+ this._sFormData = '';
+ if(typeof formId == 'string'){
+ // Determine if the argument is a form id or a form name.
+ // Note form name usage is deprecated by supported
+ // here for legacy reasons.
+ var oForm = (document.getElementById(formId) || document.forms[formId]);
+ }
+ else if(typeof formId == 'object'){
+ var oForm = formId;
+ }
+ else{
+ YAHOO.log('Unable to create form object ' + formId, 'warn', 'Connection');
+ return;
+ }
+
+ // If the isUpload argument is true, setForm will call createFrame to initialize
+ // an iframe as the form target.
+ //
+ // The argument secureURI is also required by IE in SSL environments
+ // where the secureURI string is a fully qualified HTTP path, used to set the source
+ // of the iframe, to a stub resource in the same domain.
+ if(isUpload){
+ (typeof secureUri == 'string')?this.createFrame(secureUri):this.createFrame();
+ this._isFormSubmit = true;
+ this._isFileUpload = true;
+ this._formNode = oForm;
+
+ return;
+ }
+
+ var oElement, oName, oValue, oDisabled;
+ var hasSubmit = false;
+
+ // Iterate over the form elements collection to construct the
+ // label-value pairs.
+ for (var i=0; i<oForm.elements.length; i++){
+ oDisabled = oForm.elements[i].disabled;
+
+ // If the name attribute is not populated, the form field's
+ // value will not be submitted.
+ oElement = oForm.elements[i];
+ oName = oForm.elements[i].name;
+ oValue = oForm.elements[i].value;
+
+ // Do not submit fields that are disabled or
+ // do not have a name attribute value.
+ if(!oDisabled && oName !== undefined)
+ {
+ switch (oElement.type)
+ {
+ case 'select-one':
+ case 'select-multiple':
+ for(var j=0; j<oElement.options.length; j++){
+ if(oElement.options[j].selected){
+ this._sFormData += encodeURIComponent(oName) + '=' + encodeURIComponent(oElement.options[j].value || oElement.options[j].text) + '&';
+ }
+ }
+ break;
+ case 'radio':
+ case 'checkbox':
+ if(oElement.checked){
+ this._sFormData += encodeURIComponent(oName) + '=' + encodeURIComponent(oValue) + '&';
+ }
+ break;
+ case 'file':
+ // stub case as XMLHttpRequest will only send the file path as a string.
+ case undefined:
+ // stub case for fieldset element which returns undefined.
+ case 'reset':
+ // stub case for input type reset button.
+ case 'button':
+ // stub case for input type button elements.
+ break;
+ case 'submit':
+ if(hasSubmit == false){
+ this._sFormData += encodeURIComponent(oName) + '=' + encodeURIComponent(oValue) + '&';
+ hasSubmit = true;
+ }
+ break;
+ default:
+ this._sFormData += encodeURIComponent(oName) + '=' + encodeURIComponent(oValue) + '&';
+ break;
+ }
+ }
+ }
+
+ this._isFormSubmit = true;
+ this._sFormData = this._sFormData.substr(0, this._sFormData.length - 1);
+
+ YAHOO.log('Form initialized for transaction. POST message is: ' + this._sFormData, 'info', 'Connection');
+ },
+
+ /**
+ * Creates an iframe to be used for form file uploads. It is remove from the
+ * document upon completion of the upload transaction.
+ *
+ * @private
+ * @param {string} optional qualified path of iframe resource for SSL in IE.
+ * @return void
+ */
+ createFrame:function(secureUri){
+
+ // IE does not allow the setting of id and name attributes as DOM
+ // properties. A different iframe creation pattern is required for IE.
+ if(window.ActiveXObject){
+ var io = document.createElement('<IFRAME name="ioFrame" id="ioFrame">');
+ if(secureUri){
+ // IE will throw a security exception in an SSL environment if the
+ // iframe source isn't set to a valid resource.
+ io.src = secureUri;
+ }
+ }
+ else{
+ var io = document.createElement('IFRAME');
+ io.id = 'ioFrame';
+ io.name = 'ioFrame';
+ }
+
+ io.style.position = 'absolute';
+ io.style.top = '-1000px';
+ io.style.left = '-1000px';
+
+ document.body.appendChild(io);
+ },
+
+ /**
+ * Uploads HTML form, including files/attachments, targeting the
+ * iframe created in createFrame.
+ *
+ * @private
+ * @param {int} id The transaction id.
+ * @param {object} callback - User-defined callback object.
+ * @param {string} uri Fully qualified path of resource.
+ * @return void
+ */
+ uploadFile:function(id, callback, uri){
+ // Initialize the HTML form properties in case they are
+ // not defined in the HTML form.
+ this._formNode.action = uri;
+ this._formNode.enctype = 'multipart/form-data';
+ this._formNode.method = 'POST';
+ this._formNode.target = 'ioFrame';
+ this._formNode.submit();
+
+ // Reset form status properties.
+ this._formNode = null;
+ this._isFileUpload = false;
+ this._isFormSubmit = false;
+
+ // Create the upload callback handler that fires when the iframe
+ // receives the load event. Subsequently, the event handler is detached
+ // and the iframe removed from the document.
+
+ var uploadCallback = function()
+ {
+ var oResponse =
+ {
+ tId: id,
+ responseText: document.getElementById("ioFrame").contentWindow.document.body.innerHTML,
+ argument: callback.argument
+ }
+
+ if(callback.upload){
+ if(!callback.scope){
+ callback.upload(oResponse);
+ YAHOO.log('Upload callback.', 'info', 'Connection');
+ }
+ else{
+ callback.upload.apply(callback.scope, [oResponse]);
+ YAHOO.log('Upload callback with object scope.', 'info', 'Connection');
+ }
+ }
+
+ YAHOO.util.Event.removeListener("ioFrame", "load", uploadCallback);
+ window.ioFrame.location.replace('#');
+ setTimeout("document.body.removeChild(document.getElementById('ioFrame'))",100);
+ };
+
+ // Bind the onload handler to the iframe to detect the file upload response.
+ YAHOO.util.Event.addListener("ioFrame", "load", uploadCallback);
+ },
+
+ /**
+ * Public method to terminate a transaction, if it has not reached readyState 4.
+ * @public
+ * @param {object} o The connection object returned by asyncRequest.
+ * @param {object} callback User-defined callback object.
+ * @param {string} isTimeout boolean to indicate if abort was a timeout.
+ * @return void
+ */
+ abort:function(o, callback, isTimeout)
+ {
+ if(this.isCallInProgress(o)){
+ window.clearInterval(this._poll[o.tId]);
+ this._poll.splice(o.tId);
+ if(isTimeout){
+ this._timeOut.splice(o.tId);
+ }
+ o.conn.abort();
+
+ this.handleTransactionResponse(o, callback, true);
+ YAHOO.log('Transaction ' + o.tId + ' aborted.', 'info', 'Connection');
+
+ return true;
+ }
+ else{
+ YAHOO.log('Transaction ' + o.tId + ' abort failed.', 'warn', 'Connection');
+
+ return false;
+ }
+ },
+
+ /**
+ * Public method to check if the transaction is still being processed.
+ * @public
+ * @param {object} o The connection object returned by asyncRequest
+ * @return boolean
+ */
+ isCallInProgress:function(o)
+ {
+ // if the XHR object assigned to the transaction has not been dereferenced,
+ // then check its readyState status. Otherwise, return false.
+ if(o.conn){
+ return o.conn.readyState != 4 && o.conn.readyState != 0;
+ }
+ else{
+ //The XHR object has been destroyed.
+ return false;
+ }
+ },
+
+ /**
+ * Dereference the XHR instance and the connection object after the transaction is completed.
+ * @private
+ * @param {object} o The connection object
+ * @return void
+ */
+ releaseObject:function(o)
+ {
+ //dereference the XHR instance.
+ o.conn = null;
+
+ YAHOO.log('Connection object for transaction ' + o.tId + ' destroyed.', 'info', 'Connection');
+
+ //dereference the connection object.
+ o = null;
+ }
+};
Added: branches/tomek/portal-dnd/dndRenderer.war/js/connection/connection-min.js
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/connection/connection-min.js 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/connection/connection-min.js 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,87 @@
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 0.11.1
+*/
+YAHOO.util.Connect={_msxml_progid:['MSXML2.XMLHTTP.3.0','MSXML2.XMLHTTP','Microsoft.XMLHTTP'],_http_header:{},_has_http_headers:false,_default_post_header:true,_isFormSubmit:false,_isFileUpload:false,_formNode:null,_sFormData:null,_poll:[],_timeOut:[],_polling_interval:50,_transaction_id:0,setProgId:function(id)
+{this._msxml_progid.unshift(id);},setDefaultPostHeader:function(b)
+{this._default_post_header=b;},setPollingInterval:function(i)
+{if(typeof i=='number'&&isFinite(i)){this._polling_interval=i;}},createXhrObject:function(transactionId)
+{var obj,http;try
+{http=new XMLHttpRequest();obj={conn:http,tId:transactionId};}
+catch(e)
+{for(var i=0;i<this._msxml_progid.length;++i){try
+{http=new ActiveXObject(this._msxml_progid[i]);obj={conn:http,tId:transactionId};break;}
+catch(e){}}}
+finally
+{return obj;}},getConnectionObject:function()
+{var o;var tId=this._transaction_id;try
+{o=this.createXhrObject(tId);if(o){this._transaction_id++;}}
+catch(e){}
+finally
+{return o;}},asyncRequest:function(method,uri,callback,postData)
+{var o=this.getConnectionObject();if(!o){return null;}
+else{if(this._isFormSubmit){if(this._isFileUpload){this.uploadFile(o.tId,callback,uri);this.releaseObject(o);return;}
+if(method=='GET'){uri+="?"+this._sFormData;}
+else if(method=='POST'){postData=this._sFormData;}
+this._sFormData='';}
+o.conn.open(method,uri,true);if(this._isFormSubmit||(postData&&this._default_post_header)){this.initHeader('Content-Type','application/x-www-form-urlencoded');if(this._isFormSubmit){this._isFormSubmit=false;}}
+if(this._has_http_headers){this.setHeader(o);}
+this.handleReadyState(o,callback);postData?o.conn.send(postData):o.conn.send(null);return o;}},handleReadyState:function(o,callback)
+{var timeOut=callback.timeout;var oConn=this;try
+{if(timeOut!==undefined){this._timeOut[o.tId]=window.setTimeout(function(){oConn.abort(o,callback,true)},timeOut);}
+this._poll[o.tId]=window.setInterval(function(){if(o.conn&&o.conn.readyState==4){window.clearInterval(oConn._poll[o.tId]);oConn._poll.splice(o.tId);if(timeOut){oConn._timeOut.splice(o.tId);}
+oConn.handleTransactionResponse(o,callback);}},this._polling_interval);}
+catch(e)
+{window.clearInterval(oConn._poll[o.tId]);oConn._poll.splice(o.tId);if(timeOut){oConn._timeOut.splice(o.tId);}
+oConn.handleTransactionResponse(o,callback);}},handleTransactionResponse:function(o,callback,isAbort)
+{if(!callback){this.releaseObject(o);return;}
+var httpStatus,responseObject;try
+{if(o.conn.status!==undefined&&o.conn.status!=0){httpStatus=o.conn.status;}
+else{httpStatus=13030;}}
+catch(e){httpStatus=13030;}
+if(httpStatus>=200&&httpStatus<300){responseObject=this.createResponseObject(o,callback.argument);if(callback.success){if(!callback.scope){callback.success(responseObject);}
+else{callback.success.apply(callback.scope,[responseObject]);}}}
+else{switch(httpStatus){case 12002:case 12029:case 12030:case 12031:case 12152:case 13030:responseObject=this.createExceptionObject(o.tId,callback.argument,isAbort);if(callback.failure){if(!callback.scope){callback.failure(responseObject);}
+else{callback.failure.apply(callback.scope,[responseObject]);}}
+break;default:responseObject=this.createResponseObject(o,callback.argument);if(callback.failure){if(!callback.scope){callback.failure(responseObject);}
+else{callback.failure.apply(callback.scope,[responseObject]);}}}}
+this.releaseObject(o);},createResponseObject:function(o,callbackArg)
+{var obj={};var headerObj={};try
+{var headerStr=o.conn.getAllResponseHeaders();var header=headerStr.split('\n');for(var i=0;i<header.length;i++){var delimitPos=header[i].indexOf(':');if(delimitPos!=-1){headerObj[header[i].substring(0,delimitPos)]=header[i].substring(delimitPos+2);}}}
+catch(e){}
+obj.tId=o.tId;obj.status=o.conn.status;obj.statusText=o.conn.statusText;obj.getResponseHeader=headerObj;obj.getAllResponseHeaders=headerStr;obj.responseText=o.conn.responseText;obj.responseXML=o.conn.responseXML;if(typeof callbackArg!==undefined){obj.argument=callbackArg;}
+return obj;},createExceptionObject:function(tId,callbackArg,isAbort)
+{var COMM_CODE=0;var COMM_ERROR='communication failure';var ABORT_CODE=-1;var ABORT_ERROR='transaction aborted';var obj={};obj.tId=tId;if(isAbort){obj.status=ABORT_CODE;obj.statusText=ABORT_ERROR;}
+else{obj.status=COMM_CODE;obj.statusText=COMM_ERROR;}
+if(callbackArg){obj.argument=callbackArg;}
+return obj;},initHeader:function(label,value)
+{if(this._http_header[label]===undefined){this._http_header[label]=value;}
+else{this._http_header[label]=value+","+this._http_header[label];}
+this._has_http_headers=true;},setHeader:function(o)
+{for(var prop in this._http_header){if(this._http_header.propertyIsEnumerable){o.conn.setRequestHeader(prop,this._http_header[prop]);}}
+delete this._http_header;this._http_header={};this._has_http_headers=false;},setForm:function(formId,isUpload,secureUri)
+{this._sFormData='';if(typeof formId=='string'){var oForm=(document.getElementById(formId)||document.forms[formId]);}
+else if(typeof formId=='object'){var oForm=formId;}
+else{return;}
+if(isUpload){(typeof secureUri=='string')?this.createFrame(secureUri):this.createFrame();this._isFormSubmit=true;this._isFileUpload=true;this._formNode=oForm;return;}
+var oElement,oName,oValue,oDisabled;var hasSubmit=false;for(var i=0;i<oForm.elements.length;i++){oDisabled=oForm.elements[i].disabled;oElement=oForm.elements[i];oName=oForm.elements[i].name;oValue=oForm.elements[i].value;if(!oDisabled&&oName)
+{switch(oElement.type)
+{case'select-one':case'select-multiple':for(var j=0;j<oElement.options.length;j++){if(oElement.options[j].selected){this._sFormData+=encodeURIComponent(oName)+'='+encodeURIComponent(oElement.options[j].value||oElement.options[j].text)+'&';}}
+break;case'radio':case'checkbox':if(oElement.checked){this._sFormData+=encodeURIComponent(oName)+'='+encodeURIComponent(oValue)+'&';}
+break;case'file':case undefined:case'reset':case'button':break;case'submit':if(hasSubmit==false){this._sFormData+=encodeURIComponent(oName)+'='+encodeURIComponent(oValue)+'&';hasSubmit=true;}
+break;default:this._sFormData+=encodeURIComponent(oName)+'='+encodeURIComponent(oValue)+'&';break;}}}
+this._isFormSubmit=true;this._sFormData=this._sFormData.substr(0,this._sFormData.length-1);},createFrame:function(secureUri){if(window.ActiveXObject){var io=document.createElement('<IFRAME name="ioFrame" id="ioFrame">');if(secureUri){io.src=secureUri;}}
+else{var io=document.createElement('IFRAME');io.id='ioFrame';io.name='ioFrame';}
+io.style.position='absolute';io.style.top='-1000px';io.style.left='-1000px';document.body.appendChild(io);},uploadFile:function(id,callback,uri){this._formNode.action=uri;this._formNode.enctype='multipart/form-data';this._formNode.method='POST';this._formNode.target='ioFrame';this._formNode.submit();this._formNode=null;this._isFileUpload=false;this._isFormSubmit=false;var uploadCallback=function()
+{var oResponse={tId:id,responseText:document.getElementById("ioFrame").contentWindow.document.body.innerHTML,argument:callback.argument}
+if(callback.upload){if(!callback.scope){callback.upload(oResponse);}
+else{callback.upload.apply(callback.scope,[oResponse]);}}
+YAHOO.util.Event.removeListener("ioFrame","load",uploadCallback);window.ioFrame.location.replace('#');setTimeout("document.body.removeChild(document.getElementById('ioFrame'))",100);};YAHOO.util.Event.addListener("ioFrame","load",uploadCallback);},abort:function(o,callback,isTimeout)
+{if(this.isCallInProgress(o)){window.clearInterval(this._poll[o.tId]);this._poll.splice(o.tId);if(isTimeout){this._timeOut.splice(o.tId);}
+o.conn.abort();this.handleTransactionResponse(o,callback,true);return true;}
+else{return false;}},isCallInProgress:function(o)
+{if(o.conn){return o.conn.readyState!=4&&o.conn.readyState!=0;}
+else{return false;}},releaseObject:function(o)
+{o.conn=null;o=null;}};
Added: branches/tomek/portal-dnd/dndRenderer.war/js/connection/connection.js
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/connection/connection.js 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/connection/connection.js 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,835 @@
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 0.11.1
+*/
+
+/**
+ * The Connection Manager provides a simplified interface to the XMLHttpRequest
+ * object. It handles cross-browser instantiantion of XMLHttpRequest, negotiates the
+ * interactive states and server response, returning the results to a pre-defined
+ * callback you create.
+ * @ class
+ */
+YAHOO.util.Connect =
+{
+/**
+ * Array of MSFT ActiveX ids for XMLHttpRequest.
+ * @private
+ * @type array
+ */
+ _msxml_progid:[
+ 'MSXML2.XMLHTTP.3.0',
+ 'MSXML2.XMLHTTP',
+ 'Microsoft.XMLHTTP'
+ ],
+
+ /**
+ * Object literal of HTTP header(s)
+ * @private
+ * @type object
+ */
+ _http_header:{},
+
+ /**
+ * Determines if HTTP headers are set.
+ * @private
+ * @type boolean
+ */
+ _has_http_headers:false,
+
+ /**
+ * Determines if a default header of
+ * Content-Type of 'application/x-www-form-urlencoded'
+ * will be added to any client HTTP headers sent for POST
+ * transactions.
+ * @private
+ * @type boolean
+ */
+ _default_post_header:true,
+
+ /**
+ * Property modified by setForm() to determine if the data
+ * should be submitted as an HTML form.
+ * @private
+ * @type boolean
+ */
+ _isFormSubmit:false,
+
+ /**
+ * Property modified by setForm() to determine if a file(s)
+ * upload is expected.
+ * @private
+ * @type boolean
+ */
+ _isFileUpload:false,
+
+ /**
+ * Property modified by setForm() to set a reference to the HTML
+ * form node if the desired action is file upload.
+ * @private
+ * @type object
+ */
+ _formNode:null,
+
+ /**
+ * Property modified by setForm() to set the HTML form data
+ * for each transaction.
+ * @private
+ * @type string
+ */
+ _sFormData:null,
+
+ /**
+ * Collection of polling references to the polling mechanism in handleReadyState.
+ * @private
+ * @type string
+ */
+ _poll:[],
+
+ /**
+ * Queue of timeout values for each transaction callback with a defined timeout value.
+ * @private
+ * @type string
+ */
+ _timeOut:[],
+
+ /**
+ * The polling frequency, in milliseconds, for HandleReadyState.
+ * when attempting to determine a transaction's XHR readyState.
+ * The default is 50 milliseconds.
+ * @private
+ * @type int
+ */
+ _polling_interval:50,
+
+ /**
+ * A transaction counter that increments the transaction id for each transaction.
+ * @private
+ * @type int
+ */
+ _transaction_id:0,
+
+ /**
+ * Member to add an ActiveX id to the existing xml_progid array.
+ * In the event(unlikely) a new ActiveX id is introduced, it can be added
+ * without internal code modifications.
+ * @public
+ * @param string id The ActiveX id to be added to initialize the XHR object.
+ * @return void
+ */
+ setProgId:function(id)
+ {
+ this._msxml_progid.unshift(id);
+ },
+
+ /**
+ * Member to enable or disable the default POST header.
+ * @public
+ * @param boolean b Set and use default header - true or false .
+ * @return void
+ */
+ setDefaultPostHeader:function(b)
+ {
+ this._default_post_header = b;
+ },
+
+ /**
+ * Member to modify the default polling interval.
+ * @public
+ * @param {int} i The polling interval in milliseconds.
+ * @return void
+ */
+ setPollingInterval:function(i)
+ {
+ if(typeof i == 'number' && isFinite(i)){
+ this._polling_interval = i;
+ }
+ },
+
+ /**
+ * Instantiates a XMLHttpRequest object and returns an object with two properties:
+ * the XMLHttpRequest instance and the transaction id.
+ * @private
+ * @param {int} transactionId Property containing the transaction id for this transaction.
+ * @return connection object
+ */
+ createXhrObject:function(transactionId)
+ {
+ var obj,http;
+ try
+ {
+ // Instantiates XMLHttpRequest in non-IE browsers and assigns to http.
+ http = new XMLHttpRequest();
+ // Object literal with http and tId properties
+ obj = { conn:http, tId:transactionId };
+ }
+ catch(e)
+ {
+ for(var i=0; i<this._msxml_progid.length; ++i){
+ try
+ {
+ // Instantiates XMLHttpRequest for IE and assign to http.
+ http = new ActiveXObject(this._msxml_progid[i]);
+ // Object literal with http and tId properties
+ obj = { conn:http, tId:transactionId };
+ break;
+ }
+ catch(e){}
+ }
+ }
+ finally
+ {
+ return obj;
+ }
+ },
+
+ /**
+ * This method is called by asyncRequest to create a
+ * valid connection object for the transaction. It also passes a
+ * transaction id and increments the transaction id counter.
+ * @private
+ * @return object
+ */
+ getConnectionObject:function()
+ {
+ var o;
+ var tId = this._transaction_id;
+
+ try
+ {
+ o = this.createXhrObject(tId);
+ if(o){
+ this._transaction_id++;
+ }
+ }
+ catch(e){}
+ finally
+ {
+ return o;
+ }
+ },
+
+ /**
+ * Method for initiating an asynchronous request via the XHR object.
+ * @public
+ * @param {string} method HTTP transaction method
+ * @param {string} uri Fully qualified path of resource
+ * @param callback User-defined callback function or object
+ * @param {string} postData POST body
+ * @return {object} Returns the connection object
+ */
+ asyncRequest:function(method, uri, callback, postData)
+ {
+ var o = this.getConnectionObject();
+
+ if(!o){
+ return null;
+ }
+ else{
+ if(this._isFormSubmit){
+ if(this._isFileUpload){
+ this.uploadFile(o.tId, callback, uri);
+ this.releaseObject(o);
+ return;
+ }
+
+ //If the specified HTTP method is GET, setForm() will return an
+ //encoded string that is concatenated to the uri to
+ //create a querystring.
+ if(method == 'GET'){
+ uri += "?" + this._sFormData;
+ }
+ else if(method == 'POST'){
+ postData = this._sFormData;
+ }
+ this._sFormData = '';
+ }
+
+ o.conn.open(method, uri, true);
+
+ if(this._isFormSubmit || (postData && this._default_post_header)){
+ this.initHeader('Content-Type','application/x-www-form-urlencoded');
+ if(this._isFormSubmit){
+ this._isFormSubmit = false;
+ }
+ }
+
+ //Verify whether the transaction has any user-defined HTTP headers
+ //and set them.
+ if(this._has_http_headers){
+ this.setHeader(o);
+ }
+
+ this.handleReadyState(o, callback);
+ postData?o.conn.send(postData):o.conn.send(null);
+
+ return o;
+ }
+ },
+
+ /**
+ * Method for initiating an synchronous request via the XHR object.
+ * @public
+ * @param {string} method HTTP transaction method
+ * @param {string} uri Fully qualified path of resource
+ * @param callback User-defined callback function or object
+ * @param {string} postData POST body
+ * @return {object} Returns the connection object
+ */
+ syncRequest:function(method, uri, callback, postData)
+ {
+ var o = this.getConnectionObject();
+
+ if(!o){
+ return null;
+ }
+ else{
+ if(this._isFormSubmit){
+ if(this._isFileUpload){
+ this.uploadFile(o.tId, callback, uri);
+ this.releaseObject(o);
+ return;
+ }
+
+ //If the specified HTTP method is GET, setForm() will return an
+ //encoded string that is concatenated to the uri to
+ //create a querystring.
+ if(method == 'GET'){
+ uri += "?" + this._sFormData;
+ }
+ else if(method == 'POST'){
+ postData = this._sFormData;
+ }
+ this._sFormData = '';
+ }
+
+ o.conn.open(method, uri, false);
+
+ if(this._isFormSubmit || (postData && this._default_post_header)){
+ this.initHeader('Content-Type','application/x-www-form-urlencoded');
+ if(this._isFormSubmit){
+ this._isFormSubmit = false;
+ }
+ }
+
+ //Verify whether the transaction has any user-defined HTTP headers
+ //and set them.
+ if(this._has_http_headers){
+ this.setHeader(o);
+ }
+
+ this.handleReadyState(o, callback);
+ postData?o.conn.send(postData):o.conn.send(null);
+
+ return o;
+ }
+ },
+
+ /**
+ * This method serves as a timer that polls the XHR object's readyState
+ * property during a transaction, instead of binding a callback to the
+ * onreadystatechange event. Upon readyState 4, handleTransactionResponse
+ * will process the response, and the timer will be cleared.
+ *
+ * @private
+ * @param {object} o The connection object
+ * @param callback User-defined callback object
+ * @return void
+ */
+ handleReadyState:function(o, callback)
+ {
+ var timeOut = callback.timeout;
+ var oConn = this;
+
+ try
+ {
+ if(timeOut !== undefined){
+ this._timeOut[o.tId] = window.setTimeout(function(){ oConn.abort(o, callback, true) }, timeOut);
+ }
+ this._poll[o.tId] = window.setInterval(
+ function(){
+ if(o.conn && o.conn.readyState == 4){
+ window.clearInterval(oConn._poll[o.tId]);
+ oConn._poll.splice(o.tId);
+ if(timeOut){
+ oConn._timeOut.splice(o.tId);
+ }
+
+ oConn.handleTransactionResponse(o, callback);
+ }
+ }
+ ,this._polling_interval);
+ }
+ catch(e)
+ {
+ window.clearInterval(oConn._poll[o.tId]);
+ oConn._poll.splice(o.tId);
+ if(timeOut){
+ oConn._timeOut.splice(o.tId);
+ }
+
+ oConn.handleTransactionResponse(o, callback);
+ }
+ },
+
+ /**
+ * This method attempts to interpret the server response and
+ * determine whether the transaction was successful, or if an error or
+ * exception was encountered.
+ *
+ * @private
+ * @param {object} o The connection object
+ * @param {object} callback - User-defined callback object
+ * @param {boolean} determines if the transaction was aborted.
+ * @return void
+ */
+ handleTransactionResponse:function(o, callback, isAbort)
+ {
+ // If no valid callback is provided, then do not process any callback handling.
+ if(!callback){
+ this.releaseObject(o);
+ return;
+ }
+
+ var httpStatus, responseObject;
+
+ try
+ {
+ if(o.conn.status !== undefined && o.conn.status != 0){
+ httpStatus = o.conn.status;
+ }
+ else{
+ httpStatus = 13030;
+ }
+ }
+ catch(e){
+ // 13030 is the custom code to indicate the condition -- in Mozilla/FF --
+ // when the o object's status and statusText properties are
+ // unavailable, and a query attempt throws an exception.
+ httpStatus = 13030;
+ }
+
+ if(httpStatus >= 200 && httpStatus < 300){
+ responseObject = this.createResponseObject(o, callback.argument);
+ if(callback.success){
+ if(!callback.scope){
+ callback.success(responseObject);
+ }
+ else{
+ // If a scope property is defined, the callback will be fired from
+ // the context of the object.
+ callback.success.apply(callback.scope, [responseObject]);
+ }
+ }
+ }
+ else{
+ switch(httpStatus){
+ // The following case labels are wininet.dll error codes that may be encountered.
+ // Server timeout
+ case 12002:
+ // 12029 to 12031 correspond to dropped connections.
+ case 12029:
+ case 12030:
+ case 12031:
+ // Connection closed by server.
+ case 12152:
+ // See above comments for variable status.
+ case 13030:
+ responseObject = this.createExceptionObject(o.tId, callback.argument, isAbort);
+ if(callback.failure){
+ if(!callback.scope){
+ callback.failure(responseObject);
+ }
+ else{
+ callback.failure.apply(callback.scope, [responseObject]);
+ }
+ }
+ break;
+ default:
+ responseObject = this.createResponseObject(o, callback.argument);
+ if(callback.failure){
+ if(!callback.scope){
+ callback.failure(responseObject);
+ }
+ else{
+ callback.failure.apply(callback.scope, [responseObject]);
+ }
+ }
+ }
+ }
+
+ this.releaseObject(o);
+ },
+
+ /**
+ * This method evaluates the server response, creates and returns the results via
+ * its properties. Success and failure cases will differ in the response
+ * object's property values.
+ * @private
+ * @param {object} o The connection object
+ * @param {} callbackArg User-defined argument or arguments to be passed to the callback
+ * @return object
+ */
+ createResponseObject:function(o, callbackArg)
+ {
+ var obj = {};
+ var headerObj = {};
+
+ try
+ {
+ var headerStr = o.conn.getAllResponseHeaders();
+ var header = headerStr.split('\n');
+ for(var i=0; i < header.length; i++){
+ var delimitPos = header[i].indexOf(':');
+ if(delimitPos != -1){
+ headerObj[header[i].substring(0,delimitPos)] = header[i].substring(delimitPos + 2);
+ }
+ }
+ }
+ catch(e){}
+
+ obj.tId = o.tId;
+ obj.status = o.conn.status;
+ obj.statusText = o.conn.statusText;
+ obj.getResponseHeader = headerObj;
+ obj.getAllResponseHeaders = headerStr;
+ obj.responseText = o.conn.responseText;
+ obj.responseXML = o.conn.responseXML;
+
+ if(typeof callbackArg !== undefined){
+ obj.argument = callbackArg;
+ }
+
+ return obj;
+ },
+
+ /**
+ * If a transaction cannot be completed due to dropped or closed connections,
+ * there may be not be enough information to build a full response object.
+ * The failure callback will be fired and this specific condition can be identified
+ * by a status property value of 0.
+ *
+ * If an abort was successful, the status property will report a value of -1.
+ *
+ * @private
+ * @param {int} tId Transaction Id
+ * @param callbackArg The user-defined arguments
+ * @param isAbort Determines if the exception is an abort.
+ * @return object
+ */
+ createExceptionObject:function(tId, callbackArg, isAbort)
+ {
+ var COMM_CODE = 0;
+ var COMM_ERROR = 'communication failure';
+ var ABORT_CODE = -1;
+ var ABORT_ERROR = 'transaction aborted';
+
+ var obj = {};
+
+ obj.tId = tId;
+ if(isAbort){
+ obj.status = ABORT_CODE;
+ obj.statusText = ABORT_ERROR;
+ }
+ else{
+ obj.status = COMM_CODE;
+ obj.statusText = COMM_ERROR;
+ }
+
+ if(callbackArg){
+ obj.argument = callbackArg;
+ }
+
+ return obj;
+ },
+
+ /**
+ * Public method that stores the custom HTTP headers for each transaction.
+ * @public
+ * @param {string} label The HTTP header label
+ * @param {string} value The HTTP header value
+ * @return void
+ */
+ initHeader:function(label,value)
+ {
+ if(this._http_header[label] === undefined){
+ this._http_header[label] = value;
+ }
+ else{
+ this._http_header[label] = value + "," + this._http_header[label];
+ }
+
+ this._has_http_headers = true;
+ },
+
+ /**
+ * Accessor that sets the HTTP headers for each transaction.
+ * @private
+ * @param {object} o The connection object for the transaction.
+ * @return void
+ */
+ setHeader:function(o)
+ {
+ for(var prop in this._http_header){
+ if(this._http_header.propertyIsEnumerable){
+ o.conn.setRequestHeader(prop, this._http_header[prop]);
+ }
+ }
+ delete this._http_header;
+
+ this._http_header = {};
+ this._has_http_headers = false;
+ },
+
+ /**
+ * This method assembles the form label and value pairs and
+ * constructs an encoded string.
+ * asyncRequest() will automatically initialize the
+ * transaction with a HTTP header Content-Type of
+ * application/x-www-form-urlencoded.
+ * @public
+ * @param {string || object} form id or name attribute, or form object.
+ * @param {string} optional boolean to indicate SSL environment.
+ * @param {string} optional qualified path of iframe resource for SSL in IE.
+ * @return void
+ */
+ setForm:function(formId, isUpload, secureUri)
+ {
+ this._sFormData = '';
+ if(typeof formId == 'string'){
+ // Determine if the argument is a form id or a form name.
+ // Note form name usage is deprecated by supported
+ // here for legacy reasons.
+ var oForm = (document.getElementById(formId) || document.forms[formId]);
+ }
+ else if(typeof formId == 'object'){
+ var oForm = formId;
+ }
+ else{
+ return;
+ }
+
+ // If the isUpload argument is true, setForm will call createFrame to initialize
+ // an iframe as the form target.
+ //
+ // The argument secureURI is also required by IE in SSL environments
+ // where the secureURI string is a fully qualified HTTP path, used to set the source
+ // of the iframe, to a stub resource in the same domain.
+ if(isUpload){
+ (typeof secureUri == 'string')?this.createFrame(secureUri):this.createFrame();
+ this._isFormSubmit = true;
+ this._isFileUpload = true;
+ this._formNode = oForm;
+
+ return;
+ }
+
+ var oElement, oName, oValue, oDisabled;
+ var hasSubmit = false;
+
+ // Iterate over the form elements collection to construct the
+ // label-value pairs.
+ for (var i=0; i<oForm.elements.length; i++){
+ oDisabled = oForm.elements[i].disabled;
+
+ // If the name attribute is not populated, the form field's
+ // value will not be submitted.
+ oElement = oForm.elements[i];
+ oName = oForm.elements[i].name;
+ oValue = oForm.elements[i].value;
+
+ // Do not submit fields that are disabled or
+ // do not have a name attribute value.
+ if(!oDisabled && oName)
+ {
+ switch (oElement.type)
+ {
+ case 'select-one':
+ case 'select-multiple':
+ for(var j=0; j<oElement.options.length; j++){
+ if(oElement.options[j].selected){
+ this._sFormData += encodeURIComponent(oName) + '=' + encodeURIComponent(oElement.options[j].value || oElement.options[j].text) + '&';
+ }
+ }
+ break;
+ case 'radio':
+ case 'checkbox':
+ if(oElement.checked){
+ this._sFormData += encodeURIComponent(oName) + '=' + encodeURIComponent(oValue) + '&';
+ }
+ break;
+ case 'file':
+ // stub case as XMLHttpRequest will only send the file path as a string.
+ case undefined:
+ // stub case for fieldset element which returns undefined.
+ case 'reset':
+ // stub case for input type reset button.
+ case 'button':
+ // stub case for input type button elements.
+ break;
+ case 'submit':
+ if(hasSubmit == false){
+ this._sFormData += encodeURIComponent(oName) + '=' + encodeURIComponent(oValue) + '&';
+ hasSubmit = true;
+ }
+ break;
+ default:
+ this._sFormData += encodeURIComponent(oName) + '=' + encodeURIComponent(oValue) + '&';
+ break;
+ }
+ }
+ }
+
+ this._isFormSubmit = true;
+ this._sFormData = this._sFormData.substr(0, this._sFormData.length - 1);
+ },
+
+ /**
+ * Creates an iframe to be used for form file uploads. It is remove from the
+ * document upon completion of the upload transaction.
+ *
+ * @private
+ * @param {string} optional qualified path of iframe resource for SSL in IE.
+ * @return void
+ */
+ createFrame:function(secureUri){
+
+ // IE does not allow the setting of id and name attributes as DOM
+ // properties. A different iframe creation pattern is required for IE.
+ if(window.ActiveXObject){
+ var io = document.createElement('<IFRAME name="ioFrame" id="ioFrame">');
+ if(secureUri){
+ // IE will throw a security exception in an SSL environment if the
+ // iframe source isn't set to a valid resource.
+ io.src = secureUri;
+ }
+ }
+ else{
+ var io = document.createElement('IFRAME');
+ io.id = 'ioFrame';
+ io.name = 'ioFrame';
+ }
+
+ io.style.position = 'absolute';
+ io.style.top = '-1000px';
+ io.style.left = '-1000px';
+
+ document.body.appendChild(io);
+ },
+
+ /**
+ * Uploads HTML form, including files/attachments, targeting the
+ * iframe created in createFrame.
+ *
+ * @private
+ * @param {int} id The transaction id.
+ * @param {object} callback - User-defined callback object.
+ * @param {string} uri Fully qualified path of resource.
+ * @return void
+ */
+ uploadFile:function(id, callback, uri){
+ // Initialize the HTML form properties in case they are
+ // not defined in the HTML form.
+ this._formNode.action = uri;
+ this._formNode.enctype = 'multipart/form-data';
+ this._formNode.method = 'POST';
+ this._formNode.target = 'ioFrame';
+ this._formNode.submit();
+
+ // Reset form status properties.
+ this._formNode = null;
+ this._isFileUpload = false;
+ this._isFormSubmit = false;
+
+ // Create the upload callback handler that fires when the iframe
+ // receives the load event. Subsequently, the event handler is detached
+ // and the iframe removed from the document.
+
+ var uploadCallback = function()
+ {
+ var oResponse =
+ {
+ tId: id,
+ responseText: document.getElementById("ioFrame").contentWindow.document.body.innerHTML,
+ argument: callback.argument
+ }
+
+ if(callback.upload){
+ if(!callback.scope){
+ callback.upload(oResponse);
+ }
+ else{
+ callback.upload.apply(callback.scope, [oResponse]);
+ }
+ }
+
+ YAHOO.util.Event.removeListener("ioFrame", "load", uploadCallback);
+ window.ioFrame.location.replace('#');
+ setTimeout("document.body.removeChild(document.getElementById('ioFrame'))",100);
+ };
+
+ // Bind the onload handler to the iframe to detect the file upload response.
+ YAHOO.util.Event.addListener("ioFrame", "load", uploadCallback);
+ },
+
+ /**
+ * Public method to terminate a transaction, if it has not reached readyState 4.
+ * @public
+ * @param {object} o The connection object returned by asyncRequest.
+ * @param {object} callback User-defined callback object.
+ * @param {string} isTimeout boolean to indicate if abort was a timeout.
+ * @return void
+ */
+ abort:function(o, callback, isTimeout)
+ {
+ if(this.isCallInProgress(o)){
+ window.clearInterval(this._poll[o.tId]);
+ this._poll.splice(o.tId);
+ if(isTimeout){
+ this._timeOut.splice(o.tId);
+ }
+ o.conn.abort();
+ this.handleTransactionResponse(o, callback, true);
+
+ return true;
+ }
+ else{
+ return false;
+ }
+ },
+
+ /**
+ * Public method to check if the transaction is still being processed.
+ * @public
+ * @param {object} o The connection object returned by asyncRequest
+ * @return boolean
+ */
+ isCallInProgress:function(o)
+ {
+ // if the XHR object assigned to the transaction has not been dereferenced,
+ // then check its readyState status. Otherwise, return false.
+ if(o.conn){
+ return o.conn.readyState != 4 && o.conn.readyState != 0;
+ }
+ else{
+ //The XHR object has been destroyed.
+ return false;
+ }
+ },
+
+ /**
+ * Dereference the XHR instance and the connection object after the transaction is completed.
+ * @private
+ * @param {object} o The connection object
+ * @return void
+ */
+ releaseObject:function(o)
+ {
+ //dereference the XHR instance.
+ o.conn = null;
+ //dereference the connection object.
+ o = null;
+ }
+};
Added: branches/tomek/portal-dnd/dndRenderer.war/js/container/README
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/container/README 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/container/README 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,36 @@
+Container Release Notes
+
+*** version 0.11.1 ***
+
+ - Tooltip: Removed incorrect logger statement
+ - Dialog: Corrected logic that was causing browser lockup in IE for SimpleDialog
+ - Dialog: Fixed "firstButtom" typo
+
+*** version 0.11.0 ***
+
+ - toString function added to all classes for easy logging
+ - YAHOO.extend is now being used for inheritance on all container classes
+ - Module: monitorresize feature now works on all browsers
+ - Module: Fixed bug with image root and isSecure
+ - Overlay: Fixed bugs related to IFRAME shim positioning
+ - Overlay: center() now works in quirks mode
+ - Overlay: Overlay now has a custom destroy() method that also removes the IFRAME shim
+ - OverlayManager: Fixed bug in the prototype that was preventing multiple Managers on one page
+ - OverlayManager: focusEvent now fires at all appropriate times
+ - Tooltip: context can now be specified as an array, so Tooltips can be reused across multiple context elements
+ - Tooltip: preventoverlap now functions properly for large context elements (i.e, images)
+ - Tooltip: fixed bugs regarding setTimeout
+ - Tooltip: added mousemove event to allow for more accurate Tooltip positioning
+ - Panel: added dragEvent for monitoring all event handlers for drag and drop
+ - Panel: modality mask is now resized on scroll
+ - Panel: KeyListeners are now properly destroyed when the Panel is destroyed
+ - Panel: Header is now sized properly in quirks mode
+ - Dialog: Blinking cursor issue is fixed for Firefox
+ - Dialog: callback object for Connection is now public (this.callback)
+ - Dialog: onsuccess/onfailure properties removed (as a result of the public callback object)
+ - Dialog: Dialog is now invisible by default
+ - Dialog: Buttons are now properly cleaned up on destroy
+
+*** version 0.10.0 ***
+
+* Initial release
Added: branches/tomek/portal-dnd/dndRenderer.war/js/container/assets/alrt16_1.gif
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/dndRenderer.war/js/container/assets/alrt16_1.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/dndRenderer.war/js/container/assets/blck16_1.gif
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/dndRenderer.war/js/container/assets/blck16_1.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/dndRenderer.war/js/container/assets/close12_1.gif
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/dndRenderer.war/js/container/assets/close12_1.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/dndRenderer.war/js/container/assets/container.css
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/container/assets/container.css 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/container/assets/container.css 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,210 @@
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+Version 0.11.0
+*/
+
+.overlay {
+ position:absolute;
+ display:block;
+}
+
+.tt {
+ visibility:hidden;
+ position:absolute;
+ color:#333;
+ background-color:#FDFFB4;
+ font-family:arial,helvetica,verdana,sans-serif;
+ padding:2px;
+ border:1px solid #FCC90D;
+ font:100% sans-serif;
+ width:auto;
+}
+
+* html body.masked select {
+ visibility:hidden;
+}
+
+* html div.panel-container select {
+ visibility:inherit;
+}
+
+* html div.drag select {
+ visibility:hidden;
+}
+
+* html div.hide-select select {
+ visibility:hidden;
+}
+
+.mask {
+ z-index:0;
+ display:none;
+ position:absolute;
+ top:0;
+ left:0;
+ -moz-opacity: 0.5;
+ opacity:.50;
+ filter: alpha(opacity=50);
+ background-color:#CCC;
+}
+
+.hide-scrollbars * {
+ overflow:hidden;
+}
+
+.hide-scrollbars textarea, .hide-scrollbars select {
+ overflow:hidden;
+ display:none;
+}
+
+.show-scrollbars textarea, .show-scrollbars select {
+ overflow:visible;
+}
+
+.panel-container {
+ position:absolute;
+ background-color:transparent;
+ z-index:6;
+ visibility:hidden;
+ overflow:visible;
+ width:auto;
+}
+
+.panel-container.matte {
+ padding:3px;
+ background-color:#FFF;
+}
+
+.panel-container.matte .underlay {
+ display:none;
+}
+
+.panel-container.shadow {
+ padding:0px;
+ background-color:transparent;
+}
+
+.panel-container.shadow .underlay {
+ visibility:inherit;
+ position:absolute;
+ background-color:#CCC;
+ top:3px;left:3px;
+ z-index:0;
+ width:100%;
+ height:100%;
+ -moz-opacity: 0.7;
+ opacity:.70;
+ filter:alpha(opacity=70);
+}
+
+.panel {
+ visibility:hidden;
+ border-collapse:separate;
+ position:relative;
+ left:0px;top:0px;
+ font:1em Arial;
+ background-color:#FFF;
+ border:1px solid #000;
+ z-index:1;
+ overflow:auto;
+}
+
+.panel .hd {
+ background-color:#3d77cb;
+ color:#FFF;
+ font-size:100%;
+ line-height:100%;
+ border:1px solid #FFF;
+ border-bottom:1px solid #000;
+ font-weight:bold;
+ overflow:hidden;
+ padding:4px;
+}
+
+.panel .bd {
+ overflow:hidden;
+ padding:4px;
+}
+
+.panel .bd p {
+ margin:0 0 1em;
+}
+
+.panel .close {
+ position:absolute;
+ top:5px;
+ right:4px;
+ z-index:6;
+ height:12px;
+ width:12px;
+ margin:0px;
+ padding:0px;
+ background-repeat:no-repeat;
+ cursor:pointer;
+ visibility:inherit;
+}
+
+.panel .close.nonsecure {
+ background-image:url(http://us.i1.yimg.com/us.yimg.com/i/nt/ic/ut/alt3/close12_1.gif);
+}
+
+.panel .close.secure {
+ background-image:url(https://a248.e.akamai.net/sec.yimg.com/i/nt/ic/ut/alt3/close12_1.gif);
+}
+
+.panel .ft {
+ padding:4px;
+ overflow:hidden;
+}
+
+.simple-dialog .bd .icon {
+ background-repeat:no-repeat;
+ width:16px;
+ height:16px;
+ margin-right:10px;
+ float:left;
+}
+
+.dialog .ft, .simple-dialog .ft {
+ padding-bottom:5px;
+ padding-right:5px;
+ text-align:right;
+}
+
+.dialog form, .simple-dialog form {
+ margin:0;
+}
+
+.button-group button {
+ font:100 76% verdana;
+ text-decoration:none;
+ background-color: #E4E4E4;
+ color: #333;
+ cursor: hand;
+ vertical-align: middle;
+ border: 2px solid #797979;
+ border-top-color:#FFF;
+ border-left-color:#FFF;
+ margin:2px;
+ padding:2px;
+}
+
+.button-group button.default {
+ font-weight:bold;
+}
+
+.button-group button:hover, .button-group button.hover {
+ border:2px solid #90A029;
+ background-color:#EBF09E;
+ border-top-color:#FFF;
+ border-left-color:#FFF;
+}
+
+.button-group button:active {
+ border:2px solid #E4E4E4;
+ background-color:#BBB;
+ border-top-color:#333;
+ border-left-color:#333;
+}
Added: branches/tomek/portal-dnd/dndRenderer.war/js/container/assets/hlp16_1.gif
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/dndRenderer.war/js/container/assets/hlp16_1.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/dndRenderer.war/js/container/assets/info16_1.gif
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/dndRenderer.war/js/container/assets/info16_1.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/dndRenderer.war/js/container/assets/tip16_1.gif
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/dndRenderer.war/js/container/assets/tip16_1.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/dndRenderer.war/js/container/assets/warn16_1.gif
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/dndRenderer.war/js/container/assets/warn16_1.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/dndRenderer.war/js/container/container-debug.js
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/container/container-debug.js 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/container/container-debug.js 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,3964 @@
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+Version 0.11.1
+*/
+
+/**
+* @class
+* Config is a utility used within an object to allow the implementer to maintain a list of local configuration properties and listen for changes to those properties dynamically using CustomEvent. The initial values are also maintained so that the configuration can be reset at any given point to its initial state.
+* @param {object} owner The owner object to which this Config object belongs
+* @constructor
+*/
+YAHOO.util.Config = function(owner) {
+ if (owner) {
+ this.init(owner);
+ } else {
+ YAHOO.log("No owner specified for Config object", "error");
+ }
+}
+
+YAHOO.util.Config.prototype = {
+
+ /**
+ * Object reference to the owner of this Config object
+ * @type object
+ */
+ owner : null,
+
+ /**
+ * Object reference to the owner of this Config object
+ * args: key, value
+ * @type YAHOO.util.CustomEvent
+ */
+ configChangedEvent : null,
+
+ /**
+ * Boolean flag that specifies whether a queue is currently being executed
+ * @type boolean
+ */
+ queueInProgress : false,
+
+ /**
+ * Adds a property to the Config object's private config hash.
+ * @param {string} key The configuration property's name
+ * @param {object} propertyObject The object containing all of this property's arguments
+ */
+ addProperty : function(key, propertyObject){},
+
+ /**
+ * Returns a key-value configuration map of the values currently set in the Config object.
+ * @return {object} The current config, represented in a key-value map
+ */
+ getConfig : function(){},
+
+ /**
+ * Returns the value of specified property.
+ * @param {key} The name of the property
+ * @return {object} The value of the specified property
+ */
+ getProperty : function(key){},
+
+ /**
+ * Resets the specified property's value to its initial value.
+ * @param {key} The name of the property
+ */
+ resetProperty : function(key){},
+
+ /**
+ * Sets the value of a property. If the silent property is passed as true, the property's event will not be fired.
+ * @param {key} The name of the property
+ * @param {value} The value to set the property to
+ * @param {boolean} Whether the value should be set silently, without firing the property event.
+ * @return {boolean} true, if the set was successful, false if it failed.
+ */
+ setProperty : function(key,value,silent){},
+
+ /**
+ * Sets the value of a property and queues its event to execute. If the event is already scheduled to execute, it is
+ * moved from its current position to the end of the queue.
+ * @param {key} The name of the property
+ * @param {value} The value to set the property to
+ * @return {boolean} true, if the set was successful, false if it failed.
+ */
+ queueProperty : function(key,value){},
+
+ /**
+ * Fires the event for a property using the property's current value.
+ * @param {key} The name of the property
+ */
+ refireEvent : function(key){},
+
+ /**
+ * Applies a key-value object literal to the configuration, replacing any existing values, and queueing the property events.
+ * Although the values will be set, fireQueue() must be called for their associated events to execute.
+ * @param {object} userConfig The configuration object literal
+ * @param {boolean} init When set to true, the initialConfig will be set to the userConfig passed in, so that calling a reset will reset the properties to the passed values.
+ */
+ applyConfig : function(userConfig,init){},
+
+ /**
+ * Refires the events for all configuration properties using their current values.
+ */
+ refresh : function(){},
+
+ /**
+ * Fires the normalized list of queued property change events
+ */
+ fireQueue : function(){},
+
+ /**
+ * Subscribes an external handler to the change event for any given property.
+ * @param {string} key The property name
+ * @param {Function} handler The handler function to use subscribe to the property's event
+ * @param {object} obj The object to use for scoping the event handler (see CustomEvent documentation)
+ * @param {boolean} override Optional. If true, will override "this" within the handler to map to the scope object passed into the method.
+ */
+ subscribeToConfigEvent : function(key,handler,obj,override){},
+
+ /**
+ * Unsubscribes an external handler from the change event for any given property.
+ * @param {string} key The property name
+ * @param {Function} handler The handler function to use subscribe to the property's event
+ * @param {object} obj The object to use for scoping the event handler (see CustomEvent documentation)
+ */
+ unsubscribeFromConfigEvent: function(key,handler,obj){},
+
+ /**
+ * Validates that the value passed in is a boolean.
+ * @param {object} val The value to validate
+ * @return {boolean} true, if the value is valid
+ */
+ checkBoolean: function(val) {
+ if (typeof val == 'boolean') {
+ return true;
+ } else {
+ return false;
+ }
+ },
+
+ /**
+ * Validates that the value passed in is a number.
+ * @param {object} val The value to validate
+ * @return {boolean} true, if the value is valid
+ */
+ checkNumber: function(val) {
+ if (isNaN(val)) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+}
+
+
+/**
+* Initializes the configuration object and all of its local members.
+* @param {object} owner The owner object to which this Config object belongs
+*/
+YAHOO.util.Config.prototype.init = function(owner) {
+
+ this.owner = owner;
+ this.configChangedEvent = new YAHOO.util.CustomEvent("configChanged");
+ this.queueInProgress = false;
+
+ /* Private Members */
+
+ var config = {};
+ var initialConfig = {};
+ var eventQueue = [];
+
+ /**
+ * @private
+ * Fires a configuration property event using the specified value.
+ * @param {string} key The configuration property's name
+ * @param {value} object The value of the correct type for the property
+ */
+ var fireEvent = function( key, value ) {
+ YAHOO.log("Firing Config event: " + key + "=" + value, "info");
+
+ key = key.toLowerCase();
+
+ var property = config[key];
+
+ if (typeof property != 'undefined' && property.event) {
+ property.event.fire(value);
+ }
+ }
+ /* End Private Members */
+
+ this.addProperty = function( key, propertyObject ) {
+ key = key.toLowerCase();
+
+ YAHOO.log("Added property: " + key, "info");
+
+ config[key] = propertyObject;
+
+ propertyObject.event = new YAHOO.util.CustomEvent(key);
+ propertyObject.key = key;
+
+ if (propertyObject.handler) {
+ propertyObject.event.subscribe(propertyObject.handler, this.owner, true);
+ }
+
+ this.setProperty(key, propertyObject.value, true);
+
+ if (! propertyObject.suppressEvent) {
+ this.queueProperty(key, propertyObject.value);
+ }
+ }
+
+ this.getConfig = function() {
+ var cfg = {};
+
+ for (var prop in config) {
+ var property = config[prop]
+ if (typeof property != 'undefined' && property.event) {
+ cfg[prop] = property.value;
+ }
+ }
+
+ return cfg;
+ }
+
+ this.getProperty = function(key) {
+ key = key.toLowerCase();
+
+ var property = config[key];
+ if (typeof property != 'undefined' && property.event) {
+ return property.value;
+ } else {
+ return undefined;
+ }
+ }
+
+ this.resetProperty = function(key) {
+ key = key.toLowerCase();
+
+ var property = config[key];
+ if (typeof property != 'undefined' && property.event) {
+ this.setProperty(key, initialConfig[key].value);
+ } else {
+ return undefined;
+ }
+ }
+
+ this.setProperty = function(key, value, silent) {
+ key = key.toLowerCase();
+
+ YAHOO.log("setProperty: " + key + "=" + value, "info");
+
+ if (this.queueInProgress && ! silent) {
+ this.queueProperty(key,value); // Currently running through a queue...
+ return true;
+ } else {
+ var property = config[key];
+ if (typeof property != 'undefined' && property.event) {
+ if (property.validator && ! property.validator(value)) { // validator
+ return false;
+ } else {
+ property.value = value;
+ if (! silent) {
+ fireEvent(key, value);
+ this.configChangedEvent.fire([key, value]);
+ }
+ return true;
+ }
+ } else {
+ return false;
+ }
+ }
+ }
+
+ this.queueProperty = function(key, value) {
+ key = key.toLowerCase();
+
+ YAHOO.log("queueProperty: " + key + "=" + value, "info");
+
+ var property = config[key];
+
+ if (typeof property != 'undefined' && property.event) {
+ if (typeof value != 'undefined' && property.validator && ! property.validator(value)) { // validator
+ return false;
+ } else {
+
+ if (typeof value != 'undefined') {
+ property.value = value;
+ } else {
+ value = property.value;
+ }
+
+ var foundDuplicate = false;
+
+ for (var i=0;i<eventQueue.length;i++) {
+ var queueItem = eventQueue[i];
+
+ if (queueItem) {
+ var queueItemKey = queueItem[0];
+ var queueItemValue = queueItem[1];
+
+ if (queueItemKey.toLowerCase() == key) {
+ // found a dupe... push to end of queue, null current item, and break
+ eventQueue[i] = null;
+ eventQueue.push([key, (typeof value != 'undefined' ? value : queueItemValue)]);
+ foundDuplicate = true;
+ break;
+ }
+ }
+ }
+
+ if (! foundDuplicate && typeof value != 'undefined') { // this is a refire, or a new property in the queue
+ eventQueue.push([key, value]);
+ }
+ }
+
+ if (property.supercedes) {
+ for (var s=0;s<property.supercedes.length;s++) {
+ var supercedesCheck = property.supercedes[s];
+
+ for (var q=0;q<eventQueue.length;q++) {
+ var queueItemCheck = eventQueue[q];
+
+ if (queueItemCheck) {
+ var queueItemCheckKey = queueItemCheck[0];
+ var queueItemCheckValue = queueItemCheck[1];
+
+ if ( queueItemCheckKey.toLowerCase() == supercedesCheck.toLowerCase() ) {
+ eventQueue.push([queueItemCheckKey, queueItemCheckValue]);
+ eventQueue[q] = null;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ YAHOO.log("Config event queue: " + this.outputEventQueue(), "info");
+
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ this.refireEvent = function(key) {
+ key = key.toLowerCase();
+
+ var property = config[key];
+ if (typeof property != 'undefined' && property.event && typeof property.value != 'undefined') {
+ if (this.queueInProgress) {
+ this.queueProperty(key);
+ } else {
+ fireEvent(key, property.value);
+ }
+ }
+ }
+
+ this.applyConfig = function(userConfig, init) {
+ if (init) {
+ initialConfig = userConfig;
+ }
+ for (var prop in userConfig) {
+ this.queueProperty(prop, userConfig[prop]);
+ }
+ }
+
+ this.refresh = function() {
+ for (var prop in config) {
+ this.refireEvent(prop);
+ }
+ }
+
+ this.fireQueue = function() {
+ this.queueInProgress = true;
+ for (var i=0;i<eventQueue.length;i++) {
+ var queueItem = eventQueue[i];
+ if (queueItem) {
+ var key = queueItem[0];
+ var value = queueItem[1];
+
+ var property = config[key];
+ property.value = value;
+
+ fireEvent(key,value);
+ }
+ }
+
+ this.queueInProgress = false;
+ eventQueue = new Array();
+ }
+
+ this.subscribeToConfigEvent = function(key, handler, obj, override) {
+ key = key.toLowerCase();
+
+ var property = config[key];
+ if (typeof property != 'undefined' && property.event) {
+ if (! YAHOO.util.Config.alreadySubscribed(property.event, handler, obj)) {
+ property.event.subscribe(handler, obj, override);
+ }
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+
+ this.unsubscribeFromConfigEvent = function(key, handler, obj) {
+ key = key.toLowerCase();
+
+ var property = config[key];
+ if (typeof property != 'undefined' && property.event) {
+ return property.event.unsubscribe(handler, obj);
+ } else {
+ return false;
+ }
+ }
+
+ this.toString = function() {
+ var output = "Config";
+ if (this.owner) {
+ output += " [" + this.owner.toString() + "]";
+ }
+ return output;
+ }
+
+ this.outputEventQueue = function() {
+ var output = "";
+ for (var q=0;q<eventQueue.length;q++) {
+ var queueItem = eventQueue[q];
+ if (queueItem) {
+ output += queueItem[0] + "=" + queueItem[1] + ", ";
+ }
+ }
+ return output;
+ }
+}
+
+/**
+* Checks to determine if a particular function/object pair are already subscribed to the specified CustomEvent
+* @param {YAHOO.util.CustomEvent} evt The CustomEvent for which to check the subscriptions
+* @param {Function} fn The function to look for in the subscribers list
+* @param {object} obj The execution scope object for the subscription
+* @return {boolean} true, if the function/object pair is already subscribed to the CustomEvent passed in
+*/
+YAHOO.util.Config.alreadySubscribed = function(evt, fn, obj) {
+ for (var e=0;e<evt.subscribers.length;e++) {
+ var subsc = evt.subscribers[e];
+ if (subsc && subsc.obj == obj && subsc.fn == fn) {
+ return true;
+ break;
+ }
+ }
+ return false;
+}
+
+/**
+* @class
+* Module is a JavaScript representation of the Standard Module Format. Standard Module Format is a simple standard for markup containers where child nodes representing the header, body, and footer of the content are denoted using the CSS classes "hd", "bd", and "ft" respectively. Module is the base class for all other classes in the YUI Container package.
+* @param {string} el The element ID representing the Module <em>OR</em>
+* @param {Element} el The element representing the Module
+* @param {object} userConfig The configuration object literal containing the configuration that should be set for this module. See configuration documentation for more details.
+* @constructor
+*/
+YAHOO.widget.Module = function(el, userConfig) {
+ if (el) {
+ this.init(el, userConfig);
+ } else {
+ YAHOO.log("No element or element ID specified for Module instantiation", "error");
+ }
+}
+
+/**
+* Constant representing the prefix path to use for non-secure images
+* @type string
+*/
+YAHOO.widget.Module.IMG_ROOT = "http://us.i1.yimg.com/us.yimg.com/i/";
+
+/**
+* Constant representing the prefix path to use for securely served images
+* @type string
+*/
+YAHOO.widget.Module.IMG_ROOT_SSL = "https://a248.e.akamai.net/sec.yimg.com/i/";
+
+/**
+* Constant for the default CSS class name that represents a Module
+* @type string
+* @final
+*/
+YAHOO.widget.Module.CSS_MODULE = "module";
+
+/**
+* Constant representing the module header
+* @type string
+* @final
+*/
+YAHOO.widget.Module.CSS_HEADER = "hd";
+
+/**
+* Constant representing the module body
+* @type string
+* @final
+*/
+YAHOO.widget.Module.CSS_BODY = "bd";
+
+/**
+* Constant representing the module footer
+* @type string
+* @final
+*/
+YAHOO.widget.Module.CSS_FOOTER = "ft";
+
+/**
+* Constant representing the url for the "src" attribute of the iframe used to monitor changes to the browser's base font size
+* @type string
+* @final
+*/
+YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL = null;
+
+YAHOO.widget.Module.prototype = {
+
+ /**
+ * The class's constructor function
+ * @type function
+ */
+ constructor : YAHOO.widget.Module,
+
+ /**
+ * The main module element that contains the header, body, and footer
+ * @type Element
+ */
+ element : null,
+
+ /**
+ * The header element, denoted with CSS class "hd"
+ * @type Element
+ */
+ header : null,
+
+ /**
+ * The body element, denoted with CSS class "bd"
+ * @type Element
+ */
+ body : null,
+
+ /**
+ * The footer element, denoted with CSS class "ft"
+ * @type Element
+ */
+ footer : null,
+
+ /**
+ * The id of the element
+ * @type string
+ */
+ id : null,
+
+ /**
+ * Array of elements
+ * @type Element[]
+ */
+ childNodesInDOM : null,
+
+ /**
+ * The string representing the image root
+ * @type string
+ */
+ imageRoot : YAHOO.widget.Module.IMG_ROOT,
+
+ /**
+ * CustomEvent fired prior to class initalization.
+ * args: class reference of the initializing class, such as this.beforeInitEvent.fire(YAHOO.widget.Module)
+ * @type YAHOO.util.CustomEvent
+ */
+ beforeInitEvent : null,
+
+ /**
+ * CustomEvent fired after class initalization.
+ * args: class reference of the initializing class, such as this.initEvent.fire(YAHOO.widget.Module)
+ * @type YAHOO.util.CustomEvent
+ */
+ initEvent : null,
+
+ /**
+ * CustomEvent fired when the Module is appended to the DOM
+ * args: none
+ * @type YAHOO.util.CustomEvent
+ */
+ appendEvent : null,
+
+ /**
+ * CustomEvent fired before the Module is rendered
+ * args: none
+ * @type YAHOO.util.CustomEvent
+ */
+ beforeRenderEvent : null,
+
+ /**
+ * CustomEvent fired after the Module is rendered
+ * args: none
+ * @type YAHOO.util.CustomEvent
+ */
+ renderEvent : null,
+
+ /**
+ * CustomEvent fired when the header content of the Module is modified
+ * args: string/element representing the new header content
+ * @type YAHOO.util.CustomEvent
+ */
+ changeHeaderEvent : null,
+
+ /**
+ * CustomEvent fired when the body content of the Module is modified
+ * args: string/element representing the new body content
+ * @type YAHOO.util.CustomEvent
+ */
+ changeBodyEvent : null,
+
+ /**
+ * CustomEvent fired when the footer content of the Module is modified
+ * args: string/element representing the new footer content
+ * @type YAHOO.util.CustomEvent
+ */
+ changeFooterEvent : null,
+
+ /**
+ * CustomEvent fired when the content of the Module is modified
+ * args: none
+ * @type YAHOO.util.CustomEvent
+ */
+ changeContentEvent : null,
+
+ /**
+ * CustomEvent fired when the Module is destroyed
+ * args: none
+ * @type YAHOO.util.CustomEvent
+ */
+ destroyEvent : null,
+
+ /**
+ * CustomEvent fired before the Module is shown
+ * args: none
+ * @type YAHOO.util.CustomEvent
+ */
+ beforeShowEvent : null,
+
+ /**
+ * CustomEvent fired after the Module is shown
+ * args: none
+ * @type YAHOO.util.CustomEvent
+ */
+ showEvent : null,
+
+ /**
+ * CustomEvent fired before the Module is hidden
+ * args: none
+ * @type YAHOO.util.CustomEvent
+ */
+ beforeHideEvent : null,
+
+ /**
+ * CustomEvent fired after the Module is hidden
+ * args: none
+ * @type YAHOO.util.CustomEvent
+ */
+ hideEvent : null,
+
+ /**
+ * Initializes the custom events for Module which are fired automatically at appropriate times by the Module class.
+ */
+ initEvents : function() {
+
+ this.beforeInitEvent = new YAHOO.util.CustomEvent("beforeInit");
+ this.initEvent = new YAHOO.util.CustomEvent("init");
+
+ this.appendEvent = new YAHOO.util.CustomEvent("append");
+
+ this.beforeRenderEvent = new YAHOO.util.CustomEvent("beforeRender");
+ this.renderEvent = new YAHOO.util.CustomEvent("render");
+
+ this.changeHeaderEvent = new YAHOO.util.CustomEvent("changeHeader");
+ this.changeBodyEvent = new YAHOO.util.CustomEvent("changeBody");
+ this.changeFooterEvent = new YAHOO.util.CustomEvent("changeFooter");
+
+ this.changeContentEvent = new YAHOO.util.CustomEvent("changeContent");
+
+ this.destroyEvent = new YAHOO.util.CustomEvent("destroy");
+ this.beforeShowEvent = new YAHOO.util.CustomEvent("beforeShow");
+ this.showEvent = new YAHOO.util.CustomEvent("show");
+ this.beforeHideEvent = new YAHOO.util.CustomEvent("beforeHide");
+ this.hideEvent = new YAHOO.util.CustomEvent("hide");
+ },
+
+ /**
+ * String representing the current user-agent platform
+ * @type string
+ */
+ platform : function() {
+ var ua = navigator.userAgent.toLowerCase();
+ if (ua.indexOf("windows") != -1 || ua.indexOf("win32") != -1) {
+ return "windows";
+ } else if (ua.indexOf("macintosh") != -1) {
+ return "mac";
+ } else {
+ return false;
+ }
+ }(),
+
+ /**
+ * String representing the current user-agent browser
+ * @type string
+ */
+ browser : function() {
+ var ua = navigator.userAgent.toLowerCase();
+ if (ua.indexOf('opera')!=-1) { // Opera (check first in case of spoof)
+ return 'opera';
+ } else if (ua.indexOf('msie 7')!=-1) { // IE7
+ return 'ie7';
+ } else if (ua.indexOf('msie') !=-1) { // IE
+ return 'ie';
+ } else if (ua.indexOf('safari')!=-1) { // Safari (check before Gecko because it includes "like Gecko")
+ return 'safari';
+ } else if (ua.indexOf('gecko') != -1) { // Gecko
+ return 'gecko';
+ } else {
+ return false;
+ }
+ }(),
+
+ /**
+ * Boolean representing whether or not the current browsing context is secure (https)
+ * @type boolean
+ */
+ isSecure : function() {
+ if (window.location.href.toLowerCase().indexOf("https") == 0) {
+ return true;
+ } else {
+ return false;
+ }
+ }(),
+
+ /**
+ * Initializes the custom events for Module which are fired automatically at appropriate times by the Module class.
+ */
+ initDefaultConfig : function() {
+ // Add properties //
+
+ this.cfg.addProperty("visible", { value:true, handler:this.configVisible, validator:this.cfg.checkBoolean } );
+ this.cfg.addProperty("effect", { suppressEvent:true, supercedes:["visible"] } );
+ this.cfg.addProperty("monitorresize", { value:true, handler:this.configMonitorResize } );
+ },
+
+ /**
+ * The Module class's initialization method, which is executed for Module and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present.
+ * @param {string} el The element ID representing the Module <em>OR</em>
+ * @param {Element} el The element representing the Module
+ * @param {object} userConfig The configuration object literal containing the configuration that should be set for this module. See configuration documentation for more details.
+ */
+ init : function(el, userConfig) {
+
+ this.initEvents();
+
+ this.beforeInitEvent.fire(YAHOO.widget.Module);
+
+ this.cfg = new YAHOO.util.Config(this);
+
+ if (this.isSecure) {
+ this.imageRoot = YAHOO.widget.Module.IMG_ROOT_SSL;
+ }
+
+ if (typeof el == "string") {
+ var elId = el;
+
+ el = document.getElementById(el);
+ if (! el) {
+ el = document.createElement("DIV");
+ el.id = elId;
+ }
+ }
+
+ this.element = el;
+
+ if (el.id) {
+ this.id = el.id;
+ }
+
+ var childNodes = this.element.childNodes;
+
+ if (childNodes) {
+ for (var i=0;i<childNodes.length;i++) {
+ var child = childNodes[i];
+ switch (child.className) {
+ case YAHOO.widget.Module.CSS_HEADER:
+ this.header = child;
+ break;
+ case YAHOO.widget.Module.CSS_BODY:
+ this.body = child;
+ break;
+ case YAHOO.widget.Module.CSS_FOOTER:
+ this.footer = child;
+ break;
+ }
+ }
+ }
+
+ this.initDefaultConfig();
+
+ YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Module.CSS_MODULE);
+
+ if (userConfig) {
+ this.cfg.applyConfig(userConfig, true);
+ }
+
+ // Subscribe to the fireQueue() method of Config so that any queued configuration changes are
+ // excecuted upon render of the Module
+ if (! YAHOO.util.Config.alreadySubscribed(this.renderEvent, this.cfg.fireQueue, this.cfg)) {
+ this.renderEvent.subscribe(this.cfg.fireQueue, this.cfg, true);
+ }
+
+ this.initEvent.fire(YAHOO.widget.Module);
+ },
+
+ /**
+ * Initialized an empty DOM element that is placed out of the visible area that can be used to detect text resize.
+ */
+ initResizeMonitor : function() {
+
+ if(this.browser != "opera") {
+
+ var resizeMonitor = document.getElementById("_yuiResizeMonitor");
+
+ if (! resizeMonitor) {
+
+ resizeMonitor = document.createElement("iframe");
+
+ var bIE = (this.browser.indexOf("ie") === 0);
+
+ if(this.isSecure && this.RESIZE_MONITOR_SECURE_URL && bIE) {
+
+ resizeMonitor.src = this.RESIZE_MONITOR_SECURE_URL;
+
+ }
+
+ resizeMonitor.id = "_yuiResizeMonitor";
+ resizeMonitor.style.visibility = "hidden";
+
+ document.body.appendChild(resizeMonitor);
+
+ resizeMonitor.style.width = "10em";
+ resizeMonitor.style.height = "10em";
+ resizeMonitor.style.position = "absolute";
+
+ var nLeft = -1 * resizeMonitor.offsetWidth,
+ nTop = -1 * resizeMonitor.offsetHeight;
+
+ resizeMonitor.style.top = nTop + "px";
+ resizeMonitor.style.left = nLeft + "px";
+ resizeMonitor.style.borderStyle = "none";
+ resizeMonitor.style.borderWidth = "0";
+ YAHOO.util.Dom.setStyle(resizeMonitor, "opacity", "0");
+
+ resizeMonitor.style.visibility = "visible";
+
+ if(!bIE) {
+
+ var doc = resizeMonitor.contentWindow.document;
+
+ doc.open();
+ doc.close();
+
+ }
+
+ }
+
+ if(resizeMonitor && resizeMonitor.contentWindow) {
+
+ this.resizeMonitor = resizeMonitor;
+
+ YAHOO.util.Event.addListener(this.resizeMonitor.contentWindow, "resize", this.onDomResize, this, true);
+
+ }
+
+ }
+
+ },
+
+ /**
+ * Event handler fired when the resize monitor element is resized.
+ */
+ onDomResize : function(e, obj) {
+
+ var nLeft = -1 * this.resizeMonitor.offsetWidth,
+ nTop = -1 * this.resizeMonitor.offsetHeight;
+
+ this.resizeMonitor.style.top = nTop + "px";
+ this.resizeMonitor.style.left = nLeft + "px";
+
+ },
+
+ /**
+ * Sets the Module's header content to the HTML specified, or appends the passed element to the header. If no header is present, one will be automatically created.
+ * @param {string} headerContent The HTML used to set the header <em>OR</em>
+ * @param {Element} headerContent The Element to append to the header
+ */
+ setHeader : function(headerContent) {
+ if (! this.header) {
+ this.header = document.createElement("DIV");
+ this.header.className = YAHOO.widget.Module.CSS_HEADER;
+ }
+
+ if (typeof headerContent == "string") {
+ this.header.innerHTML = headerContent;
+ } else {
+ this.header.innerHTML = "";
+ this.header.appendChild(headerContent);
+ }
+
+ this.changeHeaderEvent.fire(headerContent);
+ this.changeContentEvent.fire();
+ },
+
+ /**
+ * Appends the passed element to the header. If no header is present, one will be automatically created.
+ * @param {Element} element The element to append to the header
+ */
+ appendToHeader : function(element) {
+ if (! this.header) {
+ this.header = document.createElement("DIV");
+ this.header.className = YAHOO.widget.Module.CSS_HEADER;
+ }
+
+ this.header.appendChild(element);
+ this.changeHeaderEvent.fire(element);
+ this.changeContentEvent.fire();
+ },
+
+ /**
+ * Sets the Module's body content to the HTML specified, or appends the passed element to the body. If no body is present, one will be automatically created.
+ * @param {string} bodyContent The HTML used to set the body <em>OR</em>
+ * @param {Element} bodyContent The Element to append to the body
+ */
+ setBody : function(bodyContent) {
+ if (! this.body) {
+ this.body = document.createElement("DIV");
+ this.body.className = YAHOO.widget.Module.CSS_BODY;
+ }
+
+ if (typeof bodyContent == "string")
+ {
+ this.body.innerHTML = bodyContent;
+ } else {
+ this.body.innerHTML = "";
+ this.body.appendChild(bodyContent);
+ }
+
+ this.changeBodyEvent.fire(bodyContent);
+ this.changeContentEvent.fire();
+ },
+
+ /**
+ * Appends the passed element to the body. If no body is present, one will be automatically created.
+ * @param {Element} element The element to append to the body
+ */
+ appendToBody : function(element) {
+ if (! this.body) {
+ this.body = document.createElement("DIV");
+ this.body.className = YAHOO.widget.Module.CSS_BODY;
+ }
+
+ this.body.appendChild(element);
+ this.changeBodyEvent.fire(element);
+ this.changeContentEvent.fire();
+ },
+
+ /**
+ * Sets the Module's footer content to the HTML specified, or appends the passed element to the footer. If no footer is present, one will be automatically created.
+ * @param {string} footerContent The HTML used to set the footer <em>OR</em>
+ * @param {Element} footerContent The Element to append to the footer
+ */
+ setFooter : function(footerContent) {
+ if (! this.footer) {
+ this.footer = document.createElement("DIV");
+ this.footer.className = YAHOO.widget.Module.CSS_FOOTER;
+ }
+
+ if (typeof footerContent == "string") {
+ this.footer.innerHTML = footerContent;
+ } else {
+ this.footer.innerHTML = "";
+ this.footer.appendChild(footerContent);
+ }
+
+ this.changeFooterEvent.fire(footerContent);
+ this.changeContentEvent.fire();
+ },
+
+ /**
+ * Appends the passed element to the footer. If no footer is present, one will be automatically created.
+ * @param {Element} element The element to append to the footer
+ */
+ appendToFooter : function(element) {
+ if (! this.footer) {
+ this.footer = document.createElement("DIV");
+ this.footer.className = YAHOO.widget.Module.CSS_FOOTER;
+ }
+
+ this.footer.appendChild(element);
+ this.changeFooterEvent.fire(element);
+ this.changeContentEvent.fire();
+ },
+
+ /**
+ * Renders the Module by inserting the elements that are not already in the main Module into their correct places. Optionally appends the Module to the specified node prior to the render's execution. NOTE: For Modules without existing markup, the appendToNode argument is REQUIRED. If this argument is ommitted and the current element is not present in the document, the function will return false, indicating that the render was a failure.
+ * @param {string} appendToNode The element id to which the Module should be appended to prior to rendering <em>OR</em>
+ * @param {Element} appendToNode The element to which the Module should be appended to prior to rendering
+ * @param {Element} moduleElement OPTIONAL. The element that represents the actual Standard Module container.
+ * @return {boolean} Success or failure of the render
+ */
+ render : function(appendToNode, moduleElement) {
+ this.beforeRenderEvent.fire();
+
+ if (! moduleElement) {
+ moduleElement = this.element;
+ }
+
+ var me = this;
+ var appendTo = function(element) {
+ if (typeof element == "string") {
+ element = document.getElementById(element);
+ }
+
+ if (element) {
+ element.appendChild(me.element);
+ me.appendEvent.fire();
+ }
+ }
+
+ if (appendToNode) {
+ appendTo(appendToNode);
+ } else { // No node was passed in. If the element is not pre-marked up, this fails
+ if (! YAHOO.util.Dom.inDocument(this.element)) {
+ YAHOO.log("Render failed. Must specify appendTo node if Module isn't already in the DOM.", "error");
+ return false;
+ }
+ }
+
+ // Need to get everything into the DOM if it isn't already
+
+ if (this.header && ! YAHOO.util.Dom.inDocument(this.header)) {
+ // There is a header, but it's not in the DOM yet... need to add it
+ var firstChild = moduleElement.firstChild;
+ if (firstChild) { // Insert before first child if exists
+ moduleElement.insertBefore(this.header, firstChild);
+ } else { // Append to empty body because there are no children
+ moduleElement.appendChild(this.header);
+ }
+ }
+
+ if (this.body && ! YAHOO.util.Dom.inDocument(this.body)) {
+ // There is a body, but it's not in the DOM yet... need to add it
+ if (this.footer && YAHOO.util.Dom.isAncestor(this.moduleElement, this.footer)) { // Insert before footer if exists in DOM
+ moduleElement.insertBefore(this.body, this.footer);
+ } else { // Append to element because there is no footer
+ moduleElement.appendChild(this.body);
+ }
+ }
+
+ if (this.footer && ! YAHOO.util.Dom.inDocument(this.footer)) {
+ // There is a footer, but it's not in the DOM yet... need to add it
+ moduleElement.appendChild(this.footer);
+ }
+
+ this.renderEvent.fire();
+ return true;
+ },
+
+ /**
+ * Removes the Module element from the DOM and sets all child elements to null.
+ */
+ destroy : function() {
+ if (this.element) {
+ var parent = this.element.parentNode;
+ }
+ if (parent) {
+ parent.removeChild(this.element);
+ }
+
+ this.element = null;
+ this.header = null;
+ this.body = null;
+ this.footer = null;
+
+ this.destroyEvent.fire();
+ },
+
+ /**
+ * Shows the Module element by setting the visible configuration property to true. Also fires two events: beforeShowEvent prior to the visibility change, and showEvent after.
+ */
+ show : function() {
+ this.cfg.setProperty("visible", true);
+ },
+
+ /**
+ * Hides the Module element by setting the visible configuration property to false. Also fires two events: beforeHideEvent prior to the visibility change, and hideEvent after.
+ */
+ hide : function() {
+ this.cfg.setProperty("visible", false);
+ },
+
+ // BUILT-IN EVENT HANDLERS FOR MODULE //
+
+ /**
+ * Default event handler for changing the visibility property of a Module. By default, this is achieved by switching the "display" style between "block" and "none".
+ * This method is responsible for firing showEvent and hideEvent.
+ */
+ configVisible : function(type, args, obj) {
+ var visible = args[0];
+ if (visible) {
+ this.beforeShowEvent.fire();
+ YAHOO.util.Dom.setStyle(this.element, "display", "block");
+ this.showEvent.fire();
+ } else {
+ this.beforeHideEvent.fire();
+ YAHOO.util.Dom.setStyle(this.element, "display", "none");
+ this.hideEvent.fire();
+ }
+ },
+
+ /**
+ * Default event handler for the "monitorresize" configuration property
+ */
+ configMonitorResize : function(type, args, obj) {
+ var monitor = args[0];
+ if (monitor) {
+ this.initResizeMonitor();
+ } else {
+ YAHOO.util.Event.removeListener(this.resizeMonitor, "resize", this.onDomResize);
+ this.resizeMonitor = null;
+ }
+ }
+}
+
+/**
+* Returns a string representation of the object.
+* @type string
+*/
+YAHOO.widget.Module.prototype.toString = function() {
+ return "Module " + this.id;
+}
+
+/**
+* @class Overlay is a Module that is absolutely positioned above the page flow. It has convenience methods for positioning and sizing, as well as options for controlling zIndex and constraining the Overlay's position to the current visible viewport. Overlay also contains a dynamicly generated IFRAME which is placed beneath it for Internet Explorer 6 and 5.x so that it will be properly rendered above SELECT elements.
+* @param {string} el The element ID representing the Overlay <em>OR</em>
+* @param {Element} el The element representing the Overlay
+* @param {object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details.
+* @constructor
+*/
+YAHOO.widget.Overlay = function(el, userConfig) {
+ YAHOO.widget.Overlay.superclass.constructor.call(this, el, userConfig);
+}
+
+YAHOO.extend(YAHOO.widget.Overlay, YAHOO.widget.Module);
+
+/**
+* The URL of the blank image that will be placed in the iframe
+* @type string
+* @final
+*/
+YAHOO.widget.Overlay.IFRAME_SRC = "promo/m/irs/blank.gif";
+
+/**
+* Constant representing the top left corner of an element, used for configuring the context element alignment
+* @type string
+* @final
+*/
+YAHOO.widget.Overlay.TOP_LEFT = "tl";
+
+/**
+* Constant representing the top right corner of an element, used for configuring the context element alignment
+* @type string
+* @final
+*/
+YAHOO.widget.Overlay.TOP_RIGHT = "tr";
+
+/**
+* Constant representing the top bottom left corner of an element, used for configuring the context element alignment
+* @type string
+* @final
+*/
+YAHOO.widget.Overlay.BOTTOM_LEFT = "bl";
+
+/**
+* Constant representing the bottom right corner of an element, used for configuring the context element alignment
+* @type string
+* @final
+*/
+YAHOO.widget.Overlay.BOTTOM_RIGHT = "br";
+
+/**
+* Constant representing the default CSS class used for an Overlay
+* @type string
+* @final
+*/
+YAHOO.widget.Overlay.CSS_OVERLAY = "overlay";
+
+/**
+* CustomEvent fired before the Overlay is moved.
+* args: x,y that the Overlay will be moved to
+* @type YAHOO.util.CustomEvent
+*/
+YAHOO.widget.Overlay.prototype.beforeMoveEvent = null;
+
+/**
+* CustomEvent fired after the Overlay is moved.
+* args: x,y that the Overlay was moved to
+* @type YAHOO.util.CustomEvent
+*/
+YAHOO.widget.Overlay.prototype.moveEvent = null;
+
+/**
+* The Overlay initialization method, which is executed for Overlay and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present.
+* @param {string} el The element ID representing the Overlay <em>OR</em>
+* @param {Element} el The element representing the Overlay
+* @param {object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details.
+*/
+YAHOO.widget.Overlay.prototype.init = function(el, userConfig) {
+ YAHOO.widget.Overlay.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level
+
+ this.beforeInitEvent.fire(YAHOO.widget.Overlay);
+
+ YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Overlay.CSS_OVERLAY);
+
+ if (userConfig) {
+ this.cfg.applyConfig(userConfig, true);
+ }
+
+ if (this.platform == "mac" && this.browser == "gecko") {
+ if (! YAHOO.util.Config.alreadySubscribed(this.showEvent,this.showMacGeckoScrollbars,this)) {
+ this.showEvent.subscribe(this.showMacGeckoScrollbars,this,true);
+ }
+ if (! YAHOO.util.Config.alreadySubscribed(this.hideEvent,this.hideMacGeckoScrollbars,this)) {
+ this.hideEvent.subscribe(this.hideMacGeckoScrollbars,this,true);
+ }
+ }
+
+ this.initEvent.fire(YAHOO.widget.Overlay);
+
+}
+
+/**
+* Initializes the custom events for Overlay which are fired automatically at appropriate times by the Overlay class.
+*/
+YAHOO.widget.Overlay.prototype.initEvents = function() {
+ YAHOO.widget.Overlay.superclass.initEvents.call(this);
+
+ this.beforeMoveEvent = new YAHOO.util.CustomEvent("beforeMove", this);
+ this.moveEvent = new YAHOO.util.CustomEvent("move", this);
+}
+
+/**
+* Initializes the class's configurable properties which can be changed using the Overlay's Config object (cfg).
+*/
+YAHOO.widget.Overlay.prototype.initDefaultConfig = function() {
+ YAHOO.widget.Overlay.superclass.initDefaultConfig.call(this);
+
+ // Add overlay config properties //
+ this.cfg.addProperty("x", { handler:this.configX, validator:this.cfg.checkNumber, suppressEvent:true, supercedes:["iframe"] } );
+ this.cfg.addProperty("y", { handler:this.configY, validator:this.cfg.checkNumber, suppressEvent:true, supercedes:["iframe"] } );
+ this.cfg.addProperty("xy",{ handler:this.configXY, suppressEvent:true, supercedes:["iframe"] } );
+
+ this.cfg.addProperty("context", { handler:this.configContext, suppressEvent:true, supercedes:["iframe"] } );
+ this.cfg.addProperty("fixedcenter", { value:false, handler:this.configFixedCenter, validator:this.cfg.checkBoolean, supercedes:["iframe","visible"] } );
+
+ this.cfg.addProperty("width", { handler:this.configWidth, suppressEvent:true, supercedes:["iframe"] } );
+ this.cfg.addProperty("height", { handler:this.configHeight, suppressEvent:true, supercedes:["iframe"] } );
+
+ this.cfg.addProperty("zIndex", { value:null, handler:this.configzIndex } );
+
+ this.cfg.addProperty("constraintoviewport", { value:false, handler:this.configConstrainToViewport, validator:this.cfg.checkBoolean, supercedes:["iframe","x","y","xy"] } );
+ this.cfg.addProperty("iframe", { value:(this.browser == "ie" ? true : false), handler:this.configIframe, validator:this.cfg.checkBoolean, supercedes:["zIndex"] } );
+}
+
+/**
+* Moves the Overlay to the specified position. This function is identical to calling this.cfg.setProperty("xy", [x,y]);
+* @param {int} x The Overlay's new x position
+* @param {int} y The Overlay's new y position
+*/
+YAHOO.widget.Overlay.prototype.moveTo = function(x, y) {
+ this.cfg.setProperty("xy",[x,y]);
+}
+
+/**
+* Adds a special CSS class to the Overlay when Mac/Gecko is in use, to work around a Gecko bug where
+* scrollbars cannot be hidden. See https://bugzilla.mozilla.org/show_bug.cgi?id=187435
+*/
+YAHOO.widget.Overlay.prototype.hideMacGeckoScrollbars = function() {
+ YAHOO.util.Dom.removeClass(this.element, "show-scrollbars");
+ YAHOO.util.Dom.addClass(this.element, "hide-scrollbars");
+}
+
+/**
+* Removes a special CSS class from the Overlay when Mac/Gecko is in use, to work around a Gecko bug where
+* scrollbars cannot be hidden. See https://bugzilla.mozilla.org/show_bug.cgi?id=187435
+*/
+YAHOO.widget.Overlay.prototype.showMacGeckoScrollbars = function() {
+ YAHOO.util.Dom.removeClass(this.element, "hide-scrollbars");
+ YAHOO.util.Dom.addClass(this.element, "show-scrollbars");
+}
+
+// BEGIN BUILT-IN PROPERTY EVENT HANDLERS //
+
+/**
+* The default event handler fired when the "visible" property is changed. This method is responsible for firing showEvent and hideEvent.
+*/
+YAHOO.widget.Overlay.prototype.configVisible = function(type, args, obj) {
+ var visible = args[0];
+ var currentVis = YAHOO.util.Dom.getStyle(this.element, "visibility");
+
+ var effect = this.cfg.getProperty("effect");
+
+ var effectInstances = new Array();
+ if (effect) {
+ if (effect instanceof Array) {
+ for (var i=0;i<effect.length;i++) {
+ var eff = effect[i];
+ effectInstances[effectInstances.length] = eff.effect(this, eff.duration);
+ }
+ } else {
+ effectInstances[effectInstances.length] = effect.effect(this, effect.duration);
+ }
+ }
+
+ var isMacGecko = (this.platform == "mac" && this.browser == "gecko");
+
+ if (visible) { // Show
+ if (isMacGecko) {
+ this.showMacGeckoScrollbars();
+ }
+
+ if (effect) { // Animate in
+ if (visible) { // Animate in if not showing
+ if (currentVis != "visible") {
+ this.beforeShowEvent.fire();
+ for (var i=0;i<effectInstances.length;i++) {
+ var e = effectInstances[i];
+ if (i == 0 && ! YAHOO.util.Config.alreadySubscribed(e.animateInCompleteEvent,this.showEvent.fire,this.showEvent)) {
+ e.animateInCompleteEvent.subscribe(this.showEvent.fire,this.showEvent,true); // Delegate showEvent until end of animateInComplete
+ }
+ e.animateIn();
+ }
+ }
+ }
+ } else { // Show
+ if (currentVis != "visible") {
+ this.beforeShowEvent.fire();
+ YAHOO.util.Dom.setStyle(this.element, "visibility", "visible");
+ this.cfg.refireEvent("iframe");
+ this.showEvent.fire();
+ }
+ }
+
+ } else { // Hide
+ if (isMacGecko) {
+ this.hideMacGeckoScrollbars();
+ }
+
+ if (effect) { // Animate out if showing
+ if (currentVis == "visible") {
+ this.beforeHideEvent.fire();
+ for (var i=0;i<effectInstances.length;i++) {
+ var e = effectInstances[i];
+ if (i == 0 && ! YAHOO.util.Config.alreadySubscribed(e.animateOutCompleteEvent,this.hideEvent.fire,this.hideEvent)) {
+ e.animateOutCompleteEvent.subscribe(this.hideEvent.fire,this.hideEvent,true); // Delegate hideEvent until end of animateOutComplete
+ }
+ e.animateOut();
+ }
+ }
+ } else { // Simple hide
+ if (currentVis == "visible") {
+ this.beforeHideEvent.fire();
+ YAHOO.util.Dom.setStyle(this.element, "visibility", "hidden");
+ this.cfg.refireEvent("iframe");
+ this.hideEvent.fire();
+ }
+ }
+ }
+}
+
+/**
+* Center event handler used for centering on scroll/resize, but only if the Overlay is visible
+*/
+YAHOO.widget.Overlay.prototype.doCenterOnDOMEvent = function() {
+ if (this.cfg.getProperty("visible")) {
+ this.center();
+ }
+}
+
+/**
+* The default event handler fired when the "fixedcenter" property is changed.
+*/
+YAHOO.widget.Overlay.prototype.configFixedCenter = function(type, args, obj) {
+ var val = args[0];
+
+ if (val) {
+ this.center();
+
+ if (! YAHOO.util.Config.alreadySubscribed(this.beforeShowEvent, this.center, this)) {
+ this.beforeShowEvent.subscribe(this.center, this, true);
+ }
+
+ if (! YAHOO.util.Config.alreadySubscribed(YAHOO.widget.Overlay.windowResizeEvent, this.doCenterOnDOMEvent, this)) {
+ YAHOO.widget.Overlay.windowResizeEvent.subscribe(this.doCenterOnDOMEvent, this, true);
+ }
+
+ if (! YAHOO.util.Config.alreadySubscribed(YAHOO.widget.Overlay.windowScrollEvent, this.doCenterOnDOMEvent, this)) {
+ YAHOO.widget.Overlay.windowScrollEvent.subscribe( this.doCenterOnDOMEvent, this, true);
+ }
+ } else {
+ YAHOO.widget.Overlay.windowResizeEvent.unsubscribe(this.doCenterOnDOMEvent, this);
+ YAHOO.widget.Overlay.windowScrollEvent.unsubscribe(this.doCenterOnDOMEvent, this);
+ }
+}
+
+/**
+* The default event handler fired when the "height" property is changed.
+*/
+YAHOO.widget.Overlay.prototype.configHeight = function(type, args, obj) {
+ var height = args[0];
+ var el = this.element;
+ YAHOO.util.Dom.setStyle(el, "height", height);
+ this.cfg.refireEvent("iframe");
+}
+
+/**
+* The default event handler fired when the "width" property is changed.
+*/
+YAHOO.widget.Overlay.prototype.configWidth = function(type, args, obj) {
+ var width = args[0];
+ var el = this.element;
+ YAHOO.util.Dom.setStyle(el, "width", width);
+ this.cfg.refireEvent("iframe");
+}
+
+/**
+* The default event handler fired when the "zIndex" property is changed.
+*/
+YAHOO.widget.Overlay.prototype.configzIndex = function(type, args, obj) {
+ var zIndex = args[0];
+
+ var el = this.element;
+
+ if (! zIndex) {
+ zIndex = YAHOO.util.Dom.getStyle(el, "zIndex");
+ if (! zIndex || isNaN(zIndex)) {
+ zIndex = 0;
+ }
+ }
+
+ if (this.iframe) {
+ if (zIndex <= 0) {
+ zIndex = 1;
+ }
+ YAHOO.util.Dom.setStyle(this.iframe, "zIndex", (zIndex-1));
+ }
+
+ YAHOO.util.Dom.setStyle(el, "zIndex", zIndex);
+ this.cfg.setProperty("zIndex", zIndex, true);
+}
+
+/**
+* The default event handler fired when the "xy" property is changed.
+*/
+YAHOO.widget.Overlay.prototype.configXY = function(type, args, obj) {
+ var pos = args[0];
+ var x = pos[0];
+ var y = pos[1];
+
+ this.cfg.setProperty("x", x);
+ this.cfg.setProperty("y", y);
+
+ this.beforeMoveEvent.fire([x,y]);
+
+ x = this.cfg.getProperty("x");
+ y = this.cfg.getProperty("y");
+
+ YAHOO.log("xy: " + [x,y], "iframe");
+
+ this.cfg.refireEvent("iframe");
+ this.moveEvent.fire([x,y]);
+}
+
+/**
+* The default event handler fired when the "x" property is changed.
+*/
+YAHOO.widget.Overlay.prototype.configX = function(type, args, obj) {
+ var x = args[0];
+ var y = this.cfg.getProperty("y");
+
+ this.cfg.setProperty("x", x, true);
+ this.cfg.setProperty("y", y, true);
+
+ this.beforeMoveEvent.fire([x,y]);
+
+ x = this.cfg.getProperty("x");
+ y = this.cfg.getProperty("y");
+
+ YAHOO.util.Dom.setX(this.element, x, true);
+
+ this.cfg.setProperty("xy", [x, y], true);
+
+ this.cfg.refireEvent("iframe");
+ this.moveEvent.fire([x, y]);
+}
+
+/**
+* The default event handler fired when the "y" property is changed.
+*/
+YAHOO.widget.Overlay.prototype.configY = function(type, args, obj) {
+ var x = this.cfg.getProperty("x");
+ var y = args[0];
+
+ this.cfg.setProperty("x", x, true);
+ this.cfg.setProperty("y", y, true);
+
+ this.beforeMoveEvent.fire([x,y]);
+
+ x = this.cfg.getProperty("x");
+ y = this.cfg.getProperty("y");
+
+ YAHOO.util.Dom.setY(this.element, y, true);
+
+ this.cfg.setProperty("xy", [x, y], true);
+
+ this.cfg.refireEvent("iframe");
+ this.moveEvent.fire([x, y]);
+}
+
+/**
+* The default event handler fired when the "iframe" property is changed.
+*/
+YAHOO.widget.Overlay.prototype.configIframe = function(type, args, obj) {
+
+ var val = args[0];
+
+ var el = this.element;
+
+ var showIframe = function() {
+ if (this.iframe) {
+ this.iframe.style.display = "block";
+ }
+ }
+
+ var hideIframe = function() {
+ if (this.iframe) {
+ this.iframe.style.display = "none";
+ }
+ }
+
+ if (val) { // IFRAME shim is enabled
+
+ if (! YAHOO.util.Config.alreadySubscribed(this.showEvent, showIframe, this)) {
+ this.showEvent.subscribe(showIframe, this, true);
+ }
+ if (! YAHOO.util.Config.alreadySubscribed(this.hideEvent, hideIframe, this)) {
+ this.hideEvent.subscribe(hideIframe, this, true);
+ }
+
+ var x = this.cfg.getProperty("x");
+ var y = this.cfg.getProperty("y");
+
+ if (! x || ! y) {
+ YAHOO.log("syncPosition needed for iframe", "iframe");
+ this.syncPosition();
+ x = this.cfg.getProperty("x");
+ y = this.cfg.getProperty("y");
+ }
+
+ YAHOO.log("iframe positioning to: " + [x,y], "iframe");
+
+ if (! isNaN(x) && ! isNaN(y)) {
+ if (! this.iframe) {
+ this.iframe = document.createElement("iframe");
+ if (this.isSecure) {
+ this.iframe.src = this.imageRoot + YAHOO.widget.Overlay.IFRAME_SRC;
+ }
+
+ var parent = el.parentNode;
+ if (parent) {
+ parent.appendChild(this.iframe);
+ } else {
+ document.body.appendChild(this.iframe);
+ }
+
+ YAHOO.util.Dom.setStyle(this.iframe, "position", "absolute");
+ YAHOO.util.Dom.setStyle(this.iframe, "border", "none");
+ YAHOO.util.Dom.setStyle(this.iframe, "margin", "0");
+ YAHOO.util.Dom.setStyle(this.iframe, "padding", "0");
+ YAHOO.util.Dom.setStyle(this.iframe, "opacity", "0");
+ if (this.cfg.getProperty("visible")) {
+ showIframe.call(this);
+ } else {
+ hideIframe.call(this);
+ }
+ }
+
+ var iframeDisplay = YAHOO.util.Dom.getStyle(this.iframe, "display");
+
+ if (iframeDisplay == "none") {
+ this.iframe.style.display = "block";
+ }
+
+ YAHOO.util.Dom.setXY(this.iframe, [x,y]);
+
+ var width = el.clientWidth;
+ var height = el.clientHeight;
+
+ YAHOO.util.Dom.setStyle(this.iframe, "width", (width+2) + "px");
+ YAHOO.util.Dom.setStyle(this.iframe, "height", (height+2) + "px");
+
+ if (iframeDisplay == "none") {
+ this.iframe.style.display = "none";
+ }
+ }
+ } else {
+ if (this.iframe) {
+ this.iframe.style.display = "none";
+ }
+ this.showEvent.unsubscribe(showIframe, this);
+ this.hideEvent.unsubscribe(hideIframe, this);
+ }
+}
+
+
+/**
+* The default event handler fired when the "constraintoviewport" property is changed.
+*/
+YAHOO.widget.Overlay.prototype.configConstrainToViewport = function(type, args, obj) {
+ var val = args[0];
+ if (val) {
+ if (! YAHOO.util.Config.alreadySubscribed(this.beforeMoveEvent, this.enforceConstraints, this)) {
+ this.beforeMoveEvent.subscribe(this.enforceConstraints, this, true);
+ }
+ } else {
+ this.beforeMoveEvent.unsubscribe(this.enforceConstraints, this);
+ }
+}
+
+/**
+* The default event handler fired when the "context" property is changed.
+*/
+YAHOO.widget.Overlay.prototype.configContext = function(type, args, obj) {
+ var contextArgs = args[0];
+
+ if (contextArgs) {
+ var contextEl = contextArgs[0];
+ var elementMagnetCorner = contextArgs[1];
+ var contextMagnetCorner = contextArgs[2];
+
+ if (contextEl) {
+ if (typeof contextEl == "string") {
+ this.cfg.setProperty("context", [document.getElementById(contextEl),elementMagnetCorner,contextMagnetCorner], true);
+ }
+
+ if (elementMagnetCorner && contextMagnetCorner) {
+ this.align(elementMagnetCorner, contextMagnetCorner);
+ }
+ }
+ }
+}
+
+
+// END BUILT-IN PROPERTY EVENT HANDLERS //
+
+/**
+* Aligns the Overlay to its context element using the specified corner points (represented by the constants TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, and BOTTOM_RIGHT.
+* @param {string} elementAlign The string representing the corner of the Overlay that should be aligned to the context element
+* @param {string} contextAlign The corner of the context element that the elementAlign corner should stick to.
+*/
+YAHOO.widget.Overlay.prototype.align = function(elementAlign, contextAlign) {
+ var contextArgs = this.cfg.getProperty("context");
+ if (contextArgs) {
+ var context = contextArgs[0];
+
+ var element = this.element;
+ var me = this;
+
+ if (! elementAlign) {
+ elementAlign = contextArgs[1];
+ }
+
+ if (! contextAlign) {
+ contextAlign = contextArgs[2];
+ }
+
+ if (element && context) {
+ var elementRegion = YAHOO.util.Dom.getRegion(element);
+ var contextRegion = YAHOO.util.Dom.getRegion(context);
+
+ var doAlign = function(v,h) {
+ switch (elementAlign) {
+ case YAHOO.widget.Overlay.TOP_LEFT:
+ me.moveTo(h,v);
+ break;
+ case YAHOO.widget.Overlay.TOP_RIGHT:
+ me.moveTo(h-element.offsetWidth,v);
+ break;
+ case YAHOO.widget.Overlay.BOTTOM_LEFT:
+ me.moveTo(h,v-element.offsetHeight);
+ break;
+ case YAHOO.widget.Overlay.BOTTOM_RIGHT:
+ me.moveTo(h-element.offsetWidth,v-element.offsetHeight);
+ break;
+ }
+ }
+
+ switch (contextAlign) {
+ case YAHOO.widget.Overlay.TOP_LEFT:
+ doAlign(contextRegion.top, contextRegion.left);
+ break;
+ case YAHOO.widget.Overlay.TOP_RIGHT:
+ doAlign(contextRegion.top, contextRegion.right);
+ break;
+ case YAHOO.widget.Overlay.BOTTOM_LEFT:
+ doAlign(contextRegion.bottom, contextRegion.left);
+ break;
+ case YAHOO.widget.Overlay.BOTTOM_RIGHT:
+ doAlign(contextRegion.bottom, contextRegion.right);
+ break;
+ }
+ }
+ }
+}
+
+/**
+* The default event handler executed when the moveEvent is fired, if the "constraintoviewport" is set to true.
+*/
+YAHOO.widget.Overlay.prototype.enforceConstraints = function(type, args, obj) {
+ var pos = args[0];
+
+ var x = pos[0];
+ var y = pos[1];
+
+ var width = parseInt(this.cfg.getProperty("width"));
+
+ if (isNaN(width)) {
+ width = 0;
+ }
+
+ var offsetHeight = this.element.offsetHeight;
+ var offsetWidth = (width>0?width:this.element.offsetWidth); //this.element.offsetWidth;
+
+ var viewPortWidth = YAHOO.util.Dom.getViewportWidth();
+ var viewPortHeight = YAHOO.util.Dom.getViewportHeight();
+
+ var scrollX = window.scrollX || document.documentElement.scrollLeft;
+ var scrollY = window.scrollY || document.documentElement.scrollTop;
+
+ var topConstraint = scrollY + 10;
+ var leftConstraint = scrollX + 10;
+ var bottomConstraint = scrollY + viewPortHeight - offsetHeight - 10;
+ var rightConstraint = scrollX + viewPortWidth - offsetWidth - 10;
+
+ if (x < leftConstraint) {
+ x = leftConstraint;
+ } else if (x > rightConstraint) {
+ x = rightConstraint;
+ }
+
+ if (y < topConstraint) {
+ y = topConstraint;
+ } else if (y > bottomConstraint) {
+ y = bottomConstraint;
+ }
+
+ this.cfg.setProperty("x", x, true);
+ this.cfg.setProperty("y", y, true);
+ this.cfg.setProperty("xy", [x,y], true);
+}
+
+/**
+* Centers the container in the viewport.
+*/
+YAHOO.widget.Overlay.prototype.center = function() {
+ var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
+ var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
+
+ var viewPortWidth = YAHOO.util.Dom.getClientWidth();
+ var viewPortHeight = YAHOO.util.Dom.getClientHeight();
+
+ var elementWidth = this.element.offsetWidth;
+ var elementHeight = this.element.offsetHeight;
+
+ var x = (viewPortWidth / 2) - (elementWidth / 2) + scrollX;
+ var y = (viewPortHeight / 2) - (elementHeight / 2) + scrollY;
+
+ this.element.style.left = parseInt(x) + "px";
+ this.element.style.top = parseInt(y) + "px";
+ this.syncPosition();
+
+ this.cfg.refireEvent("iframe");
+}
+
+/**
+* Synchronizes the Panel's "xy", "x", and "y" properties with the Panel's position in the DOM. This is primarily used to update position information during drag & drop.
+*/
+YAHOO.widget.Overlay.prototype.syncPosition = function() {
+ var pos = YAHOO.util.Dom.getXY(this.element);
+ this.cfg.setProperty("x", pos[0], true);
+ this.cfg.setProperty("y", pos[1], true);
+ this.cfg.setProperty("xy", pos, true);
+}
+
+/**
+* Event handler fired when the resize monitor element is resized.
+*/
+YAHOO.widget.Overlay.prototype.onDomResize = function(e, obj) {
+ YAHOO.widget.Overlay.superclass.onDomResize.call(this, e, obj);
+ this.cfg.refireEvent("iframe");
+}
+
+/**
+* Removes the Overlay element from the DOM and sets all child elements to null.
+*/
+YAHOO.widget.Overlay.prototype.destroy = function() {
+ if (this.iframe) {
+ this.iframe.parentNode.removeChild(this.iframe);
+ }
+
+ this.iframe = null;
+
+ YAHOO.widget.Overlay.superclass.destroy.call(this);
+};
+
+/**
+* Returns a string representation of the object.
+* @type string
+*/
+YAHOO.widget.Overlay.prototype.toString = function() {
+ return "Overlay " + this.id;
+}
+
+/**
+* A singleton CustomEvent used for reacting to the DOM event for window scroll
+* @type YAHOO.util.CustomEvent
+*/
+YAHOO.widget.Overlay.windowScrollEvent = new YAHOO.util.CustomEvent("windowScroll");
+
+/**
+* A singleton CustomEvent used for reacting to the DOM event for window resize
+* @type YAHOO.util.CustomEvent
+*/
+YAHOO.widget.Overlay.windowResizeEvent = new YAHOO.util.CustomEvent("windowResize");
+
+/**
+* The DOM event handler used to fire the CustomEvent for window scroll
+* @type Function
+*/
+YAHOO.widget.Overlay.windowScrollHandler = function(e) {
+ YAHOO.widget.Overlay.windowScrollEvent.fire();
+}
+
+/**
+* The DOM event handler used to fire the CustomEvent for window resize
+* @type Function
+*/
+YAHOO.widget.Overlay.windowResizeHandler = function(e) {
+ YAHOO.widget.Overlay.windowResizeEvent.fire();
+}
+
+/**
+* @private
+*/
+YAHOO.widget.Overlay._initialized == null;
+
+if (YAHOO.widget.Overlay._initialized == null) {
+ YAHOO.util.Event.addListener(window, "scroll", YAHOO.widget.Overlay.windowScrollHandler);
+ YAHOO.util.Event.addListener(window, "resize", YAHOO.widget.Overlay.windowResizeHandler);
+
+ YAHOO.widget.Overlay._initialized = true;
+}
+
+/**
+* @class
+* OverlayManager is used for maintaining the focus status of multiple Overlays.
+* @param {Array} overlays Optional. A collection of Overlays to register with the manager.
+* @param {object} userConfig The object literal representing the user configuration of the OverlayManager
+* @constructor
+*/
+YAHOO.widget.OverlayManager = function(userConfig) {
+ this.init(userConfig);
+}
+
+/**
+* The CSS class representing a focused Overlay
+* @type string
+*/
+YAHOO.widget.OverlayManager.CSS_FOCUSED = "focused";
+
+YAHOO.widget.OverlayManager.prototype = {
+
+ constructor : YAHOO.widget.OverlayManager,
+
+ /**
+ * The array of Overlays that are currently registered
+ * @type Array
+ */
+ overlays : null,
+
+ /**
+ * Initializes the default configuration of the OverlayManager
+ */
+ initDefaultConfig : function() {
+ this.cfg.addProperty("overlays", { suppressEvent:true } );
+ this.cfg.addProperty("focusevent", { value:"mousedown" } );
+ },
+
+ /**
+ * Returns the currently focused Overlay
+ * @return {Overlay} The currently focused Overlay
+ */
+ getActive : function() {},
+
+ /**
+ * Focuses the specified Overlay
+ * @param {Overlay} The Overlay to focus
+ * @param {string} The id of the Overlay to focus
+ */
+ focus : function(overlay) {},
+
+ /**
+ * Removes the specified Overlay from the manager
+ * @param {Overlay} The Overlay to remove
+ * @param {string} The id of the Overlay to remove
+ */
+ remove: function(overlay) {},
+
+ /**
+ * Removes focus from all registered Overlays in the manager
+ */
+ blurAll : function() {},
+
+ /**
+ * Initializes the OverlayManager
+ * @param {Array} overlays Optional. A collection of Overlays to register with the manager.
+ * @param {object} userConfig The object literal representing the user configuration of the OverlayManager
+ */
+ init : function(userConfig) {
+ this.cfg = new YAHOO.util.Config(this);
+
+ this.initDefaultConfig();
+
+ if (userConfig) {
+ this.cfg.applyConfig(userConfig, true);
+ }
+ this.cfg.fireQueue();
+
+ var activeOverlay = null;
+
+ this.getActive = function() {
+ return activeOverlay;
+ }
+
+ this.focus = function(overlay) {
+ var o = this.find(overlay);
+ if (o) {
+ this.blurAll();
+ activeOverlay = o;
+ YAHOO.util.Dom.addClass(activeOverlay.element, YAHOO.widget.OverlayManager.CSS_FOCUSED);
+ this.overlays.sort(this.compareZIndexDesc);
+ var topZIndex = YAHOO.util.Dom.getStyle(this.overlays[0].element, "zIndex");
+ if (! isNaN(topZIndex) && this.overlays[0] != overlay) {
+ activeOverlay.cfg.setProperty("zIndex", (parseInt(topZIndex) + 1));
+ }
+ this.overlays.sort(this.compareZIndexDesc);
+ }
+ }
+
+ this.remove = function(overlay) {
+ var o = this.find(overlay);
+ if (o) {
+ var originalZ = YAHOO.util.Dom.getStyle(o.element, "zIndex");
+ o.cfg.setProperty("zIndex", -1000, true);
+ this.overlays.sort(this.compareZIndexDesc);
+ this.overlays = this.overlays.slice(0, this.overlays.length-1);
+ o.cfg.setProperty("zIndex", originalZ, true);
+
+ o.cfg.setProperty("manager", null);
+ o.focusEvent = null
+ o.blurEvent = null;
+ o.focus = null;
+ o.blur = null;
+ }
+ }
+
+ this.blurAll = function() {
+ activeOverlay = null;
+ for (var o=0;o<this.overlays.length;o++) {
+ YAHOO.util.Dom.removeClass(this.overlays[o].element, YAHOO.widget.OverlayManager.CSS_FOCUSED);
+ }
+ }
+
+ var overlays = this.cfg.getProperty("overlays");
+
+ if (! this.overlays) {
+ this.overlays = new Array();
+ }
+
+ if (overlays) {
+ this.register(overlays);
+ this.overlays.sort(this.compareZIndexDesc);
+ }
+ },
+
+ /**
+ * Registers an Overlay or an array of Overlays with the manager. Upon registration, the Overlay receives functions for focus and blur, along with CustomEvents for each.
+ * @param {Overlay} overlay An Overlay to register with the manager.
+ * @param {Overlay[]} overlay An array of Overlays to register with the manager.
+ * @return {boolean} True if any Overlays are registered.
+ */
+ register : function(overlay) {
+ if (overlay instanceof YAHOO.widget.Overlay) {
+ overlay.cfg.addProperty("manager", { value:this } );
+
+ overlay.focusEvent = new YAHOO.util.CustomEvent("focus");
+ overlay.blurEvent = new YAHOO.util.CustomEvent("blur");
+
+ var mgr=this;
+
+ overlay.focus = function() {
+ mgr.focus(this);
+ this.focusEvent.fire();
+ }
+
+ overlay.blur = function() {
+ mgr.blurAll();
+ this.blurEvent.fire();
+ }
+
+ var focusOnDomEvent = function(e,obj) {
+ overlay.focus();
+ }
+
+ var focusevent = this.cfg.getProperty("focusevent");
+ YAHOO.util.Event.addListener(overlay.element,focusevent,focusOnDomEvent,this,true);
+
+ var zIndex = YAHOO.util.Dom.getStyle(overlay.element, "zIndex");
+ if (! isNaN(zIndex)) {
+ overlay.cfg.setProperty("zIndex", parseInt(zIndex));
+ } else {
+ overlay.cfg.setProperty("zIndex", 0);
+ }
+
+ this.overlays.push(overlay);
+ return true;
+ } else if (overlay instanceof Array) {
+ var regcount = 0;
+ for (var i=0;i<overlay.length;i++) {
+ if (this.register(overlay[i])) {
+ regcount++;
+ }
+ }
+ if (regcount > 0) {
+ return true;
+ }
+ } else {
+ return false;
+ }
+ },
+
+ /**
+ * Attempts to locate an Overlay by instance or ID.
+ * @param {Overlay} overlay An Overlay to locate within the manager
+ * @param {string} overlay An Overlay id to locate within the manager
+ * @return {Overlay} The requested Overlay, if found, or null if it cannot be located.
+ */
+ find : function(overlay) {
+ if (overlay instanceof YAHOO.widget.Overlay) {
+ for (var o=0;o<this.overlays.length;o++) {
+ if (this.overlays[o] == overlay) {
+ return this.overlays[o];
+ }
+ }
+ } else if (typeof overlay == "string") {
+ for (var o=0;o<this.overlays.length;o++) {
+ if (this.overlays[o].id == overlay) {
+ return this.overlays[o];
+ }
+ }
+ }
+ return null;
+ },
+
+ /**
+ * Used for sorting the manager's Overlays by z-index.
+ * @private
+ */
+ compareZIndexDesc : function(o1, o2) {
+ var zIndex1 = o1.cfg.getProperty("zIndex");
+ var zIndex2 = o2.cfg.getProperty("zIndex");
+
+ if (zIndex1 > zIndex2) {
+ return -1;
+ } else if (zIndex1 < zIndex2) {
+ return 1;
+ } else {
+ return 0;
+ }
+ },
+
+ /**
+ * Shows all Overlays in the manager.
+ */
+ showAll : function() {
+ for (var o=0;o<this.overlays.length;o++) {
+ this.overlays[o].show();
+ }
+ },
+
+ /**
+ * Hides all Overlays in the manager.
+ */
+ hideAll : function() {
+ for (var o=0;o<this.overlays.length;o++) {
+ this.overlays[o].hide();
+ }
+ },
+
+ /**
+ * Returns a string representation of the object.
+ * @type string
+ */
+ toString : function() {
+ return "OverlayManager";
+ }
+
+}
+
+/**
+* KeyListener is a utility that provides an easy interface for listening for keydown/keyup events fired against DOM elements.
+* @param {Element} attachTo The element or element ID to which the key event should be attached
+* @param {string} attachTo The element or element ID to which the key event should be attached
+* @param {object} keyData The object literal representing the key(s) to detect. Possible attributes are shift(boolean), alt(boolean), ctrl(boolean) and keys(either an int or an array of ints representing keycodes).
+* @param {function} handler The CustomEvent handler to fire when the key event is detected
+* @param {object} handler An object literal representing the handler.
+* @param {string} event Optional. The event (keydown or keyup) to listen for. Defaults automatically to keydown.
+* @constructor
+*/
+YAHOO.util.KeyListener = function(attachTo, keyData, handler, event) {
+ if (! attachTo) {
+ YAHOO.log("No attachTo element specified", "error");
+ }
+ if (! keyData) {
+ YAHOO.log("No keyData specified", "error");
+ }
+ if (! handler) {
+ YAHOO.log("No handler specified", "error");
+ }
+
+ if (! event) {
+ event = YAHOO.util.KeyListener.KEYDOWN;
+ }
+
+ var keyEvent = new YAHOO.util.CustomEvent("keyPressed");
+
+ this.enabledEvent = new YAHOO.util.CustomEvent("enabled");
+ this.disabledEvent = new YAHOO.util.CustomEvent("disabled");
+
+ if (typeof attachTo == 'string') {
+ attachTo = document.getElementById(attachTo);
+ }
+
+ if (typeof handler == 'function') {
+ keyEvent.subscribe(handler);
+ } else {
+ keyEvent.subscribe(handler.fn, handler.scope, handler.correctScope);
+ }
+
+ /**
+ * Handles the key event when a key is pressed.
+ * @private
+ */
+ function handleKeyPress(e, obj) {
+ var keyPressed = e.charCode || e.keyCode;
+
+ if (! keyData.shift) keyData.shift = false;
+ if (! keyData.alt) keyData.alt = false;
+ if (! keyData.ctrl) keyData.ctrl = false;
+
+ // check held down modifying keys first
+ if (e.shiftKey == keyData.shift &&
+ e.altKey == keyData.alt &&
+ e.ctrlKey == keyData.ctrl) { // if we pass this, all modifiers match
+
+ if (keyData.keys instanceof Array) {
+ for (var i=0;i<keyData.keys.length;i++) {
+ if (keyPressed == keyData.keys[i]) {
+ keyEvent.fire(keyPressed, e);
+ break;
+ }
+ }
+ } else {
+ if (keyPressed == keyData.keys) {
+ keyEvent.fire(keyPressed, e);
+ }
+ }
+ }
+ }
+
+ this.enable = function() {
+ if (! this.enabled) {
+ YAHOO.util.Event.addListener(attachTo, event, handleKeyPress);
+ this.enabledEvent.fire(keyData);
+ }
+ this.enabled = true;
+ }
+
+ this.disable = function() {
+ if (this.enabled) {
+ YAHOO.util.Event.removeListener(attachTo, event, handleKeyPress);
+ this.disabledEvent.fire(keyData);
+ }
+ this.enabled = false;
+ }
+
+ /**
+ * Returns a string representation of the object.
+ * @type string
+ */
+ this.toString = function() {
+ return "KeyListener [" + keyData.keys + "] " + attachTo.tagName + (attachTo.id ? "[" + attachTo.id + "]" : "");
+ }
+
+}
+
+/**
+* Constant representing the DOM "keydown" event.
+* @final
+*/
+YAHOO.util.KeyListener.KEYDOWN = "keydown";
+
+/**
+* Constant representing the DOM "keyup" event.
+* @final
+*/
+YAHOO.util.KeyListener.KEYUP = "keyup";
+
+/**
+* Boolean indicating the enabled/disabled state of the Tooltip
+* @type Booleam
+*/
+YAHOO.util.KeyListener.prototype.enabled = null;
+
+/**
+* Enables the KeyListener, by dynamically attaching the key event to the appropriate DOM element.
+*/
+YAHOO.util.KeyListener.prototype.enable = function() {};
+
+/**
+* Disables the KeyListener, by dynamically removing the key event from the appropriate DOM element.
+*/
+YAHOO.util.KeyListener.prototype.disable = function() {};
+
+/**
+* CustomEvent fired when the KeyListener is enabled
+* args: keyData
+* @type YAHOO.util.CustomEvent
+*/
+YAHOO.util.KeyListener.prototype.enabledEvent = null;
+
+/**
+* CustomEvent fired when the KeyListener is disabled
+* args: keyData
+* @type YAHOO.util.CustomEvent
+*/
+YAHOO.util.KeyListener.prototype.disabledEvent = null;
+
+/**
+* @class
+* Tooltip is an implementation of Overlay that behaves like an OS tooltip, displaying when the user mouses over a particular element, and disappearing on mouse out.
+* @param {string} el The element ID representing the Tooltip <em>OR</em>
+* @param {Element} el The element representing the Tooltip
+* @param {object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details.
+* @constructor
+*/
+YAHOO.widget.Tooltip = function(el, userConfig) {
+ YAHOO.widget.Tooltip.superclass.constructor.call(this, el, userConfig);
+}
+
+YAHOO.extend(YAHOO.widget.Tooltip, YAHOO.widget.Overlay);
+
+YAHOO.widget.Tooltip.logger = new YAHOO.widget.LogWriter("Tooltip");
+
+/**
+* Constant representing the Tooltip CSS class
+* @type string
+* @final
+*/
+YAHOO.widget.Tooltip.CSS_TOOLTIP = "tt";
+
+/**
+* The Tooltip initialization method. This method is automatically called by the constructor. A Tooltip is automatically rendered by the init method, and it also is set to be invisible by default, and constrained to viewport by default as well.
+* @param {string} el The element ID representing the Tooltip <em>OR</em>
+* @param {Element} el The element representing the Tooltip
+* @param {object} userConfig The configuration object literal containing the configuration that should be set for this Tooltip. See configuration documentation for more details.
+*/
+YAHOO.widget.Tooltip.prototype.init = function(el, userConfig) {
+ this.logger = YAHOO.widget.Tooltip.logger;
+
+ if (document.readyState && document.readyState != "complete") {
+ var deferredInit = function() {
+ this.init(el, userConfig);
+ }
+ YAHOO.util.Event.addListener(window, "load", deferredInit, this, true);
+ } else {
+ YAHOO.widget.Tooltip.superclass.init.call(this, el);
+
+ this.beforeInitEvent.fire(YAHOO.widget.Tooltip);
+
+ YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Tooltip.CSS_TOOLTIP);
+
+ if (userConfig) {
+ this.cfg.applyConfig(userConfig, true);
+ }
+
+ this.cfg.queueProperty("visible",false);
+ this.cfg.queueProperty("constraintoviewport",true);
+
+ this.setBody("");
+ this.render(this.cfg.getProperty("container"));
+
+ this.initEvent.fire(YAHOO.widget.Tooltip);
+ }
+}
+
+/**
+* Initializes the class's configurable properties which can be changed using the Overlay's Config object (cfg).
+*/
+YAHOO.widget.Tooltip.prototype.initDefaultConfig = function() {
+ YAHOO.widget.Tooltip.superclass.initDefaultConfig.call(this);
+
+ this.cfg.addProperty("preventoverlap", { value:true, validator:this.cfg.checkBoolean, supercedes:["x","y","xy"] } );
+
+ this.cfg.addProperty("showdelay", { value:200, handler:this.configShowDelay, validator:this.cfg.checkNumber } );
+ this.cfg.addProperty("autodismissdelay", { value:5000, handler:this.configAutoDismissDelay, validator:this.cfg.checkNumber } );
+ this.cfg.addProperty("hidedelay", { value:250, handler:this.configHideDelay, validator:this.cfg.checkNumber } );
+
+ this.cfg.addProperty("text", { handler:this.configText, suppressEvent:true } );
+ this.cfg.addProperty("container", { value:document.body, handler:this.configContainer } );
+}
+
+// BEGIN BUILT-IN PROPERTY EVENT HANDLERS //
+
+/**
+* The default event handler fired when the "text" property is changed.
+*/
+YAHOO.widget.Tooltip.prototype.configText = function(type, args, obj) {
+ var text = args[0];
+ if (text) {
+ this.setBody(text);
+ }
+}
+
+/**
+* The default event handler fired when the "container" property is changed.
+*/
+YAHOO.widget.Tooltip.prototype.configContainer = function(type, args, obj) {
+ var container = args[0];
+ if (typeof container == 'string') {
+ this.cfg.setProperty("container", document.getElementById(container), true);
+ }
+}
+
+/**
+* The default event handler fired when the "context" property is changed.
+*/
+YAHOO.widget.Tooltip.prototype.configContext = function(type, args, obj) {
+ var context = args[0];
+ if (context) {
+
+ // Normalize parameter into an array
+ if (! (context instanceof Array)) {
+ if (typeof context == "string") {
+ this.cfg.setProperty("context", [document.getElementById(context)], true);
+ } else { // Assuming this is an element
+ this.cfg.setProperty("context", [context], true);
+ }
+ context = this.cfg.getProperty("context");
+ }
+
+
+ // Remove any existing mouseover/mouseout listeners
+ if (this._context) {
+ for (var c=0;c<this._context.length;++c) {
+ var el = this._context[c];
+ YAHOO.util.Event.removeListener(el, "mouseover", this.onContextMouseOver);
+ YAHOO.util.Event.removeListener(el, "mousemove", this.onContextMouseMove);
+ YAHOO.util.Event.removeListener(el, "mouseout", this.onContextMouseOut);
+ }
+ }
+
+ // Add mouseover/mouseout listeners to context elements
+ this._context = context;
+ for (var c=0;c<this._context.length;++c) {
+ var el = this._context[c];
+ YAHOO.util.Event.addListener(el, "mouseover", this.onContextMouseOver, this);
+ YAHOO.util.Event.addListener(el, "mousemove", this.onContextMouseMove, this);
+ YAHOO.util.Event.addListener(el, "mouseout", this.onContextMouseOut, this);
+ }
+ }
+}
+
+// END BUILT-IN PROPERTY EVENT HANDLERS //
+
+// BEGIN BUILT-IN DOM EVENT HANDLERS //
+
+/**
+* The default event handler fired when the user moves the mouse while over the context element.
+* @param {DOMEvent} e The current DOM event
+* @param {object} obj The object argument
+*/
+YAHOO.widget.Tooltip.prototype.onContextMouseMove = function(e, obj) {
+ obj.pageX = YAHOO.util.Event.getPageX(e);
+ obj.pageY = YAHOO.util.Event.getPageY(e);
+
+}
+
+/**
+* The default event handler fired when the user mouses over the context element.
+* @param {DOMEvent} e The current DOM event
+* @param {object} obj The object argument
+*/
+YAHOO.widget.Tooltip.prototype.onContextMouseOver = function(e, obj) {
+
+ if (obj.hideProcId) {
+ clearTimeout(obj.hideProcId);
+ obj.logger.log("Clearing hide timer: " + obj.hideProcId, "time");
+ obj.hideProcId = null;
+ }
+
+ var context = this;
+ YAHOO.util.Event.addListener(context, "mousemove", obj.onContextMouseMove, obj);
+
+ if (context.title) {
+ obj._tempTitle = context.title;
+ context.title = "";
+ }
+
+ /**
+ * The unique process ID associated with the thread responsible for showing the Tooltip.
+ * @type int
+ */
+ obj.showProcId = obj.doShow(e, context);
+ obj.logger.log("Setting show tooltip timeout: " + this.showProcId, "time");
+}
+
+/**
+* The default event handler fired when the user mouses out of the context element.
+* @param {DOMEvent} e The current DOM event
+* @param {object} obj The object argument
+*/
+YAHOO.widget.Tooltip.prototype.onContextMouseOut = function(e, obj) {
+ var el = this;
+
+ if (obj._tempTitle) {
+ el.title = obj._tempTitle;
+ obj._tempTitle = null;
+ }
+
+ if (obj.showProcId) {
+ clearTimeout(obj.showProcId);
+ obj.logger.log("Clearing show timer: " + obj.showProcId, "time");
+ obj.showProcId = null;
+ }
+
+ if (obj.hideProcId) {
+ clearTimeout(obj.hideProcId);
+ obj.logger.log("Clearing hide timer: " + obj.hideProcId, "time");
+ obj.hideProcId = null;
+ }
+
+
+ obj.hideProcId = setTimeout(function() {
+ obj.hide();
+ }, obj.cfg.getProperty("hidedelay"));
+}
+
+// END BUILT-IN DOM EVENT HANDLERS //
+
+/**
+* Processes the showing of the Tooltip by setting the timeout delay and offset of the Tooltip.
+* @param {DOMEvent} e The current DOM event
+* @return {int} The process ID of the timeout function associated with doShow
+*/
+YAHOO.widget.Tooltip.prototype.doShow = function(e, context) {
+
+ var yOffset = 25;
+ if (this.browser == "opera" && context.tagName == "A") {
+ yOffset += 12;
+ }
+
+ var me = this;
+ return setTimeout(
+ function() {
+ if (me._tempTitle) {
+ me.setBody(me._tempTitle);
+ } else {
+ me.cfg.refireEvent("text");
+ }
+
+ me.logger.log("Show tooltip", "time");
+ me.moveTo(me.pageX, me.pageY + yOffset);
+ if (me.cfg.getProperty("preventoverlap")) {
+ me.preventOverlap(me.pageX, me.pageY);
+ }
+
+ YAHOO.util.Event.removeListener(context, "mousemove", me.onContextMouseMove);
+
+ me.show();
+ me.hideProcId = me.doHide();
+ me.logger.log("Hide tooltip time active: " + me.hideProcId, "time");
+ },
+ this.cfg.getProperty("showdelay"));
+}
+
+/**
+* Sets the timeout for the auto-dismiss delay, which by default is 5 seconds, meaning that a tooltip will automatically dismiss itself after 5 seconds of being displayed.
+*/
+YAHOO.widget.Tooltip.prototype.doHide = function() {
+ var me = this;
+ me.logger.log("Setting hide tooltip timeout", "time");
+ return setTimeout(
+ function() {
+ me.logger.log("Hide tooltip", "time");
+ me.hide();
+ },
+ this.cfg.getProperty("autodismissdelay"));
+}
+
+/**
+* Fired when the Tooltip is moved, this event handler is used to prevent the Tooltip from overlapping with its context element.
+*/
+YAHOO.widget.Tooltip.prototype.preventOverlap = function(pageX, pageY) {
+
+ var height = this.element.offsetHeight;
+
+ var elementRegion = YAHOO.util.Dom.getRegion(this.element);
+
+ elementRegion.top -= 5;
+ elementRegion.left -= 5;
+ elementRegion.right += 5;
+ elementRegion.bottom += 5;
+
+ var mousePoint = new YAHOO.util.Point(pageX, pageY);
+
+ this.logger.log("context " + elementRegion, "ttip");
+ this.logger.log("mouse " + mousePoint, "ttip");
+
+ if (elementRegion.contains(mousePoint)) {
+ this.logger.log("OVERLAP", "warn");
+ this.cfg.setProperty("y", (pageY-height-5))
+ }
+}
+
+/**
+* Returns a string representation of the object.
+* @type string
+*/
+YAHOO.widget.Tooltip.prototype.toString = function() {
+ return "Tooltip " + this.id;
+}
+
+/**
+* @class
+* Panel is an implementation of Overlay that behaves like an OS window, with a draggable header and an optional close icon at the top right.
+* @param {string} el The element ID representing the Panel <em>OR</em>
+* @param {Element} el The element representing the Panel
+* @param {object} userConfig The configuration object literal containing the configuration that should be set for this Panel. See configuration documentation for more details.
+* @constructor
+*/
+YAHOO.widget.Panel = function(el, userConfig) {
+ YAHOO.widget.Panel.superclass.constructor.call(this, el, userConfig);
+}
+
+YAHOO.extend(YAHOO.widget.Panel, YAHOO.widget.Overlay);
+
+/**
+* Constant representing the default CSS class used for a Panel
+* @type string
+* @final
+*/
+YAHOO.widget.Panel.CSS_PANEL = "panel";
+
+/**
+* Constant representing the default CSS class used for a Panel's wrapping container
+* @type string
+* @final
+*/
+YAHOO.widget.Panel.CSS_PANEL_CONTAINER = "panel-container";
+
+/**
+* CustomEvent fired after the modality mask is shown
+* args: none
+* @type YAHOO.util.CustomEvent
+*/
+YAHOO.widget.Panel.prototype.showMaskEvent = null;
+
+/**
+* CustomEvent fired after the modality mask is hidden
+* args: none
+* @type YAHOO.util.CustomEvent
+*/
+YAHOO.widget.Panel.prototype.hideMaskEvent = null;
+
+/**
+* The Overlay initialization method, which is executed for Overlay and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present.
+* @param {string} el The element ID representing the Overlay <em>OR</em>
+* @param {Element} el The element representing the Overlay
+* @param {object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details.
+*/
+YAHOO.widget.Panel.prototype.init = function(el, userConfig) {
+ YAHOO.widget.Panel.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level
+
+ this.beforeInitEvent.fire(YAHOO.widget.Panel);
+
+ YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Panel.CSS_PANEL);
+
+ this.buildWrapper();
+
+ if (userConfig) {
+ this.cfg.applyConfig(userConfig, true);
+ }
+
+ this.beforeRenderEvent.subscribe(function() {
+ var draggable = this.cfg.getProperty("draggable");
+ if (draggable) {
+ if (! this.header) {
+ this.setHeader(" ");
+ }
+ }
+ }, this, true);
+
+ this.initEvent.fire(YAHOO.widget.Panel);
+
+}
+
+/**
+* Initializes the custom events for Module which are fired automatically at appropriate times by the Module class.
+*/
+YAHOO.widget.Panel.prototype.initEvents = function() {
+ YAHOO.widget.Panel.superclass.initEvents.call(this);
+
+ this.showMaskEvent = new YAHOO.util.CustomEvent("showMask");
+ this.hideMaskEvent = new YAHOO.util.CustomEvent("hideMask");
+
+ this.dragEvent = new YAHOO.util.CustomEvent("drag");
+}
+
+/**
+* Initializes the class's configurable properties which can be changed using the Panel's Config object (cfg).
+*/
+YAHOO.widget.Panel.prototype.initDefaultConfig = function() {
+ YAHOO.widget.Panel.superclass.initDefaultConfig.call(this);
+
+ // Add panel config properties //
+
+ this.cfg.addProperty("close", { value:true, handler:this.configClose, validator:this.cfg.checkBoolean, supercedes:["visible"] } );
+ this.cfg.addProperty("draggable", { value:true, handler:this.configDraggable, validator:this.cfg.checkBoolean, supercedes:["visible"] } );
+
+ this.cfg.addProperty("underlay", { value:"shadow", handler:this.configUnderlay, supercedes:["visible"] } );
+ this.cfg.addProperty("modal", { value:false, handler:this.configModal, validator:this.cfg.checkBoolean, supercedes:["visible"] } );
+
+ this.cfg.addProperty("keylisteners", { handler:this.configKeyListeners, suppressEvent:true, supercedes:["visible"] } );
+}
+
+// BEGIN BUILT-IN PROPERTY EVENT HANDLERS //
+
+/**
+* The default event handler fired when the "close" property is changed. The method controls the appending or hiding of the close icon at the top right of the Panel.
+*/
+YAHOO.widget.Panel.prototype.configClose = function(type, args, obj) {
+ var val = args[0];
+
+ var doHide = function(e, obj) {
+ obj.hide();
+ }
+
+ if (val) {
+ if (! this.close) {
+ this.close = document.createElement("DIV");
+ YAHOO.util.Dom.addClass(this.close, "close");
+
+ if (this.isSecure) {
+ YAHOO.util.Dom.addClass(this.close, "secure");
+ } else {
+ YAHOO.util.Dom.addClass(this.close, "nonsecure");
+ }
+
+ this.close.innerHTML = " ";
+ this.innerElement.appendChild(this.close);
+ YAHOO.util.Event.addListener(this.close, "click", doHide, this);
+ } else {
+ this.close.style.display = "block";
+ }
+ } else {
+ if (this.close) {
+ this.close.style.display = "none";
+ }
+ }
+}
+
+/**
+* The default event handler fired when the "draggable" property is changed.
+*/
+YAHOO.widget.Panel.prototype.configDraggable = function(type, args, obj) {
+ var val = args[0];
+ if (val) {
+ if (this.header) {
+ YAHOO.util.Dom.setStyle(this.header,"cursor","move");
+ this.registerDragDrop();
+ }
+ } else {
+ if (this.dd) {
+ this.dd.unreg();
+ }
+ if (this.header) {
+ YAHOO.util.Dom.setStyle(this.header,"cursor","auto");
+ }
+ }
+}
+
+/**
+* The default event handler fired when the "underlay" property is changed.
+*/
+YAHOO.widget.Panel.prototype.configUnderlay = function(type, args, obj) {
+ var val = args[0];
+
+ switch (val.toLowerCase()) {
+ case "shadow":
+ YAHOO.util.Dom.removeClass(this.element, "matte");
+ YAHOO.util.Dom.addClass(this.element, "shadow");
+
+ if (! this.underlay) { // create if not already in DOM
+ this.underlay = document.createElement("DIV");
+ this.underlay.className = "underlay";
+ this.underlay.innerHTML = " ";
+ this.element.appendChild(this.underlay);
+ }
+
+ this.sizeUnderlay();
+ break;
+ case "matte":
+ YAHOO.util.Dom.removeClass(this.element, "shadow");
+ YAHOO.util.Dom.addClass(this.element, "matte");
+ break;
+ case "none":
+ default:
+ YAHOO.util.Dom.removeClass(this.element, "shadow");
+ YAHOO.util.Dom.removeClass(this.element, "matte");
+ break;
+ }
+}
+
+/**
+* The default event handler fired when the "modal" property is changed. This handler subscribes or unsubscribes to the show and hide events to handle the display or hide of the modality mask.
+*/
+YAHOO.widget.Panel.prototype.configModal = function(type, args, obj) {
+ var modal = args[0];
+
+ if (modal) {
+ this.buildMask();
+
+ if (! YAHOO.util.Config.alreadySubscribed( this.showEvent, this.showMask, this ) ) {
+ this.showEvent.subscribe(this.showMask, this, true);
+ }
+ if (! YAHOO.util.Config.alreadySubscribed( this.hideEvent, this.hideMask, this) ) {
+ this.hideEvent.subscribe(this.hideMask, this, true);
+ }
+ if (! YAHOO.util.Config.alreadySubscribed( YAHOO.widget.Overlay.windowResizeEvent, this.sizeMask, this ) ) {
+ YAHOO.widget.Overlay.windowResizeEvent.subscribe(this.sizeMask, this, true);
+ }
+ if (! YAHOO.util.Config.alreadySubscribed( YAHOO.widget.Overlay.windowScrollEvent, this.sizeMask, this ) ) {
+ YAHOO.widget.Overlay.windowScrollEvent.subscribe(this.sizeMask, this, true);
+ }
+ } else {
+ this.beforeShowEvent.unsubscribe(this.showMask, this);
+ this.hideEvent.unsubscribe(this.hideMask, this);
+ YAHOO.widget.Overlay.windowResizeEvent.unsubscribe(this.sizeMask);
+ YAHOO.widget.Overlay.windowScrollEvent.unsubscribe(this.sizeMask);
+ }
+}
+
+/**
+* The default event handler fired when the "keylisteners" property is changed.
+*/
+YAHOO.widget.Panel.prototype.configKeyListeners = function(type, args, obj) {
+ var listeners = args[0];
+
+ if (listeners) {
+ if (listeners instanceof Array) {
+ for (var i=0;i<listeners.length;i++) {
+ var listener = listeners[i];
+
+ if (! YAHOO.util.Config.alreadySubscribed(this.showEvent, listener.enable, listener)) {
+ this.showEvent.subscribe(listener.enable, listener, true);
+ }
+ if (! YAHOO.util.Config.alreadySubscribed(this.hideEvent, listener.disable, listener)) {
+ this.hideEvent.subscribe(listener.disable, listener, true);
+ this.destroyEvent.subscribe(listener.disable, listener, true);
+ }
+ }
+ } else {
+ if (! YAHOO.util.Config.alreadySubscribed(this.showEvent, listeners.enable, listeners)) {
+ this.showEvent.subscribe(listeners.enable, listeners, true);
+ }
+ if (! YAHOO.util.Config.alreadySubscribed(this.hideEvent, listeners.disable, listeners)) {
+ this.hideEvent.subscribe(listeners.disable, listeners, true);
+ this.destroyEvent.subscribe(listeners.disable, listeners, true);
+ }
+ }
+ }
+}
+
+// END BUILT-IN PROPERTY EVENT HANDLERS //
+
+
+/**
+* Builds the wrapping container around the Panel that is used for positioning the shadow and matte underlays. The container element is assigned to a local instance variable called container, and the element is reinserted inside of it.
+*/
+YAHOO.widget.Panel.prototype.buildWrapper = function() {
+ var elementParent = this.element.parentNode;
+
+ var elementClone = this.element.cloneNode(true);
+ this.innerElement = elementClone;
+ this.innerElement.style.visibility = "inherit";
+
+ YAHOO.util.Dom.addClass(this.innerElement, YAHOO.widget.Panel.CSS_PANEL);
+
+ var wrapper = document.createElement("DIV");
+ wrapper.className = YAHOO.widget.Panel.CSS_PANEL_CONTAINER;
+ wrapper.id = elementClone.id + "_c";
+
+ wrapper.appendChild(elementClone);
+
+ if (elementParent) {
+ elementParent.replaceChild(wrapper, this.element);
+ }
+
+ this.element = wrapper;
+
+ // Resynchronize the local field references
+
+ var childNodes = this.innerElement.childNodes;
+ if (childNodes) {
+ for (var i=0;i<childNodes.length;i++) {
+ var child = childNodes[i];
+ switch (child.className) {
+ case YAHOO.widget.Module.CSS_HEADER:
+ this.header = child;
+ break;
+ case YAHOO.widget.Module.CSS_BODY:
+ this.body = child;
+ break;
+ case YAHOO.widget.Module.CSS_FOOTER:
+ this.footer = child;
+ break;
+ }
+ }
+ }
+
+ this.initDefaultConfig(); // We've changed the DOM, so the configuration must be re-tooled to get the DOM references right
+}
+
+/**
+* Adjusts the size of the shadow based on the size of the element.
+*/
+YAHOO.widget.Panel.prototype.sizeUnderlay = function() {
+ if (this.underlay && this.browser != "gecko" && this.browser != "safari") {
+ this.underlay.style.width = this.innerElement.offsetWidth + "px";
+ this.underlay.style.height = this.innerElement.offsetHeight + "px";
+ }
+}
+
+/**
+* Event handler fired when the resize monitor element is resized.
+*/
+YAHOO.widget.Panel.prototype.onDomResize = function(e, obj) {
+ YAHOO.widget.Panel.superclass.onDomResize.call(this, e, obj);
+ var me = this;
+ setTimeout(function() {
+ me.sizeUnderlay();
+ }, 0);
+};
+
+/**
+* Registers the Panel's header for drag & drop capability.
+*/
+YAHOO.widget.Panel.prototype.registerDragDrop = function() {
+ if (this.header) {
+ this.dd = new YAHOO.util.DD(this.element.id, this.id);
+
+ if (! this.header.id) {
+ this.header.id = this.id + "_h";
+ }
+
+ var me = this;
+
+ this.dd.startDrag = function() {
+
+ if (me.browser == "ie") {
+ YAHOO.util.Dom.addClass(me.element,"drag");
+ }
+
+ if (me.cfg.getProperty("constraintoviewport")) {
+ var offsetHeight = me.element.offsetHeight;
+ var offsetWidth = me.element.offsetWidth;
+
+ var viewPortWidth = YAHOO.util.Dom.getViewportWidth();
+ var viewPortHeight = YAHOO.util.Dom.getViewportHeight();
+
+ var scrollX = window.scrollX || document.documentElement.scrollLeft;
+ var scrollY = window.scrollY || document.documentElement.scrollTop;
+
+ var topConstraint = scrollY + 10;
+ var leftConstraint = scrollX + 10;
+ var bottomConstraint = scrollY + viewPortHeight - offsetHeight - 10;
+ var rightConstraint = scrollX + viewPortWidth - offsetWidth - 10;
+
+ this.minX = leftConstraint
+ this.maxX = rightConstraint;
+ this.constrainX = true;
+
+ this.minY = topConstraint;
+ this.maxY = bottomConstraint;
+ this.constrainY = true;
+ } else {
+ this.constrainX = false;
+ this.constrainY = false;
+ }
+
+ me.dragEvent.fire("startDrag", arguments);
+ }
+
+ this.dd.onDrag = function() {
+ me.syncPosition();
+ me.cfg.refireEvent("iframe");
+ if (this.platform == "mac" && this.browser == "gecko") {
+ this.showMacGeckoScrollbars();
+ }
+
+ me.dragEvent.fire("onDrag", arguments);
+ }
+
+ this.dd.endDrag = function() {
+ if (me.browser == "ie") {
+ YAHOO.util.Dom.removeClass(me.element,"drag");
+ }
+
+ me.dragEvent.fire("endDrag", arguments);
+ }
+
+ this.dd.setHandleElId(this.header.id);
+ this.dd.addInvalidHandleType("INPUT");
+ this.dd.addInvalidHandleType("SELECT");
+ this.dd.addInvalidHandleType("TEXTAREA");
+ }
+}
+
+/**
+* Builds the mask that is laid over the document when the Panel is configured to be modal.
+*/
+YAHOO.widget.Panel.prototype.buildMask = function() {
+ if (! this.mask) {
+ this.mask = document.createElement("DIV");
+ this.mask.id = this.id + "_mask";
+ this.mask.className = "mask";
+ this.mask.innerHTML = " ";
+
+ var maskClick = function(e, obj) {
+ YAHOO.util.Event.stopEvent(e);
+ }
+
+ YAHOO.util.Event.addListener(this.mask, maskClick, this);
+
+ document.body.appendChild(this.mask);
+ }
+}
+
+/**
+* Hides the modality mask.
+*/
+YAHOO.widget.Panel.prototype.hideMask = function() {
+ if (this.cfg.getProperty("modal") && this.mask) {
+ this.mask.style.display = "none";
+ this.hideMaskEvent.fire();
+ YAHOO.util.Dom.removeClass(document.body, "masked");
+ }
+}
+
+/**
+* Shows the modality mask.
+*/
+YAHOO.widget.Panel.prototype.showMask = function() {
+ if (this.cfg.getProperty("modal") && this.mask) {
+ YAHOO.util.Dom.addClass(document.body, "masked");
+ this.sizeMask();
+ this.mask.style.display = "block";
+ this.showMaskEvent.fire();
+ }
+}
+
+/**
+* Sets the size of the modality mask to cover the entire scrollable area of the document
+*/
+YAHOO.widget.Panel.prototype.sizeMask = function() {
+ if (this.mask) {
+ this.mask.style.height = YAHOO.util.Dom.getDocumentHeight()+"px";
+ this.mask.style.width = YAHOO.util.Dom.getDocumentWidth()+"px";
+ }
+}
+
+/**
+* The default event handler fired when the "height" property is changed.
+*/
+YAHOO.widget.Panel.prototype.configHeight = function(type, args, obj) {
+ var height = args[0];
+ var el = this.innerElement;
+ YAHOO.util.Dom.setStyle(el, "height", height);
+ this.cfg.refireEvent("underlay");
+ this.cfg.refireEvent("iframe");
+}
+
+/**
+* The default event handler fired when the "width" property is changed.
+*/
+YAHOO.widget.Panel.prototype.configWidth = function(type, args, obj) {
+ var width = args[0];
+ var el = this.innerElement;
+ YAHOO.util.Dom.setStyle(el, "width", width);
+ this.cfg.refireEvent("underlay");
+ this.cfg.refireEvent("iframe");
+}
+
+/**
+* Renders the Panel by inserting the elements that are not already in the main Panel into their correct places. Optionally appends the Panel to the specified node prior to the render's execution. NOTE: For Panels without existing markup, the appendToNode argument is REQUIRED. If this argument is ommitted and the current element is not present in the document, the function will return false, indicating that the render was a failure.
+* @param {string} appendToNode The element id to which the Module should be appended to prior to rendering <em>OR</em>
+* @param {Element} appendToNode The element to which the Module should be appended to prior to rendering
+* @return {boolean} Success or failure of the render
+*/
+YAHOO.widget.Panel.prototype.render = function(appendToNode) {
+ return YAHOO.widget.Panel.superclass.render.call(this, appendToNode, this.innerElement);
+}
+
+/**
+* Returns a string representation of the object.
+* @type string
+*/
+YAHOO.widget.Panel.prototype.toString = function() {
+ return "Panel " + this.id;
+}
+
+/**
+* @class
+* Dialog is an implementation of Panel that can be used to submit form data. Built-in functionality for buttons with event handlers is included, and button sets can be build dynamically, or the preincluded ones for Submit/Cancel and OK/Cancel can be utilized. Forms can be processed in 3 ways -- via an asynchronous Connection utility call, a simple form POST or GET, or manually.
+* @param {string} el The element ID representing the Dialog <em>OR</em>
+* @param {Element} el The element representing the Dialog
+* @param {object} userConfig The configuration object literal containing the configuration that should be set for this Dialog. See configuration documentation for more details.
+* @constructor
+*/
+YAHOO.widget.Dialog = function(el, userConfig) {
+ YAHOO.widget.Dialog.superclass.constructor.call(this, el, userConfig);
+}
+
+YAHOO.extend(YAHOO.widget.Dialog, YAHOO.widget.Panel);
+
+/**
+* Constant representing the default CSS class used for a Dialog
+* @type string
+* @final
+*/
+YAHOO.widget.Dialog.CSS_DIALOG = "dialog";
+
+
+/**
+* CustomEvent fired prior to submission
+* @type YAHOO.util.CustomEvent
+*/
+YAHOO.widget.Dialog.prototype.beforeSubmitEvent = null;
+
+/**
+* CustomEvent fired after submission
+* @type YAHOO.util.CustomEvent
+*/
+YAHOO.widget.Dialog.prototype.submitEvent = null;
+
+/**
+* CustomEvent fired prior to manual submission
+* @type YAHOO.util.CustomEvent
+*/
+YAHOO.widget.Dialog.prototype.manualSubmitEvent = null;
+
+/**
+* CustomEvent fired prior to asynchronous submission
+* @type YAHOO.util.CustomEvent
+*/
+YAHOO.widget.Dialog.prototype.asyncSubmitEvent = null;
+
+/**
+* CustomEvent fired prior to form-based submission
+* @type YAHOO.util.CustomEvent
+*/
+YAHOO.widget.Dialog.prototype.formSubmitEvent = null;
+
+/**
+* CustomEvent fired after cancel
+* @type YAHOO.util.CustomEvent
+*/
+YAHOO.widget.Dialog.prototype.cancelEvent = null;
+
+
+/**
+* Initializes the class's configurable properties which can be changed using the Dialog's Config object (cfg).
+*/
+YAHOO.widget.Dialog.prototype.initDefaultConfig = function() {
+ YAHOO.widget.Dialog.superclass.initDefaultConfig.call(this);
+
+ /**
+ * The internally maintained callback object for use with the Connection utility
+ * @type object
+ * @private
+ */
+ this.callback = {
+ success : null,
+ failure : null,
+ argument: null,
+ scope : this
+ }
+
+ this.doSubmit = function() {
+ var method = this.cfg.getProperty("postmethod");
+ switch (method) {
+ case "async":
+ YAHOO.util.Connect.setForm(this.form.name);
+ var cObj = YAHOO.util.Connect.asyncRequest('POST', this.form.action, this.callback);
+ this.asyncSubmitEvent.fire();
+ break;
+ case "form":
+ this.form.submit();
+ this.formSubmitEvent.fire();
+ break;
+ case "none":
+ case "manual":
+ this.manualSubmitEvent.fire();
+ break;
+ }
+ }
+
+ // Add form dialog config properties //
+ this.cfg.addProperty("postmethod", { value:"async", validator:function(val) {
+ if (val != "form" && val != "async" && val != "none" && val != "manual") {
+ return false;
+ } else {
+ return true;
+ }
+ } });
+
+ this.cfg.addProperty("buttons", { value:"none", handler:this.configButtons } );
+}
+
+/**
+* Initializes the custom events for Dialog which are fired automatically at appropriate times by the Dialog class.
+*/
+YAHOO.widget.Dialog.prototype.initEvents = function() {
+ YAHOO.widget.Dialog.superclass.initEvents.call(this);
+
+ this.beforeSubmitEvent = new YAHOO.util.CustomEvent("beforeSubmit");
+ this.submitEvent = new YAHOO.util.CustomEvent("submit");
+
+ this.manualSubmitEvent = new YAHOO.util.CustomEvent("manualSubmit");
+ this.asyncSubmitEvent = new YAHOO.util.CustomEvent("asyncSubmit");
+ this.formSubmitEvent = new YAHOO.util.CustomEvent("formSubmit");
+
+ this.cancelEvent = new YAHOO.util.CustomEvent("cancel");
+}
+
+/**
+* The Dialog initialization method, which is executed for Dialog and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present.
+* @param {string} el The element ID representing the Dialog <em>OR</em>
+* @param {Element} el The element representing the Dialog
+* @param {object} userConfig The configuration object literal containing the configuration that should be set for this Dialog. See configuration documentation for more details.
+*/
+YAHOO.widget.Dialog.prototype.init = function(el, userConfig) {
+ YAHOO.widget.Dialog.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level
+
+ this.beforeInitEvent.fire(YAHOO.widget.Dialog);
+
+ YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Dialog.CSS_DIALOG);
+
+ this.cfg.setProperty("visible", false);
+
+ if (userConfig) {
+ this.cfg.applyConfig(userConfig, true);
+ }
+
+ this.renderEvent.subscribe(this.registerForm, this, true);
+
+ this.showEvent.subscribe(this.focusFirst, this, true);
+ this.beforeHideEvent.subscribe(this.blurButtons, this, true);
+
+ this.beforeRenderEvent.subscribe(function() {
+ var buttonCfg = this.cfg.getProperty("buttons");
+ if (buttonCfg && buttonCfg != "none") {
+ if (! this.footer) {
+ this.setFooter("");
+ }
+ }
+ }, this, true);
+
+ this.initEvent.fire(YAHOO.widget.Dialog);
+}
+
+/**
+* Prepares the Dialog's internal FORM object, creating one if one is not currently present.
+*/
+YAHOO.widget.Dialog.prototype.registerForm = function() {
+ var form = this.element.getElementsByTagName("FORM")[0];
+
+ if (! form) {
+ var formHTML = "<form name=\"frm_" + this.id + "\" action=\"\"></form>";
+ this.body.innerHTML += formHTML;
+ form = this.element.getElementsByTagName("FORM")[0];
+ }
+
+ this.firstFormElement = function() {
+ for (var f=0;f<form.elements.length;f++ ) {
+ var el = form.elements[f];
+ if (el.focus) {
+ if (el.type && el.type != "hidden") {
+ return el;
+ break;
+ }
+ }
+ }
+ return null;
+ }();
+
+ this.lastFormElement = function() {
+ for (var f=form.elements.length-1;f>=0;f-- ) {
+ var el = form.elements[f];
+ if (el.focus) {
+ if (el.type && el.type != "hidden") {
+ return el;
+ break;
+ }
+ }
+ }
+ return null;
+ }();
+
+ this.form = form;
+
+ if (this.cfg.getProperty("modal") && this.form) {
+
+ var me = this;
+
+ var firstElement = this.firstFormElement || this.firstButton;
+ if (firstElement) {
+ this.preventBackTab = new YAHOO.util.KeyListener(firstElement, { shift:true, keys:9 }, {fn:me.focusLast, scope:me, correctScope:true} );
+ this.showEvent.subscribe(this.preventBackTab.enable, this.preventBackTab, true);
+ this.hideEvent.subscribe(this.preventBackTab.disable, this.preventBackTab, true);
+ }
+
+ var lastElement = this.lastButton || this.lastFormElement;
+ if (lastElement) {
+ this.preventTabOut = new YAHOO.util.KeyListener(lastElement, { shift:false, keys:9 }, {fn:me.focusFirst, scope:me, correctScope:true} );
+ this.showEvent.subscribe(this.preventTabOut.enable, this.preventTabOut, true);
+ this.hideEvent.subscribe(this.preventTabOut.disable, this.preventTabOut, true);
+ }
+ }
+}
+
+// BEGIN BUILT-IN PROPERTY EVENT HANDLERS //
+
+/**
+* The default event handler for the "buttons" configuration property
+*/
+YAHOO.widget.Dialog.prototype.configButtons = function(type, args, obj) {
+ var buttons = args[0];
+ if (buttons != "none") {
+ this.buttonSpan = null;
+ this.buttonSpan = document.createElement("SPAN");
+ this.buttonSpan.className = "button-group";
+
+ for (var b=0;b<buttons.length;b++) {
+ var button = buttons[b];
+
+ var htmlButton = document.createElement("BUTTON");
+
+ if (button.isDefault) {
+ htmlButton.className = "default";
+ this.defaultHtmlButton = htmlButton;
+ }
+
+ htmlButton.appendChild(document.createTextNode(button.text));
+ YAHOO.util.Event.addListener(htmlButton, "click", button.handler, this, true);
+
+ this.buttonSpan.appendChild(htmlButton);
+ button.htmlButton = htmlButton;
+
+ if (b == 0) {
+ this.firstButton = button.htmlButton;
+ }
+
+ if (b == (buttons.length-1)) {
+ this.lastButton = button.htmlButton;
+ }
+
+ }
+
+ this.setFooter(this.buttonSpan);
+
+ this.cfg.refireEvent("iframe");
+ this.cfg.refireEvent("underlay");
+ } else { // Do cleanup
+ if (this.buttonSpan) {
+ if (this.buttonSpan.parentNode) {
+ this.buttonSpan.parentNode.removeChild(this.buttonSpan);
+ }
+
+ this.buttonSpan = null;
+ this.firstButton = null;
+ this.lastButton = null;
+ this.defaultHtmlButton = null;
+ }
+ }
+}
+
+/**
+* The default handler fired when the "success" property is changed. Used for asynchronous submission only.
+*/
+YAHOO.widget.Dialog.prototype.configOnSuccess = function(type,args,obj){};
+
+/**
+* The default handler fired when the "failure" property is changed. Used for asynchronous submission only.
+*/
+YAHOO.widget.Dialog.prototype.configOnFailure = function(type,args,obj){};
+
+/**
+* Executes a submission of the form based on the value of the postmethod property.
+*/
+YAHOO.widget.Dialog.prototype.doSubmit = function() {};
+
+/**
+* The default event handler used to focus the first field of the form when the Dialog is shown.
+*/
+YAHOO.widget.Dialog.prototype.focusFirst = function(type,args,obj) {
+ if (args) {
+ var e = args[1];
+ if (e) {
+ YAHOO.util.Event.stopEvent(e);
+ }
+ }
+
+ if (this.firstFormElement) {
+ this.firstFormElement.focus();
+ } else {
+ this.focusDefaultButton();
+ }
+}
+
+/**
+* Sets the focus to the last button in the button or form element in the Dialog
+*/
+YAHOO.widget.Dialog.prototype.focusLast = function(type,args,obj) {
+ if (args) {
+ var e = args[1];
+ if (e) {
+ YAHOO.util.Event.stopEvent(e);
+ }
+ }
+
+ var buttons = this.cfg.getProperty("buttons");
+ if (buttons && buttons instanceof Array) {
+ this.focusLastButton();
+ } else {
+ if (this.lastFormElement) {
+ this.lastFormElement.focus();
+ }
+ }
+}
+
+/**
+* Sets the focus to the button that is designated as the default. By default, his handler is executed when the show event is fired.
+*/
+YAHOO.widget.Dialog.prototype.focusDefaultButton = function() {
+ if (this.defaultHtmlButton) {
+ this.defaultHtmlButton.focus();
+ }
+}
+
+/**
+* Blurs all the html buttons
+*/
+YAHOO.widget.Dialog.prototype.blurButtons = function() {
+ var buttons = this.cfg.getProperty("buttons");
+ if (buttons && buttons instanceof Array) {
+ var html = buttons[0].htmlButton;
+ if (html) {
+ html.blur();
+ }
+ }
+}
+
+/**
+* Sets the focus to the first button in the button list
+*/
+YAHOO.widget.Dialog.prototype.focusFirstButton = function() {
+ var buttons = this.cfg.getProperty("buttons");
+ if (buttons && buttons instanceof Array) {
+ var html = buttons[0].htmlButton;
+ if (html) {
+ html.focus();
+ }
+ }
+}
+
+/**
+* Sets the focus to the first button in the button list
+*/
+YAHOO.widget.Dialog.prototype.focusLastButton = function() {
+ var buttons = this.cfg.getProperty("buttons");
+ if (buttons && buttons instanceof Array) {
+ var html = buttons[buttons.length-1].htmlButton;
+ if (html) {
+ html.focus();
+ }
+ }
+}
+
+// END BUILT-IN PROPERTY EVENT HANDLERS //
+
+/**
+* Built-in function hook for writing a validation function that will be checked for a "true" value prior to a submit. This function, as implemented by default, always returns true, so it should be overridden if validation is necessary.
+*/
+YAHOO.widget.Dialog.prototype.validate = function() {
+ return true;
+}
+
+/**
+* Executes a submit of the Dialog followed by a hide, if validation is successful.
+*/
+YAHOO.widget.Dialog.prototype.submit = function() {
+ if (this.validate()) {
+ this.beforeSubmitEvent.fire();
+ this.doSubmit();
+ this.submitEvent.fire();
+ this.hide();
+ return true;
+ } else {
+ return false;
+ }
+}
+
+/**
+* Executes the cancel of the Dialog followed by a hide.
+*/
+YAHOO.widget.Dialog.prototype.cancel = function() {
+ this.cancelEvent.fire();
+ this.hide();
+}
+
+/**
+* Returns a JSON-compatible data structure representing the data currently contained in the form.
+* @return {object} A JSON object reprsenting the data of the current form.
+*/
+YAHOO.widget.Dialog.prototype.getData = function() {
+ var form = this.form;
+ var data = {};
+
+ if (form) {
+ for (var i in this.form) {
+ var formItem = form[i];
+ if (formItem) {
+ if (formItem.tagName) { // Got a single form item
+ switch (formItem.tagName) {
+ case "INPUT":
+ switch (formItem.type) {
+ case "checkbox":
+ data[i] = formItem.checked;
+ break;
+ case "textbox":
+ case "text":
+ case "hidden":
+ data[i] = formItem.value;
+ break;
+ }
+ break;
+ case "TEXTAREA":
+ data[i] = formItem.value;
+ break;
+ case "SELECT":
+ var val = new Array();
+ for (var x=0;x<formItem.options.length;x++) {
+ var option = formItem.options[x];
+ if (option.selected) {
+ var selval = option.value;
+ if (! selval || selval == "") {
+ selval = option.text;
+ }
+ val[val.length] = selval;
+ }
+ }
+ data[i] = val;
+ break;
+ }
+ } else if (formItem[0] && formItem[0].tagName) { // this is an array of form items
+ switch (formItem[0].tagName) {
+ case "INPUT" :
+ switch (formItem[0].type) {
+ case "radio":
+ for (var r=0; r<formItem.length; r++) {
+ var radio = formItem[r];
+ if (radio.checked) {
+ data[radio.name] = radio.value;
+ break;
+ }
+ }
+ break;
+ case "checkbox":
+ var cbArray = new Array();
+ for (var c=0; c<formItem.length; c++) {
+ var check = formItem[c];
+ if (check.checked) {
+ cbArray[cbArray.length] = check.value;
+ }
+ }
+ data[formItem[0].name] = cbArray;
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ return data;
+}
+
+/**
+* Returns a string representation of the object.
+* @type string
+*/
+YAHOO.widget.Dialog.prototype.toString = function() {
+ return "Dialog " + this.id;
+}
+
+/**
+* @class
+* SimpleDialog is a simple implementation of Dialog that can be used to submit a single value. Forms can be processed in 3 ways -- via an asynchronous Connection utility call, a simple form POST or GET, or manually.
+* @param {string} el The element ID representing the SimpleDialog <em>OR</em>
+* @param {Element} el The element representing the SimpleDialog
+* @param {object} userConfig The configuration object literal containing the configuration that should be set for this SimpleDialog. See configuration documentation for more details.
+* @constructor
+*/
+YAHOO.widget.SimpleDialog = function(el, userConfig) {
+ YAHOO.widget.SimpleDialog.superclass.constructor.call(this, el, userConfig);
+}
+
+YAHOO.extend(YAHOO.widget.SimpleDialog, YAHOO.widget.Dialog);
+
+/**
+* Constant for the standard network icon for a blocking action
+* @type string
+* @final
+*/
+YAHOO.widget.SimpleDialog.ICON_BLOCK = "nt/ic/ut/bsc/blck16_1.gif";
+
+/**
+* Constant for the standard network icon for alarm
+* @type string
+* @final
+*/
+YAHOO.widget.SimpleDialog.ICON_ALARM = "nt/ic/ut/bsc/alrt16_1.gif";
+
+/**
+* Constant for the standard network icon for help
+* @type string
+* @final
+*/
+YAHOO.widget.SimpleDialog.ICON_HELP = "nt/ic/ut/bsc/hlp16_1.gif";
+
+/**
+* Constant for the standard network icon for info
+* @type string
+* @final
+*/
+YAHOO.widget.SimpleDialog.ICON_INFO = "nt/ic/ut/bsc/info16_1.gif";
+
+/**
+* Constant for the standard network icon for warn
+* @type string
+* @final
+*/
+YAHOO.widget.SimpleDialog.ICON_WARN = "nt/ic/ut/bsc/warn16_1.gif";
+
+/**
+* Constant for the standard network icon for a tip
+* @type string
+* @final
+*/
+YAHOO.widget.SimpleDialog.ICON_TIP = "nt/ic/ut/bsc/tip16_1.gif";
+
+/**
+* Constant representing the default CSS class used for a SimpleDialog
+* @type string
+* @final
+*/
+YAHOO.widget.SimpleDialog.CSS_SIMPLEDIALOG = "simple-dialog";
+
+/**
+* Initializes the class's configurable properties which can be changed using the SimpleDialog's Config object (cfg).
+*/
+YAHOO.widget.SimpleDialog.prototype.initDefaultConfig = function() {
+ YAHOO.widget.SimpleDialog.superclass.initDefaultConfig.call(this);
+
+ // Add dialog config properties //
+ this.cfg.addProperty("icon", { value:"none", handler:this.configIcon, suppressEvent:true } );
+ this.cfg.addProperty("text", { value:"", handler:this.configText, suppressEvent:true, supercedes:["icon"] } );
+}
+
+
+/**
+* The SimpleDialog initialization method, which is executed for SimpleDialog and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present.
+* @param {string} el The element ID representing the SimpleDialog <em>OR</em>
+* @param {Element} el The element representing the SimpleDialog
+* @param {object} userConfig The configuration object literal containing the configuration that should be set for this SimpleDialog. See configuration documentation for more details.
+*/
+YAHOO.widget.SimpleDialog.prototype.init = function(el, userConfig) {
+ YAHOO.widget.SimpleDialog.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level
+
+ this.beforeInitEvent.fire(YAHOO.widget.SimpleDialog);
+
+ YAHOO.util.Dom.addClass(this.element, YAHOO.widget.SimpleDialog.CSS_SIMPLEDIALOG);
+
+ this.cfg.queueProperty("postmethod", "manual");
+
+ if (userConfig) {
+ this.cfg.applyConfig(userConfig, true);
+ }
+
+ this.beforeRenderEvent.subscribe(function() {
+ if (! this.body) {
+ this.setBody("");
+ }
+ }, this, true);
+
+ this.initEvent.fire(YAHOO.widget.SimpleDialog);
+
+}
+/**
+* Prepares the SimpleDialog's internal FORM object, creating one if one is not currently present, and adding the value hidden field.
+*/
+YAHOO.widget.SimpleDialog.prototype.registerForm = function() {
+ YAHOO.widget.SimpleDialog.superclass.registerForm.call(this);
+ this.form.innerHTML += "<input type=\"hidden\" name=\"" + this.id + "\" value=\"\"/>";
+}
+
+// BEGIN BUILT-IN PROPERTY EVENT HANDLERS //
+
+/**
+* Fired when the "icon" property is set.
+*/
+YAHOO.widget.SimpleDialog.prototype.configIcon = function(type,args,obj) {
+ var icon = args[0];
+ if (icon && icon != "none") {
+ var iconHTML = "<img src=\"" + this.imageRoot + icon + "\" class=\"icon\" />";
+ this.body.innerHTML = iconHTML + this.body.innerHTML;
+ }
+}
+
+/**
+* Fired when the "text" property is set.
+*/
+YAHOO.widget.SimpleDialog.prototype.configText = function(type,args,obj) {
+ var text = args[0];
+ if (text) {
+ this.setBody(text);
+ this.cfg.refireEvent("icon");
+ }
+}
+// END BUILT-IN PROPERTY EVENT HANDLERS //
+
+/**
+* Returns a string representation of the object.
+* @type string
+*/
+YAHOO.widget.SimpleDialog.prototype.toString = function() {
+ return "SimpleDialog " + this.id;
+}
+
+/**
+* @class
+* ContainerEffect encapsulates animation transitions that are executed when an Overlay is shown or hidden.
+* @param {Overlay} overlay The Overlay that the animation should be associated with
+* @param {object} attrIn The object literal representing the animation arguments to be used for the animate-in transition. The arguments for this literal are: attributes(object, see YAHOO.util.Anim for description), duration(float), and method(i.e. YAHOO.util.Easing.easeIn).
+* @param {object} attrOut The object literal representing the animation arguments to be used for the animate-out transition. The arguments for this literal are: attributes(object, see YAHOO.util.Anim for description), duration(float), and method(i.e. YAHOO.util.Easing.easeIn).
+* @param {Element} targetElement Optional. The target element that should be animated during the transition. Defaults to overlay.element.
+* @param {class} Optional. The animation class to instantiate. Defaults to YAHOO.util.Anim. Other options include YAHOO.util.Motion.
+* @constructor
+*/
+YAHOO.widget.ContainerEffect = function(overlay, attrIn, attrOut, targetElement, animClass) {
+ if (! animClass) {
+ animClass = YAHOO.util.Anim;
+ }
+
+ /**
+ * The overlay to animate
+ */
+ this.overlay = overlay;
+ /**
+ * The animation attributes to use when transitioning into view
+ */
+ this.attrIn = attrIn;
+ /**
+ * The animation attributes to use when transitioning out of view
+ */
+ this.attrOut = attrOut;
+ /**
+ * The target element to be animated
+ */
+ this.targetElement = targetElement || overlay.element;
+ /**
+ * The animation class to use for animating the overlay
+ */
+ this.animClass = animClass;
+}
+
+/**
+* Initializes the animation classes and events.
+*/
+YAHOO.widget.ContainerEffect.prototype.init = function() {
+ this.beforeAnimateInEvent = new YAHOO.util.CustomEvent("beforeAnimateIn");
+ this.beforeAnimateOutEvent = new YAHOO.util.CustomEvent("beforeAnimateOut");
+
+ this.animateInCompleteEvent = new YAHOO.util.CustomEvent("animateInComplete");
+ this.animateOutCompleteEvent = new YAHOO.util.CustomEvent("animateOutComplete");
+
+ this.animIn = new this.animClass(this.targetElement, this.attrIn.attributes, this.attrIn.duration, this.attrIn.method);
+ this.animIn.onStart.subscribe(this.handleStartAnimateIn, this);
+ this.animIn.onTween.subscribe(this.handleTweenAnimateIn, this);
+ this.animIn.onComplete.subscribe(this.handleCompleteAnimateIn, this);
+
+ this.animOut = new this.animClass(this.targetElement, this.attrOut.attributes, this.attrOut.duration, this.attrOut.method);
+ this.animOut.onStart.subscribe(this.handleStartAnimateOut, this);
+ this.animOut.onTween.subscribe(this.handleTweenAnimateOut, this);
+ this.animOut.onComplete.subscribe(this.handleCompleteAnimateOut, this);
+}
+
+/**
+* Triggers the in-animation.
+*/
+YAHOO.widget.ContainerEffect.prototype.animateIn = function() {
+ this.beforeAnimateInEvent.fire();
+ this.animIn.animate();
+}
+
+/**
+* Triggers the out-animation.
+*/
+YAHOO.widget.ContainerEffect.prototype.animateOut = function() {
+ this.beforeAnimateOutEvent.fire();
+ this.animOut.animate();
+}
+
+/**
+* The default onStart handler for the in-animation.
+*/
+YAHOO.widget.ContainerEffect.prototype.handleStartAnimateIn = function(type, args, obj) { }
+/**
+* The default onTween handler for the in-animation.
+*/
+YAHOO.widget.ContainerEffect.prototype.handleTweenAnimateIn = function(type, args, obj) { }
+/**
+* The default onComplete handler for the in-animation.
+*/
+YAHOO.widget.ContainerEffect.prototype.handleCompleteAnimateIn = function(type, args, obj) { }
+
+/**
+* The default onStart handler for the out-animation.
+*/
+YAHOO.widget.ContainerEffect.prototype.handleStartAnimateOut = function(type, args, obj) { }
+/**
+* The default onTween handler for the out-animation.
+*/
+YAHOO.widget.ContainerEffect.prototype.handleTweenAnimateOut = function(type, args, obj) { }
+/**
+* The default onComplete handler for the out-animation.
+*/
+YAHOO.widget.ContainerEffect.prototype.handleCompleteAnimateOut = function(type, args, obj) { }
+
+/**
+* Returns a string representation of the object.
+* @type string
+*/
+YAHOO.widget.ContainerEffect.prototype.toString = function() {
+ var output = "ContainerEffect";
+ if (this.overlay) {
+ output += " [" + this.overlay.toString() + "]";
+ }
+ return output;
+}
+
+/**
+* A pre-configured ContainerEffect instance that can be used for fading an overlay in and out.
+* @param {Overlay} The Overlay object to animate
+* @param {float} The duration of the animation
+* @type ContainerEffect
+*/
+YAHOO.widget.ContainerEffect.FADE = function(overlay, dur) {
+ var fade = new YAHOO.widget.ContainerEffect(overlay, { attributes:{opacity: {from:0, to:1}}, duration:dur, method:YAHOO.util.Easing.easeIn }, { attributes:{opacity: {to:0}}, duration:dur, method:YAHOO.util.Easing.easeOut}, overlay.element );
+
+ fade.handleStartAnimateIn = function(type,args,obj) {
+ YAHOO.util.Dom.addClass(obj.overlay.element, "hide-select");
+
+ if (! obj.overlay.underlay) {
+ obj.overlay.cfg.refireEvent("underlay");
+ }
+
+ if (obj.overlay.underlay) {
+ obj.initialUnderlayOpacity = YAHOO.util.Dom.getStyle(obj.overlay.underlay, "opacity");
+ obj.overlay.underlay.style.filter = null;
+ }
+
+ YAHOO.util.Dom.setStyle(obj.overlay.element, "visibility", "visible");
+ YAHOO.util.Dom.setStyle(obj.overlay.element, "opacity", 0);
+ }
+
+ fade.handleCompleteAnimateIn = function(type,args,obj) {
+ YAHOO.util.Dom.removeClass(obj.overlay.element, "hide-select");
+
+ if (obj.overlay.element.style.filter) {
+ obj.overlay.element.style.filter = null;
+ }
+
+ if (obj.overlay.underlay) {
+ YAHOO.util.Dom.setStyle(obj.overlay.underlay, "opacity", obj.initialUnderlayOpacity);
+ }
+
+ obj.overlay.cfg.refireEvent("iframe");
+ obj.animateInCompleteEvent.fire();
+ }
+
+ fade.handleStartAnimateOut = function(type, args, obj) {
+ YAHOO.util.Dom.addClass(obj.overlay.element, "hide-select");
+
+ if (obj.overlay.underlay) {
+ obj.overlay.underlay.style.filter = null;
+ }
+ }
+
+ fade.handleCompleteAnimateOut = function(type, args, obj) {
+ YAHOO.util.Dom.removeClass(obj.overlay.element, "hide-select");
+ if (obj.overlay.element.style.filter) {
+ obj.overlay.element.style.filter = null;
+ }
+ YAHOO.util.Dom.setStyle(obj.overlay.element, "visibility", "hidden");
+ YAHOO.util.Dom.setStyle(obj.overlay.element, "opacity", 1);
+
+ obj.overlay.cfg.refireEvent("iframe");
+
+ obj.animateOutCompleteEvent.fire();
+ };
+
+ fade.init();
+ return fade;
+};
+
+
+/**
+* A pre-configured ContainerEffect instance that can be used for sliding an overlay in and out.
+* @param {Overlay} The Overlay object to animate
+* @param {float} The duration of the animation
+* @type ContainerEffect
+*/
+YAHOO.widget.ContainerEffect.SLIDE = function(overlay, dur) {
+ var x = overlay.cfg.getProperty("x") || YAHOO.util.Dom.getX(overlay.element);
+ var y = overlay.cfg.getProperty("y") || YAHOO.util.Dom.getY(overlay.element);
+
+ var clientWidth = YAHOO.util.Dom.getClientWidth();
+ var offsetWidth = overlay.element.offsetWidth;
+
+ var slide = new YAHOO.widget.ContainerEffect(overlay, {
+ attributes:{ points: { to:[x, y] } },
+ duration:dur,
+ method:YAHOO.util.Easing.easeIn
+ },
+ {
+ attributes:{ points: { to:[(clientWidth+25), y] } },
+ duration:dur,
+ method:YAHOO.util.Easing.easeOut
+ },
+ overlay.element,
+ YAHOO.util.Motion
+ );
+
+ slide.handleStartAnimateIn = function(type,args,obj) {
+ obj.overlay.element.style.left = (-25-offsetWidth) + "px";
+ obj.overlay.element.style.top = y + "px";
+ }
+
+ slide.handleTweenAnimateIn = function(type, args, obj) {
+
+
+ var pos = YAHOO.util.Dom.getXY(obj.overlay.element);
+
+ var currentX = pos[0];
+ var currentY = pos[1];
+
+ if (YAHOO.util.Dom.getStyle(obj.overlay.element, "visibility") == "hidden" && currentX < x) {
+ YAHOO.util.Dom.setStyle(obj.overlay.element, "visibility", "visible");
+ }
+
+ obj.overlay.cfg.setProperty("xy", [currentX,currentY], true);
+ obj.overlay.cfg.refireEvent("iframe");
+ }
+
+ slide.handleCompleteAnimateIn = function(type, args, obj) {
+ obj.overlay.cfg.setProperty("xy", [x,y], true);
+ obj.startX = x;
+ obj.startY = y;
+ obj.overlay.cfg.refireEvent("iframe");
+ obj.animateInCompleteEvent.fire();
+ }
+
+ slide.handleStartAnimateOut = function(type, args, obj) {
+ var clientWidth = YAHOO.util.Dom.getViewportWidth();
+
+ var pos = YAHOO.util.Dom.getXY(obj.overlay.element);
+
+ var x = pos[0];
+ var y = pos[1];
+
+ var currentTo = obj.animOut.attributes.points.to;
+ obj.animOut.attributes.points.to = [(clientWidth+25), y];
+ }
+
+ slide.handleTweenAnimateOut = function(type, args, obj) {
+ var pos = YAHOO.util.Dom.getXY(obj.overlay.element);
+
+ var x = pos[0];
+ var y = pos[1];
+
+ obj.overlay.cfg.setProperty("xy", [x,y], true);
+ obj.overlay.cfg.refireEvent("iframe");
+ }
+
+ slide.handleCompleteAnimateOut = function(type, args, obj) {
+ YAHOO.util.Dom.setStyle(obj.overlay.element, "visibility", "hidden");
+ var offsetWidth = obj.overlay.element.offsetWidth;
+
+ obj.overlay.cfg.setProperty("xy", [x,y]);
+ obj.animateOutCompleteEvent.fire();
+ };
+
+ slide.init();
+ return slide;
+}
\ No newline at end of file
Added: branches/tomek/portal-dnd/dndRenderer.war/js/container/container-min.js
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/container/container-min.js 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/container/container-min.js 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,292 @@
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+Version 0.11.1
+*/
+YAHOO.util.Config=function(owner){if(owner){this.init(owner);}}
+YAHOO.util.Config.prototype={owner:null,configChangedEvent:null,queueInProgress:false,addProperty:function(key,propertyObject){},getConfig:function(){},getProperty:function(key){},resetProperty:function(key){},setProperty:function(key,value,silent){},queueProperty:function(key,value){},refireEvent:function(key){},applyConfig:function(userConfig,init){},refresh:function(){},fireQueue:function(){},subscribeToConfigEvent:function(key,handler,obj,override){},unsubscribeFromConfigEvent:function(key,handler,obj){},checkBoolean:function(val){if(typeof val=='boolean'){return true;}else{return false;}},checkNumber:function(val){if(isNaN(val)){return false;}else{return true;}}}
+YAHOO.util.Config.prototype.init=function(owner){this.owner=owner;this.configChangedEvent=new YAHOO.util.CustomEvent("configChanged");this.queueInProgress=false;var config={};var initialConfig={};var eventQueue=[];var fireEvent=function(key,value){key=key.toLowerCase();var property=config[key];if(typeof property!='undefined'&&property.event){property.event.fire(value);}}
+this.addProperty=function(key,propertyObject){key=key.toLowerCase();config[key]=propertyObject;propertyObject.event=new YAHOO.util.CustomEvent(key);propertyObject.key=key;if(propertyObject.handler){propertyObject.event.subscribe(propertyObject.handler,this.owner,true);}
+this.setProperty(key,propertyObject.value,true);if(!propertyObject.suppressEvent){this.queueProperty(key,propertyObject.value);}}
+this.getConfig=function(){var cfg={};for(var prop in config){var property=config[prop]
+if(typeof property!='undefined'&&property.event){cfg[prop]=property.value;}}
+return cfg;}
+this.getProperty=function(key){key=key.toLowerCase();var property=config[key];if(typeof property!='undefined'&&property.event){return property.value;}else{return undefined;}}
+this.resetProperty=function(key){key=key.toLowerCase();var property=config[key];if(typeof property!='undefined'&&property.event){this.setProperty(key,initialConfig[key].value);}else{return undefined;}}
+this.setProperty=function(key,value,silent){key=key.toLowerCase();if(this.queueInProgress&&!silent){this.queueProperty(key,value);return true;}else{var property=config[key];if(typeof property!='undefined'&&property.event){if(property.validator&&!property.validator(value)){return false;}else{property.value=value;if(!silent){fireEvent(key,value);this.configChangedEvent.fire([key,value]);}
+return true;}}else{return false;}}}
+this.queueProperty=function(key,value){key=key.toLowerCase();var property=config[key];if(typeof property!='undefined'&&property.event){if(typeof value!='undefined'&&property.validator&&!property.validator(value)){return false;}else{if(typeof value!='undefined'){property.value=value;}else{value=property.value;}
+var foundDuplicate=false;for(var i=0;i<eventQueue.length;i++){var queueItem=eventQueue[i];if(queueItem){var queueItemKey=queueItem[0];var queueItemValue=queueItem[1];if(queueItemKey.toLowerCase()==key){eventQueue[i]=null;eventQueue.push([key,(typeof value!='undefined'?value:queueItemValue)]);foundDuplicate=true;break;}}}
+if(!foundDuplicate&&typeof value!='undefined'){eventQueue.push([key,value]);}}
+if(property.supercedes){for(var s=0;s<property.supercedes.length;s++){var supercedesCheck=property.supercedes[s];for(var q=0;q<eventQueue.length;q++){var queueItemCheck=eventQueue[q];if(queueItemCheck){var queueItemCheckKey=queueItemCheck[0];var queueItemCheckValue=queueItemCheck[1];if(queueItemCheckKey.toLowerCase()==supercedesCheck.toLowerCase()){eventQueue.push([queueItemCheckKey,queueItemCheckValue]);eventQueue[q]=null;break;}}}}}
+return true;}else{return false;}}
+this.refireEvent=function(key){key=key.toLowerCase();var property=config[key];if(typeof property!='undefined'&&property.event&&typeof property.value!='undefined'){if(this.queueInProgress){this.queueProperty(key);}else{fireEvent(key,property.value);}}}
+this.applyConfig=function(userConfig,init){if(init){initialConfig=userConfig;}
+for(var prop in userConfig){this.queueProperty(prop,userConfig[prop]);}}
+this.refresh=function(){for(var prop in config){this.refireEvent(prop);}}
+this.fireQueue=function(){this.queueInProgress=true;for(var i=0;i<eventQueue.length;i++){var queueItem=eventQueue[i];if(queueItem){var key=queueItem[0];var value=queueItem[1];var property=config[key];property.value=value;fireEvent(key,value);}}
+this.queueInProgress=false;eventQueue=new Array();}
+this.subscribeToConfigEvent=function(key,handler,obj,override){key=key.toLowerCase();var property=config[key];if(typeof property!='undefined'&&property.event){if(!YAHOO.util.Config.alreadySubscribed(property.event,handler,obj)){property.event.subscribe(handler,obj,override);}
+return true;}else{return false;}}
+this.unsubscribeFromConfigEvent=function(key,handler,obj){key=key.toLowerCase();var property=config[key];if(typeof property!='undefined'&&property.event){return property.event.unsubscribe(handler,obj);}else{return false;}}
+this.toString=function(){var output="Config";if(this.owner){output+=" ["+this.owner.toString()+"]";}
+return output;}
+this.outputEventQueue=function(){var output="";for(var q=0;q<eventQueue.length;q++){var queueItem=eventQueue[q];if(queueItem){output+=queueItem[0]+"="+queueItem[1]+", ";}}
+return output;}}
+YAHOO.util.Config.alreadySubscribed=function(evt,fn,obj){for(var e=0;e<evt.subscribers.length;e++){var subsc=evt.subscribers[e];if(subsc&&subsc.obj==obj&&subsc.fn==fn){return true;break;}}
+return false;}
+YAHOO.widget.Module=function(el,userConfig){if(el){this.init(el,userConfig);}}
+YAHOO.widget.Module.IMG_ROOT="http://us.i1.yimg.com/us.yimg.com/i/";YAHOO.widget.Module.IMG_ROOT_SSL="https://a248.e.akamai.net/sec.yimg.com/i/";YAHOO.widget.Module.CSS_MODULE="module";YAHOO.widget.Module.CSS_HEADER="hd";YAHOO.widget.Module.CSS_BODY="bd";YAHOO.widget.Module.CSS_FOOTER="ft";YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL=null;YAHOO.widget.Module.prototype={constructor:YAHOO.widget.Module,element:null,header:null,body:null,footer:null,id:null,childNodesInDOM:null,imageRoot:YAHOO.widget.Module.IMG_ROOT,beforeInitEvent:null,initEvent:null,appendEvent:null,beforeRenderEvent:null,renderEvent:null,changeHeaderEvent:null,changeBodyEvent:null,changeFooterEvent:null,changeContentEvent:null,destroyEvent:null,beforeShowEvent:null,showEvent:null,beforeHideEvent:null,hideEvent:null,initEvents:function(){this.beforeInitEvent=new YAHOO.util.CustomEvent("beforeInit");this.initEvent=new YAHOO.util.CustomEvent("init");this.appendEvent=new YAHOO.util.CustomEvent("append");this.b!
eforeRenderEvent=new YAHOO.util.CustomEvent("beforeRender");this.renderEvent=new YAHOO.util.CustomEvent("render");this.changeHeaderEvent=new YAHOO.util.CustomEvent("changeHeader");this.changeBodyEvent=new YAHOO.util.CustomEvent("changeBody");this.changeFooterEvent=new YAHOO.util.CustomEvent("changeFooter");this.changeContentEvent=new YAHOO.util.CustomEvent("changeContent");this.destroyEvent=new YAHOO.util.CustomEvent("destroy");this.beforeShowEvent=new YAHOO.util.CustomEvent("beforeShow");this.showEvent=new YAHOO.util.CustomEvent("show");this.beforeHideEvent=new YAHOO.util.CustomEvent("beforeHide");this.hideEvent=new YAHOO.util.CustomEvent("hide");},platform:function(){var ua=navigator.userAgent.toLowerCase();if(ua.indexOf("windows")!=-1||ua.indexOf("win32")!=-1){return"windows";}else if(ua.indexOf("macintosh")!=-1){return"mac";}else{return false;}}(),browser:function(){var ua=navigator.userAgent.toLowerCase();if(ua.indexOf('opera')!=-1){return'opera';}else if(ua.indexOf('m!
sie 7')!=-1){return'ie7';}else if(ua.indexOf('msie')!=-1){return'ie';}
else if(ua.indexOf('safari')!=-1){return'safari';}else if(ua.indexOf('gecko')!=-1){return'gecko';}else{return false;}}(),isSecure:function(){if(window.location.href.toLowerCase().indexOf("https")==0){return true;}else{return false;}}(),initDefaultConfig:function(){this.cfg.addProperty("visible",{value:true,handler:this.configVisible,validator:this.cfg.checkBoolean});this.cfg.addProperty("effect",{suppressEvent:true,supercedes:["visible"]});this.cfg.addProperty("monitorresize",{value:true,handler:this.configMonitorResize});},init:function(el,userConfig){this.initEvents();this.beforeInitEvent.fire(YAHOO.widget.Module);this.cfg=new YAHOO.util.Config(this);if(this.isSecure){this.imageRoot=YAHOO.widget.Module.IMG_ROOT_SSL;}
+if(typeof el=="string"){var elId=el;el=document.getElementById(el);if(!el){el=document.createElement("DIV");el.id=elId;}}
+this.element=el;if(el.id){this.id=el.id;}
+var childNodes=this.element.childNodes;if(childNodes){for(var i=0;i<childNodes.length;i++){var child=childNodes[i];switch(child.className){case YAHOO.widget.Module.CSS_HEADER:this.header=child;break;case YAHOO.widget.Module.CSS_BODY:this.body=child;break;case YAHOO.widget.Module.CSS_FOOTER:this.footer=child;break;}}}
+this.initDefaultConfig();YAHOO.util.Dom.addClass(this.element,YAHOO.widget.Module.CSS_MODULE);if(userConfig){this.cfg.applyConfig(userConfig,true);}
+if(!YAHOO.util.Config.alreadySubscribed(this.renderEvent,this.cfg.fireQueue,this.cfg)){this.renderEvent.subscribe(this.cfg.fireQueue,this.cfg,true);}
+this.initEvent.fire(YAHOO.widget.Module);},initResizeMonitor:function(){if(this.browser!="opera"){var resizeMonitor=document.getElementById("_yuiResizeMonitor");if(!resizeMonitor){resizeMonitor=document.createElement("iframe");var bIE=(this.browser.indexOf("ie")===0);if(this.isSecure&&this.RESIZE_MONITOR_SECURE_URL&&bIE){resizeMonitor.src=this.RESIZE_MONITOR_SECURE_URL;}
+resizeMonitor.id="_yuiResizeMonitor";resizeMonitor.style.visibility="hidden";document.body.appendChild(resizeMonitor);resizeMonitor.style.width="10em";resizeMonitor.style.height="10em";resizeMonitor.style.position="absolute";var nLeft=-1*resizeMonitor.offsetWidth,nTop=-1*resizeMonitor.offsetHeight;resizeMonitor.style.top=nTop+"px";resizeMonitor.style.left=nLeft+"px";resizeMonitor.style.borderStyle="none";resizeMonitor.style.borderWidth="0";YAHOO.util.Dom.setStyle(resizeMonitor,"opacity","0");resizeMonitor.style.visibility="visible";if(!bIE){var doc=resizeMonitor.contentWindow.document;doc.open();doc.close();}}
+if(resizeMonitor&&resizeMonitor.contentWindow){this.resizeMonitor=resizeMonitor;YAHOO.util.Event.addListener(this.resizeMonitor.contentWindow,"resize",this.onDomResize,this,true);}}},onDomResize:function(e,obj){var nLeft=-1*this.resizeMonitor.offsetWidth,nTop=-1*this.resizeMonitor.offsetHeight;this.resizeMonitor.style.top=nTop+"px";this.resizeMonitor.style.left=nLeft+"px";},setHeader:function(headerContent){if(!this.header){this.header=document.createElement("DIV");this.header.className=YAHOO.widget.Module.CSS_HEADER;}
+if(typeof headerContent=="string"){this.header.innerHTML=headerContent;}else{this.header.innerHTML="";this.header.appendChild(headerContent);}
+this.changeHeaderEvent.fire(headerContent);this.changeContentEvent.fire();},appendToHeader:function(element){if(!this.header){this.header=document.createElement("DIV");this.header.className=YAHOO.widget.Module.CSS_HEADER;}
+this.header.appendChild(element);this.changeHeaderEvent.fire(element);this.changeContentEvent.fire();},setBody:function(bodyContent){if(!this.body){this.body=document.createElement("DIV");this.body.className=YAHOO.widget.Module.CSS_BODY;}
+if(typeof bodyContent=="string")
+{this.body.innerHTML=bodyContent;}else{this.body.innerHTML="";this.body.appendChild(bodyContent);}
+this.changeBodyEvent.fire(bodyContent);this.changeContentEvent.fire();},appendToBody:function(element){if(!this.body){this.body=document.createElement("DIV");this.body.className=YAHOO.widget.Module.CSS_BODY;}
+this.body.appendChild(element);this.changeBodyEvent.fire(element);this.changeContentEvent.fire();},setFooter:function(footerContent){if(!this.footer){this.footer=document.createElement("DIV");this.footer.className=YAHOO.widget.Module.CSS_FOOTER;}
+if(typeof footerContent=="string"){this.footer.innerHTML=footerContent;}else{this.footer.innerHTML="";this.footer.appendChild(footerContent);}
+this.changeFooterEvent.fire(footerContent);this.changeContentEvent.fire();},appendToFooter:function(element){if(!this.footer){this.footer=document.createElement("DIV");this.footer.className=YAHOO.widget.Module.CSS_FOOTER;}
+this.footer.appendChild(element);this.changeFooterEvent.fire(element);this.changeContentEvent.fire();},render:function(appendToNode,moduleElement){this.beforeRenderEvent.fire();if(!moduleElement){moduleElement=this.element;}
+var me=this;var appendTo=function(element){if(typeof element=="string"){element=document.getElementById(element);}
+if(element){element.appendChild(me.element);me.appendEvent.fire();}}
+if(appendToNode){appendTo(appendToNode);}else{if(!YAHOO.util.Dom.inDocument(this.element)){return false;}}
+if(this.header&&!YAHOO.util.Dom.inDocument(this.header)){var firstChild=moduleElement.firstChild;if(firstChild){moduleElement.insertBefore(this.header,firstChild);}else{moduleElement.appendChild(this.header);}}
+if(this.body&&!YAHOO.util.Dom.inDocument(this.body)){if(this.footer&&YAHOO.util.Dom.isAncestor(this.moduleElement,this.footer)){moduleElement.insertBefore(this.body,this.footer);}else{moduleElement.appendChild(this.body);}}
+if(this.footer&&!YAHOO.util.Dom.inDocument(this.footer)){moduleElement.appendChild(this.footer);}
+this.renderEvent.fire();return true;},destroy:function(){if(this.element){var parent=this.element.parentNode;}
+if(parent){parent.removeChild(this.element);}
+this.element=null;this.header=null;this.body=null;this.footer=null;this.destroyEvent.fire();},show:function(){this.cfg.setProperty("visible",true);},hide:function(){this.cfg.setProperty("visible",false);},configVisible:function(type,args,obj){var visible=args[0];if(visible){this.beforeShowEvent.fire();YAHOO.util.Dom.setStyle(this.element,"display","block");this.showEvent.fire();}else{this.beforeHideEvent.fire();YAHOO.util.Dom.setStyle(this.element,"display","none");this.hideEvent.fire();}},configMonitorResize:function(type,args,obj){var monitor=args[0];if(monitor){this.initResizeMonitor();}else{YAHOO.util.Event.removeListener(this.resizeMonitor,"resize",this.onDomResize);this.resizeMonitor=null;}}}
+YAHOO.widget.Module.prototype.toString=function(){return"Module "+this.id;}
+YAHOO.widget.Overlay=function(el,userConfig){YAHOO.widget.Overlay.superclass.constructor.call(this,el,userConfig);}
+YAHOO.extend(YAHOO.widget.Overlay,YAHOO.widget.Module);YAHOO.widget.Overlay.IFRAME_SRC="promo/m/irs/blank.gif";YAHOO.widget.Overlay.TOP_LEFT="tl";YAHOO.widget.Overlay.TOP_RIGHT="tr";YAHOO.widget.Overlay.BOTTOM_LEFT="bl";YAHOO.widget.Overlay.BOTTOM_RIGHT="br";YAHOO.widget.Overlay.CSS_OVERLAY="overlay";YAHOO.widget.Overlay.prototype.beforeMoveEvent=null;YAHOO.widget.Overlay.prototype.moveEvent=null;YAHOO.widget.Overlay.prototype.init=function(el,userConfig){YAHOO.widget.Overlay.superclass.init.call(this,el);this.beforeInitEvent.fire(YAHOO.widget.Overlay);YAHOO.util.Dom.addClass(this.element,YAHOO.widget.Overlay.CSS_OVERLAY);if(userConfig){this.cfg.applyConfig(userConfig,true);}
+if(this.platform=="mac"&&this.browser=="gecko"){if(!YAHOO.util.Config.alreadySubscribed(this.showEvent,this.showMacGeckoScrollbars,this)){this.showEvent.subscribe(this.showMacGeckoScrollbars,this,true);}
+if(!YAHOO.util.Config.alreadySubscribed(this.hideEvent,this.hideMacGeckoScrollbars,this)){this.hideEvent.subscribe(this.hideMacGeckoScrollbars,this,true);}}
+this.initEvent.fire(YAHOO.widget.Overlay);}
+YAHOO.widget.Overlay.prototype.initEvents=function(){YAHOO.widget.Overlay.superclass.initEvents.call(this);this.beforeMoveEvent=new YAHOO.util.CustomEvent("beforeMove",this);this.moveEvent=new YAHOO.util.CustomEvent("move",this);}
+YAHOO.widget.Overlay.prototype.initDefaultConfig=function(){YAHOO.widget.Overlay.superclass.initDefaultConfig.call(this);this.cfg.addProperty("x",{handler:this.configX,validator:this.cfg.checkNumber,suppressEvent:true,supercedes:["iframe"]});this.cfg.addProperty("y",{handler:this.configY,validator:this.cfg.checkNumber,suppressEvent:true,supercedes:["iframe"]});this.cfg.addProperty("xy",{handler:this.configXY,suppressEvent:true,supercedes:["iframe"]});this.cfg.addProperty("context",{handler:this.configContext,suppressEvent:true,supercedes:["iframe"]});this.cfg.addProperty("fixedcenter",{value:false,handler:this.configFixedCenter,validator:this.cfg.checkBoolean,supercedes:["iframe","visible"]});this.cfg.addProperty("width",{handler:this.configWidth,suppressEvent:true,supercedes:["iframe"]});this.cfg.addProperty("height",{handler:this.configHeight,suppressEvent:true,supercedes:["iframe"]});this.cfg.addProperty("zIndex",{value:null,handler:this.configzIndex});this.cfg.addProper!
ty("constraintoviewport",{value:false,handler:this.configConstrainToViewport,validator:this.cfg.checkBoolean,supercedes:["iframe","x","y","xy"]});this.cfg.addProperty("iframe",{value:(this.browser=="ie"?true:false),handler:this.configIframe,validator:this.cfg.checkBoolean,supercedes:["zIndex"]});}
+YAHOO.widget.Overlay.prototype.moveTo=function(x,y){this.cfg.setProperty("xy",[x,y]);}
+YAHOO.widget.Overlay.prototype.hideMacGeckoScrollbars=function(){YAHOO.util.Dom.removeClass(this.element,"show-scrollbars");YAHOO.util.Dom.addClass(this.element,"hide-scrollbars");}
+YAHOO.widget.Overlay.prototype.showMacGeckoScrollbars=function(){YAHOO.util.Dom.removeClass(this.element,"hide-scrollbars");YAHOO.util.Dom.addClass(this.element,"show-scrollbars");}
+YAHOO.widget.Overlay.prototype.configVisible=function(type,args,obj){var visible=args[0];var currentVis=YAHOO.util.Dom.getStyle(this.element,"visibility");var effect=this.cfg.getProperty("effect");var effectInstances=new Array();if(effect){if(effect instanceof Array){for(var i=0;i<effect.length;i++){var eff=effect[i];effectInstances[effectInstances.length]=eff.effect(this,eff.duration);}}else{effectInstances[effectInstances.length]=effect.effect(this,effect.duration);}}
+var isMacGecko=(this.platform=="mac"&&this.browser=="gecko");if(visible){if(isMacGecko){this.showMacGeckoScrollbars();}
+if(effect){if(visible){if(currentVis!="visible"){this.beforeShowEvent.fire();for(var i=0;i<effectInstances.length;i++){var e=effectInstances[i];if(i==0&&!YAHOO.util.Config.alreadySubscribed(e.animateInCompleteEvent,this.showEvent.fire,this.showEvent)){e.animateInCompleteEvent.subscribe(this.showEvent.fire,this.showEvent,true);}
+e.animateIn();}}}}else{if(currentVis!="visible"){this.beforeShowEvent.fire();YAHOO.util.Dom.setStyle(this.element,"visibility","visible");this.cfg.refireEvent("iframe");this.showEvent.fire();}}}else{if(isMacGecko){this.hideMacGeckoScrollbars();}
+if(effect){if(currentVis=="visible"){this.beforeHideEvent.fire();for(var i=0;i<effectInstances.length;i++){var e=effectInstances[i];if(i==0&&!YAHOO.util.Config.alreadySubscribed(e.animateOutCompleteEvent,this.hideEvent.fire,this.hideEvent)){e.animateOutCompleteEvent.subscribe(this.hideEvent.fire,this.hideEvent,true);}
+e.animateOut();}}}else{if(currentVis=="visible"){this.beforeHideEvent.fire();YAHOO.util.Dom.setStyle(this.element,"visibility","hidden");this.cfg.refireEvent("iframe");this.hideEvent.fire();}}}}
+YAHOO.widget.Overlay.prototype.doCenterOnDOMEvent=function(){if(this.cfg.getProperty("visible")){this.center();}}
+YAHOO.widget.Overlay.prototype.configFixedCenter=function(type,args,obj){var val=args[0];if(val){this.center();if(!YAHOO.util.Config.alreadySubscribed(this.beforeShowEvent,this.center,this)){this.beforeShowEvent.subscribe(this.center,this,true);}
+if(!YAHOO.util.Config.alreadySubscribed(YAHOO.widget.Overlay.windowResizeEvent,this.doCenterOnDOMEvent,this)){YAHOO.widget.Overlay.windowResizeEvent.subscribe(this.doCenterOnDOMEvent,this,true);}
+if(!YAHOO.util.Config.alreadySubscribed(YAHOO.widget.Overlay.windowScrollEvent,this.doCenterOnDOMEvent,this)){YAHOO.widget.Overlay.windowScrollEvent.subscribe(this.doCenterOnDOMEvent,this,true);}}else{YAHOO.widget.Overlay.windowResizeEvent.unsubscribe(this.doCenterOnDOMEvent,this);YAHOO.widget.Overlay.windowScrollEvent.unsubscribe(this.doCenterOnDOMEvent,this);}}
+YAHOO.widget.Overlay.prototype.configHeight=function(type,args,obj){var height=args[0];var el=this.element;YAHOO.util.Dom.setStyle(el,"height",height);this.cfg.refireEvent("iframe");}
+YAHOO.widget.Overlay.prototype.configWidth=function(type,args,obj){var width=args[0];var el=this.element;YAHOO.util.Dom.setStyle(el,"width",width);this.cfg.refireEvent("iframe");}
+YAHOO.widget.Overlay.prototype.configzIndex=function(type,args,obj){var zIndex=args[0];var el=this.element;if(!zIndex){zIndex=YAHOO.util.Dom.getStyle(el,"zIndex");if(!zIndex||isNaN(zIndex)){zIndex=0;}}
+if(this.iframe){if(zIndex<=0){zIndex=1;}
+YAHOO.util.Dom.setStyle(this.iframe,"zIndex",(zIndex-1));}
+YAHOO.util.Dom.setStyle(el,"zIndex",zIndex);this.cfg.setProperty("zIndex",zIndex,true);}
+YAHOO.widget.Overlay.prototype.configXY=function(type,args,obj){var pos=args[0];var x=pos[0];var y=pos[1];this.cfg.setProperty("x",x);this.cfg.setProperty("y",y);this.beforeMoveEvent.fire([x,y]);x=this.cfg.getProperty("x");y=this.cfg.getProperty("y");this.cfg.refireEvent("iframe");this.moveEvent.fire([x,y]);}
+YAHOO.widget.Overlay.prototype.configX=function(type,args,obj){var x=args[0];var y=this.cfg.getProperty("y");this.cfg.setProperty("x",x,true);this.cfg.setProperty("y",y,true);this.beforeMoveEvent.fire([x,y]);x=this.cfg.getProperty("x");y=this.cfg.getProperty("y");YAHOO.util.Dom.setX(this.element,x,true);this.cfg.setProperty("xy",[x,y],true);this.cfg.refireEvent("iframe");this.moveEvent.fire([x,y]);}
+YAHOO.widget.Overlay.prototype.configY=function(type,args,obj){var x=this.cfg.getProperty("x");var y=args[0];this.cfg.setProperty("x",x,true);this.cfg.setProperty("y",y,true);this.beforeMoveEvent.fire([x,y]);x=this.cfg.getProperty("x");y=this.cfg.getProperty("y");YAHOO.util.Dom.setY(this.element,y,true);this.cfg.setProperty("xy",[x,y],true);this.cfg.refireEvent("iframe");this.moveEvent.fire([x,y]);}
+YAHOO.widget.Overlay.prototype.configIframe=function(type,args,obj){var val=args[0];var el=this.element;var showIframe=function(){if(this.iframe){this.iframe.style.display="block";}}
+var hideIframe=function(){if(this.iframe){this.iframe.style.display="none";}}
+if(val){if(!YAHOO.util.Config.alreadySubscribed(this.showEvent,showIframe,this)){this.showEvent.subscribe(showIframe,this,true);}
+if(!YAHOO.util.Config.alreadySubscribed(this.hideEvent,hideIframe,this)){this.hideEvent.subscribe(hideIframe,this,true);}
+var x=this.cfg.getProperty("x");var y=this.cfg.getProperty("y");if(!x||!y){this.syncPosition();x=this.cfg.getProperty("x");y=this.cfg.getProperty("y");}
+if(!isNaN(x)&&!isNaN(y)){if(!this.iframe){this.iframe=document.createElement("iframe");if(this.isSecure){this.iframe.src=this.imageRoot+YAHOO.widget.Overlay.IFRAME_SRC;}
+var parent=el.parentNode;if(parent){parent.appendChild(this.iframe);}else{document.body.appendChild(this.iframe);}
+YAHOO.util.Dom.setStyle(this.iframe,"position","absolute");YAHOO.util.Dom.setStyle(this.iframe,"border","none");YAHOO.util.Dom.setStyle(this.iframe,"margin","0");YAHOO.util.Dom.setStyle(this.iframe,"padding","0");YAHOO.util.Dom.setStyle(this.iframe,"opacity","0");if(this.cfg.getProperty("visible")){showIframe.call(this);}else{hideIframe.call(this);}}
+var iframeDisplay=YAHOO.util.Dom.getStyle(this.iframe,"display");if(iframeDisplay=="none"){this.iframe.style.display="block";}
+YAHOO.util.Dom.setXY(this.iframe,[x,y]);var width=el.clientWidth;var height=el.clientHeight;YAHOO.util.Dom.setStyle(this.iframe,"width",(width+2)+"px");YAHOO.util.Dom.setStyle(this.iframe,"height",(height+2)+"px");if(iframeDisplay=="none"){this.iframe.style.display="none";}}}else{if(this.iframe){this.iframe.style.display="none";}
+this.showEvent.unsubscribe(showIframe,this);this.hideEvent.unsubscribe(hideIframe,this);}}
+YAHOO.widget.Overlay.prototype.configConstrainToViewport=function(type,args,obj){var val=args[0];if(val){if(!YAHOO.util.Config.alreadySubscribed(this.beforeMoveEvent,this.enforceConstraints,this)){this.beforeMoveEvent.subscribe(this.enforceConstraints,this,true);}}else{this.beforeMoveEvent.unsubscribe(this.enforceConstraints,this);}}
+YAHOO.widget.Overlay.prototype.configContext=function(type,args,obj){var contextArgs=args[0];if(contextArgs){var contextEl=contextArgs[0];var elementMagnetCorner=contextArgs[1];var contextMagnetCorner=contextArgs[2];if(contextEl){if(typeof contextEl=="string"){this.cfg.setProperty("context",[document.getElementById(contextEl),elementMagnetCorner,contextMagnetCorner],true);}
+if(elementMagnetCorner&&contextMagnetCorner){this.align(elementMagnetCorner,contextMagnetCorner);}}}}
+YAHOO.widget.Overlay.prototype.align=function(elementAlign,contextAlign){var contextArgs=this.cfg.getProperty("context");if(contextArgs){var context=contextArgs[0];var element=this.element;var me=this;if(!elementAlign){elementAlign=contextArgs[1];}
+if(!contextAlign){contextAlign=contextArgs[2];}
+if(element&&context){var elementRegion=YAHOO.util.Dom.getRegion(element);var contextRegion=YAHOO.util.Dom.getRegion(context);var doAlign=function(v,h){switch(elementAlign){case YAHOO.widget.Overlay.TOP_LEFT:me.moveTo(h,v);break;case YAHOO.widget.Overlay.TOP_RIGHT:me.moveTo(h-element.offsetWidth,v);break;case YAHOO.widget.Overlay.BOTTOM_LEFT:me.moveTo(h,v-element.offsetHeight);break;case YAHOO.widget.Overlay.BOTTOM_RIGHT:me.moveTo(h-element.offsetWidth,v-element.offsetHeight);break;}}
+switch(contextAlign){case YAHOO.widget.Overlay.TOP_LEFT:doAlign(contextRegion.top,contextRegion.left);break;case YAHOO.widget.Overlay.TOP_RIGHT:doAlign(contextRegion.top,contextRegion.right);break;case YAHOO.widget.Overlay.BOTTOM_LEFT:doAlign(contextRegion.bottom,contextRegion.left);break;case YAHOO.widget.Overlay.BOTTOM_RIGHT:doAlign(contextRegion.bottom,contextRegion.right);break;}}}}
+YAHOO.widget.Overlay.prototype.enforceConstraints=function(type,args,obj){var pos=args[0];var x=pos[0];var y=pos[1];var width=parseInt(this.cfg.getProperty("width"));if(isNaN(width)){width=0;}
+var offsetHeight=this.element.offsetHeight;var offsetWidth=(width>0?width:this.element.offsetWidth);var viewPortWidth=YAHOO.util.Dom.getViewportWidth();var viewPortHeight=YAHOO.util.Dom.getViewportHeight();var scrollX=window.scrollX||document.documentElement.scrollLeft;var scrollY=window.scrollY||document.documentElement.scrollTop;var topConstraint=scrollY+10;var leftConstraint=scrollX+10;var bottomConstraint=scrollY+viewPortHeight-offsetHeight-10;var rightConstraint=scrollX+viewPortWidth-offsetWidth-10;if(x<leftConstraint){x=leftConstraint;}else if(x>rightConstraint){x=rightConstraint;}
+if(y<topConstraint){y=topConstraint;}else if(y>bottomConstraint){y=bottomConstraint;}
+this.cfg.setProperty("x",x,true);this.cfg.setProperty("y",y,true);this.cfg.setProperty("xy",[x,y],true);}
+YAHOO.widget.Overlay.prototype.center=function(){var scrollX=document.documentElement.scrollLeft||document.body.scrollLeft;var scrollY=document.documentElement.scrollTop||document.body.scrollTop;var viewPortWidth=YAHOO.util.Dom.getClientWidth();var viewPortHeight=YAHOO.util.Dom.getClientHeight();var elementWidth=this.element.offsetWidth;var elementHeight=this.element.offsetHeight;var x=(viewPortWidth/2)-(elementWidth/2)+scrollX;var y=(viewPortHeight/2)-(elementHeight/2)+scrollY;this.element.style.left=parseInt(x)+"px";this.element.style.top=parseInt(y)+"px";this.syncPosition();this.cfg.refireEvent("iframe");}
+YAHOO.widget.Overlay.prototype.syncPosition=function(){var pos=YAHOO.util.Dom.getXY(this.element);this.cfg.setProperty("x",pos[0],true);this.cfg.setProperty("y",pos[1],true);this.cfg.setProperty("xy",pos,true);}
+YAHOO.widget.Overlay.prototype.onDomResize=function(e,obj){YAHOO.widget.Overlay.superclass.onDomResize.call(this,e,obj);this.cfg.refireEvent("iframe");}
+YAHOO.widget.Overlay.prototype.destroy=function(){if(this.iframe){this.iframe.parentNode.removeChild(this.iframe);}
+this.iframe=null;YAHOO.widget.Overlay.superclass.destroy.call(this);};YAHOO.widget.Overlay.prototype.toString=function(){return"Overlay "+this.id;}
+YAHOO.widget.Overlay.windowScrollEvent=new YAHOO.util.CustomEvent("windowScroll");YAHOO.widget.Overlay.windowResizeEvent=new YAHOO.util.CustomEvent("windowResize");YAHOO.widget.Overlay.windowScrollHandler=function(e){YAHOO.widget.Overlay.windowScrollEvent.fire();}
+YAHOO.widget.Overlay.windowResizeHandler=function(e){YAHOO.widget.Overlay.windowResizeEvent.fire();}
+YAHOO.widget.Overlay._initialized==null;if(YAHOO.widget.Overlay._initialized==null){YAHOO.util.Event.addListener(window,"scroll",YAHOO.widget.Overlay.windowScrollHandler);YAHOO.util.Event.addListener(window,"resize",YAHOO.widget.Overlay.windowResizeHandler);YAHOO.widget.Overlay._initialized=true;}
+YAHOO.widget.OverlayManager=function(userConfig){this.init(userConfig);}
+YAHOO.widget.OverlayManager.CSS_FOCUSED="focused";YAHOO.widget.OverlayManager.prototype={constructor:YAHOO.widget.OverlayManager,overlays:null,initDefaultConfig:function(){this.cfg.addProperty("overlays",{suppressEvent:true});this.cfg.addProperty("focusevent",{value:"mousedown"});},getActive:function(){},focus:function(overlay){},remove:function(overlay){},blurAll:function(){},init:function(userConfig){this.cfg=new YAHOO.util.Config(this);this.initDefaultConfig();if(userConfig){this.cfg.applyConfig(userConfig,true);}
+this.cfg.fireQueue();var activeOverlay=null;this.getActive=function(){return activeOverlay;}
+this.focus=function(overlay){var o=this.find(overlay);if(o){this.blurAll();activeOverlay=o;YAHOO.util.Dom.addClass(activeOverlay.element,YAHOO.widget.OverlayManager.CSS_FOCUSED);this.overlays.sort(this.compareZIndexDesc);var topZIndex=YAHOO.util.Dom.getStyle(this.overlays[0].element,"zIndex");if(!isNaN(topZIndex)&&this.overlays[0]!=overlay){activeOverlay.cfg.setProperty("zIndex",(parseInt(topZIndex)+1));}
+this.overlays.sort(this.compareZIndexDesc);}}
+this.remove=function(overlay){var o=this.find(overlay);if(o){var originalZ=YAHOO.util.Dom.getStyle(o.element,"zIndex");o.cfg.setProperty("zIndex",-1000,true);this.overlays.sort(this.compareZIndexDesc);this.overlays=this.overlays.slice(0,this.overlays.length-1);o.cfg.setProperty("zIndex",originalZ,true);o.cfg.setProperty("manager",null);o.focusEvent=null
+o.blurEvent=null;o.focus=null;o.blur=null;}}
+this.blurAll=function(){activeOverlay=null;for(var o=0;o<this.overlays.length;o++){YAHOO.util.Dom.removeClass(this.overlays[o].element,YAHOO.widget.OverlayManager.CSS_FOCUSED);}}
+var overlays=this.cfg.getProperty("overlays");if(!this.overlays){this.overlays=new Array();}
+if(overlays){this.register(overlays);this.overlays.sort(this.compareZIndexDesc);}},register:function(overlay){if(overlay instanceof YAHOO.widget.Overlay){overlay.cfg.addProperty("manager",{value:this});overlay.focusEvent=new YAHOO.util.CustomEvent("focus");overlay.blurEvent=new YAHOO.util.CustomEvent("blur");var mgr=this;overlay.focus=function(){mgr.focus(this);this.focusEvent.fire();}
+overlay.blur=function(){mgr.blurAll();this.blurEvent.fire();}
+var focusOnDomEvent=function(e,obj){overlay.focus();}
+var focusevent=this.cfg.getProperty("focusevent");YAHOO.util.Event.addListener(overlay.element,focusevent,focusOnDomEvent,this,true);var zIndex=YAHOO.util.Dom.getStyle(overlay.element,"zIndex");if(!isNaN(zIndex)){overlay.cfg.setProperty("zIndex",parseInt(zIndex));}else{overlay.cfg.setProperty("zIndex",0);}
+this.overlays.push(overlay);return true;}else if(overlay instanceof Array){var regcount=0;for(var i=0;i<overlay.length;i++){if(this.register(overlay[i])){regcount++;}}
+if(regcount>0){return true;}}else{return false;}},find:function(overlay){if(overlay instanceof YAHOO.widget.Overlay){for(var o=0;o<this.overlays.length;o++){if(this.overlays[o]==overlay){return this.overlays[o];}}}else if(typeof overlay=="string"){for(var o=0;o<this.overlays.length;o++){if(this.overlays[o].id==overlay){return this.overlays[o];}}}
+return null;},compareZIndexDesc:function(o1,o2){var zIndex1=o1.cfg.getProperty("zIndex");var zIndex2=o2.cfg.getProperty("zIndex");if(zIndex1>zIndex2){return-1;}else if(zIndex1<zIndex2){return 1;}else{return 0;}},showAll:function(){for(var o=0;o<this.overlays.length;o++){this.overlays[o].show();}},hideAll:function(){for(var o=0;o<this.overlays.length;o++){this.overlays[o].hide();}},toString:function(){return"OverlayManager";}}
+YAHOO.util.KeyListener=function(attachTo,keyData,handler,event){if(!event){event=YAHOO.util.KeyListener.KEYDOWN;}
+var keyEvent=new YAHOO.util.CustomEvent("keyPressed");this.enabledEvent=new YAHOO.util.CustomEvent("enabled");this.disabledEvent=new YAHOO.util.CustomEvent("disabled");if(typeof attachTo=='string'){attachTo=document.getElementById(attachTo);}
+if(typeof handler=='function'){keyEvent.subscribe(handler);}else{keyEvent.subscribe(handler.fn,handler.scope,handler.correctScope);}
+function handleKeyPress(e,obj){var keyPressed=e.charCode||e.keyCode;if(!keyData.shift)keyData.shift=false;if(!keyData.alt)keyData.alt=false;if(!keyData.ctrl)keyData.ctrl=false;if(e.shiftKey==keyData.shift&&e.altKey==keyData.alt&&e.ctrlKey==keyData.ctrl){if(keyData.keys instanceof Array){for(var i=0;i<keyData.keys.length;i++){if(keyPressed==keyData.keys[i]){keyEvent.fire(keyPressed,e);break;}}}else{if(keyPressed==keyData.keys){keyEvent.fire(keyPressed,e);}}}}
+this.enable=function(){if(!this.enabled){YAHOO.util.Event.addListener(attachTo,event,handleKeyPress);this.enabledEvent.fire(keyData);}
+this.enabled=true;}
+this.disable=function(){if(this.enabled){YAHOO.util.Event.removeListener(attachTo,event,handleKeyPress);this.disabledEvent.fire(keyData);}
+this.enabled=false;}
+this.toString=function(){return"KeyListener ["+keyData.keys+"] "+attachTo.tagName+(attachTo.id?"["+attachTo.id+"]":"");}}
+YAHOO.util.KeyListener.KEYDOWN="keydown";YAHOO.util.KeyListener.KEYUP="keyup";YAHOO.util.KeyListener.prototype.enabled=null;YAHOO.util.KeyListener.prototype.enable=function(){};YAHOO.util.KeyListener.prototype.disable=function(){};YAHOO.util.KeyListener.prototype.enabledEvent=null;YAHOO.util.KeyListener.prototype.disabledEvent=null;YAHOO.widget.Tooltip=function(el,userConfig){YAHOO.widget.Tooltip.superclass.constructor.call(this,el,userConfig);}
+YAHOO.extend(YAHOO.widget.Tooltip,YAHOO.widget.Overlay);YAHOO.widget.Tooltip.CSS_TOOLTIP="tt";YAHOO.widget.Tooltip.prototype.init=function(el,userConfig){if(document.readyState&&document.readyState!="complete"){var deferredInit=function(){this.init(el,userConfig);}
+YAHOO.util.Event.addListener(window,"load",deferredInit,this,true);}else{YAHOO.widget.Tooltip.superclass.init.call(this,el);this.beforeInitEvent.fire(YAHOO.widget.Tooltip);YAHOO.util.Dom.addClass(this.element,YAHOO.widget.Tooltip.CSS_TOOLTIP);if(userConfig){this.cfg.applyConfig(userConfig,true);}
+this.cfg.queueProperty("visible",false);this.cfg.queueProperty("constraintoviewport",true);this.setBody("");this.render(this.cfg.getProperty("container"));this.initEvent.fire(YAHOO.widget.Tooltip);}}
+YAHOO.widget.Tooltip.prototype.initDefaultConfig=function(){YAHOO.widget.Tooltip.superclass.initDefaultConfig.call(this);this.cfg.addProperty("preventoverlap",{value:true,validator:this.cfg.checkBoolean,supercedes:["x","y","xy"]});this.cfg.addProperty("showdelay",{value:200,handler:this.configShowDelay,validator:this.cfg.checkNumber});this.cfg.addProperty("autodismissdelay",{value:5000,handler:this.configAutoDismissDelay,validator:this.cfg.checkNumber});this.cfg.addProperty("hidedelay",{value:250,handler:this.configHideDelay,validator:this.cfg.checkNumber});this.cfg.addProperty("text",{handler:this.configText,suppressEvent:true});this.cfg.addProperty("container",{value:document.body,handler:this.configContainer});}
+YAHOO.widget.Tooltip.prototype.configText=function(type,args,obj){var text=args[0];if(text){this.setBody(text);}}
+YAHOO.widget.Tooltip.prototype.configContainer=function(type,args,obj){var container=args[0];if(typeof container=='string'){this.cfg.setProperty("container",document.getElementById(container),true);}}
+YAHOO.widget.Tooltip.prototype.configContext=function(type,args,obj){var context=args[0];if(context){if(!(context instanceof Array)){if(typeof context=="string"){this.cfg.setProperty("context",[document.getElementById(context)],true);}else{this.cfg.setProperty("context",[context],true);}
+context=this.cfg.getProperty("context");}
+if(this._context){for(var c=0;c<this._context.length;++c){var el=this._context[c];YAHOO.util.Event.removeListener(el,"mouseover",this.onContextMouseOver);YAHOO.util.Event.removeListener(el,"mousemove",this.onContextMouseMove);YAHOO.util.Event.removeListener(el,"mouseout",this.onContextMouseOut);}}
+this._context=context;for(var c=0;c<this._context.length;++c){var el=this._context[c];YAHOO.util.Event.addListener(el,"mouseover",this.onContextMouseOver,this);YAHOO.util.Event.addListener(el,"mousemove",this.onContextMouseMove,this);YAHOO.util.Event.addListener(el,"mouseout",this.onContextMouseOut,this);}}}
+YAHOO.widget.Tooltip.prototype.onContextMouseMove=function(e,obj){obj.pageX=YAHOO.util.Event.getPageX(e);obj.pageY=YAHOO.util.Event.getPageY(e);}
+YAHOO.widget.Tooltip.prototype.onContextMouseOver=function(e,obj){if(obj.hideProcId){clearTimeout(obj.hideProcId);obj.hideProcId=null;}
+var context=this;YAHOO.util.Event.addListener(context,"mousemove",obj.onContextMouseMove,obj);if(context.title){obj._tempTitle=context.title;context.title="";}
+obj.showProcId=obj.doShow(e,context);}
+YAHOO.widget.Tooltip.prototype.onContextMouseOut=function(e,obj){var el=this;if(obj._tempTitle){el.title=obj._tempTitle;obj._tempTitle=null;}
+if(obj.showProcId){clearTimeout(obj.showProcId);obj.showProcId=null;}
+if(obj.hideProcId){clearTimeout(obj.hideProcId);obj.hideProcId=null;}
+obj.hideProcId=setTimeout(function(){obj.hide();},obj.cfg.getProperty("hidedelay"));}
+YAHOO.widget.Tooltip.prototype.doShow=function(e,context){var yOffset=25;if(this.browser=="opera"&&context.tagName=="A"){yOffset+=12;}
+var me=this;return setTimeout(function(){if(me._tempTitle){me.setBody(me._tempTitle);}else{me.cfg.refireEvent("text");}
+me.moveTo(me.pageX,me.pageY+yOffset);if(me.cfg.getProperty("preventoverlap")){me.preventOverlap(me.pageX,me.pageY);}
+YAHOO.util.Event.removeListener(context,"mousemove",me.onContextMouseMove);me.show();me.hideProcId=me.doHide();},this.cfg.getProperty("showdelay"));}
+YAHOO.widget.Tooltip.prototype.doHide=function(){var me=this;return setTimeout(function(){me.hide();},this.cfg.getProperty("autodismissdelay"));}
+YAHOO.widget.Tooltip.prototype.preventOverlap=function(pageX,pageY){var height=this.element.offsetHeight;var elementRegion=YAHOO.util.Dom.getRegion(this.element);elementRegion.top-=5;elementRegion.left-=5;elementRegion.right+=5;elementRegion.bottom+=5;var mousePoint=new YAHOO.util.Point(pageX,pageY);if(elementRegion.contains(mousePoint)){this.cfg.setProperty("y",(pageY-height-5))}}
+YAHOO.widget.Tooltip.prototype.toString=function(){return"Tooltip "+this.id;}
+YAHOO.widget.Panel=function(el,userConfig){YAHOO.widget.Panel.superclass.constructor.call(this,el,userConfig);}
+YAHOO.extend(YAHOO.widget.Panel,YAHOO.widget.Overlay);YAHOO.widget.Panel.CSS_PANEL="panel";YAHOO.widget.Panel.CSS_PANEL_CONTAINER="panel-container";YAHOO.widget.Panel.prototype.showMaskEvent=null;YAHOO.widget.Panel.prototype.hideMaskEvent=null;YAHOO.widget.Panel.prototype.init=function(el,userConfig){YAHOO.widget.Panel.superclass.init.call(this,el);this.beforeInitEvent.fire(YAHOO.widget.Panel);YAHOO.util.Dom.addClass(this.element,YAHOO.widget.Panel.CSS_PANEL);this.buildWrapper();if(userConfig){this.cfg.applyConfig(userConfig,true);}
+this.beforeRenderEvent.subscribe(function(){var draggable=this.cfg.getProperty("draggable");if(draggable){if(!this.header){this.setHeader(" ");}}},this,true);this.initEvent.fire(YAHOO.widget.Panel);}
+YAHOO.widget.Panel.prototype.initEvents=function(){YAHOO.widget.Panel.superclass.initEvents.call(this);this.showMaskEvent=new YAHOO.util.CustomEvent("showMask");this.hideMaskEvent=new YAHOO.util.CustomEvent("hideMask");this.dragEvent=new YAHOO.util.CustomEvent("drag");}
+YAHOO.widget.Panel.prototype.initDefaultConfig=function(){YAHOO.widget.Panel.superclass.initDefaultConfig.call(this);this.cfg.addProperty("close",{value:true,handler:this.configClose,validator:this.cfg.checkBoolean,supercedes:["visible"]});this.cfg.addProperty("draggable",{value:true,handler:this.configDraggable,validator:this.cfg.checkBoolean,supercedes:["visible"]});this.cfg.addProperty("underlay",{value:"shadow",handler:this.configUnderlay,supercedes:["visible"]});this.cfg.addProperty("modal",{value:false,handler:this.configModal,validator:this.cfg.checkBoolean,supercedes:["visible"]});this.cfg.addProperty("keylisteners",{handler:this.configKeyListeners,suppressEvent:true,supercedes:["visible"]});}
+YAHOO.widget.Panel.prototype.configClose=function(type,args,obj){var val=args[0];var doHide=function(e,obj){obj.hide();}
+if(val){if(!this.close){this.close=document.createElement("DIV");YAHOO.util.Dom.addClass(this.close,"close");if(this.isSecure){YAHOO.util.Dom.addClass(this.close,"secure");}else{YAHOO.util.Dom.addClass(this.close,"nonsecure");}
+this.close.innerHTML=" ";this.innerElement.appendChild(this.close);YAHOO.util.Event.addListener(this.close,"click",doHide,this);}else{this.close.style.display="block";}}else{if(this.close){this.close.style.display="none";}}}
+YAHOO.widget.Panel.prototype.configDraggable=function(type,args,obj){var val=args[0];if(val){if(this.header){YAHOO.util.Dom.setStyle(this.header,"cursor","move");this.registerDragDrop();}}else{if(this.dd){this.dd.unreg();}
+if(this.header){YAHOO.util.Dom.setStyle(this.header,"cursor","auto");}}}
+YAHOO.widget.Panel.prototype.configUnderlay=function(type,args,obj){var val=args[0];switch(val.toLowerCase()){case"shadow":YAHOO.util.Dom.removeClass(this.element,"matte");YAHOO.util.Dom.addClass(this.element,"shadow");if(!this.underlay){this.underlay=document.createElement("DIV");this.underlay.className="underlay";this.underlay.innerHTML=" ";this.element.appendChild(this.underlay);}
+this.sizeUnderlay();break;case"matte":YAHOO.util.Dom.removeClass(this.element,"shadow");YAHOO.util.Dom.addClass(this.element,"matte");break;case"none":default:YAHOO.util.Dom.removeClass(this.element,"shadow");YAHOO.util.Dom.removeClass(this.element,"matte");break;}}
+YAHOO.widget.Panel.prototype.configModal=function(type,args,obj){var modal=args[0];if(modal){this.buildMask();if(!YAHOO.util.Config.alreadySubscribed(this.showEvent,this.showMask,this)){this.showEvent.subscribe(this.showMask,this,true);}
+if(!YAHOO.util.Config.alreadySubscribed(this.hideEvent,this.hideMask,this)){this.hideEvent.subscribe(this.hideMask,this,true);}
+if(!YAHOO.util.Config.alreadySubscribed(YAHOO.widget.Overlay.windowResizeEvent,this.sizeMask,this)){YAHOO.widget.Overlay.windowResizeEvent.subscribe(this.sizeMask,this,true);}
+if(!YAHOO.util.Config.alreadySubscribed(YAHOO.widget.Overlay.windowScrollEvent,this.sizeMask,this)){YAHOO.widget.Overlay.windowScrollEvent.subscribe(this.sizeMask,this,true);}}else{this.beforeShowEvent.unsubscribe(this.showMask,this);this.hideEvent.unsubscribe(this.hideMask,this);YAHOO.widget.Overlay.windowResizeEvent.unsubscribe(this.sizeMask);YAHOO.widget.Overlay.windowScrollEvent.unsubscribe(this.sizeMask);}}
+YAHOO.widget.Panel.prototype.configKeyListeners=function(type,args,obj){var listeners=args[0];if(listeners){if(listeners instanceof Array){for(var i=0;i<listeners.length;i++){var listener=listeners[i];if(!YAHOO.util.Config.alreadySubscribed(this.showEvent,listener.enable,listener)){this.showEvent.subscribe(listener.enable,listener,true);}
+if(!YAHOO.util.Config.alreadySubscribed(this.hideEvent,listener.disable,listener)){this.hideEvent.subscribe(listener.disable,listener,true);this.destroyEvent.subscribe(listener.disable,listener,true);}}}else{if(!YAHOO.util.Config.alreadySubscribed(this.showEvent,listeners.enable,listeners)){this.showEvent.subscribe(listeners.enable,listeners,true);}
+if(!YAHOO.util.Config.alreadySubscribed(this.hideEvent,listeners.disable,listeners)){this.hideEvent.subscribe(listeners.disable,listeners,true);this.destroyEvent.subscribe(listeners.disable,listeners,true);}}}}
+YAHOO.widget.Panel.prototype.buildWrapper=function(){var elementParent=this.element.parentNode;var elementClone=this.element.cloneNode(true);this.innerElement=elementClone;this.innerElement.style.visibility="inherit";YAHOO.util.Dom.addClass(this.innerElement,YAHOO.widget.Panel.CSS_PANEL);var wrapper=document.createElement("DIV");wrapper.className=YAHOO.widget.Panel.CSS_PANEL_CONTAINER;wrapper.id=elementClone.id+"_c";wrapper.appendChild(elementClone);if(elementParent){elementParent.replaceChild(wrapper,this.element);}
+this.element=wrapper;var childNodes=this.innerElement.childNodes;if(childNodes){for(var i=0;i<childNodes.length;i++){var child=childNodes[i];switch(child.className){case YAHOO.widget.Module.CSS_HEADER:this.header=child;break;case YAHOO.widget.Module.CSS_BODY:this.body=child;break;case YAHOO.widget.Module.CSS_FOOTER:this.footer=child;break;}}}
+this.initDefaultConfig();}
+YAHOO.widget.Panel.prototype.sizeUnderlay=function(){if(this.underlay&&this.browser!="gecko"&&this.browser!="safari"){this.underlay.style.width=this.innerElement.offsetWidth+"px";this.underlay.style.height=this.innerElement.offsetHeight+"px";}}
+YAHOO.widget.Panel.prototype.onDomResize=function(e,obj){YAHOO.widget.Panel.superclass.onDomResize.call(this,e,obj);var me=this;setTimeout(function(){me.sizeUnderlay();},0);};YAHOO.widget.Panel.prototype.registerDragDrop=function(){if(this.header){this.dd=new YAHOO.util.DD(this.element.id,this.id);if(!this.header.id){this.header.id=this.id+"_h";}
+var me=this;this.dd.startDrag=function(){if(me.browser=="ie"){YAHOO.util.Dom.addClass(me.element,"drag");}
+if(me.cfg.getProperty("constraintoviewport")){var offsetHeight=me.element.offsetHeight;var offsetWidth=me.element.offsetWidth;var viewPortWidth=YAHOO.util.Dom.getViewportWidth();var viewPortHeight=YAHOO.util.Dom.getViewportHeight();var scrollX=window.scrollX||document.documentElement.scrollLeft;var scrollY=window.scrollY||document.documentElement.scrollTop;var topConstraint=scrollY+10;var leftConstraint=scrollX+10;var bottomConstraint=scrollY+viewPortHeight-offsetHeight-10;var rightConstraint=scrollX+viewPortWidth-offsetWidth-10;this.minX=leftConstraint
+this.maxX=rightConstraint;this.constrainX=true;this.minY=topConstraint;this.maxY=bottomConstraint;this.constrainY=true;}else{this.constrainX=false;this.constrainY=false;}
+me.dragEvent.fire("startDrag",arguments);}
+this.dd.onDrag=function(){me.syncPosition();me.cfg.refireEvent("iframe");if(this.platform=="mac"&&this.browser=="gecko"){this.showMacGeckoScrollbars();}
+me.dragEvent.fire("onDrag",arguments);}
+this.dd.endDrag=function(){if(me.browser=="ie"){YAHOO.util.Dom.removeClass(me.element,"drag");}
+me.dragEvent.fire("endDrag",arguments);}
+this.dd.setHandleElId(this.header.id);this.dd.addInvalidHandleType("INPUT");this.dd.addInvalidHandleType("SELECT");this.dd.addInvalidHandleType("TEXTAREA");}}
+YAHOO.widget.Panel.prototype.buildMask=function(){if(!this.mask){this.mask=document.createElement("DIV");this.mask.id=this.id+"_mask";this.mask.className="mask";this.mask.innerHTML=" ";var maskClick=function(e,obj){YAHOO.util.Event.stopEvent(e);}
+YAHOO.util.Event.addListener(this.mask,maskClick,this);document.body.appendChild(this.mask);}}
+YAHOO.widget.Panel.prototype.hideMask=function(){if(this.cfg.getProperty("modal")&&this.mask){this.mask.style.display="none";this.hideMaskEvent.fire();YAHOO.util.Dom.removeClass(document.body,"masked");}}
+YAHOO.widget.Panel.prototype.showMask=function(){if(this.cfg.getProperty("modal")&&this.mask){YAHOO.util.Dom.addClass(document.body,"masked");this.sizeMask();this.mask.style.display="block";this.showMaskEvent.fire();}}
+YAHOO.widget.Panel.prototype.sizeMask=function(){if(this.mask){this.mask.style.height=YAHOO.util.Dom.getDocumentHeight()+"px";this.mask.style.width=YAHOO.util.Dom.getDocumentWidth()+"px";}}
+YAHOO.widget.Panel.prototype.configHeight=function(type,args,obj){var height=args[0];var el=this.innerElement;YAHOO.util.Dom.setStyle(el,"height",height);this.cfg.refireEvent("underlay");this.cfg.refireEvent("iframe");}
+YAHOO.widget.Panel.prototype.configWidth=function(type,args,obj){var width=args[0];var el=this.innerElement;YAHOO.util.Dom.setStyle(el,"width",width);this.cfg.refireEvent("underlay");this.cfg.refireEvent("iframe");}
+YAHOO.widget.Panel.prototype.render=function(appendToNode){return YAHOO.widget.Panel.superclass.render.call(this,appendToNode,this.innerElement);}
+YAHOO.widget.Panel.prototype.toString=function(){return"Panel "+this.id;}
+YAHOO.widget.Dialog=function(el,userConfig){YAHOO.widget.Dialog.superclass.constructor.call(this,el,userConfig);}
+YAHOO.extend(YAHOO.widget.Dialog,YAHOO.widget.Panel);YAHOO.widget.Dialog.CSS_DIALOG="dialog";YAHOO.widget.Dialog.prototype.beforeSubmitEvent=null;YAHOO.widget.Dialog.prototype.submitEvent=null;YAHOO.widget.Dialog.prototype.manualSubmitEvent=null;YAHOO.widget.Dialog.prototype.asyncSubmitEvent=null;YAHOO.widget.Dialog.prototype.formSubmitEvent=null;YAHOO.widget.Dialog.prototype.cancelEvent=null;YAHOO.widget.Dialog.prototype.initDefaultConfig=function(){YAHOO.widget.Dialog.superclass.initDefaultConfig.call(this);this.callback={success:null,failure:null,argument:null,scope:this}
+this.doSubmit=function(){var method=this.cfg.getProperty("postmethod");switch(method){case"async":YAHOO.util.Connect.setForm(this.form.name);var cObj=YAHOO.util.Connect.asyncRequest('POST',this.form.action,this.callback);this.asyncSubmitEvent.fire();break;case"form":this.form.submit();this.formSubmitEvent.fire();break;case"none":case"manual":this.manualSubmitEvent.fire();break;}}
+this.cfg.addProperty("postmethod",{value:"async",validator:function(val){if(val!="form"&&val!="async"&&val!="none"&&val!="manual"){return false;}else{return true;}}});this.cfg.addProperty("buttons",{value:"none",handler:this.configButtons});}
+YAHOO.widget.Dialog.prototype.initEvents=function(){YAHOO.widget.Dialog.superclass.initEvents.call(this);this.beforeSubmitEvent=new YAHOO.util.CustomEvent("beforeSubmit");this.submitEvent=new YAHOO.util.CustomEvent("submit");this.manualSubmitEvent=new YAHOO.util.CustomEvent("manualSubmit");this.asyncSubmitEvent=new YAHOO.util.CustomEvent("asyncSubmit");this.formSubmitEvent=new YAHOO.util.CustomEvent("formSubmit");this.cancelEvent=new YAHOO.util.CustomEvent("cancel");}
+YAHOO.widget.Dialog.prototype.init=function(el,userConfig){YAHOO.widget.Dialog.superclass.init.call(this,el);this.beforeInitEvent.fire(YAHOO.widget.Dialog);YAHOO.util.Dom.addClass(this.element,YAHOO.widget.Dialog.CSS_DIALOG);this.cfg.setProperty("visible",false);if(userConfig){this.cfg.applyConfig(userConfig,true);}
+this.renderEvent.subscribe(this.registerForm,this,true);this.showEvent.subscribe(this.focusFirst,this,true);this.beforeHideEvent.subscribe(this.blurButtons,this,true);this.beforeRenderEvent.subscribe(function(){var buttonCfg=this.cfg.getProperty("buttons");if(buttonCfg&&buttonCfg!="none"){if(!this.footer){this.setFooter("");}}},this,true);this.initEvent.fire(YAHOO.widget.Dialog);}
+YAHOO.widget.Dialog.prototype.registerForm=function(){var form=this.element.getElementsByTagName("FORM")[0];if(!form){var formHTML="<form name=\"frm_"+this.id+"\" action=\"\"></form>";this.body.innerHTML+=formHTML;form=this.element.getElementsByTagName("FORM")[0];}
+this.firstFormElement=function(){for(var f=0;f<form.elements.length;f++){var el=form.elements[f];if(el.focus){if(el.type&&el.type!="hidden"){return el;break;}}}
+return null;}();this.lastFormElement=function(){for(var f=form.elements.length-1;f>=0;f--){var el=form.elements[f];if(el.focus){if(el.type&&el.type!="hidden"){return el;break;}}}
+return null;}();this.form=form;if(this.cfg.getProperty("modal")&&this.form){var me=this;var firstElement=this.firstFormElement||this.firstButton;if(firstElement){this.preventBackTab=new YAHOO.util.KeyListener(firstElement,{shift:true,keys:9},{fn:me.focusLast,scope:me,correctScope:true});this.showEvent.subscribe(this.preventBackTab.enable,this.preventBackTab,true);this.hideEvent.subscribe(this.preventBackTab.disable,this.preventBackTab,true);}
+var lastElement=this.lastButton||this.lastFormElement;if(lastElement){this.preventTabOut=new YAHOO.util.KeyListener(lastElement,{shift:false,keys:9},{fn:me.focusFirst,scope:me,correctScope:true});this.showEvent.subscribe(this.preventTabOut.enable,this.preventTabOut,true);this.hideEvent.subscribe(this.preventTabOut.disable,this.preventTabOut,true);}}}
+YAHOO.widget.Dialog.prototype.configButtons=function(type,args,obj){var buttons=args[0];if(buttons!="none"){this.buttonSpan=null;this.buttonSpan=document.createElement("SPAN");this.buttonSpan.className="button-group";for(var b=0;b<buttons.length;b++){var button=buttons[b];var htmlButton=document.createElement("BUTTON");if(button.isDefault){htmlButton.className="default";this.defaultHtmlButton=htmlButton;}
+htmlButton.appendChild(document.createTextNode(button.text));YAHOO.util.Event.addListener(htmlButton,"click",button.handler,this,true);this.buttonSpan.appendChild(htmlButton);button.htmlButton=htmlButton;if(b==0){this.firstButton=button.htmlButton;}
+if(b==(buttons.length-1)){this.lastButton=button.htmlButton;}}
+this.setFooter(this.buttonSpan);this.cfg.refireEvent("iframe");this.cfg.refireEvent("underlay");}else{if(this.buttonSpan){if(this.buttonSpan.parentNode){this.buttonSpan.parentNode.removeChild(this.buttonSpan);}
+this.buttonSpan=null;this.firstButton=null;this.lastButton=null;this.defaultHtmlButton=null;}}}
+YAHOO.widget.Dialog.prototype.configOnSuccess=function(type,args,obj){};YAHOO.widget.Dialog.prototype.configOnFailure=function(type,args,obj){};YAHOO.widget.Dialog.prototype.doSubmit=function(){};YAHOO.widget.Dialog.prototype.focusFirst=function(type,args,obj){if(args){var e=args[1];if(e){YAHOO.util.Event.stopEvent(e);}}
+if(this.firstFormElement){this.firstFormElement.focus();}else{this.focusDefaultButton();}}
+YAHOO.widget.Dialog.prototype.focusLast=function(type,args,obj){if(args){var e=args[1];if(e){YAHOO.util.Event.stopEvent(e);}}
+var buttons=this.cfg.getProperty("buttons");if(buttons&&buttons instanceof Array){this.focusLastButton();}else{if(this.lastFormElement){this.lastFormElement.focus();}}}
+YAHOO.widget.Dialog.prototype.focusDefaultButton=function(){if(this.defaultHtmlButton){this.defaultHtmlButton.focus();}}
+YAHOO.widget.Dialog.prototype.blurButtons=function(){var buttons=this.cfg.getProperty("buttons");if(buttons&&buttons instanceof Array){var html=buttons[0].htmlButton;if(html){html.blur();}}}
+YAHOO.widget.Dialog.prototype.focusFirstButton=function(){var buttons=this.cfg.getProperty("buttons");if(buttons&&buttons instanceof Array){var html=buttons[0].htmlButton;if(html){html.focus();}}}
+YAHOO.widget.Dialog.prototype.focusLastButton=function(){var buttons=this.cfg.getProperty("buttons");if(buttons&&buttons instanceof Array){var html=buttons[buttons.length-1].htmlButton;if(html){html.focus();}}}
+YAHOO.widget.Dialog.prototype.validate=function(){return true;}
+YAHOO.widget.Dialog.prototype.submit=function(){if(this.validate()){this.beforeSubmitEvent.fire();this.doSubmit();this.submitEvent.fire();this.hide();return true;}else{return false;}}
+YAHOO.widget.Dialog.prototype.cancel=function(){this.cancelEvent.fire();this.hide();}
+YAHOO.widget.Dialog.prototype.getData=function(){var form=this.form;var data={};if(form){for(var i in this.form){var formItem=form[i];if(formItem){if(formItem.tagName){switch(formItem.tagName){case"INPUT":switch(formItem.type){case"checkbox":data[i]=formItem.checked;break;case"textbox":case"text":case"hidden":data[i]=formItem.value;break;}
+break;case"TEXTAREA":data[i]=formItem.value;break;case"SELECT":var val=new Array();for(var x=0;x<formItem.options.length;x++){var option=formItem.options[x];if(option.selected){var selval=option.value;if(!selval||selval==""){selval=option.text;}
+val[val.length]=selval;}}
+data[i]=val;break;}}else if(formItem[0]&&formItem[0].tagName){switch(formItem[0].tagName){case"INPUT":switch(formItem[0].type){case"radio":for(var r=0;r<formItem.length;r++){var radio=formItem[r];if(radio.checked){data[radio.name]=radio.value;break;}}
+break;case"checkbox":var cbArray=new Array();for(var c=0;c<formItem.length;c++){var check=formItem[c];if(check.checked){cbArray[cbArray.length]=check.value;}}
+data[formItem[0].name]=cbArray;break;}}}}}}
+return data;}
+YAHOO.widget.Dialog.prototype.toString=function(){return"Dialog "+this.id;}
+YAHOO.widget.SimpleDialog=function(el,userConfig){YAHOO.widget.SimpleDialog.superclass.constructor.call(this,el,userConfig);}
+YAHOO.extend(YAHOO.widget.SimpleDialog,YAHOO.widget.Dialog);YAHOO.widget.SimpleDialog.ICON_BLOCK="nt/ic/ut/bsc/blck16_1.gif";YAHOO.widget.SimpleDialog.ICON_ALARM="nt/ic/ut/bsc/alrt16_1.gif";YAHOO.widget.SimpleDialog.ICON_HELP="nt/ic/ut/bsc/hlp16_1.gif";YAHOO.widget.SimpleDialog.ICON_INFO="nt/ic/ut/bsc/info16_1.gif";YAHOO.widget.SimpleDialog.ICON_WARN="nt/ic/ut/bsc/warn16_1.gif";YAHOO.widget.SimpleDialog.ICON_TIP="nt/ic/ut/bsc/tip16_1.gif";YAHOO.widget.SimpleDialog.CSS_SIMPLEDIALOG="simple-dialog";YAHOO.widget.SimpleDialog.prototype.initDefaultConfig=function(){YAHOO.widget.SimpleDialog.superclass.initDefaultConfig.call(this);this.cfg.addProperty("icon",{value:"none",handler:this.configIcon,suppressEvent:true});this.cfg.addProperty("text",{value:"",handler:this.configText,suppressEvent:true,supercedes:["icon"]});}
+YAHOO.widget.SimpleDialog.prototype.init=function(el,userConfig){YAHOO.widget.SimpleDialog.superclass.init.call(this,el);this.beforeInitEvent.fire(YAHOO.widget.SimpleDialog);YAHOO.util.Dom.addClass(this.element,YAHOO.widget.SimpleDialog.CSS_SIMPLEDIALOG);this.cfg.queueProperty("postmethod","manual");if(userConfig){this.cfg.applyConfig(userConfig,true);}
+this.beforeRenderEvent.subscribe(function(){if(!this.body){this.setBody("");}},this,true);this.initEvent.fire(YAHOO.widget.SimpleDialog);}
+YAHOO.widget.SimpleDialog.prototype.registerForm=function(){YAHOO.widget.SimpleDialog.superclass.registerForm.call(this);this.form.innerHTML+="<input type=\"hidden\" name=\""+this.id+"\" value=\"\"/>";}
+YAHOO.widget.SimpleDialog.prototype.configIcon=function(type,args,obj){var icon=args[0];if(icon&&icon!="none"){var iconHTML="<img src=\""+this.imageRoot+icon+"\" class=\"icon\" />";this.body.innerHTML=iconHTML+this.body.innerHTML;}}
+YAHOO.widget.SimpleDialog.prototype.configText=function(type,args,obj){var text=args[0];if(text){this.setBody(text);this.cfg.refireEvent("icon");}}
+YAHOO.widget.SimpleDialog.prototype.toString=function(){return"SimpleDialog "+this.id;}
+YAHOO.widget.ContainerEffect=function(overlay,attrIn,attrOut,targetElement,animClass){if(!animClass){animClass=YAHOO.util.Anim;}
+this.overlay=overlay;this.attrIn=attrIn;this.attrOut=attrOut;this.targetElement=targetElement||overlay.element;this.animClass=animClass;}
+YAHOO.widget.ContainerEffect.prototype.init=function(){this.beforeAnimateInEvent=new YAHOO.util.CustomEvent("beforeAnimateIn");this.beforeAnimateOutEvent=new YAHOO.util.CustomEvent("beforeAnimateOut");this.animateInCompleteEvent=new YAHOO.util.CustomEvent("animateInComplete");this.animateOutCompleteEvent=new YAHOO.util.CustomEvent("animateOutComplete");this.animIn=new this.animClass(this.targetElement,this.attrIn.attributes,this.attrIn.duration,this.attrIn.method);this.animIn.onStart.subscribe(this.handleStartAnimateIn,this);this.animIn.onTween.subscribe(this.handleTweenAnimateIn,this);this.animIn.onComplete.subscribe(this.handleCompleteAnimateIn,this);this.animOut=new this.animClass(this.targetElement,this.attrOut.attributes,this.attrOut.duration,this.attrOut.method);this.animOut.onStart.subscribe(this.handleStartAnimateOut,this);this.animOut.onTween.subscribe(this.handleTweenAnimateOut,this);this.animOut.onComplete.subscribe(this.handleCompleteAnimateOut,this);}
+YAHOO.widget.ContainerEffect.prototype.animateIn=function(){this.beforeAnimateInEvent.fire();this.animIn.animate();}
+YAHOO.widget.ContainerEffect.prototype.animateOut=function(){this.beforeAnimateOutEvent.fire();this.animOut.animate();}
+YAHOO.widget.ContainerEffect.prototype.handleStartAnimateIn=function(type,args,obj){}
+YAHOO.widget.ContainerEffect.prototype.handleTweenAnimateIn=function(type,args,obj){}
+YAHOO.widget.ContainerEffect.prototype.handleCompleteAnimateIn=function(type,args,obj){}
+YAHOO.widget.ContainerEffect.prototype.handleStartAnimateOut=function(type,args,obj){}
+YAHOO.widget.ContainerEffect.prototype.handleTweenAnimateOut=function(type,args,obj){}
+YAHOO.widget.ContainerEffect.prototype.handleCompleteAnimateOut=function(type,args,obj){}
+YAHOO.widget.ContainerEffect.prototype.toString=function(){var output="ContainerEffect";if(this.overlay){output+=" ["+this.overlay.toString()+"]";}
+return output;}
+YAHOO.widget.ContainerEffect.FADE=function(overlay,dur){var fade=new YAHOO.widget.ContainerEffect(overlay,{attributes:{opacity:{from:0,to:1}},duration:dur,method:YAHOO.util.Easing.easeIn},{attributes:{opacity:{to:0}},duration:dur,method:YAHOO.util.Easing.easeOut},overlay.element);fade.handleStartAnimateIn=function(type,args,obj){YAHOO.util.Dom.addClass(obj.overlay.element,"hide-select");if(!obj.overlay.underlay){obj.overlay.cfg.refireEvent("underlay");}
+if(obj.overlay.underlay){obj.initialUnderlayOpacity=YAHOO.util.Dom.getStyle(obj.overlay.underlay,"opacity");obj.overlay.underlay.style.filter=null;}
+YAHOO.util.Dom.setStyle(obj.overlay.element,"visibility","visible");YAHOO.util.Dom.setStyle(obj.overlay.element,"opacity",0);}
+fade.handleCompleteAnimateIn=function(type,args,obj){YAHOO.util.Dom.removeClass(obj.overlay.element,"hide-select");if(obj.overlay.element.style.filter){obj.overlay.element.style.filter=null;}
+if(obj.overlay.underlay){YAHOO.util.Dom.setStyle(obj.overlay.underlay,"opacity",obj.initialUnderlayOpacity);}
+obj.overlay.cfg.refireEvent("iframe");obj.animateInCompleteEvent.fire();}
+fade.handleStartAnimateOut=function(type,args,obj){YAHOO.util.Dom.addClass(obj.overlay.element,"hide-select");if(obj.overlay.underlay){obj.overlay.underlay.style.filter=null;}}
+fade.handleCompleteAnimateOut=function(type,args,obj){YAHOO.util.Dom.removeClass(obj.overlay.element,"hide-select");if(obj.overlay.element.style.filter){obj.overlay.element.style.filter=null;}
+YAHOO.util.Dom.setStyle(obj.overlay.element,"visibility","hidden");YAHOO.util.Dom.setStyle(obj.overlay.element,"opacity",1);obj.overlay.cfg.refireEvent("iframe");obj.animateOutCompleteEvent.fire();};fade.init();return fade;};YAHOO.widget.ContainerEffect.SLIDE=function(overlay,dur){var x=overlay.cfg.getProperty("x")||YAHOO.util.Dom.getX(overlay.element);var y=overlay.cfg.getProperty("y")||YAHOO.util.Dom.getY(overlay.element);var clientWidth=YAHOO.util.Dom.getClientWidth();var offsetWidth=overlay.element.offsetWidth;var slide=new YAHOO.widget.ContainerEffect(overlay,{attributes:{points:{to:[x,y]}},duration:dur,method:YAHOO.util.Easing.easeIn},{attributes:{points:{to:[(clientWidth+25),y]}},duration:dur,method:YAHOO.util.Easing.easeOut},overlay.element,YAHOO.util.Motion);slide.handleStartAnimateIn=function(type,args,obj){obj.overlay.element.style.left=(-25-offsetWidth)+"px";obj.overlay.element.style.top=y+"px";}
+slide.handleTweenAnimateIn=function(type,args,obj){var pos=YAHOO.util.Dom.getXY(obj.overlay.element);var currentX=pos[0];var currentY=pos[1];if(YAHOO.util.Dom.getStyle(obj.overlay.element,"visibility")=="hidden"&¤tX<x){YAHOO.util.Dom.setStyle(obj.overlay.element,"visibility","visible");}
+obj.overlay.cfg.setProperty("xy",[currentX,currentY],true);obj.overlay.cfg.refireEvent("iframe");}
+slide.handleCompleteAnimateIn=function(type,args,obj){obj.overlay.cfg.setProperty("xy",[x,y],true);obj.startX=x;obj.startY=y;obj.overlay.cfg.refireEvent("iframe");obj.animateInCompleteEvent.fire();}
+slide.handleStartAnimateOut=function(type,args,obj){var clientWidth=YAHOO.util.Dom.getViewportWidth();var pos=YAHOO.util.Dom.getXY(obj.overlay.element);var x=pos[0];var y=pos[1];var currentTo=obj.animOut.attributes.points.to;obj.animOut.attributes.points.to=[(clientWidth+25),y];}
+slide.handleTweenAnimateOut=function(type,args,obj){var pos=YAHOO.util.Dom.getXY(obj.overlay.element);var x=pos[0];var y=pos[1];obj.overlay.cfg.setProperty("xy",[x,y],true);obj.overlay.cfg.refireEvent("iframe");}
+slide.handleCompleteAnimateOut=function(type,args,obj){YAHOO.util.Dom.setStyle(obj.overlay.element,"visibility","hidden");var offsetWidth=obj.overlay.element.offsetWidth;obj.overlay.cfg.setProperty("xy",[x,y]);obj.animateOutCompleteEvent.fire();};slide.init();return slide;}
\ No newline at end of file
Added: branches/tomek/portal-dnd/dndRenderer.war/js/container/container.js
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/container/container.js 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/container/container.js 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,3918 @@
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+Version 0.11.1
+*/
+
+/**
+* @class
+* Config is a utility used within an object to allow the implementer to maintain a list of local configuration properties and listen for changes to those properties dynamically using CustomEvent. The initial values are also maintained so that the configuration can be reset at any given point to its initial state.
+* @param {object} owner The owner object to which this Config object belongs
+* @constructor
+*/
+YAHOO.util.Config = function(owner) {
+ if (owner) {
+ this.init(owner);
+ }
+}
+
+YAHOO.util.Config.prototype = {
+
+ /**
+ * Object reference to the owner of this Config object
+ * @type object
+ */
+ owner : null,
+
+ /**
+ * Object reference to the owner of this Config object
+ * args: key, value
+ * @type YAHOO.util.CustomEvent
+ */
+ configChangedEvent : null,
+
+ /**
+ * Boolean flag that specifies whether a queue is currently being executed
+ * @type boolean
+ */
+ queueInProgress : false,
+
+ /**
+ * Adds a property to the Config object's private config hash.
+ * @param {string} key The configuration property's name
+ * @param {object} propertyObject The object containing all of this property's arguments
+ */
+ addProperty : function(key, propertyObject){},
+
+ /**
+ * Returns a key-value configuration map of the values currently set in the Config object.
+ * @return {object} The current config, represented in a key-value map
+ */
+ getConfig : function(){},
+
+ /**
+ * Returns the value of specified property.
+ * @param {key} The name of the property
+ * @return {object} The value of the specified property
+ */
+ getProperty : function(key){},
+
+ /**
+ * Resets the specified property's value to its initial value.
+ * @param {key} The name of the property
+ */
+ resetProperty : function(key){},
+
+ /**
+ * Sets the value of a property. If the silent property is passed as true, the property's event will not be fired.
+ * @param {key} The name of the property
+ * @param {value} The value to set the property to
+ * @param {boolean} Whether the value should be set silently, without firing the property event.
+ * @return {boolean} true, if the set was successful, false if it failed.
+ */
+ setProperty : function(key,value,silent){},
+
+ /**
+ * Sets the value of a property and queues its event to execute. If the event is already scheduled to execute, it is
+ * moved from its current position to the end of the queue.
+ * @param {key} The name of the property
+ * @param {value} The value to set the property to
+ * @return {boolean} true, if the set was successful, false if it failed.
+ */
+ queueProperty : function(key,value){},
+
+ /**
+ * Fires the event for a property using the property's current value.
+ * @param {key} The name of the property
+ */
+ refireEvent : function(key){},
+
+ /**
+ * Applies a key-value object literal to the configuration, replacing any existing values, and queueing the property events.
+ * Although the values will be set, fireQueue() must be called for their associated events to execute.
+ * @param {object} userConfig The configuration object literal
+ * @param {boolean} init When set to true, the initialConfig will be set to the userConfig passed in, so that calling a reset will reset the properties to the passed values.
+ */
+ applyConfig : function(userConfig,init){},
+
+ /**
+ * Refires the events for all configuration properties using their current values.
+ */
+ refresh : function(){},
+
+ /**
+ * Fires the normalized list of queued property change events
+ */
+ fireQueue : function(){},
+
+ /**
+ * Subscribes an external handler to the change event for any given property.
+ * @param {string} key The property name
+ * @param {Function} handler The handler function to use subscribe to the property's event
+ * @param {object} obj The object to use for scoping the event handler (see CustomEvent documentation)
+ * @param {boolean} override Optional. If true, will override "this" within the handler to map to the scope object passed into the method.
+ */
+ subscribeToConfigEvent : function(key,handler,obj,override){},
+
+ /**
+ * Unsubscribes an external handler from the change event for any given property.
+ * @param {string} key The property name
+ * @param {Function} handler The handler function to use subscribe to the property's event
+ * @param {object} obj The object to use for scoping the event handler (see CustomEvent documentation)
+ */
+ unsubscribeFromConfigEvent: function(key,handler,obj){},
+
+ /**
+ * Validates that the value passed in is a boolean.
+ * @param {object} val The value to validate
+ * @return {boolean} true, if the value is valid
+ */
+ checkBoolean: function(val) {
+ if (typeof val == 'boolean') {
+ return true;
+ } else {
+ return false;
+ }
+ },
+
+ /**
+ * Validates that the value passed in is a number.
+ * @param {object} val The value to validate
+ * @return {boolean} true, if the value is valid
+ */
+ checkNumber: function(val) {
+ if (isNaN(val)) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+}
+
+
+/**
+* Initializes the configuration object and all of its local members.
+* @param {object} owner The owner object to which this Config object belongs
+*/
+YAHOO.util.Config.prototype.init = function(owner) {
+
+ this.owner = owner;
+ this.configChangedEvent = new YAHOO.util.CustomEvent("configChanged");
+ this.queueInProgress = false;
+
+ /* Private Members */
+
+ var config = {};
+ var initialConfig = {};
+ var eventQueue = [];
+
+ /**
+ * @private
+ * Fires a configuration property event using the specified value.
+ * @param {string} key The configuration property's name
+ * @param {value} object The value of the correct type for the property
+ */
+ var fireEvent = function( key, value ) {
+ key = key.toLowerCase();
+
+ var property = config[key];
+
+ if (typeof property != 'undefined' && property.event) {
+ property.event.fire(value);
+ }
+ }
+ /* End Private Members */
+
+ this.addProperty = function( key, propertyObject ) {
+ key = key.toLowerCase();
+
+ config[key] = propertyObject;
+
+ propertyObject.event = new YAHOO.util.CustomEvent(key);
+ propertyObject.key = key;
+
+ if (propertyObject.handler) {
+ propertyObject.event.subscribe(propertyObject.handler, this.owner, true);
+ }
+
+ this.setProperty(key, propertyObject.value, true);
+
+ if (! propertyObject.suppressEvent) {
+ this.queueProperty(key, propertyObject.value);
+ }
+ }
+
+ this.getConfig = function() {
+ var cfg = {};
+
+ for (var prop in config) {
+ var property = config[prop]
+ if (typeof property != 'undefined' && property.event) {
+ cfg[prop] = property.value;
+ }
+ }
+
+ return cfg;
+ }
+
+ this.getProperty = function(key) {
+ key = key.toLowerCase();
+
+ var property = config[key];
+ if (typeof property != 'undefined' && property.event) {
+ return property.value;
+ } else {
+ return undefined;
+ }
+ }
+
+ this.resetProperty = function(key) {
+ key = key.toLowerCase();
+
+ var property = config[key];
+ if (typeof property != 'undefined' && property.event) {
+ this.setProperty(key, initialConfig[key].value);
+ } else {
+ return undefined;
+ }
+ }
+
+ this.setProperty = function(key, value, silent) {
+ key = key.toLowerCase();
+
+ if (this.queueInProgress && ! silent) {
+ this.queueProperty(key,value); // Currently running through a queue...
+ return true;
+ } else {
+ var property = config[key];
+ if (typeof property != 'undefined' && property.event) {
+ if (property.validator && ! property.validator(value)) { // validator
+ return false;
+ } else {
+ property.value = value;
+ if (! silent) {
+ fireEvent(key, value);
+ this.configChangedEvent.fire([key, value]);
+ }
+ return true;
+ }
+ } else {
+ return false;
+ }
+ }
+ }
+
+ this.queueProperty = function(key, value) {
+ key = key.toLowerCase();
+
+ var property = config[key];
+
+ if (typeof property != 'undefined' && property.event) {
+ if (typeof value != 'undefined' && property.validator && ! property.validator(value)) { // validator
+ return false;
+ } else {
+
+ if (typeof value != 'undefined') {
+ property.value = value;
+ } else {
+ value = property.value;
+ }
+
+ var foundDuplicate = false;
+
+ for (var i=0;i<eventQueue.length;i++) {
+ var queueItem = eventQueue[i];
+
+ if (queueItem) {
+ var queueItemKey = queueItem[0];
+ var queueItemValue = queueItem[1];
+
+ if (queueItemKey.toLowerCase() == key) {
+ // found a dupe... push to end of queue, null current item, and break
+ eventQueue[i] = null;
+ eventQueue.push([key, (typeof value != 'undefined' ? value : queueItemValue)]);
+ foundDuplicate = true;
+ break;
+ }
+ }
+ }
+
+ if (! foundDuplicate && typeof value != 'undefined') { // this is a refire, or a new property in the queue
+ eventQueue.push([key, value]);
+ }
+ }
+
+ if (property.supercedes) {
+ for (var s=0;s<property.supercedes.length;s++) {
+ var supercedesCheck = property.supercedes[s];
+
+ for (var q=0;q<eventQueue.length;q++) {
+ var queueItemCheck = eventQueue[q];
+
+ if (queueItemCheck) {
+ var queueItemCheckKey = queueItemCheck[0];
+ var queueItemCheckValue = queueItemCheck[1];
+
+ if ( queueItemCheckKey.toLowerCase() == supercedesCheck.toLowerCase() ) {
+ eventQueue.push([queueItemCheckKey, queueItemCheckValue]);
+ eventQueue[q] = null;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ this.refireEvent = function(key) {
+ key = key.toLowerCase();
+
+ var property = config[key];
+ if (typeof property != 'undefined' && property.event && typeof property.value != 'undefined') {
+ if (this.queueInProgress) {
+ this.queueProperty(key);
+ } else {
+ fireEvent(key, property.value);
+ }
+ }
+ }
+
+ this.applyConfig = function(userConfig, init) {
+ if (init) {
+ initialConfig = userConfig;
+ }
+ for (var prop in userConfig) {
+ this.queueProperty(prop, userConfig[prop]);
+ }
+ }
+
+ this.refresh = function() {
+ for (var prop in config) {
+ this.refireEvent(prop);
+ }
+ }
+
+ this.fireQueue = function() {
+ this.queueInProgress = true;
+ for (var i=0;i<eventQueue.length;i++) {
+ var queueItem = eventQueue[i];
+ if (queueItem) {
+ var key = queueItem[0];
+ var value = queueItem[1];
+
+ var property = config[key];
+ property.value = value;
+
+ fireEvent(key,value);
+ }
+ }
+
+ this.queueInProgress = false;
+ eventQueue = new Array();
+ }
+
+ this.subscribeToConfigEvent = function(key, handler, obj, override) {
+ key = key.toLowerCase();
+
+ var property = config[key];
+ if (typeof property != 'undefined' && property.event) {
+ if (! YAHOO.util.Config.alreadySubscribed(property.event, handler, obj)) {
+ property.event.subscribe(handler, obj, override);
+ }
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+
+ this.unsubscribeFromConfigEvent = function(key, handler, obj) {
+ key = key.toLowerCase();
+
+ var property = config[key];
+ if (typeof property != 'undefined' && property.event) {
+ return property.event.unsubscribe(handler, obj);
+ } else {
+ return false;
+ }
+ }
+
+ this.toString = function() {
+ var output = "Config";
+ if (this.owner) {
+ output += " [" + this.owner.toString() + "]";
+ }
+ return output;
+ }
+
+ this.outputEventQueue = function() {
+ var output = "";
+ for (var q=0;q<eventQueue.length;q++) {
+ var queueItem = eventQueue[q];
+ if (queueItem) {
+ output += queueItem[0] + "=" + queueItem[1] + ", ";
+ }
+ }
+ return output;
+ }
+}
+
+/**
+* Checks to determine if a particular function/object pair are already subscribed to the specified CustomEvent
+* @param {YAHOO.util.CustomEvent} evt The CustomEvent for which to check the subscriptions
+* @param {Function} fn The function to look for in the subscribers list
+* @param {object} obj The execution scope object for the subscription
+* @return {boolean} true, if the function/object pair is already subscribed to the CustomEvent passed in
+*/
+YAHOO.util.Config.alreadySubscribed = function(evt, fn, obj) {
+ for (var e=0;e<evt.subscribers.length;e++) {
+ var subsc = evt.subscribers[e];
+ if (subsc && subsc.obj == obj && subsc.fn == fn) {
+ return true;
+ break;
+ }
+ }
+ return false;
+}
+
+/**
+* @class
+* Module is a JavaScript representation of the Standard Module Format. Standard Module Format is a simple standard for markup containers where child nodes representing the header, body, and footer of the content are denoted using the CSS classes "hd", "bd", and "ft" respectively. Module is the base class for all other classes in the YUI Container package.
+* @param {string} el The element ID representing the Module <em>OR</em>
+* @param {Element} el The element representing the Module
+* @param {object} userConfig The configuration object literal containing the configuration that should be set for this module. See configuration documentation for more details.
+* @constructor
+*/
+YAHOO.widget.Module = function(el, userConfig) {
+ if (el) {
+ this.init(el, userConfig);
+ }
+}
+
+/**
+* Constant representing the prefix path to use for non-secure images
+* @type string
+*/
+YAHOO.widget.Module.IMG_ROOT = "http://us.i1.yimg.com/us.yimg.com/i/";
+
+/**
+* Constant representing the prefix path to use for securely served images
+* @type string
+*/
+YAHOO.widget.Module.IMG_ROOT_SSL = "https://a248.e.akamai.net/sec.yimg.com/i/";
+
+/**
+* Constant for the default CSS class name that represents a Module
+* @type string
+* @final
+*/
+YAHOO.widget.Module.CSS_MODULE = "module";
+
+/**
+* Constant representing the module header
+* @type string
+* @final
+*/
+YAHOO.widget.Module.CSS_HEADER = "hd";
+
+/**
+* Constant representing the module body
+* @type string
+* @final
+*/
+YAHOO.widget.Module.CSS_BODY = "bd";
+
+/**
+* Constant representing the module footer
+* @type string
+* @final
+*/
+YAHOO.widget.Module.CSS_FOOTER = "ft";
+
+/**
+* Constant representing the url for the "src" attribute of the iframe used to monitor changes to the browser's base font size
+* @type string
+* @final
+*/
+YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL = null;
+
+YAHOO.widget.Module.prototype = {
+
+ /**
+ * The class's constructor function
+ * @type function
+ */
+ constructor : YAHOO.widget.Module,
+
+ /**
+ * The main module element that contains the header, body, and footer
+ * @type Element
+ */
+ element : null,
+
+ /**
+ * The header element, denoted with CSS class "hd"
+ * @type Element
+ */
+ header : null,
+
+ /**
+ * The body element, denoted with CSS class "bd"
+ * @type Element
+ */
+ body : null,
+
+ /**
+ * The footer element, denoted with CSS class "ft"
+ * @type Element
+ */
+ footer : null,
+
+ /**
+ * The id of the element
+ * @type string
+ */
+ id : null,
+
+ /**
+ * Array of elements
+ * @type Element[]
+ */
+ childNodesInDOM : null,
+
+ /**
+ * The string representing the image root
+ * @type string
+ */
+ imageRoot : YAHOO.widget.Module.IMG_ROOT,
+
+ /**
+ * CustomEvent fired prior to class initalization.
+ * args: class reference of the initializing class, such as this.beforeInitEvent.fire(YAHOO.widget.Module)
+ * @type YAHOO.util.CustomEvent
+ */
+ beforeInitEvent : null,
+
+ /**
+ * CustomEvent fired after class initalization.
+ * args: class reference of the initializing class, such as this.initEvent.fire(YAHOO.widget.Module)
+ * @type YAHOO.util.CustomEvent
+ */
+ initEvent : null,
+
+ /**
+ * CustomEvent fired when the Module is appended to the DOM
+ * args: none
+ * @type YAHOO.util.CustomEvent
+ */
+ appendEvent : null,
+
+ /**
+ * CustomEvent fired before the Module is rendered
+ * args: none
+ * @type YAHOO.util.CustomEvent
+ */
+ beforeRenderEvent : null,
+
+ /**
+ * CustomEvent fired after the Module is rendered
+ * args: none
+ * @type YAHOO.util.CustomEvent
+ */
+ renderEvent : null,
+
+ /**
+ * CustomEvent fired when the header content of the Module is modified
+ * args: string/element representing the new header content
+ * @type YAHOO.util.CustomEvent
+ */
+ changeHeaderEvent : null,
+
+ /**
+ * CustomEvent fired when the body content of the Module is modified
+ * args: string/element representing the new body content
+ * @type YAHOO.util.CustomEvent
+ */
+ changeBodyEvent : null,
+
+ /**
+ * CustomEvent fired when the footer content of the Module is modified
+ * args: string/element representing the new footer content
+ * @type YAHOO.util.CustomEvent
+ */
+ changeFooterEvent : null,
+
+ /**
+ * CustomEvent fired when the content of the Module is modified
+ * args: none
+ * @type YAHOO.util.CustomEvent
+ */
+ changeContentEvent : null,
+
+ /**
+ * CustomEvent fired when the Module is destroyed
+ * args: none
+ * @type YAHOO.util.CustomEvent
+ */
+ destroyEvent : null,
+
+ /**
+ * CustomEvent fired before the Module is shown
+ * args: none
+ * @type YAHOO.util.CustomEvent
+ */
+ beforeShowEvent : null,
+
+ /**
+ * CustomEvent fired after the Module is shown
+ * args: none
+ * @type YAHOO.util.CustomEvent
+ */
+ showEvent : null,
+
+ /**
+ * CustomEvent fired before the Module is hidden
+ * args: none
+ * @type YAHOO.util.CustomEvent
+ */
+ beforeHideEvent : null,
+
+ /**
+ * CustomEvent fired after the Module is hidden
+ * args: none
+ * @type YAHOO.util.CustomEvent
+ */
+ hideEvent : null,
+
+ /**
+ * Initializes the custom events for Module which are fired automatically at appropriate times by the Module class.
+ */
+ initEvents : function() {
+
+ this.beforeInitEvent = new YAHOO.util.CustomEvent("beforeInit");
+ this.initEvent = new YAHOO.util.CustomEvent("init");
+
+ this.appendEvent = new YAHOO.util.CustomEvent("append");
+
+ this.beforeRenderEvent = new YAHOO.util.CustomEvent("beforeRender");
+ this.renderEvent = new YAHOO.util.CustomEvent("render");
+
+ this.changeHeaderEvent = new YAHOO.util.CustomEvent("changeHeader");
+ this.changeBodyEvent = new YAHOO.util.CustomEvent("changeBody");
+ this.changeFooterEvent = new YAHOO.util.CustomEvent("changeFooter");
+
+ this.changeContentEvent = new YAHOO.util.CustomEvent("changeContent");
+
+ this.destroyEvent = new YAHOO.util.CustomEvent("destroy");
+ this.beforeShowEvent = new YAHOO.util.CustomEvent("beforeShow");
+ this.showEvent = new YAHOO.util.CustomEvent("show");
+ this.beforeHideEvent = new YAHOO.util.CustomEvent("beforeHide");
+ this.hideEvent = new YAHOO.util.CustomEvent("hide");
+ },
+
+ /**
+ * String representing the current user-agent platform
+ * @type string
+ */
+ platform : function() {
+ var ua = navigator.userAgent.toLowerCase();
+ if (ua.indexOf("windows") != -1 || ua.indexOf("win32") != -1) {
+ return "windows";
+ } else if (ua.indexOf("macintosh") != -1) {
+ return "mac";
+ } else {
+ return false;
+ }
+ }(),
+
+ /**
+ * String representing the current user-agent browser
+ * @type string
+ */
+ browser : function() {
+ var ua = navigator.userAgent.toLowerCase();
+ if (ua.indexOf('opera')!=-1) { // Opera (check first in case of spoof)
+ return 'opera';
+ } else if (ua.indexOf('msie 7')!=-1) { // IE7
+ return 'ie7';
+ } else if (ua.indexOf('msie') !=-1) { // IE
+ return 'ie';
+ } else if (ua.indexOf('safari')!=-1) { // Safari (check before Gecko because it includes "like Gecko")
+ return 'safari';
+ } else if (ua.indexOf('gecko') != -1) { // Gecko
+ return 'gecko';
+ } else {
+ return false;
+ }
+ }(),
+
+ /**
+ * Boolean representing whether or not the current browsing context is secure (https)
+ * @type boolean
+ */
+ isSecure : function() {
+ if (window.location.href.toLowerCase().indexOf("https") == 0) {
+ return true;
+ } else {
+ return false;
+ }
+ }(),
+
+ /**
+ * Initializes the custom events for Module which are fired automatically at appropriate times by the Module class.
+ */
+ initDefaultConfig : function() {
+ // Add properties //
+
+ this.cfg.addProperty("visible", { value:true, handler:this.configVisible, validator:this.cfg.checkBoolean } );
+ this.cfg.addProperty("effect", { suppressEvent:true, supercedes:["visible"] } );
+ this.cfg.addProperty("monitorresize", { value:true, handler:this.configMonitorResize } );
+ },
+
+ /**
+ * The Module class's initialization method, which is executed for Module and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present.
+ * @param {string} el The element ID representing the Module <em>OR</em>
+ * @param {Element} el The element representing the Module
+ * @param {object} userConfig The configuration object literal containing the configuration that should be set for this module. See configuration documentation for more details.
+ */
+ init : function(el, userConfig) {
+
+ this.initEvents();
+
+ this.beforeInitEvent.fire(YAHOO.widget.Module);
+
+ this.cfg = new YAHOO.util.Config(this);
+
+ if (this.isSecure) {
+ this.imageRoot = YAHOO.widget.Module.IMG_ROOT_SSL;
+ }
+
+ if (typeof el == "string") {
+ var elId = el;
+
+ el = document.getElementById(el);
+ if (! el) {
+ el = document.createElement("DIV");
+ el.id = elId;
+ }
+ }
+
+ this.element = el;
+
+ if (el.id) {
+ this.id = el.id;
+ }
+
+ var childNodes = this.element.childNodes;
+
+ if (childNodes) {
+ for (var i=0;i<childNodes.length;i++) {
+ var child = childNodes[i];
+ switch (child.className) {
+ case YAHOO.widget.Module.CSS_HEADER:
+ this.header = child;
+ break;
+ case YAHOO.widget.Module.CSS_BODY:
+ this.body = child;
+ break;
+ case YAHOO.widget.Module.CSS_FOOTER:
+ this.footer = child;
+ break;
+ }
+ }
+ }
+
+ this.initDefaultConfig();
+
+ YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Module.CSS_MODULE);
+
+ if (userConfig) {
+ this.cfg.applyConfig(userConfig, true);
+ }
+
+ // Subscribe to the fireQueue() method of Config so that any queued configuration changes are
+ // excecuted upon render of the Module
+ if (! YAHOO.util.Config.alreadySubscribed(this.renderEvent, this.cfg.fireQueue, this.cfg)) {
+ this.renderEvent.subscribe(this.cfg.fireQueue, this.cfg, true);
+ }
+
+ this.initEvent.fire(YAHOO.widget.Module);
+ },
+
+ /**
+ * Initialized an empty DOM element that is placed out of the visible area that can be used to detect text resize.
+ */
+ initResizeMonitor : function() {
+
+ if(this.browser != "opera") {
+
+ var resizeMonitor = document.getElementById("_yuiResizeMonitor");
+
+ if (! resizeMonitor) {
+
+ resizeMonitor = document.createElement("iframe");
+
+ var bIE = (this.browser.indexOf("ie") === 0);
+
+ if(this.isSecure && this.RESIZE_MONITOR_SECURE_URL && bIE) {
+
+ resizeMonitor.src = this.RESIZE_MONITOR_SECURE_URL;
+
+ }
+
+ resizeMonitor.id = "_yuiResizeMonitor";
+ resizeMonitor.style.visibility = "hidden";
+
+ document.body.appendChild(resizeMonitor);
+
+ resizeMonitor.style.width = "10em";
+ resizeMonitor.style.height = "10em";
+ resizeMonitor.style.position = "absolute";
+
+ var nLeft = -1 * resizeMonitor.offsetWidth,
+ nTop = -1 * resizeMonitor.offsetHeight;
+
+ resizeMonitor.style.top = nTop + "px";
+ resizeMonitor.style.left = nLeft + "px";
+ resizeMonitor.style.borderStyle = "none";
+ resizeMonitor.style.borderWidth = "0";
+ YAHOO.util.Dom.setStyle(resizeMonitor, "opacity", "0");
+
+ resizeMonitor.style.visibility = "visible";
+
+ if(!bIE) {
+
+ var doc = resizeMonitor.contentWindow.document;
+
+ doc.open();
+ doc.close();
+
+ }
+
+ }
+
+ if(resizeMonitor && resizeMonitor.contentWindow) {
+
+ this.resizeMonitor = resizeMonitor;
+
+ YAHOO.util.Event.addListener(this.resizeMonitor.contentWindow, "resize", this.onDomResize, this, true);
+
+ }
+
+ }
+
+ },
+
+ /**
+ * Event handler fired when the resize monitor element is resized.
+ */
+ onDomResize : function(e, obj) {
+
+ var nLeft = -1 * this.resizeMonitor.offsetWidth,
+ nTop = -1 * this.resizeMonitor.offsetHeight;
+
+ this.resizeMonitor.style.top = nTop + "px";
+ this.resizeMonitor.style.left = nLeft + "px";
+
+ },
+
+ /**
+ * Sets the Module's header content to the HTML specified, or appends the passed element to the header. If no header is present, one will be automatically created.
+ * @param {string} headerContent The HTML used to set the header <em>OR</em>
+ * @param {Element} headerContent The Element to append to the header
+ */
+ setHeader : function(headerContent) {
+ if (! this.header) {
+ this.header = document.createElement("DIV");
+ this.header.className = YAHOO.widget.Module.CSS_HEADER;
+ }
+
+ if (typeof headerContent == "string") {
+ this.header.innerHTML = headerContent;
+ } else {
+ this.header.innerHTML = "";
+ this.header.appendChild(headerContent);
+ }
+
+ this.changeHeaderEvent.fire(headerContent);
+ this.changeContentEvent.fire();
+ },
+
+ /**
+ * Appends the passed element to the header. If no header is present, one will be automatically created.
+ * @param {Element} element The element to append to the header
+ */
+ appendToHeader : function(element) {
+ if (! this.header) {
+ this.header = document.createElement("DIV");
+ this.header.className = YAHOO.widget.Module.CSS_HEADER;
+ }
+
+ this.header.appendChild(element);
+ this.changeHeaderEvent.fire(element);
+ this.changeContentEvent.fire();
+ },
+
+ /**
+ * Sets the Module's body content to the HTML specified, or appends the passed element to the body. If no body is present, one will be automatically created.
+ * @param {string} bodyContent The HTML used to set the body <em>OR</em>
+ * @param {Element} bodyContent The Element to append to the body
+ */
+ setBody : function(bodyContent) {
+ if (! this.body) {
+ this.body = document.createElement("DIV");
+ this.body.className = YAHOO.widget.Module.CSS_BODY;
+ }
+
+ if (typeof bodyContent == "string")
+ {
+ this.body.innerHTML = bodyContent;
+ } else {
+ this.body.innerHTML = "";
+ this.body.appendChild(bodyContent);
+ }
+
+ this.changeBodyEvent.fire(bodyContent);
+ this.changeContentEvent.fire();
+ },
+
+ /**
+ * Appends the passed element to the body. If no body is present, one will be automatically created.
+ * @param {Element} element The element to append to the body
+ */
+ appendToBody : function(element) {
+ if (! this.body) {
+ this.body = document.createElement("DIV");
+ this.body.className = YAHOO.widget.Module.CSS_BODY;
+ }
+
+ this.body.appendChild(element);
+ this.changeBodyEvent.fire(element);
+ this.changeContentEvent.fire();
+ },
+
+ /**
+ * Sets the Module's footer content to the HTML specified, or appends the passed element to the footer. If no footer is present, one will be automatically created.
+ * @param {string} footerContent The HTML used to set the footer <em>OR</em>
+ * @param {Element} footerContent The Element to append to the footer
+ */
+ setFooter : function(footerContent) {
+ if (! this.footer) {
+ this.footer = document.createElement("DIV");
+ this.footer.className = YAHOO.widget.Module.CSS_FOOTER;
+ }
+
+ if (typeof footerContent == "string") {
+ this.footer.innerHTML = footerContent;
+ } else {
+ this.footer.innerHTML = "";
+ this.footer.appendChild(footerContent);
+ }
+
+ this.changeFooterEvent.fire(footerContent);
+ this.changeContentEvent.fire();
+ },
+
+ /**
+ * Appends the passed element to the footer. If no footer is present, one will be automatically created.
+ * @param {Element} element The element to append to the footer
+ */
+ appendToFooter : function(element) {
+ if (! this.footer) {
+ this.footer = document.createElement("DIV");
+ this.footer.className = YAHOO.widget.Module.CSS_FOOTER;
+ }
+
+ this.footer.appendChild(element);
+ this.changeFooterEvent.fire(element);
+ this.changeContentEvent.fire();
+ },
+
+ /**
+ * Renders the Module by inserting the elements that are not already in the main Module into their correct places. Optionally appends the Module to the specified node prior to the render's execution. NOTE: For Modules without existing markup, the appendToNode argument is REQUIRED. If this argument is ommitted and the current element is not present in the document, the function will return false, indicating that the render was a failure.
+ * @param {string} appendToNode The element id to which the Module should be appended to prior to rendering <em>OR</em>
+ * @param {Element} appendToNode The element to which the Module should be appended to prior to rendering
+ * @param {Element} moduleElement OPTIONAL. The element that represents the actual Standard Module container.
+ * @return {boolean} Success or failure of the render
+ */
+ render : function(appendToNode, moduleElement) {
+ this.beforeRenderEvent.fire();
+
+ if (! moduleElement) {
+ moduleElement = this.element;
+ }
+
+ var me = this;
+ var appendTo = function(element) {
+ if (typeof element == "string") {
+ element = document.getElementById(element);
+ }
+
+ if (element) {
+ element.appendChild(me.element);
+ me.appendEvent.fire();
+ }
+ }
+
+ if (appendToNode) {
+ appendTo(appendToNode);
+ } else { // No node was passed in. If the element is not pre-marked up, this fails
+ if (! YAHOO.util.Dom.inDocument(this.element)) {
+ return false;
+ }
+ }
+
+ // Need to get everything into the DOM if it isn't already
+
+ if (this.header && ! YAHOO.util.Dom.inDocument(this.header)) {
+ // There is a header, but it's not in the DOM yet... need to add it
+ var firstChild = moduleElement.firstChild;
+ if (firstChild) { // Insert before first child if exists
+ moduleElement.insertBefore(this.header, firstChild);
+ } else { // Append to empty body because there are no children
+ moduleElement.appendChild(this.header);
+ }
+ }
+
+ if (this.body && ! YAHOO.util.Dom.inDocument(this.body)) {
+ // There is a body, but it's not in the DOM yet... need to add it
+ if (this.footer && YAHOO.util.Dom.isAncestor(this.moduleElement, this.footer)) { // Insert before footer if exists in DOM
+ moduleElement.insertBefore(this.body, this.footer);
+ } else { // Append to element because there is no footer
+ moduleElement.appendChild(this.body);
+ }
+ }
+
+ if (this.footer && ! YAHOO.util.Dom.inDocument(this.footer)) {
+ // There is a footer, but it's not in the DOM yet... need to add it
+ moduleElement.appendChild(this.footer);
+ }
+
+ this.renderEvent.fire();
+ return true;
+ },
+
+ /**
+ * Removes the Module element from the DOM and sets all child elements to null.
+ */
+ destroy : function() {
+ if (this.element) {
+ var parent = this.element.parentNode;
+ }
+ if (parent) {
+ parent.removeChild(this.element);
+ }
+
+ this.element = null;
+ this.header = null;
+ this.body = null;
+ this.footer = null;
+
+ this.destroyEvent.fire();
+ },
+
+ /**
+ * Shows the Module element by setting the visible configuration property to true. Also fires two events: beforeShowEvent prior to the visibility change, and showEvent after.
+ */
+ show : function() {
+ this.cfg.setProperty("visible", true);
+ },
+
+ /**
+ * Hides the Module element by setting the visible configuration property to false. Also fires two events: beforeHideEvent prior to the visibility change, and hideEvent after.
+ */
+ hide : function() {
+ this.cfg.setProperty("visible", false);
+ },
+
+ // BUILT-IN EVENT HANDLERS FOR MODULE //
+
+ /**
+ * Default event handler for changing the visibility property of a Module. By default, this is achieved by switching the "display" style between "block" and "none".
+ * This method is responsible for firing showEvent and hideEvent.
+ */
+ configVisible : function(type, args, obj) {
+ var visible = args[0];
+ if (visible) {
+ this.beforeShowEvent.fire();
+ YAHOO.util.Dom.setStyle(this.element, "display", "block");
+ this.showEvent.fire();
+ } else {
+ this.beforeHideEvent.fire();
+ YAHOO.util.Dom.setStyle(this.element, "display", "none");
+ this.hideEvent.fire();
+ }
+ },
+
+ /**
+ * Default event handler for the "monitorresize" configuration property
+ */
+ configMonitorResize : function(type, args, obj) {
+ var monitor = args[0];
+ if (monitor) {
+ this.initResizeMonitor();
+ } else {
+ YAHOO.util.Event.removeListener(this.resizeMonitor, "resize", this.onDomResize);
+ this.resizeMonitor = null;
+ }
+ }
+}
+
+/**
+* Returns a string representation of the object.
+* @type string
+*/
+YAHOO.widget.Module.prototype.toString = function() {
+ return "Module " + this.id;
+}
+
+/**
+* @class Overlay is a Module that is absolutely positioned above the page flow. It has convenience methods for positioning and sizing, as well as options for controlling zIndex and constraining the Overlay's position to the current visible viewport. Overlay also contains a dynamicly generated IFRAME which is placed beneath it for Internet Explorer 6 and 5.x so that it will be properly rendered above SELECT elements.
+* @param {string} el The element ID representing the Overlay <em>OR</em>
+* @param {Element} el The element representing the Overlay
+* @param {object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details.
+* @constructor
+*/
+YAHOO.widget.Overlay = function(el, userConfig) {
+ YAHOO.widget.Overlay.superclass.constructor.call(this, el, userConfig);
+}
+
+YAHOO.extend(YAHOO.widget.Overlay, YAHOO.widget.Module);
+
+/**
+* The URL of the blank image that will be placed in the iframe
+* @type string
+* @final
+*/
+YAHOO.widget.Overlay.IFRAME_SRC = "promo/m/irs/blank.gif";
+
+/**
+* Constant representing the top left corner of an element, used for configuring the context element alignment
+* @type string
+* @final
+*/
+YAHOO.widget.Overlay.TOP_LEFT = "tl";
+
+/**
+* Constant representing the top right corner of an element, used for configuring the context element alignment
+* @type string
+* @final
+*/
+YAHOO.widget.Overlay.TOP_RIGHT = "tr";
+
+/**
+* Constant representing the top bottom left corner of an element, used for configuring the context element alignment
+* @type string
+* @final
+*/
+YAHOO.widget.Overlay.BOTTOM_LEFT = "bl";
+
+/**
+* Constant representing the bottom right corner of an element, used for configuring the context element alignment
+* @type string
+* @final
+*/
+YAHOO.widget.Overlay.BOTTOM_RIGHT = "br";
+
+/**
+* Constant representing the default CSS class used for an Overlay
+* @type string
+* @final
+*/
+YAHOO.widget.Overlay.CSS_OVERLAY = "overlay";
+
+/**
+* CustomEvent fired before the Overlay is moved.
+* args: x,y that the Overlay will be moved to
+* @type YAHOO.util.CustomEvent
+*/
+YAHOO.widget.Overlay.prototype.beforeMoveEvent = null;
+
+/**
+* CustomEvent fired after the Overlay is moved.
+* args: x,y that the Overlay was moved to
+* @type YAHOO.util.CustomEvent
+*/
+YAHOO.widget.Overlay.prototype.moveEvent = null;
+
+/**
+* The Overlay initialization method, which is executed for Overlay and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present.
+* @param {string} el The element ID representing the Overlay <em>OR</em>
+* @param {Element} el The element representing the Overlay
+* @param {object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details.
+*/
+YAHOO.widget.Overlay.prototype.init = function(el, userConfig) {
+ YAHOO.widget.Overlay.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level
+
+ this.beforeInitEvent.fire(YAHOO.widget.Overlay);
+
+ YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Overlay.CSS_OVERLAY);
+
+ if (userConfig) {
+ this.cfg.applyConfig(userConfig, true);
+ }
+
+ if (this.platform == "mac" && this.browser == "gecko") {
+ if (! YAHOO.util.Config.alreadySubscribed(this.showEvent,this.showMacGeckoScrollbars,this)) {
+ this.showEvent.subscribe(this.showMacGeckoScrollbars,this,true);
+ }
+ if (! YAHOO.util.Config.alreadySubscribed(this.hideEvent,this.hideMacGeckoScrollbars,this)) {
+ this.hideEvent.subscribe(this.hideMacGeckoScrollbars,this,true);
+ }
+ }
+
+ this.initEvent.fire(YAHOO.widget.Overlay);
+
+}
+
+/**
+* Initializes the custom events for Overlay which are fired automatically at appropriate times by the Overlay class.
+*/
+YAHOO.widget.Overlay.prototype.initEvents = function() {
+ YAHOO.widget.Overlay.superclass.initEvents.call(this);
+
+ this.beforeMoveEvent = new YAHOO.util.CustomEvent("beforeMove", this);
+ this.moveEvent = new YAHOO.util.CustomEvent("move", this);
+}
+
+/**
+* Initializes the class's configurable properties which can be changed using the Overlay's Config object (cfg).
+*/
+YAHOO.widget.Overlay.prototype.initDefaultConfig = function() {
+ YAHOO.widget.Overlay.superclass.initDefaultConfig.call(this);
+
+ // Add overlay config properties //
+ this.cfg.addProperty("x", { handler:this.configX, validator:this.cfg.checkNumber, suppressEvent:true, supercedes:["iframe"] } );
+ this.cfg.addProperty("y", { handler:this.configY, validator:this.cfg.checkNumber, suppressEvent:true, supercedes:["iframe"] } );
+ this.cfg.addProperty("xy",{ handler:this.configXY, suppressEvent:true, supercedes:["iframe"] } );
+
+ this.cfg.addProperty("context", { handler:this.configContext, suppressEvent:true, supercedes:["iframe"] } );
+ this.cfg.addProperty("fixedcenter", { value:false, handler:this.configFixedCenter, validator:this.cfg.checkBoolean, supercedes:["iframe","visible"] } );
+
+ this.cfg.addProperty("width", { handler:this.configWidth, suppressEvent:true, supercedes:["iframe"] } );
+ this.cfg.addProperty("height", { handler:this.configHeight, suppressEvent:true, supercedes:["iframe"] } );
+
+ this.cfg.addProperty("zIndex", { value:null, handler:this.configzIndex } );
+
+ this.cfg.addProperty("constraintoviewport", { value:false, handler:this.configConstrainToViewport, validator:this.cfg.checkBoolean, supercedes:["iframe","x","y","xy"] } );
+ this.cfg.addProperty("iframe", { value:(this.browser == "ie" ? true : false), handler:this.configIframe, validator:this.cfg.checkBoolean, supercedes:["zIndex"] } );
+}
+
+/**
+* Moves the Overlay to the specified position. This function is identical to calling this.cfg.setProperty("xy", [x,y]);
+* @param {int} x The Overlay's new x position
+* @param {int} y The Overlay's new y position
+*/
+YAHOO.widget.Overlay.prototype.moveTo = function(x, y) {
+ this.cfg.setProperty("xy",[x,y]);
+}
+
+/**
+* Adds a special CSS class to the Overlay when Mac/Gecko is in use, to work around a Gecko bug where
+* scrollbars cannot be hidden. See https://bugzilla.mozilla.org/show_bug.cgi?id=187435
+*/
+YAHOO.widget.Overlay.prototype.hideMacGeckoScrollbars = function() {
+ YAHOO.util.Dom.removeClass(this.element, "show-scrollbars");
+ YAHOO.util.Dom.addClass(this.element, "hide-scrollbars");
+}
+
+/**
+* Removes a special CSS class from the Overlay when Mac/Gecko is in use, to work around a Gecko bug where
+* scrollbars cannot be hidden. See https://bugzilla.mozilla.org/show_bug.cgi?id=187435
+*/
+YAHOO.widget.Overlay.prototype.showMacGeckoScrollbars = function() {
+ YAHOO.util.Dom.removeClass(this.element, "hide-scrollbars");
+ YAHOO.util.Dom.addClass(this.element, "show-scrollbars");
+}
+
+// BEGIN BUILT-IN PROPERTY EVENT HANDLERS //
+
+/**
+* The default event handler fired when the "visible" property is changed. This method is responsible for firing showEvent and hideEvent.
+*/
+YAHOO.widget.Overlay.prototype.configVisible = function(type, args, obj) {
+ var visible = args[0];
+ var currentVis = YAHOO.util.Dom.getStyle(this.element, "visibility");
+
+ var effect = this.cfg.getProperty("effect");
+
+ var effectInstances = new Array();
+ if (effect) {
+ if (effect instanceof Array) {
+ for (var i=0;i<effect.length;i++) {
+ var eff = effect[i];
+ effectInstances[effectInstances.length] = eff.effect(this, eff.duration);
+ }
+ } else {
+ effectInstances[effectInstances.length] = effect.effect(this, effect.duration);
+ }
+ }
+
+ var isMacGecko = (this.platform == "mac" && this.browser == "gecko");
+
+ if (visible) { // Show
+ if (isMacGecko) {
+ this.showMacGeckoScrollbars();
+ }
+
+ if (effect) { // Animate in
+ if (visible) { // Animate in if not showing
+ if (currentVis != "visible") {
+ this.beforeShowEvent.fire();
+ for (var i=0;i<effectInstances.length;i++) {
+ var e = effectInstances[i];
+ if (i == 0 && ! YAHOO.util.Config.alreadySubscribed(e.animateInCompleteEvent,this.showEvent.fire,this.showEvent)) {
+ e.animateInCompleteEvent.subscribe(this.showEvent.fire,this.showEvent,true); // Delegate showEvent until end of animateInComplete
+ }
+ e.animateIn();
+ }
+ }
+ }
+ } else { // Show
+ if (currentVis != "visible") {
+ this.beforeShowEvent.fire();
+ YAHOO.util.Dom.setStyle(this.element, "visibility", "visible");
+ this.cfg.refireEvent("iframe");
+ this.showEvent.fire();
+ }
+ }
+
+ } else { // Hide
+ if (isMacGecko) {
+ this.hideMacGeckoScrollbars();
+ }
+
+ if (effect) { // Animate out if showing
+ if (currentVis == "visible") {
+ this.beforeHideEvent.fire();
+ for (var i=0;i<effectInstances.length;i++) {
+ var e = effectInstances[i];
+ if (i == 0 && ! YAHOO.util.Config.alreadySubscribed(e.animateOutCompleteEvent,this.hideEvent.fire,this.hideEvent)) {
+ e.animateOutCompleteEvent.subscribe(this.hideEvent.fire,this.hideEvent,true); // Delegate hideEvent until end of animateOutComplete
+ }
+ e.animateOut();
+ }
+ }
+ } else { // Simple hide
+ if (currentVis == "visible") {
+ this.beforeHideEvent.fire();
+ YAHOO.util.Dom.setStyle(this.element, "visibility", "hidden");
+ this.cfg.refireEvent("iframe");
+ this.hideEvent.fire();
+ }
+ }
+ }
+}
+
+/**
+* Center event handler used for centering on scroll/resize, but only if the Overlay is visible
+*/
+YAHOO.widget.Overlay.prototype.doCenterOnDOMEvent = function() {
+ if (this.cfg.getProperty("visible")) {
+ this.center();
+ }
+}
+
+/**
+* The default event handler fired when the "fixedcenter" property is changed.
+*/
+YAHOO.widget.Overlay.prototype.configFixedCenter = function(type, args, obj) {
+ var val = args[0];
+
+ if (val) {
+ this.center();
+
+ if (! YAHOO.util.Config.alreadySubscribed(this.beforeShowEvent, this.center, this)) {
+ this.beforeShowEvent.subscribe(this.center, this, true);
+ }
+
+ if (! YAHOO.util.Config.alreadySubscribed(YAHOO.widget.Overlay.windowResizeEvent, this.doCenterOnDOMEvent, this)) {
+ YAHOO.widget.Overlay.windowResizeEvent.subscribe(this.doCenterOnDOMEvent, this, true);
+ }
+
+ if (! YAHOO.util.Config.alreadySubscribed(YAHOO.widget.Overlay.windowScrollEvent, this.doCenterOnDOMEvent, this)) {
+ YAHOO.widget.Overlay.windowScrollEvent.subscribe( this.doCenterOnDOMEvent, this, true);
+ }
+ } else {
+ YAHOO.widget.Overlay.windowResizeEvent.unsubscribe(this.doCenterOnDOMEvent, this);
+ YAHOO.widget.Overlay.windowScrollEvent.unsubscribe(this.doCenterOnDOMEvent, this);
+ }
+}
+
+/**
+* The default event handler fired when the "height" property is changed.
+*/
+YAHOO.widget.Overlay.prototype.configHeight = function(type, args, obj) {
+ var height = args[0];
+ var el = this.element;
+ YAHOO.util.Dom.setStyle(el, "height", height);
+ this.cfg.refireEvent("iframe");
+}
+
+/**
+* The default event handler fired when the "width" property is changed.
+*/
+YAHOO.widget.Overlay.prototype.configWidth = function(type, args, obj) {
+ var width = args[0];
+ var el = this.element;
+ YAHOO.util.Dom.setStyle(el, "width", width);
+ this.cfg.refireEvent("iframe");
+}
+
+/**
+* The default event handler fired when the "zIndex" property is changed.
+*/
+YAHOO.widget.Overlay.prototype.configzIndex = function(type, args, obj) {
+ var zIndex = args[0];
+
+ var el = this.element;
+
+ if (! zIndex) {
+ zIndex = YAHOO.util.Dom.getStyle(el, "zIndex");
+ if (! zIndex || isNaN(zIndex)) {
+ zIndex = 0;
+ }
+ }
+
+ if (this.iframe) {
+ if (zIndex <= 0) {
+ zIndex = 1;
+ }
+ YAHOO.util.Dom.setStyle(this.iframe, "zIndex", (zIndex-1));
+ }
+
+ YAHOO.util.Dom.setStyle(el, "zIndex", zIndex);
+ this.cfg.setProperty("zIndex", zIndex, true);
+}
+
+/**
+* The default event handler fired when the "xy" property is changed.
+*/
+YAHOO.widget.Overlay.prototype.configXY = function(type, args, obj) {
+ var pos = args[0];
+ var x = pos[0];
+ var y = pos[1];
+
+ this.cfg.setProperty("x", x);
+ this.cfg.setProperty("y", y);
+
+ this.beforeMoveEvent.fire([x,y]);
+
+ x = this.cfg.getProperty("x");
+ y = this.cfg.getProperty("y");
+
+ this.cfg.refireEvent("iframe");
+ this.moveEvent.fire([x,y]);
+}
+
+/**
+* The default event handler fired when the "x" property is changed.
+*/
+YAHOO.widget.Overlay.prototype.configX = function(type, args, obj) {
+ var x = args[0];
+ var y = this.cfg.getProperty("y");
+
+ this.cfg.setProperty("x", x, true);
+ this.cfg.setProperty("y", y, true);
+
+ this.beforeMoveEvent.fire([x,y]);
+
+ x = this.cfg.getProperty("x");
+ y = this.cfg.getProperty("y");
+
+ YAHOO.util.Dom.setX(this.element, x, true);
+
+ this.cfg.setProperty("xy", [x, y], true);
+
+ this.cfg.refireEvent("iframe");
+ this.moveEvent.fire([x, y]);
+}
+
+/**
+* The default event handler fired when the "y" property is changed.
+*/
+YAHOO.widget.Overlay.prototype.configY = function(type, args, obj) {
+ var x = this.cfg.getProperty("x");
+ var y = args[0];
+
+ this.cfg.setProperty("x", x, true);
+ this.cfg.setProperty("y", y, true);
+
+ this.beforeMoveEvent.fire([x,y]);
+
+ x = this.cfg.getProperty("x");
+ y = this.cfg.getProperty("y");
+
+ YAHOO.util.Dom.setY(this.element, y, true);
+
+ this.cfg.setProperty("xy", [x, y], true);
+
+ this.cfg.refireEvent("iframe");
+ this.moveEvent.fire([x, y]);
+}
+
+/**
+* The default event handler fired when the "iframe" property is changed.
+*/
+YAHOO.widget.Overlay.prototype.configIframe = function(type, args, obj) {
+
+ var val = args[0];
+
+ var el = this.element;
+
+ var showIframe = function() {
+ if (this.iframe) {
+ this.iframe.style.display = "block";
+ }
+ }
+
+ var hideIframe = function() {
+ if (this.iframe) {
+ this.iframe.style.display = "none";
+ }
+ }
+
+ if (val) { // IFRAME shim is enabled
+
+ if (! YAHOO.util.Config.alreadySubscribed(this.showEvent, showIframe, this)) {
+ this.showEvent.subscribe(showIframe, this, true);
+ }
+ if (! YAHOO.util.Config.alreadySubscribed(this.hideEvent, hideIframe, this)) {
+ this.hideEvent.subscribe(hideIframe, this, true);
+ }
+
+ var x = this.cfg.getProperty("x");
+ var y = this.cfg.getProperty("y");
+
+ if (! x || ! y) {
+ this.syncPosition();
+ x = this.cfg.getProperty("x");
+ y = this.cfg.getProperty("y");
+ }
+
+ if (! isNaN(x) && ! isNaN(y)) {
+ if (! this.iframe) {
+ this.iframe = document.createElement("iframe");
+ if (this.isSecure) {
+ this.iframe.src = this.imageRoot + YAHOO.widget.Overlay.IFRAME_SRC;
+ }
+
+ var parent = el.parentNode;
+ if (parent) {
+ parent.appendChild(this.iframe);
+ } else {
+ document.body.appendChild(this.iframe);
+ }
+
+ YAHOO.util.Dom.setStyle(this.iframe, "position", "absolute");
+ YAHOO.util.Dom.setStyle(this.iframe, "border", "none");
+ YAHOO.util.Dom.setStyle(this.iframe, "margin", "0");
+ YAHOO.util.Dom.setStyle(this.iframe, "padding", "0");
+ YAHOO.util.Dom.setStyle(this.iframe, "opacity", "0");
+ if (this.cfg.getProperty("visible")) {
+ showIframe.call(this);
+ } else {
+ hideIframe.call(this);
+ }
+ }
+
+ var iframeDisplay = YAHOO.util.Dom.getStyle(this.iframe, "display");
+
+ if (iframeDisplay == "none") {
+ this.iframe.style.display = "block";
+ }
+
+ YAHOO.util.Dom.setXY(this.iframe, [x,y]);
+
+ var width = el.clientWidth;
+ var height = el.clientHeight;
+
+ YAHOO.util.Dom.setStyle(this.iframe, "width", (width+2) + "px");
+ YAHOO.util.Dom.setStyle(this.iframe, "height", (height+2) + "px");
+
+ if (iframeDisplay == "none") {
+ this.iframe.style.display = "none";
+ }
+ }
+ } else {
+ if (this.iframe) {
+ this.iframe.style.display = "none";
+ }
+ this.showEvent.unsubscribe(showIframe, this);
+ this.hideEvent.unsubscribe(hideIframe, this);
+ }
+}
+
+
+/**
+* The default event handler fired when the "constraintoviewport" property is changed.
+*/
+YAHOO.widget.Overlay.prototype.configConstrainToViewport = function(type, args, obj) {
+ var val = args[0];
+ if (val) {
+ if (! YAHOO.util.Config.alreadySubscribed(this.beforeMoveEvent, this.enforceConstraints, this)) {
+ this.beforeMoveEvent.subscribe(this.enforceConstraints, this, true);
+ }
+ } else {
+ this.beforeMoveEvent.unsubscribe(this.enforceConstraints, this);
+ }
+}
+
+/**
+* The default event handler fired when the "context" property is changed.
+*/
+YAHOO.widget.Overlay.prototype.configContext = function(type, args, obj) {
+ var contextArgs = args[0];
+
+ if (contextArgs) {
+ var contextEl = contextArgs[0];
+ var elementMagnetCorner = contextArgs[1];
+ var contextMagnetCorner = contextArgs[2];
+
+ if (contextEl) {
+ if (typeof contextEl == "string") {
+ this.cfg.setProperty("context", [document.getElementById(contextEl),elementMagnetCorner,contextMagnetCorner], true);
+ }
+
+ if (elementMagnetCorner && contextMagnetCorner) {
+ this.align(elementMagnetCorner, contextMagnetCorner);
+ }
+ }
+ }
+}
+
+
+// END BUILT-IN PROPERTY EVENT HANDLERS //
+
+/**
+* Aligns the Overlay to its context element using the specified corner points (represented by the constants TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, and BOTTOM_RIGHT.
+* @param {string} elementAlign The string representing the corner of the Overlay that should be aligned to the context element
+* @param {string} contextAlign The corner of the context element that the elementAlign corner should stick to.
+*/
+YAHOO.widget.Overlay.prototype.align = function(elementAlign, contextAlign) {
+ var contextArgs = this.cfg.getProperty("context");
+ if (contextArgs) {
+ var context = contextArgs[0];
+
+ var element = this.element;
+ var me = this;
+
+ if (! elementAlign) {
+ elementAlign = contextArgs[1];
+ }
+
+ if (! contextAlign) {
+ contextAlign = contextArgs[2];
+ }
+
+ if (element && context) {
+ var elementRegion = YAHOO.util.Dom.getRegion(element);
+ var contextRegion = YAHOO.util.Dom.getRegion(context);
+
+ var doAlign = function(v,h) {
+ switch (elementAlign) {
+ case YAHOO.widget.Overlay.TOP_LEFT:
+ me.moveTo(h,v);
+ break;
+ case YAHOO.widget.Overlay.TOP_RIGHT:
+ me.moveTo(h-element.offsetWidth,v);
+ break;
+ case YAHOO.widget.Overlay.BOTTOM_LEFT:
+ me.moveTo(h,v-element.offsetHeight);
+ break;
+ case YAHOO.widget.Overlay.BOTTOM_RIGHT:
+ me.moveTo(h-element.offsetWidth,v-element.offsetHeight);
+ break;
+ }
+ }
+
+ switch (contextAlign) {
+ case YAHOO.widget.Overlay.TOP_LEFT:
+ doAlign(contextRegion.top, contextRegion.left);
+ break;
+ case YAHOO.widget.Overlay.TOP_RIGHT:
+ doAlign(contextRegion.top, contextRegion.right);
+ break;
+ case YAHOO.widget.Overlay.BOTTOM_LEFT:
+ doAlign(contextRegion.bottom, contextRegion.left);
+ break;
+ case YAHOO.widget.Overlay.BOTTOM_RIGHT:
+ doAlign(contextRegion.bottom, contextRegion.right);
+ break;
+ }
+ }
+ }
+}
+
+/**
+* The default event handler executed when the moveEvent is fired, if the "constraintoviewport" is set to true.
+*/
+YAHOO.widget.Overlay.prototype.enforceConstraints = function(type, args, obj) {
+ var pos = args[0];
+
+ var x = pos[0];
+ var y = pos[1];
+
+ var width = parseInt(this.cfg.getProperty("width"));
+
+ if (isNaN(width)) {
+ width = 0;
+ }
+
+ var offsetHeight = this.element.offsetHeight;
+ var offsetWidth = (width>0?width:this.element.offsetWidth); //this.element.offsetWidth;
+
+ var viewPortWidth = YAHOO.util.Dom.getViewportWidth();
+ var viewPortHeight = YAHOO.util.Dom.getViewportHeight();
+
+ var scrollX = window.scrollX || document.documentElement.scrollLeft;
+ var scrollY = window.scrollY || document.documentElement.scrollTop;
+
+ var topConstraint = scrollY + 10;
+ var leftConstraint = scrollX + 10;
+ var bottomConstraint = scrollY + viewPortHeight - offsetHeight - 10;
+ var rightConstraint = scrollX + viewPortWidth - offsetWidth - 10;
+
+ if (x < leftConstraint) {
+ x = leftConstraint;
+ } else if (x > rightConstraint) {
+ x = rightConstraint;
+ }
+
+ if (y < topConstraint) {
+ y = topConstraint;
+ } else if (y > bottomConstraint) {
+ y = bottomConstraint;
+ }
+
+ this.cfg.setProperty("x", x, true);
+ this.cfg.setProperty("y", y, true);
+ this.cfg.setProperty("xy", [x,y], true);
+}
+
+/**
+* Centers the container in the viewport.
+*/
+YAHOO.widget.Overlay.prototype.center = function() {
+ var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
+ var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
+
+ var viewPortWidth = YAHOO.util.Dom.getClientWidth();
+ var viewPortHeight = YAHOO.util.Dom.getClientHeight();
+
+ var elementWidth = this.element.offsetWidth;
+ var elementHeight = this.element.offsetHeight;
+
+ var x = (viewPortWidth / 2) - (elementWidth / 2) + scrollX;
+ var y = (viewPortHeight / 2) - (elementHeight / 2) + scrollY;
+
+ this.element.style.left = parseInt(x) + "px";
+ this.element.style.top = parseInt(y) + "px";
+ this.syncPosition();
+
+ this.cfg.refireEvent("iframe");
+}
+
+/**
+* Synchronizes the Panel's "xy", "x", and "y" properties with the Panel's position in the DOM. This is primarily used to update position information during drag & drop.
+*/
+YAHOO.widget.Overlay.prototype.syncPosition = function() {
+ var pos = YAHOO.util.Dom.getXY(this.element);
+ this.cfg.setProperty("x", pos[0], true);
+ this.cfg.setProperty("y", pos[1], true);
+ this.cfg.setProperty("xy", pos, true);
+}
+
+/**
+* Event handler fired when the resize monitor element is resized.
+*/
+YAHOO.widget.Overlay.prototype.onDomResize = function(e, obj) {
+ YAHOO.widget.Overlay.superclass.onDomResize.call(this, e, obj);
+ this.cfg.refireEvent("iframe");
+}
+
+/**
+* Removes the Overlay element from the DOM and sets all child elements to null.
+*/
+YAHOO.widget.Overlay.prototype.destroy = function() {
+ if (this.iframe) {
+ this.iframe.parentNode.removeChild(this.iframe);
+ }
+
+ this.iframe = null;
+
+ YAHOO.widget.Overlay.superclass.destroy.call(this);
+};
+
+/**
+* Returns a string representation of the object.
+* @type string
+*/
+YAHOO.widget.Overlay.prototype.toString = function() {
+ return "Overlay " + this.id;
+}
+
+/**
+* A singleton CustomEvent used for reacting to the DOM event for window scroll
+* @type YAHOO.util.CustomEvent
+*/
+YAHOO.widget.Overlay.windowScrollEvent = new YAHOO.util.CustomEvent("windowScroll");
+
+/**
+* A singleton CustomEvent used for reacting to the DOM event for window resize
+* @type YAHOO.util.CustomEvent
+*/
+YAHOO.widget.Overlay.windowResizeEvent = new YAHOO.util.CustomEvent("windowResize");
+
+/**
+* The DOM event handler used to fire the CustomEvent for window scroll
+* @type Function
+*/
+YAHOO.widget.Overlay.windowScrollHandler = function(e) {
+ YAHOO.widget.Overlay.windowScrollEvent.fire();
+}
+
+/**
+* The DOM event handler used to fire the CustomEvent for window resize
+* @type Function
+*/
+YAHOO.widget.Overlay.windowResizeHandler = function(e) {
+ YAHOO.widget.Overlay.windowResizeEvent.fire();
+}
+
+/**
+* @private
+*/
+YAHOO.widget.Overlay._initialized == null;
+
+if (YAHOO.widget.Overlay._initialized == null) {
+ YAHOO.util.Event.addListener(window, "scroll", YAHOO.widget.Overlay.windowScrollHandler);
+ YAHOO.util.Event.addListener(window, "resize", YAHOO.widget.Overlay.windowResizeHandler);
+
+ YAHOO.widget.Overlay._initialized = true;
+}
+
+/**
+* @class
+* OverlayManager is used for maintaining the focus status of multiple Overlays.
+* @param {Array} overlays Optional. A collection of Overlays to register with the manager.
+* @param {object} userConfig The object literal representing the user configuration of the OverlayManager
+* @constructor
+*/
+YAHOO.widget.OverlayManager = function(userConfig) {
+ this.init(userConfig);
+}
+
+/**
+* The CSS class representing a focused Overlay
+* @type string
+*/
+YAHOO.widget.OverlayManager.CSS_FOCUSED = "focused";
+
+YAHOO.widget.OverlayManager.prototype = {
+
+ constructor : YAHOO.widget.OverlayManager,
+
+ /**
+ * The array of Overlays that are currently registered
+ * @type Array
+ */
+ overlays : null,
+
+ /**
+ * Initializes the default configuration of the OverlayManager
+ */
+ initDefaultConfig : function() {
+ this.cfg.addProperty("overlays", { suppressEvent:true } );
+ this.cfg.addProperty("focusevent", { value:"mousedown" } );
+ },
+
+ /**
+ * Returns the currently focused Overlay
+ * @return {Overlay} The currently focused Overlay
+ */
+ getActive : function() {},
+
+ /**
+ * Focuses the specified Overlay
+ * @param {Overlay} The Overlay to focus
+ * @param {string} The id of the Overlay to focus
+ */
+ focus : function(overlay) {},
+
+ /**
+ * Removes the specified Overlay from the manager
+ * @param {Overlay} The Overlay to remove
+ * @param {string} The id of the Overlay to remove
+ */
+ remove: function(overlay) {},
+
+ /**
+ * Removes focus from all registered Overlays in the manager
+ */
+ blurAll : function() {},
+
+ /**
+ * Initializes the OverlayManager
+ * @param {Array} overlays Optional. A collection of Overlays to register with the manager.
+ * @param {object} userConfig The object literal representing the user configuration of the OverlayManager
+ */
+ init : function(userConfig) {
+ this.cfg = new YAHOO.util.Config(this);
+
+ this.initDefaultConfig();
+
+ if (userConfig) {
+ this.cfg.applyConfig(userConfig, true);
+ }
+ this.cfg.fireQueue();
+
+ var activeOverlay = null;
+
+ this.getActive = function() {
+ return activeOverlay;
+ }
+
+ this.focus = function(overlay) {
+ var o = this.find(overlay);
+ if (o) {
+ this.blurAll();
+ activeOverlay = o;
+ YAHOO.util.Dom.addClass(activeOverlay.element, YAHOO.widget.OverlayManager.CSS_FOCUSED);
+ this.overlays.sort(this.compareZIndexDesc);
+ var topZIndex = YAHOO.util.Dom.getStyle(this.overlays[0].element, "zIndex");
+ if (! isNaN(topZIndex) && this.overlays[0] != overlay) {
+ activeOverlay.cfg.setProperty("zIndex", (parseInt(topZIndex) + 1));
+ }
+ this.overlays.sort(this.compareZIndexDesc);
+ }
+ }
+
+ this.remove = function(overlay) {
+ var o = this.find(overlay);
+ if (o) {
+ var originalZ = YAHOO.util.Dom.getStyle(o.element, "zIndex");
+ o.cfg.setProperty("zIndex", -1000, true);
+ this.overlays.sort(this.compareZIndexDesc);
+ this.overlays = this.overlays.slice(0, this.overlays.length-1);
+ o.cfg.setProperty("zIndex", originalZ, true);
+
+ o.cfg.setProperty("manager", null);
+ o.focusEvent = null
+ o.blurEvent = null;
+ o.focus = null;
+ o.blur = null;
+ }
+ }
+
+ this.blurAll = function() {
+ activeOverlay = null;
+ for (var o=0;o<this.overlays.length;o++) {
+ YAHOO.util.Dom.removeClass(this.overlays[o].element, YAHOO.widget.OverlayManager.CSS_FOCUSED);
+ }
+ }
+
+ var overlays = this.cfg.getProperty("overlays");
+
+ if (! this.overlays) {
+ this.overlays = new Array();
+ }
+
+ if (overlays) {
+ this.register(overlays);
+ this.overlays.sort(this.compareZIndexDesc);
+ }
+ },
+
+ /**
+ * Registers an Overlay or an array of Overlays with the manager. Upon registration, the Overlay receives functions for focus and blur, along with CustomEvents for each.
+ * @param {Overlay} overlay An Overlay to register with the manager.
+ * @param {Overlay[]} overlay An array of Overlays to register with the manager.
+ * @return {boolean} True if any Overlays are registered.
+ */
+ register : function(overlay) {
+ if (overlay instanceof YAHOO.widget.Overlay) {
+ overlay.cfg.addProperty("manager", { value:this } );
+
+ overlay.focusEvent = new YAHOO.util.CustomEvent("focus");
+ overlay.blurEvent = new YAHOO.util.CustomEvent("blur");
+
+ var mgr=this;
+
+ overlay.focus = function() {
+ mgr.focus(this);
+ this.focusEvent.fire();
+ }
+
+ overlay.blur = function() {
+ mgr.blurAll();
+ this.blurEvent.fire();
+ }
+
+ var focusOnDomEvent = function(e,obj) {
+ overlay.focus();
+ }
+
+ var focusevent = this.cfg.getProperty("focusevent");
+ YAHOO.util.Event.addListener(overlay.element,focusevent,focusOnDomEvent,this,true);
+
+ var zIndex = YAHOO.util.Dom.getStyle(overlay.element, "zIndex");
+ if (! isNaN(zIndex)) {
+ overlay.cfg.setProperty("zIndex", parseInt(zIndex));
+ } else {
+ overlay.cfg.setProperty("zIndex", 0);
+ }
+
+ this.overlays.push(overlay);
+ return true;
+ } else if (overlay instanceof Array) {
+ var regcount = 0;
+ for (var i=0;i<overlay.length;i++) {
+ if (this.register(overlay[i])) {
+ regcount++;
+ }
+ }
+ if (regcount > 0) {
+ return true;
+ }
+ } else {
+ return false;
+ }
+ },
+
+ /**
+ * Attempts to locate an Overlay by instance or ID.
+ * @param {Overlay} overlay An Overlay to locate within the manager
+ * @param {string} overlay An Overlay id to locate within the manager
+ * @return {Overlay} The requested Overlay, if found, or null if it cannot be located.
+ */
+ find : function(overlay) {
+ if (overlay instanceof YAHOO.widget.Overlay) {
+ for (var o=0;o<this.overlays.length;o++) {
+ if (this.overlays[o] == overlay) {
+ return this.overlays[o];
+ }
+ }
+ } else if (typeof overlay == "string") {
+ for (var o=0;o<this.overlays.length;o++) {
+ if (this.overlays[o].id == overlay) {
+ return this.overlays[o];
+ }
+ }
+ }
+ return null;
+ },
+
+ /**
+ * Used for sorting the manager's Overlays by z-index.
+ * @private
+ */
+ compareZIndexDesc : function(o1, o2) {
+ var zIndex1 = o1.cfg.getProperty("zIndex");
+ var zIndex2 = o2.cfg.getProperty("zIndex");
+
+ if (zIndex1 > zIndex2) {
+ return -1;
+ } else if (zIndex1 < zIndex2) {
+ return 1;
+ } else {
+ return 0;
+ }
+ },
+
+ /**
+ * Shows all Overlays in the manager.
+ */
+ showAll : function() {
+ for (var o=0;o<this.overlays.length;o++) {
+ this.overlays[o].show();
+ }
+ },
+
+ /**
+ * Hides all Overlays in the manager.
+ */
+ hideAll : function() {
+ for (var o=0;o<this.overlays.length;o++) {
+ this.overlays[o].hide();
+ }
+ },
+
+ /**
+ * Returns a string representation of the object.
+ * @type string
+ */
+ toString : function() {
+ return "OverlayManager";
+ }
+
+}
+
+/**
+* KeyListener is a utility that provides an easy interface for listening for keydown/keyup events fired against DOM elements.
+* @param {Element} attachTo The element or element ID to which the key event should be attached
+* @param {string} attachTo The element or element ID to which the key event should be attached
+* @param {object} keyData The object literal representing the key(s) to detect. Possible attributes are shift(boolean), alt(boolean), ctrl(boolean) and keys(either an int or an array of ints representing keycodes).
+* @param {function} handler The CustomEvent handler to fire when the key event is detected
+* @param {object} handler An object literal representing the handler.
+* @param {string} event Optional. The event (keydown or keyup) to listen for. Defaults automatically to keydown.
+* @constructor
+*/
+YAHOO.util.KeyListener = function(attachTo, keyData, handler, event) {
+ if (! event) {
+ event = YAHOO.util.KeyListener.KEYDOWN;
+ }
+
+ var keyEvent = new YAHOO.util.CustomEvent("keyPressed");
+
+ this.enabledEvent = new YAHOO.util.CustomEvent("enabled");
+ this.disabledEvent = new YAHOO.util.CustomEvent("disabled");
+
+ if (typeof attachTo == 'string') {
+ attachTo = document.getElementById(attachTo);
+ }
+
+ if (typeof handler == 'function') {
+ keyEvent.subscribe(handler);
+ } else {
+ keyEvent.subscribe(handler.fn, handler.scope, handler.correctScope);
+ }
+
+ /**
+ * Handles the key event when a key is pressed.
+ * @private
+ */
+ function handleKeyPress(e, obj) {
+ var keyPressed = e.charCode || e.keyCode;
+
+ if (! keyData.shift) keyData.shift = false;
+ if (! keyData.alt) keyData.alt = false;
+ if (! keyData.ctrl) keyData.ctrl = false;
+
+ // check held down modifying keys first
+ if (e.shiftKey == keyData.shift &&
+ e.altKey == keyData.alt &&
+ e.ctrlKey == keyData.ctrl) { // if we pass this, all modifiers match
+
+ if (keyData.keys instanceof Array) {
+ for (var i=0;i<keyData.keys.length;i++) {
+ if (keyPressed == keyData.keys[i]) {
+ keyEvent.fire(keyPressed, e);
+ break;
+ }
+ }
+ } else {
+ if (keyPressed == keyData.keys) {
+ keyEvent.fire(keyPressed, e);
+ }
+ }
+ }
+ }
+
+ this.enable = function() {
+ if (! this.enabled) {
+ YAHOO.util.Event.addListener(attachTo, event, handleKeyPress);
+ this.enabledEvent.fire(keyData);
+ }
+ this.enabled = true;
+ }
+
+ this.disable = function() {
+ if (this.enabled) {
+ YAHOO.util.Event.removeListener(attachTo, event, handleKeyPress);
+ this.disabledEvent.fire(keyData);
+ }
+ this.enabled = false;
+ }
+
+ /**
+ * Returns a string representation of the object.
+ * @type string
+ */
+ this.toString = function() {
+ return "KeyListener [" + keyData.keys + "] " + attachTo.tagName + (attachTo.id ? "[" + attachTo.id + "]" : "");
+ }
+
+}
+
+/**
+* Constant representing the DOM "keydown" event.
+* @final
+*/
+YAHOO.util.KeyListener.KEYDOWN = "keydown";
+
+/**
+* Constant representing the DOM "keyup" event.
+* @final
+*/
+YAHOO.util.KeyListener.KEYUP = "keyup";
+
+/**
+* Boolean indicating the enabled/disabled state of the Tooltip
+* @type Booleam
+*/
+YAHOO.util.KeyListener.prototype.enabled = null;
+
+/**
+* Enables the KeyListener, by dynamically attaching the key event to the appropriate DOM element.
+*/
+YAHOO.util.KeyListener.prototype.enable = function() {};
+
+/**
+* Disables the KeyListener, by dynamically removing the key event from the appropriate DOM element.
+*/
+YAHOO.util.KeyListener.prototype.disable = function() {};
+
+/**
+* CustomEvent fired when the KeyListener is enabled
+* args: keyData
+* @type YAHOO.util.CustomEvent
+*/
+YAHOO.util.KeyListener.prototype.enabledEvent = null;
+
+/**
+* CustomEvent fired when the KeyListener is disabled
+* args: keyData
+* @type YAHOO.util.CustomEvent
+*/
+YAHOO.util.KeyListener.prototype.disabledEvent = null;
+
+/**
+* @class
+* Tooltip is an implementation of Overlay that behaves like an OS tooltip, displaying when the user mouses over a particular element, and disappearing on mouse out.
+* @param {string} el The element ID representing the Tooltip <em>OR</em>
+* @param {Element} el The element representing the Tooltip
+* @param {object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details.
+* @constructor
+*/
+YAHOO.widget.Tooltip = function(el, userConfig) {
+ YAHOO.widget.Tooltip.superclass.constructor.call(this, el, userConfig);
+}
+
+YAHOO.extend(YAHOO.widget.Tooltip, YAHOO.widget.Overlay);
+
+/**
+* Constant representing the Tooltip CSS class
+* @type string
+* @final
+*/
+YAHOO.widget.Tooltip.CSS_TOOLTIP = "tt";
+
+/**
+* The Tooltip initialization method. This method is automatically called by the constructor. A Tooltip is automatically rendered by the init method, and it also is set to be invisible by default, and constrained to viewport by default as well.
+* @param {string} el The element ID representing the Tooltip <em>OR</em>
+* @param {Element} el The element representing the Tooltip
+* @param {object} userConfig The configuration object literal containing the configuration that should be set for this Tooltip. See configuration documentation for more details.
+*/
+YAHOO.widget.Tooltip.prototype.init = function(el, userConfig) {
+ if (document.readyState && document.readyState != "complete") {
+ var deferredInit = function() {
+ this.init(el, userConfig);
+ }
+ YAHOO.util.Event.addListener(window, "load", deferredInit, this, true);
+ } else {
+ YAHOO.widget.Tooltip.superclass.init.call(this, el);
+
+ this.beforeInitEvent.fire(YAHOO.widget.Tooltip);
+
+ YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Tooltip.CSS_TOOLTIP);
+
+ if (userConfig) {
+ this.cfg.applyConfig(userConfig, true);
+ }
+
+ this.cfg.queueProperty("visible",false);
+ this.cfg.queueProperty("constraintoviewport",true);
+
+ this.setBody("");
+ this.render(this.cfg.getProperty("container"));
+
+ this.initEvent.fire(YAHOO.widget.Tooltip);
+ }
+}
+
+/**
+* Initializes the class's configurable properties which can be changed using the Overlay's Config object (cfg).
+*/
+YAHOO.widget.Tooltip.prototype.initDefaultConfig = function() {
+ YAHOO.widget.Tooltip.superclass.initDefaultConfig.call(this);
+
+ this.cfg.addProperty("preventoverlap", { value:true, validator:this.cfg.checkBoolean, supercedes:["x","y","xy"] } );
+
+ this.cfg.addProperty("showdelay", { value:200, handler:this.configShowDelay, validator:this.cfg.checkNumber } );
+ this.cfg.addProperty("autodismissdelay", { value:5000, handler:this.configAutoDismissDelay, validator:this.cfg.checkNumber } );
+ this.cfg.addProperty("hidedelay", { value:250, handler:this.configHideDelay, validator:this.cfg.checkNumber } );
+
+ this.cfg.addProperty("text", { handler:this.configText, suppressEvent:true } );
+ this.cfg.addProperty("container", { value:document.body, handler:this.configContainer } );
+}
+
+// BEGIN BUILT-IN PROPERTY EVENT HANDLERS //
+
+/**
+* The default event handler fired when the "text" property is changed.
+*/
+YAHOO.widget.Tooltip.prototype.configText = function(type, args, obj) {
+ var text = args[0];
+ if (text) {
+ this.setBody(text);
+ }
+}
+
+/**
+* The default event handler fired when the "container" property is changed.
+*/
+YAHOO.widget.Tooltip.prototype.configContainer = function(type, args, obj) {
+ var container = args[0];
+ if (typeof container == 'string') {
+ this.cfg.setProperty("container", document.getElementById(container), true);
+ }
+}
+
+/**
+* The default event handler fired when the "context" property is changed.
+*/
+YAHOO.widget.Tooltip.prototype.configContext = function(type, args, obj) {
+ var context = args[0];
+ if (context) {
+
+ // Normalize parameter into an array
+ if (! (context instanceof Array)) {
+ if (typeof context == "string") {
+ this.cfg.setProperty("context", [document.getElementById(context)], true);
+ } else { // Assuming this is an element
+ this.cfg.setProperty("context", [context], true);
+ }
+ context = this.cfg.getProperty("context");
+ }
+
+
+ // Remove any existing mouseover/mouseout listeners
+ if (this._context) {
+ for (var c=0;c<this._context.length;++c) {
+ var el = this._context[c];
+ YAHOO.util.Event.removeListener(el, "mouseover", this.onContextMouseOver);
+ YAHOO.util.Event.removeListener(el, "mousemove", this.onContextMouseMove);
+ YAHOO.util.Event.removeListener(el, "mouseout", this.onContextMouseOut);
+ }
+ }
+
+ // Add mouseover/mouseout listeners to context elements
+ this._context = context;
+ for (var c=0;c<this._context.length;++c) {
+ var el = this._context[c];
+ YAHOO.util.Event.addListener(el, "mouseover", this.onContextMouseOver, this);
+ YAHOO.util.Event.addListener(el, "mousemove", this.onContextMouseMove, this);
+ YAHOO.util.Event.addListener(el, "mouseout", this.onContextMouseOut, this);
+ }
+ }
+}
+
+// END BUILT-IN PROPERTY EVENT HANDLERS //
+
+// BEGIN BUILT-IN DOM EVENT HANDLERS //
+
+/**
+* The default event handler fired when the user moves the mouse while over the context element.
+* @param {DOMEvent} e The current DOM event
+* @param {object} obj The object argument
+*/
+YAHOO.widget.Tooltip.prototype.onContextMouseMove = function(e, obj) {
+ obj.pageX = YAHOO.util.Event.getPageX(e);
+ obj.pageY = YAHOO.util.Event.getPageY(e);
+
+}
+
+/**
+* The default event handler fired when the user mouses over the context element.
+* @param {DOMEvent} e The current DOM event
+* @param {object} obj The object argument
+*/
+YAHOO.widget.Tooltip.prototype.onContextMouseOver = function(e, obj) {
+
+ if (obj.hideProcId) {
+ clearTimeout(obj.hideProcId);
+ obj.hideProcId = null;
+ }
+
+ var context = this;
+ YAHOO.util.Event.addListener(context, "mousemove", obj.onContextMouseMove, obj);
+
+ if (context.title) {
+ obj._tempTitle = context.title;
+ context.title = "";
+ }
+
+ /**
+ * The unique process ID associated with the thread responsible for showing the Tooltip.
+ * @type int
+ */
+ obj.showProcId = obj.doShow(e, context);
+}
+
+/**
+* The default event handler fired when the user mouses out of the context element.
+* @param {DOMEvent} e The current DOM event
+* @param {object} obj The object argument
+*/
+YAHOO.widget.Tooltip.prototype.onContextMouseOut = function(e, obj) {
+ var el = this;
+
+ if (obj._tempTitle) {
+ el.title = obj._tempTitle;
+ obj._tempTitle = null;
+ }
+
+ if (obj.showProcId) {
+ clearTimeout(obj.showProcId);
+ obj.showProcId = null;
+ }
+
+ if (obj.hideProcId) {
+ clearTimeout(obj.hideProcId);
+ obj.hideProcId = null;
+ }
+
+
+ obj.hideProcId = setTimeout(function() {
+ obj.hide();
+ }, obj.cfg.getProperty("hidedelay"));
+}
+
+// END BUILT-IN DOM EVENT HANDLERS //
+
+/**
+* Processes the showing of the Tooltip by setting the timeout delay and offset of the Tooltip.
+* @param {DOMEvent} e The current DOM event
+* @return {int} The process ID of the timeout function associated with doShow
+*/
+YAHOO.widget.Tooltip.prototype.doShow = function(e, context) {
+
+ var yOffset = 25;
+ if (this.browser == "opera" && context.tagName == "A") {
+ yOffset += 12;
+ }
+
+ var me = this;
+ return setTimeout(
+ function() {
+ if (me._tempTitle) {
+ me.setBody(me._tempTitle);
+ } else {
+ me.cfg.refireEvent("text");
+ }
+
+ me.moveTo(me.pageX, me.pageY + yOffset);
+ if (me.cfg.getProperty("preventoverlap")) {
+ me.preventOverlap(me.pageX, me.pageY);
+ }
+
+ YAHOO.util.Event.removeListener(context, "mousemove", me.onContextMouseMove);
+
+ me.show();
+ me.hideProcId = me.doHide();
+ },
+ this.cfg.getProperty("showdelay"));
+}
+
+/**
+* Sets the timeout for the auto-dismiss delay, which by default is 5 seconds, meaning that a tooltip will automatically dismiss itself after 5 seconds of being displayed.
+*/
+YAHOO.widget.Tooltip.prototype.doHide = function() {
+ var me = this;
+ return setTimeout(
+ function() {
+ me.hide();
+ },
+ this.cfg.getProperty("autodismissdelay"));
+}
+
+/**
+* Fired when the Tooltip is moved, this event handler is used to prevent the Tooltip from overlapping with its context element.
+*/
+YAHOO.widget.Tooltip.prototype.preventOverlap = function(pageX, pageY) {
+
+ var height = this.element.offsetHeight;
+
+ var elementRegion = YAHOO.util.Dom.getRegion(this.element);
+
+ elementRegion.top -= 5;
+ elementRegion.left -= 5;
+ elementRegion.right += 5;
+ elementRegion.bottom += 5;
+
+ var mousePoint = new YAHOO.util.Point(pageX, pageY);
+
+ if (elementRegion.contains(mousePoint)) {
+ this.cfg.setProperty("y", (pageY-height-5))
+ }
+}
+
+/**
+* Returns a string representation of the object.
+* @type string
+*/
+YAHOO.widget.Tooltip.prototype.toString = function() {
+ return "Tooltip " + this.id;
+}
+
+/**
+* @class
+* Panel is an implementation of Overlay that behaves like an OS window, with a draggable header and an optional close icon at the top right.
+* @param {string} el The element ID representing the Panel <em>OR</em>
+* @param {Element} el The element representing the Panel
+* @param {object} userConfig The configuration object literal containing the configuration that should be set for this Panel. See configuration documentation for more details.
+* @constructor
+*/
+YAHOO.widget.Panel = function(el, userConfig) {
+ YAHOO.widget.Panel.superclass.constructor.call(this, el, userConfig);
+}
+
+YAHOO.extend(YAHOO.widget.Panel, YAHOO.widget.Overlay);
+
+/**
+* Constant representing the default CSS class used for a Panel
+* @type string
+* @final
+*/
+YAHOO.widget.Panel.CSS_PANEL = "panel";
+
+/**
+* Constant representing the default CSS class used for a Panel's wrapping container
+* @type string
+* @final
+*/
+YAHOO.widget.Panel.CSS_PANEL_CONTAINER = "panel-container";
+
+/**
+* CustomEvent fired after the modality mask is shown
+* args: none
+* @type YAHOO.util.CustomEvent
+*/
+YAHOO.widget.Panel.prototype.showMaskEvent = null;
+
+/**
+* CustomEvent fired after the modality mask is hidden
+* args: none
+* @type YAHOO.util.CustomEvent
+*/
+YAHOO.widget.Panel.prototype.hideMaskEvent = null;
+
+/**
+* The Overlay initialization method, which is executed for Overlay and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present.
+* @param {string} el The element ID representing the Overlay <em>OR</em>
+* @param {Element} el The element representing the Overlay
+* @param {object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details.
+*/
+YAHOO.widget.Panel.prototype.init = function(el, userConfig) {
+ YAHOO.widget.Panel.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level
+
+ this.beforeInitEvent.fire(YAHOO.widget.Panel);
+
+ YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Panel.CSS_PANEL);
+
+ this.buildWrapper();
+
+ if (userConfig) {
+ this.cfg.applyConfig(userConfig, true);
+ }
+
+ this.beforeRenderEvent.subscribe(function() {
+ var draggable = this.cfg.getProperty("draggable");
+ if (draggable) {
+ if (! this.header) {
+ this.setHeader(" ");
+ }
+ }
+ }, this, true);
+
+ this.initEvent.fire(YAHOO.widget.Panel);
+
+}
+
+/**
+* Initializes the custom events for Module which are fired automatically at appropriate times by the Module class.
+*/
+YAHOO.widget.Panel.prototype.initEvents = function() {
+ YAHOO.widget.Panel.superclass.initEvents.call(this);
+
+ this.showMaskEvent = new YAHOO.util.CustomEvent("showMask");
+ this.hideMaskEvent = new YAHOO.util.CustomEvent("hideMask");
+
+ this.dragEvent = new YAHOO.util.CustomEvent("drag");
+}
+
+/**
+* Initializes the class's configurable properties which can be changed using the Panel's Config object (cfg).
+*/
+YAHOO.widget.Panel.prototype.initDefaultConfig = function() {
+ YAHOO.widget.Panel.superclass.initDefaultConfig.call(this);
+
+ // Add panel config properties //
+
+ this.cfg.addProperty("close", { value:true, handler:this.configClose, validator:this.cfg.checkBoolean, supercedes:["visible"] } );
+ this.cfg.addProperty("draggable", { value:true, handler:this.configDraggable, validator:this.cfg.checkBoolean, supercedes:["visible"] } );
+
+ this.cfg.addProperty("underlay", { value:"shadow", handler:this.configUnderlay, supercedes:["visible"] } );
+ this.cfg.addProperty("modal", { value:false, handler:this.configModal, validator:this.cfg.checkBoolean, supercedes:["visible"] } );
+
+ this.cfg.addProperty("keylisteners", { handler:this.configKeyListeners, suppressEvent:true, supercedes:["visible"] } );
+}
+
+// BEGIN BUILT-IN PROPERTY EVENT HANDLERS //
+
+/**
+* The default event handler fired when the "close" property is changed. The method controls the appending or hiding of the close icon at the top right of the Panel.
+*/
+YAHOO.widget.Panel.prototype.configClose = function(type, args, obj) {
+ var val = args[0];
+
+ var doHide = function(e, obj) {
+ obj.hide();
+ }
+
+ if (val) {
+ if (! this.close) {
+ this.close = document.createElement("DIV");
+ YAHOO.util.Dom.addClass(this.close, "close");
+
+ if (this.isSecure) {
+ YAHOO.util.Dom.addClass(this.close, "secure");
+ } else {
+ YAHOO.util.Dom.addClass(this.close, "nonsecure");
+ }
+
+ this.close.innerHTML = " ";
+ this.innerElement.appendChild(this.close);
+ YAHOO.util.Event.addListener(this.close, "click", doHide, this);
+ } else {
+ this.close.style.display = "block";
+ }
+ } else {
+ if (this.close) {
+ this.close.style.display = "none";
+ }
+ }
+}
+
+/**
+* The default event handler fired when the "draggable" property is changed.
+*/
+YAHOO.widget.Panel.prototype.configDraggable = function(type, args, obj) {
+ var val = args[0];
+ if (val) {
+ if (this.header) {
+ YAHOO.util.Dom.setStyle(this.header,"cursor","move");
+ this.registerDragDrop();
+ }
+ } else {
+ if (this.dd) {
+ this.dd.unreg();
+ }
+ if (this.header) {
+ YAHOO.util.Dom.setStyle(this.header,"cursor","auto");
+ }
+ }
+}
+
+/**
+* The default event handler fired when the "underlay" property is changed.
+*/
+YAHOO.widget.Panel.prototype.configUnderlay = function(type, args, obj) {
+ var val = args[0];
+
+ switch (val.toLowerCase()) {
+ case "shadow":
+ YAHOO.util.Dom.removeClass(this.element, "matte");
+ YAHOO.util.Dom.addClass(this.element, "shadow");
+
+ if (! this.underlay) { // create if not already in DOM
+ this.underlay = document.createElement("DIV");
+ this.underlay.className = "underlay";
+ this.underlay.innerHTML = " ";
+ this.element.appendChild(this.underlay);
+ }
+
+ this.sizeUnderlay();
+ break;
+ case "matte":
+ YAHOO.util.Dom.removeClass(this.element, "shadow");
+ YAHOO.util.Dom.addClass(this.element, "matte");
+ break;
+ case "none":
+ default:
+ YAHOO.util.Dom.removeClass(this.element, "shadow");
+ YAHOO.util.Dom.removeClass(this.element, "matte");
+ break;
+ }
+}
+
+/**
+* The default event handler fired when the "modal" property is changed. This handler subscribes or unsubscribes to the show and hide events to handle the display or hide of the modality mask.
+*/
+YAHOO.widget.Panel.prototype.configModal = function(type, args, obj) {
+ var modal = args[0];
+
+ if (modal) {
+ this.buildMask();
+
+ if (! YAHOO.util.Config.alreadySubscribed( this.showEvent, this.showMask, this ) ) {
+ this.showEvent.subscribe(this.showMask, this, true);
+ }
+ if (! YAHOO.util.Config.alreadySubscribed( this.hideEvent, this.hideMask, this) ) {
+ this.hideEvent.subscribe(this.hideMask, this, true);
+ }
+ if (! YAHOO.util.Config.alreadySubscribed( YAHOO.widget.Overlay.windowResizeEvent, this.sizeMask, this ) ) {
+ YAHOO.widget.Overlay.windowResizeEvent.subscribe(this.sizeMask, this, true);
+ }
+ if (! YAHOO.util.Config.alreadySubscribed( YAHOO.widget.Overlay.windowScrollEvent, this.sizeMask, this ) ) {
+ YAHOO.widget.Overlay.windowScrollEvent.subscribe(this.sizeMask, this, true);
+ }
+ } else {
+ this.beforeShowEvent.unsubscribe(this.showMask, this);
+ this.hideEvent.unsubscribe(this.hideMask, this);
+ YAHOO.widget.Overlay.windowResizeEvent.unsubscribe(this.sizeMask);
+ YAHOO.widget.Overlay.windowScrollEvent.unsubscribe(this.sizeMask);
+ }
+}
+
+/**
+* The default event handler fired when the "keylisteners" property is changed.
+*/
+YAHOO.widget.Panel.prototype.configKeyListeners = function(type, args, obj) {
+ var listeners = args[0];
+
+ if (listeners) {
+ if (listeners instanceof Array) {
+ for (var i=0;i<listeners.length;i++) {
+ var listener = listeners[i];
+
+ if (! YAHOO.util.Config.alreadySubscribed(this.showEvent, listener.enable, listener)) {
+ this.showEvent.subscribe(listener.enable, listener, true);
+ }
+ if (! YAHOO.util.Config.alreadySubscribed(this.hideEvent, listener.disable, listener)) {
+ this.hideEvent.subscribe(listener.disable, listener, true);
+ this.destroyEvent.subscribe(listener.disable, listener, true);
+ }
+ }
+ } else {
+ if (! YAHOO.util.Config.alreadySubscribed(this.showEvent, listeners.enable, listeners)) {
+ this.showEvent.subscribe(listeners.enable, listeners, true);
+ }
+ if (! YAHOO.util.Config.alreadySubscribed(this.hideEvent, listeners.disable, listeners)) {
+ this.hideEvent.subscribe(listeners.disable, listeners, true);
+ this.destroyEvent.subscribe(listeners.disable, listeners, true);
+ }
+ }
+ }
+}
+
+// END BUILT-IN PROPERTY EVENT HANDLERS //
+
+
+/**
+* Builds the wrapping container around the Panel that is used for positioning the shadow and matte underlays. The container element is assigned to a local instance variable called container, and the element is reinserted inside of it.
+*/
+YAHOO.widget.Panel.prototype.buildWrapper = function() {
+ var elementParent = this.element.parentNode;
+
+ var elementClone = this.element.cloneNode(true);
+ this.innerElement = elementClone;
+ this.innerElement.style.visibility = "inherit";
+
+ YAHOO.util.Dom.addClass(this.innerElement, YAHOO.widget.Panel.CSS_PANEL);
+
+ var wrapper = document.createElement("DIV");
+ wrapper.className = YAHOO.widget.Panel.CSS_PANEL_CONTAINER;
+ wrapper.id = elementClone.id + "_c";
+
+ wrapper.appendChild(elementClone);
+
+ if (elementParent) {
+ elementParent.replaceChild(wrapper, this.element);
+ }
+
+ this.element = wrapper;
+
+ // Resynchronize the local field references
+
+ var childNodes = this.innerElement.childNodes;
+ if (childNodes) {
+ for (var i=0;i<childNodes.length;i++) {
+ var child = childNodes[i];
+ switch (child.className) {
+ case YAHOO.widget.Module.CSS_HEADER:
+ this.header = child;
+ break;
+ case YAHOO.widget.Module.CSS_BODY:
+ this.body = child;
+ break;
+ case YAHOO.widget.Module.CSS_FOOTER:
+ this.footer = child;
+ break;
+ }
+ }
+ }
+
+ this.initDefaultConfig(); // We've changed the DOM, so the configuration must be re-tooled to get the DOM references right
+}
+
+/**
+* Adjusts the size of the shadow based on the size of the element.
+*/
+YAHOO.widget.Panel.prototype.sizeUnderlay = function() {
+ if (this.underlay && this.browser != "gecko" && this.browser != "safari") {
+ this.underlay.style.width = this.innerElement.offsetWidth + "px";
+ this.underlay.style.height = this.innerElement.offsetHeight + "px";
+ }
+}
+
+/**
+* Event handler fired when the resize monitor element is resized.
+*/
+YAHOO.widget.Panel.prototype.onDomResize = function(e, obj) {
+ YAHOO.widget.Panel.superclass.onDomResize.call(this, e, obj);
+ var me = this;
+ setTimeout(function() {
+ me.sizeUnderlay();
+ }, 0);
+};
+
+/**
+* Registers the Panel's header for drag & drop capability.
+*/
+YAHOO.widget.Panel.prototype.registerDragDrop = function() {
+ if (this.header) {
+ this.dd = new YAHOO.util.DD(this.element.id, this.id);
+
+ if (! this.header.id) {
+ this.header.id = this.id + "_h";
+ }
+
+ var me = this;
+
+ this.dd.startDrag = function() {
+
+ if (me.browser == "ie") {
+ YAHOO.util.Dom.addClass(me.element,"drag");
+ }
+
+ if (me.cfg.getProperty("constraintoviewport")) {
+ var offsetHeight = me.element.offsetHeight;
+ var offsetWidth = me.element.offsetWidth;
+
+ var viewPortWidth = YAHOO.util.Dom.getViewportWidth();
+ var viewPortHeight = YAHOO.util.Dom.getViewportHeight();
+
+ var scrollX = window.scrollX || document.documentElement.scrollLeft;
+ var scrollY = window.scrollY || document.documentElement.scrollTop;
+
+ var topConstraint = scrollY + 10;
+ var leftConstraint = scrollX + 10;
+ var bottomConstraint = scrollY + viewPortHeight - offsetHeight - 10;
+ var rightConstraint = scrollX + viewPortWidth - offsetWidth - 10;
+
+ this.minX = leftConstraint
+ this.maxX = rightConstraint;
+ this.constrainX = true;
+
+ this.minY = topConstraint;
+ this.maxY = bottomConstraint;
+ this.constrainY = true;
+ } else {
+ this.constrainX = false;
+ this.constrainY = false;
+ }
+
+ me.dragEvent.fire("startDrag", arguments);
+ }
+
+ this.dd.onDrag = function() {
+ me.syncPosition();
+ me.cfg.refireEvent("iframe");
+ if (this.platform == "mac" && this.browser == "gecko") {
+ this.showMacGeckoScrollbars();
+ }
+
+ me.dragEvent.fire("onDrag", arguments);
+ }
+
+ this.dd.endDrag = function() {
+ if (me.browser == "ie") {
+ YAHOO.util.Dom.removeClass(me.element,"drag");
+ }
+
+ me.dragEvent.fire("endDrag", arguments);
+ }
+
+ this.dd.setHandleElId(this.header.id);
+ this.dd.addInvalidHandleType("INPUT");
+ this.dd.addInvalidHandleType("SELECT");
+ this.dd.addInvalidHandleType("TEXTAREA");
+ }
+}
+
+/**
+* Builds the mask that is laid over the document when the Panel is configured to be modal.
+*/
+YAHOO.widget.Panel.prototype.buildMask = function() {
+ if (! this.mask) {
+ this.mask = document.createElement("DIV");
+ this.mask.id = this.id + "_mask";
+ this.mask.className = "mask";
+ this.mask.innerHTML = " ";
+
+ var maskClick = function(e, obj) {
+ YAHOO.util.Event.stopEvent(e);
+ }
+
+ YAHOO.util.Event.addListener(this.mask, maskClick, this);
+
+ document.body.appendChild(this.mask);
+ }
+}
+
+/**
+* Hides the modality mask.
+*/
+YAHOO.widget.Panel.prototype.hideMask = function() {
+ if (this.cfg.getProperty("modal") && this.mask) {
+ this.mask.style.display = "none";
+ this.hideMaskEvent.fire();
+ YAHOO.util.Dom.removeClass(document.body, "masked");
+ }
+}
+
+/**
+* Shows the modality mask.
+*/
+YAHOO.widget.Panel.prototype.showMask = function() {
+ if (this.cfg.getProperty("modal") && this.mask) {
+ YAHOO.util.Dom.addClass(document.body, "masked");
+ this.sizeMask();
+ this.mask.style.display = "block";
+ this.showMaskEvent.fire();
+ }
+}
+
+/**
+* Sets the size of the modality mask to cover the entire scrollable area of the document
+*/
+YAHOO.widget.Panel.prototype.sizeMask = function() {
+ if (this.mask) {
+ this.mask.style.height = YAHOO.util.Dom.getDocumentHeight()+"px";
+ this.mask.style.width = YAHOO.util.Dom.getDocumentWidth()+"px";
+ }
+}
+
+/**
+* The default event handler fired when the "height" property is changed.
+*/
+YAHOO.widget.Panel.prototype.configHeight = function(type, args, obj) {
+ var height = args[0];
+ var el = this.innerElement;
+ YAHOO.util.Dom.setStyle(el, "height", height);
+ this.cfg.refireEvent("underlay");
+ this.cfg.refireEvent("iframe");
+}
+
+/**
+* The default event handler fired when the "width" property is changed.
+*/
+YAHOO.widget.Panel.prototype.configWidth = function(type, args, obj) {
+ var width = args[0];
+ var el = this.innerElement;
+ YAHOO.util.Dom.setStyle(el, "width", width);
+ this.cfg.refireEvent("underlay");
+ this.cfg.refireEvent("iframe");
+}
+
+/**
+* Renders the Panel by inserting the elements that are not already in the main Panel into their correct places. Optionally appends the Panel to the specified node prior to the render's execution. NOTE: For Panels without existing markup, the appendToNode argument is REQUIRED. If this argument is ommitted and the current element is not present in the document, the function will return false, indicating that the render was a failure.
+* @param {string} appendToNode The element id to which the Module should be appended to prior to rendering <em>OR</em>
+* @param {Element} appendToNode The element to which the Module should be appended to prior to rendering
+* @return {boolean} Success or failure of the render
+*/
+YAHOO.widget.Panel.prototype.render = function(appendToNode) {
+ return YAHOO.widget.Panel.superclass.render.call(this, appendToNode, this.innerElement);
+}
+
+/**
+* Returns a string representation of the object.
+* @type string
+*/
+YAHOO.widget.Panel.prototype.toString = function() {
+ return "Panel " + this.id;
+}
+
+/**
+* @class
+* Dialog is an implementation of Panel that can be used to submit form data. Built-in functionality for buttons with event handlers is included, and button sets can be build dynamically, or the preincluded ones for Submit/Cancel and OK/Cancel can be utilized. Forms can be processed in 3 ways -- via an asynchronous Connection utility call, a simple form POST or GET, or manually.
+* @param {string} el The element ID representing the Dialog <em>OR</em>
+* @param {Element} el The element representing the Dialog
+* @param {object} userConfig The configuration object literal containing the configuration that should be set for this Dialog. See configuration documentation for more details.
+* @constructor
+*/
+YAHOO.widget.Dialog = function(el, userConfig) {
+ YAHOO.widget.Dialog.superclass.constructor.call(this, el, userConfig);
+}
+
+YAHOO.extend(YAHOO.widget.Dialog, YAHOO.widget.Panel);
+
+/**
+* Constant representing the default CSS class used for a Dialog
+* @type string
+* @final
+*/
+YAHOO.widget.Dialog.CSS_DIALOG = "dialog";
+
+
+/**
+* CustomEvent fired prior to submission
+* @type YAHOO.util.CustomEvent
+*/
+YAHOO.widget.Dialog.prototype.beforeSubmitEvent = null;
+
+/**
+* CustomEvent fired after submission
+* @type YAHOO.util.CustomEvent
+*/
+YAHOO.widget.Dialog.prototype.submitEvent = null;
+
+/**
+* CustomEvent fired prior to manual submission
+* @type YAHOO.util.CustomEvent
+*/
+YAHOO.widget.Dialog.prototype.manualSubmitEvent = null;
+
+/**
+* CustomEvent fired prior to asynchronous submission
+* @type YAHOO.util.CustomEvent
+*/
+YAHOO.widget.Dialog.prototype.asyncSubmitEvent = null;
+
+/**
+* CustomEvent fired prior to form-based submission
+* @type YAHOO.util.CustomEvent
+*/
+YAHOO.widget.Dialog.prototype.formSubmitEvent = null;
+
+/**
+* CustomEvent fired after cancel
+* @type YAHOO.util.CustomEvent
+*/
+YAHOO.widget.Dialog.prototype.cancelEvent = null;
+
+
+/**
+* Initializes the class's configurable properties which can be changed using the Dialog's Config object (cfg).
+*/
+YAHOO.widget.Dialog.prototype.initDefaultConfig = function() {
+ YAHOO.widget.Dialog.superclass.initDefaultConfig.call(this);
+
+ /**
+ * The internally maintained callback object for use with the Connection utility
+ * @type object
+ * @private
+ */
+ this.callback = {
+ success : null,
+ failure : null,
+ argument: null,
+ scope : this
+ }
+
+ this.doSubmit = function() {
+ var method = this.cfg.getProperty("postmethod");
+ switch (method) {
+ case "async":
+ YAHOO.util.Connect.setForm(this.form.name);
+ var cObj = YAHOO.util.Connect.asyncRequest('POST', this.form.action, this.callback);
+ this.asyncSubmitEvent.fire();
+ break;
+ case "form":
+ this.form.submit();
+ this.formSubmitEvent.fire();
+ break;
+ case "none":
+ case "manual":
+ this.manualSubmitEvent.fire();
+ break;
+ }
+ }
+
+ // Add form dialog config properties //
+ this.cfg.addProperty("postmethod", { value:"async", validator:function(val) {
+ if (val != "form" && val != "async" && val != "none" && val != "manual") {
+ return false;
+ } else {
+ return true;
+ }
+ } });
+
+ this.cfg.addProperty("buttons", { value:"none", handler:this.configButtons } );
+}
+
+/**
+* Initializes the custom events for Dialog which are fired automatically at appropriate times by the Dialog class.
+*/
+YAHOO.widget.Dialog.prototype.initEvents = function() {
+ YAHOO.widget.Dialog.superclass.initEvents.call(this);
+
+ this.beforeSubmitEvent = new YAHOO.util.CustomEvent("beforeSubmit");
+ this.submitEvent = new YAHOO.util.CustomEvent("submit");
+
+ this.manualSubmitEvent = new YAHOO.util.CustomEvent("manualSubmit");
+ this.asyncSubmitEvent = new YAHOO.util.CustomEvent("asyncSubmit");
+ this.formSubmitEvent = new YAHOO.util.CustomEvent("formSubmit");
+
+ this.cancelEvent = new YAHOO.util.CustomEvent("cancel");
+}
+
+/**
+* The Dialog initialization method, which is executed for Dialog and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present.
+* @param {string} el The element ID representing the Dialog <em>OR</em>
+* @param {Element} el The element representing the Dialog
+* @param {object} userConfig The configuration object literal containing the configuration that should be set for this Dialog. See configuration documentation for more details.
+*/
+YAHOO.widget.Dialog.prototype.init = function(el, userConfig) {
+ YAHOO.widget.Dialog.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level
+
+ this.beforeInitEvent.fire(YAHOO.widget.Dialog);
+
+ YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Dialog.CSS_DIALOG);
+
+ this.cfg.setProperty("visible", false);
+
+ if (userConfig) {
+ this.cfg.applyConfig(userConfig, true);
+ }
+
+ this.renderEvent.subscribe(this.registerForm, this, true);
+
+ this.showEvent.subscribe(this.focusFirst, this, true);
+ this.beforeHideEvent.subscribe(this.blurButtons, this, true);
+
+ this.beforeRenderEvent.subscribe(function() {
+ var buttonCfg = this.cfg.getProperty("buttons");
+ if (buttonCfg && buttonCfg != "none") {
+ if (! this.footer) {
+ this.setFooter("");
+ }
+ }
+ }, this, true);
+
+ this.initEvent.fire(YAHOO.widget.Dialog);
+}
+
+/**
+* Prepares the Dialog's internal FORM object, creating one if one is not currently present.
+*/
+YAHOO.widget.Dialog.prototype.registerForm = function() {
+ var form = this.element.getElementsByTagName("FORM")[0];
+
+ if (! form) {
+ var formHTML = "<form name=\"frm_" + this.id + "\" action=\"\"></form>";
+ this.body.innerHTML += formHTML;
+ form = this.element.getElementsByTagName("FORM")[0];
+ }
+
+ this.firstFormElement = function() {
+ for (var f=0;f<form.elements.length;f++ ) {
+ var el = form.elements[f];
+ if (el.focus) {
+ if (el.type && el.type != "hidden") {
+ return el;
+ break;
+ }
+ }
+ }
+ return null;
+ }();
+
+ this.lastFormElement = function() {
+ for (var f=form.elements.length-1;f>=0;f-- ) {
+ var el = form.elements[f];
+ if (el.focus) {
+ if (el.type && el.type != "hidden") {
+ return el;
+ break;
+ }
+ }
+ }
+ return null;
+ }();
+
+ this.form = form;
+
+ if (this.cfg.getProperty("modal") && this.form) {
+
+ var me = this;
+
+ var firstElement = this.firstFormElement || this.firstButton;
+ if (firstElement) {
+ this.preventBackTab = new YAHOO.util.KeyListener(firstElement, { shift:true, keys:9 }, {fn:me.focusLast, scope:me, correctScope:true} );
+ this.showEvent.subscribe(this.preventBackTab.enable, this.preventBackTab, true);
+ this.hideEvent.subscribe(this.preventBackTab.disable, this.preventBackTab, true);
+ }
+
+ var lastElement = this.lastButton || this.lastFormElement;
+ if (lastElement) {
+ this.preventTabOut = new YAHOO.util.KeyListener(lastElement, { shift:false, keys:9 }, {fn:me.focusFirst, scope:me, correctScope:true} );
+ this.showEvent.subscribe(this.preventTabOut.enable, this.preventTabOut, true);
+ this.hideEvent.subscribe(this.preventTabOut.disable, this.preventTabOut, true);
+ }
+ }
+}
+
+// BEGIN BUILT-IN PROPERTY EVENT HANDLERS //
+
+/**
+* The default event handler for the "buttons" configuration property
+*/
+YAHOO.widget.Dialog.prototype.configButtons = function(type, args, obj) {
+ var buttons = args[0];
+ if (buttons != "none") {
+ this.buttonSpan = null;
+ this.buttonSpan = document.createElement("SPAN");
+ this.buttonSpan.className = "button-group";
+
+ for (var b=0;b<buttons.length;b++) {
+ var button = buttons[b];
+
+ var htmlButton = document.createElement("BUTTON");
+
+ if (button.isDefault) {
+ htmlButton.className = "default";
+ this.defaultHtmlButton = htmlButton;
+ }
+
+ htmlButton.appendChild(document.createTextNode(button.text));
+ YAHOO.util.Event.addListener(htmlButton, "click", button.handler, this, true);
+
+ this.buttonSpan.appendChild(htmlButton);
+ button.htmlButton = htmlButton;
+
+ if (b == 0) {
+ this.firstButton = button.htmlButton;
+ }
+
+ if (b == (buttons.length-1)) {
+ this.lastButton = button.htmlButton;
+ }
+
+ }
+
+ this.setFooter(this.buttonSpan);
+
+ this.cfg.refireEvent("iframe");
+ this.cfg.refireEvent("underlay");
+ } else { // Do cleanup
+ if (this.buttonSpan) {
+ if (this.buttonSpan.parentNode) {
+ this.buttonSpan.parentNode.removeChild(this.buttonSpan);
+ }
+
+ this.buttonSpan = null;
+ this.firstButton = null;
+ this.lastButton = null;
+ this.defaultHtmlButton = null;
+ }
+ }
+}
+
+/**
+* The default handler fired when the "success" property is changed. Used for asynchronous submission only.
+*/
+YAHOO.widget.Dialog.prototype.configOnSuccess = function(type,args,obj){};
+
+/**
+* The default handler fired when the "failure" property is changed. Used for asynchronous submission only.
+*/
+YAHOO.widget.Dialog.prototype.configOnFailure = function(type,args,obj){};
+
+/**
+* Executes a submission of the form based on the value of the postmethod property.
+*/
+YAHOO.widget.Dialog.prototype.doSubmit = function() {};
+
+/**
+* The default event handler used to focus the first field of the form when the Dialog is shown.
+*/
+YAHOO.widget.Dialog.prototype.focusFirst = function(type,args,obj) {
+ if (args) {
+ var e = args[1];
+ if (e) {
+ YAHOO.util.Event.stopEvent(e);
+ }
+ }
+
+ if (this.firstFormElement) {
+ this.firstFormElement.focus();
+ } else {
+ this.focusDefaultButton();
+ }
+}
+
+/**
+* Sets the focus to the last button in the button or form element in the Dialog
+*/
+YAHOO.widget.Dialog.prototype.focusLast = function(type,args,obj) {
+ if (args) {
+ var e = args[1];
+ if (e) {
+ YAHOO.util.Event.stopEvent(e);
+ }
+ }
+
+ var buttons = this.cfg.getProperty("buttons");
+ if (buttons && buttons instanceof Array) {
+ this.focusLastButton();
+ } else {
+ if (this.lastFormElement) {
+ this.lastFormElement.focus();
+ }
+ }
+}
+
+/**
+* Sets the focus to the button that is designated as the default. By default, his handler is executed when the show event is fired.
+*/
+YAHOO.widget.Dialog.prototype.focusDefaultButton = function() {
+ if (this.defaultHtmlButton) {
+ this.defaultHtmlButton.focus();
+ }
+}
+
+/**
+* Blurs all the html buttons
+*/
+YAHOO.widget.Dialog.prototype.blurButtons = function() {
+ var buttons = this.cfg.getProperty("buttons");
+ if (buttons && buttons instanceof Array) {
+ var html = buttons[0].htmlButton;
+ if (html) {
+ html.blur();
+ }
+ }
+}
+
+/**
+* Sets the focus to the first button in the button list
+*/
+YAHOO.widget.Dialog.prototype.focusFirstButton = function() {
+ var buttons = this.cfg.getProperty("buttons");
+ if (buttons && buttons instanceof Array) {
+ var html = buttons[0].htmlButton;
+ if (html) {
+ html.focus();
+ }
+ }
+}
+
+/**
+* Sets the focus to the first button in the button list
+*/
+YAHOO.widget.Dialog.prototype.focusLastButton = function() {
+ var buttons = this.cfg.getProperty("buttons");
+ if (buttons && buttons instanceof Array) {
+ var html = buttons[buttons.length-1].htmlButton;
+ if (html) {
+ html.focus();
+ }
+ }
+}
+
+// END BUILT-IN PROPERTY EVENT HANDLERS //
+
+/**
+* Built-in function hook for writing a validation function that will be checked for a "true" value prior to a submit. This function, as implemented by default, always returns true, so it should be overridden if validation is necessary.
+*/
+YAHOO.widget.Dialog.prototype.validate = function() {
+ return true;
+}
+
+/**
+* Executes a submit of the Dialog followed by a hide, if validation is successful.
+*/
+YAHOO.widget.Dialog.prototype.submit = function() {
+ if (this.validate()) {
+ this.beforeSubmitEvent.fire();
+ this.doSubmit();
+ this.submitEvent.fire();
+ this.hide();
+ return true;
+ } else {
+ return false;
+ }
+}
+
+/**
+* Executes the cancel of the Dialog followed by a hide.
+*/
+YAHOO.widget.Dialog.prototype.cancel = function() {
+ this.cancelEvent.fire();
+ this.hide();
+}
+
+/**
+* Returns a JSON-compatible data structure representing the data currently contained in the form.
+* @return {object} A JSON object reprsenting the data of the current form.
+*/
+YAHOO.widget.Dialog.prototype.getData = function() {
+ var form = this.form;
+ var data = {};
+
+ if (form) {
+ for (var i in this.form) {
+ var formItem = form[i];
+ if (formItem) {
+ if (formItem.tagName) { // Got a single form item
+ switch (formItem.tagName) {
+ case "INPUT":
+ switch (formItem.type) {
+ case "checkbox":
+ data[i] = formItem.checked;
+ break;
+ case "textbox":
+ case "text":
+ case "hidden":
+ data[i] = formItem.value;
+ break;
+ }
+ break;
+ case "TEXTAREA":
+ data[i] = formItem.value;
+ break;
+ case "SELECT":
+ var val = new Array();
+ for (var x=0;x<formItem.options.length;x++) {
+ var option = formItem.options[x];
+ if (option.selected) {
+ var selval = option.value;
+ if (! selval || selval == "") {
+ selval = option.text;
+ }
+ val[val.length] = selval;
+ }
+ }
+ data[i] = val;
+ break;
+ }
+ } else if (formItem[0] && formItem[0].tagName) { // this is an array of form items
+ switch (formItem[0].tagName) {
+ case "INPUT" :
+ switch (formItem[0].type) {
+ case "radio":
+ for (var r=0; r<formItem.length; r++) {
+ var radio = formItem[r];
+ if (radio.checked) {
+ data[radio.name] = radio.value;
+ break;
+ }
+ }
+ break;
+ case "checkbox":
+ var cbArray = new Array();
+ for (var c=0; c<formItem.length; c++) {
+ var check = formItem[c];
+ if (check.checked) {
+ cbArray[cbArray.length] = check.value;
+ }
+ }
+ data[formItem[0].name] = cbArray;
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ return data;
+}
+
+/**
+* Returns a string representation of the object.
+* @type string
+*/
+YAHOO.widget.Dialog.prototype.toString = function() {
+ return "Dialog " + this.id;
+}
+
+/**
+* @class
+* SimpleDialog is a simple implementation of Dialog that can be used to submit a single value. Forms can be processed in 3 ways -- via an asynchronous Connection utility call, a simple form POST or GET, or manually.
+* @param {string} el The element ID representing the SimpleDialog <em>OR</em>
+* @param {Element} el The element representing the SimpleDialog
+* @param {object} userConfig The configuration object literal containing the configuration that should be set for this SimpleDialog. See configuration documentation for more details.
+* @constructor
+*/
+YAHOO.widget.SimpleDialog = function(el, userConfig) {
+ YAHOO.widget.SimpleDialog.superclass.constructor.call(this, el, userConfig);
+}
+
+YAHOO.extend(YAHOO.widget.SimpleDialog, YAHOO.widget.Dialog);
+
+/**
+* Constant for the standard network icon for a blocking action
+* @type string
+* @final
+*/
+YAHOO.widget.SimpleDialog.ICON_BLOCK = "nt/ic/ut/bsc/blck16_1.gif";
+
+/**
+* Constant for the standard network icon for alarm
+* @type string
+* @final
+*/
+YAHOO.widget.SimpleDialog.ICON_ALARM = "nt/ic/ut/bsc/alrt16_1.gif";
+
+/**
+* Constant for the standard network icon for help
+* @type string
+* @final
+*/
+YAHOO.widget.SimpleDialog.ICON_HELP = "nt/ic/ut/bsc/hlp16_1.gif";
+
+/**
+* Constant for the standard network icon for info
+* @type string
+* @final
+*/
+YAHOO.widget.SimpleDialog.ICON_INFO = "nt/ic/ut/bsc/info16_1.gif";
+
+/**
+* Constant for the standard network icon for warn
+* @type string
+* @final
+*/
+YAHOO.widget.SimpleDialog.ICON_WARN = "nt/ic/ut/bsc/warn16_1.gif";
+
+/**
+* Constant for the standard network icon for a tip
+* @type string
+* @final
+*/
+YAHOO.widget.SimpleDialog.ICON_TIP = "nt/ic/ut/bsc/tip16_1.gif";
+
+/**
+* Constant representing the default CSS class used for a SimpleDialog
+* @type string
+* @final
+*/
+YAHOO.widget.SimpleDialog.CSS_SIMPLEDIALOG = "simple-dialog";
+
+/**
+* Initializes the class's configurable properties which can be changed using the SimpleDialog's Config object (cfg).
+*/
+YAHOO.widget.SimpleDialog.prototype.initDefaultConfig = function() {
+ YAHOO.widget.SimpleDialog.superclass.initDefaultConfig.call(this);
+
+ // Add dialog config properties //
+ this.cfg.addProperty("icon", { value:"none", handler:this.configIcon, suppressEvent:true } );
+ this.cfg.addProperty("text", { value:"", handler:this.configText, suppressEvent:true, supercedes:["icon"] } );
+}
+
+
+/**
+* The SimpleDialog initialization method, which is executed for SimpleDialog and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present.
+* @param {string} el The element ID representing the SimpleDialog <em>OR</em>
+* @param {Element} el The element representing the SimpleDialog
+* @param {object} userConfig The configuration object literal containing the configuration that should be set for this SimpleDialog. See configuration documentation for more details.
+*/
+YAHOO.widget.SimpleDialog.prototype.init = function(el, userConfig) {
+ YAHOO.widget.SimpleDialog.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level
+
+ this.beforeInitEvent.fire(YAHOO.widget.SimpleDialog);
+
+ YAHOO.util.Dom.addClass(this.element, YAHOO.widget.SimpleDialog.CSS_SIMPLEDIALOG);
+
+ this.cfg.queueProperty("postmethod", "manual");
+
+ if (userConfig) {
+ this.cfg.applyConfig(userConfig, true);
+ }
+
+ this.beforeRenderEvent.subscribe(function() {
+ if (! this.body) {
+ this.setBody("");
+ }
+ }, this, true);
+
+ this.initEvent.fire(YAHOO.widget.SimpleDialog);
+
+}
+/**
+* Prepares the SimpleDialog's internal FORM object, creating one if one is not currently present, and adding the value hidden field.
+*/
+YAHOO.widget.SimpleDialog.prototype.registerForm = function() {
+ YAHOO.widget.SimpleDialog.superclass.registerForm.call(this);
+ this.form.innerHTML += "<input type=\"hidden\" name=\"" + this.id + "\" value=\"\"/>";
+}
+
+// BEGIN BUILT-IN PROPERTY EVENT HANDLERS //
+
+/**
+* Fired when the "icon" property is set.
+*/
+YAHOO.widget.SimpleDialog.prototype.configIcon = function(type,args,obj) {
+ var icon = args[0];
+ if (icon && icon != "none") {
+ var iconHTML = "<img src=\"" + this.imageRoot + icon + "\" class=\"icon\" />";
+ this.body.innerHTML = iconHTML + this.body.innerHTML;
+ }
+}
+
+/**
+* Fired when the "text" property is set.
+*/
+YAHOO.widget.SimpleDialog.prototype.configText = function(type,args,obj) {
+ var text = args[0];
+ if (text) {
+ this.setBody(text);
+ this.cfg.refireEvent("icon");
+ }
+}
+// END BUILT-IN PROPERTY EVENT HANDLERS //
+
+/**
+* Returns a string representation of the object.
+* @type string
+*/
+YAHOO.widget.SimpleDialog.prototype.toString = function() {
+ return "SimpleDialog " + this.id;
+}
+
+/**
+* @class
+* ContainerEffect encapsulates animation transitions that are executed when an Overlay is shown or hidden.
+* @param {Overlay} overlay The Overlay that the animation should be associated with
+* @param {object} attrIn The object literal representing the animation arguments to be used for the animate-in transition. The arguments for this literal are: attributes(object, see YAHOO.util.Anim for description), duration(float), and method(i.e. YAHOO.util.Easing.easeIn).
+* @param {object} attrOut The object literal representing the animation arguments to be used for the animate-out transition. The arguments for this literal are: attributes(object, see YAHOO.util.Anim for description), duration(float), and method(i.e. YAHOO.util.Easing.easeIn).
+* @param {Element} targetElement Optional. The target element that should be animated during the transition. Defaults to overlay.element.
+* @param {class} Optional. The animation class to instantiate. Defaults to YAHOO.util.Anim. Other options include YAHOO.util.Motion.
+* @constructor
+*/
+YAHOO.widget.ContainerEffect = function(overlay, attrIn, attrOut, targetElement, animClass) {
+ if (! animClass) {
+ animClass = YAHOO.util.Anim;
+ }
+
+ /**
+ * The overlay to animate
+ */
+ this.overlay = overlay;
+ /**
+ * The animation attributes to use when transitioning into view
+ */
+ this.attrIn = attrIn;
+ /**
+ * The animation attributes to use when transitioning out of view
+ */
+ this.attrOut = attrOut;
+ /**
+ * The target element to be animated
+ */
+ this.targetElement = targetElement || overlay.element;
+ /**
+ * The animation class to use for animating the overlay
+ */
+ this.animClass = animClass;
+}
+
+/**
+* Initializes the animation classes and events.
+*/
+YAHOO.widget.ContainerEffect.prototype.init = function() {
+ this.beforeAnimateInEvent = new YAHOO.util.CustomEvent("beforeAnimateIn");
+ this.beforeAnimateOutEvent = new YAHOO.util.CustomEvent("beforeAnimateOut");
+
+ this.animateInCompleteEvent = new YAHOO.util.CustomEvent("animateInComplete");
+ this.animateOutCompleteEvent = new YAHOO.util.CustomEvent("animateOutComplete");
+
+ this.animIn = new this.animClass(this.targetElement, this.attrIn.attributes, this.attrIn.duration, this.attrIn.method);
+ this.animIn.onStart.subscribe(this.handleStartAnimateIn, this);
+ this.animIn.onTween.subscribe(this.handleTweenAnimateIn, this);
+ this.animIn.onComplete.subscribe(this.handleCompleteAnimateIn, this);
+
+ this.animOut = new this.animClass(this.targetElement, this.attrOut.attributes, this.attrOut.duration, this.attrOut.method);
+ this.animOut.onStart.subscribe(this.handleStartAnimateOut, this);
+ this.animOut.onTween.subscribe(this.handleTweenAnimateOut, this);
+ this.animOut.onComplete.subscribe(this.handleCompleteAnimateOut, this);
+}
+
+/**
+* Triggers the in-animation.
+*/
+YAHOO.widget.ContainerEffect.prototype.animateIn = function() {
+ this.beforeAnimateInEvent.fire();
+ this.animIn.animate();
+}
+
+/**
+* Triggers the out-animation.
+*/
+YAHOO.widget.ContainerEffect.prototype.animateOut = function() {
+ this.beforeAnimateOutEvent.fire();
+ this.animOut.animate();
+}
+
+/**
+* The default onStart handler for the in-animation.
+*/
+YAHOO.widget.ContainerEffect.prototype.handleStartAnimateIn = function(type, args, obj) { }
+/**
+* The default onTween handler for the in-animation.
+*/
+YAHOO.widget.ContainerEffect.prototype.handleTweenAnimateIn = function(type, args, obj) { }
+/**
+* The default onComplete handler for the in-animation.
+*/
+YAHOO.widget.ContainerEffect.prototype.handleCompleteAnimateIn = function(type, args, obj) { }
+
+/**
+* The default onStart handler for the out-animation.
+*/
+YAHOO.widget.ContainerEffect.prototype.handleStartAnimateOut = function(type, args, obj) { }
+/**
+* The default onTween handler for the out-animation.
+*/
+YAHOO.widget.ContainerEffect.prototype.handleTweenAnimateOut = function(type, args, obj) { }
+/**
+* The default onComplete handler for the out-animation.
+*/
+YAHOO.widget.ContainerEffect.prototype.handleCompleteAnimateOut = function(type, args, obj) { }
+
+/**
+* Returns a string representation of the object.
+* @type string
+*/
+YAHOO.widget.ContainerEffect.prototype.toString = function() {
+ var output = "ContainerEffect";
+ if (this.overlay) {
+ output += " [" + this.overlay.toString() + "]";
+ }
+ return output;
+}
+
+/**
+* A pre-configured ContainerEffect instance that can be used for fading an overlay in and out.
+* @param {Overlay} The Overlay object to animate
+* @param {float} The duration of the animation
+* @type ContainerEffect
+*/
+YAHOO.widget.ContainerEffect.FADE = function(overlay, dur) {
+ var fade = new YAHOO.widget.ContainerEffect(overlay, { attributes:{opacity: {from:0, to:1}}, duration:dur, method:YAHOO.util.Easing.easeIn }, { attributes:{opacity: {to:0}}, duration:dur, method:YAHOO.util.Easing.easeOut}, overlay.element );
+
+ fade.handleStartAnimateIn = function(type,args,obj) {
+ YAHOO.util.Dom.addClass(obj.overlay.element, "hide-select");
+
+ if (! obj.overlay.underlay) {
+ obj.overlay.cfg.refireEvent("underlay");
+ }
+
+ if (obj.overlay.underlay) {
+ obj.initialUnderlayOpacity = YAHOO.util.Dom.getStyle(obj.overlay.underlay, "opacity");
+ obj.overlay.underlay.style.filter = null;
+ }
+
+ YAHOO.util.Dom.setStyle(obj.overlay.element, "visibility", "visible");
+ YAHOO.util.Dom.setStyle(obj.overlay.element, "opacity", 0);
+ }
+
+ fade.handleCompleteAnimateIn = function(type,args,obj) {
+ YAHOO.util.Dom.removeClass(obj.overlay.element, "hide-select");
+
+ if (obj.overlay.element.style.filter) {
+ obj.overlay.element.style.filter = null;
+ }
+
+ if (obj.overlay.underlay) {
+ YAHOO.util.Dom.setStyle(obj.overlay.underlay, "opacity", obj.initialUnderlayOpacity);
+ }
+
+ obj.overlay.cfg.refireEvent("iframe");
+ obj.animateInCompleteEvent.fire();
+ }
+
+ fade.handleStartAnimateOut = function(type, args, obj) {
+ YAHOO.util.Dom.addClass(obj.overlay.element, "hide-select");
+
+ if (obj.overlay.underlay) {
+ obj.overlay.underlay.style.filter = null;
+ }
+ }
+
+ fade.handleCompleteAnimateOut = function(type, args, obj) {
+ YAHOO.util.Dom.removeClass(obj.overlay.element, "hide-select");
+ if (obj.overlay.element.style.filter) {
+ obj.overlay.element.style.filter = null;
+ }
+ YAHOO.util.Dom.setStyle(obj.overlay.element, "visibility", "hidden");
+ YAHOO.util.Dom.setStyle(obj.overlay.element, "opacity", 1);
+
+ obj.overlay.cfg.refireEvent("iframe");
+
+ obj.animateOutCompleteEvent.fire();
+ };
+
+ fade.init();
+ return fade;
+};
+
+
+/**
+* A pre-configured ContainerEffect instance that can be used for sliding an overlay in and out.
+* @param {Overlay} The Overlay object to animate
+* @param {float} The duration of the animation
+* @type ContainerEffect
+*/
+YAHOO.widget.ContainerEffect.SLIDE = function(overlay, dur) {
+ var x = overlay.cfg.getProperty("x") || YAHOO.util.Dom.getX(overlay.element);
+ var y = overlay.cfg.getProperty("y") || YAHOO.util.Dom.getY(overlay.element);
+
+ var clientWidth = YAHOO.util.Dom.getClientWidth();
+ var offsetWidth = overlay.element.offsetWidth;
+
+ var slide = new YAHOO.widget.ContainerEffect(overlay, {
+ attributes:{ points: { to:[x, y] } },
+ duration:dur,
+ method:YAHOO.util.Easing.easeIn
+ },
+ {
+ attributes:{ points: { to:[(clientWidth+25), y] } },
+ duration:dur,
+ method:YAHOO.util.Easing.easeOut
+ },
+ overlay.element,
+ YAHOO.util.Motion
+ );
+
+ slide.handleStartAnimateIn = function(type,args,obj) {
+ obj.overlay.element.style.left = (-25-offsetWidth) + "px";
+ obj.overlay.element.style.top = y + "px";
+ }
+
+ slide.handleTweenAnimateIn = function(type, args, obj) {
+
+
+ var pos = YAHOO.util.Dom.getXY(obj.overlay.element);
+
+ var currentX = pos[0];
+ var currentY = pos[1];
+
+ if (YAHOO.util.Dom.getStyle(obj.overlay.element, "visibility") == "hidden" && currentX < x) {
+ YAHOO.util.Dom.setStyle(obj.overlay.element, "visibility", "visible");
+ }
+
+ obj.overlay.cfg.setProperty("xy", [currentX,currentY], true);
+ obj.overlay.cfg.refireEvent("iframe");
+ }
+
+ slide.handleCompleteAnimateIn = function(type, args, obj) {
+ obj.overlay.cfg.setProperty("xy", [x,y], true);
+ obj.startX = x;
+ obj.startY = y;
+ obj.overlay.cfg.refireEvent("iframe");
+ obj.animateInCompleteEvent.fire();
+ }
+
+ slide.handleStartAnimateOut = function(type, args, obj) {
+ var clientWidth = YAHOO.util.Dom.getViewportWidth();
+
+ var pos = YAHOO.util.Dom.getXY(obj.overlay.element);
+
+ var x = pos[0];
+ var y = pos[1];
+
+ var currentTo = obj.animOut.attributes.points.to;
+ obj.animOut.attributes.points.to = [(clientWidth+25), y];
+ }
+
+ slide.handleTweenAnimateOut = function(type, args, obj) {
+ var pos = YAHOO.util.Dom.getXY(obj.overlay.element);
+
+ var x = pos[0];
+ var y = pos[1];
+
+ obj.overlay.cfg.setProperty("xy", [x,y], true);
+ obj.overlay.cfg.refireEvent("iframe");
+ }
+
+ slide.handleCompleteAnimateOut = function(type, args, obj) {
+ YAHOO.util.Dom.setStyle(obj.overlay.element, "visibility", "hidden");
+ var offsetWidth = obj.overlay.element.offsetWidth;
+
+ obj.overlay.cfg.setProperty("xy", [x,y]);
+ obj.animateOutCompleteEvent.fire();
+ };
+
+ slide.init();
+ return slide;
+}
\ No newline at end of file
Added: branches/tomek/portal-dnd/dndRenderer.war/js/container/container_core-debug.js
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/container/container_core-debug.js 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/container/container_core-debug.js 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,2274 @@
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+Version 0.11.1
+*/
+
+/**
+* @class
+* Config is a utility used within an object to allow the implementer to maintain a list of local configuration properties and listen for changes to those properties dynamically using CustomEvent. The initial values are also maintained so that the configuration can be reset at any given point to its initial state.
+* @param {object} owner The owner object to which this Config object belongs
+* @constructor
+*/
+YAHOO.util.Config = function(owner) {
+ if (owner) {
+ this.init(owner);
+ } else {
+ YAHOO.log("No owner specified for Config object", "error");
+ }
+}
+
+YAHOO.util.Config.prototype = {
+
+ /**
+ * Object reference to the owner of this Config object
+ * @type object
+ */
+ owner : null,
+
+ /**
+ * Object reference to the owner of this Config object
+ * args: key, value
+ * @type YAHOO.util.CustomEvent
+ */
+ configChangedEvent : null,
+
+ /**
+ * Boolean flag that specifies whether a queue is currently being executed
+ * @type boolean
+ */
+ queueInProgress : false,
+
+ /**
+ * Adds a property to the Config object's private config hash.
+ * @param {string} key The configuration property's name
+ * @param {object} propertyObject The object containing all of this property's arguments
+ */
+ addProperty : function(key, propertyObject){},
+
+ /**
+ * Returns a key-value configuration map of the values currently set in the Config object.
+ * @return {object} The current config, represented in a key-value map
+ */
+ getConfig : function(){},
+
+ /**
+ * Returns the value of specified property.
+ * @param {key} The name of the property
+ * @return {object} The value of the specified property
+ */
+ getProperty : function(key){},
+
+ /**
+ * Resets the specified property's value to its initial value.
+ * @param {key} The name of the property
+ */
+ resetProperty : function(key){},
+
+ /**
+ * Sets the value of a property. If the silent property is passed as true, the property's event will not be fired.
+ * @param {key} The name of the property
+ * @param {value} The value to set the property to
+ * @param {boolean} Whether the value should be set silently, without firing the property event.
+ * @return {boolean} true, if the set was successful, false if it failed.
+ */
+ setProperty : function(key,value,silent){},
+
+ /**
+ * Sets the value of a property and queues its event to execute. If the event is already scheduled to execute, it is
+ * moved from its current position to the end of the queue.
+ * @param {key} The name of the property
+ * @param {value} The value to set the property to
+ * @return {boolean} true, if the set was successful, false if it failed.
+ */
+ queueProperty : function(key,value){},
+
+ /**
+ * Fires the event for a property using the property's current value.
+ * @param {key} The name of the property
+ */
+ refireEvent : function(key){},
+
+ /**
+ * Applies a key-value object literal to the configuration, replacing any existing values, and queueing the property events.
+ * Although the values will be set, fireQueue() must be called for their associated events to execute.
+ * @param {object} userConfig The configuration object literal
+ * @param {boolean} init When set to true, the initialConfig will be set to the userConfig passed in, so that calling a reset will reset the properties to the passed values.
+ */
+ applyConfig : function(userConfig,init){},
+
+ /**
+ * Refires the events for all configuration properties using their current values.
+ */
+ refresh : function(){},
+
+ /**
+ * Fires the normalized list of queued property change events
+ */
+ fireQueue : function(){},
+
+ /**
+ * Subscribes an external handler to the change event for any given property.
+ * @param {string} key The property name
+ * @param {Function} handler The handler function to use subscribe to the property's event
+ * @param {object} obj The object to use for scoping the event handler (see CustomEvent documentation)
+ * @param {boolean} override Optional. If true, will override "this" within the handler to map to the scope object passed into the method.
+ */
+ subscribeToConfigEvent : function(key,handler,obj,override){},
+
+ /**
+ * Unsubscribes an external handler from the change event for any given property.
+ * @param {string} key The property name
+ * @param {Function} handler The handler function to use subscribe to the property's event
+ * @param {object} obj The object to use for scoping the event handler (see CustomEvent documentation)
+ */
+ unsubscribeFromConfigEvent: function(key,handler,obj){},
+
+ /**
+ * Validates that the value passed in is a boolean.
+ * @param {object} val The value to validate
+ * @return {boolean} true, if the value is valid
+ */
+ checkBoolean: function(val) {
+ if (typeof val == 'boolean') {
+ return true;
+ } else {
+ return false;
+ }
+ },
+
+ /**
+ * Validates that the value passed in is a number.
+ * @param {object} val The value to validate
+ * @return {boolean} true, if the value is valid
+ */
+ checkNumber: function(val) {
+ if (isNaN(val)) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+}
+
+
+/**
+* Initializes the configuration object and all of its local members.
+* @param {object} owner The owner object to which this Config object belongs
+*/
+YAHOO.util.Config.prototype.init = function(owner) {
+
+ this.owner = owner;
+ this.configChangedEvent = new YAHOO.util.CustomEvent("configChanged");
+ this.queueInProgress = false;
+
+ /* Private Members */
+
+ var config = {};
+ var initialConfig = {};
+ var eventQueue = [];
+
+ /**
+ * @private
+ * Fires a configuration property event using the specified value.
+ * @param {string} key The configuration property's name
+ * @param {value} object The value of the correct type for the property
+ */
+ var fireEvent = function( key, value ) {
+ YAHOO.log("Firing Config event: " + key + "=" + value, "info");
+
+ key = key.toLowerCase();
+
+ var property = config[key];
+
+ if (typeof property != 'undefined' && property.event) {
+ property.event.fire(value);
+ }
+ }
+ /* End Private Members */
+
+ this.addProperty = function( key, propertyObject ) {
+ key = key.toLowerCase();
+
+ YAHOO.log("Added property: " + key, "info");
+
+ config[key] = propertyObject;
+
+ propertyObject.event = new YAHOO.util.CustomEvent(key);
+ propertyObject.key = key;
+
+ if (propertyObject.handler) {
+ propertyObject.event.subscribe(propertyObject.handler, this.owner, true);
+ }
+
+ this.setProperty(key, propertyObject.value, true);
+
+ if (! propertyObject.suppressEvent) {
+ this.queueProperty(key, propertyObject.value);
+ }
+ }
+
+ this.getConfig = function() {
+ var cfg = {};
+
+ for (var prop in config) {
+ var property = config[prop]
+ if (typeof property != 'undefined' && property.event) {
+ cfg[prop] = property.value;
+ }
+ }
+
+ return cfg;
+ }
+
+ this.getProperty = function(key) {
+ key = key.toLowerCase();
+
+ var property = config[key];
+ if (typeof property != 'undefined' && property.event) {
+ return property.value;
+ } else {
+ return undefined;
+ }
+ }
+
+ this.resetProperty = function(key) {
+ key = key.toLowerCase();
+
+ var property = config[key];
+ if (typeof property != 'undefined' && property.event) {
+ this.setProperty(key, initialConfig[key].value);
+ } else {
+ return undefined;
+ }
+ }
+
+ this.setProperty = function(key, value, silent) {
+ key = key.toLowerCase();
+
+ YAHOO.log("setProperty: " + key + "=" + value, "info");
+
+ if (this.queueInProgress && ! silent) {
+ this.queueProperty(key,value); // Currently running through a queue...
+ return true;
+ } else {
+ var property = config[key];
+ if (typeof property != 'undefined' && property.event) {
+ if (property.validator && ! property.validator(value)) { // validator
+ return false;
+ } else {
+ property.value = value;
+ if (! silent) {
+ fireEvent(key, value);
+ this.configChangedEvent.fire([key, value]);
+ }
+ return true;
+ }
+ } else {
+ return false;
+ }
+ }
+ }
+
+ this.queueProperty = function(key, value) {
+ key = key.toLowerCase();
+
+ YAHOO.log("queueProperty: " + key + "=" + value, "info");
+
+ var property = config[key];
+
+ if (typeof property != 'undefined' && property.event) {
+ if (typeof value != 'undefined' && property.validator && ! property.validator(value)) { // validator
+ return false;
+ } else {
+
+ if (typeof value != 'undefined') {
+ property.value = value;
+ } else {
+ value = property.value;
+ }
+
+ var foundDuplicate = false;
+
+ for (var i=0;i<eventQueue.length;i++) {
+ var queueItem = eventQueue[i];
+
+ if (queueItem) {
+ var queueItemKey = queueItem[0];
+ var queueItemValue = queueItem[1];
+
+ if (queueItemKey.toLowerCase() == key) {
+ // found a dupe... push to end of queue, null current item, and break
+ eventQueue[i] = null;
+ eventQueue.push([key, (typeof value != 'undefined' ? value : queueItemValue)]);
+ foundDuplicate = true;
+ break;
+ }
+ }
+ }
+
+ if (! foundDuplicate && typeof value != 'undefined') { // this is a refire, or a new property in the queue
+ eventQueue.push([key, value]);
+ }
+ }
+
+ if (property.supercedes) {
+ for (var s=0;s<property.supercedes.length;s++) {
+ var supercedesCheck = property.supercedes[s];
+
+ for (var q=0;q<eventQueue.length;q++) {
+ var queueItemCheck = eventQueue[q];
+
+ if (queueItemCheck) {
+ var queueItemCheckKey = queueItemCheck[0];
+ var queueItemCheckValue = queueItemCheck[1];
+
+ if ( queueItemCheckKey.toLowerCase() == supercedesCheck.toLowerCase() ) {
+ eventQueue.push([queueItemCheckKey, queueItemCheckValue]);
+ eventQueue[q] = null;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ YAHOO.log("Config event queue: " + this.outputEventQueue(), "info");
+
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ this.refireEvent = function(key) {
+ key = key.toLowerCase();
+
+ var property = config[key];
+ if (typeof property != 'undefined' && property.event && typeof property.value != 'undefined') {
+ if (this.queueInProgress) {
+ this.queueProperty(key);
+ } else {
+ fireEvent(key, property.value);
+ }
+ }
+ }
+
+ this.applyConfig = function(userConfig, init) {
+ if (init) {
+ initialConfig = userConfig;
+ }
+ for (var prop in userConfig) {
+ this.queueProperty(prop, userConfig[prop]);
+ }
+ }
+
+ this.refresh = function() {
+ for (var prop in config) {
+ this.refireEvent(prop);
+ }
+ }
+
+ this.fireQueue = function() {
+ this.queueInProgress = true;
+ for (var i=0;i<eventQueue.length;i++) {
+ var queueItem = eventQueue[i];
+ if (queueItem) {
+ var key = queueItem[0];
+ var value = queueItem[1];
+
+ var property = config[key];
+ property.value = value;
+
+ fireEvent(key,value);
+ }
+ }
+
+ this.queueInProgress = false;
+ eventQueue = new Array();
+ }
+
+ this.subscribeToConfigEvent = function(key, handler, obj, override) {
+ key = key.toLowerCase();
+
+ var property = config[key];
+ if (typeof property != 'undefined' && property.event) {
+ if (! YAHOO.util.Config.alreadySubscribed(property.event, handler, obj)) {
+ property.event.subscribe(handler, obj, override);
+ }
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+
+ this.unsubscribeFromConfigEvent = function(key, handler, obj) {
+ key = key.toLowerCase();
+
+ var property = config[key];
+ if (typeof property != 'undefined' && property.event) {
+ return property.event.unsubscribe(handler, obj);
+ } else {
+ return false;
+ }
+ }
+
+ this.toString = function() {
+ var output = "Config";
+ if (this.owner) {
+ output += " [" + this.owner.toString() + "]";
+ }
+ return output;
+ }
+
+ this.outputEventQueue = function() {
+ var output = "";
+ for (var q=0;q<eventQueue.length;q++) {
+ var queueItem = eventQueue[q];
+ if (queueItem) {
+ output += queueItem[0] + "=" + queueItem[1] + ", ";
+ }
+ }
+ return output;
+ }
+}
+
+/**
+* Checks to determine if a particular function/object pair are already subscribed to the specified CustomEvent
+* @param {YAHOO.util.CustomEvent} evt The CustomEvent for which to check the subscriptions
+* @param {Function} fn The function to look for in the subscribers list
+* @param {object} obj The execution scope object for the subscription
+* @return {boolean} true, if the function/object pair is already subscribed to the CustomEvent passed in
+*/
+YAHOO.util.Config.alreadySubscribed = function(evt, fn, obj) {
+ for (var e=0;e<evt.subscribers.length;e++) {
+ var subsc = evt.subscribers[e];
+ if (subsc && subsc.obj == obj && subsc.fn == fn) {
+ return true;
+ break;
+ }
+ }
+ return false;
+}
+
+/**
+* @class
+* Module is a JavaScript representation of the Standard Module Format. Standard Module Format is a simple standard for markup containers where child nodes representing the header, body, and footer of the content are denoted using the CSS classes "hd", "bd", and "ft" respectively. Module is the base class for all other classes in the YUI Container package.
+* @param {string} el The element ID representing the Module <em>OR</em>
+* @param {Element} el The element representing the Module
+* @param {object} userConfig The configuration object literal containing the configuration that should be set for this module. See configuration documentation for more details.
+* @constructor
+*/
+YAHOO.widget.Module = function(el, userConfig) {
+ if (el) {
+ this.init(el, userConfig);
+ } else {
+ YAHOO.log("No element or element ID specified for Module instantiation", "error");
+ }
+}
+
+/**
+* Constant representing the prefix path to use for non-secure images
+* @type string
+*/
+YAHOO.widget.Module.IMG_ROOT = "http://us.i1.yimg.com/us.yimg.com/i/";
+
+/**
+* Constant representing the prefix path to use for securely served images
+* @type string
+*/
+YAHOO.widget.Module.IMG_ROOT_SSL = "https://a248.e.akamai.net/sec.yimg.com/i/";
+
+/**
+* Constant for the default CSS class name that represents a Module
+* @type string
+* @final
+*/
+YAHOO.widget.Module.CSS_MODULE = "module";
+
+/**
+* Constant representing the module header
+* @type string
+* @final
+*/
+YAHOO.widget.Module.CSS_HEADER = "hd";
+
+/**
+* Constant representing the module body
+* @type string
+* @final
+*/
+YAHOO.widget.Module.CSS_BODY = "bd";
+
+/**
+* Constant representing the module footer
+* @type string
+* @final
+*/
+YAHOO.widget.Module.CSS_FOOTER = "ft";
+
+/**
+* Constant representing the url for the "src" attribute of the iframe used to monitor changes to the browser's base font size
+* @type string
+* @final
+*/
+YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL = null;
+
+YAHOO.widget.Module.prototype = {
+
+ /**
+ * The class's constructor function
+ * @type function
+ */
+ constructor : YAHOO.widget.Module,
+
+ /**
+ * The main module element that contains the header, body, and footer
+ * @type Element
+ */
+ element : null,
+
+ /**
+ * The header element, denoted with CSS class "hd"
+ * @type Element
+ */
+ header : null,
+
+ /**
+ * The body element, denoted with CSS class "bd"
+ * @type Element
+ */
+ body : null,
+
+ /**
+ * The footer element, denoted with CSS class "ft"
+ * @type Element
+ */
+ footer : null,
+
+ /**
+ * The id of the element
+ * @type string
+ */
+ id : null,
+
+ /**
+ * Array of elements
+ * @type Element[]
+ */
+ childNodesInDOM : null,
+
+ /**
+ * The string representing the image root
+ * @type string
+ */
+ imageRoot : YAHOO.widget.Module.IMG_ROOT,
+
+ /**
+ * CustomEvent fired prior to class initalization.
+ * args: class reference of the initializing class, such as this.beforeInitEvent.fire(YAHOO.widget.Module)
+ * @type YAHOO.util.CustomEvent
+ */
+ beforeInitEvent : null,
+
+ /**
+ * CustomEvent fired after class initalization.
+ * args: class reference of the initializing class, such as this.initEvent.fire(YAHOO.widget.Module)
+ * @type YAHOO.util.CustomEvent
+ */
+ initEvent : null,
+
+ /**
+ * CustomEvent fired when the Module is appended to the DOM
+ * args: none
+ * @type YAHOO.util.CustomEvent
+ */
+ appendEvent : null,
+
+ /**
+ * CustomEvent fired before the Module is rendered
+ * args: none
+ * @type YAHOO.util.CustomEvent
+ */
+ beforeRenderEvent : null,
+
+ /**
+ * CustomEvent fired after the Module is rendered
+ * args: none
+ * @type YAHOO.util.CustomEvent
+ */
+ renderEvent : null,
+
+ /**
+ * CustomEvent fired when the header content of the Module is modified
+ * args: string/element representing the new header content
+ * @type YAHOO.util.CustomEvent
+ */
+ changeHeaderEvent : null,
+
+ /**
+ * CustomEvent fired when the body content of the Module is modified
+ * args: string/element representing the new body content
+ * @type YAHOO.util.CustomEvent
+ */
+ changeBodyEvent : null,
+
+ /**
+ * CustomEvent fired when the footer content of the Module is modified
+ * args: string/element representing the new footer content
+ * @type YAHOO.util.CustomEvent
+ */
+ changeFooterEvent : null,
+
+ /**
+ * CustomEvent fired when the content of the Module is modified
+ * args: none
+ * @type YAHOO.util.CustomEvent
+ */
+ changeContentEvent : null,
+
+ /**
+ * CustomEvent fired when the Module is destroyed
+ * args: none
+ * @type YAHOO.util.CustomEvent
+ */
+ destroyEvent : null,
+
+ /**
+ * CustomEvent fired before the Module is shown
+ * args: none
+ * @type YAHOO.util.CustomEvent
+ */
+ beforeShowEvent : null,
+
+ /**
+ * CustomEvent fired after the Module is shown
+ * args: none
+ * @type YAHOO.util.CustomEvent
+ */
+ showEvent : null,
+
+ /**
+ * CustomEvent fired before the Module is hidden
+ * args: none
+ * @type YAHOO.util.CustomEvent
+ */
+ beforeHideEvent : null,
+
+ /**
+ * CustomEvent fired after the Module is hidden
+ * args: none
+ * @type YAHOO.util.CustomEvent
+ */
+ hideEvent : null,
+
+ /**
+ * Initializes the custom events for Module which are fired automatically at appropriate times by the Module class.
+ */
+ initEvents : function() {
+
+ this.beforeInitEvent = new YAHOO.util.CustomEvent("beforeInit");
+ this.initEvent = new YAHOO.util.CustomEvent("init");
+
+ this.appendEvent = new YAHOO.util.CustomEvent("append");
+
+ this.beforeRenderEvent = new YAHOO.util.CustomEvent("beforeRender");
+ this.renderEvent = new YAHOO.util.CustomEvent("render");
+
+ this.changeHeaderEvent = new YAHOO.util.CustomEvent("changeHeader");
+ this.changeBodyEvent = new YAHOO.util.CustomEvent("changeBody");
+ this.changeFooterEvent = new YAHOO.util.CustomEvent("changeFooter");
+
+ this.changeContentEvent = new YAHOO.util.CustomEvent("changeContent");
+
+ this.destroyEvent = new YAHOO.util.CustomEvent("destroy");
+ this.beforeShowEvent = new YAHOO.util.CustomEvent("beforeShow");
+ this.showEvent = new YAHOO.util.CustomEvent("show");
+ this.beforeHideEvent = new YAHOO.util.CustomEvent("beforeHide");
+ this.hideEvent = new YAHOO.util.CustomEvent("hide");
+ },
+
+ /**
+ * String representing the current user-agent platform
+ * @type string
+ */
+ platform : function() {
+ var ua = navigator.userAgent.toLowerCase();
+ if (ua.indexOf("windows") != -1 || ua.indexOf("win32") != -1) {
+ return "windows";
+ } else if (ua.indexOf("macintosh") != -1) {
+ return "mac";
+ } else {
+ return false;
+ }
+ }(),
+
+ /**
+ * String representing the current user-agent browser
+ * @type string
+ */
+ browser : function() {
+ var ua = navigator.userAgent.toLowerCase();
+ if (ua.indexOf('opera')!=-1) { // Opera (check first in case of spoof)
+ return 'opera';
+ } else if (ua.indexOf('msie 7')!=-1) { // IE7
+ return 'ie7';
+ } else if (ua.indexOf('msie') !=-1) { // IE
+ return 'ie';
+ } else if (ua.indexOf('safari')!=-1) { // Safari (check before Gecko because it includes "like Gecko")
+ return 'safari';
+ } else if (ua.indexOf('gecko') != -1) { // Gecko
+ return 'gecko';
+ } else {
+ return false;
+ }
+ }(),
+
+ /**
+ * Boolean representing whether or not the current browsing context is secure (https)
+ * @type boolean
+ */
+ isSecure : function() {
+ if (window.location.href.toLowerCase().indexOf("https") == 0) {
+ return true;
+ } else {
+ return false;
+ }
+ }(),
+
+ /**
+ * Initializes the custom events for Module which are fired automatically at appropriate times by the Module class.
+ */
+ initDefaultConfig : function() {
+ // Add properties //
+
+ this.cfg.addProperty("visible", { value:true, handler:this.configVisible, validator:this.cfg.checkBoolean } );
+ this.cfg.addProperty("effect", { suppressEvent:true, supercedes:["visible"] } );
+ this.cfg.addProperty("monitorresize", { value:true, handler:this.configMonitorResize } );
+ },
+
+ /**
+ * The Module class's initialization method, which is executed for Module and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present.
+ * @param {string} el The element ID representing the Module <em>OR</em>
+ * @param {Element} el The element representing the Module
+ * @param {object} userConfig The configuration object literal containing the configuration that should be set for this module. See configuration documentation for more details.
+ */
+ init : function(el, userConfig) {
+
+ this.initEvents();
+
+ this.beforeInitEvent.fire(YAHOO.widget.Module);
+
+ this.cfg = new YAHOO.util.Config(this);
+
+ if (this.isSecure) {
+ this.imageRoot = YAHOO.widget.Module.IMG_ROOT_SSL;
+ }
+
+ if (typeof el == "string") {
+ var elId = el;
+
+ el = document.getElementById(el);
+ if (! el) {
+ el = document.createElement("DIV");
+ el.id = elId;
+ }
+ }
+
+ this.element = el;
+
+ if (el.id) {
+ this.id = el.id;
+ }
+
+ var childNodes = this.element.childNodes;
+
+ if (childNodes) {
+ for (var i=0;i<childNodes.length;i++) {
+ var child = childNodes[i];
+ switch (child.className) {
+ case YAHOO.widget.Module.CSS_HEADER:
+ this.header = child;
+ break;
+ case YAHOO.widget.Module.CSS_BODY:
+ this.body = child;
+ break;
+ case YAHOO.widget.Module.CSS_FOOTER:
+ this.footer = child;
+ break;
+ }
+ }
+ }
+
+ this.initDefaultConfig();
+
+ YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Module.CSS_MODULE);
+
+ if (userConfig) {
+ this.cfg.applyConfig(userConfig, true);
+ }
+
+ // Subscribe to the fireQueue() method of Config so that any queued configuration changes are
+ // excecuted upon render of the Module
+ if (! YAHOO.util.Config.alreadySubscribed(this.renderEvent, this.cfg.fireQueue, this.cfg)) {
+ this.renderEvent.subscribe(this.cfg.fireQueue, this.cfg, true);
+ }
+
+ this.initEvent.fire(YAHOO.widget.Module);
+ },
+
+ /**
+ * Initialized an empty DOM element that is placed out of the visible area that can be used to detect text resize.
+ */
+ initResizeMonitor : function() {
+
+ if(this.browser != "opera") {
+
+ var resizeMonitor = document.getElementById("_yuiResizeMonitor");
+
+ if (! resizeMonitor) {
+
+ resizeMonitor = document.createElement("iframe");
+
+ var bIE = (this.browser.indexOf("ie") === 0);
+
+ if(this.isSecure && this.RESIZE_MONITOR_SECURE_URL && bIE) {
+
+ resizeMonitor.src = this.RESIZE_MONITOR_SECURE_URL;
+
+ }
+
+ resizeMonitor.id = "_yuiResizeMonitor";
+ resizeMonitor.style.visibility = "hidden";
+
+ document.body.appendChild(resizeMonitor);
+
+ resizeMonitor.style.width = "10em";
+ resizeMonitor.style.height = "10em";
+ resizeMonitor.style.position = "absolute";
+
+ var nLeft = -1 * resizeMonitor.offsetWidth,
+ nTop = -1 * resizeMonitor.offsetHeight;
+
+ resizeMonitor.style.top = nTop + "px";
+ resizeMonitor.style.left = nLeft + "px";
+ resizeMonitor.style.borderStyle = "none";
+ resizeMonitor.style.borderWidth = "0";
+ YAHOO.util.Dom.setStyle(resizeMonitor, "opacity", "0");
+
+ resizeMonitor.style.visibility = "visible";
+
+ if(!bIE) {
+
+ var doc = resizeMonitor.contentWindow.document;
+
+ doc.open();
+ doc.close();
+
+ }
+
+ }
+
+ if(resizeMonitor && resizeMonitor.contentWindow) {
+
+ this.resizeMonitor = resizeMonitor;
+
+ YAHOO.util.Event.addListener(this.resizeMonitor.contentWindow, "resize", this.onDomResize, this, true);
+
+ }
+
+ }
+
+ },
+
+ /**
+ * Event handler fired when the resize monitor element is resized.
+ */
+ onDomResize : function(e, obj) {
+
+ var nLeft = -1 * this.resizeMonitor.offsetWidth,
+ nTop = -1 * this.resizeMonitor.offsetHeight;
+
+ this.resizeMonitor.style.top = nTop + "px";
+ this.resizeMonitor.style.left = nLeft + "px";
+
+ },
+
+ /**
+ * Sets the Module's header content to the HTML specified, or appends the passed element to the header. If no header is present, one will be automatically created.
+ * @param {string} headerContent The HTML used to set the header <em>OR</em>
+ * @param {Element} headerContent The Element to append to the header
+ */
+ setHeader : function(headerContent) {
+ if (! this.header) {
+ this.header = document.createElement("DIV");
+ this.header.className = YAHOO.widget.Module.CSS_HEADER;
+ }
+
+ if (typeof headerContent == "string") {
+ this.header.innerHTML = headerContent;
+ } else {
+ this.header.innerHTML = "";
+ this.header.appendChild(headerContent);
+ }
+
+ this.changeHeaderEvent.fire(headerContent);
+ this.changeContentEvent.fire();
+ },
+
+ /**
+ * Appends the passed element to the header. If no header is present, one will be automatically created.
+ * @param {Element} element The element to append to the header
+ */
+ appendToHeader : function(element) {
+ if (! this.header) {
+ this.header = document.createElement("DIV");
+ this.header.className = YAHOO.widget.Module.CSS_HEADER;
+ }
+
+ this.header.appendChild(element);
+ this.changeHeaderEvent.fire(element);
+ this.changeContentEvent.fire();
+ },
+
+ /**
+ * Sets the Module's body content to the HTML specified, or appends the passed element to the body. If no body is present, one will be automatically created.
+ * @param {string} bodyContent The HTML used to set the body <em>OR</em>
+ * @param {Element} bodyContent The Element to append to the body
+ */
+ setBody : function(bodyContent) {
+ if (! this.body) {
+ this.body = document.createElement("DIV");
+ this.body.className = YAHOO.widget.Module.CSS_BODY;
+ }
+
+ if (typeof bodyContent == "string")
+ {
+ this.body.innerHTML = bodyContent;
+ } else {
+ this.body.innerHTML = "";
+ this.body.appendChild(bodyContent);
+ }
+
+ this.changeBodyEvent.fire(bodyContent);
+ this.changeContentEvent.fire();
+ },
+
+ /**
+ * Appends the passed element to the body. If no body is present, one will be automatically created.
+ * @param {Element} element The element to append to the body
+ */
+ appendToBody : function(element) {
+ if (! this.body) {
+ this.body = document.createElement("DIV");
+ this.body.className = YAHOO.widget.Module.CSS_BODY;
+ }
+
+ this.body.appendChild(element);
+ this.changeBodyEvent.fire(element);
+ this.changeContentEvent.fire();
+ },
+
+ /**
+ * Sets the Module's footer content to the HTML specified, or appends the passed element to the footer. If no footer is present, one will be automatically created.
+ * @param {string} footerContent The HTML used to set the footer <em>OR</em>
+ * @param {Element} footerContent The Element to append to the footer
+ */
+ setFooter : function(footerContent) {
+ if (! this.footer) {
+ this.footer = document.createElement("DIV");
+ this.footer.className = YAHOO.widget.Module.CSS_FOOTER;
+ }
+
+ if (typeof footerContent == "string") {
+ this.footer.innerHTML = footerContent;
+ } else {
+ this.footer.innerHTML = "";
+ this.footer.appendChild(footerContent);
+ }
+
+ this.changeFooterEvent.fire(footerContent);
+ this.changeContentEvent.fire();
+ },
+
+ /**
+ * Appends the passed element to the footer. If no footer is present, one will be automatically created.
+ * @param {Element} element The element to append to the footer
+ */
+ appendToFooter : function(element) {
+ if (! this.footer) {
+ this.footer = document.createElement("DIV");
+ this.footer.className = YAHOO.widget.Module.CSS_FOOTER;
+ }
+
+ this.footer.appendChild(element);
+ this.changeFooterEvent.fire(element);
+ this.changeContentEvent.fire();
+ },
+
+ /**
+ * Renders the Module by inserting the elements that are not already in the main Module into their correct places. Optionally appends the Module to the specified node prior to the render's execution. NOTE: For Modules without existing markup, the appendToNode argument is REQUIRED. If this argument is ommitted and the current element is not present in the document, the function will return false, indicating that the render was a failure.
+ * @param {string} appendToNode The element id to which the Module should be appended to prior to rendering <em>OR</em>
+ * @param {Element} appendToNode The element to which the Module should be appended to prior to rendering
+ * @param {Element} moduleElement OPTIONAL. The element that represents the actual Standard Module container.
+ * @return {boolean} Success or failure of the render
+ */
+ render : function(appendToNode, moduleElement) {
+ this.beforeRenderEvent.fire();
+
+ if (! moduleElement) {
+ moduleElement = this.element;
+ }
+
+ var me = this;
+ var appendTo = function(element) {
+ if (typeof element == "string") {
+ element = document.getElementById(element);
+ }
+
+ if (element) {
+ element.appendChild(me.element);
+ me.appendEvent.fire();
+ }
+ }
+
+ if (appendToNode) {
+ appendTo(appendToNode);
+ } else { // No node was passed in. If the element is not pre-marked up, this fails
+ if (! YAHOO.util.Dom.inDocument(this.element)) {
+ YAHOO.log("Render failed. Must specify appendTo node if Module isn't already in the DOM.", "error");
+ return false;
+ }
+ }
+
+ // Need to get everything into the DOM if it isn't already
+
+ if (this.header && ! YAHOO.util.Dom.inDocument(this.header)) {
+ // There is a header, but it's not in the DOM yet... need to add it
+ var firstChild = moduleElement.firstChild;
+ if (firstChild) { // Insert before first child if exists
+ moduleElement.insertBefore(this.header, firstChild);
+ } else { // Append to empty body because there are no children
+ moduleElement.appendChild(this.header);
+ }
+ }
+
+ if (this.body && ! YAHOO.util.Dom.inDocument(this.body)) {
+ // There is a body, but it's not in the DOM yet... need to add it
+ if (this.footer && YAHOO.util.Dom.isAncestor(this.moduleElement, this.footer)) { // Insert before footer if exists in DOM
+ moduleElement.insertBefore(this.body, this.footer);
+ } else { // Append to element because there is no footer
+ moduleElement.appendChild(this.body);
+ }
+ }
+
+ if (this.footer && ! YAHOO.util.Dom.inDocument(this.footer)) {
+ // There is a footer, but it's not in the DOM yet... need to add it
+ moduleElement.appendChild(this.footer);
+ }
+
+ this.renderEvent.fire();
+ return true;
+ },
+
+ /**
+ * Removes the Module element from the DOM and sets all child elements to null.
+ */
+ destroy : function() {
+ if (this.element) {
+ var parent = this.element.parentNode;
+ }
+ if (parent) {
+ parent.removeChild(this.element);
+ }
+
+ this.element = null;
+ this.header = null;
+ this.body = null;
+ this.footer = null;
+
+ this.destroyEvent.fire();
+ },
+
+ /**
+ * Shows the Module element by setting the visible configuration property to true. Also fires two events: beforeShowEvent prior to the visibility change, and showEvent after.
+ */
+ show : function() {
+ this.cfg.setProperty("visible", true);
+ },
+
+ /**
+ * Hides the Module element by setting the visible configuration property to false. Also fires two events: beforeHideEvent prior to the visibility change, and hideEvent after.
+ */
+ hide : function() {
+ this.cfg.setProperty("visible", false);
+ },
+
+ // BUILT-IN EVENT HANDLERS FOR MODULE //
+
+ /**
+ * Default event handler for changing the visibility property of a Module. By default, this is achieved by switching the "display" style between "block" and "none".
+ * This method is responsible for firing showEvent and hideEvent.
+ */
+ configVisible : function(type, args, obj) {
+ var visible = args[0];
+ if (visible) {
+ this.beforeShowEvent.fire();
+ YAHOO.util.Dom.setStyle(this.element, "display", "block");
+ this.showEvent.fire();
+ } else {
+ this.beforeHideEvent.fire();
+ YAHOO.util.Dom.setStyle(this.element, "display", "none");
+ this.hideEvent.fire();
+ }
+ },
+
+ /**
+ * Default event handler for the "monitorresize" configuration property
+ */
+ configMonitorResize : function(type, args, obj) {
+ var monitor = args[0];
+ if (monitor) {
+ this.initResizeMonitor();
+ } else {
+ YAHOO.util.Event.removeListener(this.resizeMonitor, "resize", this.onDomResize);
+ this.resizeMonitor = null;
+ }
+ }
+}
+
+/**
+* Returns a string representation of the object.
+* @type string
+*/
+YAHOO.widget.Module.prototype.toString = function() {
+ return "Module " + this.id;
+}
+
+/**
+* @class Overlay is a Module that is absolutely positioned above the page flow. It has convenience methods for positioning and sizing, as well as options for controlling zIndex and constraining the Overlay's position to the current visible viewport. Overlay also contains a dynamicly generated IFRAME which is placed beneath it for Internet Explorer 6 and 5.x so that it will be properly rendered above SELECT elements.
+* @param {string} el The element ID representing the Overlay <em>OR</em>
+* @param {Element} el The element representing the Overlay
+* @param {object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details.
+* @constructor
+*/
+YAHOO.widget.Overlay = function(el, userConfig) {
+ YAHOO.widget.Overlay.superclass.constructor.call(this, el, userConfig);
+}
+
+YAHOO.extend(YAHOO.widget.Overlay, YAHOO.widget.Module);
+
+/**
+* The URL of the blank image that will be placed in the iframe
+* @type string
+* @final
+*/
+YAHOO.widget.Overlay.IFRAME_SRC = "promo/m/irs/blank.gif";
+
+/**
+* Constant representing the top left corner of an element, used for configuring the context element alignment
+* @type string
+* @final
+*/
+YAHOO.widget.Overlay.TOP_LEFT = "tl";
+
+/**
+* Constant representing the top right corner of an element, used for configuring the context element alignment
+* @type string
+* @final
+*/
+YAHOO.widget.Overlay.TOP_RIGHT = "tr";
+
+/**
+* Constant representing the top bottom left corner of an element, used for configuring the context element alignment
+* @type string
+* @final
+*/
+YAHOO.widget.Overlay.BOTTOM_LEFT = "bl";
+
+/**
+* Constant representing the bottom right corner of an element, used for configuring the context element alignment
+* @type string
+* @final
+*/
+YAHOO.widget.Overlay.BOTTOM_RIGHT = "br";
+
+/**
+* Constant representing the default CSS class used for an Overlay
+* @type string
+* @final
+*/
+YAHOO.widget.Overlay.CSS_OVERLAY = "overlay";
+
+/**
+* CustomEvent fired before the Overlay is moved.
+* args: x,y that the Overlay will be moved to
+* @type YAHOO.util.CustomEvent
+*/
+YAHOO.widget.Overlay.prototype.beforeMoveEvent = null;
+
+/**
+* CustomEvent fired after the Overlay is moved.
+* args: x,y that the Overlay was moved to
+* @type YAHOO.util.CustomEvent
+*/
+YAHOO.widget.Overlay.prototype.moveEvent = null;
+
+/**
+* The Overlay initialization method, which is executed for Overlay and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present.
+* @param {string} el The element ID representing the Overlay <em>OR</em>
+* @param {Element} el The element representing the Overlay
+* @param {object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details.
+*/
+YAHOO.widget.Overlay.prototype.init = function(el, userConfig) {
+ YAHOO.widget.Overlay.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level
+
+ this.beforeInitEvent.fire(YAHOO.widget.Overlay);
+
+ YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Overlay.CSS_OVERLAY);
+
+ if (userConfig) {
+ this.cfg.applyConfig(userConfig, true);
+ }
+
+ if (this.platform == "mac" && this.browser == "gecko") {
+ if (! YAHOO.util.Config.alreadySubscribed(this.showEvent,this.showMacGeckoScrollbars,this)) {
+ this.showEvent.subscribe(this.showMacGeckoScrollbars,this,true);
+ }
+ if (! YAHOO.util.Config.alreadySubscribed(this.hideEvent,this.hideMacGeckoScrollbars,this)) {
+ this.hideEvent.subscribe(this.hideMacGeckoScrollbars,this,true);
+ }
+ }
+
+ this.initEvent.fire(YAHOO.widget.Overlay);
+
+}
+
+/**
+* Initializes the custom events for Overlay which are fired automatically at appropriate times by the Overlay class.
+*/
+YAHOO.widget.Overlay.prototype.initEvents = function() {
+ YAHOO.widget.Overlay.superclass.initEvents.call(this);
+
+ this.beforeMoveEvent = new YAHOO.util.CustomEvent("beforeMove", this);
+ this.moveEvent = new YAHOO.util.CustomEvent("move", this);
+}
+
+/**
+* Initializes the class's configurable properties which can be changed using the Overlay's Config object (cfg).
+*/
+YAHOO.widget.Overlay.prototype.initDefaultConfig = function() {
+ YAHOO.widget.Overlay.superclass.initDefaultConfig.call(this);
+
+ // Add overlay config properties //
+ this.cfg.addProperty("x", { handler:this.configX, validator:this.cfg.checkNumber, suppressEvent:true, supercedes:["iframe"] } );
+ this.cfg.addProperty("y", { handler:this.configY, validator:this.cfg.checkNumber, suppressEvent:true, supercedes:["iframe"] } );
+ this.cfg.addProperty("xy",{ handler:this.configXY, suppressEvent:true, supercedes:["iframe"] } );
+
+ this.cfg.addProperty("context", { handler:this.configContext, suppressEvent:true, supercedes:["iframe"] } );
+ this.cfg.addProperty("fixedcenter", { value:false, handler:this.configFixedCenter, validator:this.cfg.checkBoolean, supercedes:["iframe","visible"] } );
+
+ this.cfg.addProperty("width", { handler:this.configWidth, suppressEvent:true, supercedes:["iframe"] } );
+ this.cfg.addProperty("height", { handler:this.configHeight, suppressEvent:true, supercedes:["iframe"] } );
+
+ this.cfg.addProperty("zIndex", { value:null, handler:this.configzIndex } );
+
+ this.cfg.addProperty("constraintoviewport", { value:false, handler:this.configConstrainToViewport, validator:this.cfg.checkBoolean, supercedes:["iframe","x","y","xy"] } );
+ this.cfg.addProperty("iframe", { value:(this.browser == "ie" ? true : false), handler:this.configIframe, validator:this.cfg.checkBoolean, supercedes:["zIndex"] } );
+}
+
+/**
+* Moves the Overlay to the specified position. This function is identical to calling this.cfg.setProperty("xy", [x,y]);
+* @param {int} x The Overlay's new x position
+* @param {int} y The Overlay's new y position
+*/
+YAHOO.widget.Overlay.prototype.moveTo = function(x, y) {
+ this.cfg.setProperty("xy",[x,y]);
+}
+
+/**
+* Adds a special CSS class to the Overlay when Mac/Gecko is in use, to work around a Gecko bug where
+* scrollbars cannot be hidden. See https://bugzilla.mozilla.org/show_bug.cgi?id=187435
+*/
+YAHOO.widget.Overlay.prototype.hideMacGeckoScrollbars = function() {
+ YAHOO.util.Dom.removeClass(this.element, "show-scrollbars");
+ YAHOO.util.Dom.addClass(this.element, "hide-scrollbars");
+}
+
+/**
+* Removes a special CSS class from the Overlay when Mac/Gecko is in use, to work around a Gecko bug where
+* scrollbars cannot be hidden. See https://bugzilla.mozilla.org/show_bug.cgi?id=187435
+*/
+YAHOO.widget.Overlay.prototype.showMacGeckoScrollbars = function() {
+ YAHOO.util.Dom.removeClass(this.element, "hide-scrollbars");
+ YAHOO.util.Dom.addClass(this.element, "show-scrollbars");
+}
+
+// BEGIN BUILT-IN PROPERTY EVENT HANDLERS //
+
+/**
+* The default event handler fired when the "visible" property is changed. This method is responsible for firing showEvent and hideEvent.
+*/
+YAHOO.widget.Overlay.prototype.configVisible = function(type, args, obj) {
+ var visible = args[0];
+ var currentVis = YAHOO.util.Dom.getStyle(this.element, "visibility");
+
+ var effect = this.cfg.getProperty("effect");
+
+ var effectInstances = new Array();
+ if (effect) {
+ if (effect instanceof Array) {
+ for (var i=0;i<effect.length;i++) {
+ var eff = effect[i];
+ effectInstances[effectInstances.length] = eff.effect(this, eff.duration);
+ }
+ } else {
+ effectInstances[effectInstances.length] = effect.effect(this, effect.duration);
+ }
+ }
+
+ var isMacGecko = (this.platform == "mac" && this.browser == "gecko");
+
+ if (visible) { // Show
+ if (isMacGecko) {
+ this.showMacGeckoScrollbars();
+ }
+
+ if (effect) { // Animate in
+ if (visible) { // Animate in if not showing
+ if (currentVis != "visible") {
+ this.beforeShowEvent.fire();
+ for (var i=0;i<effectInstances.length;i++) {
+ var e = effectInstances[i];
+ if (i == 0 && ! YAHOO.util.Config.alreadySubscribed(e.animateInCompleteEvent,this.showEvent.fire,this.showEvent)) {
+ e.animateInCompleteEvent.subscribe(this.showEvent.fire,this.showEvent,true); // Delegate showEvent until end of animateInComplete
+ }
+ e.animateIn();
+ }
+ }
+ }
+ } else { // Show
+ if (currentVis != "visible") {
+ this.beforeShowEvent.fire();
+ YAHOO.util.Dom.setStyle(this.element, "visibility", "visible");
+ this.cfg.refireEvent("iframe");
+ this.showEvent.fire();
+ }
+ }
+
+ } else { // Hide
+ if (isMacGecko) {
+ this.hideMacGeckoScrollbars();
+ }
+
+ if (effect) { // Animate out if showing
+ if (currentVis == "visible") {
+ this.beforeHideEvent.fire();
+ for (var i=0;i<effectInstances.length;i++) {
+ var e = effectInstances[i];
+ if (i == 0 && ! YAHOO.util.Config.alreadySubscribed(e.animateOutCompleteEvent,this.hideEvent.fire,this.hideEvent)) {
+ e.animateOutCompleteEvent.subscribe(this.hideEvent.fire,this.hideEvent,true); // Delegate hideEvent until end of animateOutComplete
+ }
+ e.animateOut();
+ }
+ }
+ } else { // Simple hide
+ if (currentVis == "visible") {
+ this.beforeHideEvent.fire();
+ YAHOO.util.Dom.setStyle(this.element, "visibility", "hidden");
+ this.cfg.refireEvent("iframe");
+ this.hideEvent.fire();
+ }
+ }
+ }
+}
+
+/**
+* Center event handler used for centering on scroll/resize, but only if the Overlay is visible
+*/
+YAHOO.widget.Overlay.prototype.doCenterOnDOMEvent = function() {
+ if (this.cfg.getProperty("visible")) {
+ this.center();
+ }
+}
+
+/**
+* The default event handler fired when the "fixedcenter" property is changed.
+*/
+YAHOO.widget.Overlay.prototype.configFixedCenter = function(type, args, obj) {
+ var val = args[0];
+
+ if (val) {
+ this.center();
+
+ if (! YAHOO.util.Config.alreadySubscribed(this.beforeShowEvent, this.center, this)) {
+ this.beforeShowEvent.subscribe(this.center, this, true);
+ }
+
+ if (! YAHOO.util.Config.alreadySubscribed(YAHOO.widget.Overlay.windowResizeEvent, this.doCenterOnDOMEvent, this)) {
+ YAHOO.widget.Overlay.windowResizeEvent.subscribe(this.doCenterOnDOMEvent, this, true);
+ }
+
+ if (! YAHOO.util.Config.alreadySubscribed(YAHOO.widget.Overlay.windowScrollEvent, this.doCenterOnDOMEvent, this)) {
+ YAHOO.widget.Overlay.windowScrollEvent.subscribe( this.doCenterOnDOMEvent, this, true);
+ }
+ } else {
+ YAHOO.widget.Overlay.windowResizeEvent.unsubscribe(this.doCenterOnDOMEvent, this);
+ YAHOO.widget.Overlay.windowScrollEvent.unsubscribe(this.doCenterOnDOMEvent, this);
+ }
+}
+
+/**
+* The default event handler fired when the "height" property is changed.
+*/
+YAHOO.widget.Overlay.prototype.configHeight = function(type, args, obj) {
+ var height = args[0];
+ var el = this.element;
+ YAHOO.util.Dom.setStyle(el, "height", height);
+ this.cfg.refireEvent("iframe");
+}
+
+/**
+* The default event handler fired when the "width" property is changed.
+*/
+YAHOO.widget.Overlay.prototype.configWidth = function(type, args, obj) {
+ var width = args[0];
+ var el = this.element;
+ YAHOO.util.Dom.setStyle(el, "width", width);
+ this.cfg.refireEvent("iframe");
+}
+
+/**
+* The default event handler fired when the "zIndex" property is changed.
+*/
+YAHOO.widget.Overlay.prototype.configzIndex = function(type, args, obj) {
+ var zIndex = args[0];
+
+ var el = this.element;
+
+ if (! zIndex) {
+ zIndex = YAHOO.util.Dom.getStyle(el, "zIndex");
+ if (! zIndex || isNaN(zIndex)) {
+ zIndex = 0;
+ }
+ }
+
+ if (this.iframe) {
+ if (zIndex <= 0) {
+ zIndex = 1;
+ }
+ YAHOO.util.Dom.setStyle(this.iframe, "zIndex", (zIndex-1));
+ }
+
+ YAHOO.util.Dom.setStyle(el, "zIndex", zIndex);
+ this.cfg.setProperty("zIndex", zIndex, true);
+}
+
+/**
+* The default event handler fired when the "xy" property is changed.
+*/
+YAHOO.widget.Overlay.prototype.configXY = function(type, args, obj) {
+ var pos = args[0];
+ var x = pos[0];
+ var y = pos[1];
+
+ this.cfg.setProperty("x", x);
+ this.cfg.setProperty("y", y);
+
+ this.beforeMoveEvent.fire([x,y]);
+
+ x = this.cfg.getProperty("x");
+ y = this.cfg.getProperty("y");
+
+ YAHOO.log("xy: " + [x,y], "iframe");
+
+ this.cfg.refireEvent("iframe");
+ this.moveEvent.fire([x,y]);
+}
+
+/**
+* The default event handler fired when the "x" property is changed.
+*/
+YAHOO.widget.Overlay.prototype.configX = function(type, args, obj) {
+ var x = args[0];
+ var y = this.cfg.getProperty("y");
+
+ this.cfg.setProperty("x", x, true);
+ this.cfg.setProperty("y", y, true);
+
+ this.beforeMoveEvent.fire([x,y]);
+
+ x = this.cfg.getProperty("x");
+ y = this.cfg.getProperty("y");
+
+ YAHOO.util.Dom.setX(this.element, x, true);
+
+ this.cfg.setProperty("xy", [x, y], true);
+
+ this.cfg.refireEvent("iframe");
+ this.moveEvent.fire([x, y]);
+}
+
+/**
+* The default event handler fired when the "y" property is changed.
+*/
+YAHOO.widget.Overlay.prototype.configY = function(type, args, obj) {
+ var x = this.cfg.getProperty("x");
+ var y = args[0];
+
+ this.cfg.setProperty("x", x, true);
+ this.cfg.setProperty("y", y, true);
+
+ this.beforeMoveEvent.fire([x,y]);
+
+ x = this.cfg.getProperty("x");
+ y = this.cfg.getProperty("y");
+
+ YAHOO.util.Dom.setY(this.element, y, true);
+
+ this.cfg.setProperty("xy", [x, y], true);
+
+ this.cfg.refireEvent("iframe");
+ this.moveEvent.fire([x, y]);
+}
+
+/**
+* The default event handler fired when the "iframe" property is changed.
+*/
+YAHOO.widget.Overlay.prototype.configIframe = function(type, args, obj) {
+
+ var val = args[0];
+
+ var el = this.element;
+
+ var showIframe = function() {
+ if (this.iframe) {
+ this.iframe.style.display = "block";
+ }
+ }
+
+ var hideIframe = function() {
+ if (this.iframe) {
+ this.iframe.style.display = "none";
+ }
+ }
+
+ if (val) { // IFRAME shim is enabled
+
+ if (! YAHOO.util.Config.alreadySubscribed(this.showEvent, showIframe, this)) {
+ this.showEvent.subscribe(showIframe, this, true);
+ }
+ if (! YAHOO.util.Config.alreadySubscribed(this.hideEvent, hideIframe, this)) {
+ this.hideEvent.subscribe(hideIframe, this, true);
+ }
+
+ var x = this.cfg.getProperty("x");
+ var y = this.cfg.getProperty("y");
+
+ if (! x || ! y) {
+ YAHOO.log("syncPosition needed for iframe", "iframe");
+ this.syncPosition();
+ x = this.cfg.getProperty("x");
+ y = this.cfg.getProperty("y");
+ }
+
+ YAHOO.log("iframe positioning to: " + [x,y], "iframe");
+
+ if (! isNaN(x) && ! isNaN(y)) {
+ if (! this.iframe) {
+ this.iframe = document.createElement("iframe");
+ if (this.isSecure) {
+ this.iframe.src = this.imageRoot + YAHOO.widget.Overlay.IFRAME_SRC;
+ }
+
+ var parent = el.parentNode;
+ if (parent) {
+ parent.appendChild(this.iframe);
+ } else {
+ document.body.appendChild(this.iframe);
+ }
+
+ YAHOO.util.Dom.setStyle(this.iframe, "position", "absolute");
+ YAHOO.util.Dom.setStyle(this.iframe, "border", "none");
+ YAHOO.util.Dom.setStyle(this.iframe, "margin", "0");
+ YAHOO.util.Dom.setStyle(this.iframe, "padding", "0");
+ YAHOO.util.Dom.setStyle(this.iframe, "opacity", "0");
+ if (this.cfg.getProperty("visible")) {
+ showIframe.call(this);
+ } else {
+ hideIframe.call(this);
+ }
+ }
+
+ var iframeDisplay = YAHOO.util.Dom.getStyle(this.iframe, "display");
+
+ if (iframeDisplay == "none") {
+ this.iframe.style.display = "block";
+ }
+
+ YAHOO.util.Dom.setXY(this.iframe, [x,y]);
+
+ var width = el.clientWidth;
+ var height = el.clientHeight;
+
+ YAHOO.util.Dom.setStyle(this.iframe, "width", (width+2) + "px");
+ YAHOO.util.Dom.setStyle(this.iframe, "height", (height+2) + "px");
+
+ if (iframeDisplay == "none") {
+ this.iframe.style.display = "none";
+ }
+ }
+ } else {
+ if (this.iframe) {
+ this.iframe.style.display = "none";
+ }
+ this.showEvent.unsubscribe(showIframe, this);
+ this.hideEvent.unsubscribe(hideIframe, this);
+ }
+}
+
+
+/**
+* The default event handler fired when the "constraintoviewport" property is changed.
+*/
+YAHOO.widget.Overlay.prototype.configConstrainToViewport = function(type, args, obj) {
+ var val = args[0];
+ if (val) {
+ if (! YAHOO.util.Config.alreadySubscribed(this.beforeMoveEvent, this.enforceConstraints, this)) {
+ this.beforeMoveEvent.subscribe(this.enforceConstraints, this, true);
+ }
+ } else {
+ this.beforeMoveEvent.unsubscribe(this.enforceConstraints, this);
+ }
+}
+
+/**
+* The default event handler fired when the "context" property is changed.
+*/
+YAHOO.widget.Overlay.prototype.configContext = function(type, args, obj) {
+ var contextArgs = args[0];
+
+ if (contextArgs) {
+ var contextEl = contextArgs[0];
+ var elementMagnetCorner = contextArgs[1];
+ var contextMagnetCorner = contextArgs[2];
+
+ if (contextEl) {
+ if (typeof contextEl == "string") {
+ this.cfg.setProperty("context", [document.getElementById(contextEl),elementMagnetCorner,contextMagnetCorner], true);
+ }
+
+ if (elementMagnetCorner && contextMagnetCorner) {
+ this.align(elementMagnetCorner, contextMagnetCorner);
+ }
+ }
+ }
+}
+
+
+// END BUILT-IN PROPERTY EVENT HANDLERS //
+
+/**
+* Aligns the Overlay to its context element using the specified corner points (represented by the constants TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, and BOTTOM_RIGHT.
+* @param {string} elementAlign The string representing the corner of the Overlay that should be aligned to the context element
+* @param {string} contextAlign The corner of the context element that the elementAlign corner should stick to.
+*/
+YAHOO.widget.Overlay.prototype.align = function(elementAlign, contextAlign) {
+ var contextArgs = this.cfg.getProperty("context");
+ if (contextArgs) {
+ var context = contextArgs[0];
+
+ var element = this.element;
+ var me = this;
+
+ if (! elementAlign) {
+ elementAlign = contextArgs[1];
+ }
+
+ if (! contextAlign) {
+ contextAlign = contextArgs[2];
+ }
+
+ if (element && context) {
+ var elementRegion = YAHOO.util.Dom.getRegion(element);
+ var contextRegion = YAHOO.util.Dom.getRegion(context);
+
+ var doAlign = function(v,h) {
+ switch (elementAlign) {
+ case YAHOO.widget.Overlay.TOP_LEFT:
+ me.moveTo(h,v);
+ break;
+ case YAHOO.widget.Overlay.TOP_RIGHT:
+ me.moveTo(h-element.offsetWidth,v);
+ break;
+ case YAHOO.widget.Overlay.BOTTOM_LEFT:
+ me.moveTo(h,v-element.offsetHeight);
+ break;
+ case YAHOO.widget.Overlay.BOTTOM_RIGHT:
+ me.moveTo(h-element.offsetWidth,v-element.offsetHeight);
+ break;
+ }
+ }
+
+ switch (contextAlign) {
+ case YAHOO.widget.Overlay.TOP_LEFT:
+ doAlign(contextRegion.top, contextRegion.left);
+ break;
+ case YAHOO.widget.Overlay.TOP_RIGHT:
+ doAlign(contextRegion.top, contextRegion.right);
+ break;
+ case YAHOO.widget.Overlay.BOTTOM_LEFT:
+ doAlign(contextRegion.bottom, contextRegion.left);
+ break;
+ case YAHOO.widget.Overlay.BOTTOM_RIGHT:
+ doAlign(contextRegion.bottom, contextRegion.right);
+ break;
+ }
+ }
+ }
+}
+
+/**
+* The default event handler executed when the moveEvent is fired, if the "constraintoviewport" is set to true.
+*/
+YAHOO.widget.Overlay.prototype.enforceConstraints = function(type, args, obj) {
+ var pos = args[0];
+
+ var x = pos[0];
+ var y = pos[1];
+
+ var width = parseInt(this.cfg.getProperty("width"));
+
+ if (isNaN(width)) {
+ width = 0;
+ }
+
+ var offsetHeight = this.element.offsetHeight;
+ var offsetWidth = (width>0?width:this.element.offsetWidth); //this.element.offsetWidth;
+
+ var viewPortWidth = YAHOO.util.Dom.getViewportWidth();
+ var viewPortHeight = YAHOO.util.Dom.getViewportHeight();
+
+ var scrollX = window.scrollX || document.documentElement.scrollLeft;
+ var scrollY = window.scrollY || document.documentElement.scrollTop;
+
+ var topConstraint = scrollY + 10;
+ var leftConstraint = scrollX + 10;
+ var bottomConstraint = scrollY + viewPortHeight - offsetHeight - 10;
+ var rightConstraint = scrollX + viewPortWidth - offsetWidth - 10;
+
+ if (x < leftConstraint) {
+ x = leftConstraint;
+ } else if (x > rightConstraint) {
+ x = rightConstraint;
+ }
+
+ if (y < topConstraint) {
+ y = topConstraint;
+ } else if (y > bottomConstraint) {
+ y = bottomConstraint;
+ }
+
+ this.cfg.setProperty("x", x, true);
+ this.cfg.setProperty("y", y, true);
+ this.cfg.setProperty("xy", [x,y], true);
+}
+
+/**
+* Centers the container in the viewport.
+*/
+YAHOO.widget.Overlay.prototype.center = function() {
+ var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
+ var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
+
+ var viewPortWidth = YAHOO.util.Dom.getClientWidth();
+ var viewPortHeight = YAHOO.util.Dom.getClientHeight();
+
+ var elementWidth = this.element.offsetWidth;
+ var elementHeight = this.element.offsetHeight;
+
+ var x = (viewPortWidth / 2) - (elementWidth / 2) + scrollX;
+ var y = (viewPortHeight / 2) - (elementHeight / 2) + scrollY;
+
+ this.element.style.left = parseInt(x) + "px";
+ this.element.style.top = parseInt(y) + "px";
+ this.syncPosition();
+
+ this.cfg.refireEvent("iframe");
+}
+
+/**
+* Synchronizes the Panel's "xy", "x", and "y" properties with the Panel's position in the DOM. This is primarily used to update position information during drag & drop.
+*/
+YAHOO.widget.Overlay.prototype.syncPosition = function() {
+ var pos = YAHOO.util.Dom.getXY(this.element);
+ this.cfg.setProperty("x", pos[0], true);
+ this.cfg.setProperty("y", pos[1], true);
+ this.cfg.setProperty("xy", pos, true);
+}
+
+/**
+* Event handler fired when the resize monitor element is resized.
+*/
+YAHOO.widget.Overlay.prototype.onDomResize = function(e, obj) {
+ YAHOO.widget.Overlay.superclass.onDomResize.call(this, e, obj);
+ this.cfg.refireEvent("iframe");
+}
+
+/**
+* Removes the Overlay element from the DOM and sets all child elements to null.
+*/
+YAHOO.widget.Overlay.prototype.destroy = function() {
+ if (this.iframe) {
+ this.iframe.parentNode.removeChild(this.iframe);
+ }
+
+ this.iframe = null;
+
+ YAHOO.widget.Overlay.superclass.destroy.call(this);
+};
+
+/**
+* Returns a string representation of the object.
+* @type string
+*/
+YAHOO.widget.Overlay.prototype.toString = function() {
+ return "Overlay " + this.id;
+}
+
+/**
+* A singleton CustomEvent used for reacting to the DOM event for window scroll
+* @type YAHOO.util.CustomEvent
+*/
+YAHOO.widget.Overlay.windowScrollEvent = new YAHOO.util.CustomEvent("windowScroll");
+
+/**
+* A singleton CustomEvent used for reacting to the DOM event for window resize
+* @type YAHOO.util.CustomEvent
+*/
+YAHOO.widget.Overlay.windowResizeEvent = new YAHOO.util.CustomEvent("windowResize");
+
+/**
+* The DOM event handler used to fire the CustomEvent for window scroll
+* @type Function
+*/
+YAHOO.widget.Overlay.windowScrollHandler = function(e) {
+ YAHOO.widget.Overlay.windowScrollEvent.fire();
+}
+
+/**
+* The DOM event handler used to fire the CustomEvent for window resize
+* @type Function
+*/
+YAHOO.widget.Overlay.windowResizeHandler = function(e) {
+ YAHOO.widget.Overlay.windowResizeEvent.fire();
+}
+
+/**
+* @private
+*/
+YAHOO.widget.Overlay._initialized == null;
+
+if (YAHOO.widget.Overlay._initialized == null) {
+ YAHOO.util.Event.addListener(window, "scroll", YAHOO.widget.Overlay.windowScrollHandler);
+ YAHOO.util.Event.addListener(window, "resize", YAHOO.widget.Overlay.windowResizeHandler);
+
+ YAHOO.widget.Overlay._initialized = true;
+}
+
+/**
+* @class
+* OverlayManager is used for maintaining the focus status of multiple Overlays.
+* @param {Array} overlays Optional. A collection of Overlays to register with the manager.
+* @param {object} userConfig The object literal representing the user configuration of the OverlayManager
+* @constructor
+*/
+YAHOO.widget.OverlayManager = function(userConfig) {
+ this.init(userConfig);
+}
+
+/**
+* The CSS class representing a focused Overlay
+* @type string
+*/
+YAHOO.widget.OverlayManager.CSS_FOCUSED = "focused";
+
+YAHOO.widget.OverlayManager.prototype = {
+
+ constructor : YAHOO.widget.OverlayManager,
+
+ /**
+ * The array of Overlays that are currently registered
+ * @type Array
+ */
+ overlays : null,
+
+ /**
+ * Initializes the default configuration of the OverlayManager
+ */
+ initDefaultConfig : function() {
+ this.cfg.addProperty("overlays", { suppressEvent:true } );
+ this.cfg.addProperty("focusevent", { value:"mousedown" } );
+ },
+
+ /**
+ * Returns the currently focused Overlay
+ * @return {Overlay} The currently focused Overlay
+ */
+ getActive : function() {},
+
+ /**
+ * Focuses the specified Overlay
+ * @param {Overlay} The Overlay to focus
+ * @param {string} The id of the Overlay to focus
+ */
+ focus : function(overlay) {},
+
+ /**
+ * Removes the specified Overlay from the manager
+ * @param {Overlay} The Overlay to remove
+ * @param {string} The id of the Overlay to remove
+ */
+ remove: function(overlay) {},
+
+ /**
+ * Removes focus from all registered Overlays in the manager
+ */
+ blurAll : function() {},
+
+ /**
+ * Initializes the OverlayManager
+ * @param {Array} overlays Optional. A collection of Overlays to register with the manager.
+ * @param {object} userConfig The object literal representing the user configuration of the OverlayManager
+ */
+ init : function(userConfig) {
+ this.cfg = new YAHOO.util.Config(this);
+
+ this.initDefaultConfig();
+
+ if (userConfig) {
+ this.cfg.applyConfig(userConfig, true);
+ }
+ this.cfg.fireQueue();
+
+ var activeOverlay = null;
+
+ this.getActive = function() {
+ return activeOverlay;
+ }
+
+ this.focus = function(overlay) {
+ var o = this.find(overlay);
+ if (o) {
+ this.blurAll();
+ activeOverlay = o;
+ YAHOO.util.Dom.addClass(activeOverlay.element, YAHOO.widget.OverlayManager.CSS_FOCUSED);
+ this.overlays.sort(this.compareZIndexDesc);
+ var topZIndex = YAHOO.util.Dom.getStyle(this.overlays[0].element, "zIndex");
+ if (! isNaN(topZIndex) && this.overlays[0] != overlay) {
+ activeOverlay.cfg.setProperty("zIndex", (parseInt(topZIndex) + 1));
+ }
+ this.overlays.sort(this.compareZIndexDesc);
+ }
+ }
+
+ this.remove = function(overlay) {
+ var o = this.find(overlay);
+ if (o) {
+ var originalZ = YAHOO.util.Dom.getStyle(o.element, "zIndex");
+ o.cfg.setProperty("zIndex", -1000, true);
+ this.overlays.sort(this.compareZIndexDesc);
+ this.overlays = this.overlays.slice(0, this.overlays.length-1);
+ o.cfg.setProperty("zIndex", originalZ, true);
+
+ o.cfg.setProperty("manager", null);
+ o.focusEvent = null
+ o.blurEvent = null;
+ o.focus = null;
+ o.blur = null;
+ }
+ }
+
+ this.blurAll = function() {
+ activeOverlay = null;
+ for (var o=0;o<this.overlays.length;o++) {
+ YAHOO.util.Dom.removeClass(this.overlays[o].element, YAHOO.widget.OverlayManager.CSS_FOCUSED);
+ }
+ }
+
+ var overlays = this.cfg.getProperty("overlays");
+
+ if (! this.overlays) {
+ this.overlays = new Array();
+ }
+
+ if (overlays) {
+ this.register(overlays);
+ this.overlays.sort(this.compareZIndexDesc);
+ }
+ },
+
+ /**
+ * Registers an Overlay or an array of Overlays with the manager. Upon registration, the Overlay receives functions for focus and blur, along with CustomEvents for each.
+ * @param {Overlay} overlay An Overlay to register with the manager.
+ * @param {Overlay[]} overlay An array of Overlays to register with the manager.
+ * @return {boolean} True if any Overlays are registered.
+ */
+ register : function(overlay) {
+ if (overlay instanceof YAHOO.widget.Overlay) {
+ overlay.cfg.addProperty("manager", { value:this } );
+
+ overlay.focusEvent = new YAHOO.util.CustomEvent("focus");
+ overlay.blurEvent = new YAHOO.util.CustomEvent("blur");
+
+ var mgr=this;
+
+ overlay.focus = function() {
+ mgr.focus(this);
+ this.focusEvent.fire();
+ }
+
+ overlay.blur = function() {
+ mgr.blurAll();
+ this.blurEvent.fire();
+ }
+
+ var focusOnDomEvent = function(e,obj) {
+ overlay.focus();
+ }
+
+ var focusevent = this.cfg.getProperty("focusevent");
+ YAHOO.util.Event.addListener(overlay.element,focusevent,focusOnDomEvent,this,true);
+
+ var zIndex = YAHOO.util.Dom.getStyle(overlay.element, "zIndex");
+ if (! isNaN(zIndex)) {
+ overlay.cfg.setProperty("zIndex", parseInt(zIndex));
+ } else {
+ overlay.cfg.setProperty("zIndex", 0);
+ }
+
+ this.overlays.push(overlay);
+ return true;
+ } else if (overlay instanceof Array) {
+ var regcount = 0;
+ for (var i=0;i<overlay.length;i++) {
+ if (this.register(overlay[i])) {
+ regcount++;
+ }
+ }
+ if (regcount > 0) {
+ return true;
+ }
+ } else {
+ return false;
+ }
+ },
+
+ /**
+ * Attempts to locate an Overlay by instance or ID.
+ * @param {Overlay} overlay An Overlay to locate within the manager
+ * @param {string} overlay An Overlay id to locate within the manager
+ * @return {Overlay} The requested Overlay, if found, or null if it cannot be located.
+ */
+ find : function(overlay) {
+ if (overlay instanceof YAHOO.widget.Overlay) {
+ for (var o=0;o<this.overlays.length;o++) {
+ if (this.overlays[o] == overlay) {
+ return this.overlays[o];
+ }
+ }
+ } else if (typeof overlay == "string") {
+ for (var o=0;o<this.overlays.length;o++) {
+ if (this.overlays[o].id == overlay) {
+ return this.overlays[o];
+ }
+ }
+ }
+ return null;
+ },
+
+ /**
+ * Used for sorting the manager's Overlays by z-index.
+ * @private
+ */
+ compareZIndexDesc : function(o1, o2) {
+ var zIndex1 = o1.cfg.getProperty("zIndex");
+ var zIndex2 = o2.cfg.getProperty("zIndex");
+
+ if (zIndex1 > zIndex2) {
+ return -1;
+ } else if (zIndex1 < zIndex2) {
+ return 1;
+ } else {
+ return 0;
+ }
+ },
+
+ /**
+ * Shows all Overlays in the manager.
+ */
+ showAll : function() {
+ for (var o=0;o<this.overlays.length;o++) {
+ this.overlays[o].show();
+ }
+ },
+
+ /**
+ * Hides all Overlays in the manager.
+ */
+ hideAll : function() {
+ for (var o=0;o<this.overlays.length;o++) {
+ this.overlays[o].hide();
+ }
+ },
+
+ /**
+ * Returns a string representation of the object.
+ * @type string
+ */
+ toString : function() {
+ return "OverlayManager";
+ }
+
+}
+
+/**
+* KeyListener is a utility that provides an easy interface for listening for keydown/keyup events fired against DOM elements.
+* @param {Element} attachTo The element or element ID to which the key event should be attached
+* @param {string} attachTo The element or element ID to which the key event should be attached
+* @param {object} keyData The object literal representing the key(s) to detect. Possible attributes are shift(boolean), alt(boolean), ctrl(boolean) and keys(either an int or an array of ints representing keycodes).
+* @param {function} handler The CustomEvent handler to fire when the key event is detected
+* @param {object} handler An object literal representing the handler.
+* @param {string} event Optional. The event (keydown or keyup) to listen for. Defaults automatically to keydown.
+* @constructor
+*/
+YAHOO.util.KeyListener = function(attachTo, keyData, handler, event) {
+ if (! attachTo) {
+ YAHOO.log("No attachTo element specified", "error");
+ }
+ if (! keyData) {
+ YAHOO.log("No keyData specified", "error");
+ }
+ if (! handler) {
+ YAHOO.log("No handler specified", "error");
+ }
+
+ if (! event) {
+ event = YAHOO.util.KeyListener.KEYDOWN;
+ }
+
+ var keyEvent = new YAHOO.util.CustomEvent("keyPressed");
+
+ this.enabledEvent = new YAHOO.util.CustomEvent("enabled");
+ this.disabledEvent = new YAHOO.util.CustomEvent("disabled");
+
+ if (typeof attachTo == 'string') {
+ attachTo = document.getElementById(attachTo);
+ }
+
+ if (typeof handler == 'function') {
+ keyEvent.subscribe(handler);
+ } else {
+ keyEvent.subscribe(handler.fn, handler.scope, handler.correctScope);
+ }
+
+ /**
+ * Handles the key event when a key is pressed.
+ * @private
+ */
+ function handleKeyPress(e, obj) {
+ var keyPressed = e.charCode || e.keyCode;
+
+ if (! keyData.shift) keyData.shift = false;
+ if (! keyData.alt) keyData.alt = false;
+ if (! keyData.ctrl) keyData.ctrl = false;
+
+ // check held down modifying keys first
+ if (e.shiftKey == keyData.shift &&
+ e.altKey == keyData.alt &&
+ e.ctrlKey == keyData.ctrl) { // if we pass this, all modifiers match
+
+ if (keyData.keys instanceof Array) {
+ for (var i=0;i<keyData.keys.length;i++) {
+ if (keyPressed == keyData.keys[i]) {
+ keyEvent.fire(keyPressed, e);
+ break;
+ }
+ }
+ } else {
+ if (keyPressed == keyData.keys) {
+ keyEvent.fire(keyPressed, e);
+ }
+ }
+ }
+ }
+
+ this.enable = function() {
+ if (! this.enabled) {
+ YAHOO.util.Event.addListener(attachTo, event, handleKeyPress);
+ this.enabledEvent.fire(keyData);
+ }
+ this.enabled = true;
+ }
+
+ this.disable = function() {
+ if (this.enabled) {
+ YAHOO.util.Event.removeListener(attachTo, event, handleKeyPress);
+ this.disabledEvent.fire(keyData);
+ }
+ this.enabled = false;
+ }
+
+ /**
+ * Returns a string representation of the object.
+ * @type string
+ */
+ this.toString = function() {
+ return "KeyListener [" + keyData.keys + "] " + attachTo.tagName + (attachTo.id ? "[" + attachTo.id + "]" : "");
+ }
+
+}
+
+/**
+* Constant representing the DOM "keydown" event.
+* @final
+*/
+YAHOO.util.KeyListener.KEYDOWN = "keydown";
+
+/**
+* Constant representing the DOM "keyup" event.
+* @final
+*/
+YAHOO.util.KeyListener.KEYUP = "keyup";
+
+/**
+* Boolean indicating the enabled/disabled state of the Tooltip
+* @type Booleam
+*/
+YAHOO.util.KeyListener.prototype.enabled = null;
+
+/**
+* Enables the KeyListener, by dynamically attaching the key event to the appropriate DOM element.
+*/
+YAHOO.util.KeyListener.prototype.enable = function() {};
+
+/**
+* Disables the KeyListener, by dynamically removing the key event from the appropriate DOM element.
+*/
+YAHOO.util.KeyListener.prototype.disable = function() {};
+
+/**
+* CustomEvent fired when the KeyListener is enabled
+* args: keyData
+* @type YAHOO.util.CustomEvent
+*/
+YAHOO.util.KeyListener.prototype.enabledEvent = null;
+
+/**
+* CustomEvent fired when the KeyListener is disabled
+* args: keyData
+* @type YAHOO.util.CustomEvent
+*/
+YAHOO.util.KeyListener.prototype.disabledEvent = null;
\ No newline at end of file
Added: branches/tomek/portal-dnd/dndRenderer.war/js/container/container_core-min.js
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/container/container_core-min.js 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/container/container_core-min.js 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,153 @@
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+Version 0.11.1
+*/
+YAHOO.util.Config=function(owner){if(owner){this.init(owner);}}
+YAHOO.util.Config.prototype={owner:null,configChangedEvent:null,queueInProgress:false,addProperty:function(key,propertyObject){},getConfig:function(){},getProperty:function(key){},resetProperty:function(key){},setProperty:function(key,value,silent){},queueProperty:function(key,value){},refireEvent:function(key){},applyConfig:function(userConfig,init){},refresh:function(){},fireQueue:function(){},subscribeToConfigEvent:function(key,handler,obj,override){},unsubscribeFromConfigEvent:function(key,handler,obj){},checkBoolean:function(val){if(typeof val=='boolean'){return true;}else{return false;}},checkNumber:function(val){if(isNaN(val)){return false;}else{return true;}}}
+YAHOO.util.Config.prototype.init=function(owner){this.owner=owner;this.configChangedEvent=new YAHOO.util.CustomEvent("configChanged");this.queueInProgress=false;var config={};var initialConfig={};var eventQueue=[];var fireEvent=function(key,value){key=key.toLowerCase();var property=config[key];if(typeof property!='undefined'&&property.event){property.event.fire(value);}}
+this.addProperty=function(key,propertyObject){key=key.toLowerCase();config[key]=propertyObject;propertyObject.event=new YAHOO.util.CustomEvent(key);propertyObject.key=key;if(propertyObject.handler){propertyObject.event.subscribe(propertyObject.handler,this.owner,true);}
+this.setProperty(key,propertyObject.value,true);if(!propertyObject.suppressEvent){this.queueProperty(key,propertyObject.value);}}
+this.getConfig=function(){var cfg={};for(var prop in config){var property=config[prop]
+if(typeof property!='undefined'&&property.event){cfg[prop]=property.value;}}
+return cfg;}
+this.getProperty=function(key){key=key.toLowerCase();var property=config[key];if(typeof property!='undefined'&&property.event){return property.value;}else{return undefined;}}
+this.resetProperty=function(key){key=key.toLowerCase();var property=config[key];if(typeof property!='undefined'&&property.event){this.setProperty(key,initialConfig[key].value);}else{return undefined;}}
+this.setProperty=function(key,value,silent){key=key.toLowerCase();if(this.queueInProgress&&!silent){this.queueProperty(key,value);return true;}else{var property=config[key];if(typeof property!='undefined'&&property.event){if(property.validator&&!property.validator(value)){return false;}else{property.value=value;if(!silent){fireEvent(key,value);this.configChangedEvent.fire([key,value]);}
+return true;}}else{return false;}}}
+this.queueProperty=function(key,value){key=key.toLowerCase();var property=config[key];if(typeof property!='undefined'&&property.event){if(typeof value!='undefined'&&property.validator&&!property.validator(value)){return false;}else{if(typeof value!='undefined'){property.value=value;}else{value=property.value;}
+var foundDuplicate=false;for(var i=0;i<eventQueue.length;i++){var queueItem=eventQueue[i];if(queueItem){var queueItemKey=queueItem[0];var queueItemValue=queueItem[1];if(queueItemKey.toLowerCase()==key){eventQueue[i]=null;eventQueue.push([key,(typeof value!='undefined'?value:queueItemValue)]);foundDuplicate=true;break;}}}
+if(!foundDuplicate&&typeof value!='undefined'){eventQueue.push([key,value]);}}
+if(property.supercedes){for(var s=0;s<property.supercedes.length;s++){var supercedesCheck=property.supercedes[s];for(var q=0;q<eventQueue.length;q++){var queueItemCheck=eventQueue[q];if(queueItemCheck){var queueItemCheckKey=queueItemCheck[0];var queueItemCheckValue=queueItemCheck[1];if(queueItemCheckKey.toLowerCase()==supercedesCheck.toLowerCase()){eventQueue.push([queueItemCheckKey,queueItemCheckValue]);eventQueue[q]=null;break;}}}}}
+return true;}else{return false;}}
+this.refireEvent=function(key){key=key.toLowerCase();var property=config[key];if(typeof property!='undefined'&&property.event&&typeof property.value!='undefined'){if(this.queueInProgress){this.queueProperty(key);}else{fireEvent(key,property.value);}}}
+this.applyConfig=function(userConfig,init){if(init){initialConfig=userConfig;}
+for(var prop in userConfig){this.queueProperty(prop,userConfig[prop]);}}
+this.refresh=function(){for(var prop in config){this.refireEvent(prop);}}
+this.fireQueue=function(){this.queueInProgress=true;for(var i=0;i<eventQueue.length;i++){var queueItem=eventQueue[i];if(queueItem){var key=queueItem[0];var value=queueItem[1];var property=config[key];property.value=value;fireEvent(key,value);}}
+this.queueInProgress=false;eventQueue=new Array();}
+this.subscribeToConfigEvent=function(key,handler,obj,override){key=key.toLowerCase();var property=config[key];if(typeof property!='undefined'&&property.event){if(!YAHOO.util.Config.alreadySubscribed(property.event,handler,obj)){property.event.subscribe(handler,obj,override);}
+return true;}else{return false;}}
+this.unsubscribeFromConfigEvent=function(key,handler,obj){key=key.toLowerCase();var property=config[key];if(typeof property!='undefined'&&property.event){return property.event.unsubscribe(handler,obj);}else{return false;}}
+this.toString=function(){var output="Config";if(this.owner){output+=" ["+this.owner.toString()+"]";}
+return output;}
+this.outputEventQueue=function(){var output="";for(var q=0;q<eventQueue.length;q++){var queueItem=eventQueue[q];if(queueItem){output+=queueItem[0]+"="+queueItem[1]+", ";}}
+return output;}}
+YAHOO.util.Config.alreadySubscribed=function(evt,fn,obj){for(var e=0;e<evt.subscribers.length;e++){var subsc=evt.subscribers[e];if(subsc&&subsc.obj==obj&&subsc.fn==fn){return true;break;}}
+return false;}
+YAHOO.widget.Module=function(el,userConfig){if(el){this.init(el,userConfig);}}
+YAHOO.widget.Module.IMG_ROOT="http://us.i1.yimg.com/us.yimg.com/i/";YAHOO.widget.Module.IMG_ROOT_SSL="https://a248.e.akamai.net/sec.yimg.com/i/";YAHOO.widget.Module.CSS_MODULE="module";YAHOO.widget.Module.CSS_HEADER="hd";YAHOO.widget.Module.CSS_BODY="bd";YAHOO.widget.Module.CSS_FOOTER="ft";YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL=null;YAHOO.widget.Module.prototype={constructor:YAHOO.widget.Module,element:null,header:null,body:null,footer:null,id:null,childNodesInDOM:null,imageRoot:YAHOO.widget.Module.IMG_ROOT,beforeInitEvent:null,initEvent:null,appendEvent:null,beforeRenderEvent:null,renderEvent:null,changeHeaderEvent:null,changeBodyEvent:null,changeFooterEvent:null,changeContentEvent:null,destroyEvent:null,beforeShowEvent:null,showEvent:null,beforeHideEvent:null,hideEvent:null,initEvents:function(){this.beforeInitEvent=new YAHOO.util.CustomEvent("beforeInit");this.initEvent=new YAHOO.util.CustomEvent("init");this.appendEvent=new YAHOO.util.CustomEvent("append");this.b!
eforeRenderEvent=new YAHOO.util.CustomEvent("beforeRender");this.renderEvent=new YAHOO.util.CustomEvent("render");this.changeHeaderEvent=new YAHOO.util.CustomEvent("changeHeader");this.changeBodyEvent=new YAHOO.util.CustomEvent("changeBody");this.changeFooterEvent=new YAHOO.util.CustomEvent("changeFooter");this.changeContentEvent=new YAHOO.util.CustomEvent("changeContent");this.destroyEvent=new YAHOO.util.CustomEvent("destroy");this.beforeShowEvent=new YAHOO.util.CustomEvent("beforeShow");this.showEvent=new YAHOO.util.CustomEvent("show");this.beforeHideEvent=new YAHOO.util.CustomEvent("beforeHide");this.hideEvent=new YAHOO.util.CustomEvent("hide");},platform:function(){var ua=navigator.userAgent.toLowerCase();if(ua.indexOf("windows")!=-1||ua.indexOf("win32")!=-1){return"windows";}else if(ua.indexOf("macintosh")!=-1){return"mac";}else{return false;}}(),browser:function(){var ua=navigator.userAgent.toLowerCase();if(ua.indexOf('opera')!=-1){return'opera';}else if(ua.indexOf('m!
sie 7')!=-1){return'ie7';}else if(ua.indexOf('msie')!=-1){return'ie';}
else if(ua.indexOf('safari')!=-1){return'safari';}else if(ua.indexOf('gecko')!=-1){return'gecko';}else{return false;}}(),isSecure:function(){if(window.location.href.toLowerCase().indexOf("https")==0){return true;}else{return false;}}(),initDefaultConfig:function(){this.cfg.addProperty("visible",{value:true,handler:this.configVisible,validator:this.cfg.checkBoolean});this.cfg.addProperty("effect",{suppressEvent:true,supercedes:["visible"]});this.cfg.addProperty("monitorresize",{value:true,handler:this.configMonitorResize});},init:function(el,userConfig){this.initEvents();this.beforeInitEvent.fire(YAHOO.widget.Module);this.cfg=new YAHOO.util.Config(this);if(this.isSecure){this.imageRoot=YAHOO.widget.Module.IMG_ROOT_SSL;}
+if(typeof el=="string"){var elId=el;el=document.getElementById(el);if(!el){el=document.createElement("DIV");el.id=elId;}}
+this.element=el;if(el.id){this.id=el.id;}
+var childNodes=this.element.childNodes;if(childNodes){for(var i=0;i<childNodes.length;i++){var child=childNodes[i];switch(child.className){case YAHOO.widget.Module.CSS_HEADER:this.header=child;break;case YAHOO.widget.Module.CSS_BODY:this.body=child;break;case YAHOO.widget.Module.CSS_FOOTER:this.footer=child;break;}}}
+this.initDefaultConfig();YAHOO.util.Dom.addClass(this.element,YAHOO.widget.Module.CSS_MODULE);if(userConfig){this.cfg.applyConfig(userConfig,true);}
+if(!YAHOO.util.Config.alreadySubscribed(this.renderEvent,this.cfg.fireQueue,this.cfg)){this.renderEvent.subscribe(this.cfg.fireQueue,this.cfg,true);}
+this.initEvent.fire(YAHOO.widget.Module);},initResizeMonitor:function(){if(this.browser!="opera"){var resizeMonitor=document.getElementById("_yuiResizeMonitor");if(!resizeMonitor){resizeMonitor=document.createElement("iframe");var bIE=(this.browser.indexOf("ie")===0);if(this.isSecure&&this.RESIZE_MONITOR_SECURE_URL&&bIE){resizeMonitor.src=this.RESIZE_MONITOR_SECURE_URL;}
+resizeMonitor.id="_yuiResizeMonitor";resizeMonitor.style.visibility="hidden";document.body.appendChild(resizeMonitor);resizeMonitor.style.width="10em";resizeMonitor.style.height="10em";resizeMonitor.style.position="absolute";var nLeft=-1*resizeMonitor.offsetWidth,nTop=-1*resizeMonitor.offsetHeight;resizeMonitor.style.top=nTop+"px";resizeMonitor.style.left=nLeft+"px";resizeMonitor.style.borderStyle="none";resizeMonitor.style.borderWidth="0";YAHOO.util.Dom.setStyle(resizeMonitor,"opacity","0");resizeMonitor.style.visibility="visible";if(!bIE){var doc=resizeMonitor.contentWindow.document;doc.open();doc.close();}}
+if(resizeMonitor&&resizeMonitor.contentWindow){this.resizeMonitor=resizeMonitor;YAHOO.util.Event.addListener(this.resizeMonitor.contentWindow,"resize",this.onDomResize,this,true);}}},onDomResize:function(e,obj){var nLeft=-1*this.resizeMonitor.offsetWidth,nTop=-1*this.resizeMonitor.offsetHeight;this.resizeMonitor.style.top=nTop+"px";this.resizeMonitor.style.left=nLeft+"px";},setHeader:function(headerContent){if(!this.header){this.header=document.createElement("DIV");this.header.className=YAHOO.widget.Module.CSS_HEADER;}
+if(typeof headerContent=="string"){this.header.innerHTML=headerContent;}else{this.header.innerHTML="";this.header.appendChild(headerContent);}
+this.changeHeaderEvent.fire(headerContent);this.changeContentEvent.fire();},appendToHeader:function(element){if(!this.header){this.header=document.createElement("DIV");this.header.className=YAHOO.widget.Module.CSS_HEADER;}
+this.header.appendChild(element);this.changeHeaderEvent.fire(element);this.changeContentEvent.fire();},setBody:function(bodyContent){if(!this.body){this.body=document.createElement("DIV");this.body.className=YAHOO.widget.Module.CSS_BODY;}
+if(typeof bodyContent=="string")
+{this.body.innerHTML=bodyContent;}else{this.body.innerHTML="";this.body.appendChild(bodyContent);}
+this.changeBodyEvent.fire(bodyContent);this.changeContentEvent.fire();},appendToBody:function(element){if(!this.body){this.body=document.createElement("DIV");this.body.className=YAHOO.widget.Module.CSS_BODY;}
+this.body.appendChild(element);this.changeBodyEvent.fire(element);this.changeContentEvent.fire();},setFooter:function(footerContent){if(!this.footer){this.footer=document.createElement("DIV");this.footer.className=YAHOO.widget.Module.CSS_FOOTER;}
+if(typeof footerContent=="string"){this.footer.innerHTML=footerContent;}else{this.footer.innerHTML="";this.footer.appendChild(footerContent);}
+this.changeFooterEvent.fire(footerContent);this.changeContentEvent.fire();},appendToFooter:function(element){if(!this.footer){this.footer=document.createElement("DIV");this.footer.className=YAHOO.widget.Module.CSS_FOOTER;}
+this.footer.appendChild(element);this.changeFooterEvent.fire(element);this.changeContentEvent.fire();},render:function(appendToNode,moduleElement){this.beforeRenderEvent.fire();if(!moduleElement){moduleElement=this.element;}
+var me=this;var appendTo=function(element){if(typeof element=="string"){element=document.getElementById(element);}
+if(element){element.appendChild(me.element);me.appendEvent.fire();}}
+if(appendToNode){appendTo(appendToNode);}else{if(!YAHOO.util.Dom.inDocument(this.element)){return false;}}
+if(this.header&&!YAHOO.util.Dom.inDocument(this.header)){var firstChild=moduleElement.firstChild;if(firstChild){moduleElement.insertBefore(this.header,firstChild);}else{moduleElement.appendChild(this.header);}}
+if(this.body&&!YAHOO.util.Dom.inDocument(this.body)){if(this.footer&&YAHOO.util.Dom.isAncestor(this.moduleElement,this.footer)){moduleElement.insertBefore(this.body,this.footer);}else{moduleElement.appendChild(this.body);}}
+if(this.footer&&!YAHOO.util.Dom.inDocument(this.footer)){moduleElement.appendChild(this.footer);}
+this.renderEvent.fire();return true;},destroy:function(){if(this.element){var parent=this.element.parentNode;}
+if(parent){parent.removeChild(this.element);}
+this.element=null;this.header=null;this.body=null;this.footer=null;this.destroyEvent.fire();},show:function(){this.cfg.setProperty("visible",true);},hide:function(){this.cfg.setProperty("visible",false);},configVisible:function(type,args,obj){var visible=args[0];if(visible){this.beforeShowEvent.fire();YAHOO.util.Dom.setStyle(this.element,"display","block");this.showEvent.fire();}else{this.beforeHideEvent.fire();YAHOO.util.Dom.setStyle(this.element,"display","none");this.hideEvent.fire();}},configMonitorResize:function(type,args,obj){var monitor=args[0];if(monitor){this.initResizeMonitor();}else{YAHOO.util.Event.removeListener(this.resizeMonitor,"resize",this.onDomResize);this.resizeMonitor=null;}}}
+YAHOO.widget.Module.prototype.toString=function(){return"Module "+this.id;}
+YAHOO.widget.Overlay=function(el,userConfig){YAHOO.widget.Overlay.superclass.constructor.call(this,el,userConfig);}
+YAHOO.extend(YAHOO.widget.Overlay,YAHOO.widget.Module);YAHOO.widget.Overlay.IFRAME_SRC="promo/m/irs/blank.gif";YAHOO.widget.Overlay.TOP_LEFT="tl";YAHOO.widget.Overlay.TOP_RIGHT="tr";YAHOO.widget.Overlay.BOTTOM_LEFT="bl";YAHOO.widget.Overlay.BOTTOM_RIGHT="br";YAHOO.widget.Overlay.CSS_OVERLAY="overlay";YAHOO.widget.Overlay.prototype.beforeMoveEvent=null;YAHOO.widget.Overlay.prototype.moveEvent=null;YAHOO.widget.Overlay.prototype.init=function(el,userConfig){YAHOO.widget.Overlay.superclass.init.call(this,el);this.beforeInitEvent.fire(YAHOO.widget.Overlay);YAHOO.util.Dom.addClass(this.element,YAHOO.widget.Overlay.CSS_OVERLAY);if(userConfig){this.cfg.applyConfig(userConfig,true);}
+if(this.platform=="mac"&&this.browser=="gecko"){if(!YAHOO.util.Config.alreadySubscribed(this.showEvent,this.showMacGeckoScrollbars,this)){this.showEvent.subscribe(this.showMacGeckoScrollbars,this,true);}
+if(!YAHOO.util.Config.alreadySubscribed(this.hideEvent,this.hideMacGeckoScrollbars,this)){this.hideEvent.subscribe(this.hideMacGeckoScrollbars,this,true);}}
+this.initEvent.fire(YAHOO.widget.Overlay);}
+YAHOO.widget.Overlay.prototype.initEvents=function(){YAHOO.widget.Overlay.superclass.initEvents.call(this);this.beforeMoveEvent=new YAHOO.util.CustomEvent("beforeMove",this);this.moveEvent=new YAHOO.util.CustomEvent("move",this);}
+YAHOO.widget.Overlay.prototype.initDefaultConfig=function(){YAHOO.widget.Overlay.superclass.initDefaultConfig.call(this);this.cfg.addProperty("x",{handler:this.configX,validator:this.cfg.checkNumber,suppressEvent:true,supercedes:["iframe"]});this.cfg.addProperty("y",{handler:this.configY,validator:this.cfg.checkNumber,suppressEvent:true,supercedes:["iframe"]});this.cfg.addProperty("xy",{handler:this.configXY,suppressEvent:true,supercedes:["iframe"]});this.cfg.addProperty("context",{handler:this.configContext,suppressEvent:true,supercedes:["iframe"]});this.cfg.addProperty("fixedcenter",{value:false,handler:this.configFixedCenter,validator:this.cfg.checkBoolean,supercedes:["iframe","visible"]});this.cfg.addProperty("width",{handler:this.configWidth,suppressEvent:true,supercedes:["iframe"]});this.cfg.addProperty("height",{handler:this.configHeight,suppressEvent:true,supercedes:["iframe"]});this.cfg.addProperty("zIndex",{value:null,handler:this.configzIndex});this.cfg.addProper!
ty("constraintoviewport",{value:false,handler:this.configConstrainToViewport,validator:this.cfg.checkBoolean,supercedes:["iframe","x","y","xy"]});this.cfg.addProperty("iframe",{value:(this.browser=="ie"?true:false),handler:this.configIframe,validator:this.cfg.checkBoolean,supercedes:["zIndex"]});}
+YAHOO.widget.Overlay.prototype.moveTo=function(x,y){this.cfg.setProperty("xy",[x,y]);}
+YAHOO.widget.Overlay.prototype.hideMacGeckoScrollbars=function(){YAHOO.util.Dom.removeClass(this.element,"show-scrollbars");YAHOO.util.Dom.addClass(this.element,"hide-scrollbars");}
+YAHOO.widget.Overlay.prototype.showMacGeckoScrollbars=function(){YAHOO.util.Dom.removeClass(this.element,"hide-scrollbars");YAHOO.util.Dom.addClass(this.element,"show-scrollbars");}
+YAHOO.widget.Overlay.prototype.configVisible=function(type,args,obj){var visible=args[0];var currentVis=YAHOO.util.Dom.getStyle(this.element,"visibility");var effect=this.cfg.getProperty("effect");var effectInstances=new Array();if(effect){if(effect instanceof Array){for(var i=0;i<effect.length;i++){var eff=effect[i];effectInstances[effectInstances.length]=eff.effect(this,eff.duration);}}else{effectInstances[effectInstances.length]=effect.effect(this,effect.duration);}}
+var isMacGecko=(this.platform=="mac"&&this.browser=="gecko");if(visible){if(isMacGecko){this.showMacGeckoScrollbars();}
+if(effect){if(visible){if(currentVis!="visible"){this.beforeShowEvent.fire();for(var i=0;i<effectInstances.length;i++){var e=effectInstances[i];if(i==0&&!YAHOO.util.Config.alreadySubscribed(e.animateInCompleteEvent,this.showEvent.fire,this.showEvent)){e.animateInCompleteEvent.subscribe(this.showEvent.fire,this.showEvent,true);}
+e.animateIn();}}}}else{if(currentVis!="visible"){this.beforeShowEvent.fire();YAHOO.util.Dom.setStyle(this.element,"visibility","visible");this.cfg.refireEvent("iframe");this.showEvent.fire();}}}else{if(isMacGecko){this.hideMacGeckoScrollbars();}
+if(effect){if(currentVis=="visible"){this.beforeHideEvent.fire();for(var i=0;i<effectInstances.length;i++){var e=effectInstances[i];if(i==0&&!YAHOO.util.Config.alreadySubscribed(e.animateOutCompleteEvent,this.hideEvent.fire,this.hideEvent)){e.animateOutCompleteEvent.subscribe(this.hideEvent.fire,this.hideEvent,true);}
+e.animateOut();}}}else{if(currentVis=="visible"){this.beforeHideEvent.fire();YAHOO.util.Dom.setStyle(this.element,"visibility","hidden");this.cfg.refireEvent("iframe");this.hideEvent.fire();}}}}
+YAHOO.widget.Overlay.prototype.doCenterOnDOMEvent=function(){if(this.cfg.getProperty("visible")){this.center();}}
+YAHOO.widget.Overlay.prototype.configFixedCenter=function(type,args,obj){var val=args[0];if(val){this.center();if(!YAHOO.util.Config.alreadySubscribed(this.beforeShowEvent,this.center,this)){this.beforeShowEvent.subscribe(this.center,this,true);}
+if(!YAHOO.util.Config.alreadySubscribed(YAHOO.widget.Overlay.windowResizeEvent,this.doCenterOnDOMEvent,this)){YAHOO.widget.Overlay.windowResizeEvent.subscribe(this.doCenterOnDOMEvent,this,true);}
+if(!YAHOO.util.Config.alreadySubscribed(YAHOO.widget.Overlay.windowScrollEvent,this.doCenterOnDOMEvent,this)){YAHOO.widget.Overlay.windowScrollEvent.subscribe(this.doCenterOnDOMEvent,this,true);}}else{YAHOO.widget.Overlay.windowResizeEvent.unsubscribe(this.doCenterOnDOMEvent,this);YAHOO.widget.Overlay.windowScrollEvent.unsubscribe(this.doCenterOnDOMEvent,this);}}
+YAHOO.widget.Overlay.prototype.configHeight=function(type,args,obj){var height=args[0];var el=this.element;YAHOO.util.Dom.setStyle(el,"height",height);this.cfg.refireEvent("iframe");}
+YAHOO.widget.Overlay.prototype.configWidth=function(type,args,obj){var width=args[0];var el=this.element;YAHOO.util.Dom.setStyle(el,"width",width);this.cfg.refireEvent("iframe");}
+YAHOO.widget.Overlay.prototype.configzIndex=function(type,args,obj){var zIndex=args[0];var el=this.element;if(!zIndex){zIndex=YAHOO.util.Dom.getStyle(el,"zIndex");if(!zIndex||isNaN(zIndex)){zIndex=0;}}
+if(this.iframe){if(zIndex<=0){zIndex=1;}
+YAHOO.util.Dom.setStyle(this.iframe,"zIndex",(zIndex-1));}
+YAHOO.util.Dom.setStyle(el,"zIndex",zIndex);this.cfg.setProperty("zIndex",zIndex,true);}
+YAHOO.widget.Overlay.prototype.configXY=function(type,args,obj){var pos=args[0];var x=pos[0];var y=pos[1];this.cfg.setProperty("x",x);this.cfg.setProperty("y",y);this.beforeMoveEvent.fire([x,y]);x=this.cfg.getProperty("x");y=this.cfg.getProperty("y");this.cfg.refireEvent("iframe");this.moveEvent.fire([x,y]);}
+YAHOO.widget.Overlay.prototype.configX=function(type,args,obj){var x=args[0];var y=this.cfg.getProperty("y");this.cfg.setProperty("x",x,true);this.cfg.setProperty("y",y,true);this.beforeMoveEvent.fire([x,y]);x=this.cfg.getProperty("x");y=this.cfg.getProperty("y");YAHOO.util.Dom.setX(this.element,x,true);this.cfg.setProperty("xy",[x,y],true);this.cfg.refireEvent("iframe");this.moveEvent.fire([x,y]);}
+YAHOO.widget.Overlay.prototype.configY=function(type,args,obj){var x=this.cfg.getProperty("x");var y=args[0];this.cfg.setProperty("x",x,true);this.cfg.setProperty("y",y,true);this.beforeMoveEvent.fire([x,y]);x=this.cfg.getProperty("x");y=this.cfg.getProperty("y");YAHOO.util.Dom.setY(this.element,y,true);this.cfg.setProperty("xy",[x,y],true);this.cfg.refireEvent("iframe");this.moveEvent.fire([x,y]);}
+YAHOO.widget.Overlay.prototype.configIframe=function(type,args,obj){var val=args[0];var el=this.element;var showIframe=function(){if(this.iframe){this.iframe.style.display="block";}}
+var hideIframe=function(){if(this.iframe){this.iframe.style.display="none";}}
+if(val){if(!YAHOO.util.Config.alreadySubscribed(this.showEvent,showIframe,this)){this.showEvent.subscribe(showIframe,this,true);}
+if(!YAHOO.util.Config.alreadySubscribed(this.hideEvent,hideIframe,this)){this.hideEvent.subscribe(hideIframe,this,true);}
+var x=this.cfg.getProperty("x");var y=this.cfg.getProperty("y");if(!x||!y){this.syncPosition();x=this.cfg.getProperty("x");y=this.cfg.getProperty("y");}
+if(!isNaN(x)&&!isNaN(y)){if(!this.iframe){this.iframe=document.createElement("iframe");if(this.isSecure){this.iframe.src=this.imageRoot+YAHOO.widget.Overlay.IFRAME_SRC;}
+var parent=el.parentNode;if(parent){parent.appendChild(this.iframe);}else{document.body.appendChild(this.iframe);}
+YAHOO.util.Dom.setStyle(this.iframe,"position","absolute");YAHOO.util.Dom.setStyle(this.iframe,"border","none");YAHOO.util.Dom.setStyle(this.iframe,"margin","0");YAHOO.util.Dom.setStyle(this.iframe,"padding","0");YAHOO.util.Dom.setStyle(this.iframe,"opacity","0");if(this.cfg.getProperty("visible")){showIframe.call(this);}else{hideIframe.call(this);}}
+var iframeDisplay=YAHOO.util.Dom.getStyle(this.iframe,"display");if(iframeDisplay=="none"){this.iframe.style.display="block";}
+YAHOO.util.Dom.setXY(this.iframe,[x,y]);var width=el.clientWidth;var height=el.clientHeight;YAHOO.util.Dom.setStyle(this.iframe,"width",(width+2)+"px");YAHOO.util.Dom.setStyle(this.iframe,"height",(height+2)+"px");if(iframeDisplay=="none"){this.iframe.style.display="none";}}}else{if(this.iframe){this.iframe.style.display="none";}
+this.showEvent.unsubscribe(showIframe,this);this.hideEvent.unsubscribe(hideIframe,this);}}
+YAHOO.widget.Overlay.prototype.configConstrainToViewport=function(type,args,obj){var val=args[0];if(val){if(!YAHOO.util.Config.alreadySubscribed(this.beforeMoveEvent,this.enforceConstraints,this)){this.beforeMoveEvent.subscribe(this.enforceConstraints,this,true);}}else{this.beforeMoveEvent.unsubscribe(this.enforceConstraints,this);}}
+YAHOO.widget.Overlay.prototype.configContext=function(type,args,obj){var contextArgs=args[0];if(contextArgs){var contextEl=contextArgs[0];var elementMagnetCorner=contextArgs[1];var contextMagnetCorner=contextArgs[2];if(contextEl){if(typeof contextEl=="string"){this.cfg.setProperty("context",[document.getElementById(contextEl),elementMagnetCorner,contextMagnetCorner],true);}
+if(elementMagnetCorner&&contextMagnetCorner){this.align(elementMagnetCorner,contextMagnetCorner);}}}}
+YAHOO.widget.Overlay.prototype.align=function(elementAlign,contextAlign){var contextArgs=this.cfg.getProperty("context");if(contextArgs){var context=contextArgs[0];var element=this.element;var me=this;if(!elementAlign){elementAlign=contextArgs[1];}
+if(!contextAlign){contextAlign=contextArgs[2];}
+if(element&&context){var elementRegion=YAHOO.util.Dom.getRegion(element);var contextRegion=YAHOO.util.Dom.getRegion(context);var doAlign=function(v,h){switch(elementAlign){case YAHOO.widget.Overlay.TOP_LEFT:me.moveTo(h,v);break;case YAHOO.widget.Overlay.TOP_RIGHT:me.moveTo(h-element.offsetWidth,v);break;case YAHOO.widget.Overlay.BOTTOM_LEFT:me.moveTo(h,v-element.offsetHeight);break;case YAHOO.widget.Overlay.BOTTOM_RIGHT:me.moveTo(h-element.offsetWidth,v-element.offsetHeight);break;}}
+switch(contextAlign){case YAHOO.widget.Overlay.TOP_LEFT:doAlign(contextRegion.top,contextRegion.left);break;case YAHOO.widget.Overlay.TOP_RIGHT:doAlign(contextRegion.top,contextRegion.right);break;case YAHOO.widget.Overlay.BOTTOM_LEFT:doAlign(contextRegion.bottom,contextRegion.left);break;case YAHOO.widget.Overlay.BOTTOM_RIGHT:doAlign(contextRegion.bottom,contextRegion.right);break;}}}}
+YAHOO.widget.Overlay.prototype.enforceConstraints=function(type,args,obj){var pos=args[0];var x=pos[0];var y=pos[1];var width=parseInt(this.cfg.getProperty("width"));if(isNaN(width)){width=0;}
+var offsetHeight=this.element.offsetHeight;var offsetWidth=(width>0?width:this.element.offsetWidth);var viewPortWidth=YAHOO.util.Dom.getViewportWidth();var viewPortHeight=YAHOO.util.Dom.getViewportHeight();var scrollX=window.scrollX||document.documentElement.scrollLeft;var scrollY=window.scrollY||document.documentElement.scrollTop;var topConstraint=scrollY+10;var leftConstraint=scrollX+10;var bottomConstraint=scrollY+viewPortHeight-offsetHeight-10;var rightConstraint=scrollX+viewPortWidth-offsetWidth-10;if(x<leftConstraint){x=leftConstraint;}else if(x>rightConstraint){x=rightConstraint;}
+if(y<topConstraint){y=topConstraint;}else if(y>bottomConstraint){y=bottomConstraint;}
+this.cfg.setProperty("x",x,true);this.cfg.setProperty("y",y,true);this.cfg.setProperty("xy",[x,y],true);}
+YAHOO.widget.Overlay.prototype.center=function(){var scrollX=document.documentElement.scrollLeft||document.body.scrollLeft;var scrollY=document.documentElement.scrollTop||document.body.scrollTop;var viewPortWidth=YAHOO.util.Dom.getClientWidth();var viewPortHeight=YAHOO.util.Dom.getClientHeight();var elementWidth=this.element.offsetWidth;var elementHeight=this.element.offsetHeight;var x=(viewPortWidth/2)-(elementWidth/2)+scrollX;var y=(viewPortHeight/2)-(elementHeight/2)+scrollY;this.element.style.left=parseInt(x)+"px";this.element.style.top=parseInt(y)+"px";this.syncPosition();this.cfg.refireEvent("iframe");}
+YAHOO.widget.Overlay.prototype.syncPosition=function(){var pos=YAHOO.util.Dom.getXY(this.element);this.cfg.setProperty("x",pos[0],true);this.cfg.setProperty("y",pos[1],true);this.cfg.setProperty("xy",pos,true);}
+YAHOO.widget.Overlay.prototype.onDomResize=function(e,obj){YAHOO.widget.Overlay.superclass.onDomResize.call(this,e,obj);this.cfg.refireEvent("iframe");}
+YAHOO.widget.Overlay.prototype.destroy=function(){if(this.iframe){this.iframe.parentNode.removeChild(this.iframe);}
+this.iframe=null;YAHOO.widget.Overlay.superclass.destroy.call(this);};YAHOO.widget.Overlay.prototype.toString=function(){return"Overlay "+this.id;}
+YAHOO.widget.Overlay.windowScrollEvent=new YAHOO.util.CustomEvent("windowScroll");YAHOO.widget.Overlay.windowResizeEvent=new YAHOO.util.CustomEvent("windowResize");YAHOO.widget.Overlay.windowScrollHandler=function(e){YAHOO.widget.Overlay.windowScrollEvent.fire();}
+YAHOO.widget.Overlay.windowResizeHandler=function(e){YAHOO.widget.Overlay.windowResizeEvent.fire();}
+YAHOO.widget.Overlay._initialized==null;if(YAHOO.widget.Overlay._initialized==null){YAHOO.util.Event.addListener(window,"scroll",YAHOO.widget.Overlay.windowScrollHandler);YAHOO.util.Event.addListener(window,"resize",YAHOO.widget.Overlay.windowResizeHandler);YAHOO.widget.Overlay._initialized=true;}
+YAHOO.widget.OverlayManager=function(userConfig){this.init(userConfig);}
+YAHOO.widget.OverlayManager.CSS_FOCUSED="focused";YAHOO.widget.OverlayManager.prototype={constructor:YAHOO.widget.OverlayManager,overlays:null,initDefaultConfig:function(){this.cfg.addProperty("overlays",{suppressEvent:true});this.cfg.addProperty("focusevent",{value:"mousedown"});},getActive:function(){},focus:function(overlay){},remove:function(overlay){},blurAll:function(){},init:function(userConfig){this.cfg=new YAHOO.util.Config(this);this.initDefaultConfig();if(userConfig){this.cfg.applyConfig(userConfig,true);}
+this.cfg.fireQueue();var activeOverlay=null;this.getActive=function(){return activeOverlay;}
+this.focus=function(overlay){var o=this.find(overlay);if(o){this.blurAll();activeOverlay=o;YAHOO.util.Dom.addClass(activeOverlay.element,YAHOO.widget.OverlayManager.CSS_FOCUSED);this.overlays.sort(this.compareZIndexDesc);var topZIndex=YAHOO.util.Dom.getStyle(this.overlays[0].element,"zIndex");if(!isNaN(topZIndex)&&this.overlays[0]!=overlay){activeOverlay.cfg.setProperty("zIndex",(parseInt(topZIndex)+1));}
+this.overlays.sort(this.compareZIndexDesc);}}
+this.remove=function(overlay){var o=this.find(overlay);if(o){var originalZ=YAHOO.util.Dom.getStyle(o.element,"zIndex");o.cfg.setProperty("zIndex",-1000,true);this.overlays.sort(this.compareZIndexDesc);this.overlays=this.overlays.slice(0,this.overlays.length-1);o.cfg.setProperty("zIndex",originalZ,true);o.cfg.setProperty("manager",null);o.focusEvent=null
+o.blurEvent=null;o.focus=null;o.blur=null;}}
+this.blurAll=function(){activeOverlay=null;for(var o=0;o<this.overlays.length;o++){YAHOO.util.Dom.removeClass(this.overlays[o].element,YAHOO.widget.OverlayManager.CSS_FOCUSED);}}
+var overlays=this.cfg.getProperty("overlays");if(!this.overlays){this.overlays=new Array();}
+if(overlays){this.register(overlays);this.overlays.sort(this.compareZIndexDesc);}},register:function(overlay){if(overlay instanceof YAHOO.widget.Overlay){overlay.cfg.addProperty("manager",{value:this});overlay.focusEvent=new YAHOO.util.CustomEvent("focus");overlay.blurEvent=new YAHOO.util.CustomEvent("blur");var mgr=this;overlay.focus=function(){mgr.focus(this);this.focusEvent.fire();}
+overlay.blur=function(){mgr.blurAll();this.blurEvent.fire();}
+var focusOnDomEvent=function(e,obj){overlay.focus();}
+var focusevent=this.cfg.getProperty("focusevent");YAHOO.util.Event.addListener(overlay.element,focusevent,focusOnDomEvent,this,true);var zIndex=YAHOO.util.Dom.getStyle(overlay.element,"zIndex");if(!isNaN(zIndex)){overlay.cfg.setProperty("zIndex",parseInt(zIndex));}else{overlay.cfg.setProperty("zIndex",0);}
+this.overlays.push(overlay);return true;}else if(overlay instanceof Array){var regcount=0;for(var i=0;i<overlay.length;i++){if(this.register(overlay[i])){regcount++;}}
+if(regcount>0){return true;}}else{return false;}},find:function(overlay){if(overlay instanceof YAHOO.widget.Overlay){for(var o=0;o<this.overlays.length;o++){if(this.overlays[o]==overlay){return this.overlays[o];}}}else if(typeof overlay=="string"){for(var o=0;o<this.overlays.length;o++){if(this.overlays[o].id==overlay){return this.overlays[o];}}}
+return null;},compareZIndexDesc:function(o1,o2){var zIndex1=o1.cfg.getProperty("zIndex");var zIndex2=o2.cfg.getProperty("zIndex");if(zIndex1>zIndex2){return-1;}else if(zIndex1<zIndex2){return 1;}else{return 0;}},showAll:function(){for(var o=0;o<this.overlays.length;o++){this.overlays[o].show();}},hideAll:function(){for(var o=0;o<this.overlays.length;o++){this.overlays[o].hide();}},toString:function(){return"OverlayManager";}}
+YAHOO.util.KeyListener=function(attachTo,keyData,handler,event){if(!event){event=YAHOO.util.KeyListener.KEYDOWN;}
+var keyEvent=new YAHOO.util.CustomEvent("keyPressed");this.enabledEvent=new YAHOO.util.CustomEvent("enabled");this.disabledEvent=new YAHOO.util.CustomEvent("disabled");if(typeof attachTo=='string'){attachTo=document.getElementById(attachTo);}
+if(typeof handler=='function'){keyEvent.subscribe(handler);}else{keyEvent.subscribe(handler.fn,handler.scope,handler.correctScope);}
+function handleKeyPress(e,obj){var keyPressed=e.charCode||e.keyCode;if(!keyData.shift)keyData.shift=false;if(!keyData.alt)keyData.alt=false;if(!keyData.ctrl)keyData.ctrl=false;if(e.shiftKey==keyData.shift&&e.altKey==keyData.alt&&e.ctrlKey==keyData.ctrl){if(keyData.keys instanceof Array){for(var i=0;i<keyData.keys.length;i++){if(keyPressed==keyData.keys[i]){keyEvent.fire(keyPressed,e);break;}}}else{if(keyPressed==keyData.keys){keyEvent.fire(keyPressed,e);}}}}
+this.enable=function(){if(!this.enabled){YAHOO.util.Event.addListener(attachTo,event,handleKeyPress);this.enabledEvent.fire(keyData);}
+this.enabled=true;}
+this.disable=function(){if(this.enabled){YAHOO.util.Event.removeListener(attachTo,event,handleKeyPress);this.disabledEvent.fire(keyData);}
+this.enabled=false;}
+this.toString=function(){return"KeyListener ["+keyData.keys+"] "+attachTo.tagName+(attachTo.id?"["+attachTo.id+"]":"");}}
+YAHOO.util.KeyListener.KEYDOWN="keydown";YAHOO.util.KeyListener.KEYUP="keyup";YAHOO.util.KeyListener.prototype.enabled=null;YAHOO.util.KeyListener.prototype.enable=function(){};YAHOO.util.KeyListener.prototype.disable=function(){};YAHOO.util.KeyListener.prototype.enabledEvent=null;YAHOO.util.KeyListener.prototype.disabledEvent=null;
\ No newline at end of file
Added: branches/tomek/portal-dnd/dndRenderer.war/js/container/container_core.js
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/container/container_core.js 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/container/container_core.js 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,2244 @@
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+Version 0.11.1
+*/
+
+/**
+* @class
+* Config is a utility used within an object to allow the implementer to maintain a list of local configuration properties and listen for changes to those properties dynamically using CustomEvent. The initial values are also maintained so that the configuration can be reset at any given point to its initial state.
+* @param {object} owner The owner object to which this Config object belongs
+* @constructor
+*/
+YAHOO.util.Config = function(owner) {
+ if (owner) {
+ this.init(owner);
+ }
+}
+
+YAHOO.util.Config.prototype = {
+
+ /**
+ * Object reference to the owner of this Config object
+ * @type object
+ */
+ owner : null,
+
+ /**
+ * Object reference to the owner of this Config object
+ * args: key, value
+ * @type YAHOO.util.CustomEvent
+ */
+ configChangedEvent : null,
+
+ /**
+ * Boolean flag that specifies whether a queue is currently being executed
+ * @type boolean
+ */
+ queueInProgress : false,
+
+ /**
+ * Adds a property to the Config object's private config hash.
+ * @param {string} key The configuration property's name
+ * @param {object} propertyObject The object containing all of this property's arguments
+ */
+ addProperty : function(key, propertyObject){},
+
+ /**
+ * Returns a key-value configuration map of the values currently set in the Config object.
+ * @return {object} The current config, represented in a key-value map
+ */
+ getConfig : function(){},
+
+ /**
+ * Returns the value of specified property.
+ * @param {key} The name of the property
+ * @return {object} The value of the specified property
+ */
+ getProperty : function(key){},
+
+ /**
+ * Resets the specified property's value to its initial value.
+ * @param {key} The name of the property
+ */
+ resetProperty : function(key){},
+
+ /**
+ * Sets the value of a property. If the silent property is passed as true, the property's event will not be fired.
+ * @param {key} The name of the property
+ * @param {value} The value to set the property to
+ * @param {boolean} Whether the value should be set silently, without firing the property event.
+ * @return {boolean} true, if the set was successful, false if it failed.
+ */
+ setProperty : function(key,value,silent){},
+
+ /**
+ * Sets the value of a property and queues its event to execute. If the event is already scheduled to execute, it is
+ * moved from its current position to the end of the queue.
+ * @param {key} The name of the property
+ * @param {value} The value to set the property to
+ * @return {boolean} true, if the set was successful, false if it failed.
+ */
+ queueProperty : function(key,value){},
+
+ /**
+ * Fires the event for a property using the property's current value.
+ * @param {key} The name of the property
+ */
+ refireEvent : function(key){},
+
+ /**
+ * Applies a key-value object literal to the configuration, replacing any existing values, and queueing the property events.
+ * Although the values will be set, fireQueue() must be called for their associated events to execute.
+ * @param {object} userConfig The configuration object literal
+ * @param {boolean} init When set to true, the initialConfig will be set to the userConfig passed in, so that calling a reset will reset the properties to the passed values.
+ */
+ applyConfig : function(userConfig,init){},
+
+ /**
+ * Refires the events for all configuration properties using their current values.
+ */
+ refresh : function(){},
+
+ /**
+ * Fires the normalized list of queued property change events
+ */
+ fireQueue : function(){},
+
+ /**
+ * Subscribes an external handler to the change event for any given property.
+ * @param {string} key The property name
+ * @param {Function} handler The handler function to use subscribe to the property's event
+ * @param {object} obj The object to use for scoping the event handler (see CustomEvent documentation)
+ * @param {boolean} override Optional. If true, will override "this" within the handler to map to the scope object passed into the method.
+ */
+ subscribeToConfigEvent : function(key,handler,obj,override){},
+
+ /**
+ * Unsubscribes an external handler from the change event for any given property.
+ * @param {string} key The property name
+ * @param {Function} handler The handler function to use subscribe to the property's event
+ * @param {object} obj The object to use for scoping the event handler (see CustomEvent documentation)
+ */
+ unsubscribeFromConfigEvent: function(key,handler,obj){},
+
+ /**
+ * Validates that the value passed in is a boolean.
+ * @param {object} val The value to validate
+ * @return {boolean} true, if the value is valid
+ */
+ checkBoolean: function(val) {
+ if (typeof val == 'boolean') {
+ return true;
+ } else {
+ return false;
+ }
+ },
+
+ /**
+ * Validates that the value passed in is a number.
+ * @param {object} val The value to validate
+ * @return {boolean} true, if the value is valid
+ */
+ checkNumber: function(val) {
+ if (isNaN(val)) {
+ return false;
+ } else {
+ return true;
+ }
+ }
+}
+
+
+/**
+* Initializes the configuration object and all of its local members.
+* @param {object} owner The owner object to which this Config object belongs
+*/
+YAHOO.util.Config.prototype.init = function(owner) {
+
+ this.owner = owner;
+ this.configChangedEvent = new YAHOO.util.CustomEvent("configChanged");
+ this.queueInProgress = false;
+
+ /* Private Members */
+
+ var config = {};
+ var initialConfig = {};
+ var eventQueue = [];
+
+ /**
+ * @private
+ * Fires a configuration property event using the specified value.
+ * @param {string} key The configuration property's name
+ * @param {value} object The value of the correct type for the property
+ */
+ var fireEvent = function( key, value ) {
+ key = key.toLowerCase();
+
+ var property = config[key];
+
+ if (typeof property != 'undefined' && property.event) {
+ property.event.fire(value);
+ }
+ }
+ /* End Private Members */
+
+ this.addProperty = function( key, propertyObject ) {
+ key = key.toLowerCase();
+
+ config[key] = propertyObject;
+
+ propertyObject.event = new YAHOO.util.CustomEvent(key);
+ propertyObject.key = key;
+
+ if (propertyObject.handler) {
+ propertyObject.event.subscribe(propertyObject.handler, this.owner, true);
+ }
+
+ this.setProperty(key, propertyObject.value, true);
+
+ if (! propertyObject.suppressEvent) {
+ this.queueProperty(key, propertyObject.value);
+ }
+ }
+
+ this.getConfig = function() {
+ var cfg = {};
+
+ for (var prop in config) {
+ var property = config[prop]
+ if (typeof property != 'undefined' && property.event) {
+ cfg[prop] = property.value;
+ }
+ }
+
+ return cfg;
+ }
+
+ this.getProperty = function(key) {
+ key = key.toLowerCase();
+
+ var property = config[key];
+ if (typeof property != 'undefined' && property.event) {
+ return property.value;
+ } else {
+ return undefined;
+ }
+ }
+
+ this.resetProperty = function(key) {
+ key = key.toLowerCase();
+
+ var property = config[key];
+ if (typeof property != 'undefined' && property.event) {
+ this.setProperty(key, initialConfig[key].value);
+ } else {
+ return undefined;
+ }
+ }
+
+ this.setProperty = function(key, value, silent) {
+ key = key.toLowerCase();
+
+ if (this.queueInProgress && ! silent) {
+ this.queueProperty(key,value); // Currently running through a queue...
+ return true;
+ } else {
+ var property = config[key];
+ if (typeof property != 'undefined' && property.event) {
+ if (property.validator && ! property.validator(value)) { // validator
+ return false;
+ } else {
+ property.value = value;
+ if (! silent) {
+ fireEvent(key, value);
+ this.configChangedEvent.fire([key, value]);
+ }
+ return true;
+ }
+ } else {
+ return false;
+ }
+ }
+ }
+
+ this.queueProperty = function(key, value) {
+ key = key.toLowerCase();
+
+ var property = config[key];
+
+ if (typeof property != 'undefined' && property.event) {
+ if (typeof value != 'undefined' && property.validator && ! property.validator(value)) { // validator
+ return false;
+ } else {
+
+ if (typeof value != 'undefined') {
+ property.value = value;
+ } else {
+ value = property.value;
+ }
+
+ var foundDuplicate = false;
+
+ for (var i=0;i<eventQueue.length;i++) {
+ var queueItem = eventQueue[i];
+
+ if (queueItem) {
+ var queueItemKey = queueItem[0];
+ var queueItemValue = queueItem[1];
+
+ if (queueItemKey.toLowerCase() == key) {
+ // found a dupe... push to end of queue, null current item, and break
+ eventQueue[i] = null;
+ eventQueue.push([key, (typeof value != 'undefined' ? value : queueItemValue)]);
+ foundDuplicate = true;
+ break;
+ }
+ }
+ }
+
+ if (! foundDuplicate && typeof value != 'undefined') { // this is a refire, or a new property in the queue
+ eventQueue.push([key, value]);
+ }
+ }
+
+ if (property.supercedes) {
+ for (var s=0;s<property.supercedes.length;s++) {
+ var supercedesCheck = property.supercedes[s];
+
+ for (var q=0;q<eventQueue.length;q++) {
+ var queueItemCheck = eventQueue[q];
+
+ if (queueItemCheck) {
+ var queueItemCheckKey = queueItemCheck[0];
+ var queueItemCheckValue = queueItemCheck[1];
+
+ if ( queueItemCheckKey.toLowerCase() == supercedesCheck.toLowerCase() ) {
+ eventQueue.push([queueItemCheckKey, queueItemCheckValue]);
+ eventQueue[q] = null;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+ this.refireEvent = function(key) {
+ key = key.toLowerCase();
+
+ var property = config[key];
+ if (typeof property != 'undefined' && property.event && typeof property.value != 'undefined') {
+ if (this.queueInProgress) {
+ this.queueProperty(key);
+ } else {
+ fireEvent(key, property.value);
+ }
+ }
+ }
+
+ this.applyConfig = function(userConfig, init) {
+ if (init) {
+ initialConfig = userConfig;
+ }
+ for (var prop in userConfig) {
+ this.queueProperty(prop, userConfig[prop]);
+ }
+ }
+
+ this.refresh = function() {
+ for (var prop in config) {
+ this.refireEvent(prop);
+ }
+ }
+
+ this.fireQueue = function() {
+ this.queueInProgress = true;
+ for (var i=0;i<eventQueue.length;i++) {
+ var queueItem = eventQueue[i];
+ if (queueItem) {
+ var key = queueItem[0];
+ var value = queueItem[1];
+
+ var property = config[key];
+ property.value = value;
+
+ fireEvent(key,value);
+ }
+ }
+
+ this.queueInProgress = false;
+ eventQueue = new Array();
+ }
+
+ this.subscribeToConfigEvent = function(key, handler, obj, override) {
+ key = key.toLowerCase();
+
+ var property = config[key];
+ if (typeof property != 'undefined' && property.event) {
+ if (! YAHOO.util.Config.alreadySubscribed(property.event, handler, obj)) {
+ property.event.subscribe(handler, obj, override);
+ }
+ return true;
+ } else {
+ return false;
+ }
+ }
+
+
+ this.unsubscribeFromConfigEvent = function(key, handler, obj) {
+ key = key.toLowerCase();
+
+ var property = config[key];
+ if (typeof property != 'undefined' && property.event) {
+ return property.event.unsubscribe(handler, obj);
+ } else {
+ return false;
+ }
+ }
+
+ this.toString = function() {
+ var output = "Config";
+ if (this.owner) {
+ output += " [" + this.owner.toString() + "]";
+ }
+ return output;
+ }
+
+ this.outputEventQueue = function() {
+ var output = "";
+ for (var q=0;q<eventQueue.length;q++) {
+ var queueItem = eventQueue[q];
+ if (queueItem) {
+ output += queueItem[0] + "=" + queueItem[1] + ", ";
+ }
+ }
+ return output;
+ }
+}
+
+/**
+* Checks to determine if a particular function/object pair are already subscribed to the specified CustomEvent
+* @param {YAHOO.util.CustomEvent} evt The CustomEvent for which to check the subscriptions
+* @param {Function} fn The function to look for in the subscribers list
+* @param {object} obj The execution scope object for the subscription
+* @return {boolean} true, if the function/object pair is already subscribed to the CustomEvent passed in
+*/
+YAHOO.util.Config.alreadySubscribed = function(evt, fn, obj) {
+ for (var e=0;e<evt.subscribers.length;e++) {
+ var subsc = evt.subscribers[e];
+ if (subsc && subsc.obj == obj && subsc.fn == fn) {
+ return true;
+ break;
+ }
+ }
+ return false;
+}
+
+/**
+* @class
+* Module is a JavaScript representation of the Standard Module Format. Standard Module Format is a simple standard for markup containers where child nodes representing the header, body, and footer of the content are denoted using the CSS classes "hd", "bd", and "ft" respectively. Module is the base class for all other classes in the YUI Container package.
+* @param {string} el The element ID representing the Module <em>OR</em>
+* @param {Element} el The element representing the Module
+* @param {object} userConfig The configuration object literal containing the configuration that should be set for this module. See configuration documentation for more details.
+* @constructor
+*/
+YAHOO.widget.Module = function(el, userConfig) {
+ if (el) {
+ this.init(el, userConfig);
+ }
+}
+
+/**
+* Constant representing the prefix path to use for non-secure images
+* @type string
+*/
+YAHOO.widget.Module.IMG_ROOT = "http://us.i1.yimg.com/us.yimg.com/i/";
+
+/**
+* Constant representing the prefix path to use for securely served images
+* @type string
+*/
+YAHOO.widget.Module.IMG_ROOT_SSL = "https://a248.e.akamai.net/sec.yimg.com/i/";
+
+/**
+* Constant for the default CSS class name that represents a Module
+* @type string
+* @final
+*/
+YAHOO.widget.Module.CSS_MODULE = "module";
+
+/**
+* Constant representing the module header
+* @type string
+* @final
+*/
+YAHOO.widget.Module.CSS_HEADER = "hd";
+
+/**
+* Constant representing the module body
+* @type string
+* @final
+*/
+YAHOO.widget.Module.CSS_BODY = "bd";
+
+/**
+* Constant representing the module footer
+* @type string
+* @final
+*/
+YAHOO.widget.Module.CSS_FOOTER = "ft";
+
+/**
+* Constant representing the url for the "src" attribute of the iframe used to monitor changes to the browser's base font size
+* @type string
+* @final
+*/
+YAHOO.widget.Module.RESIZE_MONITOR_SECURE_URL = null;
+
+YAHOO.widget.Module.prototype = {
+
+ /**
+ * The class's constructor function
+ * @type function
+ */
+ constructor : YAHOO.widget.Module,
+
+ /**
+ * The main module element that contains the header, body, and footer
+ * @type Element
+ */
+ element : null,
+
+ /**
+ * The header element, denoted with CSS class "hd"
+ * @type Element
+ */
+ header : null,
+
+ /**
+ * The body element, denoted with CSS class "bd"
+ * @type Element
+ */
+ body : null,
+
+ /**
+ * The footer element, denoted with CSS class "ft"
+ * @type Element
+ */
+ footer : null,
+
+ /**
+ * The id of the element
+ * @type string
+ */
+ id : null,
+
+ /**
+ * Array of elements
+ * @type Element[]
+ */
+ childNodesInDOM : null,
+
+ /**
+ * The string representing the image root
+ * @type string
+ */
+ imageRoot : YAHOO.widget.Module.IMG_ROOT,
+
+ /**
+ * CustomEvent fired prior to class initalization.
+ * args: class reference of the initializing class, such as this.beforeInitEvent.fire(YAHOO.widget.Module)
+ * @type YAHOO.util.CustomEvent
+ */
+ beforeInitEvent : null,
+
+ /**
+ * CustomEvent fired after class initalization.
+ * args: class reference of the initializing class, such as this.initEvent.fire(YAHOO.widget.Module)
+ * @type YAHOO.util.CustomEvent
+ */
+ initEvent : null,
+
+ /**
+ * CustomEvent fired when the Module is appended to the DOM
+ * args: none
+ * @type YAHOO.util.CustomEvent
+ */
+ appendEvent : null,
+
+ /**
+ * CustomEvent fired before the Module is rendered
+ * args: none
+ * @type YAHOO.util.CustomEvent
+ */
+ beforeRenderEvent : null,
+
+ /**
+ * CustomEvent fired after the Module is rendered
+ * args: none
+ * @type YAHOO.util.CustomEvent
+ */
+ renderEvent : null,
+
+ /**
+ * CustomEvent fired when the header content of the Module is modified
+ * args: string/element representing the new header content
+ * @type YAHOO.util.CustomEvent
+ */
+ changeHeaderEvent : null,
+
+ /**
+ * CustomEvent fired when the body content of the Module is modified
+ * args: string/element representing the new body content
+ * @type YAHOO.util.CustomEvent
+ */
+ changeBodyEvent : null,
+
+ /**
+ * CustomEvent fired when the footer content of the Module is modified
+ * args: string/element representing the new footer content
+ * @type YAHOO.util.CustomEvent
+ */
+ changeFooterEvent : null,
+
+ /**
+ * CustomEvent fired when the content of the Module is modified
+ * args: none
+ * @type YAHOO.util.CustomEvent
+ */
+ changeContentEvent : null,
+
+ /**
+ * CustomEvent fired when the Module is destroyed
+ * args: none
+ * @type YAHOO.util.CustomEvent
+ */
+ destroyEvent : null,
+
+ /**
+ * CustomEvent fired before the Module is shown
+ * args: none
+ * @type YAHOO.util.CustomEvent
+ */
+ beforeShowEvent : null,
+
+ /**
+ * CustomEvent fired after the Module is shown
+ * args: none
+ * @type YAHOO.util.CustomEvent
+ */
+ showEvent : null,
+
+ /**
+ * CustomEvent fired before the Module is hidden
+ * args: none
+ * @type YAHOO.util.CustomEvent
+ */
+ beforeHideEvent : null,
+
+ /**
+ * CustomEvent fired after the Module is hidden
+ * args: none
+ * @type YAHOO.util.CustomEvent
+ */
+ hideEvent : null,
+
+ /**
+ * Initializes the custom events for Module which are fired automatically at appropriate times by the Module class.
+ */
+ initEvents : function() {
+
+ this.beforeInitEvent = new YAHOO.util.CustomEvent("beforeInit");
+ this.initEvent = new YAHOO.util.CustomEvent("init");
+
+ this.appendEvent = new YAHOO.util.CustomEvent("append");
+
+ this.beforeRenderEvent = new YAHOO.util.CustomEvent("beforeRender");
+ this.renderEvent = new YAHOO.util.CustomEvent("render");
+
+ this.changeHeaderEvent = new YAHOO.util.CustomEvent("changeHeader");
+ this.changeBodyEvent = new YAHOO.util.CustomEvent("changeBody");
+ this.changeFooterEvent = new YAHOO.util.CustomEvent("changeFooter");
+
+ this.changeContentEvent = new YAHOO.util.CustomEvent("changeContent");
+
+ this.destroyEvent = new YAHOO.util.CustomEvent("destroy");
+ this.beforeShowEvent = new YAHOO.util.CustomEvent("beforeShow");
+ this.showEvent = new YAHOO.util.CustomEvent("show");
+ this.beforeHideEvent = new YAHOO.util.CustomEvent("beforeHide");
+ this.hideEvent = new YAHOO.util.CustomEvent("hide");
+ },
+
+ /**
+ * String representing the current user-agent platform
+ * @type string
+ */
+ platform : function() {
+ var ua = navigator.userAgent.toLowerCase();
+ if (ua.indexOf("windows") != -1 || ua.indexOf("win32") != -1) {
+ return "windows";
+ } else if (ua.indexOf("macintosh") != -1) {
+ return "mac";
+ } else {
+ return false;
+ }
+ }(),
+
+ /**
+ * String representing the current user-agent browser
+ * @type string
+ */
+ browser : function() {
+ var ua = navigator.userAgent.toLowerCase();
+ if (ua.indexOf('opera')!=-1) { // Opera (check first in case of spoof)
+ return 'opera';
+ } else if (ua.indexOf('msie 7')!=-1) { // IE7
+ return 'ie7';
+ } else if (ua.indexOf('msie') !=-1) { // IE
+ return 'ie';
+ } else if (ua.indexOf('safari')!=-1) { // Safari (check before Gecko because it includes "like Gecko")
+ return 'safari';
+ } else if (ua.indexOf('gecko') != -1) { // Gecko
+ return 'gecko';
+ } else {
+ return false;
+ }
+ }(),
+
+ /**
+ * Boolean representing whether or not the current browsing context is secure (https)
+ * @type boolean
+ */
+ isSecure : function() {
+ if (window.location.href.toLowerCase().indexOf("https") == 0) {
+ return true;
+ } else {
+ return false;
+ }
+ }(),
+
+ /**
+ * Initializes the custom events for Module which are fired automatically at appropriate times by the Module class.
+ */
+ initDefaultConfig : function() {
+ // Add properties //
+
+ this.cfg.addProperty("visible", { value:true, handler:this.configVisible, validator:this.cfg.checkBoolean } );
+ this.cfg.addProperty("effect", { suppressEvent:true, supercedes:["visible"] } );
+ this.cfg.addProperty("monitorresize", { value:true, handler:this.configMonitorResize } );
+ },
+
+ /**
+ * The Module class's initialization method, which is executed for Module and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present.
+ * @param {string} el The element ID representing the Module <em>OR</em>
+ * @param {Element} el The element representing the Module
+ * @param {object} userConfig The configuration object literal containing the configuration that should be set for this module. See configuration documentation for more details.
+ */
+ init : function(el, userConfig) {
+
+ this.initEvents();
+
+ this.beforeInitEvent.fire(YAHOO.widget.Module);
+
+ this.cfg = new YAHOO.util.Config(this);
+
+ if (this.isSecure) {
+ this.imageRoot = YAHOO.widget.Module.IMG_ROOT_SSL;
+ }
+
+ if (typeof el == "string") {
+ var elId = el;
+
+ el = document.getElementById(el);
+ if (! el) {
+ el = document.createElement("DIV");
+ el.id = elId;
+ }
+ }
+
+ this.element = el;
+
+ if (el.id) {
+ this.id = el.id;
+ }
+
+ var childNodes = this.element.childNodes;
+
+ if (childNodes) {
+ for (var i=0;i<childNodes.length;i++) {
+ var child = childNodes[i];
+ switch (child.className) {
+ case YAHOO.widget.Module.CSS_HEADER:
+ this.header = child;
+ break;
+ case YAHOO.widget.Module.CSS_BODY:
+ this.body = child;
+ break;
+ case YAHOO.widget.Module.CSS_FOOTER:
+ this.footer = child;
+ break;
+ }
+ }
+ }
+
+ this.initDefaultConfig();
+
+ YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Module.CSS_MODULE);
+
+ if (userConfig) {
+ this.cfg.applyConfig(userConfig, true);
+ }
+
+ // Subscribe to the fireQueue() method of Config so that any queued configuration changes are
+ // excecuted upon render of the Module
+ if (! YAHOO.util.Config.alreadySubscribed(this.renderEvent, this.cfg.fireQueue, this.cfg)) {
+ this.renderEvent.subscribe(this.cfg.fireQueue, this.cfg, true);
+ }
+
+ this.initEvent.fire(YAHOO.widget.Module);
+ },
+
+ /**
+ * Initialized an empty DOM element that is placed out of the visible area that can be used to detect text resize.
+ */
+ initResizeMonitor : function() {
+
+ if(this.browser != "opera") {
+
+ var resizeMonitor = document.getElementById("_yuiResizeMonitor");
+
+ if (! resizeMonitor) {
+
+ resizeMonitor = document.createElement("iframe");
+
+ var bIE = (this.browser.indexOf("ie") === 0);
+
+ if(this.isSecure && this.RESIZE_MONITOR_SECURE_URL && bIE) {
+
+ resizeMonitor.src = this.RESIZE_MONITOR_SECURE_URL;
+
+ }
+
+ resizeMonitor.id = "_yuiResizeMonitor";
+ resizeMonitor.style.visibility = "hidden";
+
+ document.body.appendChild(resizeMonitor);
+
+ resizeMonitor.style.width = "10em";
+ resizeMonitor.style.height = "10em";
+ resizeMonitor.style.position = "absolute";
+
+ var nLeft = -1 * resizeMonitor.offsetWidth,
+ nTop = -1 * resizeMonitor.offsetHeight;
+
+ resizeMonitor.style.top = nTop + "px";
+ resizeMonitor.style.left = nLeft + "px";
+ resizeMonitor.style.borderStyle = "none";
+ resizeMonitor.style.borderWidth = "0";
+ YAHOO.util.Dom.setStyle(resizeMonitor, "opacity", "0");
+
+ resizeMonitor.style.visibility = "visible";
+
+ if(!bIE) {
+
+ var doc = resizeMonitor.contentWindow.document;
+
+ doc.open();
+ doc.close();
+
+ }
+
+ }
+
+ if(resizeMonitor && resizeMonitor.contentWindow) {
+
+ this.resizeMonitor = resizeMonitor;
+
+ YAHOO.util.Event.addListener(this.resizeMonitor.contentWindow, "resize", this.onDomResize, this, true);
+
+ }
+
+ }
+
+ },
+
+ /**
+ * Event handler fired when the resize monitor element is resized.
+ */
+ onDomResize : function(e, obj) {
+
+ var nLeft = -1 * this.resizeMonitor.offsetWidth,
+ nTop = -1 * this.resizeMonitor.offsetHeight;
+
+ this.resizeMonitor.style.top = nTop + "px";
+ this.resizeMonitor.style.left = nLeft + "px";
+
+ },
+
+ /**
+ * Sets the Module's header content to the HTML specified, or appends the passed element to the header. If no header is present, one will be automatically created.
+ * @param {string} headerContent The HTML used to set the header <em>OR</em>
+ * @param {Element} headerContent The Element to append to the header
+ */
+ setHeader : function(headerContent) {
+ if (! this.header) {
+ this.header = document.createElement("DIV");
+ this.header.className = YAHOO.widget.Module.CSS_HEADER;
+ }
+
+ if (typeof headerContent == "string") {
+ this.header.innerHTML = headerContent;
+ } else {
+ this.header.innerHTML = "";
+ this.header.appendChild(headerContent);
+ }
+
+ this.changeHeaderEvent.fire(headerContent);
+ this.changeContentEvent.fire();
+ },
+
+ /**
+ * Appends the passed element to the header. If no header is present, one will be automatically created.
+ * @param {Element} element The element to append to the header
+ */
+ appendToHeader : function(element) {
+ if (! this.header) {
+ this.header = document.createElement("DIV");
+ this.header.className = YAHOO.widget.Module.CSS_HEADER;
+ }
+
+ this.header.appendChild(element);
+ this.changeHeaderEvent.fire(element);
+ this.changeContentEvent.fire();
+ },
+
+ /**
+ * Sets the Module's body content to the HTML specified, or appends the passed element to the body. If no body is present, one will be automatically created.
+ * @param {string} bodyContent The HTML used to set the body <em>OR</em>
+ * @param {Element} bodyContent The Element to append to the body
+ */
+ setBody : function(bodyContent) {
+ if (! this.body) {
+ this.body = document.createElement("DIV");
+ this.body.className = YAHOO.widget.Module.CSS_BODY;
+ }
+
+ if (typeof bodyContent == "string")
+ {
+ this.body.innerHTML = bodyContent;
+ } else {
+ this.body.innerHTML = "";
+ this.body.appendChild(bodyContent);
+ }
+
+ this.changeBodyEvent.fire(bodyContent);
+ this.changeContentEvent.fire();
+ },
+
+ /**
+ * Appends the passed element to the body. If no body is present, one will be automatically created.
+ * @param {Element} element The element to append to the body
+ */
+ appendToBody : function(element) {
+ if (! this.body) {
+ this.body = document.createElement("DIV");
+ this.body.className = YAHOO.widget.Module.CSS_BODY;
+ }
+
+ this.body.appendChild(element);
+ this.changeBodyEvent.fire(element);
+ this.changeContentEvent.fire();
+ },
+
+ /**
+ * Sets the Module's footer content to the HTML specified, or appends the passed element to the footer. If no footer is present, one will be automatically created.
+ * @param {string} footerContent The HTML used to set the footer <em>OR</em>
+ * @param {Element} footerContent The Element to append to the footer
+ */
+ setFooter : function(footerContent) {
+ if (! this.footer) {
+ this.footer = document.createElement("DIV");
+ this.footer.className = YAHOO.widget.Module.CSS_FOOTER;
+ }
+
+ if (typeof footerContent == "string") {
+ this.footer.innerHTML = footerContent;
+ } else {
+ this.footer.innerHTML = "";
+ this.footer.appendChild(footerContent);
+ }
+
+ this.changeFooterEvent.fire(footerContent);
+ this.changeContentEvent.fire();
+ },
+
+ /**
+ * Appends the passed element to the footer. If no footer is present, one will be automatically created.
+ * @param {Element} element The element to append to the footer
+ */
+ appendToFooter : function(element) {
+ if (! this.footer) {
+ this.footer = document.createElement("DIV");
+ this.footer.className = YAHOO.widget.Module.CSS_FOOTER;
+ }
+
+ this.footer.appendChild(element);
+ this.changeFooterEvent.fire(element);
+ this.changeContentEvent.fire();
+ },
+
+ /**
+ * Renders the Module by inserting the elements that are not already in the main Module into their correct places. Optionally appends the Module to the specified node prior to the render's execution. NOTE: For Modules without existing markup, the appendToNode argument is REQUIRED. If this argument is ommitted and the current element is not present in the document, the function will return false, indicating that the render was a failure.
+ * @param {string} appendToNode The element id to which the Module should be appended to prior to rendering <em>OR</em>
+ * @param {Element} appendToNode The element to which the Module should be appended to prior to rendering
+ * @param {Element} moduleElement OPTIONAL. The element that represents the actual Standard Module container.
+ * @return {boolean} Success or failure of the render
+ */
+ render : function(appendToNode, moduleElement) {
+ this.beforeRenderEvent.fire();
+
+ if (! moduleElement) {
+ moduleElement = this.element;
+ }
+
+ var me = this;
+ var appendTo = function(element) {
+ if (typeof element == "string") {
+ element = document.getElementById(element);
+ }
+
+ if (element) {
+ element.appendChild(me.element);
+ me.appendEvent.fire();
+ }
+ }
+
+ if (appendToNode) {
+ appendTo(appendToNode);
+ } else { // No node was passed in. If the element is not pre-marked up, this fails
+ if (! YAHOO.util.Dom.inDocument(this.element)) {
+ return false;
+ }
+ }
+
+ // Need to get everything into the DOM if it isn't already
+
+ if (this.header && ! YAHOO.util.Dom.inDocument(this.header)) {
+ // There is a header, but it's not in the DOM yet... need to add it
+ var firstChild = moduleElement.firstChild;
+ if (firstChild) { // Insert before first child if exists
+ moduleElement.insertBefore(this.header, firstChild);
+ } else { // Append to empty body because there are no children
+ moduleElement.appendChild(this.header);
+ }
+ }
+
+ if (this.body && ! YAHOO.util.Dom.inDocument(this.body)) {
+ // There is a body, but it's not in the DOM yet... need to add it
+ if (this.footer && YAHOO.util.Dom.isAncestor(this.moduleElement, this.footer)) { // Insert before footer if exists in DOM
+ moduleElement.insertBefore(this.body, this.footer);
+ } else { // Append to element because there is no footer
+ moduleElement.appendChild(this.body);
+ }
+ }
+
+ if (this.footer && ! YAHOO.util.Dom.inDocument(this.footer)) {
+ // There is a footer, but it's not in the DOM yet... need to add it
+ moduleElement.appendChild(this.footer);
+ }
+
+ this.renderEvent.fire();
+ return true;
+ },
+
+ /**
+ * Removes the Module element from the DOM and sets all child elements to null.
+ */
+ destroy : function() {
+ if (this.element) {
+ var parent = this.element.parentNode;
+ }
+ if (parent) {
+ parent.removeChild(this.element);
+ }
+
+ this.element = null;
+ this.header = null;
+ this.body = null;
+ this.footer = null;
+
+ this.destroyEvent.fire();
+ },
+
+ /**
+ * Shows the Module element by setting the visible configuration property to true. Also fires two events: beforeShowEvent prior to the visibility change, and showEvent after.
+ */
+ show : function() {
+ this.cfg.setProperty("visible", true);
+ },
+
+ /**
+ * Hides the Module element by setting the visible configuration property to false. Also fires two events: beforeHideEvent prior to the visibility change, and hideEvent after.
+ */
+ hide : function() {
+ this.cfg.setProperty("visible", false);
+ },
+
+ // BUILT-IN EVENT HANDLERS FOR MODULE //
+
+ /**
+ * Default event handler for changing the visibility property of a Module. By default, this is achieved by switching the "display" style between "block" and "none".
+ * This method is responsible for firing showEvent and hideEvent.
+ */
+ configVisible : function(type, args, obj) {
+ var visible = args[0];
+ if (visible) {
+ this.beforeShowEvent.fire();
+ YAHOO.util.Dom.setStyle(this.element, "display", "block");
+ this.showEvent.fire();
+ } else {
+ this.beforeHideEvent.fire();
+ YAHOO.util.Dom.setStyle(this.element, "display", "none");
+ this.hideEvent.fire();
+ }
+ },
+
+ /**
+ * Default event handler for the "monitorresize" configuration property
+ */
+ configMonitorResize : function(type, args, obj) {
+ var monitor = args[0];
+ if (monitor) {
+ this.initResizeMonitor();
+ } else {
+ YAHOO.util.Event.removeListener(this.resizeMonitor, "resize", this.onDomResize);
+ this.resizeMonitor = null;
+ }
+ }
+}
+
+/**
+* Returns a string representation of the object.
+* @type string
+*/
+YAHOO.widget.Module.prototype.toString = function() {
+ return "Module " + this.id;
+}
+
+/**
+* @class Overlay is a Module that is absolutely positioned above the page flow. It has convenience methods for positioning and sizing, as well as options for controlling zIndex and constraining the Overlay's position to the current visible viewport. Overlay also contains a dynamicly generated IFRAME which is placed beneath it for Internet Explorer 6 and 5.x so that it will be properly rendered above SELECT elements.
+* @param {string} el The element ID representing the Overlay <em>OR</em>
+* @param {Element} el The element representing the Overlay
+* @param {object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details.
+* @constructor
+*/
+YAHOO.widget.Overlay = function(el, userConfig) {
+ YAHOO.widget.Overlay.superclass.constructor.call(this, el, userConfig);
+}
+
+YAHOO.extend(YAHOO.widget.Overlay, YAHOO.widget.Module);
+
+/**
+* The URL of the blank image that will be placed in the iframe
+* @type string
+* @final
+*/
+YAHOO.widget.Overlay.IFRAME_SRC = "promo/m/irs/blank.gif";
+
+/**
+* Constant representing the top left corner of an element, used for configuring the context element alignment
+* @type string
+* @final
+*/
+YAHOO.widget.Overlay.TOP_LEFT = "tl";
+
+/**
+* Constant representing the top right corner of an element, used for configuring the context element alignment
+* @type string
+* @final
+*/
+YAHOO.widget.Overlay.TOP_RIGHT = "tr";
+
+/**
+* Constant representing the top bottom left corner of an element, used for configuring the context element alignment
+* @type string
+* @final
+*/
+YAHOO.widget.Overlay.BOTTOM_LEFT = "bl";
+
+/**
+* Constant representing the bottom right corner of an element, used for configuring the context element alignment
+* @type string
+* @final
+*/
+YAHOO.widget.Overlay.BOTTOM_RIGHT = "br";
+
+/**
+* Constant representing the default CSS class used for an Overlay
+* @type string
+* @final
+*/
+YAHOO.widget.Overlay.CSS_OVERLAY = "overlay";
+
+/**
+* CustomEvent fired before the Overlay is moved.
+* args: x,y that the Overlay will be moved to
+* @type YAHOO.util.CustomEvent
+*/
+YAHOO.widget.Overlay.prototype.beforeMoveEvent = null;
+
+/**
+* CustomEvent fired after the Overlay is moved.
+* args: x,y that the Overlay was moved to
+* @type YAHOO.util.CustomEvent
+*/
+YAHOO.widget.Overlay.prototype.moveEvent = null;
+
+/**
+* The Overlay initialization method, which is executed for Overlay and all of its subclasses. This method is automatically called by the constructor, and sets up all DOM references for pre-existing markup, and creates required markup if it is not already present.
+* @param {string} el The element ID representing the Overlay <em>OR</em>
+* @param {Element} el The element representing the Overlay
+* @param {object} userConfig The configuration object literal containing the configuration that should be set for this Overlay. See configuration documentation for more details.
+*/
+YAHOO.widget.Overlay.prototype.init = function(el, userConfig) {
+ YAHOO.widget.Overlay.superclass.init.call(this, el/*, userConfig*/); // Note that we don't pass the user config in here yet because we only want it executed once, at the lowest subclass level
+
+ this.beforeInitEvent.fire(YAHOO.widget.Overlay);
+
+ YAHOO.util.Dom.addClass(this.element, YAHOO.widget.Overlay.CSS_OVERLAY);
+
+ if (userConfig) {
+ this.cfg.applyConfig(userConfig, true);
+ }
+
+ if (this.platform == "mac" && this.browser == "gecko") {
+ if (! YAHOO.util.Config.alreadySubscribed(this.showEvent,this.showMacGeckoScrollbars,this)) {
+ this.showEvent.subscribe(this.showMacGeckoScrollbars,this,true);
+ }
+ if (! YAHOO.util.Config.alreadySubscribed(this.hideEvent,this.hideMacGeckoScrollbars,this)) {
+ this.hideEvent.subscribe(this.hideMacGeckoScrollbars,this,true);
+ }
+ }
+
+ this.initEvent.fire(YAHOO.widget.Overlay);
+
+}
+
+/**
+* Initializes the custom events for Overlay which are fired automatically at appropriate times by the Overlay class.
+*/
+YAHOO.widget.Overlay.prototype.initEvents = function() {
+ YAHOO.widget.Overlay.superclass.initEvents.call(this);
+
+ this.beforeMoveEvent = new YAHOO.util.CustomEvent("beforeMove", this);
+ this.moveEvent = new YAHOO.util.CustomEvent("move", this);
+}
+
+/**
+* Initializes the class's configurable properties which can be changed using the Overlay's Config object (cfg).
+*/
+YAHOO.widget.Overlay.prototype.initDefaultConfig = function() {
+ YAHOO.widget.Overlay.superclass.initDefaultConfig.call(this);
+
+ // Add overlay config properties //
+ this.cfg.addProperty("x", { handler:this.configX, validator:this.cfg.checkNumber, suppressEvent:true, supercedes:["iframe"] } );
+ this.cfg.addProperty("y", { handler:this.configY, validator:this.cfg.checkNumber, suppressEvent:true, supercedes:["iframe"] } );
+ this.cfg.addProperty("xy",{ handler:this.configXY, suppressEvent:true, supercedes:["iframe"] } );
+
+ this.cfg.addProperty("context", { handler:this.configContext, suppressEvent:true, supercedes:["iframe"] } );
+ this.cfg.addProperty("fixedcenter", { value:false, handler:this.configFixedCenter, validator:this.cfg.checkBoolean, supercedes:["iframe","visible"] } );
+
+ this.cfg.addProperty("width", { handler:this.configWidth, suppressEvent:true, supercedes:["iframe"] } );
+ this.cfg.addProperty("height", { handler:this.configHeight, suppressEvent:true, supercedes:["iframe"] } );
+
+ this.cfg.addProperty("zIndex", { value:null, handler:this.configzIndex } );
+
+ this.cfg.addProperty("constraintoviewport", { value:false, handler:this.configConstrainToViewport, validator:this.cfg.checkBoolean, supercedes:["iframe","x","y","xy"] } );
+ this.cfg.addProperty("iframe", { value:(this.browser == "ie" ? true : false), handler:this.configIframe, validator:this.cfg.checkBoolean, supercedes:["zIndex"] } );
+}
+
+/**
+* Moves the Overlay to the specified position. This function is identical to calling this.cfg.setProperty("xy", [x,y]);
+* @param {int} x The Overlay's new x position
+* @param {int} y The Overlay's new y position
+*/
+YAHOO.widget.Overlay.prototype.moveTo = function(x, y) {
+ this.cfg.setProperty("xy",[x,y]);
+}
+
+/**
+* Adds a special CSS class to the Overlay when Mac/Gecko is in use, to work around a Gecko bug where
+* scrollbars cannot be hidden. See https://bugzilla.mozilla.org/show_bug.cgi?id=187435
+*/
+YAHOO.widget.Overlay.prototype.hideMacGeckoScrollbars = function() {
+ YAHOO.util.Dom.removeClass(this.element, "show-scrollbars");
+ YAHOO.util.Dom.addClass(this.element, "hide-scrollbars");
+}
+
+/**
+* Removes a special CSS class from the Overlay when Mac/Gecko is in use, to work around a Gecko bug where
+* scrollbars cannot be hidden. See https://bugzilla.mozilla.org/show_bug.cgi?id=187435
+*/
+YAHOO.widget.Overlay.prototype.showMacGeckoScrollbars = function() {
+ YAHOO.util.Dom.removeClass(this.element, "hide-scrollbars");
+ YAHOO.util.Dom.addClass(this.element, "show-scrollbars");
+}
+
+// BEGIN BUILT-IN PROPERTY EVENT HANDLERS //
+
+/**
+* The default event handler fired when the "visible" property is changed. This method is responsible for firing showEvent and hideEvent.
+*/
+YAHOO.widget.Overlay.prototype.configVisible = function(type, args, obj) {
+ var visible = args[0];
+ var currentVis = YAHOO.util.Dom.getStyle(this.element, "visibility");
+
+ var effect = this.cfg.getProperty("effect");
+
+ var effectInstances = new Array();
+ if (effect) {
+ if (effect instanceof Array) {
+ for (var i=0;i<effect.length;i++) {
+ var eff = effect[i];
+ effectInstances[effectInstances.length] = eff.effect(this, eff.duration);
+ }
+ } else {
+ effectInstances[effectInstances.length] = effect.effect(this, effect.duration);
+ }
+ }
+
+ var isMacGecko = (this.platform == "mac" && this.browser == "gecko");
+
+ if (visible) { // Show
+ if (isMacGecko) {
+ this.showMacGeckoScrollbars();
+ }
+
+ if (effect) { // Animate in
+ if (visible) { // Animate in if not showing
+ if (currentVis != "visible") {
+ this.beforeShowEvent.fire();
+ for (var i=0;i<effectInstances.length;i++) {
+ var e = effectInstances[i];
+ if (i == 0 && ! YAHOO.util.Config.alreadySubscribed(e.animateInCompleteEvent,this.showEvent.fire,this.showEvent)) {
+ e.animateInCompleteEvent.subscribe(this.showEvent.fire,this.showEvent,true); // Delegate showEvent until end of animateInComplete
+ }
+ e.animateIn();
+ }
+ }
+ }
+ } else { // Show
+ if (currentVis != "visible") {
+ this.beforeShowEvent.fire();
+ YAHOO.util.Dom.setStyle(this.element, "visibility", "visible");
+ this.cfg.refireEvent("iframe");
+ this.showEvent.fire();
+ }
+ }
+
+ } else { // Hide
+ if (isMacGecko) {
+ this.hideMacGeckoScrollbars();
+ }
+
+ if (effect) { // Animate out if showing
+ if (currentVis == "visible") {
+ this.beforeHideEvent.fire();
+ for (var i=0;i<effectInstances.length;i++) {
+ var e = effectInstances[i];
+ if (i == 0 && ! YAHOO.util.Config.alreadySubscribed(e.animateOutCompleteEvent,this.hideEvent.fire,this.hideEvent)) {
+ e.animateOutCompleteEvent.subscribe(this.hideEvent.fire,this.hideEvent,true); // Delegate hideEvent until end of animateOutComplete
+ }
+ e.animateOut();
+ }
+ }
+ } else { // Simple hide
+ if (currentVis == "visible") {
+ this.beforeHideEvent.fire();
+ YAHOO.util.Dom.setStyle(this.element, "visibility", "hidden");
+ this.cfg.refireEvent("iframe");
+ this.hideEvent.fire();
+ }
+ }
+ }
+}
+
+/**
+* Center event handler used for centering on scroll/resize, but only if the Overlay is visible
+*/
+YAHOO.widget.Overlay.prototype.doCenterOnDOMEvent = function() {
+ if (this.cfg.getProperty("visible")) {
+ this.center();
+ }
+}
+
+/**
+* The default event handler fired when the "fixedcenter" property is changed.
+*/
+YAHOO.widget.Overlay.prototype.configFixedCenter = function(type, args, obj) {
+ var val = args[0];
+
+ if (val) {
+ this.center();
+
+ if (! YAHOO.util.Config.alreadySubscribed(this.beforeShowEvent, this.center, this)) {
+ this.beforeShowEvent.subscribe(this.center, this, true);
+ }
+
+ if (! YAHOO.util.Config.alreadySubscribed(YAHOO.widget.Overlay.windowResizeEvent, this.doCenterOnDOMEvent, this)) {
+ YAHOO.widget.Overlay.windowResizeEvent.subscribe(this.doCenterOnDOMEvent, this, true);
+ }
+
+ if (! YAHOO.util.Config.alreadySubscribed(YAHOO.widget.Overlay.windowScrollEvent, this.doCenterOnDOMEvent, this)) {
+ YAHOO.widget.Overlay.windowScrollEvent.subscribe( this.doCenterOnDOMEvent, this, true);
+ }
+ } else {
+ YAHOO.widget.Overlay.windowResizeEvent.unsubscribe(this.doCenterOnDOMEvent, this);
+ YAHOO.widget.Overlay.windowScrollEvent.unsubscribe(this.doCenterOnDOMEvent, this);
+ }
+}
+
+/**
+* The default event handler fired when the "height" property is changed.
+*/
+YAHOO.widget.Overlay.prototype.configHeight = function(type, args, obj) {
+ var height = args[0];
+ var el = this.element;
+ YAHOO.util.Dom.setStyle(el, "height", height);
+ this.cfg.refireEvent("iframe");
+}
+
+/**
+* The default event handler fired when the "width" property is changed.
+*/
+YAHOO.widget.Overlay.prototype.configWidth = function(type, args, obj) {
+ var width = args[0];
+ var el = this.element;
+ YAHOO.util.Dom.setStyle(el, "width", width);
+ this.cfg.refireEvent("iframe");
+}
+
+/**
+* The default event handler fired when the "zIndex" property is changed.
+*/
+YAHOO.widget.Overlay.prototype.configzIndex = function(type, args, obj) {
+ var zIndex = args[0];
+
+ var el = this.element;
+
+ if (! zIndex) {
+ zIndex = YAHOO.util.Dom.getStyle(el, "zIndex");
+ if (! zIndex || isNaN(zIndex)) {
+ zIndex = 0;
+ }
+ }
+
+ if (this.iframe) {
+ if (zIndex <= 0) {
+ zIndex = 1;
+ }
+ YAHOO.util.Dom.setStyle(this.iframe, "zIndex", (zIndex-1));
+ }
+
+ YAHOO.util.Dom.setStyle(el, "zIndex", zIndex);
+ this.cfg.setProperty("zIndex", zIndex, true);
+}
+
+/**
+* The default event handler fired when the "xy" property is changed.
+*/
+YAHOO.widget.Overlay.prototype.configXY = function(type, args, obj) {
+ var pos = args[0];
+ var x = pos[0];
+ var y = pos[1];
+
+ this.cfg.setProperty("x", x);
+ this.cfg.setProperty("y", y);
+
+ this.beforeMoveEvent.fire([x,y]);
+
+ x = this.cfg.getProperty("x");
+ y = this.cfg.getProperty("y");
+
+ this.cfg.refireEvent("iframe");
+ this.moveEvent.fire([x,y]);
+}
+
+/**
+* The default event handler fired when the "x" property is changed.
+*/
+YAHOO.widget.Overlay.prototype.configX = function(type, args, obj) {
+ var x = args[0];
+ var y = this.cfg.getProperty("y");
+
+ this.cfg.setProperty("x", x, true);
+ this.cfg.setProperty("y", y, true);
+
+ this.beforeMoveEvent.fire([x,y]);
+
+ x = this.cfg.getProperty("x");
+ y = this.cfg.getProperty("y");
+
+ YAHOO.util.Dom.setX(this.element, x, true);
+
+ this.cfg.setProperty("xy", [x, y], true);
+
+ this.cfg.refireEvent("iframe");
+ this.moveEvent.fire([x, y]);
+}
+
+/**
+* The default event handler fired when the "y" property is changed.
+*/
+YAHOO.widget.Overlay.prototype.configY = function(type, args, obj) {
+ var x = this.cfg.getProperty("x");
+ var y = args[0];
+
+ this.cfg.setProperty("x", x, true);
+ this.cfg.setProperty("y", y, true);
+
+ this.beforeMoveEvent.fire([x,y]);
+
+ x = this.cfg.getProperty("x");
+ y = this.cfg.getProperty("y");
+
+ YAHOO.util.Dom.setY(this.element, y, true);
+
+ this.cfg.setProperty("xy", [x, y], true);
+
+ this.cfg.refireEvent("iframe");
+ this.moveEvent.fire([x, y]);
+}
+
+/**
+* The default event handler fired when the "iframe" property is changed.
+*/
+YAHOO.widget.Overlay.prototype.configIframe = function(type, args, obj) {
+
+ var val = args[0];
+
+ var el = this.element;
+
+ var showIframe = function() {
+ if (this.iframe) {
+ this.iframe.style.display = "block";
+ }
+ }
+
+ var hideIframe = function() {
+ if (this.iframe) {
+ this.iframe.style.display = "none";
+ }
+ }
+
+ if (val) { // IFRAME shim is enabled
+
+ if (! YAHOO.util.Config.alreadySubscribed(this.showEvent, showIframe, this)) {
+ this.showEvent.subscribe(showIframe, this, true);
+ }
+ if (! YAHOO.util.Config.alreadySubscribed(this.hideEvent, hideIframe, this)) {
+ this.hideEvent.subscribe(hideIframe, this, true);
+ }
+
+ var x = this.cfg.getProperty("x");
+ var y = this.cfg.getProperty("y");
+
+ if (! x || ! y) {
+ this.syncPosition();
+ x = this.cfg.getProperty("x");
+ y = this.cfg.getProperty("y");
+ }
+
+ if (! isNaN(x) && ! isNaN(y)) {
+ if (! this.iframe) {
+ this.iframe = document.createElement("iframe");
+ if (this.isSecure) {
+ this.iframe.src = this.imageRoot + YAHOO.widget.Overlay.IFRAME_SRC;
+ }
+
+ var parent = el.parentNode;
+ if (parent) {
+ parent.appendChild(this.iframe);
+ } else {
+ document.body.appendChild(this.iframe);
+ }
+
+ YAHOO.util.Dom.setStyle(this.iframe, "position", "absolute");
+ YAHOO.util.Dom.setStyle(this.iframe, "border", "none");
+ YAHOO.util.Dom.setStyle(this.iframe, "margin", "0");
+ YAHOO.util.Dom.setStyle(this.iframe, "padding", "0");
+ YAHOO.util.Dom.setStyle(this.iframe, "opacity", "0");
+ if (this.cfg.getProperty("visible")) {
+ showIframe.call(this);
+ } else {
+ hideIframe.call(this);
+ }
+ }
+
+ var iframeDisplay = YAHOO.util.Dom.getStyle(this.iframe, "display");
+
+ if (iframeDisplay == "none") {
+ this.iframe.style.display = "block";
+ }
+
+ YAHOO.util.Dom.setXY(this.iframe, [x,y]);
+
+ var width = el.clientWidth;
+ var height = el.clientHeight;
+
+ YAHOO.util.Dom.setStyle(this.iframe, "width", (width+2) + "px");
+ YAHOO.util.Dom.setStyle(this.iframe, "height", (height+2) + "px");
+
+ if (iframeDisplay == "none") {
+ this.iframe.style.display = "none";
+ }
+ }
+ } else {
+ if (this.iframe) {
+ this.iframe.style.display = "none";
+ }
+ this.showEvent.unsubscribe(showIframe, this);
+ this.hideEvent.unsubscribe(hideIframe, this);
+ }
+}
+
+
+/**
+* The default event handler fired when the "constraintoviewport" property is changed.
+*/
+YAHOO.widget.Overlay.prototype.configConstrainToViewport = function(type, args, obj) {
+ var val = args[0];
+ if (val) {
+ if (! YAHOO.util.Config.alreadySubscribed(this.beforeMoveEvent, this.enforceConstraints, this)) {
+ this.beforeMoveEvent.subscribe(this.enforceConstraints, this, true);
+ }
+ } else {
+ this.beforeMoveEvent.unsubscribe(this.enforceConstraints, this);
+ }
+}
+
+/**
+* The default event handler fired when the "context" property is changed.
+*/
+YAHOO.widget.Overlay.prototype.configContext = function(type, args, obj) {
+ var contextArgs = args[0];
+
+ if (contextArgs) {
+ var contextEl = contextArgs[0];
+ var elementMagnetCorner = contextArgs[1];
+ var contextMagnetCorner = contextArgs[2];
+
+ if (contextEl) {
+ if (typeof contextEl == "string") {
+ this.cfg.setProperty("context", [document.getElementById(contextEl),elementMagnetCorner,contextMagnetCorner], true);
+ }
+
+ if (elementMagnetCorner && contextMagnetCorner) {
+ this.align(elementMagnetCorner, contextMagnetCorner);
+ }
+ }
+ }
+}
+
+
+// END BUILT-IN PROPERTY EVENT HANDLERS //
+
+/**
+* Aligns the Overlay to its context element using the specified corner points (represented by the constants TOP_LEFT, TOP_RIGHT, BOTTOM_LEFT, and BOTTOM_RIGHT.
+* @param {string} elementAlign The string representing the corner of the Overlay that should be aligned to the context element
+* @param {string} contextAlign The corner of the context element that the elementAlign corner should stick to.
+*/
+YAHOO.widget.Overlay.prototype.align = function(elementAlign, contextAlign) {
+ var contextArgs = this.cfg.getProperty("context");
+ if (contextArgs) {
+ var context = contextArgs[0];
+
+ var element = this.element;
+ var me = this;
+
+ if (! elementAlign) {
+ elementAlign = contextArgs[1];
+ }
+
+ if (! contextAlign) {
+ contextAlign = contextArgs[2];
+ }
+
+ if (element && context) {
+ var elementRegion = YAHOO.util.Dom.getRegion(element);
+ var contextRegion = YAHOO.util.Dom.getRegion(context);
+
+ var doAlign = function(v,h) {
+ switch (elementAlign) {
+ case YAHOO.widget.Overlay.TOP_LEFT:
+ me.moveTo(h,v);
+ break;
+ case YAHOO.widget.Overlay.TOP_RIGHT:
+ me.moveTo(h-element.offsetWidth,v);
+ break;
+ case YAHOO.widget.Overlay.BOTTOM_LEFT:
+ me.moveTo(h,v-element.offsetHeight);
+ break;
+ case YAHOO.widget.Overlay.BOTTOM_RIGHT:
+ me.moveTo(h-element.offsetWidth,v-element.offsetHeight);
+ break;
+ }
+ }
+
+ switch (contextAlign) {
+ case YAHOO.widget.Overlay.TOP_LEFT:
+ doAlign(contextRegion.top, contextRegion.left);
+ break;
+ case YAHOO.widget.Overlay.TOP_RIGHT:
+ doAlign(contextRegion.top, contextRegion.right);
+ break;
+ case YAHOO.widget.Overlay.BOTTOM_LEFT:
+ doAlign(contextRegion.bottom, contextRegion.left);
+ break;
+ case YAHOO.widget.Overlay.BOTTOM_RIGHT:
+ doAlign(contextRegion.bottom, contextRegion.right);
+ break;
+ }
+ }
+ }
+}
+
+/**
+* The default event handler executed when the moveEvent is fired, if the "constraintoviewport" is set to true.
+*/
+YAHOO.widget.Overlay.prototype.enforceConstraints = function(type, args, obj) {
+ var pos = args[0];
+
+ var x = pos[0];
+ var y = pos[1];
+
+ var width = parseInt(this.cfg.getProperty("width"));
+
+ if (isNaN(width)) {
+ width = 0;
+ }
+
+ var offsetHeight = this.element.offsetHeight;
+ var offsetWidth = (width>0?width:this.element.offsetWidth); //this.element.offsetWidth;
+
+ var viewPortWidth = YAHOO.util.Dom.getViewportWidth();
+ var viewPortHeight = YAHOO.util.Dom.getViewportHeight();
+
+ var scrollX = window.scrollX || document.documentElement.scrollLeft;
+ var scrollY = window.scrollY || document.documentElement.scrollTop;
+
+ var topConstraint = scrollY + 10;
+ var leftConstraint = scrollX + 10;
+ var bottomConstraint = scrollY + viewPortHeight - offsetHeight - 10;
+ var rightConstraint = scrollX + viewPortWidth - offsetWidth - 10;
+
+ if (x < leftConstraint) {
+ x = leftConstraint;
+ } else if (x > rightConstraint) {
+ x = rightConstraint;
+ }
+
+ if (y < topConstraint) {
+ y = topConstraint;
+ } else if (y > bottomConstraint) {
+ y = bottomConstraint;
+ }
+
+ this.cfg.setProperty("x", x, true);
+ this.cfg.setProperty("y", y, true);
+ this.cfg.setProperty("xy", [x,y], true);
+}
+
+/**
+* Centers the container in the viewport.
+*/
+YAHOO.widget.Overlay.prototype.center = function() {
+ var scrollX = document.documentElement.scrollLeft || document.body.scrollLeft;
+ var scrollY = document.documentElement.scrollTop || document.body.scrollTop;
+
+ var viewPortWidth = YAHOO.util.Dom.getClientWidth();
+ var viewPortHeight = YAHOO.util.Dom.getClientHeight();
+
+ var elementWidth = this.element.offsetWidth;
+ var elementHeight = this.element.offsetHeight;
+
+ var x = (viewPortWidth / 2) - (elementWidth / 2) + scrollX;
+ var y = (viewPortHeight / 2) - (elementHeight / 2) + scrollY;
+
+ this.element.style.left = parseInt(x) + "px";
+ this.element.style.top = parseInt(y) + "px";
+ this.syncPosition();
+
+ this.cfg.refireEvent("iframe");
+}
+
+/**
+* Synchronizes the Panel's "xy", "x", and "y" properties with the Panel's position in the DOM. This is primarily used to update position information during drag & drop.
+*/
+YAHOO.widget.Overlay.prototype.syncPosition = function() {
+ var pos = YAHOO.util.Dom.getXY(this.element);
+ this.cfg.setProperty("x", pos[0], true);
+ this.cfg.setProperty("y", pos[1], true);
+ this.cfg.setProperty("xy", pos, true);
+}
+
+/**
+* Event handler fired when the resize monitor element is resized.
+*/
+YAHOO.widget.Overlay.prototype.onDomResize = function(e, obj) {
+ YAHOO.widget.Overlay.superclass.onDomResize.call(this, e, obj);
+ this.cfg.refireEvent("iframe");
+}
+
+/**
+* Removes the Overlay element from the DOM and sets all child elements to null.
+*/
+YAHOO.widget.Overlay.prototype.destroy = function() {
+ if (this.iframe) {
+ this.iframe.parentNode.removeChild(this.iframe);
+ }
+
+ this.iframe = null;
+
+ YAHOO.widget.Overlay.superclass.destroy.call(this);
+};
+
+/**
+* Returns a string representation of the object.
+* @type string
+*/
+YAHOO.widget.Overlay.prototype.toString = function() {
+ return "Overlay " + this.id;
+}
+
+/**
+* A singleton CustomEvent used for reacting to the DOM event for window scroll
+* @type YAHOO.util.CustomEvent
+*/
+YAHOO.widget.Overlay.windowScrollEvent = new YAHOO.util.CustomEvent("windowScroll");
+
+/**
+* A singleton CustomEvent used for reacting to the DOM event for window resize
+* @type YAHOO.util.CustomEvent
+*/
+YAHOO.widget.Overlay.windowResizeEvent = new YAHOO.util.CustomEvent("windowResize");
+
+/**
+* The DOM event handler used to fire the CustomEvent for window scroll
+* @type Function
+*/
+YAHOO.widget.Overlay.windowScrollHandler = function(e) {
+ YAHOO.widget.Overlay.windowScrollEvent.fire();
+}
+
+/**
+* The DOM event handler used to fire the CustomEvent for window resize
+* @type Function
+*/
+YAHOO.widget.Overlay.windowResizeHandler = function(e) {
+ YAHOO.widget.Overlay.windowResizeEvent.fire();
+}
+
+/**
+* @private
+*/
+YAHOO.widget.Overlay._initialized == null;
+
+if (YAHOO.widget.Overlay._initialized == null) {
+ YAHOO.util.Event.addListener(window, "scroll", YAHOO.widget.Overlay.windowScrollHandler);
+ YAHOO.util.Event.addListener(window, "resize", YAHOO.widget.Overlay.windowResizeHandler);
+
+ YAHOO.widget.Overlay._initialized = true;
+}
+
+/**
+* @class
+* OverlayManager is used for maintaining the focus status of multiple Overlays.
+* @param {Array} overlays Optional. A collection of Overlays to register with the manager.
+* @param {object} userConfig The object literal representing the user configuration of the OverlayManager
+* @constructor
+*/
+YAHOO.widget.OverlayManager = function(userConfig) {
+ this.init(userConfig);
+}
+
+/**
+* The CSS class representing a focused Overlay
+* @type string
+*/
+YAHOO.widget.OverlayManager.CSS_FOCUSED = "focused";
+
+YAHOO.widget.OverlayManager.prototype = {
+
+ constructor : YAHOO.widget.OverlayManager,
+
+ /**
+ * The array of Overlays that are currently registered
+ * @type Array
+ */
+ overlays : null,
+
+ /**
+ * Initializes the default configuration of the OverlayManager
+ */
+ initDefaultConfig : function() {
+ this.cfg.addProperty("overlays", { suppressEvent:true } );
+ this.cfg.addProperty("focusevent", { value:"mousedown" } );
+ },
+
+ /**
+ * Returns the currently focused Overlay
+ * @return {Overlay} The currently focused Overlay
+ */
+ getActive : function() {},
+
+ /**
+ * Focuses the specified Overlay
+ * @param {Overlay} The Overlay to focus
+ * @param {string} The id of the Overlay to focus
+ */
+ focus : function(overlay) {},
+
+ /**
+ * Removes the specified Overlay from the manager
+ * @param {Overlay} The Overlay to remove
+ * @param {string} The id of the Overlay to remove
+ */
+ remove: function(overlay) {},
+
+ /**
+ * Removes focus from all registered Overlays in the manager
+ */
+ blurAll : function() {},
+
+ /**
+ * Initializes the OverlayManager
+ * @param {Array} overlays Optional. A collection of Overlays to register with the manager.
+ * @param {object} userConfig The object literal representing the user configuration of the OverlayManager
+ */
+ init : function(userConfig) {
+ this.cfg = new YAHOO.util.Config(this);
+
+ this.initDefaultConfig();
+
+ if (userConfig) {
+ this.cfg.applyConfig(userConfig, true);
+ }
+ this.cfg.fireQueue();
+
+ var activeOverlay = null;
+
+ this.getActive = function() {
+ return activeOverlay;
+ }
+
+ this.focus = function(overlay) {
+ var o = this.find(overlay);
+ if (o) {
+ this.blurAll();
+ activeOverlay = o;
+ YAHOO.util.Dom.addClass(activeOverlay.element, YAHOO.widget.OverlayManager.CSS_FOCUSED);
+ this.overlays.sort(this.compareZIndexDesc);
+ var topZIndex = YAHOO.util.Dom.getStyle(this.overlays[0].element, "zIndex");
+ if (! isNaN(topZIndex) && this.overlays[0] != overlay) {
+ activeOverlay.cfg.setProperty("zIndex", (parseInt(topZIndex) + 1));
+ }
+ this.overlays.sort(this.compareZIndexDesc);
+ }
+ }
+
+ this.remove = function(overlay) {
+ var o = this.find(overlay);
+ if (o) {
+ var originalZ = YAHOO.util.Dom.getStyle(o.element, "zIndex");
+ o.cfg.setProperty("zIndex", -1000, true);
+ this.overlays.sort(this.compareZIndexDesc);
+ this.overlays = this.overlays.slice(0, this.overlays.length-1);
+ o.cfg.setProperty("zIndex", originalZ, true);
+
+ o.cfg.setProperty("manager", null);
+ o.focusEvent = null
+ o.blurEvent = null;
+ o.focus = null;
+ o.blur = null;
+ }
+ }
+
+ this.blurAll = function() {
+ activeOverlay = null;
+ for (var o=0;o<this.overlays.length;o++) {
+ YAHOO.util.Dom.removeClass(this.overlays[o].element, YAHOO.widget.OverlayManager.CSS_FOCUSED);
+ }
+ }
+
+ var overlays = this.cfg.getProperty("overlays");
+
+ if (! this.overlays) {
+ this.overlays = new Array();
+ }
+
+ if (overlays) {
+ this.register(overlays);
+ this.overlays.sort(this.compareZIndexDesc);
+ }
+ },
+
+ /**
+ * Registers an Overlay or an array of Overlays with the manager. Upon registration, the Overlay receives functions for focus and blur, along with CustomEvents for each.
+ * @param {Overlay} overlay An Overlay to register with the manager.
+ * @param {Overlay[]} overlay An array of Overlays to register with the manager.
+ * @return {boolean} True if any Overlays are registered.
+ */
+ register : function(overlay) {
+ if (overlay instanceof YAHOO.widget.Overlay) {
+ overlay.cfg.addProperty("manager", { value:this } );
+
+ overlay.focusEvent = new YAHOO.util.CustomEvent("focus");
+ overlay.blurEvent = new YAHOO.util.CustomEvent("blur");
+
+ var mgr=this;
+
+ overlay.focus = function() {
+ mgr.focus(this);
+ this.focusEvent.fire();
+ }
+
+ overlay.blur = function() {
+ mgr.blurAll();
+ this.blurEvent.fire();
+ }
+
+ var focusOnDomEvent = function(e,obj) {
+ overlay.focus();
+ }
+
+ var focusevent = this.cfg.getProperty("focusevent");
+ YAHOO.util.Event.addListener(overlay.element,focusevent,focusOnDomEvent,this,true);
+
+ var zIndex = YAHOO.util.Dom.getStyle(overlay.element, "zIndex");
+ if (! isNaN(zIndex)) {
+ overlay.cfg.setProperty("zIndex", parseInt(zIndex));
+ } else {
+ overlay.cfg.setProperty("zIndex", 0);
+ }
+
+ this.overlays.push(overlay);
+ return true;
+ } else if (overlay instanceof Array) {
+ var regcount = 0;
+ for (var i=0;i<overlay.length;i++) {
+ if (this.register(overlay[i])) {
+ regcount++;
+ }
+ }
+ if (regcount > 0) {
+ return true;
+ }
+ } else {
+ return false;
+ }
+ },
+
+ /**
+ * Attempts to locate an Overlay by instance or ID.
+ * @param {Overlay} overlay An Overlay to locate within the manager
+ * @param {string} overlay An Overlay id to locate within the manager
+ * @return {Overlay} The requested Overlay, if found, or null if it cannot be located.
+ */
+ find : function(overlay) {
+ if (overlay instanceof YAHOO.widget.Overlay) {
+ for (var o=0;o<this.overlays.length;o++) {
+ if (this.overlays[o] == overlay) {
+ return this.overlays[o];
+ }
+ }
+ } else if (typeof overlay == "string") {
+ for (var o=0;o<this.overlays.length;o++) {
+ if (this.overlays[o].id == overlay) {
+ return this.overlays[o];
+ }
+ }
+ }
+ return null;
+ },
+
+ /**
+ * Used for sorting the manager's Overlays by z-index.
+ * @private
+ */
+ compareZIndexDesc : function(o1, o2) {
+ var zIndex1 = o1.cfg.getProperty("zIndex");
+ var zIndex2 = o2.cfg.getProperty("zIndex");
+
+ if (zIndex1 > zIndex2) {
+ return -1;
+ } else if (zIndex1 < zIndex2) {
+ return 1;
+ } else {
+ return 0;
+ }
+ },
+
+ /**
+ * Shows all Overlays in the manager.
+ */
+ showAll : function() {
+ for (var o=0;o<this.overlays.length;o++) {
+ this.overlays[o].show();
+ }
+ },
+
+ /**
+ * Hides all Overlays in the manager.
+ */
+ hideAll : function() {
+ for (var o=0;o<this.overlays.length;o++) {
+ this.overlays[o].hide();
+ }
+ },
+
+ /**
+ * Returns a string representation of the object.
+ * @type string
+ */
+ toString : function() {
+ return "OverlayManager";
+ }
+
+}
+
+/**
+* KeyListener is a utility that provides an easy interface for listening for keydown/keyup events fired against DOM elements.
+* @param {Element} attachTo The element or element ID to which the key event should be attached
+* @param {string} attachTo The element or element ID to which the key event should be attached
+* @param {object} keyData The object literal representing the key(s) to detect. Possible attributes are shift(boolean), alt(boolean), ctrl(boolean) and keys(either an int or an array of ints representing keycodes).
+* @param {function} handler The CustomEvent handler to fire when the key event is detected
+* @param {object} handler An object literal representing the handler.
+* @param {string} event Optional. The event (keydown or keyup) to listen for. Defaults automatically to keydown.
+* @constructor
+*/
+YAHOO.util.KeyListener = function(attachTo, keyData, handler, event) {
+ if (! event) {
+ event = YAHOO.util.KeyListener.KEYDOWN;
+ }
+
+ var keyEvent = new YAHOO.util.CustomEvent("keyPressed");
+
+ this.enabledEvent = new YAHOO.util.CustomEvent("enabled");
+ this.disabledEvent = new YAHOO.util.CustomEvent("disabled");
+
+ if (typeof attachTo == 'string') {
+ attachTo = document.getElementById(attachTo);
+ }
+
+ if (typeof handler == 'function') {
+ keyEvent.subscribe(handler);
+ } else {
+ keyEvent.subscribe(handler.fn, handler.scope, handler.correctScope);
+ }
+
+ /**
+ * Handles the key event when a key is pressed.
+ * @private
+ */
+ function handleKeyPress(e, obj) {
+ var keyPressed = e.charCode || e.keyCode;
+
+ if (! keyData.shift) keyData.shift = false;
+ if (! keyData.alt) keyData.alt = false;
+ if (! keyData.ctrl) keyData.ctrl = false;
+
+ // check held down modifying keys first
+ if (e.shiftKey == keyData.shift &&
+ e.altKey == keyData.alt &&
+ e.ctrlKey == keyData.ctrl) { // if we pass this, all modifiers match
+
+ if (keyData.keys instanceof Array) {
+ for (var i=0;i<keyData.keys.length;i++) {
+ if (keyPressed == keyData.keys[i]) {
+ keyEvent.fire(keyPressed, e);
+ break;
+ }
+ }
+ } else {
+ if (keyPressed == keyData.keys) {
+ keyEvent.fire(keyPressed, e);
+ }
+ }
+ }
+ }
+
+ this.enable = function() {
+ if (! this.enabled) {
+ YAHOO.util.Event.addListener(attachTo, event, handleKeyPress);
+ this.enabledEvent.fire(keyData);
+ }
+ this.enabled = true;
+ }
+
+ this.disable = function() {
+ if (this.enabled) {
+ YAHOO.util.Event.removeListener(attachTo, event, handleKeyPress);
+ this.disabledEvent.fire(keyData);
+ }
+ this.enabled = false;
+ }
+
+ /**
+ * Returns a string representation of the object.
+ * @type string
+ */
+ this.toString = function() {
+ return "KeyListener [" + keyData.keys + "] " + attachTo.tagName + (attachTo.id ? "[" + attachTo.id + "]" : "");
+ }
+
+}
+
+/**
+* Constant representing the DOM "keydown" event.
+* @final
+*/
+YAHOO.util.KeyListener.KEYDOWN = "keydown";
+
+/**
+* Constant representing the DOM "keyup" event.
+* @final
+*/
+YAHOO.util.KeyListener.KEYUP = "keyup";
+
+/**
+* Boolean indicating the enabled/disabled state of the Tooltip
+* @type Booleam
+*/
+YAHOO.util.KeyListener.prototype.enabled = null;
+
+/**
+* Enables the KeyListener, by dynamically attaching the key event to the appropriate DOM element.
+*/
+YAHOO.util.KeyListener.prototype.enable = function() {};
+
+/**
+* Disables the KeyListener, by dynamically removing the key event from the appropriate DOM element.
+*/
+YAHOO.util.KeyListener.prototype.disable = function() {};
+
+/**
+* CustomEvent fired when the KeyListener is enabled
+* args: keyData
+* @type YAHOO.util.CustomEvent
+*/
+YAHOO.util.KeyListener.prototype.enabledEvent = null;
+
+/**
+* CustomEvent fired when the KeyListener is disabled
+* args: keyData
+* @type YAHOO.util.CustomEvent
+*/
+YAHOO.util.KeyListener.prototype.disabledEvent = null;
\ No newline at end of file
Added: branches/tomek/portal-dnd/dndRenderer.war/js/dom/README
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/dom/README 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/dom/README 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,45 @@
+Dom Release Notes
+
+*** version 0.11.1 ***
+
+* return null if el is null for get()
+* test offsetParent rather than parentNode for getXY()
+* limit depth of parent.document crawl for IE getXY() to 1
+* if no oldClassName to replace, just addClass for replaceClass()
+
+
+*** version 0.11.0 ***
+* Work around Opera 9 broken currentStyle
+* Removed timeout wrapper from setXY retry
+* Tagname tests now case-insensitive
+* Internal "this" references changed to allow for method shorthand
+* get/setStyle now accept both camel and hyphen case
+* Gecko reverted to crawling offsets for getXY
+
+
+*** version 0.10.0 ***
+
+* Safari now fails gracefully when querying computedStyle of an unavailable element
+
+* Class management functions added (hasClass, addClass, removeClass, replaceClass, getElementsByClassName)
+
+* All methods that accept HTMLElements or IDs now also accept arrays of HTMLElements and/or IDs
+
+* GenerateId method added
+
+* isAncestor method added
+
+* inDocument method added
+
+* getElementsBy method added
+
+* batch method added
+
+* getClientHeight/Width deprecated in favor of getViewportHeight/Width
+
+* getDocumentHeight/Width methods added
+
+*** version 0.9.0 ***
+
+* Initial release
+
Added: branches/tomek/portal-dnd/dndRenderer.war/js/dom/dom-debug.js
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/dom/dom-debug.js 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/dom/dom-debug.js 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,921 @@
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+Version: 0.11.1
+*/
+
+/**
+ * @class Provides helper methods for DOM elements.
+ */
+YAHOO.util.Dom = function() {
+ var ua = navigator.userAgent.toLowerCase();
+ var isOpera = (ua.indexOf('opera') > -1);
+ var isSafari = (ua.indexOf('safari') > -1);
+ var isIE = (window.ActiveXObject);
+
+ var id_counter = 0;
+ var util = YAHOO.util; // internal shorthand
+ var property_cache = {}; // to cache case conversion for set/getStyle
+ var logger = {};
+ logger.log = function() {YAHOO.log.apply(window, arguments)};
+
+ var toCamel = function(property) {
+ var convert = function(prop) {
+ var test = /(-[a-z])/i.exec(prop);
+ return prop.replace(RegExp.$1, RegExp.$1.substr(1).toUpperCase());
+ };
+
+ while(property.indexOf('-') > -1) {
+ property = convert(property);
+ }
+
+ return property;
+ //return property.replace(/-([a-z])/gi, function(m0, m1) {return m1.toUpperCase()}) // cant use function as 2nd arg yet due to safari bug
+ };
+
+ var toHyphen = function(property) {
+ if (property.indexOf('-') > -1) { // assume hyphen
+ return property;
+ }
+
+ var converted = '';
+ for (var i = 0, len = property.length;i < len; ++i) {
+ if (property.charAt(i) == property.charAt(i).toUpperCase()) {
+ converted = converted + '-' + property.charAt(i).toLowerCase();
+ } else {
+ converted = converted + property.charAt(i);
+ }
+ }
+
+ return converted;
+ //return property.replace(/([a-z])([A-Z]+)/g, function(m0, m1, m2) {return (m1 + '-' + m2.toLowerCase())});
+ };
+
+ // improve performance by only looking up once
+ var cacheConvertedProperties = function(property) {
+ property_cache[property] = {
+ camel: toCamel(property),
+ hyphen: toHyphen(property)
+ };
+ };
+
+ return {
+ /**
+ * Returns an HTMLElement reference
+ * @param {String/HTMLElement/Array} el Accepts a string to use as an ID for getting a DOM reference, an actual DOM reference, or an Array of IDs and/or HTMLElements.
+ * @return {HTMLElement/Array} A DOM reference to an HTML element or an array of HTMLElements.
+ */
+ get: function(el) {
+ if (!el) { return null; } // nothing to work with
+
+ if (typeof el != 'string' && !(el instanceof Array) ) { // assuming HTMLElement or HTMLCollection, so pass back as is
+ logger.log('get(' + el + ') returning ' + el, 'info', 'Dom');
+ return el;
+ }
+
+ if (typeof el == 'string') { // ID
+ logger.log('get("' + el + '") returning ' + document.getElementById(el), 'info', 'Dom');
+ return document.getElementById(el);
+ }
+ else { // array of ID's and/or elements
+ var collection = [];
+ for (var i = 0, len = el.length; i < len; ++i) {
+ collection[collection.length] = util.Dom.get(el[i]);
+ }
+
+ logger.log('get("' + el + '") returning ' + collection, 'info', 'Dom');
+ return collection;
+ }
+
+ logger.log('element ' + el + ' not found', 'error', 'Dom');
+ return null; // safety, should never happen
+ },
+
+ /**
+ * Normalizes currentStyle and ComputedStyle.
+ * @param {String/HTMLElement/Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.
+ * @param {String} property The style property whose value is returned.
+ * @return {String/Array} The current value of the style property for the element(s).
+ */
+ getStyle: function(el, property) {
+ var f = function(el) {
+ var value = null;
+ var dv = document.defaultView;
+
+ if (!property_cache[property]) {
+ cacheConvertedProperties(property);
+ }
+
+ var camel = property_cache[property]['camel'];
+ var hyphen = property_cache[property]['hyphen'];
+
+ if (property == 'opacity' && el.filters) {// IE opacity
+ value = 1;
+ try {
+ value = el.filters.item('DXImageTransform.Microsoft.Alpha').opacity / 100;
+ } catch(e) {
+ try {
+ value = el.filters.item('alpha').opacity / 100;
+ } catch(e) {}
+ }
+ } else if (el.style[camel]) { // camelCase for valid styles
+ value = el.style[camel];
+ }
+ else if (isIE && el.currentStyle && el.currentStyle[camel]) { // camelCase for currentStyle; isIE to workaround broken Opera 9 currentStyle
+ value = el.currentStyle[camel];
+ }
+ else if ( dv && dv.getComputedStyle ) { // hyphen-case for computedStyle
+ var computed = dv.getComputedStyle(el, '');
+
+ if (computed && computed.getPropertyValue(hyphen)) {
+ value = computed.getPropertyValue(hyphen);
+ }
+ }
+
+ logger.log('getStyle ' + property + ' returning ' + value, 'info', 'Dom');
+ return value;
+ };
+
+ return util.Dom.batch(el, f, util.Dom, true);
+ },
+
+ /**
+ * Wrapper for setting style properties of HTMLElements. Normalizes "opacity" across modern browsers.
+ * @param {String/HTMLElement/Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.
+ * @param {String} property The style property to be set.
+ * @param {String} val The value to apply to the given property.
+ */
+ setStyle: function(el, property, val) {
+ if (!property_cache[property]) {
+ cacheConvertedProperties(property);
+ }
+
+ var camel = property_cache[property]['camel'];
+
+ var f = function(el) {
+ switch(property) {
+ case 'opacity' :
+ if (isIE && typeof el.style.filter == 'string') { // in case not appended
+ el.style.filter = 'alpha(opacity=' + val * 100 + ')';
+
+ if (!el.currentStyle || !el.currentStyle.hasLayout) {
+ el.style.zoom = 1; // when no layout or cant tell
+ }
+ } else {
+ el.style.opacity = val;
+ el.style['-moz-opacity'] = val;
+ el.style['-khtml-opacity'] = val;
+ }
+
+ break;
+ default :
+ el.style[camel] = val;
+ }
+
+ logger.log('setStyle setting ' + property + ' to ' + val, 'info', 'Dom');
+
+ };
+
+ util.Dom.batch(el, f, util.Dom, true);
+ },
+
+ /**
+ * Gets the current position of an element based on page coordinates. Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
+ * @param {String/HTMLElement/Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements
+ @ return {Array} The XY position of the element(s)
+ */
+ getXY: function(el) {
+ var f = function(el) {
+
+ // has to be part of document to have pageXY
+ if (el.offsetParent === null || this.getStyle(el, 'display') == 'none') {
+ logger.log('getXY failed: element not available', 'error', 'Dom');
+ return false;
+ }
+
+ var parentNode = null;
+ var pos = [];
+ var box;
+
+ if (el.getBoundingClientRect) { // IE
+ box = el.getBoundingClientRect();
+ var doc = document;
+ if ( !this.inDocument(el) && parent.document != document) {// might be in a frame, need to get its scroll
+ doc = parent.document;
+
+ if ( !this.isAncestor(doc.documentElement, el) ) {
+ logger.log('getXY failed: element not available', 'error', 'Dom');
+ return false;
+ }
+
+ }
+
+ var scrollTop = Math.max(doc.documentElement.scrollTop, doc.body.scrollTop);
+ var scrollLeft = Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft);
+
+ return [box.left + scrollLeft, box.top + scrollTop];
+ }
+ else { // safari, opera, & gecko
+ pos = [el.offsetLeft, el.offsetTop];
+ parentNode = el.offsetParent;
+ if (parentNode != el) {
+ while (parentNode) {
+ pos[0] += parentNode.offsetLeft;
+ pos[1] += parentNode.offsetTop;
+ parentNode = parentNode.offsetParent;
+ }
+ }
+ if (isSafari && this.getStyle(el, 'position') == 'absolute' ) { // safari doubles in some cases
+ pos[0] -= document.body.offsetLeft;
+ pos[1] -= document.body.offsetTop;
+ }
+ }
+
+ if (el.parentNode) { parentNode = el.parentNode; }
+ else { parentNode = null; }
+
+ while (parentNode && parentNode.tagName.toUpperCase() != 'BODY' && parentNode.tagName.toUpperCase() != 'HTML')
+ { // account for any scrolled ancestors
+ pos[0] -= parentNode.scrollLeft;
+ pos[1] -= parentNode.scrollTop;
+
+ if (parentNode.parentNode) { parentNode = parentNode.parentNode; }
+ else { parentNode = null; }
+ }
+
+ logger.log('getXY returning ' + pos, 'info', 'Dom');
+
+ return pos;
+ };
+
+ return util.Dom.batch(el, f, util.Dom, true);
+ },
+
+ /**
+ * Gets the current X position of an element based on page coordinates. The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
+ * @param {String/HTMLElement/Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements
+ * @return {String/Array} The X position of the element(s)
+ */
+ getX: function(el) {
+ return util.Dom.getXY(el)[0];
+ },
+
+ /**
+ * Gets the current Y position of an element based on page coordinates. Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
+ * @param {String/HTMLElement/Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements
+ * @return {String/Array} The Y position of the element(s)
+ */
+ getY: function(el) {
+ return util.Dom.getXY(el)[1];
+ },
+
+ /**
+ * Set the position of an html element in page coordinates, regardless of how the element is positioned.
+ * The element(s) must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
+ * @param {String/HTMLElement/Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements
+ * @param {Array} pos Contains X & Y values for new position (coordinates are page-based)
+ * @param {Boolean} noRetry By default we try and set the position a second time if the first fails
+ */
+ setXY: function(el, pos, noRetry) {
+ var f = function(el) {
+ var style_pos = this.getStyle(el, 'position');
+ if (style_pos == 'static') { // default to relative
+ this.setStyle(el, 'position', 'relative');
+ style_pos = 'relative';
+ }
+
+ var pageXY = this.getXY(el);
+ if (pageXY === false) { // has to be part of doc to have pageXY
+ logger.log('setXY failed: element not available', 'error', 'Dom');
+ return false;
+ }
+
+ var delta = [ // assuming pixels; if not we will have to retry
+ parseInt( this.getStyle(el, 'left'), 10 ),
+ parseInt( this.getStyle(el, 'top'), 10 )
+ ];
+
+ if ( isNaN(delta[0]) ) {// in case of 'auto'
+ delta[0] = (style_pos == 'relative') ? 0 : el.offsetLeft;
+ }
+ if ( isNaN(delta[1]) ) { // in case of 'auto'
+ delta[1] = (style_pos == 'relative') ? 0 : el.offsetTop;
+ }
+
+ if (pos[0] !== null) { el.style.left = pos[0] - pageXY[0] + delta[0] + 'px'; }
+ if (pos[1] !== null) { el.style.top = pos[1] - pageXY[1] + delta[1] + 'px'; }
+
+ var newXY = this.getXY(el);
+
+ // if retry is true, try one more time if we miss
+ if (!noRetry && (newXY[0] != pos[0] || newXY[1] != pos[1]) ) {
+ this.setXY(el, pos, true);
+ }
+
+ logger.log('setXY setting position to ' + pos, 'info', 'Dom');
+ };
+
+ util.Dom.batch(el, f, util.Dom, true);
+ },
+
+ /**
+ * Set the X position of an html element in page coordinates, regardless of how the element is positioned.
+ * The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
+ * @param {String/HTMLElement/Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.
+ * @param {Int} x to use as the X coordinate for the element(s).
+ */
+ setX: function(el, x) {
+ util.Dom.setXY(el, [x, null]);
+ },
+
+ /**
+ * Set the Y position of an html element in page coordinates, regardless of how the element is positioned.
+ * The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
+ * @param {String/HTMLElement/Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.
+ * @param {Int} x to use as the Y coordinate for the element(s).
+ */
+ setY: function(el, y) {
+ util.Dom.setXY(el, [null, y]);
+ },
+
+ /**
+ * Returns the region position of the given element.
+ * The element must be part of the DOM tree to have a region (display:none or elements not appended return false).
+ * @param {String/HTMLElement/Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.
+ * @return {Region/Array} A Region or array of Region instances containing "top, left, bottom, right" member data.
+ */
+ getRegion: function(el) {
+ var f = function(el) {
+ var region = new YAHOO.util.Region.getRegion(el);
+ logger.log('getRegion returning ' + region, 'info', 'Dom');
+ return region;
+ };
+
+ return util.Dom.batch(el, f, util.Dom, true);
+ },
+
+ /**
+ * Returns the width of the client (viewport).
+ * Now using getViewportWidth. This interface left intact for back compat.
+ * @return {Int} The width of the viewable area of the page.
+ */
+ getClientWidth: function() {
+ return util.Dom.getViewportWidth();
+ },
+
+ /**
+ * Returns the height of the client (viewport).
+ * Now using getViewportHeight. This interface left intact for back compat.
+ * @return {Int} The height of the viewable area of the page.
+ */
+ getClientHeight: function() {
+ return util.Dom.getViewportHeight();
+ },
+
+ /**
+ * Returns a array of HTMLElements with the given class
+ * For optimized performance, include a tag and/or root node if possible
+ * @param {String} className The class name to match against
+ * @param {String} tag (optional) The tag name of the elements being collected
+ * @param {String/HTMLElement} root (optional) The HTMLElement or an ID to use as the starting point
+ * @return {Array} An array of elements that have the given class name
+ */
+ getElementsByClassName: function(className, tag, root) {
+ var method = function(el) { return util.Dom.hasClass(el, className) };
+ return util.Dom.getElementsBy(method, tag, root);
+ },
+
+ /**
+ * Determines whether an HTMLElement has the given className
+ * @param {String/HTMLElement/Array} el The element or collection to test
+ * @param {String} className the class name to search for
+ * @return {Boolean/Array} A boolean value or array of boolean values
+ */
+ hasClass: function(el, className) {
+ var re = new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)');
+
+ var f = function(el) {
+ logger.log('hasClass returning ' + re.test(el['className']), 'info', 'Dom');
+ return re.test(el['className']);
+ };
+
+ return util.Dom.batch(el, f, util.Dom, true);
+ },
+
+ /**
+ * Adds a class name to a given element or collection of elements
+ * @param {String/HTMLElement/Array} el The element or collection to add the class to
+ * @param {String} className the class name to add to the class attribute
+ */
+ addClass: function(el, className) {
+ var f = function(el) {
+ if (this.hasClass(el, className)) { return; } // already present
+
+ logger.log('addClass adding ' + className, 'info', 'Dom');
+
+ el['className'] = [el['className'], className].join(' ');
+ };
+
+ util.Dom.batch(el, f, util.Dom, true);
+ },
+
+ /**
+ * Removes a class name from a given element or collection of elements
+ * @param {String/HTMLElement/Array} el The element or collection to remove the class from
+ * @param {String} className the class name to remove from the class attribute
+ */
+ removeClass: function(el, className) {
+ var re = new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)', 'g');
+
+ var f = function(el) {
+ if (!this.hasClass(el, className)) { return; } // not present
+
+ logger.log('removeClass removing ' + className, 'info', 'Dom');
+
+ var c = el['className'];
+ el['className'] = c.replace(re, ' ');
+ if ( this.hasClass(el, className) ) { // in case of multiple adjacent
+ this.removeClass(el, className);
+ }
+
+ };
+
+ util.Dom.batch(el, f, util.Dom, true);
+ },
+
+ /**
+ * Replace a class with another class for a given element or collection of elements.
+ * If no oldClassName is present, the newClassName is simply added.
+ * @param {String/HTMLElement/Array} el The element or collection to remove the class from
+ * @param {String} oldClassName the class name to be replaced
+ * @param {String} newClassName the class name that will be replacing the old class name
+ */
+ replaceClass: function(el, oldClassName, newClassName) {
+ var re = new RegExp('(?:^|\\s+)' + oldClassName + '(?:\\s+|$)', 'g');
+
+ var f = function(el) {
+ logger.log('replaceClass replacing ' + oldClassName + ' with ' + newClassName, 'info', 'Dom');
+
+ if ( !this.hasClass(el, oldClassName) ) {
+ this.addClass(el, newClassName); // just add it if nothing to replace
+ return; // note return
+ }
+
+ el['className'] = el['className'].replace(re, ' ' + newClassName + ' ');
+
+ if ( this.hasClass(el, oldClassName) ) { // in case of multiple adjacent
+ this.replaceClass(el, oldClassName, newClassName);
+ }
+ };
+
+ util.Dom.batch(el, f, util.Dom, true);
+ },
+
+ /**
+ * Generates a unique ID
+ * @param {String/HTMLElement/Array} el (optional) An optional element array of elements to add an ID to (no ID is added if one is already present)
+ * @param {String} prefix (optional) an optional prefix to use (defaults to "yui-gen")
+ * @return {String/Array} The generated ID, or array of generated IDs (or original ID if already present on an element)
+ */
+ generateId: function(el, prefix) {
+ prefix = prefix || 'yui-gen';
+ el = el || {};
+
+ var f = function(el) {
+ if (el) {
+ el = util.Dom.get(el);
+ } else {
+ el = {}; // just generating ID in this case
+ }
+
+ if (!el.id) {
+ el.id = prefix + id_counter++;
+ logger.log('generateId generating ' + el.id, 'info', 'Dom');
+ } // dont override existing
+
+ logger.log('generateId returning ' + el.id, 'info', 'Dom');
+
+ return el.id;
+ };
+
+ return util.Dom.batch(el, f, util.Dom, true);
+ },
+
+ /**
+ * Determines whether an HTMLElement is an ancestor of another HTML element in the DOM hierarchy
+ * @param {String/HTMLElement} haystack The possible ancestor
+ * @param {String/HTMLElement} needle The possible descendent
+ * @return {Boolean} Whether or not the haystack is an ancestor of needle
+ */
+ isAncestor: function(haystack, needle) {
+ haystack = util.Dom.get(haystack);
+ if (!haystack || !needle) { return false; }
+
+ var f = function(needle) {
+ if (haystack.contains && !isSafari) { // safari "contains" is broken
+ logger.log('isAncestor returning ' + haystack.contains(needle), 'info', 'Dom');
+ return haystack.contains(needle);
+ }
+ else if ( haystack.compareDocumentPosition ) {
+ logger.log('isAncestor returning ' + !!(haystack.compareDocumentPosition(needle) & 16), 'info', 'Dom');
+ return !!(haystack.compareDocumentPosition(needle) & 16);
+ }
+ else { // loop up and test each parent
+ var parent = needle.parentNode;
+
+ while (parent) {
+ if (parent == haystack) {
+ logger.log('isAncestor returning true', 'info', 'Dom');
+ return true;
+ }
+ else if (parent.tagName.toUpperCase() == 'HTML') {
+ logger.log('isAncestor returning false', 'info', 'Dom');
+ return false;
+ }
+
+ parent = parent.parentNode;
+ }
+ logger.log('isAncestor returning false', 'info', 'Dom');
+ return false;
+ }
+ };
+
+ return util.Dom.batch(needle, f, util.Dom, true);
+ },
+
+ /**
+ * Determines whether an HTMLElement is present in the current document
+ * @param {String/HTMLElement} el The element to search for
+ * @return {Boolean} Whether or not the element is present in the current document
+ */
+ inDocument: function(el) {
+ var f = function(el) {
+ return this.isAncestor(document.documentElement, el);
+ };
+
+ return util.Dom.batch(el, f, util.Dom, true);
+ },
+
+ /**
+ * Returns a array of HTMLElements that pass the test applied by supplied boolean method
+ * For optimized performance, include a tag and/or root node if possible
+ * @param {Function} method A boolean method to test elements with
+ * @param {String} tag (optional) The tag name of the elements being collected
+ * @param {String/HTMLElement} root (optional) The HTMLElement or an ID to use as the starting point
+ */
+ getElementsBy: function(method, tag, root) {
+ tag = tag || '*';
+ root = util.Dom.get(root) || document;
+
+ var nodes = [];
+ var elements = root.getElementsByTagName(tag);
+
+ if ( !elements.length && (tag == '*' && root.all) ) {
+ elements = root.all; // IE < 6
+ }
+
+ for (var i = 0, len = elements.length; i < len; ++i)
+ {
+ if ( method(elements[i]) ) { nodes[nodes.length] = elements[i]; }
+ }
+
+ logger.log('getElementsBy returning ' + nodes, 'info', 'Dom');
+
+ return nodes;
+ },
+
+ /**
+ * Returns an array of elements that have had the supplied method applied.
+ * The method is called with the element(s) as the first arg, and the optional param as the second ( method(el, o) )
+ * @param {String/HTMLElement/Array} el (optional) An element or array of elements to apply the method to
+ * @param {Function} method The method to apply to the element(s)
+ * @param {Generic} (optional) o An optional arg that is passed to the supplied method
+ * @param {Boolean} (optional) override Whether or not to override the scope of "method" with "o"
+ * @return {HTMLElement/Array} The element(s) with the method applied
+ */
+ batch: function(el, method, o, override) {
+ var id = el;
+ el = util.Dom.get(el);
+
+ var scope = (override) ? o : window;
+
+ if (!el || el.tagName || !el.length) { // is null or not a collection (tagName for SELECT and others that can be both an element and a collection)
+ if (!el) {
+ logger.log(id + ' not available', 'error', 'Dom');
+ return false;
+ }
+ return method.call(scope, el, o);
+ }
+
+ var collection = [];
+
+ for (var i = 0, len = el.length; i < len; ++i) {
+ if (!el[i]) {
+ id = id[i];
+ logger.log(id + ' not available', 'error', 'Dom');
+ }
+ collection[collection.length] = method.call(scope, el[i], o);
+ }
+
+ return collection;
+ },
+
+ /**
+ * Returns the height of the document.
+ * @return {Int} The height of the actual document (which includes the body and its margin).
+ */
+ getDocumentHeight: function() {
+ var scrollHeight=-1,windowHeight=-1,bodyHeight=-1;
+ var marginTop = parseInt(util.Dom.getStyle(document.body, 'marginTop'), 10);
+ var marginBottom = parseInt(util.Dom.getStyle(document.body, 'marginBottom'), 10);
+
+ var mode = document.compatMode;
+
+ if ( (mode || isIE) && !isOpera ) { // (IE, Gecko)
+ switch (mode) {
+ case 'CSS1Compat': // Standards mode
+ scrollHeight = ((window.innerHeight && window.scrollMaxY) ? window.innerHeight+window.scrollMaxY : -1);
+ windowHeight = [document.documentElement.clientHeight,self.innerHeight||-1].sort(function(a, b){return(a-b);})[1];
+ bodyHeight = document.body.offsetHeight + marginTop + marginBottom;
+ break;
+
+ default: // Quirks
+ scrollHeight = document.body.scrollHeight;
+ bodyHeight = document.body.clientHeight;
+ }
+ } else { // Safari & Opera
+ scrollHeight = document.documentElement.scrollHeight;
+ windowHeight = self.innerHeight;
+ bodyHeight = document.documentElement.clientHeight;
+ }
+
+ var h = [scrollHeight,windowHeight,bodyHeight].sort(function(a, b){return(a-b);});
+ logger.log('getDocumentHeight returning ' + h[2], 'info', 'Dom');
+ return h[2];
+ },
+
+ /**
+ * Returns the width of the document.
+ * @return {Int} The width of the actual document (which includes the body and its margin).
+ */
+ getDocumentWidth: function() {
+ var docWidth=-1,bodyWidth=-1,winWidth=-1;
+ var marginRight = parseInt(util.Dom.getStyle(document.body, 'marginRight'), 10);
+ var marginLeft = parseInt(util.Dom.getStyle(document.body, 'marginLeft'), 10);
+
+ var mode = document.compatMode;
+
+ if (mode || isIE) { // (IE, Gecko, Opera)
+ switch (mode) {
+ case 'CSS1Compat': // Standards mode
+ docWidth = document.documentElement.clientWidth;
+ bodyWidth = document.body.offsetWidth + marginLeft + marginRight;
+ winWidth = self.innerWidth || -1;
+ break;
+
+ default: // Quirks
+ bodyWidth = document.body.clientWidth;
+ winWidth = document.body.scrollWidth;
+ break;
+ }
+ } else { // Safari
+ docWidth = document.documentElement.clientWidth;
+ bodyWidth = document.body.offsetWidth + marginLeft + marginRight;
+ winWidth = self.innerWidth;
+ }
+
+ var w = [docWidth,bodyWidth,winWidth].sort(function(a, b){return(a-b);});
+ logger.log('getDocumentWidth returning ' + w[2], 'info', 'Dom');
+ return w[2];
+ },
+
+ /**
+ * Returns the current height of the viewport.
+ * @return {Int} The height of the viewable area of the page (excludes scrollbars).
+ */
+ getViewportHeight: function() {
+ var height = -1;
+ var mode = document.compatMode;
+
+ if ( (mode || isIE) && !isOpera ) {
+ switch (mode) { // (IE, Gecko)
+ case 'CSS1Compat': // Standards mode
+ height = document.documentElement.clientHeight;
+ break;
+
+ default: // Quirks
+ height = document.body.clientHeight;
+ }
+ } else { // Safari, Opera
+ height = self.innerHeight;
+ }
+
+ logger.log('getViewportHeight returning ' + height, 'info', 'Dom');
+ return height;
+ },
+
+ /**
+ * Returns the current width of the viewport.
+ * @return {Int} The width of the viewable area of the page (excludes scrollbars).
+ */
+
+ getViewportWidth: function() {
+ var width = -1;
+ var mode = document.compatMode;
+
+ if (mode || isIE) { // (IE, Gecko, Opera)
+ switch (mode) {
+ case 'CSS1Compat': // Standards mode
+ width = document.documentElement.clientWidth;
+ break;
+
+ default: // Quirks
+ width = document.body.clientWidth;
+ }
+ } else { // Safari
+ width = self.innerWidth;
+ }
+ logger.log('getViewportWidth returning ' + width, 'info', 'Dom');
+ return width;
+ }
+ };
+}();
+
+/**
+ * @class A region is a representation of an object on a grid. It is defined
+ * by the top, right, bottom, left extents, so is rectangular by default. If
+ * other shapes are required, this class could be extended to support it.
+ *
+ * @param {int} t the top extent
+ * @param {int} r the right extent
+ * @param {int} b the bottom extent
+ * @param {int} l the left extent
+ * @constructor
+ */
+YAHOO.util.Region = function(t, r, b, l) {
+
+ /**
+ * The region's top extent
+ * @type int
+ */
+ this.top = t;
+
+ /**
+ * The region's top extent as index, for symmetry with set/getXY
+ * @type int
+ */
+ this[1] = t;
+
+ /**
+ * The region's right extent
+ * @type int
+ */
+ this.right = r;
+
+ /**
+ * The region's bottom extent
+ * @type int
+ */
+ this.bottom = b;
+
+ /**
+ * The region's left extent
+ * @type int
+ */
+ this.left = l;
+
+ /**
+ * The region's left extent as index, for symmetry with set/getXY
+ * @type int
+ */
+ this[0] = l;
+};
+
+/**
+ * Returns true if this region contains the region passed in
+ *
+ * @param {Region} region The region to evaluate
+ * @return {boolean} True if the region is contained with this region,
+ * else false
+ */
+YAHOO.util.Region.prototype.contains = function(region) {
+ return ( region.left >= this.left &&
+ region.right <= this.right &&
+ region.top >= this.top &&
+ region.bottom <= this.bottom );
+
+ // this.logger.debug("does " + this + " contain " + region + " ... " + ret);
+};
+
+/**
+ * Returns the area of the region
+ *
+ * @return {int} the region's area
+ */
+YAHOO.util.Region.prototype.getArea = function() {
+ return ( (this.bottom - this.top) * (this.right - this.left) );
+};
+
+/**
+ * Returns the region where the passed in region overlaps with this one
+ *
+ * @param {Region} region The region that intersects
+ * @return {Region} The overlap region, or null if there is no overlap
+ */
+YAHOO.util.Region.prototype.intersect = function(region) {
+ var t = Math.max( this.top, region.top );
+ var r = Math.min( this.right, region.right );
+ var b = Math.min( this.bottom, region.bottom );
+ var l = Math.max( this.left, region.left );
+
+ if (b >= t && r >= l) {
+ return new YAHOO.util.Region(t, r, b, l);
+ } else {
+ return null;
+ }
+};
+
+/**
+ * Returns the region representing the smallest region that can contain both
+ * the passed in region and this region.
+ *
+ * @param {Region} region The region that to create the union with
+ * @return {Region} The union region
+ */
+YAHOO.util.Region.prototype.union = function(region) {
+ var t = Math.min( this.top, region.top );
+ var r = Math.max( this.right, region.right );
+ var b = Math.max( this.bottom, region.bottom );
+ var l = Math.min( this.left, region.left );
+
+ return new YAHOO.util.Region(t, r, b, l);
+};
+
+/**
+ * toString
+ * @return string the region properties
+ */
+YAHOO.util.Region.prototype.toString = function() {
+ return ( "Region {" +
+ "top: " + this.top +
+ ", right: " + this.right +
+ ", bottom: " + this.bottom +
+ ", left: " + this.left +
+ "}" );
+};
+
+/**
+ * Returns a region that is occupied by the DOM element
+ *
+ * @param {HTMLElement} el The element
+ * @return {Region} The region that the element occupies
+ * @static
+ */
+YAHOO.util.Region.getRegion = function(el) {
+ var p = YAHOO.util.Dom.getXY(el);
+
+ var t = p[1];
+ var r = p[0] + el.offsetWidth;
+ var b = p[1] + el.offsetHeight;
+ var l = p[0];
+
+ return new YAHOO.util.Region(t, r, b, l);
+};
+
+/////////////////////////////////////////////////////////////////////////////
+
+
+/**
+ * @class
+ *
+ * A point is a region that is special in that it represents a single point on
+ * the grid.
+ *
+ * @param {int} x The X position of the point
+ * @param {int} y The Y position of the point
+ * @constructor
+ * @extends Region
+ */
+YAHOO.util.Point = function(x, y) {
+ if (x instanceof Array) { // accept output from Dom.getXY
+ y = x[1];
+ x = x[0];
+ }
+
+ /**
+ * The X position of the point, which is also the right, left and index zero (for Dom.getXY symmetry)
+ * @type int
+ */
+
+ this.x = this.right = this.left = this[0] = x;
+
+ /**
+ * The Y position of the point, which is also the top, bottom and index one (for Dom.getXY symmetry)
+ * @type int
+ */
+ this.y = this.top = this.bottom = this[1] = y;
+};
+
+YAHOO.util.Point.prototype = new YAHOO.util.Region();
+
Added: branches/tomek/portal-dnd/dndRenderer.war/js/dom/dom-min.js
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/dom/dom-min.js 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/dom/dom-min.js 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1 @@
+/* Copyright (c) 2006, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.net/yui/license.txt Version: 0.11.1 */ YAHOO.util.Dom=function(){var ua=navigator.userAgent.toLowerCase();var isOpera=(ua.indexOf('opera')>-1);var isSafari=(ua.indexOf('safari')>-1);var isIE=(window.ActiveXObject);var id_counter=0;var util=YAHOO.util;var property_cache={};var toCamel=function(property){var convert=function(prop){var test=/(-[a-z])/i.exec(prop);return prop.replace(RegExp.$1,RegExp.$1.substr(1).toUpperCase());};while(property.indexOf('-')>-1){property=convert(property);}return property;};var toHyphen=function(property){if(property.indexOf('-')>-1){return property;}var converted='';for(var i=0,len=property.length;i<len;++i){if(property.charAt(i)==property.charAt(i).toUpperCase()){converted=converted+'-'+property.charAt(i).toLowerCase();}else{converted=converted+property.charAt(i);}}return converted;};var cacheConvertedProperties=function(propert!
y){property_cache[property]={camel:toCamel(property),hyphen:toHyphen(property)};};return{get:function(el){if(!el){return null;}if(typeof el!='string'&&!(el instanceof Array)){return el;}if(typeof el=='string'){return document.getElementById(el);}else{var collection=[];for(var i=0,len=el.length;i<len;++i){collection[collection.length]=util.Dom.get(el[i]);}return collection;}return null;},getStyle:function(el,property){var f=function(el){var value=null;var dv=document.defaultView;if(!property_cache[property]){cacheConvertedProperties(property);}var camel=property_cache[property]['camel'];var hyphen=property_cache[property]['hyphen'];if(property=='opacity'&&el.filters){value=1;try{value=el.filters.item('DXImageTransform.Microsoft.Alpha').opacity/100;}catch(e){try{value=el.filters.item('alpha').opacity/100;}catch(e){}}}else if(el.style[camel]){value=el.style[camel];}else if(isIE&&el.currentStyle&&el.currentStyle[camel]){value=el.currentStyle[camel];}else if(dv&&dv.getComputedSt!
yle){var computed=dv.getComputedStyle(el,'');if(computed&&computed.get
PropertyValue(hyphen)){value=computed.getPropertyValue(hyphen);}}return value;};return util.Dom.batch(el,f,util.Dom,true);},setStyle:function(el,property,val){if(!property_cache[property]){cacheConvertedProperties(property);}var camel=property_cache[property]['camel'];var f=function(el){switch(property){case'opacity':if(isIE&&typeof el.style.filter=='string'){el.style.filter='alpha(opacity='+val*100+')';if(!el.currentStyle||!el.currentStyle.hasLayout){el.style.zoom=1;}}else{el.style.opacity=val;el.style['-moz-opacity']=val;el.style['-khtml-opacity']=val;}break;default:el.style[camel]=val;}};util.Dom.batch(el,f,util.Dom,true);},getXY:function(el){var f=function(el){if(el.offsetParent===null||this.getStyle(el,'display')=='none'){return false;}var parentNode=null;var pos=[];var box;if(el.getBoundingClientRect){box=el.getBoundingClientRect();var doc=document;if(!this.inDocument(el)&&parent.document!=document){doc=parent.document;if(!this.isAncestor(doc.documentElement,el)){retur!
n false;}}var scrollTop=Math.max(doc.documentElement.scrollTop,doc.body.scrollTop);var scrollLeft=Math.max(doc.documentElement.scrollLeft,doc.body.scrollLeft);return[box.left+scrollLeft,box.top+scrollTop];}else{pos=[el.offsetLeft,el.offsetTop];parentNode=el.offsetParent;if(parentNode!=el){while(parentNode){pos[0]+=parentNode.offsetLeft;pos[1]+=parentNode.offsetTop;parentNode=parentNode.offsetParent;}}if(isSafari&&this.getStyle(el,'position')=='absolute'){pos[0]-=document.body.offsetLeft;pos[1]-=document.body.offsetTop;}}if(el.parentNode){parentNode=el.parentNode;}else{parentNode=null;}while(parentNode&&parentNode.tagName.toUpperCase()!='BODY'&&parentNode.tagName.toUpperCase()!='HTML'){pos[0]-=parentNode.scrollLeft;pos[1]-=parentNode.scrollTop;if(parentNode.parentNode){parentNode=parentNode.parentNode;}else{parentNode=null;}}return pos;};return util.Dom.batch(el,f,util.Dom,true);},getX:function(el){return util.Dom.getXY(el)[0];},getY:function(el){return util.Dom.getXY(el)[1]!
;},setXY:function(el,pos,noRetry){var f=function(el){var style_pos=thi
s.getStyle(el,'position');if(style_pos=='static'){this.setStyle(el,'position','relative');style_pos='relative';}var pageXY=this.getXY(el);if(pageXY===false){return false;}var delta=[parseInt(this.getStyle(el,'left'),10),parseInt(this.getStyle(el,'top'),10)];if(isNaN(delta[0])){delta[0]=(style_pos=='relative')?0:el.offsetLeft;}if(isNaN(delta[1])){delta[1]=(style_pos=='relative')?0:el.offsetTop;}if(pos[0]!==null){el.style.left=pos[0]-pageXY[0]+delta[0]+'px';}if(pos[1]!==null){el.style.top=pos[1]-pageXY[1]+delta[1]+'px';}var newXY=this.getXY(el);if(!noRetry&&(newXY[0]!=pos[0]||newXY[1]!=pos[1])){this.setXY(el,pos,true);}};util.Dom.batch(el,f,util.Dom,true);},setX:function(el,x){util.Dom.setXY(el,[x,null]);},setY:function(el,y){util.Dom.setXY(el,[null,y]);},getRegion:function(el){var f=function(el){var region=new YAHOO.util.Region.getRegion(el);return region;};return util.Dom.batch(el,f,util.Dom,true);},getClientWidth:function(){return util.Dom.getViewportWidth();},getClientHeig!
ht:function(){return util.Dom.getViewportHeight();},getElementsByClassName:function(className,tag,root){var method=function(el){return util.Dom.hasClass(el,className)};return util.Dom.getElementsBy(method,tag,root);},hasClass:function(el,className){var re=new RegExp('(?:^|\\s+)'+className+'(?:\\s+|$)');var f=function(el){return re.test(el['className']);};return util.Dom.batch(el,f,util.Dom,true);},addClass:function(el,className){var f=function(el){if(this.hasClass(el,className)){return;}el['className']=[el['className'],className].join(' ');};util.Dom.batch(el,f,util.Dom,true);},removeClass:function(el,className){var re=new RegExp('(?:^|\\s+)'+className+'(?:\\s+|$)','g');var f=function(el){if(!this.hasClass(el,className)){return;}var c=el['className'];el['className']=c.replace(re,' ');if(this.hasClass(el,className)){this.removeClass(el,className);}};util.Dom.batch(el,f,util.Dom,true);},replaceClass:function(el,oldClassName,newClassName){var re=new RegExp('(?:^|\\s+)'+oldClas!
sName+'(?:\\s+|$)','g');var f=function(el){if(!this.hasClass(el,oldCla
ssName)){this.addClass(el,newClassName);return;}el['className']=el['className'].replace(re,' '+newClassName+' ');if(this.hasClass(el,oldClassName)){this.replaceClass(el,oldClassName,newClassName);}};util.Dom.batch(el,f,util.Dom,true);},generateId:function(el,prefix){prefix=prefix||'yui-gen';el=el||{};var f=function(el){if(el){el=util.Dom.get(el);}else{el={};}if(!el.id){el.id=prefix+id_counter++;}return el.id;};return util.Dom.batch(el,f,util.Dom,true);},isAncestor:function(haystack,needle){haystack=util.Dom.get(haystack);if(!haystack||!needle){return false;}var f=function(needle){if(haystack.contains&&!isSafari){return haystack.contains(needle);}else if(haystack.compareDocumentPosition){return!!(haystack.compareDocumentPosition(needle)&16);}else{var parent=needle.parentNode;while(parent){if(parent==haystack){return true;}else if(parent.tagName.toUpperCase()=='HTML'){return false;}parent=parent.parentNode;}return false;}};return util.Dom.batch(needle,f,util.Dom,true);},inDocu!
ment:function(el){var f=function(el){return this.isAncestor(document.documentElement,el);};return util.Dom.batch(el,f,util.Dom,true);},getElementsBy:function(method,tag,root){tag=tag||'*';root=util.Dom.get(root)||document;var nodes=[];var elements=root.getElementsByTagName(tag);if(!elements.length&&(tag=='*'&&root.all)){elements=root.all;}for(var i=0,len=elements.length;i<len;++i){if(method(elements[i])){nodes[nodes.length]=elements[i];}}return nodes;},batch:function(el,method,o,override){var id=el;el=util.Dom.get(el);var scope=(override)?o:window;if(!el||el.tagName||!el.length){if(!el){return false;}return method.call(scope,el,o);}var collection=[];for(var i=0,len=el.length;i<len;++i){if(!el[i]){id=id[i];}collection[collection.length]=method.call(scope,el[i],o);}return collection;},getDocumentHeight:function(){var scrollHeight=-1,windowHeight=-1,bodyHeight=-1;var marginTop=parseInt(util.Dom.getStyle(document.body,'marginTop'),10);var marginBottom=parseInt(util.Dom.getStyle!
(document.body,'marginBottom'),10);var mode=document.compatMode;if((mo
de||isIE)&&!isOpera){switch(mode){case'CSS1Compat':scrollHeight=((window.innerHeight&&window.scrollMaxY)?window.innerHeight+window.scrollMaxY:-1);windowHeight=[document.documentElement.clientHeight,self.innerHeight||-1].sort(function(a,b){return(a-b);})[1];bodyHeight=document.body.offsetHeight+marginTop+marginBottom;break;default:scrollHeight=document.body.scrollHeight;bodyHeight=document.body.clientHeight;}}else{scrollHeight=document.documentElement.scrollHeight;windowHeight=self.innerHeight;bodyHeight=document.documentElement.clientHeight;}var h=[scrollHeight,windowHeight,bodyHeight].sort(function(a,b){return(a-b);});return h[2];},getDocumentWidth:function(){var docWidth=-1,bodyWidth=-1,winWidth=-1;var marginRight=parseInt(util.Dom.getStyle(document.body,'marginRight'),10);var marginLeft=parseInt(util.Dom.getStyle(document.body,'marginLeft'),10);var mode=document.compatMode;if(mode||isIE){switch(mode){case'CSS1Compat':docWidth=document.documentElement.clientWidth;bodyWidth!
=document.body.offsetWidth+marginLeft+marginRight;winWidth=self.innerWidth||-1;break;default:bodyWidth=document.body.clientWidth;winWidth=document.body.scrollWidth;break;}}else{docWidth=document.documentElement.clientWidth;bodyWidth=document.body.offsetWidth+marginLeft+marginRight;winWidth=self.innerWidth;}var w=[docWidth,bodyWidth,winWidth].sort(function(a,b){return(a-b);});return w[2];},getViewportHeight:function(){var height=-1;var mode=document.compatMode;if((mode||isIE)&&!isOpera){switch(mode){case'CSS1Compat':height=document.documentElement.clientHeight;break;default:height=document.body.clientHeight;}}else{height=self.innerHeight;}return height;},getViewportWidth:function(){var width=-1;var mode=document.compatMode;if(mode||isIE){switch(mode){case'CSS1Compat':width=document.documentElement.clientWidth;break;default:width=document.body.clientWidth;}}else{width=self.innerWidth;}return width;}};}();YAHOO.util.Region=function(t,r,b,l){this.top=t;this[1]=t;this.right=r;th!
is.bottom=b;this.left=l;this[0]=l;};YAHOO.util.Region.prototype.contai
ns=function(region){return(region.left>=this.left&®ion.right<=this.right&®ion.top>=this.top&®ion.bottom<=this.bottom);};YAHOO.util.Region.prototype.getArea=function(){return((this.bottom-this.top)*(this.right-this.left));};YAHOO.util.Region.prototype.intersect=function(region){var t=Math.max(this.top,region.top);var r=Math.min(this.right,region.right);var b=Math.min(this.bottom,region.bottom);var l=Math.max(this.left,region.left);if(b>=t&&r>=l){return new YAHOO.util.Region(t,r,b,l);}else{return null;}};YAHOO.util.Region.prototype.union=function(region){var t=Math.min(this.top,region.top);var r=Math.max(this.right,region.right);var b=Math.max(this.bottom,region.bottom);var l=Math.min(this.left,region.left);return new YAHOO.util.Region(t,r,b,l);};YAHOO.util.Region.prototype.toString=function(){return("Region {"+"top: "+this.top+", right: "+this.right+", bottom: "+this.bottom+", left: "+this.left+"}");};YAHOO.util.Region.getRegion=function(el){var p=YAHOO.util.Dom.getX!
Y(el);var t=p[1];var r=p[0]+el.offsetWidth;var b=p[1]+el.offsetHeight;var l=p[0];return new YAHOO.util.Region(t,r,b,l);};YAHOO.util.Point=function(x,y){if(x instanceof Array){y=x[1];x=x[0];}this.x=this.right=this.left=this[0]=x;this.y=this.top=this.bottom=this[1]=y;};YAHOO.util.Point.prototype=new YAHOO.util.Region();
Added: branches/tomek/portal-dnd/dndRenderer.war/js/dom/dom.js
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/dom/dom.js 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/dom/dom.js 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,887 @@
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+Version: 0.11.1
+*/
+
+/**
+ * @class Provides helper methods for DOM elements.
+ */
+YAHOO.util.Dom = function() {
+ var ua = navigator.userAgent.toLowerCase();
+ var isOpera = (ua.indexOf('opera') > -1);
+ var isSafari = (ua.indexOf('safari') > -1);
+ var isIE = (window.ActiveXObject);
+
+ var id_counter = 0;
+ var util = YAHOO.util; // internal shorthand
+ var property_cache = {}; // to cache case conversion for set/getStyle
+
+ var toCamel = function(property) {
+ var convert = function(prop) {
+ var test = /(-[a-z])/i.exec(prop);
+ return prop.replace(RegExp.$1, RegExp.$1.substr(1).toUpperCase());
+ };
+
+ while(property.indexOf('-') > -1) {
+ property = convert(property);
+ }
+
+ return property;
+ //return property.replace(/-([a-z])/gi, function(m0, m1) {return m1.toUpperCase()}) // cant use function as 2nd arg yet due to safari bug
+ };
+
+ var toHyphen = function(property) {
+ if (property.indexOf('-') > -1) { // assume hyphen
+ return property;
+ }
+
+ var converted = '';
+ for (var i = 0, len = property.length;i < len; ++i) {
+ if (property.charAt(i) == property.charAt(i).toUpperCase()) {
+ converted = converted + '-' + property.charAt(i).toLowerCase();
+ } else {
+ converted = converted + property.charAt(i);
+ }
+ }
+
+ return converted;
+ //return property.replace(/([a-z])([A-Z]+)/g, function(m0, m1, m2) {return (m1 + '-' + m2.toLowerCase())});
+ };
+
+ // improve performance by only looking up once
+ var cacheConvertedProperties = function(property) {
+ property_cache[property] = {
+ camel: toCamel(property),
+ hyphen: toHyphen(property)
+ };
+ };
+
+ return {
+ /**
+ * Returns an HTMLElement reference
+ * @param {String/HTMLElement/Array} el Accepts a string to use as an ID for getting a DOM reference, an actual DOM reference, or an Array of IDs and/or HTMLElements.
+ * @return {HTMLElement/Array} A DOM reference to an HTML element or an array of HTMLElements.
+ */
+ get: function(el) {
+ if (!el) { return null; } // nothing to work with
+
+ if (typeof el != 'string' && !(el instanceof Array) ) { // assuming HTMLElement or HTMLCollection, so pass back as is
+ return el;
+ }
+
+ if (typeof el == 'string') { // ID
+ return document.getElementById(el);
+ }
+ else { // array of ID's and/or elements
+ var collection = [];
+ for (var i = 0, len = el.length; i < len; ++i) {
+ collection[collection.length] = util.Dom.get(el[i]);
+ }
+
+ return collection;
+ }
+
+ return null; // safety, should never happen
+ },
+
+ /**
+ * Normalizes currentStyle and ComputedStyle.
+ * @param {String/HTMLElement/Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.
+ * @param {String} property The style property whose value is returned.
+ * @return {String/Array} The current value of the style property for the element(s).
+ */
+ getStyle: function(el, property) {
+ var f = function(el) {
+ var value = null;
+ var dv = document.defaultView;
+
+ if (!property_cache[property]) {
+ cacheConvertedProperties(property);
+ }
+
+ var camel = property_cache[property]['camel'];
+ var hyphen = property_cache[property]['hyphen'];
+
+ if (property == 'opacity' && el.filters) {// IE opacity
+ value = 1;
+ try {
+ value = el.filters.item('DXImageTransform.Microsoft.Alpha').opacity / 100;
+ } catch(e) {
+ try {
+ value = el.filters.item('alpha').opacity / 100;
+ } catch(e) {}
+ }
+ } else if (el.style[camel]) { // camelCase for valid styles
+ value = el.style[camel];
+ }
+ else if (isIE && el.currentStyle && el.currentStyle[camel]) { // camelCase for currentStyle; isIE to workaround broken Opera 9 currentStyle
+ value = el.currentStyle[camel];
+ }
+ else if ( dv && dv.getComputedStyle ) { // hyphen-case for computedStyle
+ var computed = dv.getComputedStyle(el, '');
+
+ if (computed && computed.getPropertyValue(hyphen)) {
+ value = computed.getPropertyValue(hyphen);
+ }
+ }
+
+ return value;
+ };
+
+ return util.Dom.batch(el, f, util.Dom, true);
+ },
+
+ /**
+ * Wrapper for setting style properties of HTMLElements. Normalizes "opacity" across modern browsers.
+ * @param {String/HTMLElement/Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.
+ * @param {String} property The style property to be set.
+ * @param {String} val The value to apply to the given property.
+ */
+ setStyle: function(el, property, val) {
+ if (!property_cache[property]) {
+ cacheConvertedProperties(property);
+ }
+
+ var camel = property_cache[property]['camel'];
+
+ var f = function(el) {
+ switch(property) {
+ case 'opacity' :
+ if (isIE && typeof el.style.filter == 'string') { // in case not appended
+ el.style.filter = 'alpha(opacity=' + val * 100 + ')';
+
+ if (!el.currentStyle || !el.currentStyle.hasLayout) {
+ el.style.zoom = 1; // when no layout or cant tell
+ }
+ } else {
+ el.style.opacity = val;
+ el.style['-moz-opacity'] = val;
+ el.style['-khtml-opacity'] = val;
+ }
+
+ break;
+ default :
+ el.style[camel] = val;
+ }
+
+
+ };
+
+ util.Dom.batch(el, f, util.Dom, true);
+ },
+
+ /**
+ * Gets the current position of an element based on page coordinates. Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
+ * @param {String/HTMLElement/Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements
+ @ return {Array} The XY position of the element(s)
+ */
+ getXY: function(el) {
+ var f = function(el) {
+
+ // has to be part of document to have pageXY
+ if (el.offsetParent === null || this.getStyle(el, 'display') == 'none') {
+ return false;
+ }
+
+ var parentNode = null;
+ var pos = [];
+ var box;
+
+ if (el.getBoundingClientRect) { // IE
+ box = el.getBoundingClientRect();
+ var doc = document;
+ if ( !this.inDocument(el) && parent.document != document) {// might be in a frame, need to get its scroll
+ doc = parent.document;
+
+ if ( !this.isAncestor(doc.documentElement, el) ) {
+ return false;
+ }
+
+ }
+
+ var scrollTop = Math.max(doc.documentElement.scrollTop, doc.body.scrollTop);
+ var scrollLeft = Math.max(doc.documentElement.scrollLeft, doc.body.scrollLeft);
+
+ return [box.left + scrollLeft, box.top + scrollTop];
+ }
+ else { // safari, opera, & gecko
+ pos = [el.offsetLeft, el.offsetTop];
+ parentNode = el.offsetParent;
+ if (parentNode != el) {
+ while (parentNode) {
+ pos[0] += parentNode.offsetLeft;
+ pos[1] += parentNode.offsetTop;
+ parentNode = parentNode.offsetParent;
+ }
+ }
+ if (isSafari && this.getStyle(el, 'position') == 'absolute' ) { // safari doubles in some cases
+ pos[0] -= document.body.offsetLeft;
+ pos[1] -= document.body.offsetTop;
+ }
+ }
+
+ if (el.parentNode) { parentNode = el.parentNode; }
+ else { parentNode = null; }
+
+ while (parentNode && parentNode.tagName.toUpperCase() != 'BODY' && parentNode.tagName.toUpperCase() != 'HTML')
+ { // account for any scrolled ancestors
+ pos[0] -= parentNode.scrollLeft;
+ pos[1] -= parentNode.scrollTop;
+
+ if (parentNode.parentNode) { parentNode = parentNode.parentNode; }
+ else { parentNode = null; }
+ }
+
+
+ return pos;
+ };
+
+ return util.Dom.batch(el, f, util.Dom, true);
+ },
+
+ /**
+ * Gets the current X position of an element based on page coordinates. The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
+ * @param {String/HTMLElement/Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements
+ * @return {String/Array} The X position of the element(s)
+ */
+ getX: function(el) {
+ return util.Dom.getXY(el)[0];
+ },
+
+ /**
+ * Gets the current Y position of an element based on page coordinates. Element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
+ * @param {String/HTMLElement/Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements
+ * @return {String/Array} The Y position of the element(s)
+ */
+ getY: function(el) {
+ return util.Dom.getXY(el)[1];
+ },
+
+ /**
+ * Set the position of an html element in page coordinates, regardless of how the element is positioned.
+ * The element(s) must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
+ * @param {String/HTMLElement/Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements
+ * @param {Array} pos Contains X & Y values for new position (coordinates are page-based)
+ * @param {Boolean} noRetry By default we try and set the position a second time if the first fails
+ */
+ setXY: function(el, pos, noRetry) {
+ var f = function(el) {
+ var style_pos = this.getStyle(el, 'position');
+ if (style_pos == 'static') { // default to relative
+ this.setStyle(el, 'position', 'relative');
+ style_pos = 'relative';
+ }
+
+ var pageXY = this.getXY(el);
+ if (pageXY === false) { // has to be part of doc to have pageXY
+ return false;
+ }
+
+ var delta = [ // assuming pixels; if not we will have to retry
+ parseInt( this.getStyle(el, 'left'), 10 ),
+ parseInt( this.getStyle(el, 'top'), 10 )
+ ];
+
+ if ( isNaN(delta[0]) ) {// in case of 'auto'
+ delta[0] = (style_pos == 'relative') ? 0 : el.offsetLeft;
+ }
+ if ( isNaN(delta[1]) ) { // in case of 'auto'
+ delta[1] = (style_pos == 'relative') ? 0 : el.offsetTop;
+ }
+
+ if (pos[0] !== null) { el.style.left = pos[0] - pageXY[0] + delta[0] + 'px'; }
+ if (pos[1] !== null) { el.style.top = pos[1] - pageXY[1] + delta[1] + 'px'; }
+
+ var newXY = this.getXY(el);
+
+ // if retry is true, try one more time if we miss
+ if (!noRetry && (newXY[0] != pos[0] || newXY[1] != pos[1]) ) {
+ this.setXY(el, pos, true);
+ }
+
+ };
+
+ util.Dom.batch(el, f, util.Dom, true);
+ },
+
+ /**
+ * Set the X position of an html element in page coordinates, regardless of how the element is positioned.
+ * The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
+ * @param {String/HTMLElement/Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.
+ * @param {Int} x to use as the X coordinate for the element(s).
+ */
+ setX: function(el, x) {
+ util.Dom.setXY(el, [x, null]);
+ },
+
+ /**
+ * Set the Y position of an html element in page coordinates, regardless of how the element is positioned.
+ * The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
+ * @param {String/HTMLElement/Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.
+ * @param {Int} x to use as the Y coordinate for the element(s).
+ */
+ setY: function(el, y) {
+ util.Dom.setXY(el, [null, y]);
+ },
+
+ /**
+ * Returns the region position of the given element.
+ * The element must be part of the DOM tree to have a region (display:none or elements not appended return false).
+ * @param {String/HTMLElement/Array} el Accepts a string to use as an ID, an actual DOM reference, or an Array of IDs and/or HTMLElements.
+ * @return {Region/Array} A Region or array of Region instances containing "top, left, bottom, right" member data.
+ */
+ getRegion: function(el) {
+ var f = function(el) {
+ var region = new YAHOO.util.Region.getRegion(el);
+ return region;
+ };
+
+ return util.Dom.batch(el, f, util.Dom, true);
+ },
+
+ /**
+ * Returns the width of the client (viewport).
+ * Now using getViewportWidth. This interface left intact for back compat.
+ * @return {Int} The width of the viewable area of the page.
+ */
+ getClientWidth: function() {
+ return util.Dom.getViewportWidth();
+ },
+
+ /**
+ * Returns the height of the client (viewport).
+ * Now using getViewportHeight. This interface left intact for back compat.
+ * @return {Int} The height of the viewable area of the page.
+ */
+ getClientHeight: function() {
+ return util.Dom.getViewportHeight();
+ },
+
+ /**
+ * Returns a array of HTMLElements with the given class
+ * For optimized performance, include a tag and/or root node if possible
+ * @param {String} className The class name to match against
+ * @param {String} tag (optional) The tag name of the elements being collected
+ * @param {String/HTMLElement} root (optional) The HTMLElement or an ID to use as the starting point
+ * @return {Array} An array of elements that have the given class name
+ */
+ getElementsByClassName: function(className, tag, root) {
+ var method = function(el) { return util.Dom.hasClass(el, className) };
+ return util.Dom.getElementsBy(method, tag, root);
+ },
+
+ /**
+ * Determines whether an HTMLElement has the given className
+ * @param {String/HTMLElement/Array} el The element or collection to test
+ * @param {String} className the class name to search for
+ * @return {Boolean/Array} A boolean value or array of boolean values
+ */
+ hasClass: function(el, className) {
+ var re = new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)');
+
+ var f = function(el) {
+ return re.test(el['className']);
+ };
+
+ return util.Dom.batch(el, f, util.Dom, true);
+ },
+
+ /**
+ * Adds a class name to a given element or collection of elements
+ * @param {String/HTMLElement/Array} el The element or collection to add the class to
+ * @param {String} className the class name to add to the class attribute
+ */
+ addClass: function(el, className) {
+ var f = function(el) {
+ if (this.hasClass(el, className)) { return; } // already present
+
+
+ el['className'] = [el['className'], className].join(' ');
+ };
+
+ util.Dom.batch(el, f, util.Dom, true);
+ },
+
+ /**
+ * Removes a class name from a given element or collection of elements
+ * @param {String/HTMLElement/Array} el The element or collection to remove the class from
+ * @param {String} className the class name to remove from the class attribute
+ */
+ removeClass: function(el, className) {
+ var re = new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)', 'g');
+
+ var f = function(el) {
+ if (!this.hasClass(el, className)) { return; } // not present
+
+
+ var c = el['className'];
+ el['className'] = c.replace(re, ' ');
+ if ( this.hasClass(el, className) ) { // in case of multiple adjacent
+ this.removeClass(el, className);
+ }
+
+ };
+
+ util.Dom.batch(el, f, util.Dom, true);
+ },
+
+ /**
+ * Replace a class with another class for a given element or collection of elements.
+ * If no oldClassName is present, the newClassName is simply added.
+ * @param {String/HTMLElement/Array} el The element or collection to remove the class from
+ * @param {String} oldClassName the class name to be replaced
+ * @param {String} newClassName the class name that will be replacing the old class name
+ */
+ replaceClass: function(el, oldClassName, newClassName) {
+ var re = new RegExp('(?:^|\\s+)' + oldClassName + '(?:\\s+|$)', 'g');
+
+ var f = function(el) {
+
+ if ( !this.hasClass(el, oldClassName) ) {
+ this.addClass(el, newClassName); // just add it if nothing to replace
+ return; // note return
+ }
+
+ el['className'] = el['className'].replace(re, ' ' + newClassName + ' ');
+
+ if ( this.hasClass(el, oldClassName) ) { // in case of multiple adjacent
+ this.replaceClass(el, oldClassName, newClassName);
+ }
+ };
+
+ util.Dom.batch(el, f, util.Dom, true);
+ },
+
+ /**
+ * Generates a unique ID
+ * @param {String/HTMLElement/Array} el (optional) An optional element array of elements to add an ID to (no ID is added if one is already present)
+ * @param {String} prefix (optional) an optional prefix to use (defaults to "yui-gen")
+ * @return {String/Array} The generated ID, or array of generated IDs (or original ID if already present on an element)
+ */
+ generateId: function(el, prefix) {
+ prefix = prefix || 'yui-gen';
+ el = el || {};
+
+ var f = function(el) {
+ if (el) {
+ el = util.Dom.get(el);
+ } else {
+ el = {}; // just generating ID in this case
+ }
+
+ if (!el.id) {
+ el.id = prefix + id_counter++;
+ } // dont override existing
+
+
+ return el.id;
+ };
+
+ return util.Dom.batch(el, f, util.Dom, true);
+ },
+
+ /**
+ * Determines whether an HTMLElement is an ancestor of another HTML element in the DOM hierarchy
+ * @param {String/HTMLElement} haystack The possible ancestor
+ * @param {String/HTMLElement} needle The possible descendent
+ * @return {Boolean} Whether or not the haystack is an ancestor of needle
+ */
+ isAncestor: function(haystack, needle) {
+ haystack = util.Dom.get(haystack);
+ if (!haystack || !needle) { return false; }
+
+ var f = function(needle) {
+ if (haystack.contains && !isSafari) { // safari "contains" is broken
+ return haystack.contains(needle);
+ }
+ else if ( haystack.compareDocumentPosition ) {
+ return !!(haystack.compareDocumentPosition(needle) & 16);
+ }
+ else { // loop up and test each parent
+ var parent = needle.parentNode;
+
+ while (parent) {
+ if (parent == haystack) {
+ return true;
+ }
+ else if (parent.tagName.toUpperCase() == 'HTML') {
+ return false;
+ }
+
+ parent = parent.parentNode;
+ }
+ return false;
+ }
+ };
+
+ return util.Dom.batch(needle, f, util.Dom, true);
+ },
+
+ /**
+ * Determines whether an HTMLElement is present in the current document
+ * @param {String/HTMLElement} el The element to search for
+ * @return {Boolean} Whether or not the element is present in the current document
+ */
+ inDocument: function(el) {
+ var f = function(el) {
+ return this.isAncestor(document.documentElement, el);
+ };
+
+ return util.Dom.batch(el, f, util.Dom, true);
+ },
+
+ /**
+ * Returns a array of HTMLElements that pass the test applied by supplied boolean method
+ * For optimized performance, include a tag and/or root node if possible
+ * @param {Function} method A boolean method to test elements with
+ * @param {String} tag (optional) The tag name of the elements being collected
+ * @param {String/HTMLElement} root (optional) The HTMLElement or an ID to use as the starting point
+ */
+ getElementsBy: function(method, tag, root) {
+ tag = tag || '*';
+ root = util.Dom.get(root) || document;
+
+ var nodes = [];
+ var elements = root.getElementsByTagName(tag);
+
+ if ( !elements.length && (tag == '*' && root.all) ) {
+ elements = root.all; // IE < 6
+ }
+
+ for (var i = 0, len = elements.length; i < len; ++i)
+ {
+ if ( method(elements[i]) ) { nodes[nodes.length] = elements[i]; }
+ }
+
+
+ return nodes;
+ },
+
+ /**
+ * Returns an array of elements that have had the supplied method applied.
+ * The method is called with the element(s) as the first arg, and the optional param as the second ( method(el, o) )
+ * @param {String/HTMLElement/Array} el (optional) An element or array of elements to apply the method to
+ * @param {Function} method The method to apply to the element(s)
+ * @param {Generic} (optional) o An optional arg that is passed to the supplied method
+ * @param {Boolean} (optional) override Whether or not to override the scope of "method" with "o"
+ * @return {HTMLElement/Array} The element(s) with the method applied
+ */
+ batch: function(el, method, o, override) {
+ var id = el;
+ el = util.Dom.get(el);
+
+ var scope = (override) ? o : window;
+
+ if (!el || el.tagName || !el.length) { // is null or not a collection (tagName for SELECT and others that can be both an element and a collection)
+ if (!el) {
+ return false;
+ }
+ return method.call(scope, el, o);
+ }
+
+ var collection = [];
+
+ for (var i = 0, len = el.length; i < len; ++i) {
+ if (!el[i]) {
+ id = id[i];
+ }
+ collection[collection.length] = method.call(scope, el[i], o);
+ }
+
+ return collection;
+ },
+
+ /**
+ * Returns the height of the document.
+ * @return {Int} The height of the actual document (which includes the body and its margin).
+ */
+ getDocumentHeight: function() {
+ var scrollHeight=-1,windowHeight=-1,bodyHeight=-1;
+ var marginTop = parseInt(util.Dom.getStyle(document.body, 'marginTop'), 10);
+ var marginBottom = parseInt(util.Dom.getStyle(document.body, 'marginBottom'), 10);
+
+ var mode = document.compatMode;
+
+ if ( (mode || isIE) && !isOpera ) { // (IE, Gecko)
+ switch (mode) {
+ case 'CSS1Compat': // Standards mode
+ scrollHeight = ((window.innerHeight && window.scrollMaxY) ? window.innerHeight+window.scrollMaxY : -1);
+ windowHeight = [document.documentElement.clientHeight,self.innerHeight||-1].sort(function(a, b){return(a-b);})[1];
+ bodyHeight = document.body.offsetHeight + marginTop + marginBottom;
+ break;
+
+ default: // Quirks
+ scrollHeight = document.body.scrollHeight;
+ bodyHeight = document.body.clientHeight;
+ }
+ } else { // Safari & Opera
+ scrollHeight = document.documentElement.scrollHeight;
+ windowHeight = self.innerHeight;
+ bodyHeight = document.documentElement.clientHeight;
+ }
+
+ var h = [scrollHeight,windowHeight,bodyHeight].sort(function(a, b){return(a-b);});
+ return h[2];
+ },
+
+ /**
+ * Returns the width of the document.
+ * @return {Int} The width of the actual document (which includes the body and its margin).
+ */
+ getDocumentWidth: function() {
+ var docWidth=-1,bodyWidth=-1,winWidth=-1;
+ var marginRight = parseInt(util.Dom.getStyle(document.body, 'marginRight'), 10);
+ var marginLeft = parseInt(util.Dom.getStyle(document.body, 'marginLeft'), 10);
+
+ var mode = document.compatMode;
+
+ if (mode || isIE) { // (IE, Gecko, Opera)
+ switch (mode) {
+ case 'CSS1Compat': // Standards mode
+ docWidth = document.documentElement.clientWidth;
+ bodyWidth = document.body.offsetWidth + marginLeft + marginRight;
+ winWidth = self.innerWidth || -1;
+ break;
+
+ default: // Quirks
+ bodyWidth = document.body.clientWidth;
+ winWidth = document.body.scrollWidth;
+ break;
+ }
+ } else { // Safari
+ docWidth = document.documentElement.clientWidth;
+ bodyWidth = document.body.offsetWidth + marginLeft + marginRight;
+ winWidth = self.innerWidth;
+ }
+
+ var w = [docWidth,bodyWidth,winWidth].sort(function(a, b){return(a-b);});
+ return w[2];
+ },
+
+ /**
+ * Returns the current height of the viewport.
+ * @return {Int} The height of the viewable area of the page (excludes scrollbars).
+ */
+ getViewportHeight: function() {
+ var height = -1;
+ var mode = document.compatMode;
+
+ if ( (mode || isIE) && !isOpera ) {
+ switch (mode) { // (IE, Gecko)
+ case 'CSS1Compat': // Standards mode
+ height = document.documentElement.clientHeight;
+ break;
+
+ default: // Quirks
+ height = document.body.clientHeight;
+ }
+ } else { // Safari, Opera
+ height = self.innerHeight;
+ }
+
+ return height;
+ },
+
+ /**
+ * Returns the current width of the viewport.
+ * @return {Int} The width of the viewable area of the page (excludes scrollbars).
+ */
+
+ getViewportWidth: function() {
+ var width = -1;
+ var mode = document.compatMode;
+
+ if (mode || isIE) { // (IE, Gecko, Opera)
+ switch (mode) {
+ case 'CSS1Compat': // Standards mode
+ width = document.documentElement.clientWidth;
+ break;
+
+ default: // Quirks
+ width = document.body.clientWidth;
+ }
+ } else { // Safari
+ width = self.innerWidth;
+ }
+ return width;
+ }
+ };
+}();
+
+/**
+ * @class A region is a representation of an object on a grid. It is defined
+ * by the top, right, bottom, left extents, so is rectangular by default. If
+ * other shapes are required, this class could be extended to support it.
+ *
+ * @param {int} t the top extent
+ * @param {int} r the right extent
+ * @param {int} b the bottom extent
+ * @param {int} l the left extent
+ * @constructor
+ */
+YAHOO.util.Region = function(t, r, b, l) {
+
+ /**
+ * The region's top extent
+ * @type int
+ */
+ this.top = t;
+
+ /**
+ * The region's top extent as index, for symmetry with set/getXY
+ * @type int
+ */
+ this[1] = t;
+
+ /**
+ * The region's right extent
+ * @type int
+ */
+ this.right = r;
+
+ /**
+ * The region's bottom extent
+ * @type int
+ */
+ this.bottom = b;
+
+ /**
+ * The region's left extent
+ * @type int
+ */
+ this.left = l;
+
+ /**
+ * The region's left extent as index, for symmetry with set/getXY
+ * @type int
+ */
+ this[0] = l;
+};
+
+/**
+ * Returns true if this region contains the region passed in
+ *
+ * @param {Region} region The region to evaluate
+ * @return {boolean} True if the region is contained with this region,
+ * else false
+ */
+YAHOO.util.Region.prototype.contains = function(region) {
+ return ( region.left >= this.left &&
+ region.right <= this.right &&
+ region.top >= this.top &&
+ region.bottom <= this.bottom );
+
+};
+
+/**
+ * Returns the area of the region
+ *
+ * @return {int} the region's area
+ */
+YAHOO.util.Region.prototype.getArea = function() {
+ return ( (this.bottom - this.top) * (this.right - this.left) );
+};
+
+/**
+ * Returns the region where the passed in region overlaps with this one
+ *
+ * @param {Region} region The region that intersects
+ * @return {Region} The overlap region, or null if there is no overlap
+ */
+YAHOO.util.Region.prototype.intersect = function(region) {
+ var t = Math.max( this.top, region.top );
+ var r = Math.min( this.right, region.right );
+ var b = Math.min( this.bottom, region.bottom );
+ var l = Math.max( this.left, region.left );
+
+ if (b >= t && r >= l) {
+ return new YAHOO.util.Region(t, r, b, l);
+ } else {
+ return null;
+ }
+};
+
+/**
+ * Returns the region representing the smallest region that can contain both
+ * the passed in region and this region.
+ *
+ * @param {Region} region The region that to create the union with
+ * @return {Region} The union region
+ */
+YAHOO.util.Region.prototype.union = function(region) {
+ var t = Math.min( this.top, region.top );
+ var r = Math.max( this.right, region.right );
+ var b = Math.max( this.bottom, region.bottom );
+ var l = Math.min( this.left, region.left );
+
+ return new YAHOO.util.Region(t, r, b, l);
+};
+
+/**
+ * toString
+ * @return string the region properties
+ */
+YAHOO.util.Region.prototype.toString = function() {
+ return ( "Region {" +
+ "top: " + this.top +
+ ", right: " + this.right +
+ ", bottom: " + this.bottom +
+ ", left: " + this.left +
+ "}" );
+};
+
+/**
+ * Returns a region that is occupied by the DOM element
+ *
+ * @param {HTMLElement} el The element
+ * @return {Region} The region that the element occupies
+ * @static
+ */
+YAHOO.util.Region.getRegion = function(el) {
+ var p = YAHOO.util.Dom.getXY(el);
+
+ var t = p[1];
+ var r = p[0] + el.offsetWidth;
+ var b = p[1] + el.offsetHeight;
+ var l = p[0];
+
+ return new YAHOO.util.Region(t, r, b, l);
+};
+
+/////////////////////////////////////////////////////////////////////////////
+
+/**
+ * @class
+ *
+ * A point is a region that is special in that it represents a single point on
+ * the grid.
+ *
+ * @param {int} x The X position of the point
+ * @param {int} y The Y position of the point
+ * @constructor
+ * @extends Region
+ */
+YAHOO.util.Point = function(x, y) {
+ if (x instanceof Array) { // accept output from Dom.getXY
+ y = x[1];
+ x = x[0];
+ }
+
+ /**
+ * The X position of the point, which is also the right, left and index zero (for Dom.getXY symmetry)
+ * @type int
+ */
+
+ this.x = this.right = this.left = this[0] = x;
+
+ /**
+ * The Y position of the point, which is also the top, bottom and index one (for Dom.getXY symmetry)
+ * @type int
+ */
+ this.y = this.top = this.bottom = this[1] = y;
+};
+
+YAHOO.util.Point.prototype = new YAHOO.util.Region();
+
Added: branches/tomek/portal-dnd/dndRenderer.war/js/dragdrop/README
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/dragdrop/README 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/dragdrop/README 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,61 @@
+Drag and Drop Release Notes
+
+0.11.2
+
+ * Drag and drop will no longer interfere with selecting text on elements
+ that are not involved in drag and drop.
+
+ * The shared drag and drop proxy element now resizes correctly when autoResize
+ is enabled.
+
+0.11.1
+
+ * Fixes an issue where the setXY cache could get out of sync if the element's
+ offsetParent is changed during onDragDrop.
+
+0.11.0
+
+ * The Dom.util.setXY calculation for the initial placement of the dragged
+ element is cached during the drag, enhancing the drag performance.
+
+ * DDProxy no longer enforces having a single proxy element for all instances.
+ dragElId can be set in the config object in the constructor. If the
+ element already exists it will use that element, otherwise a new one will
+ be created with that id.
+
+ * DDProxy->borderWidth has been removed. The value is calculated on the fly
+ instead.
+
+ * Added DragDrop->clearTicks and DragDrop->clearConstraints
+
+ * All drag and drop constructors now have an additional, optional parameter
+ call "config". It is an object that can contain properties for a
+ number of configuration settings.
+
+ * Drag and drop will not be disabled for elements that cannot have their
+ location determined.
+
+ * isLegalTarget won't return dd objects that are not targetable.
+
+ * Added DragDrop->removeFromGroup.
+
+ * Constraints are now applied properly when determining which drag and drop
+ events should fire.
+
+
+0.10.0
+
+ * Improved the performance in intersect mode
+
+ * It was possible for the drag and drop initialization to be skipped
+ for very slow loading pages. This was fixed.
+
+ * New methods to exclude regions within your drag and drop element:
+ addInvalidHandleId(), addInvalidHandleClass()
+
+ * Added an onAvailable handler that is executed after the initial state is set.
+
+ * Drag and drop is more forgiving when the implementer attempts to create the
+ instance prior to the element being in the document, but after the window
+ load event has fired.
+
Added: branches/tomek/portal-dnd/dndRenderer.war/js/dragdrop/dragdrop-debug.js
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/dragdrop/dragdrop-debug.js 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/dragdrop/dragdrop-debug.js 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,2809 @@
+
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 0.11.2
+*/
+
+/**
+ * Defines the interface and base operation of items that that can be
+ * dragged or can be drop targets. It was designed to be extended, overriding
+ * the event handlers for startDrag, onDrag, onDragOver, onDragOut.
+ * Up to three html elements can be associated with a DragDrop instance:
+ * <ul>
+ * <li>linked element: the element that is passed into the constructor.
+ * This is the element which defines the boundaries for interaction with
+ * other DragDrop objects.</li>
+ * <li>handle element(s): The drag operation only occurs if the element that
+ * was clicked matches a handle element. By default this is the linked
+ * element, but there are times that you will want only a portion of the
+ * linked element to initiate the drag operation, and the setHandleElId()
+ * method provides a way to define this.</li>
+ * <li>drag element: this represents an the element that would be moved along
+ * with the cursor during a drag operation. By default, this is the linked
+ * element itself as in {@link YAHOO.util.DD}. setDragElId() lets you define
+ * a separate element that would be moved, as in {@link YAHOO.util.DDProxy}
+ * </li>
+ * </ul>
+ * This class should not be instantiated until the onload event to ensure that
+ * the associated elements are available.
+ * The following would define a DragDrop obj that would interact with any
+ * other * DragDrop obj in the "group1" group:
+ * <pre>
+ * dd = new YAHOO.util.DragDrop("div1", "group1");
+ * </pre>
+ * Since none of the event handlers have been implemented, nothing would
+ * actually happen if you were to run the code above. Normally you would
+ * override this class or one of the default implementations, but you can
+ * also override the methods you want on an instance of the class...
+ * <pre>
+ * dd.onDragDrop = function(e, id) {
+ * alert("dd was dropped on " + id);
+ * }
+ * </pre>
+ * @constructor
+ * @param {String} id of the element that is linked to this instance
+ * @param {String} sGroup the group of related DragDrop objects
+ * @param {object} config an object containing configurable attributes
+ * Valid properties for DragDrop:
+ * padding, isTarget, maintainOffset, primaryButtonOnly
+ */
+YAHOO.util.DragDrop = function(id, sGroup, config) {
+ if (id) {
+ this.init(id, sGroup, config);
+ }
+};
+
+YAHOO.util.DragDrop.prototype = {
+
+ /**
+ * The id of the element associated with this object. This is what we
+ * refer to as the "linked element" because the size and position of
+ * this element is used to determine when the drag and drop objects have
+ * interacted.
+ *
+ * @type String
+ */
+ id: null,
+
+ /**
+ * Configuration attributes passed into the constructor
+ * @type object
+ */
+ config: null,
+
+ /**
+ * The id of the element that will be dragged. By default this is same
+ * as the linked element , but could be changed to another element. Ex:
+ * YAHOO.util.DDProxy
+ *
+ * @type String
+ * @private
+ */
+ dragElId: null,
+
+ /**
+ * the id of the element that initiates the drag operation. By default
+ * this is the linked element, but could be changed to be a child of this
+ * element. This lets us do things like only starting the drag when the
+ * header element within the linked html element is clicked.
+ *
+ * @type String
+ * @private
+ */
+ handleElId: null,
+
+ /**
+ * An associative array of HTML tags that will be ignored if clicked.
+ * @type {string: string}
+ */
+ invalidHandleTypes: null,
+
+ /**
+ * An associative array of ids for elements that will be ignored if clicked
+ * @type {string: string}
+ */
+ invalidHandleIds: null,
+
+ /**
+ * An indexted array of css class names for elements that will be ignored
+ * if clicked.
+ * @type string[]
+ */
+ invalidHandleClasses: null,
+
+ /**
+ * The linked element's absolute X position at the time the drag was
+ * started
+ *
+ * @type int
+ * @private
+ */
+ startPageX: 0,
+
+ /**
+ * The linked element's absolute X position at the time the drag was
+ * started
+ *
+ * @type int
+ * @private
+ */
+ startPageY: 0,
+
+ /**
+ * The group defines a logical collection of DragDrop objects that are
+ * related. Instances only get events when interacting with other
+ * DragDrop object in the same group. This lets us define multiple
+ * groups using a single DragDrop subclass if we want.
+ * @type {string: string}
+ */
+ groups: null,
+
+ /**
+ * Individual drag/drop instances can be locked. This will prevent
+ * onmousedown start drag.
+ *
+ * @type boolean
+ * @private
+ */
+ locked: false,
+
+ /**
+ * Lock this instance
+ */
+ lock: function() { this.locked = true; },
+
+ /**
+ * Unlock this instace
+ */
+ unlock: function() { this.locked = false; },
+
+ /**
+ * By default, all insances can be a drop target. This can be disabled by
+ * setting isTarget to false.
+ *
+ * @type boolean
+ */
+ isTarget: true,
+
+ /**
+ * The padding configured for this drag and drop object for calculating
+ * the drop zone intersection with this object.
+ * @type int[]
+ */
+ padding: null,
+
+ /**
+ * @private
+ */
+ _domRef: null,
+
+ /**
+ * Internal typeof flag
+ * @private
+ */
+ __ygDragDrop: true,
+
+ /**
+ * Set to true when horizontal contraints are applied
+ *
+ * @type boolean
+ * @private
+ */
+ constrainX: false,
+
+ /**
+ * Set to true when vertical contraints are applied
+ *
+ * @type boolean
+ * @private
+ */
+ constrainY: false,
+
+ /**
+ * The left constraint
+ *
+ * @type int
+ * @private
+ */
+ minX: 0,
+
+ /**
+ * The right constraint
+ *
+ * @type int
+ * @private
+ */
+ maxX: 0,
+
+ /**
+ * The up constraint
+ *
+ * @type int
+ * @private
+ */
+ minY: 0,
+
+ /**
+ * The down constraint
+ *
+ * @type int
+ * @private
+ */
+ maxY: 0,
+
+ /**
+ * Maintain offsets when we resetconstraints. Used to maintain the
+ * slider thumb value, and this needs to be fixed.
+ * @type boolean
+ */
+ maintainOffset: false,
+
+ /**
+ * Array of pixel locations the element will snap to if we specified a
+ * horizontal graduation/interval. This array is generated automatically
+ * when you define a tick interval.
+ * @type int[]
+ */
+ xTicks: null,
+
+ /**
+ * Array of pixel locations the element will snap to if we specified a
+ * vertical graduation/interval. This array is generated automatically
+ * when you define a tick interval.
+ * @type int[]
+ */
+ yTicks: null,
+
+ /**
+ * By default the drag and drop instance will only respond to the primary
+ * button click (left button for a right-handed mouse). Set to true to
+ * allow drag and drop to start with any mouse click that is propogated
+ * by the browser
+ * @type boolean
+ */
+ primaryButtonOnly: true,
+
+ /**
+ * The availabe property is false until the linked dom element is accessible.
+ * @type boolean
+ */
+ available: false,
+
+ /**
+ * Code that executes immediately before the startDrag event
+ * @private
+ */
+ b4StartDrag: function(x, y) { },
+
+ /**
+ * Abstract method called after a drag/drop object is clicked
+ * and the drag or mousedown time thresholds have beeen met.
+ *
+ * @param {int} X click location
+ * @param {int} Y click location
+ */
+ startDrag: function(x, y) { /* override this */ },
+
+ /**
+ * Code that executes immediately before the onDrag event
+ * @private
+ */
+ b4Drag: function(e) { },
+
+ /**
+ * Abstract method called during the onMouseMove event while dragging an
+ * object.
+ *
+ * @param {Event} e
+ */
+ onDrag: function(e) { /* override this */ },
+
+ /**
+ * Code that executes immediately before the onDragEnter event
+ * @private
+ */
+ // b4DragEnter: function(e) { },
+
+ /**
+ * Abstract method called when this element fist begins hovering over
+ * another DragDrop obj
+ *
+ * @param {Event} e
+ * @param {String || YAHOO.util.DragDrop[]} id In POINT mode, the element
+ * id this is hovering over. In INTERSECT mode, an array of one or more
+ * dragdrop items being hovered over.
+ */
+ onDragEnter: function(e, id) { /* override this */ },
+
+ /**
+ * Code that executes immediately before the onDragOver event
+ * @private
+ */
+ b4DragOver: function(e) { },
+
+ /**
+ * Abstract method called when this element is hovering over another
+ * DragDrop obj
+ *
+ * @param {Event} e
+ * @param {String || YAHOO.util.DragDrop[]} id In POINT mode, the element
+ * id this is hovering over. In INTERSECT mode, an array of dd items
+ * being hovered over.
+ */
+ onDragOver: function(e, id) { /* override this */ },
+
+ /**
+ * Code that executes immediately before the onDragOut event
+ * @private
+ */
+ b4DragOut: function(e) { },
+
+ /**
+ * Abstract method called when we are no longer hovering over an element
+ *
+ * @param {Event} e
+ * @param {String || YAHOO.util.DragDrop[]} id In POINT mode, the element
+ * id this was hovering over. In INTERSECT mode, an array of dd items
+ * that the mouse is no longer over.
+ */
+ onDragOut: function(e, id) { /* override this */ },
+
+ /**
+ * Code that executes immediately before the onDragDrop event
+ * @private
+ */
+ b4DragDrop: function(e) { },
+
+ /**
+ * Abstract method called when this item is dropped on another DragDrop
+ * obj
+ *
+ * @param {Event} e
+ * @param {String || YAHOO.util.DragDrop[]} id In POINT mode, the element
+ * id this was dropped on. In INTERSECT mode, an array of dd items this
+ * was dropped on.
+ */
+ onDragDrop: function(e, id) { /* override this */ },
+
+ /**
+ * Code that executes immediately before the endDrag event
+ * @private
+ */
+ b4EndDrag: function(e) { },
+
+ /**
+ * Fired when we are done dragging the object
+ *
+ * @param {Event} e
+ */
+ endDrag: function(e) { /* override this */ },
+
+ /**
+ * Code executed immediately before the onMouseDown event
+
+ * @param {Event} e
+ * @private
+ */
+ b4MouseDown: function(e) { },
+
+ /**
+ * Event handler that fires when a drag/drop obj gets a mousedown
+ * @param {Event} e
+ */
+ onMouseDown: function(e) { /* override this */ },
+
+ /**
+ * Event handler that fires when a drag/drop obj gets a mouseup
+ * @param {Event} e
+ */
+ onMouseUp: function(e) { /* override this */ },
+
+ /**
+ * Override the onAvailable method to do what is needed after the initial
+ * position was determined.
+ */
+ onAvailable: function () {
+ this.logger.log("onAvailable (base)");
+ },
+
+ /**
+ * Returns a reference to the linked element
+ *
+ * @return {HTMLElement} the html element
+ */
+ getEl: function() {
+ if (!this._domRef) {
+ this._domRef = YAHOO.util.Dom.get(this.id);
+ }
+
+ return this._domRef;
+ },
+
+ /**
+ * Returns a reference to the actual element to drag. By default this is
+ * the same as the html element, but it can be assigned to another
+ * element. An example of this can be found in YAHOO.util.DDProxy
+ *
+ * @return {HTMLElement} the html element
+ */
+ getDragEl: function() {
+ return YAHOO.util.Dom.get(this.dragElId);
+ },
+
+ /**
+ * Sets up the DragDrop object. Must be called in the constructor of any
+ * YAHOO.util.DragDrop subclass
+ *
+ * @param id the id of the linked element
+ * @param {String} sGroup the group of related items
+ * @param {object} config configuration attributes
+ */
+ init: function(id, sGroup, config) {
+ this.initTarget(id, sGroup, config);
+ YAHOO.util.Event.addListener(this.id, "mousedown",
+ this.handleMouseDown, this, true);
+ },
+
+ /**
+ * Initializes Targeting functionality only... the object does not
+ * get a mousedown handler.
+ *
+ * @param id the id of the linked element
+ * @param {String} sGroup the group of related items
+ * @param {object} config configuration attributes
+ */
+ initTarget: function(id, sGroup, config) {
+
+ // configuration attributes
+ this.config = config || {};
+
+ // create a local reference to the drag and drop manager
+ this.DDM = YAHOO.util.DDM;
+ // initialize the groups array
+ this.groups = {};
+
+ // set the id
+ this.id = id;
+
+ // add to an interaction group
+ this.addToGroup((sGroup) ? sGroup : "default");
+
+ // We don't want to register this as the handle with the manager
+ // so we just set the id rather than calling the setter.
+ this.handleElId = id;
+
+ YAHOO.util.Event.onAvailable(id, this.handleOnAvailable, this, true);
+
+ // create a logger instance
+ this.logger = (YAHOO.widget.LogWriter) ?
+ new YAHOO.widget.LogWriter(this.toString()) : YAHOO;
+
+ // the linked element is the element that gets dragged by default
+ this.setDragElId(id);
+
+ // by default, clicked anchors will not start drag operations.
+ // @TODO what else should be here? Probably form fields.
+ this.invalidHandleTypes = { A: "A" };
+ this.invalidHandleIds = {};
+ this.invalidHandleClasses = [];
+
+ this.applyConfig();
+ },
+
+ /**
+ * Applies the configuration parameters that were passed into the constructor.
+ * This is supposed to happen at each level through the inheritance chain. So
+ * a DDProxy implentation will execute apply config on DDProxy, DD, and
+ * DragDrop in order to get all of the parameters that are available in
+ * each object.
+ */
+ applyConfig: function() {
+
+ // configurable properties:
+ // padding, isTarget, maintainOffset, primaryButtonOnly
+ this.padding = this.config.padding || [0, 0, 0, 0];
+ this.isTarget = (this.config.isTarget !== false);
+ this.maintainOffset = (this.config.maintainOffset);
+ this.primaryButtonOnly = (this.config.primaryButtonOnly !== false);
+
+ },
+
+ /**
+ * Executed when the linked element is available
+ * @private
+ */
+ handleOnAvailable: function() {
+ this.logger.log("handleOnAvailable");
+ this.available = true;
+ this.resetConstraints();
+ this.onAvailable();
+ },
+
+ /**
+ * Configures the padding for the target zone in px. Effectively expands
+ * (or reduces) the virtual object size for targeting calculations.
+ * Supports css-style shorthand; if only one parameter is passed, all sides
+ * will have that padding, and if only two are passed, the top and bottom
+ * will have the first param, the left and right the second.
+ * @param {int} iTop Top pad
+ * @param {int} iRight Right pad
+ * @param {int} iBot Bot pad
+ * @param {int} iLeft Left pad
+ */
+ setPadding: function(iTop, iRight, iBot, iLeft) {
+ // this.padding = [iLeft, iRight, iTop, iBot];
+ if (!iRight && 0 !== iRight) {
+ this.padding = [iTop, iTop, iTop, iTop];
+ } else if (!iBot && 0 !== iBot) {
+ this.padding = [iTop, iRight, iTop, iRight];
+ } else {
+ this.padding = [iTop, iRight, iBot, iLeft];
+ }
+ },
+
+ /**
+ * Stores the initial placement of the dd element
+ */
+ setInitPosition: function(diffX, diffY) {
+ var el = this.getEl();
+
+ if (!this.DDM.verifyEl(el)) {
+ this.logger.log(this.id + " element is broken");
+ return;
+ }
+
+ var dx = diffX || 0;
+ var dy = diffY || 0;
+
+ var p = YAHOO.util.Dom.getXY( el );
+
+ this.initPageX = p[0] - dx;
+ this.initPageY = p[1] - dy;
+
+ this.lastPageX = p[0];
+ this.lastPageY = p[1];
+
+ this.logger.log(this.id + " inital position: " + this.initPageX +
+ ", " + this.initPageY);
+
+
+ this.setStartPosition(p);
+ },
+
+ /**
+ * Sets the start position of the element. This is set when the obj
+ * is initialized, the reset when a drag is started.
+ * @param pos current position (from previous lookup)
+ * @private
+ */
+ setStartPosition: function(pos) {
+ var p = pos || YAHOO.util.Dom.getXY( this.getEl() );
+ this.deltaSetXY = null;
+
+ this.startPageX = p[0];
+ this.startPageY = p[1];
+ },
+
+ /**
+ * Add this instance to a group of related drag/drop objects. All
+ * instances belong to at least one group, and can belong to as many
+ * groups as needed.
+ *
+ * @param sGroup {string} the name of the group
+ */
+ addToGroup: function(sGroup) {
+ this.groups[sGroup] = true;
+ this.DDM.regDragDrop(this, sGroup);
+ },
+
+ /**
+ * Remove's this instance from the supplied interaction group
+ * @param {string} sGroup The group to drop
+ */
+ removeFromGroup: function(sGroup) {
+ this.logger.log("Removing from group: " + sGroup);
+ if (this.groups[sGroup]) {
+ delete this.groups[sGroup];
+ }
+
+ this.DDM.removeDDFromGroup(this, sGroup);
+ },
+
+ /**
+ * Allows you to specify that an element other than the linked element
+ * will be moved with the cursor during a drag
+ *
+ * @param id the id of the element that will be used to initiate the drag
+ */
+ setDragElId: function(id) {
+ this.dragElId = id;
+ },
+
+ /**
+ * Allows you to specify a child of the linked element that should be
+ * used to initiate the drag operation. An example of this would be if
+ * you have a content div with text and links. Clicking anywhere in the
+ * content area would normally start the drag operation. Use this method
+ * to specify that an element inside of the content div is the element
+ * that starts the drag operation.
+ *
+ * @param id the id of the element that will be used to initiate the drag
+ */
+ setHandleElId: function(id) {
+ this.handleElId = id;
+ this.DDM.regHandle(this.id, id);
+ },
+
+ /**
+ * Allows you to set an element outside of the linked element as a drag
+ * handle
+ */
+ setOuterHandleElId: function(id) {
+ this.logger.log("Adding outer handle event: " + id);
+ YAHOO.util.Event.addListener(id, "mousedown",
+ this.handleMouseDown, this, true);
+ this.setHandleElId(id);
+ },
+
+ /**
+ * Remove all drag and drop hooks for this element
+ */
+ unreg: function() {
+ this.logger.log("DragDrop obj cleanup " + this.id);
+ YAHOO.util.Event.removeListener(this.id, "mousedown",
+ this.handleMouseDown);
+ this._domRef = null;
+ this.DDM._remove(this);
+ },
+
+ /**
+ * Returns true if this instance is locked, or the drag drop mgr is locked
+ * (meaning that all drag/drop is disabled on the page.)
+ *
+ * @return {boolean} true if this obj or all drag/drop is locked, else
+ * false
+ */
+ isLocked: function() {
+ return (this.DDM.isLocked() || this.locked);
+ },
+
+ /**
+ * Fired when this object is clicked
+ *
+ * @param {Event} e
+ * @param {YAHOO.util.DragDrop} oDD the clicked dd object (this dd obj)
+ * @private
+ */
+ handleMouseDown: function(e, oDD) {
+
+ this.logger.log("isLocked: " + this.isLocked());
+
+ var EU = YAHOO.util.Event;
+
+ var button = e.which || e.button;
+ this.logger.log("button: " + button);
+
+ if (this.primaryButtonOnly && button > 1) {
+ this.logger.log("Mousedown was not produced by the primary button");
+ return;
+ }
+
+ if (this.isLocked()) {
+ this.logger.log("Drag and drop is disabled, aborting");
+ return;
+ }
+
+ this.logger.log("mousedown " + this.id);
+ this.DDM.refreshCache(this.groups);
+ // var self = this;
+ // setTimeout( function() { self.DDM.refreshCache(self.groups); }, 0);
+
+ // Only process the event if we really clicked within the linked
+ // element. The reason we make this check is that in the case that
+ // another element was moved between the clicked element and the
+ // cursor in the time between the mousedown and mouseup events. When
+ // this happens, the element gets the next mousedown event
+ // regardless of where on the screen it happened.
+ var pt = new YAHOO.util.Point(EU.getPageX(e), EU.getPageY(e));
+ if ( this.DDM.isOverTarget(pt, this) ) {
+
+ this.logger.log("click is over target");
+
+ // check to see if the handle was clicked
+ var srcEl = EU.getTarget(e);
+
+ if (this.isValidHandleChild(srcEl) &&
+ (this.id == this.handleElId ||
+ this.DDM.handleWasClicked(srcEl, this.id)) ) {
+
+ this.logger.log("click was a valid handle");
+
+ // set the initial element position
+ this.setStartPosition();
+
+ this.logger.log("firing onMouseDown events");
+
+
+ this.b4MouseDown(e);
+ this.onMouseDown(e);
+ this.DDM.handleMouseDown(e, this);
+
+ this.DDM.stopEvent(e);
+ }
+ }
+ },
+
+ /**
+ * Allows you to specify a tag name that should not start a drag operation
+ * when clicked. This is designed to facilitate embedding links within a
+ * drag handle that do something other than start the drag.
+ *
+ * @param {string} tagName the type of element to exclude
+ */
+ addInvalidHandleType: function(tagName) {
+ var type = tagName.toUpperCase();
+ this.invalidHandleTypes[type] = type;
+ },
+
+ /**
+ * Lets you to specify an element id for a child of a drag handle
+ * that should not initiate a drag
+ * @param {string} id the element id of the element you wish to ignore
+ */
+ addInvalidHandleId: function(id) {
+ this.invalidHandleIds[id] = id;
+ },
+
+
+ /**
+ * Lets you specify a css class of elements that will not initiate a drag
+ * @param {string} cssClass the class of the elements you wish to ignore
+ */
+ addInvalidHandleClass: function(cssClass) {
+ this.invalidHandleClasses.push(cssClass);
+ },
+
+ /**
+ * Unsets an excluded tag name set by addInvalidHandleType
+ *
+ * @param {string} tagName the type of element to unexclude
+ */
+ removeInvalidHandleType: function(tagName) {
+ var type = tagName.toUpperCase();
+ // this.invalidHandleTypes[type] = null;
+ delete this.invalidHandleTypes[type];
+ },
+
+ /**
+ * Unsets an invalid handle id
+ * @param {string} the id of the element to re-enable
+ */
+ removeInvalidHandleId: function(id) {
+ delete this.invalidHandleIds[id];
+ },
+
+ /**
+ * Unsets an invalid css class
+ * @param {string} the class of the element(s) you wish to re-enable
+ */
+ removeInvalidHandleClass: function(cssClass) {
+ for (var i=0, len=this.invalidHandleClasses.length; i<len; ++i) {
+ if (this.invalidHandleClasses[i] == cssClass) {
+ delete this.invalidHandleClasses[i];
+ }
+ }
+ },
+
+ /**
+ * Checks the tag exclusion list to see if this click should be ignored
+ *
+ * @param {ygNode} node
+ * @return {boolean} true if this is a valid tag type, false if not
+ */
+ isValidHandleChild: function(node) {
+
+ var valid = true;
+ // var n = (node.nodeName == "#text") ? node.parentNode : node;
+ var nodeName;
+ try {
+ nodeName = node.nodeName.toUpperCase();
+ } catch(e) {
+ nodeName = node.nodeName;
+ }
+ valid = valid && !this.invalidHandleTypes[nodeName];
+ valid = valid && !this.invalidHandleIds[node.id];
+
+ for (var i=0, len=this.invalidHandleClasses.length; valid && i<len; ++i) {
+ valid = !YAHOO.util.Dom.hasClass(node, this.invalidHandleClasses[i]);
+ }
+
+ this.logger.log("Valid handle? ... " + valid);
+
+ return valid;
+
+ },
+
+ /**
+ * Create the array of horizontal tick marks if an interval was specified
+ * in setXConstraint().
+ *
+ * @private
+ */
+ setXTicks: function(iStartX, iTickSize) {
+ this.xTicks = [];
+ this.xTickSize = iTickSize;
+
+ var tickMap = {};
+
+ for (var i = this.initPageX; i >= this.minX; i = i - iTickSize) {
+ if (!tickMap[i]) {
+ this.xTicks[this.xTicks.length] = i;
+ tickMap[i] = true;
+ }
+ }
+
+ for (i = this.initPageX; i <= this.maxX; i = i + iTickSize) {
+ if (!tickMap[i]) {
+ this.xTicks[this.xTicks.length] = i;
+ tickMap[i] = true;
+ }
+ }
+
+ this.xTicks.sort(this.DDM.numericSort) ;
+ this.logger.log("xTicks: " + this.xTicks.join());
+ },
+
+ /**
+ * Create the array of vertical tick marks if an interval was specified in
+ * setYConstraint().
+ *
+ * @private
+ */
+ setYTicks: function(iStartY, iTickSize) {
+ // this.logger.log("setYTicks: " + iStartY + ", " + iTickSize
+ // + ", " + this.initPageY + ", " + this.minY + ", " + this.maxY );
+ this.yTicks = [];
+ this.yTickSize = iTickSize;
+
+ var tickMap = {};
+
+ for (var i = this.initPageY; i >= this.minY; i = i - iTickSize) {
+ if (!tickMap[i]) {
+ this.yTicks[this.yTicks.length] = i;
+ tickMap[i] = true;
+ }
+ }
+
+ for (i = this.initPageY; i <= this.maxY; i = i + iTickSize) {
+ if (!tickMap[i]) {
+ this.yTicks[this.yTicks.length] = i;
+ tickMap[i] = true;
+ }
+ }
+
+ this.yTicks.sort(this.DDM.numericSort) ;
+ this.logger.log("yTicks: " + this.yTicks.join());
+ },
+
+ /**
+ * By default, the element can be dragged any place on the screen. Use
+ * this method to limit the horizontal travel of the element. Pass in
+ * 0,0 for the parameters if you want to lock the drag to the y axis.
+ *
+ * @param {int} iLeft the number of pixels the element can move to the left
+ * @param {int} iRight the number of pixels the element can move to the
+ * right
+ * @param {int} iTickSize optional parameter for specifying that the
+ * element
+ * should move iTickSize pixels at a time.
+ */
+ setXConstraint: function(iLeft, iRight, iTickSize) {
+ this.leftConstraint = iLeft;
+ this.rightConstraint = iRight;
+
+ this.minX = this.initPageX - iLeft;
+ this.maxX = this.initPageX + iRight;
+ if (iTickSize) { this.setXTicks(this.initPageX, iTickSize); }
+
+ this.constrainX = true;
+ this.logger.log("initPageX:" + this.initPageX + " minX:" + this.minX +
+ " maxX:" + this.maxX);
+ },
+
+ /**
+ * Clears any constraints applied to this instance. Also clears ticks
+ * since they can't exist independent of a constraint at this time.
+ */
+ clearConstraints: function() {
+ this.logger.log("Clearing constraints");
+ this.constrainX = false;
+ this.constrainY = false;
+ this.clearTicks();
+ },
+
+ /**
+ * Clears any tick interval defined for this instance
+ */
+ clearTicks: function() {
+ this.logger.log("Clearing ticks");
+ this.xTicks = null;
+ this.yTicks = null;
+ this.xTickSize = 0;
+ this.yTickSize = 0;
+ },
+
+ /**
+ * By default, the element can be dragged any place on the screen. Set
+ * this to limit the vertical travel of the element. Pass in 0,0 for the
+ * parameters if you want to lock the drag to the x axis.
+ *
+ * @param {int} iUp the number of pixels the element can move up
+ * @param {int} iDown the number of pixels the element can move down
+ * @param {int} iTickSize optional parameter for specifying that the
+ * element should move iTickSize pixels at a time.
+ */
+ setYConstraint: function(iUp, iDown, iTickSize) {
+ this.logger.log("setYConstraint: " + iUp + "," + iDown + "," + iTickSize);
+ this.topConstraint = iUp;
+ this.bottomConstraint = iDown;
+
+ this.minY = this.initPageY - iUp;
+ this.maxY = this.initPageY + iDown;
+ if (iTickSize) { this.setYTicks(this.initPageY, iTickSize); }
+
+ this.constrainY = true;
+
+ this.logger.log("initPageY:" + this.initPageY + " minY:" + this.minY +
+ " maxY:" + this.maxY);
+ },
+
+ /**
+ * resetConstraints must be called if you manually reposition a dd element.
+ * @param {boolean} maintainOffset
+ */
+ resetConstraints: function() {
+
+ this.logger.log("resetConstraints");
+
+ // Maintain offsets if necessary
+ if (this.initPageX || this.initPageX === 0) {
+ this.logger.log("init pagexy: " + this.initPageX + ", " +
+ this.initPageY);
+ this.logger.log("last pagexy: " + this.lastPageX + ", " +
+ this.lastPageY);
+ // figure out how much this thing has moved
+ var dx = (this.maintainOffset) ? this.lastPageX - this.initPageX : 0;
+ var dy = (this.maintainOffset) ? this.lastPageY - this.initPageY : 0;
+
+ this.setInitPosition(dx, dy);
+
+ // This is the first time we have detected the element's position
+ } else {
+ this.setInitPosition();
+ }
+
+ if (this.constrainX) {
+ this.setXConstraint( this.leftConstraint,
+ this.rightConstraint,
+ this.xTickSize );
+ }
+
+ if (this.constrainY) {
+ this.setYConstraint( this.topConstraint,
+ this.bottomConstraint,
+ this.yTickSize );
+ }
+ },
+
+ /**
+ * Normally the drag element is moved pixel by pixel, but we can specify
+ * that it move a number of pixels at a time. This method resolves the
+ * location when we have it set up like this.
+ *
+ * @param {int} val where we want to place the object
+ * @param {int[]} tickArray sorted array of valid points
+ * @return {int} the closest tick
+ * @private
+ */
+ getTick: function(val, tickArray) {
+
+ if (!tickArray) {
+ // If tick interval is not defined, it is effectively 1 pixel,
+ // so we return the value passed to us.
+ return val;
+ } else if (tickArray[0] >= val) {
+ // The value is lower than the first tick, so we return the first
+ // tick.
+ return tickArray[0];
+ } else {
+ for (var i=0, len=tickArray.length; i<len; ++i) {
+ var next = i + 1;
+ if (tickArray[next] && tickArray[next] >= val) {
+ var diff1 = val - tickArray[i];
+ var diff2 = tickArray[next] - val;
+ return (diff2 > diff1) ? tickArray[i] : tickArray[next];
+ }
+ }
+
+ // The value is larger than the last tick, so we return the last
+ // tick.
+ return tickArray[tickArray.length - 1];
+ }
+ },
+
+ /**
+ * toString method
+ * @return {string} string representation of the dd obj
+ */
+ toString: function() {
+ return ("DragDrop " + this.id);
+ }
+
+};
+
+// Only load the library once. Rewriting the manager class would orphan
+// existing drag and drop instances.
+if (!YAHOO.util.DragDropMgr) {
+
+ /**
+ * Handles the element interaction for all DragDrop items in the
+ * window. Generally, you will not call this class directly, but it does
+ * have helper methods that could be useful in your DragDrop
+ * implementations. This class should not be instantiated; all methods
+ * are are static.
+ *
+ * @constructor
+ */
+ YAHOO.util.DragDropMgr = new function() {
+
+ /**
+ * Two dimensional Array of registered DragDrop objects. The first
+ * dimension is the DragDrop item group, the second the DragDrop
+ * object.
+ *
+ * @type {string: string}
+ * @private
+ */
+ this.ids = {};
+
+ /**
+ * Array of element ids defined as drag handles. Used to determine
+ * if the element that generated the mousedown event is actually the
+ * handle and not the html element itself.
+ *
+ * @type {string: string}
+ * @private
+ */
+ this.handleIds = {};
+
+ /**
+ * the DragDrop object that is currently being dragged
+ *
+ * @type DragDrop
+ * @private
+ **/
+ this.dragCurrent = null;
+
+ /**
+ * the DragDrop object(s) that are being hovered over
+ *
+ * @type Array
+ * @private
+ */
+ this.dragOvers = {};
+
+ /**
+ * @private
+ */
+ this.logger = null;
+
+ /**
+ * the X distance between the cursor and the object being dragged
+ *
+ * @type int
+ * @private
+ */
+ this.deltaX = 0;
+
+ /**
+ * the Y distance between the cursor and the object being dragged
+ *
+ * @type int
+ * @private
+ */
+ this.deltaY = 0;
+
+ /**
+ * Flag to determine if we should prevent the default behavior of the
+ * events we define. By default this is true, but this can be set to
+ * false if you need the default behavior (not recommended)
+ *
+ * @type boolean
+ */
+ this.preventDefault = true;
+
+ /**
+ * Flag to determine if we should stop the propagation of the events
+ * we generate. This is true by default but you may want to set it to
+ * false if the html element contains other features that require the
+ * mouse click.
+ *
+ * @type boolean
+ */
+ this.stopPropagation = true;
+
+ /**
+ * @private
+ */
+ this.initalized = false;
+
+ /**
+ * All drag and drop can be disabled.
+ *
+ * @private
+ */
+ this.locked = false;
+
+ /**
+ * Called the first time an element is registered.
+ *
+ * @private
+ */
+ this.init = function() {
+ this.logger = (YAHOO.widget.LogWriter) ?
+ new YAHOO.widget.LogWriter("DragDropMgr") : YAHOO;
+ this.initialized = true;
+ };
+
+ /**
+ * In point mode, drag and drop interaction is defined by the
+ * location of the cursor during the drag/drop
+ * @type int
+ */
+ this.POINT = 0;
+
+ /**
+ * In intersect mode, drag and drop interactio nis defined by the
+ * overlap of two or more drag and drop objects.
+ * @type int
+ */
+ this.INTERSECT = 1;
+
+ /**
+ * The current drag and drop mode. Default it point mode
+ * @type int
+ */
+ this.mode = this.POINT;
+
+ /**
+ * Runs method on all drag and drop objects
+ * @private
+ */
+ this._execOnAll = function(sMethod, args) {
+ for (var i in this.ids) {
+ for (var j in this.ids[i]) {
+ var oDD = this.ids[i][j];
+ if (! this.isTypeOfDD(oDD)) {
+ continue;
+ }
+ oDD[sMethod].apply(oDD, args);
+ }
+ }
+ };
+
+ /**
+ * Drag and drop initialization. Sets up the global event handlers
+ * @private
+ */
+ this._onLoad = function() {
+
+ this.init();
+
+ this.logger.log("DDM onload");
+
+ var EU = YAHOO.util.Event;
+
+ EU.on(document, "mouseup", this.handleMouseUp, this, true);
+ EU.on(document, "mousemove", this.handleMouseMove, this, true);
+ EU.on(window, "unload", this._onUnload, this, true);
+ EU.on(window, "resize", this._onResize, this, true);
+ // EU.on(window, "mouseout", this._test);
+
+ };
+
+ /**
+ * Reset constraints on all drag and drop objs
+ * @private
+ */
+ this._onResize = function(e) {
+ this.logger.log("window resize");
+ this._execOnAll("resetConstraints", []);
+ };
+
+ /**
+ * Lock all drag and drop functionality
+ */
+ this.lock = function() { this.locked = true; };
+
+ /**
+ * Unlock all drag and drop functionality
+ */
+ this.unlock = function() { this.locked = false; };
+
+ /**
+ * Is drag and drop locked?
+ *
+ * @return {boolean} True if drag and drop is locked, false otherwise.
+ */
+ this.isLocked = function() { return this.locked; };
+
+ /**
+ * Location cache that is set for all drag drop objects when a drag is
+ * initiated, cleared when the drag is finished.
+ *
+ * @private
+ */
+ this.locationCache = {};
+
+ /**
+ * Set useCache to false if you want to force object the lookup of each
+ * drag and drop linked element constantly during a drag.
+ * @type boolean
+ */
+ this.useCache = true;
+
+ /**
+ * The number of pixels that the mouse needs to move after the
+ * mousedown before the drag is initiated. Default=3;
+ * @type int
+ */
+ this.clickPixelThresh = 3;
+
+ /**
+ * The number of milliseconds after the mousedown event to initiate the
+ * drag if we don't get a mouseup event. Default=1000
+ * @type int
+ */
+ this.clickTimeThresh = 1000;
+
+ /**
+ * Flag that indicates that either the drag pixel threshold or the
+ * mousdown time threshold has been met
+ * @type boolean
+ * @private
+ */
+ this.dragThreshMet = false;
+
+ /**
+ * Timeout used for the click time threshold
+ * @type Object
+ * @private
+ */
+ this.clickTimeout = null;
+
+ /**
+ * The X position of the mousedown event stored for later use when a
+ * drag threshold is met.
+ * @type int
+ * @private
+ */
+ this.startX = 0;
+
+ /**
+ * The Y position of the mousedown event stored for later use when a
+ * drag threshold is met.
+ * @type int
+ * @private
+ */
+ this.startY = 0;
+
+ /**
+ * Each DragDrop instance must be registered with the DragDropMgr.
+ * This is executed in DragDrop.init()
+ *
+ * @param {DragDrop} oDD the DragDrop object to register
+ * @param {String} sGroup the name of the group this element belongs to
+ */
+ this.regDragDrop = function(oDD, sGroup) {
+ if (!this.initialized) { this.init(); }
+
+ if (!this.ids[sGroup]) {
+ this.ids[sGroup] = {};
+ }
+ this.ids[sGroup][oDD.id] = oDD;
+ };
+
+ /**
+ * Removes the supplied dd instance from the supplied group. Executed
+ * by DragDrop.removeFromGroup.
+ * @private
+ */
+ this.removeDDFromGroup = function(oDD, sGroup) {
+ if (!this.ids[sGroup]) {
+ this.ids[sGroup] = {};
+ }
+
+ var obj = this.ids[sGroup];
+ if (obj && obj[oDD.id]) {
+ delete obj[oDD.id];
+ }
+ };
+
+ /**
+ * Unregisters a drag and drop item. This is executed in
+ * DragDrop.unreg, use that method instead of calling this directly.
+ * @private
+ */
+ this._remove = function(oDD) {
+ for (var g in oDD.groups) {
+ if (g && this.ids[g][oDD.id]) {
+ delete this.ids[g][oDD.id];
+ }
+ }
+ delete this.handleIds[oDD.id];
+ };
+
+ /**
+ * Each DragDrop handle element must be registered. This is done
+ * automatically when executing DragDrop.setHandleElId()
+ *
+ * @param {String} sDDId the DragDrop id this element is a handle for
+ * @param {String} sHandleId the id of the element that is the drag
+ * handle
+ */
+ this.regHandle = function(sDDId, sHandleId) {
+ if (!this.handleIds[sDDId]) {
+ this.handleIds[sDDId] = {};
+ }
+ this.handleIds[sDDId][sHandleId] = sHandleId;
+ };
+
+ /**
+ * Utility function to determine if a given element has been
+ * registered as a drag drop item.
+ *
+ * @param {String} id the element id to check
+ * @return {boolean} true if this element is a DragDrop item,
+ * false otherwise
+ */
+ this.isDragDrop = function(id) {
+ return ( this.getDDById(id) ) ? true : false;
+ };
+
+ /**
+ * Returns the drag and drop instances that are in all groups the
+ * passed in instance belongs to.
+ *
+ * @param {DragDrop} p_oDD the obj to get related data for
+ * @param {boolean} bTargetsOnly if true, only return targetable objs
+ * @return {DragDrop[]} the related instances
+ */
+ this.getRelated = function(p_oDD, bTargetsOnly) {
+ var oDDs = [];
+ for (var i in p_oDD.groups) {
+ for (j in this.ids[i]) {
+ var dd = this.ids[i][j];
+ if (! this.isTypeOfDD(dd)) {
+ continue;
+ }
+ if (!bTargetsOnly || dd.isTarget) {
+ oDDs[oDDs.length] = dd;
+ }
+ }
+ }
+
+ return oDDs;
+ };
+
+ /**
+ * Returns true if the specified dd target is a legal target for
+ * the specifice drag obj
+ *
+ * @param {DragDrop} the drag obj
+ * @param {DragDrop) the target
+ * @return {boolean} true if the target is a legal target for the
+ * dd obj
+ */
+ this.isLegalTarget = function (oDD, oTargetDD) {
+ var targets = this.getRelated(oDD, true);
+ for (var i=0, len=targets.length;i<len;++i) {
+ if (targets[i].id == oTargetDD.id) {
+ return true;
+ }
+ }
+
+ return false;
+ };
+
+ /**
+ * My goal is to be able to transparently determine if an object is
+ * typeof DragDrop, and the exact subclass of DragDrop. typeof
+ * returns "object", oDD.constructor.toString() always returns
+ * "DragDrop" and not the name of the subclass. So for now it just
+ * evaluates a well-known variable in DragDrop.
+ *
+ * @param {Object} the object to evaluate
+ * @return {boolean} true if typeof oDD = DragDrop
+ */
+ this.isTypeOfDD = function (oDD) {
+ return (oDD && oDD.__ygDragDrop);
+ };
+
+ /**
+ * Utility function to determine if a given element has been
+ * registered as a drag drop handle for the given Drag Drop object.
+ *
+ * @param {String} id the element id to check
+ * @return {boolean} true if this element is a DragDrop handle, false
+ * otherwise
+ */
+ this.isHandle = function(sDDId, sHandleId) {
+ return ( this.handleIds[sDDId] &&
+ this.handleIds[sDDId][sHandleId] );
+ };
+
+ /**
+ * Returns the DragDrop instance for a given id
+ *
+ * @param {String} id the id of the DragDrop object
+ * @return {DragDrop} the drag drop object, null if it is not found
+ */
+ this.getDDById = function(id) {
+ for (var i in this.ids) {
+ if (this.ids[i][id]) {
+ return this.ids[i][id];
+ }
+ }
+ return null;
+ };
+
+ /**
+ * Fired after a registered DragDrop object gets the mousedown event.
+ * Sets up the events required to track the object being dragged
+ *
+ * @param {Event} e the event
+ * @param oDD the DragDrop object being dragged
+ * @private
+ */
+ this.handleMouseDown = function(e, oDD) {
+
+ this.currentTarget = YAHOO.util.Event.getTarget(e);
+
+ this.logger.log("mousedown - adding event handlers");
+ this.dragCurrent = oDD;
+
+ var el = oDD.getEl();
+
+ // track start position
+ this.startX = YAHOO.util.Event.getPageX(e);
+ this.startY = YAHOO.util.Event.getPageY(e);
+
+ this.deltaX = this.startX - el.offsetLeft;
+ this.deltaY = this.startY - el.offsetTop;
+
+ this.dragThreshMet = false;
+
+ this.clickTimeout = setTimeout(
+ function() {
+ var DDM = YAHOO.util.DDM;
+ DDM.startDrag(DDM.startX, DDM.startY);
+ },
+ this.clickTimeThresh );
+ };
+
+ /**
+ * Fired when either the drag pixel threshol or the mousedown hold
+ * time threshold has been met.
+ *
+ * @param x {int} the X position of the original mousedown
+ * @param y {int} the Y position of the original mousedown
+ */
+ this.startDrag = function(x, y) {
+ this.logger.log("firing drag start events");
+ clearTimeout(this.clickTimeout);
+ if (this.dragCurrent) {
+ this.dragCurrent.b4StartDrag(x, y);
+ this.dragCurrent.startDrag(x, y);
+ }
+ this.dragThreshMet = true;
+ };
+
+ /**
+ * Internal function to handle the mouseup event. Will be invoked
+ * from the context of the document.
+ *
+ * @param {Event} e the event
+ * @private
+ */
+ this.handleMouseUp = function(e) {
+
+ if (! this.dragCurrent) {
+ return;
+ }
+
+ clearTimeout(this.clickTimeout);
+
+ if (this.dragThreshMet) {
+ this.logger.log("mouseup detected - completing drag");
+ this.fireEvents(e, true);
+ } else {
+ this.logger.log("drag threshold not met");
+ }
+
+ this.stopDrag(e);
+
+ this.stopEvent(e);
+ };
+
+ /**
+ * Utility to stop event propagation and event default, if these
+ * features are turned on.
+ *
+ * @param {Event} e the event as returned by this.getEvent()
+ */
+ this.stopEvent = function(e) {
+ if (this.stopPropagation) {
+ YAHOO.util.Event.stopPropagation(e);
+ }
+
+ if (this.preventDefault) {
+ YAHOO.util.Event.preventDefault(e);
+ }
+ };
+
+ /**
+ * Internal function to clean up event handlers after the drag
+ * operation is complete
+ *
+ * @param {Event} e the event
+ * @private
+ */
+ this.stopDrag = function(e) {
+ // this.logger.log("mouseup - removing event handlers");
+
+ // Fire the drag end event for the item that was dragged
+ if (this.dragCurrent) {
+ if (this.dragThreshMet) {
+ this.logger.log("firing endDrag events");
+ this.dragCurrent.b4EndDrag(e);
+ this.dragCurrent.endDrag(e);
+ }
+
+ this.logger.log("firing mouseUp event");
+ this.dragCurrent.onMouseUp(e);
+ }
+
+ this.dragCurrent = null;
+ this.dragOvers = {};
+ };
+
+
+ /**
+ * Internal function to handle the mousemove event. Will be invoked
+ * from the context of the html element.
+ *
+ * @TODO figure out what we can do about mouse events lost when the
+ * user drags objects beyond the window boundary. Currently we can
+ * detect this in internet explorer by verifying that the mouse is
+ * down during the mousemove event. Firefox doesn't give us the
+ * button state on the mousemove event.
+ *
+ * @param {Event} e the event
+ * @private
+ */
+ this.handleMouseMove = function(e) {
+ if (! this.dragCurrent) {
+ // this.logger.log("no current drag obj");
+ return true;
+ }
+
+ // var button = e.which || e.button;
+ // this.logger.log("which: " + e.which + ", button: "+ e.button);
+
+ // check for IE mouseup outside of page boundary
+ if (YAHOO.util.Event.isIE && !e.button) {
+ this.logger.log("button failure");
+ this.stopEvent(e);
+ return this.handleMouseUp(e);
+ }
+
+ if (!this.dragThreshMet) {
+ var diffX = Math.abs(this.startX - YAHOO.util.Event.getPageX(e));
+ var diffY = Math.abs(this.startY - YAHOO.util.Event.getPageY(e));
+ // this.logger.log("diffX: " + diffX + "diffY: " + diffY);
+ if (diffX > this.clickPixelThresh ||
+ diffY > this.clickPixelThresh) {
+ this.logger.log("pixel threshold met");
+ this.startDrag(this.startX, this.startY);
+ }
+ }
+
+ if (this.dragThreshMet) {
+ this.dragCurrent.b4Drag(e);
+ this.dragCurrent.onDrag(e);
+ this.fireEvents(e, false);
+ }
+
+ this.stopEvent(e);
+
+ return true;
+ };
+
+ /**
+ * Iterates over all of the DragDrop elements to find ones we are
+ * hovering over or dropping on
+ *
+ * @param {Event} e the event
+ * @param {boolean} isDrop is this a drop op or a mouseover op?
+ * @private
+ */
+ this.fireEvents = function(e, isDrop) {
+ var dc = this.dragCurrent;
+
+ // If the user did the mouse up outside of the window, we could
+ // get here even though we have ended the drag.
+ if (!dc || dc.isLocked()) {
+ return;
+ }
+
+ var x = YAHOO.util.Event.getPageX(e);
+ var y = YAHOO.util.Event.getPageY(e);
+ var pt = new YAHOO.util.Point(x,y);
+
+ // cache the previous dragOver array
+ var oldOvers = [];
+
+ var outEvts = [];
+ var overEvts = [];
+ var dropEvts = [];
+ var enterEvts = [];
+
+ // Check to see if the object(s) we were hovering over is no longer
+ // being hovered over so we can fire the onDragOut event
+ for (var i in this.dragOvers) {
+
+ var ddo = this.dragOvers[i];
+
+ if (! this.isTypeOfDD(ddo)) {
+ continue;
+ }
+
+ if (! this.isOverTarget(pt, ddo, this.mode)) {
+ outEvts.push( ddo );
+ }
+
+ oldOvers[i] = true;
+ delete this.dragOvers[i];
+ }
+
+ for (var sGroup in dc.groups) {
+ // this.logger.log("Processing group " + sGroup);
+
+ if ("string" != typeof sGroup) {
+ continue;
+ }
+
+ for (i in this.ids[sGroup]) {
+ var oDD = this.ids[sGroup][i];
+ if (! this.isTypeOfDD(oDD)) {
+ continue;
+ }
+
+ if (oDD.isTarget && !oDD.isLocked() && oDD != dc) {
+ if (this.isOverTarget(pt, oDD, this.mode)) {
+ // look for drop interactions
+ if (isDrop) {
+ dropEvts.push( oDD );
+ // look for drag enter and drag over interactions
+ } else {
+
+ // initial drag over: dragEnter fires
+ if (!oldOvers[oDD.id]) {
+ enterEvts.push( oDD );
+ // subsequent drag overs: dragOver fires
+ } else {
+ overEvts.push( oDD );
+ }
+
+ this.dragOvers[oDD.id] = oDD;
+ }
+ }
+ }
+ }
+ }
+
+ if (this.mode) {
+ if (outEvts.length) {
+ this.logger.log(dc.id+" onDragOut: " + outEvts);
+ dc.b4DragOut(e, outEvts);
+ dc.onDragOut(e, outEvts);
+ }
+
+ if (enterEvts.length) {
+ this.logger.log(dc.id+" onDragEnter: " + enterEvts);
+ dc.onDragEnter(e, enterEvts);
+ }
+
+ if (overEvts.length) {
+ this.logger.log(dc.id+" onDragOver: " + overEvts);
+ dc.b4DragOver(e, overEvts);
+ dc.onDragOver(e, overEvts);
+ }
+
+ if (dropEvts.length) {
+ this.logger.log(dc.id+" onDragDrop: " + dropEvts);
+ dc.b4DragDrop(e, dropEvts);
+ dc.onDragDrop(e, dropEvts);
+ }
+
+ } else {
+ // fire dragout events
+ var len = 0;
+ for (i=0, len=outEvts.length; i<len; ++i) {
+ this.logger.log(dc.id+" onDragOut: " + outEvts[i].id);
+ dc.b4DragOut(e, outEvts[i].id);
+ dc.onDragOut(e, outEvts[i].id);
+ }
+
+ // fire enter events
+ for (i=0,len=enterEvts.length; i<len; ++i) {
+ this.logger.log(dc.id + " onDragEnter " + enterEvts[i].id);
+ // dc.b4DragEnter(e, oDD.id);
+ dc.onDragEnter(e, enterEvts[i].id);
+ }
+
+ // fire over events
+ for (i=0,len=overEvts.length; i<len; ++i) {
+ this.logger.log(dc.id + " onDragOver " + overEvts[i].id);
+ dc.b4DragOver(e, overEvts[i].id);
+ dc.onDragOver(e, overEvts[i].id);
+ }
+
+ // fire drop events
+ for (i=0, len=dropEvts.length; i<len; ++i) {
+ this.logger.log(dc.id + " dropped on " + dropEvts[i].id);
+ dc.b4DragDrop(e, dropEvts[i].id);
+ dc.onDragDrop(e, dropEvts[i].id);
+ }
+
+ }
+
+ };
+
+ /**
+ * Helper function for getting the best match from the list of drag
+ * and drop objects returned by the drag and drop events when we are
+ * in INTERSECT mode. It returns either the first object that the
+ * cursor is over, or the object that has the greatest overlap with
+ * the dragged element.
+ *
+ * @param {DragDrop[]} dds The array of drag and drop objects
+ * targeted
+ * @return {DragDrop} The best single match
+ */
+ this.getBestMatch = function(dds) {
+ var winner = null;
+ // Return null if the input is not what we expect
+ //if (!dds || !dds.length || dds.length == 0) {
+ // winner = null;
+ // If there is only one item, it wins
+ //} else if (dds.length == 1) {
+
+ var len = dds.length;
+
+ if (len == 1) {
+ winner = dds[0];
+ } else {
+ // Loop through the targeted items
+ for (var i=0; i<len; ++i) {
+ var dd = dds[i];
+ // If the cursor is over the object, it wins. If the
+ // cursor is over multiple matches, the first one we come
+ // to wins.
+ if (dd.cursorIsOver) {
+ winner = dd;
+ break;
+ // Otherwise the object with the most overlap wins
+ } else {
+ if (!winner ||
+ winner.overlap.getArea() < dd.overlap.getArea()) {
+ winner = dd;
+ }
+ }
+ }
+ }
+
+ return winner;
+ };
+
+ /**
+ * Refreshes the cache of the top-left and bottom-right points of the
+ * drag and drop objects in the specified groups
+ *
+ * @param {Object} groups an associative array of groups to refresh
+ */
+ this.refreshCache = function(groups) {
+ this.logger.log("refreshing element location cache");
+ for (sGroup in groups) {
+ if ("string" != typeof sGroup) {
+ continue;
+ }
+ for (i in this.ids[sGroup]) {
+ var oDD = this.ids[sGroup][i];
+
+ if (this.isTypeOfDD(oDD)) {
+ // if (this.isTypeOfDD(oDD) && oDD.isTarget) {
+ var loc = this.getLocation(oDD);
+ if (loc) {
+ this.locationCache[oDD.id] = loc;
+ } else {
+ delete this.locationCache[oDD.id];
+ this.logger.log("Could not get the loc for " + oDD.id,
+ "warn");
+ // this will unregister the drag and drop object if
+ // the element is not in a usable state
+ // oDD.unreg();
+ }
+ }
+ }
+ }
+ };
+
+ /**
+ * This checks to make sure an element exists and is in the DOM. The
+ * main purpose is to handle cases where innerHTML is used to remove
+ * drag and drop objects from the DOM. IE provides an 'unspecified
+ * error' when trying to access the offsetParent of such an element
+ * @param {HTMLElement} el the element to check
+ * @return {boolean} true if the element looks usable
+ */
+ this.verifyEl = function(el) {
+ try {
+ if (el) {
+ var parent = el.offsetParent;
+ if (parent) {
+ return true;
+ }
+ }
+ } catch(e) {
+ this.logger.log("detected problem with an element");
+ }
+
+ return false;
+ };
+
+ /**
+ * Returns the an array containing the drag and drop element's position
+ * and size, including the DragDrop.padding configured for it
+ *
+ * @param {DragDrop} oDD the drag and drop object to get the
+ * location for
+ * @return array containing the top left and bottom right points of the
+ * element
+ */
+ this.getLocation = function(oDD) {
+ if (! this.isTypeOfDD(oDD)) {
+ this.logger.log(oDD + " is not a DD obj");
+ return null;
+ }
+
+ var el = oDD.getEl();
+
+ // element will not have an offsetparent if it was removed from the
+ // document or display=none
+ // if (!this.verifyEl(el)) {
+ // this.logger.log(oDD + " element is not usable");
+ // return null;
+ // }
+
+ // this.logger.log(oDD.id + " padding: " + oDD.padding);
+
+ // var aPos = ygPos.getPos(el);
+ var aPos = null;
+ try {
+ aPos= YAHOO.util.Dom.getXY(el);
+ } catch (e) { }
+
+ if (!aPos) {
+ return null;
+ }
+
+ x1 = aPos[0];
+ x2 = x1 + el.offsetWidth;
+
+ y1 = aPos[1];
+ y2 = y1 + el.offsetHeight;
+
+ var t = y1 - oDD.padding[0];
+ var r = x2 + oDD.padding[1];
+ var b = y2 + oDD.padding[2];
+ var l = x1 - oDD.padding[3];
+
+ return new YAHOO.util.Region( t, r, b, l );
+
+ };
+
+ /**
+ * Checks the cursor location to see if it over the target
+ *
+ * @param {YAHOO.util.Point} pt The point to evaluate
+ * @param {DragDrop} oTarget the DragDrop object we are inspecting
+ * @return {boolean} true if the mouse is over the target
+ * @private
+ */
+ this.isOverTarget = function(pt, oTarget, intersect) {
+ // use cache if available
+ var loc = this.locationCache[oTarget.id];
+ if (!loc || !this.useCache) {
+ this.logger.log("cache not populated");
+ loc = this.getLocation(oTarget);
+ this.locationCache[oTarget.id] = loc;
+
+ this.logger.log("cache: " + loc);
+ }
+
+ if (!loc) {
+ return false;
+ }
+
+ oTarget.cursorIsOver = loc.contains( pt );
+
+ // DragDrop is using this as a sanity check for the initial mousedown
+ // in this case we are done. In POINT mode, if the drag obj has no
+ // contraints, we are also done. Otherwise we need to evaluate the
+ // location of the target as related to the actual location of the
+ // dragged element.
+ var dc = this.dragCurrent;
+ if (!dc || (!intersect && !dc.constrainX && !dc.constrainY)) {
+ return oTarget.cursorIsOver;
+ }
+
+ oTarget.overlap = null;
+
+ // Get the current location of the drag element, this is the
+ // location of the mouse event less the delta that represents
+ // where the original mousedown happened on the element. We
+ // need to consider constraints and ticks as well.
+ var pos = dc.getTargetCoord(pt.x, pt.y);
+
+ var el = dc.getDragEl();
+ var curRegion = new YAHOO.util.Region( pos.y,
+ pos.x + el.offsetWidth,
+ pos.y + el.offsetHeight,
+ pos.x );
+
+ var overlap = curRegion.intersect(loc);
+
+ if (overlap) {
+ oTarget.overlap = overlap;
+ return (intersect) ? true : oTarget.cursorIsOver;
+ } else {
+ return false;
+ }
+ };
+
+ /**
+ * @private
+ */
+ this._onUnload = function(e, me) {
+ this.unregAll();
+ };
+
+ /**
+ * Cleans up the drag and drop events and objects.
+ * @private
+ */
+ this.unregAll = function() {
+ this.logger.log("unregister all");
+
+ if (this.dragCurrent) {
+ this.stopDrag();
+ this.dragCurrent = null;
+ }
+
+ this._execOnAll("unreg", []);
+
+ for (i in this.elementCache) {
+ delete this.elementCache[i];
+ }
+
+ this.elementCache = {};
+ this.ids = {};
+ };
+
+ /**
+ * A cache of DOM elements
+ * @private
+ */
+ this.elementCache = {};
+
+ /**
+ * Get the wrapper for the DOM element specified
+ *
+ * @param {String} id the id of the elment to get
+ * @return {YAHOO.util.DDM.ElementWrapper} the wrapped element
+ * @private
+ * @deprecated
+ */
+ this.getElWrapper = function(id) {
+ var oWrapper = this.elementCache[id];
+ if (!oWrapper || !oWrapper.el) {
+ oWrapper = this.elementCache[id] =
+ new this.ElementWrapper(YAHOO.util.Dom.get(id));
+ }
+ return oWrapper;
+ };
+
+ /**
+ * Returns the actual DOM element
+ *
+ * @param {String} id the id of the elment to get
+ * @return {Object} The element
+ * @deprecated
+ */
+ this.getElement = function(id) {
+ return YAHOO.util.Dom.get(id);
+ };
+
+ /**
+ * Returns the style property for the DOM element (i.e.,
+ * document.getElById(id).style)
+ *
+ * @param {String} id the id of the elment to get
+ * @return {Object} The style property of the element
+ * @deprecated
+ */
+ this.getCss = function(id) {
+ var el = YAHOO.util.Dom.get(id);
+ return (el) ? el.style : null;
+ };
+
+ /**
+ * Inner class for cached elements
+ * @private
+ * @deprecated
+ */
+ this.ElementWrapper = function(el) {
+ /**
+ * @private
+ */
+ this.el = el || null;
+ /**
+ * @private
+ */
+ this.id = this.el && el.id;
+ /**
+ * @private
+ */
+ this.css = this.el && el.style;
+ };
+
+ /**
+ * Returns the X position of an html element
+ * @param el the element for which to get the position
+ * @return {int} the X coordinate
+ * @deprecated
+ */
+ this.getPosX = function(el) {
+ return YAHOO.util.Dom.getX(el);
+ };
+
+ /**
+ * Returns the Y position of an html element
+ * @param el the element for which to get the position
+ * @return {int} the Y coordinate
+ * @deprecated
+ */
+ this.getPosY = function(el) {
+ return YAHOO.util.Dom.getY(el);
+ };
+
+ /**
+ * Swap two nodes. In IE, we use the native method, for others we
+ * emulate the IE behavior
+ *
+ * @param n1 the first node to swap
+ * @param n2 the other node to swap
+ */
+ this.swapNode = function(n1, n2) {
+ if (n1.swapNode) {
+ n1.swapNode(n2);
+ } else {
+ // the node reference order for the swap is a little tricky.
+ var p = n2.parentNode;
+ var s = n2.nextSibling;
+ n1.parentNode.replaceChild(n2, n1);
+ p.insertBefore(n1,s);
+ }
+ };
+
+ /**
+ * @private
+ */
+ this.getScroll = function () {
+ var t, l;
+ if (document.documentElement && document.documentElement.scrollTop) {
+ t = document.documentElement.scrollTop;
+ l = document.documentElement.scrollLeft;
+ } else if (document.body) {
+ t = document.body.scrollTop;
+ l = document.body.scrollLeft;
+ }
+ return { top: t, left: l };
+ };
+
+ /**
+ * Returns the specified element style property
+ * @param {HTMLElement} el the element
+ * @param {string} styleProp the style property
+ * @return {string} The value of the style property
+ * @deprecated, use YAHOO.util.Dom.getStyle
+ */
+ this.getStyle = function(el, styleProp) {
+ return YAHOO.util.Dom.getStyle(el, styleProp);
+ };
+
+ /**
+ * Gets the scrollTop
+ * @return {int} the document's scrollTop
+ */
+ this.getScrollTop = function () { return this.getScroll().top; };
+
+ /**
+ * Gets the scrollLeft
+ * @return {int} the document's scrollTop
+ */
+ this.getScrollLeft = function () { return this.getScroll().left; };
+
+ /**
+ * Sets the x/y position of an element to the location of the
+ * target element.
+ * @param {HTMLElement} moveEl The element to move
+ * @param {HTMLElement} targetEl The position reference element
+ */
+ this.moveToEl = function (moveEl, targetEl) {
+ var aCoord = YAHOO.util.Dom.getXY(targetEl);
+ this.logger.log("moveToEl: " + aCoord);
+ YAHOO.util.Dom.setXY(moveEl, aCoord);
+ };
+
+ /**
+ * Gets the client height
+ * @return {int} client height in px
+ * @deprecated
+ */
+ this.getClientHeight = function() {
+ return YAHOO.util.Dom.getClientHeight();
+ };
+
+ /**
+ * Gets the client width
+ * @return {int} client width in px
+ * @deprecated
+ */
+ this.getClientWidth = function() {
+ return YAHOO.util.Dom.getClientWidth();
+ };
+
+ /**
+ * numeric array sort function
+ */
+ this.numericSort = function(a, b) { return (a - b); };
+
+ /**
+ * @private
+ */
+ this._timeoutCount = 0;
+
+ /**
+ * Trying to make the load order less important. Without this we get
+ * an error if this file is loaded before the Event Utility.
+ * @private
+ */
+ this._addListeners = function() {
+ if ( YAHOO.util.Event && document ) {
+ this._onLoad();
+ } else {
+ if (this._timeoutCount > 1000) {
+ this.logger.log("DragDrop requires the Event Utility");
+ } else {
+ var DDM = YAHOO.util.DDM;
+ setTimeout( function() { DDM._addListeners(); }, 10);
+ if (document && document.body) {
+ this._timeoutCount += 1;
+ }
+ }
+ }
+ };
+
+ /**
+ * Recursively searches the immediate parent and all child nodes for
+ * the handle element in order to determine wheter or not it was
+ * clicked.
+ * @param node the html element to inspect
+ */
+ this.handleWasClicked = function(node, id) {
+ if (this.isHandle(id, node.id)) {
+ this.logger.log("clicked node is a handle");
+ return true;
+ } else {
+ // check to see if this is a text node child of the one we want
+ var p = node.parentNode;
+ // this.logger.log("p: " + p);
+
+ while (p) {
+ if (this.isHandle(id, p.id)) {
+ return true;
+ } else {
+ this.logger.log(p.id + " is not a handle");
+ p = p.parentNode;
+ }
+ }
+ }
+
+ return false;
+ };
+
+ } ();
+
+ // shorter alias, save a few bytes
+ YAHOO.util.DDM = YAHOO.util.DragDropMgr;
+ YAHOO.util.DDM._addListeners();
+
+}
+
+/**
+ * A DragDrop implementation where the linked element follows the
+ * mouse cursor during a drag.
+ *
+ * @extends YAHOO.util.DragDrop
+ * @constructor
+ * @param {String} id the id of the linked element
+ * @param {String} sGroup the group of related DragDrop items
+ * @param {object} config an object containing configurable attributes
+ * Valid properties for DD:
+ * scroll
+ */
+YAHOO.util.DD = function(id, sGroup, config) {
+ if (id) {
+ this.init(id, sGroup, config);
+ }
+};
+
+// YAHOO.util.DD.prototype = new YAHOO.util.DragDrop();
+YAHOO.extend(YAHOO.util.DD, YAHOO.util.DragDrop);
+
+/**
+ * When set to true, the utility automatically tries to scroll the browser
+ * window wehn a drag and drop element is dragged near the viewport boundary.
+ * Defaults to true.
+ *
+ * @type boolean
+ */
+YAHOO.util.DD.prototype.scroll = true;
+
+/**
+ * Sets the pointer offset to the distance between the linked element's top
+ * left corner and the location the element was clicked
+ *
+ * @param {int} iPageX the X coordinate of the click
+ * @param {int} iPageY the Y coordinate of the click
+ */
+YAHOO.util.DD.prototype.autoOffset = function(iPageX, iPageY) {
+ // var el = this.getEl();
+ // var aCoord = YAHOO.util.Dom.getXY(el);
+ // var x = iPageX - aCoord[0];
+ // var y = iPageY - aCoord[1];
+ var x = iPageX - this.startPageX;
+ var y = iPageY - this.startPageY;
+ this.setDelta(x, y);
+ // this.logger.log("autoOffset el pos: " + aCoord + ", delta: " + x + "," + y);
+};
+
+/**
+ * Sets the pointer offset. You can call this directly to force the offset to
+ * be in a particular location (e.g., pass in 0,0 to set it to the center of the
+ * object, as done in YAHOO.widget.Slider)
+ *
+ * @param {int} iDeltaX the distance from the left
+ * @param {int} iDeltaY the distance from the top
+ */
+YAHOO.util.DD.prototype.setDelta = function(iDeltaX, iDeltaY) {
+ this.deltaX = iDeltaX;
+ this.deltaY = iDeltaY;
+ this.logger.log("deltaX:" + this.deltaX + ", deltaY:" + this.deltaY);
+};
+
+/**
+ * Sets the drag element to the location of the mousedown or click event,
+ * maintaining the cursor location relative to the location on the element
+ * that was clicked. Override this if you want to place the element in a
+ * location other than where the cursor is.
+ *
+ * @param {int} iPageX the X coordinate of the mousedown or drag event
+ * @param {int} iPageY the Y coordinate of the mousedown or drag event
+ */
+
+YAHOO.util.DD.prototype.setDragElPos = function(iPageX, iPageY) {
+ // the first time we do this, we are going to check to make sure
+ // the element has css positioning
+
+ var el = this.getDragEl();
+
+ // if (!this.cssVerified) {
+ // var pos = el.style.position;
+ // this.logger.log("drag element position: " + pos);
+ // }
+
+ this.alignElWithMouse(el, iPageX, iPageY);
+};
+
+/**
+ * Sets the element to the location of the mousedown or click event,
+ * maintaining the cursor location relative to the location on the element
+ * that was clicked. Override this if you want to place the element in a
+ * location other than where the cursor is.
+ *
+ * @param {HTMLElement} el the element to move
+ * @param {int} iPageX the X coordinate of the mousedown or drag event
+ * @param {int} iPageY the Y coordinate of the mousedown or drag event
+ */
+YAHOO.util.DD.prototype.alignElWithMouse = function(el, iPageX, iPageY) {
+ var oCoord = this.getTargetCoord(iPageX, iPageY);
+ // this.logger.log("****alignElWithMouse : " + el.id + ", " + aCoord + ", " + el.style.display);
+
+ // this.deltaSetXY = null;
+ if (!this.deltaSetXY) {
+ var aCoord = [oCoord.x, oCoord.y];
+ YAHOO.util.Dom.setXY(el, aCoord);
+ var newLeft = parseInt( YAHOO.util.Dom.getStyle(el, "left"), 10 );
+ var newTop = parseInt( YAHOO.util.Dom.getStyle(el, "top" ), 10 );
+
+ this.deltaSetXY = [ newLeft - oCoord.x, newTop - oCoord.y ];
+
+ // this.logger.log("css X: " + YAHOO.util.Dom.getStyle(el, "left"));
+ // this.logger.log("css Y: " + YAHOO.util.Dom.getStyle(el, "top"));
+ // this.logger.log("deltaSetXY: " + this.deltaSetXY);
+ } else {
+ YAHOO.util.Dom.setStyle(el, "left", (oCoord.x + this.deltaSetXY[0]) + "px");
+ YAHOO.util.Dom.setStyle(el, "top", (oCoord.y + this.deltaSetXY[1]) + "px");
+ }
+
+
+ this.cachePosition(oCoord.x, oCoord.y);
+
+ this.autoScroll(oCoord.x, oCoord.y, el.offsetHeight, el.offsetWidth);
+};
+
+/**
+ * Saves the most recent position so that we can reset the constraints and
+ * tick marks on-demand. We need to know this so that we can calculate the
+ * number of pixels the element is offset from its original position.
+ */
+YAHOO.util.DD.prototype.cachePosition = function(iPageX, iPageY) {
+ if (iPageX) {
+ this.lastPageX = iPageX;
+ this.lastPageY = iPageY;
+ } else {
+ var aCoord = YAHOO.util.Dom.getXY(this.getEl());
+ this.lastPageX = aCoord[0];
+ this.lastPageY = aCoord[1];
+ }
+};
+
+/**
+ * Auto-scroll the window if the dragged object has been moved beyond the
+ * visible window boundary.
+ *
+ * @param {int} x the drag element's x position
+ * @param {int} y the drag element's y position
+ * @param {int} h the height of the drag element
+ * @param {int} w the width of the drag element
+ * @private
+ */
+YAHOO.util.DD.prototype.autoScroll = function(x, y, h, w) {
+
+ if (this.scroll) {
+ // The client height
+ var clientH = this.DDM.getClientHeight();
+
+ // The client width
+ var clientW = this.DDM.getClientWidth();
+
+ // The amt scrolled down
+ var st = this.DDM.getScrollTop();
+
+ // The amt scrolled right
+ var sl = this.DDM.getScrollLeft();
+
+ // Location of the bottom of the element
+ var bot = h + y;
+
+ // Location of the right of the element
+ var right = w + x;
+
+ // The distance from the cursor to the bottom of the visible area,
+ // adjusted so that we don't scroll if the cursor is beyond the
+ // element drag constraints
+ var toBot = (clientH + st - y - this.deltaY);
+
+ // The distance from the cursor to the right of the visible area
+ var toRight = (clientW + sl - x - this.deltaX);
+
+ // this.logger.log( " x: " + x + " y: " + y + " h: " + h +
+ // " clientH: " + clientH + " clientW: " + clientW +
+ // " st: " + st + " sl: " + sl + " bot: " + bot +
+ // " right: " + right + " toBot: " + toBot + " toRight: " + toRight);
+
+ // How close to the edge the cursor must be before we scroll
+ // var thresh = (document.all) ? 100 : 40;
+ var thresh = 40;
+
+ // How many pixels to scroll per autoscroll op. This helps to reduce
+ // clunky scrolling. IE is more sensitive about this ... it needs this
+ // value to be higher.
+ var scrAmt = (document.all) ? 80 : 30;
+
+ // Scroll down if we are near the bottom of the visible page and the
+ // obj extends below the crease
+ if ( bot > clientH && toBot < thresh ) {
+ window.scrollTo(sl, st + scrAmt);
+ }
+
+ // Scroll up if the window is scrolled down and the top of the object
+ // goes above the top border
+ if ( y < st && st > 0 && y - st < thresh ) {
+ window.scrollTo(sl, st - scrAmt);
+ }
+
+ // Scroll right if the obj is beyond the right border and the cursor is
+ // near the border.
+ if ( right > clientW && toRight < thresh ) {
+ window.scrollTo(sl + scrAmt, st);
+ }
+
+ // Scroll left if the window has been scrolled to the right and the obj
+ // extends past the left border
+ if ( x < sl && sl > 0 && x - sl < thresh ) {
+ window.scrollTo(sl - scrAmt, st);
+ }
+ }
+};
+
+/**
+ * Finds the location the element should be placed if we want to move
+ * it to where the mouse location less the click offset would place us.
+ *
+ * @param {int} iPageX the X coordinate of the click
+ * @param {int} iPageY the Y coordinate of the click
+ * @return an object that contains the coordinates (Object.x and Object.y)
+ * @private
+ */
+YAHOO.util.DD.prototype.getTargetCoord = function(iPageX, iPageY) {
+
+ // this.logger.log("getTargetCoord: " + iPageX + ", " + iPageY);
+
+ var x = iPageX - this.deltaX;
+ var y = iPageY - this.deltaY;
+
+ if (this.constrainX) {
+ if (x < this.minX) { x = this.minX; }
+ if (x > this.maxX) { x = this.maxX; }
+ }
+
+ if (this.constrainY) {
+ if (y < this.minY) { y = this.minY; }
+ if (y > this.maxY) { y = this.maxY; }
+ }
+
+ x = this.getTick(x, this.xTicks);
+ y = this.getTick(y, this.yTicks);
+
+ // this.logger.log("getTargetCoord " +
+ // " iPageX: " + iPageX +
+ // " iPageY: " + iPageY +
+ // " x: " + x + ", y: " + y);
+
+ return {x:x, y:y};
+};
+
+YAHOO.util.DD.prototype.applyConfig = function() {
+ YAHOO.util.DD.superclass.applyConfig.call(this);
+ this.scroll = (this.config.scroll !== false);
+};
+
+/**
+ * Event that fires prior to the onMouseDown event. Overrides
+ * YAHOO.util.DragDrop.
+ */
+YAHOO.util.DD.prototype.b4MouseDown = function(e) {
+ // this.resetConstraints();
+ this.autoOffset(YAHOO.util.Event.getPageX(e),
+ YAHOO.util.Event.getPageY(e));
+};
+
+/**
+ * Event that fires prior to the onDrag event. Overrides
+ * YAHOO.util.DragDrop.
+ */
+YAHOO.util.DD.prototype.b4Drag = function(e) {
+ this.setDragElPos(YAHOO.util.Event.getPageX(e),
+ YAHOO.util.Event.getPageY(e));
+};
+
+YAHOO.util.DD.prototype.toString = function() {
+ return ("DD " + this.id);
+};
+
+///////////////////////////////////////////////////////////////////////////////
+// Debugging ygDragDrop events that can be overridden
+///////////////////////////////////////////////////////////////////////////////
+/*
+YAHOO.util.DD.prototype.startDrag = function(x, y) {
+ this.logger.log(this.id.toString() + " startDrag");
+};
+
+YAHOO.util.DD.prototype.onDrag = function(e) {
+ this.logger.log(this.id.toString() + " onDrag");
+};
+
+YAHOO.util.DD.prototype.onDragEnter = function(e, id) {
+ this.logger.log(this.id.toString() + " onDragEnter: " + id);
+};
+
+YAHOO.util.DD.prototype.onDragOver = function(e, id) {
+ this.logger.log(this.id.toString() + " onDragOver: " + id);
+};
+
+YAHOO.util.DD.prototype.onDragOut = function(e, id) {
+ this.logger.log(this.id.toString() + " onDragOut: " + id);
+};
+
+YAHOO.util.DD.prototype.onDragDrop = function(e, id) {
+ this.logger.log(this.id.toString() + " onDragDrop: " + id);
+};
+
+YAHOO.util.DD.prototype.endDrag = function(e) {
+ this.logger.log(this.id.toString() + " endDrag");
+};
+*/
+
+/**
+ * A DragDrop implementation that inserts an empty, bordered div into
+ * the document that follows the cursor during drag operations. At the time of
+ * the click, the frame div is resized to the dimensions of the linked html
+ * element, and moved to the exact location of the linked element.
+ *
+ * References to the "frame" element refer to the single proxy element that
+ * was created to be dragged in place of all DDProxy elements on the
+ * page.
+ *
+ * @extends YAHOO.util.DD
+ * @constructor
+ * @param {String} id the id of the linked html element
+ * @param {String} sGroup the group of related DragDrop objects
+ * @param {object} config an object containing configurable attributes
+ * Valid properties for DDProxy in addition to those in DragDrop:
+ * resizeFrame, centerFrame, dragElId
+ */
+YAHOO.util.DDProxy = function(id, sGroup, config) {
+ if (id) {
+ this.init(id, sGroup, config);
+ this.initFrame();
+ }
+};
+
+YAHOO.extend(YAHOO.util.DDProxy, YAHOO.util.DD);
+
+/**
+ * The default drag frame div id
+ * @type String
+ */
+YAHOO.util.DDProxy.dragElId = "ygddfdiv";
+
+/**
+ * By default we resize the drag frame to be the same size as the element
+ * we want to drag (this is to get the frame effect). We can turn it off
+ * if we want a different behavior.
+ *
+ * @type boolean
+ */
+YAHOO.util.DDProxy.prototype.resizeFrame = true;
+
+/**
+ * By default the frame is positioned exactly where the drag element is, so
+ * we use the cursor offset provided by YAHOO.util.DD. Another option that works only if
+ * you do not have constraints on the obj is to have the drag frame centered
+ * around the cursor. Set centerFrame to true for this effect.
+ *
+ * @type boolean
+ */
+YAHOO.util.DDProxy.prototype.centerFrame = false;
+
+/**
+ * Create the drag frame if needed
+ */
+YAHOO.util.DDProxy.prototype.createFrame = function() {
+ var self = this;
+ var body = document.body;
+
+ if (!body || !body.firstChild) {
+ setTimeout( function() { self.createFrame(); }, 50 );
+ return;
+ }
+
+ var div = this.getDragEl();
+
+ if (!div) {
+ div = document.createElement("div");
+ div.id = this.dragElId;
+ var s = div.style;
+
+ s.position = "absolute";
+ s.visibility = "hidden";
+ s.cursor = "move";
+ s.border = "2px solid #aaa";
+ s.zIndex = 999;
+
+ // appendChild can blow up IE if invoked prior to the window load event
+ // while rendering a table. It is possible there are other scenarios
+ // that would cause this to happen as well.
+ body.insertBefore(div, body.firstChild);
+ }
+};
+
+/**
+ * Initialization for the drag frame element. Must be called in the
+ * constructor of all subclasses
+ */
+YAHOO.util.DDProxy.prototype.initFrame = function() {
+ // YAHOO.util.DDProxy.createFrame();
+ // this.setDragElId(YAHOO.util.DDProxy.dragElId);
+
+ this.createFrame();
+
+};
+
+YAHOO.util.DDProxy.prototype.applyConfig = function() {
+ this.logger.log("DDProxy applyConfig");
+ YAHOO.util.DDProxy.superclass.applyConfig.call(this);
+
+ this.resizeFrame = (this.config.resizeFrame !== false);
+ this.centerFrame = (this.config.centerFrame);
+ this.setDragElId(this.config.dragElId || YAHOO.util.DDProxy.dragElId);
+
+ //this.logger.log("dragElId: " + this.dragElId);
+};
+
+/**
+ * Resizes the drag frame to the dimensions of the clicked object, positions
+ * it over the object, and finally displays it
+ *
+ * @param {int} iPageX X click position
+ * @param {int} iPageY Y click position
+ * @private
+ */
+YAHOO.util.DDProxy.prototype.showFrame = function(iPageX, iPageY) {
+ var el = this.getEl();
+ var dragEl = this.getDragEl();
+ var s = dragEl.style;
+
+ this._resizeProxy();
+
+ if (this.centerFrame) {
+ this.setDelta( Math.round(parseInt(s.width, 10)/2),
+ Math.round(parseInt(s.height, 10)/2) );
+ }
+
+ this.setDragElPos(iPageX, iPageY);
+
+ YAHOO.util.Dom.setStyle(dragEl, "visibility", "visible");
+};
+
+YAHOO.util.DDProxy.prototype._resizeProxy = function() {
+ var DOM = YAHOO.util.Dom;
+ var el = this.getEl();
+ var dragEl = this.getDragEl();
+
+ if (this.resizeFrame) {
+ var bt = parseInt( DOM.getStyle(dragEl, "borderTopWidth" ), 10);
+ var br = parseInt( DOM.getStyle(dragEl, "borderRightWidth" ), 10);
+ var bb = parseInt( DOM.getStyle(dragEl, "borderBottomWidth" ), 10);
+ var bl = parseInt( DOM.getStyle(dragEl, "borderLeftWidth" ), 10);
+
+ if (isNaN(bt)) { bt = 0; }
+ if (isNaN(br)) { br = 0; }
+ if (isNaN(bb)) { bb = 0; }
+ if (isNaN(bl)) { bl = 0; }
+
+ this.logger.log("proxy size: " + bt + " " + br + " " + bb + " " + bl);
+
+ var newWidth = el.offsetWidth - br - bl;
+ var newHeight = el.offsetHeight - bt - bb;
+
+ this.logger.log("Resizing proxy element");
+
+ DOM.setStyle( dragEl, "width", newWidth + "px" );
+ DOM.setStyle( dragEl, "height", newHeight + "px" );
+ }
+};
+
+// overrides YAHOO.util.DragDrop
+YAHOO.util.DDProxy.prototype.b4MouseDown = function(e) {
+ var x = YAHOO.util.Event.getPageX(e);
+ var y = YAHOO.util.Event.getPageY(e);
+ this.autoOffset(x, y);
+ this.setDragElPos(x, y);
+};
+
+// overrides YAHOO.util.DragDrop
+YAHOO.util.DDProxy.prototype.b4StartDrag = function(x, y) {
+ // show the drag frame
+ this.logger.log("start drag show frame, x: " + x + ", y: " + y);
+ this.showFrame(x, y);
+};
+
+// overrides YAHOO.util.DragDrop
+YAHOO.util.DDProxy.prototype.b4EndDrag = function(e) {
+ this.logger.log(this.id + " b4EndDrag");
+ YAHOO.util.Dom.setStyle(this.getDragEl(), "visibility", "hidden");
+};
+
+// overrides YAHOO.util.DragDrop
+// By default we try to move the element to the last location of the frame.
+// This is so that the default behavior mirrors that of YAHOO.util.DD.
+YAHOO.util.DDProxy.prototype.endDrag = function(e) {
+ var DOM = YAHOO.util.Dom;
+ this.logger.log(this.id + " endDrag");
+ var lel = this.getEl();
+ var del = this.getDragEl();
+
+ // Show the drag frame briefly so we can get its position
+ // del.style.visibility = "";
+ DOM.setStyle(del, "visibility", "");
+
+ // Hide the linked element before the move to get around a Safari
+ // rendering bug.
+ //lel.style.visibility = "hidden";
+ DOM.setStyle(lel, "visibility", "hidden");
+ YAHOO.util.DDM.moveToEl(lel, del);
+ //del.style.visibility = "hidden";
+ DOM.setStyle(del, "visibility", "hidden");
+ //lel.style.visibility = "";
+ DOM.setStyle(lel, "visibility", "");
+};
+
+YAHOO.util.DDProxy.prototype.toString = function() {
+ return ("DDProxy " + this.id);
+};
+
+/**
+ * A DragDrop implementation that does not move, but can be a drop
+ * target. You would get the same result by simply omitting implementation
+ * for the event callbacks, but this way we reduce the processing cost of the
+ * event listener and the callbacks.
+ *
+ * @extends YAHOO.util.DragDrop
+ * @constructor
+ * @param {String} id the id of the element that is a drop target
+ * @param {String} sGroup the group of related DragDrop objects
+ * @param {object} config an object containing configurable attributes
+ * Valid properties for DDTarget in addition to those in DragDrop:
+ * none
+ */
+
+YAHOO.util.DDTarget = function(id, sGroup, config) {
+ if (id) {
+ this.initTarget(id, sGroup, config);
+ }
+};
+
+// YAHOO.util.DDTarget.prototype = new YAHOO.util.DragDrop();
+YAHOO.extend(YAHOO.util.DDTarget, YAHOO.util.DragDrop);
+
+YAHOO.util.DDTarget.prototype.toString = function() {
+ return ("DDTarget " + this.id);
+};
+
Added: branches/tomek/portal-dnd/dndRenderer.war/js/dragdrop/dragdrop-min.js
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/dragdrop/dragdrop-min.js 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/dragdrop/dragdrop-min.js 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,9 @@
+
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 0.11.2
+*/
+
+YAHOO.util.DragDrop=function(id,_2,_3){if(id){this.init(id,_2,_3);}};YAHOO.util.DragDrop.prototype={id:null,config:null,dragElId:null,handleElId:null,invalidHandleTypes:null,invalidHandleIds:null,invalidHandleClasses:null,startPageX:0,startPageY:0,groups:null,locked:false,lock:function(){this.locked=true;},unlock:function(){this.locked=false;},isTarget:true,padding:null,_domRef:null,__ygDragDrop:true,constrainX:false,constrainY:false,minX:0,maxX:0,minY:0,maxY:0,maintainOffset:false,xTicks:null,yTicks:null,primaryButtonOnly:true,available:false,b4StartDrag:function(x,y){},startDrag:function(x,y){},b4Drag:function(e){},onDrag:function(e){},onDragEnter:function(e,id){},b4DragOver:function(e){},onDragOver:function(e,id){},b4DragOut:function(e){},onDragOut:function(e,id){},b4DragDrop:function(e){},onDragDrop:function(e,id){},b4EndDrag:function(e){},endDrag:function(e){},b4MouseDown:function(e){},onMouseDown:function(e){},onMouseUp:function(e){},onAvailable:function(){},getEl:fun!
ction(){if(!this._domRef){this._domRef=YAHOO.util.Dom.get(this.id);}return this._domRef;},getDragEl:function(){return YAHOO.util.Dom.get(this.dragElId);},init:function(id,_7,_8){this.initTarget(id,_7,_8);YAHOO.util.Event.addListener(this.id,"mousedown",this.handleMouseDown,this,true);},initTarget:function(id,_9,_10){this.config=_10||{};this.DDM=YAHOO.util.DDM;this.groups={};this.id=id;this.addToGroup((_9)?_9:"default");this.handleElId=id;YAHOO.util.Event.onAvailable(id,this.handleOnAvailable,this,true);this.setDragElId(id);this.invalidHandleTypes={A:"A"};this.invalidHandleIds={};this.invalidHandleClasses=[];this.applyConfig();},applyConfig:function(){this.padding=this.config.padding||[0,0,0,0];this.isTarget=(this.config.isTarget!==false);this.maintainOffset=(this.config.maintainOffset);this.primaryButtonOnly=(this.config.primaryButtonOnly!==false);},handleOnAvailable:function(){this.available=true;this.resetConstraints();this.onAvailable();},setPadding:function(_11,_12,_13,!
_14){if(!_12&&0!==_12){this.padding=[_11,_11,_11,_11];}else{if(!_13&&0
!==_13){this.padding=[_11,_12,_11,_12];}else{this.padding=[_11,_12,_13,_14];}}},setInitPosition:function(_15,_16){var el=this.getEl();if(!this.DDM.verifyEl(el)){return;}var dx=_15||0;var dy=_16||0;var p=YAHOO.util.Dom.getXY(el);this.initPageX=p[0]-dx;this.initPageY=p[1]-dy;this.lastPageX=p[0];this.lastPageY=p[1];this.setStartPosition(p);},setStartPosition:function(pos){var p=pos||YAHOO.util.Dom.getXY(this.getEl());this.deltaSetXY=null;this.startPageX=p[0];this.startPageY=p[1];},addToGroup:function(_22){this.groups[_22]=true;this.DDM.regDragDrop(this,_22);},removeFromGroup:function(_23){if(this.groups[_23]){delete this.groups[_23];}this.DDM.removeDDFromGroup(this,_23);},setDragElId:function(id){this.dragElId=id;},setHandleElId:function(id){this.handleElId=id;this.DDM.regHandle(this.id,id);},setOuterHandleElId:function(id){YAHOO.util.Event.addListener(id,"mousedown",this.handleMouseDown,this,true);this.setHandleElId(id);},unreg:function(){YAHOO.util.Event.removeListener(this.i!
d,"mousedown",this.handleMouseDown);this._domRef=null;this.DDM._remove(this);},isLocked:function(){return (this.DDM.isLocked()||this.locked);},handleMouseDown:function(e,oDD){var EU=YAHOO.util.Event;var _26=e.which||e.button;if(this.primaryButtonOnly&&_26>1){return;}if(this.isLocked()){return;}this.DDM.refreshCache(this.groups);var pt=new YAHOO.util.Point(EU.getPageX(e),EU.getPageY(e));if(this.DDM.isOverTarget(pt,this)){var _28=EU.getTarget(e);if(this.isValidHandleChild(_28)&&(this.id==this.handleElId||this.DDM.handleWasClicked(_28,this.id))){this.setStartPosition();this.b4MouseDown(e);this.onMouseDown(e);this.DDM.handleMouseDown(e,this);this.DDM.stopEvent(e);}}},addInvalidHandleType:function(_29){var _30=_29.toUpperCase();this.invalidHandleTypes[_30]=_30;},addInvalidHandleId:function(id){this.invalidHandleIds[id]=id;},addInvalidHandleClass:function(_31){this.invalidHandleClasses.push(_31);},removeInvalidHandleType:function(_32){var _33=_32.toUpperCase();delete this.invalid!
HandleTypes[_33];},removeInvalidHandleId:function(id){delete this.inva
lidHandleIds[id];},removeInvalidHandleClass:function(_34){for(var i=0,len=this.invalidHandleClasses.length;i<len;++i){if(this.invalidHandleClasses[i]==_34){delete this.invalidHandleClasses[i];}}},isValidHandleChild:function(_36){var _37=true;var _38;try{_38=_36.nodeName.toUpperCase();}catch(e){_38=_36.nodeName;}_37=_37&&!this.invalidHandleTypes[_38];_37=_37&&!this.invalidHandleIds[_36.id];for(var i=0,len=this.invalidHandleClasses.length;_37&&i<len;++i){_37=!YAHOO.util.Dom.hasClass(_36,this.invalidHandleClasses[i]);}return _37;},setXTicks:function(_39,_40){this.xTicks=[];this.xTickSize=_40;var _41={};for(var i=this.initPageX;i>=this.minX;i=i-_40){if(!_41[i]){this.xTicks[this.xTicks.length]=i;_41[i]=true;}}for(i=this.initPageX;i<=this.maxX;i=i+_40){if(!_41[i]){this.xTicks[this.xTicks.length]=i;_41[i]=true;}}this.xTicks.sort(this.DDM.numericSort);},setYTicks:function(_42,_43){this.yTicks=[];this.yTickSize=_43;var _44={};for(var i=this.initPageY;i>=this.minY;i=i-_43){if(!_44[i])!
{this.yTicks[this.yTicks.length]=i;_44[i]=true;}}for(i=this.initPageY;i<=this.maxY;i=i+_43){if(!_44[i]){this.yTicks[this.yTicks.length]=i;_44[i]=true;}}this.yTicks.sort(this.DDM.numericSort);},setXConstraint:function(_45,_46,_47){this.leftConstraint=_45;this.rightConstraint=_46;this.minX=this.initPageX-_45;this.maxX=this.initPageX+_46;if(_47){this.setXTicks(this.initPageX,_47);}this.constrainX=true;},clearConstraints:function(){this.constrainX=false;this.constrainY=false;this.clearTicks();},clearTicks:function(){this.xTicks=null;this.yTicks=null;this.xTickSize=0;this.yTickSize=0;},setYConstraint:function(iUp,_49,_50){this.topConstraint=iUp;this.bottomConstraint=_49;this.minY=this.initPageY-iUp;this.maxY=this.initPageY+_49;if(_50){this.setYTicks(this.initPageY,_50);}this.constrainY=true;},resetConstraints:function(){if(this.initPageX||this.initPageX===0){var dx=(this.maintainOffset)?this.lastPageX-this.initPageX:0;var dy=(this.maintainOffset)?this.lastPageY-this.initPageY:0;!
this.setInitPosition(dx,dy);}else{this.setInitPosition();}if(this.cons
trainX){this.setXConstraint(this.leftConstraint,this.rightConstraint,this.xTickSize);}if(this.constrainY){this.setYConstraint(this.topConstraint,this.bottomConstraint,this.yTickSize);}},getTick:function(val,_52){if(!_52){return val;}else{if(_52[0]>=val){return _52[0];}else{for(var i=0,len=_52.length;i<len;++i){var _53=i+1;if(_52[_53]&&_52[_53]>=val){var _54=val-_52[i];var _55=_52[_53]-val;return (_55>_54)?_52[i]:_52[_53];}}return _52[_52.length-1];}}},toString:function(){return ("DragDrop "+this.id);}};if(!YAHOO.util.DragDropMgr){YAHOO.util.DragDropMgr=new function(){this.ids={};this.handleIds={};this.dragCurrent=null;this.dragOvers={};this.deltaX=0;this.deltaY=0;this.preventDefault=true;this.stopPropagation=true;this.initalized=false;this.locked=false;this.init=function(){this.initialized=true;};this.POINT=0;this.INTERSECT=1;this.mode=this.POINT;this._execOnAll=function(_56,_57){for(var i in this.ids){for(var j in this.ids[i]){var oDD=this.ids[i][j];if(!this.isTypeOfDD(oDD)!
){continue;}oDD[_56].apply(oDD,_57);}}};this._onLoad=function(){this.init();var EU=YAHOO.util.Event;EU.on(document,"mouseup",this.handleMouseUp,this,true);EU.on(document,"mousemove",this.handleMouseMove,this,true);EU.on(window,"unload",this._onUnload,this,true);EU.on(window,"resize",this._onResize,this,true);};this._onResize=function(e){this._execOnAll("resetConstraints",[]);};this.lock=function(){this.locked=true;};this.unlock=function(){this.locked=false;};this.isLocked=function(){return this.locked;};this.locationCache={};this.useCache=true;this.clickPixelThresh=3;this.clickTimeThresh=1000;this.dragThreshMet=false;this.clickTimeout=null;this.startX=0;this.startY=0;this.regDragDrop=function(oDD,_59){if(!this.initialized){this.init();}if(!this.ids[_59]){this.ids[_59]={};}this.ids[_59][oDD.id]=oDD;};this.removeDDFromGroup=function(oDD,_60){if(!this.ids[_60]){this.ids[_60]={};}var obj=this.ids[_60];if(obj&&obj[oDD.id]){delete obj[oDD.id];}};this._remove=function(oDD){for(var!
g in oDD.groups){if(g&&this.ids[g][oDD.id]){delete this.ids[g][oDD.id
];}}delete this.handleIds[oDD.id];};this.regHandle=function(_63,_64){if(!this.handleIds[_63]){this.handleIds[_63]={};}this.handleIds[_63][_64]=_64;};this.isDragDrop=function(id){return (this.getDDById(id))?true:false;};this.getRelated=function(_65,_66){var _67=[];for(var i in _65.groups){for(j in this.ids[i]){var dd=this.ids[i][j];if(!this.isTypeOfDD(dd)){continue;}if(!_66||dd.isTarget){_67[_67.length]=dd;}}}return _67;};this.isLegalTarget=function(oDD,_69){var _70=this.getRelated(oDD,true);for(var i=0,len=_70.length;i<len;++i){if(_70[i].id==_69.id){return true;}}return false;};this.isTypeOfDD=function(oDD){return (oDD&&oDD.__ygDragDrop);};this.isHandle=function(_71,_72){return (this.handleIds[_71]&&this.handleIds[_71][_72]);};this.getDDById=function(id){for(var i in this.ids){if(this.ids[i][id]){return this.ids[i][id];}}return null;};this.handleMouseDown=function(e,oDD){this.currentTarget=YAHOO.util.Event.getTarget(e);this.dragCurrent=oDD;var el=oDD.getEl();this.startX=YAHO!
O.util.Event.getPageX(e);this.startY=YAHOO.util.Event.getPageY(e);this.deltaX=this.startX-el.offsetLeft;this.deltaY=this.startY-el.offsetTop;this.dragThreshMet=false;this.clickTimeout=setTimeout(function(){var DDM=YAHOO.util.DDM;DDM.startDrag(DDM.startX,DDM.startY);},this.clickTimeThresh);};this.startDrag=function(x,y){clearTimeout(this.clickTimeout);if(this.dragCurrent){this.dragCurrent.b4StartDrag(x,y);this.dragCurrent.startDrag(x,y);}this.dragThreshMet=true;};this.handleMouseUp=function(e){if(!this.dragCurrent){return;}clearTimeout(this.clickTimeout);if(this.dragThreshMet){this.fireEvents(e,true);}else{}this.stopDrag(e);this.stopEvent(e);};this.stopEvent=function(e){if(this.stopPropagation){YAHOO.util.Event.stopPropagation(e);}if(this.preventDefault){YAHOO.util.Event.preventDefault(e);}};this.stopDrag=function(e){if(this.dragCurrent){if(this.dragThreshMet){this.dragCurrent.b4EndDrag(e);this.dragCurrent.endDrag(e);}this.dragCurrent.onMouseUp(e);}this.dragCurrent=null;this!
.dragOvers={};};this.handleMouseMove=function(e){if(!this.dragCurrent)
{return true;}if(YAHOO.util.Event.isIE&&!e.button){this.stopEvent(e);return this.handleMouseUp(e);}if(!this.dragThreshMet){var _74=Math.abs(this.startX-YAHOO.util.Event.getPageX(e));var _75=Math.abs(this.startY-YAHOO.util.Event.getPageY(e));if(_74>this.clickPixelThresh||_75>this.clickPixelThresh){this.startDrag(this.startX,this.startY);}}if(this.dragThreshMet){this.dragCurrent.b4Drag(e);this.dragCurrent.onDrag(e);this.fireEvents(e,false);}this.stopEvent(e);return true;};this.fireEvents=function(e,_76){var dc=this.dragCurrent;if(!dc||dc.isLocked()){return;}var x=YAHOO.util.Event.getPageX(e);var y=YAHOO.util.Event.getPageY(e);var pt=new YAHOO.util.Point(x,y);var _78=[];var _79=[];var _80=[];var _81=[];var _82=[];for(var i in this.dragOvers){var ddo=this.dragOvers[i];if(!this.isTypeOfDD(ddo)){continue;}if(!this.isOverTarget(pt,ddo,this.mode)){_79.push(ddo);}_78[i]=true;delete this.dragOvers[i];}for(var _84 in dc.groups){if("string"!=typeof _84){continue;}for(i in this.ids[_84])!
{var oDD=this.ids[_84][i];if(!this.isTypeOfDD(oDD)){continue;}if(oDD.isTarget&&!oDD.isLocked()&&oDD!=dc){if(this.isOverTarget(pt,oDD,this.mode)){if(_76){_81.push(oDD);}else{if(!_78[oDD.id]){_82.push(oDD);}else{_80.push(oDD);}this.dragOvers[oDD.id]=oDD;}}}}}if(this.mode){if(_79.length){dc.b4DragOut(e,_79);dc.onDragOut(e,_79);}if(_82.length){dc.onDragEnter(e,_82);}if(_80.length){dc.b4DragOver(e,_80);dc.onDragOver(e,_80);}if(_81.length){dc.b4DragDrop(e,_81);dc.onDragDrop(e,_81);}}else{var len=0;for(i=0,len=_79.length;i<len;++i){dc.b4DragOut(e,_79[i].id);dc.onDragOut(e,_79[i].id);}for(i=0,len=_82.length;i<len;++i){dc.onDragEnter(e,_82[i].id);}for(i=0,len=_80.length;i<len;++i){dc.b4DragOver(e,_80[i].id);dc.onDragOver(e,_80[i].id);}for(i=0,len=_81.length;i<len;++i){dc.b4DragDrop(e,_81[i].id);dc.onDragDrop(e,_81[i].id);}}};this.getBestMatch=function(dds){var _87=null;var len=dds.length;if(len==1){_87=dds[0];}else{for(var i=0;i<len;++i){var dd=dds[i];if(dd.cursorIsOver){_87=dd;brea!
k;}else{if(!_87||_87.overlap.getArea()<dd.overlap.getArea()){_87=dd;}}
}}return _87;};this.refreshCache=function(_88){for(sGroup in _88){if("string"!=typeof sGroup){continue;}for(i in this.ids[sGroup]){var oDD=this.ids[sGroup][i];if(this.isTypeOfDD(oDD)){var loc=this.getLocation(oDD);if(loc){this.locationCache[oDD.id]=loc;}else{delete this.locationCache[oDD.id];}}}}};this.verifyEl=function(el){try{if(el){var _90=el.offsetParent;if(_90){return true;}}}catch(e){}return false;};this.getLocation=function(oDD){if(!this.isTypeOfDD(oDD)){return null;}var el=oDD.getEl();var _91=null;try{_91=YAHOO.util.Dom.getXY(el);}catch(e){}if(!_91){return null;}x1=_91[0];x2=x1+el.offsetWidth;y1=_91[1];y2=y1+el.offsetHeight;var t=y1-oDD.padding[0];var r=x2+oDD.padding[1];var b=y2+oDD.padding[2];var l=x1-oDD.padding[3];return new YAHOO.util.Region(t,r,b,l);};this.isOverTarget=function(pt,_96,_97){var loc=this.locationCache[_96.id];if(!loc||!this.useCache){loc=this.getLocation(_96);this.locationCache[_96.id]=loc;}if(!loc){return false;}_96.cursorIsOver=loc.contains(pt)!
;var dc=this.dragCurrent;if(!dc||(!_97&&!dc.constrainX&&!dc.constrainY)){return _96.cursorIsOver;}_96.overlap=null;var pos=dc.getTargetCoord(pt.x,pt.y);var el=dc.getDragEl();var _98=new YAHOO.util.Region(pos.y,pos.x+el.offsetWidth,pos.y+el.offsetHeight,pos.x);var _99=_98.intersect(loc);if(_99){_96.overlap=_99;return (_97)?true:_96.cursorIsOver;}else{return false;}};this._onUnload=function(e,me){this.unregAll();};this.unregAll=function(){if(this.dragCurrent){this.stopDrag();this.dragCurrent=null;}this._execOnAll("unreg",[]);for(i in this.elementCache){delete this.elementCache[i];}this.elementCache={};this.ids={};};this.elementCache={};this.getElWrapper=function(id){var _101=this.elementCache[id];if(!_101||!_101.el){_101=this.elementCache[id]=new this.ElementWrapper(YAHOO.util.Dom.get(id));}return _101;};this.getElement=function(id){return YAHOO.util.Dom.get(id);};this.getCss=function(id){var el=YAHOO.util.Dom.get(id);return (el)?el.style:null;};this.ElementWrapper=function(e!
l){this.el=el||null;this.id=this.el&&el.id;this.css=this.el&&el.style;
};this.getPosX=function(el){return YAHOO.util.Dom.getX(el);};this.getPosY=function(el){return YAHOO.util.Dom.getY(el);};this.swapNode=function(n1,n2){if(n1.swapNode){n1.swapNode(n2);}else{var p=n2.parentNode;var s=n2.nextSibling;n1.parentNode.replaceChild(n2,n1);p.insertBefore(n1,s);}};this.getScroll=function(){var t,l;if(document.documentElement&&document.documentElement.scrollTop){t=document.documentElement.scrollTop;l=document.documentElement.scrollLeft;}else{if(document.body){t=document.body.scrollTop;l=document.body.scrollLeft;}}return {top:t,left:l};};this.getStyle=function(el,_105){return YAHOO.util.Dom.getStyle(el,_105);};this.getScrollTop=function(){return this.getScroll().top;};this.getScrollLeft=function(){return this.getScroll().left;};this.moveToEl=function(_106,_107){var _108=YAHOO.util.Dom.getXY(_107);YAHOO.util.Dom.setXY(_106,_108);};this.getClientHeight=function(){return YAHOO.util.Dom.getClientHeight();};this.getClientWidth=function(){return YAHOO.util.Dom.!
getClientWidth();};this.numericSort=function(a,b){return (a-b);};this._timeoutCount=0;this._addListeners=function(){if(YAHOO.util.Event&&document){this._onLoad();}else{if(this._timeoutCount>1000){}else{var DDM=YAHOO.util.DDM;setTimeout(function(){DDM._addListeners();},10);if(document&&document.body){this._timeoutCount+=1;}}}};this.handleWasClicked=function(node,id){if(this.isHandle(id,node.id)){return true;}else{var p=node.parentNode;while(p){if(this.isHandle(id,p.id)){return true;}else{p=p.parentNode;}}}return false;};}();YAHOO.util.DDM=YAHOO.util.DragDropMgr;YAHOO.util.DDM._addListeners();}YAHOO.util.DD=function(id,_111,_112){if(id){this.init(id,_111,_112);}};YAHOO.extend(YAHOO.util.DD,YAHOO.util.DragDrop);YAHOO.util.DD.prototype.scroll=true;YAHOO.util.DD.prototype.autoOffset=function(_113,_114){var x=_113-this.startPageX;var y=_114-this.startPageY;this.setDelta(x,y);};YAHOO.util.DD.prototype.setDelta=function(_115,_116){this.deltaX=_115;this.deltaY=_116;};YAHOO.util.DD.p!
rototype.setDragElPos=function(_117,_118){var el=this.getDragEl();this
.alignElWithMouse(el,_117,_118);};YAHOO.util.DD.prototype.alignElWithMouse=function(el,_119,_120){var _121=this.getTargetCoord(_119,_120);if(!this.deltaSetXY){var _122=[_121.x,_121.y];YAHOO.util.Dom.setXY(el,_122);var _123=parseInt(YAHOO.util.Dom.getStyle(el,"left"),10);var _124=parseInt(YAHOO.util.Dom.getStyle(el,"top"),10);this.deltaSetXY=[_123-_121.x,_124-_121.y];}else{YAHOO.util.Dom.setStyle(el,"left",(_121.x+this.deltaSetXY[0])+"px");YAHOO.util.Dom.setStyle(el,"top",(_121.y+this.deltaSetXY[1])+"px");}this.cachePosition(_121.x,_121.y);this.autoScroll(_121.x,_121.y,el.offsetHeight,el.offsetWidth);};YAHOO.util.DD.prototype.cachePosition=function(_125,_126){if(_125){this.lastPageX=_125;this.lastPageY=_126;}else{var _127=YAHOO.util.Dom.getXY(this.getEl());this.lastPageX=_127[0];this.lastPageY=_127[1];}};YAHOO.util.DD.prototype.autoScroll=function(x,y,h,w){if(this.scroll){var _130=this.DDM.getClientHeight();var _131=this.DDM.getClientWidth();var st=this.DDM.getScrollTop();var!
sl=this.DDM.getScrollLeft();var bot=h+y;var _135=w+x;var _136=(_130+st-y-this.deltaY);var _137=(_131+sl-x-this.deltaX);var _138=40;var _139=(document.all)?80:30;if(bot>_130&&_136<_138){window.scrollTo(sl,st+_139);}if(y<st&&st>0&&y-st<_138){window.scrollTo(sl,st-_139);}if(_135>_131&&_137<_138){window.scrollTo(sl+_139,st);}if(x<sl&&sl>0&&x-sl<_138){window.scrollTo(sl-_139,st);}}};YAHOO.util.DD.prototype.getTargetCoord=function(_140,_141){var x=_140-this.deltaX;var y=_141-this.deltaY;if(this.constrainX){if(x<this.minX){x=this.minX;}if(x>this.maxX){x=this.maxX;}}if(this.constrainY){if(y<this.minY){y=this.minY;}if(y>this.maxY){y=this.maxY;}}x=this.getTick(x,this.xTicks);y=this.getTick(y,this.yTicks);return {x:x,y:y};};YAHOO.util.DD.prototype.applyConfig=function(){YAHOO.util.DD.superclass.applyConfig.call(this);this.scroll=(this.config.scroll!==false);};YAHOO.util.DD.prototype.b4MouseDown=function(e){this.autoOffset(YAHOO.util.Event.getPageX(e),YAHOO.util.Event.getPageY(e));};Y!
AHOO.util.DD.prototype.b4Drag=function(e){this.setDragElPos(YAHOO.util
.Event.getPageX(e),YAHOO.util.Event.getPageY(e));};YAHOO.util.DD.prototype.toString=function(){return ("DD "+this.id);};YAHOO.util.DDProxy=function(id,_142,_143){if(id){this.init(id,_142,_143);this.initFrame();}};YAHOO.extend(YAHOO.util.DDProxy,YAHOO.util.DD);YAHOO.util.DDProxy.dragElId="ygddfdiv";YAHOO.util.DDProxy.prototype.resizeFrame=true;YAHOO.util.DDProxy.prototype.centerFrame=false;YAHOO.util.DDProxy.prototype.createFrame=function(){var self=this;var body=document.body;if(!body||!body.firstChild){setTimeout(function(){self.createFrame();},50);return;}var div=this.getDragEl();if(!div){div=document.createElement("div");div.id=this.dragElId;var s=div.style;s.position="absolute";s.visibility="hidden";s.cursor="move";s.border="2px solid #aaa";s.zIndex=999;body.insertBefore(div,body.firstChild);}};YAHOO.util.DDProxy.prototype.initFrame=function(){this.createFrame();};YAHOO.util.DDProxy.prototype.applyConfig=function(){YAHOO.util.DDProxy.superclass.applyConfig.call(this);thi!
s.resizeFrame=(this.config.resizeFrame!==false);this.centerFrame=(this.config.centerFrame);this.setDragElId(this.config.dragElId||YAHOO.util.DDProxy.dragElId);};YAHOO.util.DDProxy.prototype.showFrame=function(_147,_148){var el=this.getEl();var _149=this.getDragEl();var s=_149.style;this._resizeProxy();if(this.centerFrame){this.setDelta(Math.round(parseInt(s.width,10)/2),Math.round(parseInt(s.height,10)/2));}this.setDragElPos(_147,_148);YAHOO.util.Dom.setStyle(_149,"visibility","visible");};YAHOO.util.DDProxy.prototype._resizeProxy=function(){var DOM=YAHOO.util.Dom;var el=this.getEl();var _151=this.getDragEl();if(this.resizeFrame){var bt=parseInt(DOM.getStyle(_151,"borderTopWidth"),10);var br=parseInt(DOM.getStyle(_151,"borderRightWidth"),10);var bb=parseInt(DOM.getStyle(_151,"borderBottomWidth"),10);var bl=parseInt(DOM.getStyle(_151,"borderLeftWidth"),10);if(isNaN(bt)){bt=0;}if(isNaN(br)){br=0;}if(isNaN(bb)){bb=0;}if(isNaN(bl)){bl=0;}var _156=el.offsetWidth-br-bl;var _157=e!
l.offsetHeight-bt-bb;DOM.setStyle(_151,"width",_156+"px");DOM.setStyle
(_151,"height",_157+"px");}};YAHOO.util.DDProxy.prototype.b4MouseDown=function(e){var x=YAHOO.util.Event.getPageX(e);var y=YAHOO.util.Event.getPageY(e);this.autoOffset(x,y);this.setDragElPos(x,y);};YAHOO.util.DDProxy.prototype.b4StartDrag=function(x,y){this.showFrame(x,y);};YAHOO.util.DDProxy.prototype.b4EndDrag=function(e){YAHOO.util.Dom.setStyle(this.getDragEl(),"visibility","hidden");};YAHOO.util.DDProxy.prototype.endDrag=function(e){var DOM=YAHOO.util.Dom;var lel=this.getEl();var del=this.getDragEl();DOM.setStyle(del,"visibility","");DOM.setStyle(lel,"visibility","hidden");YAHOO.util.DDM.moveToEl(lel,del);DOM.setStyle(del,"visibility","hidden");DOM.setStyle(lel,"visibility","");};YAHOO.util.DDProxy.prototype.toString=function(){return ("DDProxy "+this.id);};YAHOO.util.DDTarget=function(id,_160,_161){if(id){this.initTarget(id,_160,_161);}};YAHOO.extend(YAHOO.util.DDTarget,YAHOO.util.DragDrop);YAHOO.util.DDTarget.prototype.toString=function(){return ("DDTarget "+this.id);};
\ No newline at end of file
Added: branches/tomek/portal-dnd/dndRenderer.war/js/dragdrop/dragdrop.js
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/dragdrop/dragdrop.js 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/dragdrop/dragdrop.js 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,2698 @@
+
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 0.11.2
+*/
+
+/**
+ * Defines the interface and base operation of items that that can be
+ * dragged or can be drop targets. It was designed to be extended, overriding
+ * the event handlers for startDrag, onDrag, onDragOver, onDragOut.
+ * Up to three html elements can be associated with a DragDrop instance:
+ * <ul>
+ * <li>linked element: the element that is passed into the constructor.
+ * This is the element which defines the boundaries for interaction with
+ * other DragDrop objects.</li>
+ * <li>handle element(s): The drag operation only occurs if the element that
+ * was clicked matches a handle element. By default this is the linked
+ * element, but there are times that you will want only a portion of the
+ * linked element to initiate the drag operation, and the setHandleElId()
+ * method provides a way to define this.</li>
+ * <li>drag element: this represents an the element that would be moved along
+ * with the cursor during a drag operation. By default, this is the linked
+ * element itself as in {@link YAHOO.util.DD}. setDragElId() lets you define
+ * a separate element that would be moved, as in {@link YAHOO.util.DDProxy}
+ * </li>
+ * </ul>
+ * This class should not be instantiated until the onload event to ensure that
+ * the associated elements are available.
+ * The following would define a DragDrop obj that would interact with any
+ * other * DragDrop obj in the "group1" group:
+ * <pre>
+ * dd = new YAHOO.util.DragDrop("div1", "group1");
+ * </pre>
+ * Since none of the event handlers have been implemented, nothing would
+ * actually happen if you were to run the code above. Normally you would
+ * override this class or one of the default implementations, but you can
+ * also override the methods you want on an instance of the class...
+ * <pre>
+ * dd.onDragDrop = function(e, id) {
+ * alert("dd was dropped on " + id);
+ * }
+ * </pre>
+ * @constructor
+ * @param {String} id of the element that is linked to this instance
+ * @param {String} sGroup the group of related DragDrop objects
+ * @param {object} config an object containing configurable attributes
+ * Valid properties for DragDrop:
+ * padding, isTarget, maintainOffset, primaryButtonOnly
+ */
+YAHOO.util.DragDrop = function(id, sGroup, config) {
+ if (id) {
+ this.init(id, sGroup, config);
+ }
+};
+
+YAHOO.util.DragDrop.prototype = {
+
+ /**
+ * The id of the element associated with this object. This is what we
+ * refer to as the "linked element" because the size and position of
+ * this element is used to determine when the drag and drop objects have
+ * interacted.
+ *
+ * @type String
+ */
+ id: null,
+
+ /**
+ * Configuration attributes passed into the constructor
+ * @type object
+ */
+ config: null,
+
+ /**
+ * The id of the element that will be dragged. By default this is same
+ * as the linked element , but could be changed to another element. Ex:
+ * YAHOO.util.DDProxy
+ *
+ * @type String
+ * @private
+ */
+ dragElId: null,
+
+ /**
+ * the id of the element that initiates the drag operation. By default
+ * this is the linked element, but could be changed to be a child of this
+ * element. This lets us do things like only starting the drag when the
+ * header element within the linked html element is clicked.
+ *
+ * @type String
+ * @private
+ */
+ handleElId: null,
+
+ /**
+ * An associative array of HTML tags that will be ignored if clicked.
+ * @type {string: string}
+ */
+ invalidHandleTypes: null,
+
+ /**
+ * An associative array of ids for elements that will be ignored if clicked
+ * @type {string: string}
+ */
+ invalidHandleIds: null,
+
+ /**
+ * An indexted array of css class names for elements that will be ignored
+ * if clicked.
+ * @type string[]
+ */
+ invalidHandleClasses: null,
+
+ /**
+ * The linked element's absolute X position at the time the drag was
+ * started
+ *
+ * @type int
+ * @private
+ */
+ startPageX: 0,
+
+ /**
+ * The linked element's absolute X position at the time the drag was
+ * started
+ *
+ * @type int
+ * @private
+ */
+ startPageY: 0,
+
+ /**
+ * The group defines a logical collection of DragDrop objects that are
+ * related. Instances only get events when interacting with other
+ * DragDrop object in the same group. This lets us define multiple
+ * groups using a single DragDrop subclass if we want.
+ * @type {string: string}
+ */
+ groups: null,
+
+ /**
+ * Individual drag/drop instances can be locked. This will prevent
+ * onmousedown start drag.
+ *
+ * @type boolean
+ * @private
+ */
+ locked: false,
+
+ /**
+ * Lock this instance
+ */
+ lock: function() { this.locked = true; },
+
+ /**
+ * Unlock this instace
+ */
+ unlock: function() { this.locked = false; },
+
+ /**
+ * By default, all insances can be a drop target. This can be disabled by
+ * setting isTarget to false.
+ *
+ * @type boolean
+ */
+ isTarget: true,
+
+ /**
+ * The padding configured for this drag and drop object for calculating
+ * the drop zone intersection with this object.
+ * @type int[]
+ */
+ padding: null,
+
+ /**
+ * @private
+ */
+ _domRef: null,
+
+ /**
+ * Internal typeof flag
+ * @private
+ */
+ __ygDragDrop: true,
+
+ /**
+ * Set to true when horizontal contraints are applied
+ *
+ * @type boolean
+ * @private
+ */
+ constrainX: false,
+
+ /**
+ * Set to true when vertical contraints are applied
+ *
+ * @type boolean
+ * @private
+ */
+ constrainY: false,
+
+ /**
+ * The left constraint
+ *
+ * @type int
+ * @private
+ */
+ minX: 0,
+
+ /**
+ * The right constraint
+ *
+ * @type int
+ * @private
+ */
+ maxX: 0,
+
+ /**
+ * The up constraint
+ *
+ * @type int
+ * @private
+ */
+ minY: 0,
+
+ /**
+ * The down constraint
+ *
+ * @type int
+ * @private
+ */
+ maxY: 0,
+
+ /**
+ * Maintain offsets when we resetconstraints. Used to maintain the
+ * slider thumb value, and this needs to be fixed.
+ * @type boolean
+ */
+ maintainOffset: false,
+
+ /**
+ * Array of pixel locations the element will snap to if we specified a
+ * horizontal graduation/interval. This array is generated automatically
+ * when you define a tick interval.
+ * @type int[]
+ */
+ xTicks: null,
+
+ /**
+ * Array of pixel locations the element will snap to if we specified a
+ * vertical graduation/interval. This array is generated automatically
+ * when you define a tick interval.
+ * @type int[]
+ */
+ yTicks: null,
+
+ /**
+ * By default the drag and drop instance will only respond to the primary
+ * button click (left button for a right-handed mouse). Set to true to
+ * allow drag and drop to start with any mouse click that is propogated
+ * by the browser
+ * @type boolean
+ */
+ primaryButtonOnly: true,
+
+ /**
+ * The availabe property is false until the linked dom element is accessible.
+ * @type boolean
+ */
+ available: false,
+
+ /**
+ * Code that executes immediately before the startDrag event
+ * @private
+ */
+ b4StartDrag: function(x, y) { },
+
+ /**
+ * Abstract method called after a drag/drop object is clicked
+ * and the drag or mousedown time thresholds have beeen met.
+ *
+ * @param {int} X click location
+ * @param {int} Y click location
+ */
+ startDrag: function(x, y) { /* override this */ },
+
+ /**
+ * Code that executes immediately before the onDrag event
+ * @private
+ */
+ b4Drag: function(e) { },
+
+ /**
+ * Abstract method called during the onMouseMove event while dragging an
+ * object.
+ *
+ * @param {Event} e
+ */
+ onDrag: function(e) { /* override this */ },
+
+ /**
+ * Code that executes immediately before the onDragEnter event
+ * @private
+ */
+ // b4DragEnter: function(e) { },
+
+ /**
+ * Abstract method called when this element fist begins hovering over
+ * another DragDrop obj
+ *
+ * @param {Event} e
+ * @param {String || YAHOO.util.DragDrop[]} id In POINT mode, the element
+ * id this is hovering over. In INTERSECT mode, an array of one or more
+ * dragdrop items being hovered over.
+ */
+ onDragEnter: function(e, id) { /* override this */ },
+
+ /**
+ * Code that executes immediately before the onDragOver event
+ * @private
+ */
+ b4DragOver: function(e) { },
+
+ /**
+ * Abstract method called when this element is hovering over another
+ * DragDrop obj
+ *
+ * @param {Event} e
+ * @param {String || YAHOO.util.DragDrop[]} id In POINT mode, the element
+ * id this is hovering over. In INTERSECT mode, an array of dd items
+ * being hovered over.
+ */
+ onDragOver: function(e, id) { /* override this */ },
+
+ /**
+ * Code that executes immediately before the onDragOut event
+ * @private
+ */
+ b4DragOut: function(e) { },
+
+ /**
+ * Abstract method called when we are no longer hovering over an element
+ *
+ * @param {Event} e
+ * @param {String || YAHOO.util.DragDrop[]} id In POINT mode, the element
+ * id this was hovering over. In INTERSECT mode, an array of dd items
+ * that the mouse is no longer over.
+ */
+ onDragOut: function(e, id) { /* override this */ },
+
+ /**
+ * Code that executes immediately before the onDragDrop event
+ * @private
+ */
+ b4DragDrop: function(e) { },
+
+ /**
+ * Abstract method called when this item is dropped on another DragDrop
+ * obj
+ *
+ * @param {Event} e
+ * @param {String || YAHOO.util.DragDrop[]} id In POINT mode, the element
+ * id this was dropped on. In INTERSECT mode, an array of dd items this
+ * was dropped on.
+ */
+ onDragDrop: function(e, id) { /* override this */ },
+
+ /**
+ * Code that executes immediately before the endDrag event
+ * @private
+ */
+ b4EndDrag: function(e) { },
+
+ /**
+ * Fired when we are done dragging the object
+ *
+ * @param {Event} e
+ */
+ endDrag: function(e) { /* override this */ },
+
+ /**
+ * Code executed immediately before the onMouseDown event
+
+ * @param {Event} e
+ * @private
+ */
+ b4MouseDown: function(e) { },
+
+ /**
+ * Event handler that fires when a drag/drop obj gets a mousedown
+ * @param {Event} e
+ */
+ onMouseDown: function(e) { /* override this */ },
+
+ /**
+ * Event handler that fires when a drag/drop obj gets a mouseup
+ * @param {Event} e
+ */
+ onMouseUp: function(e) { /* override this */ },
+
+ /**
+ * Override the onAvailable method to do what is needed after the initial
+ * position was determined.
+ */
+ onAvailable: function () {
+ },
+
+ /**
+ * Returns a reference to the linked element
+ *
+ * @return {HTMLElement} the html element
+ */
+ getEl: function() {
+ if (!this._domRef) {
+ this._domRef = YAHOO.util.Dom.get(this.id);
+ }
+
+ return this._domRef;
+ },
+
+ /**
+ * Returns a reference to the actual element to drag. By default this is
+ * the same as the html element, but it can be assigned to another
+ * element. An example of this can be found in YAHOO.util.DDProxy
+ *
+ * @return {HTMLElement} the html element
+ */
+ getDragEl: function() {
+ return YAHOO.util.Dom.get(this.dragElId);
+ },
+
+ /**
+ * Sets up the DragDrop object. Must be called in the constructor of any
+ * YAHOO.util.DragDrop subclass
+ *
+ * @param id the id of the linked element
+ * @param {String} sGroup the group of related items
+ * @param {object} config configuration attributes
+ */
+ init: function(id, sGroup, config) {
+ this.initTarget(id, sGroup, config);
+ YAHOO.util.Event.addListener(this.id, "mousedown",
+ this.handleMouseDown, this, true);
+ },
+
+ /**
+ * Initializes Targeting functionality only... the object does not
+ * get a mousedown handler.
+ *
+ * @param id the id of the linked element
+ * @param {String} sGroup the group of related items
+ * @param {object} config configuration attributes
+ */
+ initTarget: function(id, sGroup, config) {
+
+ // configuration attributes
+ this.config = config || {};
+
+ // create a local reference to the drag and drop manager
+ this.DDM = YAHOO.util.DDM;
+ // initialize the groups array
+ this.groups = {};
+
+ // set the id
+ this.id = id;
+
+ // add to an interaction group
+ this.addToGroup((sGroup) ? sGroup : "default");
+
+ // We don't want to register this as the handle with the manager
+ // so we just set the id rather than calling the setter.
+ this.handleElId = id;
+
+ YAHOO.util.Event.onAvailable(id, this.handleOnAvailable, this, true);
+
+
+ // the linked element is the element that gets dragged by default
+ this.setDragElId(id);
+
+ // by default, clicked anchors will not start drag operations.
+ // @TODO what else should be here? Probably form fields.
+ this.invalidHandleTypes = { A: "A" };
+ this.invalidHandleIds = {};
+ this.invalidHandleClasses = [];
+
+ this.applyConfig();
+ },
+
+ /**
+ * Applies the configuration parameters that were passed into the constructor.
+ * This is supposed to happen at each level through the inheritance chain. So
+ * a DDProxy implentation will execute apply config on DDProxy, DD, and
+ * DragDrop in order to get all of the parameters that are available in
+ * each object.
+ */
+ applyConfig: function() {
+
+ // configurable properties:
+ // padding, isTarget, maintainOffset, primaryButtonOnly
+ this.padding = this.config.padding || [0, 0, 0, 0];
+ this.isTarget = (this.config.isTarget !== false);
+ this.maintainOffset = (this.config.maintainOffset);
+ this.primaryButtonOnly = (this.config.primaryButtonOnly !== false);
+
+ },
+
+ /**
+ * Executed when the linked element is available
+ * @private
+ */
+ handleOnAvailable: function() {
+ this.available = true;
+ this.resetConstraints();
+ this.onAvailable();
+ },
+
+ /**
+ * Configures the padding for the target zone in px. Effectively expands
+ * (or reduces) the virtual object size for targeting calculations.
+ * Supports css-style shorthand; if only one parameter is passed, all sides
+ * will have that padding, and if only two are passed, the top and bottom
+ * will have the first param, the left and right the second.
+ * @param {int} iTop Top pad
+ * @param {int} iRight Right pad
+ * @param {int} iBot Bot pad
+ * @param {int} iLeft Left pad
+ */
+ setPadding: function(iTop, iRight, iBot, iLeft) {
+ // this.padding = [iLeft, iRight, iTop, iBot];
+ if (!iRight && 0 !== iRight) {
+ this.padding = [iTop, iTop, iTop, iTop];
+ } else if (!iBot && 0 !== iBot) {
+ this.padding = [iTop, iRight, iTop, iRight];
+ } else {
+ this.padding = [iTop, iRight, iBot, iLeft];
+ }
+ },
+
+ /**
+ * Stores the initial placement of the dd element
+ */
+ setInitPosition: function(diffX, diffY) {
+ var el = this.getEl();
+
+ if (!this.DDM.verifyEl(el)) {
+ return;
+ }
+
+ var dx = diffX || 0;
+ var dy = diffY || 0;
+
+ var p = YAHOO.util.Dom.getXY( el );
+
+ this.initPageX = p[0] - dx;
+ this.initPageY = p[1] - dy;
+
+ this.lastPageX = p[0];
+ this.lastPageY = p[1];
+
+
+ this.setStartPosition(p);
+ },
+
+ /**
+ * Sets the start position of the element. This is set when the obj
+ * is initialized, the reset when a drag is started.
+ * @param pos current position (from previous lookup)
+ * @private
+ */
+ setStartPosition: function(pos) {
+ var p = pos || YAHOO.util.Dom.getXY( this.getEl() );
+ this.deltaSetXY = null;
+
+ this.startPageX = p[0];
+ this.startPageY = p[1];
+ },
+
+ /**
+ * Add this instance to a group of related drag/drop objects. All
+ * instances belong to at least one group, and can belong to as many
+ * groups as needed.
+ *
+ * @param sGroup {string} the name of the group
+ */
+ addToGroup: function(sGroup) {
+ this.groups[sGroup] = true;
+ this.DDM.regDragDrop(this, sGroup);
+ },
+
+ /**
+ * Remove's this instance from the supplied interaction group
+ * @param {string} sGroup The group to drop
+ */
+ removeFromGroup: function(sGroup) {
+ if (this.groups[sGroup]) {
+ delete this.groups[sGroup];
+ }
+
+ this.DDM.removeDDFromGroup(this, sGroup);
+ },
+
+ /**
+ * Allows you to specify that an element other than the linked element
+ * will be moved with the cursor during a drag
+ *
+ * @param id the id of the element that will be used to initiate the drag
+ */
+ setDragElId: function(id) {
+ this.dragElId = id;
+ },
+
+ /**
+ * Allows you to specify a child of the linked element that should be
+ * used to initiate the drag operation. An example of this would be if
+ * you have a content div with text and links. Clicking anywhere in the
+ * content area would normally start the drag operation. Use this method
+ * to specify that an element inside of the content div is the element
+ * that starts the drag operation.
+ *
+ * @param id the id of the element that will be used to initiate the drag
+ */
+ setHandleElId: function(id) {
+ this.handleElId = id;
+ this.DDM.regHandle(this.id, id);
+ },
+
+ /**
+ * Allows you to set an element outside of the linked element as a drag
+ * handle
+ */
+ setOuterHandleElId: function(id) {
+ YAHOO.util.Event.addListener(id, "mousedown",
+ this.handleMouseDown, this, true);
+ this.setHandleElId(id);
+ },
+
+ /**
+ * Remove all drag and drop hooks for this element
+ */
+ unreg: function() {
+ YAHOO.util.Event.removeListener(this.id, "mousedown",
+ this.handleMouseDown);
+ this._domRef = null;
+ this.DDM._remove(this);
+ },
+
+ /**
+ * Returns true if this instance is locked, or the drag drop mgr is locked
+ * (meaning that all drag/drop is disabled on the page.)
+ *
+ * @return {boolean} true if this obj or all drag/drop is locked, else
+ * false
+ */
+ isLocked: function() {
+ return (this.DDM.isLocked() || this.locked);
+ },
+
+ /**
+ * Fired when this object is clicked
+ *
+ * @param {Event} e
+ * @param {YAHOO.util.DragDrop} oDD the clicked dd object (this dd obj)
+ * @private
+ */
+ handleMouseDown: function(e, oDD) {
+
+
+ var EU = YAHOO.util.Event;
+
+ var button = e.which || e.button;
+
+ if (this.primaryButtonOnly && button > 1) {
+ return;
+ }
+
+ if (this.isLocked()) {
+ return;
+ }
+
+ this.DDM.refreshCache(this.groups);
+ // var self = this;
+ // setTimeout( function() { self.DDM.refreshCache(self.groups); }, 0);
+
+ // Only process the event if we really clicked within the linked
+ // element. The reason we make this check is that in the case that
+ // another element was moved between the clicked element and the
+ // cursor in the time between the mousedown and mouseup events. When
+ // this happens, the element gets the next mousedown event
+ // regardless of where on the screen it happened.
+ var pt = new YAHOO.util.Point(EU.getPageX(e), EU.getPageY(e));
+ if ( this.DDM.isOverTarget(pt, this) ) {
+
+
+ // check to see if the handle was clicked
+ var srcEl = EU.getTarget(e);
+
+ if (this.isValidHandleChild(srcEl) &&
+ (this.id == this.handleElId ||
+ this.DDM.handleWasClicked(srcEl, this.id)) ) {
+
+
+ // set the initial element position
+ this.setStartPosition();
+
+
+ this.b4MouseDown(e);
+ this.onMouseDown(e);
+ this.DDM.handleMouseDown(e, this);
+
+ this.DDM.stopEvent(e);
+ }
+ }
+ },
+
+ /**
+ * Allows you to specify a tag name that should not start a drag operation
+ * when clicked. This is designed to facilitate embedding links within a
+ * drag handle that do something other than start the drag.
+ *
+ * @param {string} tagName the type of element to exclude
+ */
+ addInvalidHandleType: function(tagName) {
+ var type = tagName.toUpperCase();
+ this.invalidHandleTypes[type] = type;
+ },
+
+ /**
+ * Lets you to specify an element id for a child of a drag handle
+ * that should not initiate a drag
+ * @param {string} id the element id of the element you wish to ignore
+ */
+ addInvalidHandleId: function(id) {
+ this.invalidHandleIds[id] = id;
+ },
+
+ /**
+ * Lets you specify a css class of elements that will not initiate a drag
+ * @param {string} cssClass the class of the elements you wish to ignore
+ */
+ addInvalidHandleClass: function(cssClass) {
+ this.invalidHandleClasses.push(cssClass);
+ },
+
+ /**
+ * Unsets an excluded tag name set by addInvalidHandleType
+ *
+ * @param {string} tagName the type of element to unexclude
+ */
+ removeInvalidHandleType: function(tagName) {
+ var type = tagName.toUpperCase();
+ // this.invalidHandleTypes[type] = null;
+ delete this.invalidHandleTypes[type];
+ },
+
+ /**
+ * Unsets an invalid handle id
+ * @param {string} the id of the element to re-enable
+ */
+ removeInvalidHandleId: function(id) {
+ delete this.invalidHandleIds[id];
+ },
+
+ /**
+ * Unsets an invalid css class
+ * @param {string} the class of the element(s) you wish to re-enable
+ */
+ removeInvalidHandleClass: function(cssClass) {
+ for (var i=0, len=this.invalidHandleClasses.length; i<len; ++i) {
+ if (this.invalidHandleClasses[i] == cssClass) {
+ delete this.invalidHandleClasses[i];
+ }
+ }
+ },
+
+ /**
+ * Checks the tag exclusion list to see if this click should be ignored
+ *
+ * @param {ygNode} node
+ * @return {boolean} true if this is a valid tag type, false if not
+ */
+ isValidHandleChild: function(node) {
+
+ var valid = true;
+ // var n = (node.nodeName == "#text") ? node.parentNode : node;
+ var nodeName;
+ try {
+ nodeName = node.nodeName.toUpperCase();
+ } catch(e) {
+ nodeName = node.nodeName;
+ }
+ valid = valid && !this.invalidHandleTypes[nodeName];
+ valid = valid && !this.invalidHandleIds[node.id];
+
+ for (var i=0, len=this.invalidHandleClasses.length; valid && i<len; ++i) {
+ valid = !YAHOO.util.Dom.hasClass(node, this.invalidHandleClasses[i]);
+ }
+
+
+ return valid;
+
+ },
+
+ /**
+ * Create the array of horizontal tick marks if an interval was specified
+ * in setXConstraint().
+ *
+ * @private
+ */
+ setXTicks: function(iStartX, iTickSize) {
+ this.xTicks = [];
+ this.xTickSize = iTickSize;
+
+ var tickMap = {};
+
+ for (var i = this.initPageX; i >= this.minX; i = i - iTickSize) {
+ if (!tickMap[i]) {
+ this.xTicks[this.xTicks.length] = i;
+ tickMap[i] = true;
+ }
+ }
+
+ for (i = this.initPageX; i <= this.maxX; i = i + iTickSize) {
+ if (!tickMap[i]) {
+ this.xTicks[this.xTicks.length] = i;
+ tickMap[i] = true;
+ }
+ }
+
+ this.xTicks.sort(this.DDM.numericSort) ;
+ },
+
+ /**
+ * Create the array of vertical tick marks if an interval was specified in
+ * setYConstraint().
+ *
+ * @private
+ */
+ setYTicks: function(iStartY, iTickSize) {
+ this.yTicks = [];
+ this.yTickSize = iTickSize;
+
+ var tickMap = {};
+
+ for (var i = this.initPageY; i >= this.minY; i = i - iTickSize) {
+ if (!tickMap[i]) {
+ this.yTicks[this.yTicks.length] = i;
+ tickMap[i] = true;
+ }
+ }
+
+ for (i = this.initPageY; i <= this.maxY; i = i + iTickSize) {
+ if (!tickMap[i]) {
+ this.yTicks[this.yTicks.length] = i;
+ tickMap[i] = true;
+ }
+ }
+
+ this.yTicks.sort(this.DDM.numericSort) ;
+ },
+
+ /**
+ * By default, the element can be dragged any place on the screen. Use
+ * this method to limit the horizontal travel of the element. Pass in
+ * 0,0 for the parameters if you want to lock the drag to the y axis.
+ *
+ * @param {int} iLeft the number of pixels the element can move to the left
+ * @param {int} iRight the number of pixels the element can move to the
+ * right
+ * @param {int} iTickSize optional parameter for specifying that the
+ * element
+ * should move iTickSize pixels at a time.
+ */
+ setXConstraint: function(iLeft, iRight, iTickSize) {
+ this.leftConstraint = iLeft;
+ this.rightConstraint = iRight;
+
+ this.minX = this.initPageX - iLeft;
+ this.maxX = this.initPageX + iRight;
+ if (iTickSize) { this.setXTicks(this.initPageX, iTickSize); }
+
+ this.constrainX = true;
+ },
+
+ /**
+ * Clears any constraints applied to this instance. Also clears ticks
+ * since they can't exist independent of a constraint at this time.
+ */
+ clearConstraints: function() {
+ this.constrainX = false;
+ this.constrainY = false;
+ this.clearTicks();
+ },
+
+ /**
+ * Clears any tick interval defined for this instance
+ */
+ clearTicks: function() {
+ this.xTicks = null;
+ this.yTicks = null;
+ this.xTickSize = 0;
+ this.yTickSize = 0;
+ },
+
+ /**
+ * By default, the element can be dragged any place on the screen. Set
+ * this to limit the vertical travel of the element. Pass in 0,0 for the
+ * parameters if you want to lock the drag to the x axis.
+ *
+ * @param {int} iUp the number of pixels the element can move up
+ * @param {int} iDown the number of pixels the element can move down
+ * @param {int} iTickSize optional parameter for specifying that the
+ * element should move iTickSize pixels at a time.
+ */
+ setYConstraint: function(iUp, iDown, iTickSize) {
+ this.topConstraint = iUp;
+ this.bottomConstraint = iDown;
+
+ this.minY = this.initPageY - iUp;
+ this.maxY = this.initPageY + iDown;
+ if (iTickSize) { this.setYTicks(this.initPageY, iTickSize); }
+
+ this.constrainY = true;
+
+ },
+
+ /**
+ * resetConstraints must be called if you manually reposition a dd element.
+ * @param {boolean} maintainOffset
+ */
+ resetConstraints: function() {
+
+
+ // Maintain offsets if necessary
+ if (this.initPageX || this.initPageX === 0) {
+ // figure out how much this thing has moved
+ var dx = (this.maintainOffset) ? this.lastPageX - this.initPageX : 0;
+ var dy = (this.maintainOffset) ? this.lastPageY - this.initPageY : 0;
+
+ this.setInitPosition(dx, dy);
+
+ // This is the first time we have detected the element's position
+ } else {
+ this.setInitPosition();
+ }
+
+ if (this.constrainX) {
+ this.setXConstraint( this.leftConstraint,
+ this.rightConstraint,
+ this.xTickSize );
+ }
+
+ if (this.constrainY) {
+ this.setYConstraint( this.topConstraint,
+ this.bottomConstraint,
+ this.yTickSize );
+ }
+ },
+
+ /**
+ * Normally the drag element is moved pixel by pixel, but we can specify
+ * that it move a number of pixels at a time. This method resolves the
+ * location when we have it set up like this.
+ *
+ * @param {int} val where we want to place the object
+ * @param {int[]} tickArray sorted array of valid points
+ * @return {int} the closest tick
+ * @private
+ */
+ getTick: function(val, tickArray) {
+
+ if (!tickArray) {
+ // If tick interval is not defined, it is effectively 1 pixel,
+ // so we return the value passed to us.
+ return val;
+ } else if (tickArray[0] >= val) {
+ // The value is lower than the first tick, so we return the first
+ // tick.
+ return tickArray[0];
+ } else {
+ for (var i=0, len=tickArray.length; i<len; ++i) {
+ var next = i + 1;
+ if (tickArray[next] && tickArray[next] >= val) {
+ var diff1 = val - tickArray[i];
+ var diff2 = tickArray[next] - val;
+ return (diff2 > diff1) ? tickArray[i] : tickArray[next];
+ }
+ }
+
+ // The value is larger than the last tick, so we return the last
+ // tick.
+ return tickArray[tickArray.length - 1];
+ }
+ },
+
+ /**
+ * toString method
+ * @return {string} string representation of the dd obj
+ */
+ toString: function() {
+ return ("DragDrop " + this.id);
+ }
+
+};
+
+// Only load the library once. Rewriting the manager class would orphan
+// existing drag and drop instances.
+if (!YAHOO.util.DragDropMgr) {
+
+ /**
+ * Handles the element interaction for all DragDrop items in the
+ * window. Generally, you will not call this class directly, but it does
+ * have helper methods that could be useful in your DragDrop
+ * implementations. This class should not be instantiated; all methods
+ * are are static.
+ *
+ * @constructor
+ */
+ YAHOO.util.DragDropMgr = new function() {
+
+ /**
+ * Two dimensional Array of registered DragDrop objects. The first
+ * dimension is the DragDrop item group, the second the DragDrop
+ * object.
+ *
+ * @type {string: string}
+ * @private
+ */
+ this.ids = {};
+
+ /**
+ * Array of element ids defined as drag handles. Used to determine
+ * if the element that generated the mousedown event is actually the
+ * handle and not the html element itself.
+ *
+ * @type {string: string}
+ * @private
+ */
+ this.handleIds = {};
+
+ /**
+ * the DragDrop object that is currently being dragged
+ *
+ * @type DragDrop
+ * @private
+ **/
+ this.dragCurrent = null;
+
+ /**
+ * the DragDrop object(s) that are being hovered over
+ *
+ * @type Array
+ * @private
+ */
+ this.dragOvers = {};
+
+ /**
+ * @private
+ */
+
+ /**
+ * the X distance between the cursor and the object being dragged
+ *
+ * @type int
+ * @private
+ */
+ this.deltaX = 0;
+
+ /**
+ * the Y distance between the cursor and the object being dragged
+ *
+ * @type int
+ * @private
+ */
+ this.deltaY = 0;
+
+ /**
+ * Flag to determine if we should prevent the default behavior of the
+ * events we define. By default this is true, but this can be set to
+ * false if you need the default behavior (not recommended)
+ *
+ * @type boolean
+ */
+ this.preventDefault = true;
+
+ /**
+ * Flag to determine if we should stop the propagation of the events
+ * we generate. This is true by default but you may want to set it to
+ * false if the html element contains other features that require the
+ * mouse click.
+ *
+ * @type boolean
+ */
+ this.stopPropagation = true;
+
+ /**
+ * @private
+ */
+ this.initalized = false;
+
+ /**
+ * All drag and drop can be disabled.
+ *
+ * @private
+ */
+ this.locked = false;
+
+ /**
+ * Called the first time an element is registered.
+ *
+ * @private
+ */
+ this.init = function() {
+ this.initialized = true;
+ };
+
+ /**
+ * In point mode, drag and drop interaction is defined by the
+ * location of the cursor during the drag/drop
+ * @type int
+ */
+ this.POINT = 0;
+
+ /**
+ * In intersect mode, drag and drop interactio nis defined by the
+ * overlap of two or more drag and drop objects.
+ * @type int
+ */
+ this.INTERSECT = 1;
+
+ /**
+ * The current drag and drop mode. Default it point mode
+ * @type int
+ */
+ this.mode = this.POINT;
+
+ /**
+ * Runs method on all drag and drop objects
+ * @private
+ */
+ this._execOnAll = function(sMethod, args) {
+ for (var i in this.ids) {
+ for (var j in this.ids[i]) {
+ var oDD = this.ids[i][j];
+ if (! this.isTypeOfDD(oDD)) {
+ continue;
+ }
+ oDD[sMethod].apply(oDD, args);
+ }
+ }
+ };
+
+ /**
+ * Drag and drop initialization. Sets up the global event handlers
+ * @private
+ */
+ this._onLoad = function() {
+
+ this.init();
+
+
+ var EU = YAHOO.util.Event;
+
+ EU.on(document, "mouseup", this.handleMouseUp, this, true);
+ EU.on(document, "mousemove", this.handleMouseMove, this, true);
+ EU.on(window, "unload", this._onUnload, this, true);
+ EU.on(window, "resize", this._onResize, this, true);
+ // EU.on(window, "mouseout", this._test);
+
+ };
+
+ /**
+ * Reset constraints on all drag and drop objs
+ * @private
+ */
+ this._onResize = function(e) {
+ this._execOnAll("resetConstraints", []);
+ };
+
+ /**
+ * Lock all drag and drop functionality
+ */
+ this.lock = function() { this.locked = true; };
+
+ /**
+ * Unlock all drag and drop functionality
+ */
+ this.unlock = function() { this.locked = false; };
+
+ /**
+ * Is drag and drop locked?
+ *
+ * @return {boolean} True if drag and drop is locked, false otherwise.
+ */
+ this.isLocked = function() { return this.locked; };
+
+ /**
+ * Location cache that is set for all drag drop objects when a drag is
+ * initiated, cleared when the drag is finished.
+ *
+ * @private
+ */
+ this.locationCache = {};
+
+ /**
+ * Set useCache to false if you want to force object the lookup of each
+ * drag and drop linked element constantly during a drag.
+ * @type boolean
+ */
+ this.useCache = true;
+
+ /**
+ * The number of pixels that the mouse needs to move after the
+ * mousedown before the drag is initiated. Default=3;
+ * @type int
+ */
+ this.clickPixelThresh = 3;
+
+ /**
+ * The number of milliseconds after the mousedown event to initiate the
+ * drag if we don't get a mouseup event. Default=1000
+ * @type int
+ */
+ this.clickTimeThresh = 1000;
+
+ /**
+ * Flag that indicates that either the drag pixel threshold or the
+ * mousdown time threshold has been met
+ * @type boolean
+ * @private
+ */
+ this.dragThreshMet = false;
+
+ /**
+ * Timeout used for the click time threshold
+ * @type Object
+ * @private
+ */
+ this.clickTimeout = null;
+
+ /**
+ * The X position of the mousedown event stored for later use when a
+ * drag threshold is met.
+ * @type int
+ * @private
+ */
+ this.startX = 0;
+
+ /**
+ * The Y position of the mousedown event stored for later use when a
+ * drag threshold is met.
+ * @type int
+ * @private
+ */
+ this.startY = 0;
+
+ /**
+ * Each DragDrop instance must be registered with the DragDropMgr.
+ * This is executed in DragDrop.init()
+ *
+ * @param {DragDrop} oDD the DragDrop object to register
+ * @param {String} sGroup the name of the group this element belongs to
+ */
+ this.regDragDrop = function(oDD, sGroup) {
+ if (!this.initialized) { this.init(); }
+
+ if (!this.ids[sGroup]) {
+ this.ids[sGroup] = {};
+ }
+ this.ids[sGroup][oDD.id] = oDD;
+ };
+
+ /**
+ * Removes the supplied dd instance from the supplied group. Executed
+ * by DragDrop.removeFromGroup.
+ * @private
+ */
+ this.removeDDFromGroup = function(oDD, sGroup) {
+ if (!this.ids[sGroup]) {
+ this.ids[sGroup] = {};
+ }
+
+ var obj = this.ids[sGroup];
+ if (obj && obj[oDD.id]) {
+ delete obj[oDD.id];
+ }
+ };
+
+ /**
+ * Unregisters a drag and drop item. This is executed in
+ * DragDrop.unreg, use that method instead of calling this directly.
+ * @private
+ */
+ this._remove = function(oDD) {
+ for (var g in oDD.groups) {
+ if (g && this.ids[g][oDD.id]) {
+ delete this.ids[g][oDD.id];
+ }
+ }
+ delete this.handleIds[oDD.id];
+ };
+
+ /**
+ * Each DragDrop handle element must be registered. This is done
+ * automatically when executing DragDrop.setHandleElId()
+ *
+ * @param {String} sDDId the DragDrop id this element is a handle for
+ * @param {String} sHandleId the id of the element that is the drag
+ * handle
+ */
+ this.regHandle = function(sDDId, sHandleId) {
+ if (!this.handleIds[sDDId]) {
+ this.handleIds[sDDId] = {};
+ }
+ this.handleIds[sDDId][sHandleId] = sHandleId;
+ };
+
+ /**
+ * Utility function to determine if a given element has been
+ * registered as a drag drop item.
+ *
+ * @param {String} id the element id to check
+ * @return {boolean} true if this element is a DragDrop item,
+ * false otherwise
+ */
+ this.isDragDrop = function(id) {
+ return ( this.getDDById(id) ) ? true : false;
+ };
+
+ /**
+ * Returns the drag and drop instances that are in all groups the
+ * passed in instance belongs to.
+ *
+ * @param {DragDrop} p_oDD the obj to get related data for
+ * @param {boolean} bTargetsOnly if true, only return targetable objs
+ * @return {DragDrop[]} the related instances
+ */
+ this.getRelated = function(p_oDD, bTargetsOnly) {
+ var oDDs = [];
+ for (var i in p_oDD.groups) {
+ for (j in this.ids[i]) {
+ var dd = this.ids[i][j];
+ if (! this.isTypeOfDD(dd)) {
+ continue;
+ }
+ if (!bTargetsOnly || dd.isTarget) {
+ oDDs[oDDs.length] = dd;
+ }
+ }
+ }
+
+ return oDDs;
+ };
+
+ /**
+ * Returns true if the specified dd target is a legal target for
+ * the specifice drag obj
+ *
+ * @param {DragDrop} the drag obj
+ * @param {DragDrop) the target
+ * @return {boolean} true if the target is a legal target for the
+ * dd obj
+ */
+ this.isLegalTarget = function (oDD, oTargetDD) {
+ var targets = this.getRelated(oDD, true);
+ for (var i=0, len=targets.length;i<len;++i) {
+ if (targets[i].id == oTargetDD.id) {
+ return true;
+ }
+ }
+
+ return false;
+ };
+
+ /**
+ * My goal is to be able to transparently determine if an object is
+ * typeof DragDrop, and the exact subclass of DragDrop. typeof
+ * returns "object", oDD.constructor.toString() always returns
+ * "DragDrop" and not the name of the subclass. So for now it just
+ * evaluates a well-known variable in DragDrop.
+ *
+ * @param {Object} the object to evaluate
+ * @return {boolean} true if typeof oDD = DragDrop
+ */
+ this.isTypeOfDD = function (oDD) {
+ return (oDD && oDD.__ygDragDrop);
+ };
+
+ /**
+ * Utility function to determine if a given element has been
+ * registered as a drag drop handle for the given Drag Drop object.
+ *
+ * @param {String} id the element id to check
+ * @return {boolean} true if this element is a DragDrop handle, false
+ * otherwise
+ */
+ this.isHandle = function(sDDId, sHandleId) {
+ return ( this.handleIds[sDDId] &&
+ this.handleIds[sDDId][sHandleId] );
+ };
+
+ /**
+ * Returns the DragDrop instance for a given id
+ *
+ * @param {String} id the id of the DragDrop object
+ * @return {DragDrop} the drag drop object, null if it is not found
+ */
+ this.getDDById = function(id) {
+ for (var i in this.ids) {
+ if (this.ids[i][id]) {
+ return this.ids[i][id];
+ }
+ }
+ return null;
+ };
+
+ /**
+ * Fired after a registered DragDrop object gets the mousedown event.
+ * Sets up the events required to track the object being dragged
+ *
+ * @param {Event} e the event
+ * @param oDD the DragDrop object being dragged
+ * @private
+ */
+ this.handleMouseDown = function(e, oDD) {
+
+ this.currentTarget = YAHOO.util.Event.getTarget(e);
+
+ this.dragCurrent = oDD;
+
+ var el = oDD.getEl();
+
+ // track start position
+ this.startX = YAHOO.util.Event.getPageX(e);
+ this.startY = YAHOO.util.Event.getPageY(e);
+
+ this.deltaX = this.startX - el.offsetLeft;
+ this.deltaY = this.startY - el.offsetTop;
+
+ this.dragThreshMet = false;
+
+ this.clickTimeout = setTimeout(
+ function() {
+ var DDM = YAHOO.util.DDM;
+ DDM.startDrag(DDM.startX, DDM.startY);
+ },
+ this.clickTimeThresh );
+ };
+
+ /**
+ * Fired when either the drag pixel threshol or the mousedown hold
+ * time threshold has been met.
+ *
+ * @param x {int} the X position of the original mousedown
+ * @param y {int} the Y position of the original mousedown
+ */
+ this.startDrag = function(x, y) {
+ clearTimeout(this.clickTimeout);
+ if (this.dragCurrent) {
+ this.dragCurrent.b4StartDrag(x, y);
+ this.dragCurrent.startDrag(x, y);
+ }
+ this.dragThreshMet = true;
+ };
+
+ /**
+ * Internal function to handle the mouseup event. Will be invoked
+ * from the context of the document.
+ *
+ * @param {Event} e the event
+ * @private
+ */
+ this.handleMouseUp = function(e) {
+
+ if (! this.dragCurrent) {
+ return;
+ }
+
+ clearTimeout(this.clickTimeout);
+
+ if (this.dragThreshMet) {
+ this.fireEvents(e, true);
+ } else {
+ }
+
+ this.stopDrag(e);
+
+ this.stopEvent(e);
+ };
+
+ /**
+ * Utility to stop event propagation and event default, if these
+ * features are turned on.
+ *
+ * @param {Event} e the event as returned by this.getEvent()
+ */
+ this.stopEvent = function(e) {
+ if (this.stopPropagation) {
+ YAHOO.util.Event.stopPropagation(e);
+ }
+
+ if (this.preventDefault) {
+ YAHOO.util.Event.preventDefault(e);
+ }
+ };
+
+ /**
+ * Internal function to clean up event handlers after the drag
+ * operation is complete
+ *
+ * @param {Event} e the event
+ * @private
+ */
+ this.stopDrag = function(e) {
+
+ // Fire the drag end event for the item that was dragged
+ if (this.dragCurrent) {
+ if (this.dragThreshMet) {
+ this.dragCurrent.b4EndDrag(e);
+ this.dragCurrent.endDrag(e);
+ }
+
+ this.dragCurrent.onMouseUp(e);
+ }
+
+ this.dragCurrent = null;
+ this.dragOvers = {};
+ };
+
+ /**
+ * Internal function to handle the mousemove event. Will be invoked
+ * from the context of the html element.
+ *
+ * @TODO figure out what we can do about mouse events lost when the
+ * user drags objects beyond the window boundary. Currently we can
+ * detect this in internet explorer by verifying that the mouse is
+ * down during the mousemove event. Firefox doesn't give us the
+ * button state on the mousemove event.
+ *
+ * @param {Event} e the event
+ * @private
+ */
+ this.handleMouseMove = function(e) {
+ if (! this.dragCurrent) {
+ return true;
+ }
+
+ // var button = e.which || e.button;
+
+ // check for IE mouseup outside of page boundary
+ if (YAHOO.util.Event.isIE && !e.button) {
+ this.stopEvent(e);
+ return this.handleMouseUp(e);
+ }
+
+ if (!this.dragThreshMet) {
+ var diffX = Math.abs(this.startX - YAHOO.util.Event.getPageX(e));
+ var diffY = Math.abs(this.startY - YAHOO.util.Event.getPageY(e));
+ if (diffX > this.clickPixelThresh ||
+ diffY > this.clickPixelThresh) {
+ this.startDrag(this.startX, this.startY);
+ }
+ }
+
+ if (this.dragThreshMet) {
+ this.dragCurrent.b4Drag(e);
+ this.dragCurrent.onDrag(e);
+ this.fireEvents(e, false);
+ }
+
+ this.stopEvent(e);
+
+ return true;
+ };
+
+ /**
+ * Iterates over all of the DragDrop elements to find ones we are
+ * hovering over or dropping on
+ *
+ * @param {Event} e the event
+ * @param {boolean} isDrop is this a drop op or a mouseover op?
+ * @private
+ */
+ this.fireEvents = function(e, isDrop) {
+ var dc = this.dragCurrent;
+
+ // If the user did the mouse up outside of the window, we could
+ // get here even though we have ended the drag.
+ if (!dc || dc.isLocked()) {
+ return;
+ }
+
+ var x = YAHOO.util.Event.getPageX(e);
+ var y = YAHOO.util.Event.getPageY(e);
+ var pt = new YAHOO.util.Point(x,y);
+
+ // cache the previous dragOver array
+ var oldOvers = [];
+
+ var outEvts = [];
+ var overEvts = [];
+ var dropEvts = [];
+ var enterEvts = [];
+
+ // Check to see if the object(s) we were hovering over is no longer
+ // being hovered over so we can fire the onDragOut event
+ for (var i in this.dragOvers) {
+
+ var ddo = this.dragOvers[i];
+
+ if (! this.isTypeOfDD(ddo)) {
+ continue;
+ }
+
+ if (! this.isOverTarget(pt, ddo, this.mode)) {
+ outEvts.push( ddo );
+ }
+
+ oldOvers[i] = true;
+ delete this.dragOvers[i];
+ }
+
+ for (var sGroup in dc.groups) {
+
+ if ("string" != typeof sGroup) {
+ continue;
+ }
+
+ for (i in this.ids[sGroup]) {
+ var oDD = this.ids[sGroup][i];
+ if (! this.isTypeOfDD(oDD)) {
+ continue;
+ }
+
+ if (oDD.isTarget && !oDD.isLocked() && oDD != dc) {
+ if (this.isOverTarget(pt, oDD, this.mode)) {
+ // look for drop interactions
+ if (isDrop) {
+ dropEvts.push( oDD );
+ // look for drag enter and drag over interactions
+ } else {
+
+ // initial drag over: dragEnter fires
+ if (!oldOvers[oDD.id]) {
+ enterEvts.push( oDD );
+ // subsequent drag overs: dragOver fires
+ } else {
+ overEvts.push( oDD );
+ }
+
+ this.dragOvers[oDD.id] = oDD;
+ }
+ }
+ }
+ }
+ }
+
+ if (this.mode) {
+ if (outEvts.length) {
+ dc.b4DragOut(e, outEvts);
+ dc.onDragOut(e, outEvts);
+ }
+
+ if (enterEvts.length) {
+ dc.onDragEnter(e, enterEvts);
+ }
+
+ if (overEvts.length) {
+ dc.b4DragOver(e, overEvts);
+ dc.onDragOver(e, overEvts);
+ }
+
+ if (dropEvts.length) {
+ dc.b4DragDrop(e, dropEvts);
+ dc.onDragDrop(e, dropEvts);
+ }
+
+ } else {
+ // fire dragout events
+ var len = 0;
+ for (i=0, len=outEvts.length; i<len; ++i) {
+ dc.b4DragOut(e, outEvts[i].id);
+ dc.onDragOut(e, outEvts[i].id);
+ }
+
+ // fire enter events
+ for (i=0,len=enterEvts.length; i<len; ++i) {
+ // dc.b4DragEnter(e, oDD.id);
+ dc.onDragEnter(e, enterEvts[i].id);
+ }
+
+ // fire over events
+ for (i=0,len=overEvts.length; i<len; ++i) {
+ dc.b4DragOver(e, overEvts[i].id);
+ dc.onDragOver(e, overEvts[i].id);
+ }
+
+ // fire drop events
+ for (i=0, len=dropEvts.length; i<len; ++i) {
+ dc.b4DragDrop(e, dropEvts[i].id);
+ dc.onDragDrop(e, dropEvts[i].id);
+ }
+
+ }
+
+ };
+
+ /**
+ * Helper function for getting the best match from the list of drag
+ * and drop objects returned by the drag and drop events when we are
+ * in INTERSECT mode. It returns either the first object that the
+ * cursor is over, or the object that has the greatest overlap with
+ * the dragged element.
+ *
+ * @param {DragDrop[]} dds The array of drag and drop objects
+ * targeted
+ * @return {DragDrop} The best single match
+ */
+ this.getBestMatch = function(dds) {
+ var winner = null;
+ // Return null if the input is not what we expect
+ //if (!dds || !dds.length || dds.length == 0) {
+ // winner = null;
+ // If there is only one item, it wins
+ //} else if (dds.length == 1) {
+
+ var len = dds.length;
+
+ if (len == 1) {
+ winner = dds[0];
+ } else {
+ // Loop through the targeted items
+ for (var i=0; i<len; ++i) {
+ var dd = dds[i];
+ // If the cursor is over the object, it wins. If the
+ // cursor is over multiple matches, the first one we come
+ // to wins.
+ if (dd.cursorIsOver) {
+ winner = dd;
+ break;
+ // Otherwise the object with the most overlap wins
+ } else {
+ if (!winner ||
+ winner.overlap.getArea() < dd.overlap.getArea()) {
+ winner = dd;
+ }
+ }
+ }
+ }
+
+ return winner;
+ };
+
+ /**
+ * Refreshes the cache of the top-left and bottom-right points of the
+ * drag and drop objects in the specified groups
+ *
+ * @param {Object} groups an associative array of groups to refresh
+ */
+ this.refreshCache = function(groups) {
+ for (sGroup in groups) {
+ if ("string" != typeof sGroup) {
+ continue;
+ }
+ for (i in this.ids[sGroup]) {
+ var oDD = this.ids[sGroup][i];
+
+ if (this.isTypeOfDD(oDD)) {
+ // if (this.isTypeOfDD(oDD) && oDD.isTarget) {
+ var loc = this.getLocation(oDD);
+ if (loc) {
+ this.locationCache[oDD.id] = loc;
+ } else {
+ delete this.locationCache[oDD.id];
+ // this will unregister the drag and drop object if
+ // the element is not in a usable state
+ // oDD.unreg();
+ }
+ }
+ }
+ }
+ };
+
+ /**
+ * This checks to make sure an element exists and is in the DOM. The
+ * main purpose is to handle cases where innerHTML is used to remove
+ * drag and drop objects from the DOM. IE provides an 'unspecified
+ * error' when trying to access the offsetParent of such an element
+ * @param {HTMLElement} el the element to check
+ * @return {boolean} true if the element looks usable
+ */
+ this.verifyEl = function(el) {
+ try {
+ if (el) {
+ var parent = el.offsetParent;
+ if (parent) {
+ return true;
+ }
+ }
+ } catch(e) {
+ }
+
+ return false;
+ };
+
+ /**
+ * Returns the an array containing the drag and drop element's position
+ * and size, including the DragDrop.padding configured for it
+ *
+ * @param {DragDrop} oDD the drag and drop object to get the
+ * location for
+ * @return array containing the top left and bottom right points of the
+ * element
+ */
+ this.getLocation = function(oDD) {
+ if (! this.isTypeOfDD(oDD)) {
+ return null;
+ }
+
+ var el = oDD.getEl();
+
+ // element will not have an offsetparent if it was removed from the
+ // document or display=none
+ // if (!this.verifyEl(el)) {
+ // return null;
+ // }
+
+
+ // var aPos = ygPos.getPos(el);
+ var aPos = null;
+ try {
+ aPos= YAHOO.util.Dom.getXY(el);
+ } catch (e) { }
+
+ if (!aPos) {
+ return null;
+ }
+
+ x1 = aPos[0];
+ x2 = x1 + el.offsetWidth;
+
+ y1 = aPos[1];
+ y2 = y1 + el.offsetHeight;
+
+ var t = y1 - oDD.padding[0];
+ var r = x2 + oDD.padding[1];
+ var b = y2 + oDD.padding[2];
+ var l = x1 - oDD.padding[3];
+
+ return new YAHOO.util.Region( t, r, b, l );
+
+ };
+
+ /**
+ * Checks the cursor location to see if it over the target
+ *
+ * @param {YAHOO.util.Point} pt The point to evaluate
+ * @param {DragDrop} oTarget the DragDrop object we are inspecting
+ * @return {boolean} true if the mouse is over the target
+ * @private
+ */
+ this.isOverTarget = function(pt, oTarget, intersect) {
+ // use cache if available
+ var loc = this.locationCache[oTarget.id];
+ if (!loc || !this.useCache) {
+ loc = this.getLocation(oTarget);
+ this.locationCache[oTarget.id] = loc;
+
+ }
+
+ if (!loc) {
+ return false;
+ }
+
+ oTarget.cursorIsOver = loc.contains( pt );
+
+ // DragDrop is using this as a sanity check for the initial mousedown
+ // in this case we are done. In POINT mode, if the drag obj has no
+ // contraints, we are also done. Otherwise we need to evaluate the
+ // location of the target as related to the actual location of the
+ // dragged element.
+ var dc = this.dragCurrent;
+ if (!dc || (!intersect && !dc.constrainX && !dc.constrainY)) {
+ return oTarget.cursorIsOver;
+ }
+
+ oTarget.overlap = null;
+
+ // Get the current location of the drag element, this is the
+ // location of the mouse event less the delta that represents
+ // where the original mousedown happened on the element. We
+ // need to consider constraints and ticks as well.
+ var pos = dc.getTargetCoord(pt.x, pt.y);
+
+ var el = dc.getDragEl();
+ var curRegion = new YAHOO.util.Region( pos.y,
+ pos.x + el.offsetWidth,
+ pos.y + el.offsetHeight,
+ pos.x );
+
+ var overlap = curRegion.intersect(loc);
+
+ if (overlap) {
+ oTarget.overlap = overlap;
+ return (intersect) ? true : oTarget.cursorIsOver;
+ } else {
+ return false;
+ }
+ };
+
+ /**
+ * @private
+ */
+ this._onUnload = function(e, me) {
+ this.unregAll();
+ };
+
+ /**
+ * Cleans up the drag and drop events and objects.
+ * @private
+ */
+ this.unregAll = function() {
+
+ if (this.dragCurrent) {
+ this.stopDrag();
+ this.dragCurrent = null;
+ }
+
+ this._execOnAll("unreg", []);
+
+ for (i in this.elementCache) {
+ delete this.elementCache[i];
+ }
+
+ this.elementCache = {};
+ this.ids = {};
+ };
+
+ /**
+ * A cache of DOM elements
+ * @private
+ */
+ this.elementCache = {};
+
+ /**
+ * Get the wrapper for the DOM element specified
+ *
+ * @param {String} id the id of the elment to get
+ * @return {YAHOO.util.DDM.ElementWrapper} the wrapped element
+ * @private
+ * @deprecated
+ */
+ this.getElWrapper = function(id) {
+ var oWrapper = this.elementCache[id];
+ if (!oWrapper || !oWrapper.el) {
+ oWrapper = this.elementCache[id] =
+ new this.ElementWrapper(YAHOO.util.Dom.get(id));
+ }
+ return oWrapper;
+ };
+
+ /**
+ * Returns the actual DOM element
+ *
+ * @param {String} id the id of the elment to get
+ * @return {Object} The element
+ * @deprecated
+ */
+ this.getElement = function(id) {
+ return YAHOO.util.Dom.get(id);
+ };
+
+ /**
+ * Returns the style property for the DOM element (i.e.,
+ * document.getElById(id).style)
+ *
+ * @param {String} id the id of the elment to get
+ * @return {Object} The style property of the element
+ * @deprecated
+ */
+ this.getCss = function(id) {
+ var el = YAHOO.util.Dom.get(id);
+ return (el) ? el.style : null;
+ };
+
+ /**
+ * Inner class for cached elements
+ * @private
+ * @deprecated
+ */
+ this.ElementWrapper = function(el) {
+ /**
+ * @private
+ */
+ this.el = el || null;
+ /**
+ * @private
+ */
+ this.id = this.el && el.id;
+ /**
+ * @private
+ */
+ this.css = this.el && el.style;
+ };
+
+ /**
+ * Returns the X position of an html element
+ * @param el the element for which to get the position
+ * @return {int} the X coordinate
+ * @deprecated
+ */
+ this.getPosX = function(el) {
+ return YAHOO.util.Dom.getX(el);
+ };
+
+ /**
+ * Returns the Y position of an html element
+ * @param el the element for which to get the position
+ * @return {int} the Y coordinate
+ * @deprecated
+ */
+ this.getPosY = function(el) {
+ return YAHOO.util.Dom.getY(el);
+ };
+
+ /**
+ * Swap two nodes. In IE, we use the native method, for others we
+ * emulate the IE behavior
+ *
+ * @param n1 the first node to swap
+ * @param n2 the other node to swap
+ */
+ this.swapNode = function(n1, n2) {
+ if (n1.swapNode) {
+ n1.swapNode(n2);
+ } else {
+ // the node reference order for the swap is a little tricky.
+ var p = n2.parentNode;
+ var s = n2.nextSibling;
+ n1.parentNode.replaceChild(n2, n1);
+ p.insertBefore(n1,s);
+ }
+ };
+
+ /**
+ * @private
+ */
+ this.getScroll = function () {
+ var t, l;
+ if (document.documentElement && document.documentElement.scrollTop) {
+ t = document.documentElement.scrollTop;
+ l = document.documentElement.scrollLeft;
+ } else if (document.body) {
+ t = document.body.scrollTop;
+ l = document.body.scrollLeft;
+ }
+ return { top: t, left: l };
+ };
+
+ /**
+ * Returns the specified element style property
+ * @param {HTMLElement} el the element
+ * @param {string} styleProp the style property
+ * @return {string} The value of the style property
+ * @deprecated, use YAHOO.util.Dom.getStyle
+ */
+ this.getStyle = function(el, styleProp) {
+ return YAHOO.util.Dom.getStyle(el, styleProp);
+ };
+
+ /**
+ * Gets the scrollTop
+ * @return {int} the document's scrollTop
+ */
+ this.getScrollTop = function () { return this.getScroll().top; };
+
+ /**
+ * Gets the scrollLeft
+ * @return {int} the document's scrollTop
+ */
+ this.getScrollLeft = function () { return this.getScroll().left; };
+
+ /**
+ * Sets the x/y position of an element to the location of the
+ * target element.
+ * @param {HTMLElement} moveEl The element to move
+ * @param {HTMLElement} targetEl The position reference element
+ */
+ this.moveToEl = function (moveEl, targetEl) {
+ var aCoord = YAHOO.util.Dom.getXY(targetEl);
+ YAHOO.util.Dom.setXY(moveEl, aCoord);
+ };
+
+ /**
+ * Gets the client height
+ * @return {int} client height in px
+ * @deprecated
+ */
+ this.getClientHeight = function() {
+ return YAHOO.util.Dom.getClientHeight();
+ };
+
+ /**
+ * Gets the client width
+ * @return {int} client width in px
+ * @deprecated
+ */
+ this.getClientWidth = function() {
+ return YAHOO.util.Dom.getClientWidth();
+ };
+
+ /**
+ * numeric array sort function
+ */
+ this.numericSort = function(a, b) { return (a - b); };
+
+ /**
+ * @private
+ */
+ this._timeoutCount = 0;
+
+ /**
+ * Trying to make the load order less important. Without this we get
+ * an error if this file is loaded before the Event Utility.
+ * @private
+ */
+ this._addListeners = function() {
+ if ( YAHOO.util.Event && document ) {
+ this._onLoad();
+ } else {
+ if (this._timeoutCount > 1000) {
+ } else {
+ var DDM = YAHOO.util.DDM;
+ setTimeout( function() { DDM._addListeners(); }, 10);
+ if (document && document.body) {
+ this._timeoutCount += 1;
+ }
+ }
+ }
+ };
+
+ /**
+ * Recursively searches the immediate parent and all child nodes for
+ * the handle element in order to determine wheter or not it was
+ * clicked.
+ * @param node the html element to inspect
+ */
+ this.handleWasClicked = function(node, id) {
+ if (this.isHandle(id, node.id)) {
+ return true;
+ } else {
+ // check to see if this is a text node child of the one we want
+ var p = node.parentNode;
+
+ while (p) {
+ if (this.isHandle(id, p.id)) {
+ return true;
+ } else {
+ p = p.parentNode;
+ }
+ }
+ }
+
+ return false;
+ };
+
+ } ();
+
+ // shorter alias, save a few bytes
+ YAHOO.util.DDM = YAHOO.util.DragDropMgr;
+ YAHOO.util.DDM._addListeners();
+
+}
+
+/**
+ * A DragDrop implementation where the linked element follows the
+ * mouse cursor during a drag.
+ *
+ * @extends YAHOO.util.DragDrop
+ * @constructor
+ * @param {String} id the id of the linked element
+ * @param {String} sGroup the group of related DragDrop items
+ * @param {object} config an object containing configurable attributes
+ * Valid properties for DD:
+ * scroll
+ */
+YAHOO.util.DD = function(id, sGroup, config) {
+ if (id) {
+ this.init(id, sGroup, config);
+ }
+};
+
+// YAHOO.util.DD.prototype = new YAHOO.util.DragDrop();
+YAHOO.extend(YAHOO.util.DD, YAHOO.util.DragDrop);
+
+/**
+ * When set to true, the utility automatically tries to scroll the browser
+ * window wehn a drag and drop element is dragged near the viewport boundary.
+ * Defaults to true.
+ *
+ * @type boolean
+ */
+YAHOO.util.DD.prototype.scroll = true;
+
+/**
+ * Sets the pointer offset to the distance between the linked element's top
+ * left corner and the location the element was clicked
+ *
+ * @param {int} iPageX the X coordinate of the click
+ * @param {int} iPageY the Y coordinate of the click
+ */
+YAHOO.util.DD.prototype.autoOffset = function(iPageX, iPageY) {
+ // var el = this.getEl();
+ // var aCoord = YAHOO.util.Dom.getXY(el);
+ // var x = iPageX - aCoord[0];
+ // var y = iPageY - aCoord[1];
+ var x = iPageX - this.startPageX;
+ var y = iPageY - this.startPageY;
+ this.setDelta(x, y);
+};
+
+/**
+ * Sets the pointer offset. You can call this directly to force the offset to
+ * be in a particular location (e.g., pass in 0,0 to set it to the center of the
+ * object, as done in YAHOO.widget.Slider)
+ *
+ * @param {int} iDeltaX the distance from the left
+ * @param {int} iDeltaY the distance from the top
+ */
+YAHOO.util.DD.prototype.setDelta = function(iDeltaX, iDeltaY) {
+ this.deltaX = iDeltaX;
+ this.deltaY = iDeltaY;
+};
+
+/**
+ * Sets the drag element to the location of the mousedown or click event,
+ * maintaining the cursor location relative to the location on the element
+ * that was clicked. Override this if you want to place the element in a
+ * location other than where the cursor is.
+ *
+ * @param {int} iPageX the X coordinate of the mousedown or drag event
+ * @param {int} iPageY the Y coordinate of the mousedown or drag event
+ */
+
+YAHOO.util.DD.prototype.setDragElPos = function(iPageX, iPageY) {
+ // the first time we do this, we are going to check to make sure
+ // the element has css positioning
+
+ var el = this.getDragEl();
+
+ // if (!this.cssVerified) {
+ // var pos = el.style.position;
+ // }
+
+ this.alignElWithMouse(el, iPageX, iPageY);
+};
+
+/**
+ * Sets the element to the location of the mousedown or click event,
+ * maintaining the cursor location relative to the location on the element
+ * that was clicked. Override this if you want to place the element in a
+ * location other than where the cursor is.
+ *
+ * @param {HTMLElement} el the element to move
+ * @param {int} iPageX the X coordinate of the mousedown or drag event
+ * @param {int} iPageY the Y coordinate of the mousedown or drag event
+ */
+YAHOO.util.DD.prototype.alignElWithMouse = function(el, iPageX, iPageY) {
+ var oCoord = this.getTargetCoord(iPageX, iPageY);
+
+ // this.deltaSetXY = null;
+ if (!this.deltaSetXY) {
+ var aCoord = [oCoord.x, oCoord.y];
+ YAHOO.util.Dom.setXY(el, aCoord);
+ var newLeft = parseInt( YAHOO.util.Dom.getStyle(el, "left"), 10 );
+ var newTop = parseInt( YAHOO.util.Dom.getStyle(el, "top" ), 10 );
+
+ this.deltaSetXY = [ newLeft - oCoord.x, newTop - oCoord.y ];
+
+ } else {
+ YAHOO.util.Dom.setStyle(el, "left", (oCoord.x + this.deltaSetXY[0]) + "px");
+ YAHOO.util.Dom.setStyle(el, "top", (oCoord.y + this.deltaSetXY[1]) + "px");
+ }
+
+
+ this.cachePosition(oCoord.x, oCoord.y);
+
+ this.autoScroll(oCoord.x, oCoord.y, el.offsetHeight, el.offsetWidth);
+};
+
+/**
+ * Saves the most recent position so that we can reset the constraints and
+ * tick marks on-demand. We need to know this so that we can calculate the
+ * number of pixels the element is offset from its original position.
+ */
+YAHOO.util.DD.prototype.cachePosition = function(iPageX, iPageY) {
+ if (iPageX) {
+ this.lastPageX = iPageX;
+ this.lastPageY = iPageY;
+ } else {
+ var aCoord = YAHOO.util.Dom.getXY(this.getEl());
+ this.lastPageX = aCoord[0];
+ this.lastPageY = aCoord[1];
+ }
+};
+
+/**
+ * Auto-scroll the window if the dragged object has been moved beyond the
+ * visible window boundary.
+ *
+ * @param {int} x the drag element's x position
+ * @param {int} y the drag element's y position
+ * @param {int} h the height of the drag element
+ * @param {int} w the width of the drag element
+ * @private
+ */
+YAHOO.util.DD.prototype.autoScroll = function(x, y, h, w) {
+
+ if (this.scroll) {
+ // The client height
+ var clientH = this.DDM.getClientHeight();
+
+ // The client width
+ var clientW = this.DDM.getClientWidth();
+
+ // The amt scrolled down
+ var st = this.DDM.getScrollTop();
+
+ // The amt scrolled right
+ var sl = this.DDM.getScrollLeft();
+
+ // Location of the bottom of the element
+ var bot = h + y;
+
+ // Location of the right of the element
+ var right = w + x;
+
+ // The distance from the cursor to the bottom of the visible area,
+ // adjusted so that we don't scroll if the cursor is beyond the
+ // element drag constraints
+ var toBot = (clientH + st - y - this.deltaY);
+
+ // The distance from the cursor to the right of the visible area
+ var toRight = (clientW + sl - x - this.deltaX);
+
+
+ // How close to the edge the cursor must be before we scroll
+ // var thresh = (document.all) ? 100 : 40;
+ var thresh = 40;
+
+ // How many pixels to scroll per autoscroll op. This helps to reduce
+ // clunky scrolling. IE is more sensitive about this ... it needs this
+ // value to be higher.
+ var scrAmt = (document.all) ? 80 : 30;
+
+ // Scroll down if we are near the bottom of the visible page and the
+ // obj extends below the crease
+ if ( bot > clientH && toBot < thresh ) {
+ window.scrollTo(sl, st + scrAmt);
+ }
+
+ // Scroll up if the window is scrolled down and the top of the object
+ // goes above the top border
+ if ( y < st && st > 0 && y - st < thresh ) {
+ window.scrollTo(sl, st - scrAmt);
+ }
+
+ // Scroll right if the obj is beyond the right border and the cursor is
+ // near the border.
+ if ( right > clientW && toRight < thresh ) {
+ window.scrollTo(sl + scrAmt, st);
+ }
+
+ // Scroll left if the window has been scrolled to the right and the obj
+ // extends past the left border
+ if ( x < sl && sl > 0 && x - sl < thresh ) {
+ window.scrollTo(sl - scrAmt, st);
+ }
+ }
+};
+
+/**
+ * Finds the location the element should be placed if we want to move
+ * it to where the mouse location less the click offset would place us.
+ *
+ * @param {int} iPageX the X coordinate of the click
+ * @param {int} iPageY the Y coordinate of the click
+ * @return an object that contains the coordinates (Object.x and Object.y)
+ * @private
+ */
+YAHOO.util.DD.prototype.getTargetCoord = function(iPageX, iPageY) {
+
+
+ var x = iPageX - this.deltaX;
+ var y = iPageY - this.deltaY;
+
+ if (this.constrainX) {
+ if (x < this.minX) { x = this.minX; }
+ if (x > this.maxX) { x = this.maxX; }
+ }
+
+ if (this.constrainY) {
+ if (y < this.minY) { y = this.minY; }
+ if (y > this.maxY) { y = this.maxY; }
+ }
+
+ x = this.getTick(x, this.xTicks);
+ y = this.getTick(y, this.yTicks);
+
+
+ return {x:x, y:y};
+};
+
+YAHOO.util.DD.prototype.applyConfig = function() {
+ YAHOO.util.DD.superclass.applyConfig.call(this);
+ this.scroll = (this.config.scroll !== false);
+};
+
+/**
+ * Event that fires prior to the onMouseDown event. Overrides
+ * YAHOO.util.DragDrop.
+ */
+YAHOO.util.DD.prototype.b4MouseDown = function(e) {
+ // this.resetConstraints();
+ this.autoOffset(YAHOO.util.Event.getPageX(e),
+ YAHOO.util.Event.getPageY(e));
+};
+
+/**
+ * Event that fires prior to the onDrag event. Overrides
+ * YAHOO.util.DragDrop.
+ */
+YAHOO.util.DD.prototype.b4Drag = function(e) {
+ this.setDragElPos(YAHOO.util.Event.getPageX(e),
+ YAHOO.util.Event.getPageY(e));
+};
+
+YAHOO.util.DD.prototype.toString = function() {
+ return ("DD " + this.id);
+};
+
+///////////////////////////////////////////////////////////////////////////////
+// Debugging ygDragDrop events that can be overridden
+///////////////////////////////////////////////////////////////////////////////
+/*
+YAHOO.util.DD.prototype.startDrag = function(x, y) {
+};
+
+YAHOO.util.DD.prototype.onDrag = function(e) {
+};
+
+YAHOO.util.DD.prototype.onDragEnter = function(e, id) {
+};
+
+YAHOO.util.DD.prototype.onDragOver = function(e, id) {
+};
+
+YAHOO.util.DD.prototype.onDragOut = function(e, id) {
+};
+
+YAHOO.util.DD.prototype.onDragDrop = function(e, id) {
+};
+
+YAHOO.util.DD.prototype.endDrag = function(e) {
+};
+*/
+
+/**
+ * A DragDrop implementation that inserts an empty, bordered div into
+ * the document that follows the cursor during drag operations. At the time of
+ * the click, the frame div is resized to the dimensions of the linked html
+ * element, and moved to the exact location of the linked element.
+ *
+ * References to the "frame" element refer to the single proxy element that
+ * was created to be dragged in place of all DDProxy elements on the
+ * page.
+ *
+ * @extends YAHOO.util.DD
+ * @constructor
+ * @param {String} id the id of the linked html element
+ * @param {String} sGroup the group of related DragDrop objects
+ * @param {object} config an object containing configurable attributes
+ * Valid properties for DDProxy in addition to those in DragDrop:
+ * resizeFrame, centerFrame, dragElId
+ */
+YAHOO.util.DDProxy = function(id, sGroup, config) {
+ if (id) {
+ this.init(id, sGroup, config);
+ this.initFrame();
+ }
+};
+
+YAHOO.extend(YAHOO.util.DDProxy, YAHOO.util.DD);
+
+/**
+ * The default drag frame div id
+ * @type String
+ */
+YAHOO.util.DDProxy.dragElId = "ygddfdiv";
+
+/**
+ * By default we resize the drag frame to be the same size as the element
+ * we want to drag (this is to get the frame effect). We can turn it off
+ * if we want a different behavior.
+ *
+ * @type boolean
+ */
+YAHOO.util.DDProxy.prototype.resizeFrame = true;
+
+/**
+ * By default the frame is positioned exactly where the drag element is, so
+ * we use the cursor offset provided by YAHOO.util.DD. Another option that works only if
+ * you do not have constraints on the obj is to have the drag frame centered
+ * around the cursor. Set centerFrame to true for this effect.
+ *
+ * @type boolean
+ */
+YAHOO.util.DDProxy.prototype.centerFrame = false;
+
+/**
+ * Create the drag frame if needed
+ */
+YAHOO.util.DDProxy.prototype.createFrame = function() {
+ var self = this;
+ var body = document.body;
+
+ if (!body || !body.firstChild) {
+ setTimeout( function() { self.createFrame(); }, 50 );
+ return;
+ }
+
+ var div = this.getDragEl();
+
+ if (!div) {
+ div = document.createElement("div");
+ div.id = this.dragElId;
+ var s = div.style;
+
+ s.position = "absolute";
+ s.visibility = "hidden";
+ s.cursor = "move";
+ s.border = "2px solid #aaa";
+ s.zIndex = 999;
+
+ // appendChild can blow up IE if invoked prior to the window load event
+ // while rendering a table. It is possible there are other scenarios
+ // that would cause this to happen as well.
+ body.insertBefore(div, body.firstChild);
+ }
+};
+
+/**
+ * Initialization for the drag frame element. Must be called in the
+ * constructor of all subclasses
+ */
+YAHOO.util.DDProxy.prototype.initFrame = function() {
+ // YAHOO.util.DDProxy.createFrame();
+ // this.setDragElId(YAHOO.util.DDProxy.dragElId);
+
+ this.createFrame();
+
+};
+
+YAHOO.util.DDProxy.prototype.applyConfig = function() {
+ YAHOO.util.DDProxy.superclass.applyConfig.call(this);
+
+ this.resizeFrame = (this.config.resizeFrame !== false);
+ this.centerFrame = (this.config.centerFrame);
+ this.setDragElId(this.config.dragElId || YAHOO.util.DDProxy.dragElId);
+
+};
+
+/**
+ * Resizes the drag frame to the dimensions of the clicked object, positions
+ * it over the object, and finally displays it
+ *
+ * @param {int} iPageX X click position
+ * @param {int} iPageY Y click position
+ * @private
+ */
+YAHOO.util.DDProxy.prototype.showFrame = function(iPageX, iPageY) {
+ var el = this.getEl();
+ var dragEl = this.getDragEl();
+ var s = dragEl.style;
+
+ this._resizeProxy();
+
+ if (this.centerFrame) {
+ this.setDelta( Math.round(parseInt(s.width, 10)/2),
+ Math.round(parseInt(s.height, 10)/2) );
+ }
+
+ this.setDragElPos(iPageX, iPageY);
+
+ YAHOO.util.Dom.setStyle(dragEl, "visibility", "visible");
+};
+
+YAHOO.util.DDProxy.prototype._resizeProxy = function() {
+ var DOM = YAHOO.util.Dom;
+ var el = this.getEl();
+ var dragEl = this.getDragEl();
+
+ if (this.resizeFrame) {
+ var bt = parseInt( DOM.getStyle(dragEl, "borderTopWidth" ), 10);
+ var br = parseInt( DOM.getStyle(dragEl, "borderRightWidth" ), 10);
+ var bb = parseInt( DOM.getStyle(dragEl, "borderBottomWidth" ), 10);
+ var bl = parseInt( DOM.getStyle(dragEl, "borderLeftWidth" ), 10);
+
+ if (isNaN(bt)) { bt = 0; }
+ if (isNaN(br)) { br = 0; }
+ if (isNaN(bb)) { bb = 0; }
+ if (isNaN(bl)) { bl = 0; }
+
+
+ var newWidth = el.offsetWidth - br - bl;
+ var newHeight = el.offsetHeight - bt - bb;
+
+
+ DOM.setStyle( dragEl, "width", newWidth + "px" );
+ DOM.setStyle( dragEl, "height", newHeight + "px" );
+ }
+};
+
+// overrides YAHOO.util.DragDrop
+YAHOO.util.DDProxy.prototype.b4MouseDown = function(e) {
+ var x = YAHOO.util.Event.getPageX(e);
+ var y = YAHOO.util.Event.getPageY(e);
+ this.autoOffset(x, y);
+ this.setDragElPos(x, y);
+};
+
+// overrides YAHOO.util.DragDrop
+YAHOO.util.DDProxy.prototype.b4StartDrag = function(x, y) {
+ // show the drag frame
+ this.showFrame(x, y);
+};
+
+// overrides YAHOO.util.DragDrop
+YAHOO.util.DDProxy.prototype.b4EndDrag = function(e) {
+ YAHOO.util.Dom.setStyle(this.getDragEl(), "visibility", "hidden");
+};
+
+// overrides YAHOO.util.DragDrop
+// By default we try to move the element to the last location of the frame.
+// This is so that the default behavior mirrors that of YAHOO.util.DD.
+YAHOO.util.DDProxy.prototype.endDrag = function(e) {
+ var DOM = YAHOO.util.Dom;
+ var lel = this.getEl();
+ var del = this.getDragEl();
+
+ // Show the drag frame briefly so we can get its position
+ // del.style.visibility = "";
+ DOM.setStyle(del, "visibility", "");
+
+ // Hide the linked element before the move to get around a Safari
+ // rendering bug.
+ //lel.style.visibility = "hidden";
+ DOM.setStyle(lel, "visibility", "hidden");
+ YAHOO.util.DDM.moveToEl(lel, del);
+ //del.style.visibility = "hidden";
+ DOM.setStyle(del, "visibility", "hidden");
+ //lel.style.visibility = "";
+ DOM.setStyle(lel, "visibility", "");
+};
+
+YAHOO.util.DDProxy.prototype.toString = function() {
+ return ("DDProxy " + this.id);
+};
+
+/**
+ * A DragDrop implementation that does not move, but can be a drop
+ * target. You would get the same result by simply omitting implementation
+ * for the event callbacks, but this way we reduce the processing cost of the
+ * event listener and the callbacks.
+ *
+ * @extends YAHOO.util.DragDrop
+ * @constructor
+ * @param {String} id the id of the element that is a drop target
+ * @param {String} sGroup the group of related DragDrop objects
+ * @param {object} config an object containing configurable attributes
+ * Valid properties for DDTarget in addition to those in DragDrop:
+ * none
+ */
+
+YAHOO.util.DDTarget = function(id, sGroup, config) {
+ if (id) {
+ this.initTarget(id, sGroup, config);
+ }
+};
+
+// YAHOO.util.DDTarget.prototype = new YAHOO.util.DragDrop();
+YAHOO.extend(YAHOO.util.DDTarget, YAHOO.util.DragDrop);
+
+YAHOO.util.DDTarget.prototype.toString = function() {
+ return ("DDTarget " + this.id);
+};
+
Added: branches/tomek/portal-dnd/dndRenderer.war/js/event/README
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/event/README 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/event/README 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,55 @@
+
+YUI Library - Event - Release Notes
+
+0.11.0
+
+ * Added Event.purgeElement which will remove all listeners added via
+ addListener from the supplied element. If an optional "type" parameter
+ is supplied, only events of that type will be removed. Optionally, the
+ purge can be performed recursively on the element's children as well.
+
+ * Added Event.getListeners which will return all listeners attached to
+ a given element.. either all listeners or listeners of a specific type.
+
+ * getTarget now automatically resolves text nodes. The optional parameter
+ for this feature is now deprecated.
+
+ * getRelatedTarget now resolves text nodes for the browsers that return the
+ text node rather than its host HTML element.
+
+ * CustomEvent now logs the custom event activity if the logger widget is available
+
+0.10.0
+
+ * Added Safari dblclick to the list of legacy events.
+
+ * When multiple identical event handlers are defined, multiple calls
+ to removeListener can now remove all of them.
+
+ * removeListener works properly for unload events
+
+ * Legacy event bookkeeping is more efficient, improving the performance for
+ adding Safari click events.
+
+ * _unload() is more efficient, improving the page transition experience in
+ Safari in particular.
+
+ * addListener, removeListener now return false if the function argument is
+ not valid.
+
+ * Fixed an operator precedence issue in getCharCode.
+
+ * Added Event.getXY, which returns [Event.getPageX(e), Event.getPageY(e)]
+
+ * Added Event.onAvailable, which will execute the callback when the element
+ with the supplied id is found. Currently searches periodically until the
+ window load event or for up to 10 seconds after the onAvailable method
+ was executed.
+
+ * The lazy listener attachment process now will poll beyond the window load
+ event in order to better handle the case when a listener is defined
+ late in the page but before the element is in the dom.
+
+ * Fixed browser detection for Opera installations reporting as IE.
+
+ * It is now possible to remove and re-add legacy events (Safari click event).
Added: branches/tomek/portal-dnd/dndRenderer.war/js/event/event-debug.js
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/event/event-debug.js 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/event/event-debug.js 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,1232 @@
+
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 0.11.0
+*/
+
+
+/**
+ * The CustomEvent class lets you define events for your application
+ * that can be subscribed to by one or more independent component.
+ *
+ * @param {String} type The type of event, which is passed to the callback
+ * when the event fires
+ * @param {Object} oScope The context the event will fire from. "this" will
+ * refer to this object in the callback. Default value:
+ * the window object. The listener can override this.
+ * @constructor
+ */
+YAHOO.util.CustomEvent = function(type, oScope, silent) {
+
+ /**
+ * The type of event, returned to subscribers when the event fires
+ * @type string
+ */
+ this.type = type;
+
+ /**
+ * The scope the the event will fire from by default. Defaults to the window
+ * obj
+ * @type object
+ */
+ this.scope = oScope || window;
+
+ /**
+ * By default all custom events are logged in the debug build, set silent
+ * to true to disable logging for this event.
+ * @type boolean
+ */
+ this.silent = silent;
+
+ /**
+ * The subscribers to this event
+ * @type Subscriber[]
+ */
+ this.subscribers = [];
+
+ // Register with the event utility for automatic cleanup. Made optional
+ // so that CustomEvent can be used independently of pe.event
+ if (YAHOO.util.Event) {
+ YAHOO.util.Event.regCE(this);
+ }
+
+ if (!this.silent) {
+ YAHOO.log( "Creating " + this, "info", "Event" );
+ }
+};
+
+YAHOO.util.CustomEvent.prototype = {
+ /**
+ * Subscribes the caller to this event
+ * @param {Function} fn The function to execute
+ * @param {Object} obj An object to be passed along when the event fires
+ * @param {boolean} bOverride If true, the obj passed in becomes the execution
+ * scope of the listener
+ */
+ subscribe: function(fn, obj, bOverride) {
+ this.subscribers.push( new YAHOO.util.Subscriber(fn, obj, bOverride) );
+ },
+
+ /**
+ * Unsubscribes the caller from this event
+ * @param {Function} fn The function to execute
+ * @param {Object} obj An object to be passed along when the event fires
+ * @return {boolean} True if the subscriber was found and detached.
+ */
+ unsubscribe: function(fn, obj) {
+ var found = false;
+ for (var i=0, len=this.subscribers.length; i<len; ++i) {
+ var s = this.subscribers[i];
+ if (s && s.contains(fn, obj)) {
+ this._delete(i);
+ found = true;
+ }
+ }
+
+ return found;
+ },
+
+ /**
+ * Notifies the subscribers. The callback functions will be executed
+ * from the scope specified when the event was created, and with the following
+ * parameters:
+ * <pre>
+ * - The type of event
+ * - All of the arguments fire() was executed with as an array
+ * - The custom object (if any) that was passed into the subscribe() method
+ * </pre>
+ *
+ * @param {Array} an arbitrary set of parameters to pass to the handler
+ */
+ fire: function() {
+ var len=this.subscribers.length;
+
+ var args = [];
+
+ for (var i=0; i<arguments.length; ++i) {
+ args.push(arguments[i]);
+ }
+
+
+ if (!this.silent) {
+ YAHOO.log( "Firing " + this + ", " +
+ "args: " + args + ", " +
+ "subscribers: " + len,
+ "info", "Event" );
+ }
+
+ for (i=0; i<len; ++i) {
+ var s = this.subscribers[i];
+ if (s) {
+ if (!this.silent) {
+ YAHOO.log( this.type + "->" + (i+1) + ": " + s, "info", "Event" );
+ }
+ var scope = (s.override) ? s.obj : this.scope;
+ s.fn.call(scope, this.type, args, s.obj);
+ }
+ }
+ },
+
+ /**
+ * Removes all listeners
+ */
+ unsubscribeAll: function() {
+ for (var i=0, len=this.subscribers.length; i<len; ++i) {
+ this._delete(i);
+ }
+ },
+
+ /**
+ * @private
+ */
+ _delete: function(index) {
+ var s = this.subscribers[index];
+ if (s) {
+ delete s.fn;
+ delete s.obj;
+ }
+
+ delete this.subscribers[index];
+ },
+
+ toString: function() {
+ return "CustomEvent: " + "'" + this.type + "', " +
+ "scope: " + this.scope;
+
+ }
+};
+
+/////////////////////////////////////////////////////////////////////
+
+/**
+ * @class Stores the subscriber information to be used when the event fires.
+ * @param {Function} fn The function to execute
+ * @param {Object} obj An object to be passed along when the event fires
+ * @param {boolean} bOverride If true, the obj passed in becomes the execution
+ * scope of the listener
+ * @constructor
+ */
+YAHOO.util.Subscriber = function(fn, obj, bOverride) {
+ /**
+ * The callback that will be execute when the event fires
+ * @type function
+ */
+ this.fn = fn;
+
+ /**
+ * An optional custom object that will passed to the callback when
+ * the event fires
+ * @type object
+ */
+ this.obj = obj || null;
+
+ /**
+ * The default execution scope for the event listener is defined when the
+ * event is created (usually the object which contains the event).
+ * By setting override to true, the execution scope becomes the custom
+ * object passed in by the subscriber
+ * @type boolean
+ */
+ this.override = (bOverride);
+};
+
+/**
+ * Returns true if the fn and obj match this objects properties.
+ * Used by the unsubscribe method to match the right subscriber.
+ *
+ * @param {Function} fn the function to execute
+ * @param {Object} obj an object to be passed along when the event fires
+ * @return {boolean} true if the supplied arguments match this
+ * subscriber's signature.
+ */
+YAHOO.util.Subscriber.prototype.contains = function(fn, obj) {
+ return (this.fn == fn && this.obj == obj);
+};
+
+YAHOO.util.Subscriber.prototype.toString = function() {
+ return "Subscriber { obj: " + (this.obj || "") +
+ ", override: " + (this.override || "no") + " }";
+};
+// Only load this library once. If it is loaded a second time, existing
+// events cannot be detached.
+if (!YAHOO.util.Event) {
+
+/**
+ * @class
+ * The event utility provides functions to add and remove event listeners,
+ * event cleansing. It also tries to automatically remove listeners it
+ * registers during the unload event.
+ * @constructor
+ */
+ YAHOO.util.Event = function() {
+
+ /**
+ * True after the onload event has fired
+ * @type boolean
+ * @private
+ */
+ var loadComplete = false;
+
+ /**
+ * Cache of wrapped listeners
+ * @type array
+ * @private
+ */
+ var listeners = [];
+
+ /**
+ * Listeners that will be attached during the onload event
+ * @type array
+ * @private
+ */
+ var delayedListeners = [];
+
+ /**
+ * User-defined unload function that will be fired before all events
+ * are detached
+ * @type array
+ * @private
+ */
+ var unloadListeners = [];
+
+ /**
+ * Cache of the custom events that have been defined. Used for
+ * automatic cleanup
+ * @type array
+ * @private
+ */
+ var customEvents = [];
+
+ /**
+ * Cache of DOM0 event handlers to work around issues with DOM2 events
+ * in Safari
+ * @private
+ */
+ var legacyEvents = [];
+
+ /**
+ * Listener stack for DOM0 events
+ * @private
+ */
+ var legacyHandlers = [];
+
+ /**
+ * The number of times to poll after window.onload. This number is
+ * increased if additional late-bound handlers are requested after
+ * the page load.
+ * @private
+ */
+ var retryCount = 0;
+
+ /**
+ * onAvailable listeners
+ * @private
+ */
+ var onAvailStack = [];
+
+ /**
+ * Lookup table for legacy events
+ * @private
+ */
+ var legacyMap = [];
+
+ /**
+ * Counter for auto id generation
+ * @private
+ */
+ var counter = 0;
+
+ return { // PREPROCESS
+
+ /**
+ * The number of times we should look for elements that are not
+ * in the DOM at the time the event is requested after the document
+ * has been loaded. The default is 200 at 50 ms, so it will poll
+ * for 10 seconds or until all outstanding handlers are bound
+ * (whichever comes first).
+ * @type int
+ */
+ POLL_RETRYS: 200,
+
+ /**
+ * The poll interval in milliseconds
+ * @type int
+ */
+ POLL_INTERVAL: 50,
+
+ /**
+ * Element to bind, int constant
+ * @type int
+ */
+ EL: 0,
+
+ /**
+ * Type of event, int constant
+ * @type int
+ */
+ TYPE: 1,
+
+ /**
+ * Function to execute, int constant
+ * @type int
+ */
+ FN: 2,
+
+ /**
+ * Function wrapped for scope correction and cleanup, int constant
+ * @type int
+ */
+ WFN: 3,
+
+ /**
+ * Object passed in by the user that will be returned as a
+ * parameter to the callback, int constant
+ * @type int
+ */
+ SCOPE: 3,
+
+ /**
+ * Adjusted scope, either the element we are registering the event
+ * on or the custom object passed in by the listener, int constant
+ * @type int
+ */
+ ADJ_SCOPE: 4,
+
+ /**
+ * Safari detection is necessary to work around the preventDefault
+ * bug that makes it so you can't cancel a href click from the
+ * handler. There is not a capabilities check we can use here.
+ * @private
+ */
+ isSafari: (/Safari|Konqueror|KHTML/gi).test(navigator.userAgent),
+
+ /**
+ * IE detection needed to properly calculate pageX and pageY.
+ * capabilities checking didn't seem to work because another
+ * browser that does not provide the properties have the values
+ * calculated in a different manner than IE.
+ * @private
+ */
+ isIE: (!this.isSafari && !navigator.userAgent.match(/opera/gi) &&
+ navigator.userAgent.match(/msie/gi)),
+
+ /**
+ * @private
+ */
+ addDelayedListener: function(el, sType, fn, oScope, bOverride) {
+ delayedListeners[delayedListeners.length] =
+ [el, sType, fn, oScope, bOverride];
+
+ // If this happens after the inital page load, we need to
+ // reset the poll counter so that we continue to search for
+ // the element for a fixed period of time.
+ if (loadComplete) {
+ retryCount = this.POLL_RETRYS;
+ this.startTimeout(0);
+ // this._tryPreloadAttach();
+ }
+ },
+
+ /**
+ * @private
+ */
+ startTimeout: function(interval) {
+ var i = (interval || interval === 0) ? interval : this.POLL_INTERVAL;
+ var self = this;
+ var callback = function() { self._tryPreloadAttach(); };
+ this.timeout = setTimeout(callback, i);
+ },
+
+ /**
+ * Executes the supplied callback when the item with the supplied
+ * id is found. This is meant to be used to execute behavior as
+ * soon as possible as the page loads. If you use this after the
+ * initial page load it will poll for a fixed time for the element.
+ * The number of times it will poll and the frequency are
+ * configurable. By default it will poll for 10 seconds.
+ * @param {string} p_id the id of the element to look for.
+ * @param {function} p_fn what to execute when the element is found.
+ * @param {object} p_obj an optional object to be passed back as
+ * a parameter to p_fn.
+ * @param {boolean} p_override If set to true, p_fn will execute
+ * in the scope of p_obj
+ *
+ */
+ onAvailable: function(p_id, p_fn, p_obj, p_override) {
+ onAvailStack.push( { id: p_id,
+ fn: p_fn,
+ obj: p_obj,
+ override: p_override } );
+
+ retryCount = this.POLL_RETRYS;
+ this.startTimeout(0);
+ // this._tryPreloadAttach();
+ },
+
+ /**
+ * Appends an event handler
+ *
+ * @param {Object} el The html element to assign the
+ * event to
+ * @param {String} sType The type of event to append
+ * @param {Function} fn The method the event invokes
+ * @param {Object} oScope An arbitrary object that will be
+ * passed as a parameter to the handler
+ * @param {boolean} bOverride If true, the obj passed in becomes
+ * the execution scope of the listener
+ * @return {boolean} True if the action was successful or defered,
+ * false if one or more of the elements
+ * could not have the event bound to it.
+ */
+ addListener: function(el, sType, fn, oScope, bOverride) {
+
+ if (!fn || !fn.call) {
+ // this.logger.debug("Error, function is not valid " + fn);
+ return false;
+ }
+
+ // The el argument can be an array of elements or element ids.
+ if ( this._isValidCollection(el)) {
+ var ok = true;
+ for (var i=0,len=el.length; i<len; ++i) {
+ ok = ( this.on(el[i],
+ sType,
+ fn,
+ oScope,
+ bOverride) && ok );
+ }
+ return ok;
+
+ } else if (typeof el == "string") {
+ var oEl = this.getEl(el);
+ // If the el argument is a string, we assume it is
+ // actually the id of the element. If the page is loaded
+ // we convert el to the actual element, otherwise we
+ // defer attaching the event until onload event fires
+
+ // check to see if we need to delay hooking up the event
+ // until after the page loads.
+ if (loadComplete && oEl) {
+ el = oEl;
+ } else {
+ // defer adding the event until onload fires
+ this.addDelayedListener(el,
+ sType,
+ fn,
+ oScope,
+ bOverride);
+
+ return true;
+ }
+ }
+
+ // Element should be an html element or an array if we get
+ // here.
+ if (!el) {
+ // this.logger.debug("unable to attach event " + sType);
+ return false;
+ }
+
+ // we need to make sure we fire registered unload events
+ // prior to automatically unhooking them. So we hang on to
+ // these instead of attaching them to the window and fire the
+ // handles explicitly during our one unload event.
+ if ("unload" == sType && oScope !== this) {
+ unloadListeners[unloadListeners.length] =
+ [el, sType, fn, oScope, bOverride];
+ return true;
+ }
+
+ // this.logger.debug("Adding handler: " + el + ", " + sType);
+
+ // if the user chooses to override the scope, we use the custom
+ // object passed in, otherwise the executing scope will be the
+ // HTML element that the event is registered on
+ var scope = (bOverride) ? oScope : el;
+
+ // wrap the function so we can return the oScope object when
+ // the event fires;
+ var wrappedFn = function(e) {
+ return fn.call(scope, YAHOO.util.Event.getEvent(e),
+ oScope);
+ };
+
+ var li = [el, sType, fn, wrappedFn, scope];
+ var index = listeners.length;
+ // cache the listener so we can try to automatically unload
+ listeners[index] = li;
+
+ if (this.useLegacyEvent(el, sType)) {
+ var legacyIndex = this.getLegacyIndex(el, sType);
+ if (legacyIndex == -1) {
+
+ legacyIndex = legacyEvents.length;
+ legacyMap[el.id + sType] = legacyIndex;
+
+ // cache the signature for the DOM0 event, and
+ // include the existing handler for the event, if any
+ legacyEvents[legacyIndex] =
+ [el, sType, el["on" + sType]];
+ legacyHandlers[legacyIndex] = [];
+
+ el["on" + sType] =
+ function(e) {
+ YAHOO.util.Event.fireLegacyEvent(
+ YAHOO.util.Event.getEvent(e), legacyIndex);
+ };
+ }
+
+ // add a reference to the wrapped listener to our custom
+ // stack of events
+ legacyHandlers[legacyIndex].push(index);
+
+ // DOM2 Event model
+ } else if (el.addEventListener) {
+ // this.logger.debug("adding DOM event: " + el.id +
+ // ", " + sType);
+ el.addEventListener(sType, wrappedFn, false);
+ // IE
+ } else if (el.attachEvent) {
+ el.attachEvent("on" + sType, wrappedFn);
+ }
+
+ return true;
+
+ },
+
+ /**
+ * Shorthand for YAHOO.util.Event.addListener
+ * @type function
+ */
+ // on: this.addListener,
+
+ /**
+ * When using legacy events, the handler is routed to this object
+ * so we can fire our custom listener stack.
+ * @private
+ */
+ fireLegacyEvent: function(e, legacyIndex) {
+ // this.logger.debug("fireLegacyEvent " + legacyIndex);
+ var ok = true;
+
+ var le = legacyHandlers[legacyIndex];
+ for (var i=0,len=le.length; i<len; ++i) {
+ var index = le[i];
+ // this.logger.debug(index);
+ if (index) {
+ var li = listeners[index];
+ if ( li && li[this.WFN] ) {
+ var scope = li[this.ADJ_SCOPE];
+ var ret = li[this.WFN].call(scope, e);
+ ok = (ok && ret);
+ } else {
+ // This listener was removed, so delete it from
+ // the array
+ delete le[i];
+ }
+ // this.logger.debug(ok);
+ }
+ }
+
+ return ok;
+ },
+
+ /**
+ * Returns the legacy event index that matches the supplied
+ * signature
+ * @private
+ */
+ getLegacyIndex: function(el, sType) {
+ /*
+ for (var i=0,len=legacyEvents.length; i<len; ++i) {
+ var le = legacyEvents[i];
+ if (le && le[0] === el && le[1] === sType) {
+ return i;
+ }
+ }
+ return -1;
+ */
+
+ var key = this.generateId(el) + sType;
+ if (typeof legacyMap[key] == "undefined") {
+ return -1;
+ } else {
+ return legacyMap[key];
+ }
+
+ },
+
+ /**
+ * Logic that determines when we should automatically use legacy
+ * events instead of DOM2 events.
+ * @private
+ */
+ useLegacyEvent: function(el, sType) {
+
+ if (!el.addEventListener && !el.attachEvent) {
+ return true;
+ } else if (this.isSafari) {
+ if ("click" == sType || "dblclick" == sType) {
+ return true;
+ }
+ }
+
+ return false;
+ },
+
+ /**
+ * Removes an event handler
+ *
+ * @param {Object} el the html element or the id of the element to
+ * assign the event to.
+ * @param {String} sType the type of event to remove
+ * @param {Function} fn the method the event invokes
+ * @return {boolean} true if the unbind was successful, false
+ * otherwise
+ */
+ removeListener: function(el, sType, fn, index) {
+
+ if (!fn || !fn.call) {
+ // this.logger.debug("Error, function is not valid " + fn);
+ return false;
+ }
+
+ // The el argument can be a string
+ if (typeof el == "string") {
+ el = this.getEl(el);
+ // The el argument can be an array of elements or element ids.
+ } else if ( this._isValidCollection(el)) {
+ var ok = true;
+ for (var i=0,len=el.length; i<len; ++i) {
+ ok = ( this.removeListener(el[i], sType, fn) && ok );
+ }
+ return ok;
+ }
+
+ if ("unload" == sType) {
+
+ for (i=0, len=unloadListeners.length; i<len; i++) {
+ var li = unloadListeners[i];
+ if (li &&
+ li[0] == el &&
+ li[1] == sType &&
+ li[2] == fn) {
+ delete unloadListeners[i];
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ var cacheItem = null;
+
+ if ("undefined" == typeof index) {
+ index = this._getCacheIndex(el, sType, fn);
+ }
+
+ if (index >= 0) {
+ cacheItem = listeners[index];
+ }
+
+ if (!el || !cacheItem) {
+ // this.logger.debug("cached listener not found");
+ return false;
+ }
+
+ // this.logger.debug("Removing handler: " + el + ", " + sType);
+
+ if (el.removeEventListener) {
+ el.removeEventListener(sType, cacheItem[this.WFN], false);
+ // this.logger.debug("adsf");
+ } else if (el.detachEvent) {
+ el.detachEvent("on" + sType, cacheItem[this.WFN]);
+ }
+
+ // removed the wrapped handler
+ delete listeners[index][this.WFN];
+ delete listeners[index][this.FN];
+ delete listeners[index];
+
+ return true;
+
+ },
+
+ /**
+ * Returns the event's target element
+ * @param {Event} ev the event
+ * @param {boolean} resolveTextNode when set to true the target's
+ * parent will be returned if the target is a
+ * text node. @deprecated, the text node is
+ * now resolved automatically
+ * @return {HTMLElement} the event's target
+ */
+ getTarget: function(ev, resolveTextNode) {
+ var t = ev.target || ev.srcElement;
+ return this.resolveTextNode(t);
+ },
+
+ /**
+ * In some cases, some browsers will return a text node inside
+ * the actual element that was targeted. This normalizes the
+ * return value for getTarget and getRelatedTarget.
+ * @param {HTMLElement} node to resolve
+ * @return the normized node
+ */
+ resolveTextNode: function(node) {
+ if (node && node.nodeName &&
+ "#TEXT" == node.nodeName.toUpperCase()) {
+ return node.parentNode;
+ } else {
+ return node;
+ }
+ },
+
+ /**
+ * Returns the event's pageX
+ * @param {Event} ev the event
+ * @return {int} the event's pageX
+ */
+ getPageX: function(ev) {
+ var x = ev.pageX;
+ if (!x && 0 !== x) {
+ x = ev.clientX || 0;
+
+ if ( this.isIE ) {
+ x += this._getScrollLeft();
+ }
+ }
+
+ return x;
+ },
+
+ /**
+ * Returns the event's pageY
+ * @param {Event} ev the event
+ * @return {int} the event's pageY
+ */
+ getPageY: function(ev) {
+ var y = ev.pageY;
+ if (!y && 0 !== y) {
+ y = ev.clientY || 0;
+
+ if ( this.isIE ) {
+ y += this._getScrollTop();
+ }
+ }
+
+
+ return y;
+ },
+
+ /**
+ * Returns the pageX and pageY properties as an indexed array.
+ * @type int[]
+ */
+ getXY: function(ev) {
+ return [this.getPageX(ev), this.getPageY(ev)];
+ },
+
+ /**
+ * Returns the event's related target
+ * @param {Event} ev the event
+ * @return {HTMLElement} the event's relatedTarget
+ */
+ getRelatedTarget: function(ev) {
+ var t = ev.relatedTarget;
+ if (!t) {
+ if (ev.type == "mouseout") {
+ t = ev.toElement;
+ } else if (ev.type == "mouseover") {
+ t = ev.fromElement;
+ }
+ }
+
+ return this.resolveTextNode(t);
+ },
+
+ /**
+ * Returns the time of the event. If the time is not included, the
+ * event is modified using the current time.
+ * @param {Event} ev the event
+ * @return {Date} the time of the event
+ */
+ getTime: function(ev) {
+ if (!ev.time) {
+ var t = new Date().getTime();
+ try {
+ ev.time = t;
+ } catch(e) {
+ // can't set the time property
+ return t;
+ }
+ }
+
+ return ev.time;
+ },
+
+ /**
+ * Convenience method for stopPropagation + preventDefault
+ * @param {Event} ev the event
+ */
+ stopEvent: function(ev) {
+ this.stopPropagation(ev);
+ this.preventDefault(ev);
+ },
+
+ /**
+ * Stops event propagation
+ * @param {Event} ev the event
+ */
+ stopPropagation: function(ev) {
+ if (ev.stopPropagation) {
+ ev.stopPropagation();
+ } else {
+ ev.cancelBubble = true;
+ }
+ },
+
+ /**
+ * Prevents the default behavior of the event
+ * @param {Event} ev the event
+ */
+ preventDefault: function(ev) {
+ if (ev.preventDefault) {
+ ev.preventDefault();
+ } else {
+ ev.returnValue = false;
+ }
+ },
+
+ /**
+ * Finds the event in the window object, the caller's arguments, or
+ * in the arguments of another method in the callstack. This is
+ * executed automatically for events registered through the event
+ * manager, so the implementer should not normally need to execute
+ * this function at all.
+ * @param {Event} the event parameter from the handler
+ * @return {Event} the event
+ */
+ getEvent: function(e) {
+ var ev = e || window.event;
+
+ if (!ev) {
+ var c = this.getEvent.caller;
+ while (c) {
+ ev = c.arguments[0];
+ if (ev && Event == ev.constructor) {
+ break;
+ }
+ c = c.caller;
+ }
+ }
+
+ return ev;
+ },
+
+ /**
+ * Returns the charcode for an event
+ * @param {Event} ev the event
+ * @return {int} the event's charCode
+ */
+ getCharCode: function(ev) {
+ return ev.charCode || ((ev.type == "keypress") ? ev.keyCode : 0);
+ },
+
+ /**
+ * @private
+ * Locating the saved event handler data by function ref
+ */
+ _getCacheIndex: function(el, sType, fn) {
+ for (var i=0,len=listeners.length; i<len; ++i) {
+ var li = listeners[i];
+ if ( li &&
+ li[this.FN] == fn &&
+ li[this.EL] == el &&
+ li[this.TYPE] == sType ) {
+ return i;
+ }
+ }
+
+ return -1;
+ },
+
+ /**
+ * Generates an unique ID for the element if it does not already
+ * have one.
+ * @param el the element
+ * @return {string} the id of the element
+ */
+ generateId: function(el) {
+ var id = el.id;
+
+ if (!id) {
+ id = "yuievtautoid-" + counter;
+ ++counter;
+ el.id = id;
+ }
+
+ return id;
+ },
+
+
+ /**
+ * We want to be able to use getElementsByTagName as a collection
+ * to attach a group of events to. Unfortunately, different
+ * browsers return different types of collections. This function
+ * tests to determine if the object is array-like. It will also
+ * fail if the object is an array, but is empty.
+ * @param o the object to test
+ * @return {boolean} true if the object is array-like and populated
+ * @private
+ */
+ _isValidCollection: function(o) {
+ // this.logger.debug(o.constructor.toString())
+ // this.logger.debug(typeof o)
+
+ return ( o && // o is something
+ o.length && // o is indexed
+ typeof o != "string" && // o is not a string
+ !o.tagName && // o is not an HTML element
+ !o.alert && // o is not a window
+ typeof o[0] != "undefined" );
+
+ },
+
+ /**
+ * @private
+ * DOM element cache
+ */
+ elCache: {},
+
+ /**
+ * We cache elements bound by id because when the unload event
+ * fires, we can no longer use document.getElementById
+ * @private
+ */
+ getEl: function(id) {
+ return document.getElementById(id);
+ },
+
+ /**
+ * Clears the element cache
+ * @deprecated
+ * @private
+ */
+ clearCache: function() { },
+
+ /**
+ * Called by CustomEvent instances to provide a handle to the
+ * event * that can be removed later on. Should be package
+ * protected.
+ * @private
+ */
+ regCE: function(ce) {
+ customEvents.push(ce);
+ },
+
+ /**
+ * @private
+ * hook up any deferred listeners
+ */
+ _load: function(e) {
+ // me.logger = new ygLogger("pe.Event");
+ //me.logger.debug([this.isSafari, this.isOpera, this.isIE]);
+ loadComplete = true;
+ },
+
+ /**
+ * Polling function that runs before the onload event fires,
+ * attempting to attach to DOM Nodes as soon as they are
+ * available
+ * @private
+ */
+ _tryPreloadAttach: function() {
+
+ if (this.locked) {
+ return false;
+ }
+
+ this.locked = true;
+
+ // this.logger.debug("tryPreloadAttach");
+
+ // keep trying until after the page is loaded. We need to
+ // check the page load state prior to trying to bind the
+ // elements so that we can be certain all elements have been
+ // tested appropriately
+ var tryAgain = !loadComplete;
+ if (!tryAgain) {
+ tryAgain = (retryCount > 0);
+ }
+
+ // Delayed listeners
+ var stillDelayed = [];
+
+ for (var i=0,len=delayedListeners.length; i<len; ++i) {
+ var d = delayedListeners[i];
+ // There may be a race condition here, so we need to
+ // verify the array element is usable.
+ if (d) {
+
+ // el will be null if document.getElementById did not
+ // work
+ var el = this.getEl(d[this.EL]);
+
+ if (el) {
+ // this.logger.debug("attaching: " + d[this.EL]);
+ this.on(el, d[this.TYPE], d[this.FN],
+ d[this.SCOPE], d[this.ADJ_SCOPE]);
+ delete delayedListeners[i];
+ } else {
+ stillDelayed.push(d);
+ }
+ }
+ }
+
+ delayedListeners = stillDelayed;
+
+ // onAvailable
+ var notAvail = [];
+ for (i=0,len=onAvailStack.length; i<len ; ++i) {
+ var item = onAvailStack[i];
+ if (item) {
+ el = this.getEl(item.id);
+
+ if (el) {
+ var scope = (item.override) ? item.obj : el;
+ item.fn.call(scope, item.obj);
+ delete onAvailStack[i];
+ } else {
+ notAvail.push(item);
+ }
+ }
+ }
+
+ retryCount = (stillDelayed.length === 0 &&
+ notAvail.length === 0) ? 0 : retryCount - 1;
+
+ if (tryAgain) {
+ this.startTimeout();
+ }
+
+ this.locked = false;
+
+ return true;
+
+ },
+
+ /**
+ * Removes all listeners attached to the given element via addListener.
+ * Optionally, the node's children can also be purged.
+ * Optionally, you can specify a specific type of event to remove.
+ * @param {HTMLElement} el the element to purge
+ * @param {boolean} recurse recursively purge this element's children
+ * as well. Use with caution.
+ * @param {string} sType optional type of listener to purge. If
+ * left out, all listeners will be removed
+ */
+ purgeElement: function(el, recurse, sType) {
+ var elListeners = this.getListeners(el, sType);
+ if (elListeners) {
+ for (var i=0,len=elListeners.length; i<len ; ++i) {
+ var l = elListeners[i];
+ this.removeListener(el, l.type, l.fn, l.index);
+ }
+ }
+
+ if (recurse && el && el.childNodes) {
+ for (i=0,len=el.childNodes.length; i<len ; ++i) {
+ this.purgeElement(el.childNodes[i], recurse, sType);
+ }
+ }
+ },
+
+ /**
+ * Returns all listeners attached to the given element via addListener.
+ * Optionally, you can specify a specific type of event to return.
+ * @param el {HTMLElement} the element to inspect
+ * @param sType {string} optional type of listener to return. If
+ * left out, all listeners will be returned
+ * @return {Object} the listener. Contains the following fields:
+ * type: (string) the type of event
+ * fn: (function) the callback supplied to addListener
+ * obj: (object) the custom object supplied to addListener
+ * adjust: (boolean) whether or not to adjust the default scope
+ * index: (int) its position in the Event util listener cache
+ */
+ getListeners: function(el, sType) {
+ var elListeners = [];
+ if (listeners && listeners.length > 0) {
+ for (var i=0,len=listeners.length; i<len ; ++i) {
+ var l = listeners[i];
+ if ( l && l[this.EL] === el &&
+ (!sType || sType === l[this.TYPE]) ) {
+ elListeners.push({
+ type: l[this.TYPE],
+ fn: l[this.FN],
+ obj: l[this.SCOPE],
+ adjust: l[this.ADJ_SCOPE],
+ index: i
+ });
+ }
+ }
+ }
+
+ return (elListeners.length) ? elListeners : null;
+ },
+
+ /**
+ * Removes all listeners registered by pe.event. Called
+ * automatically during the unload event.
+ * @private
+ */
+ _unload: function(e, me) {
+ for (var i=0,len=unloadListeners.length; i<len; ++i) {
+ var l = unloadListeners[i];
+ if (l) {
+ var scope = (l[this.ADJ_SCOPE]) ? l[this.SCOPE]: window;
+ l[this.FN].call(scope, this.getEvent(e), l[this.SCOPE] );
+ }
+ }
+
+ if (listeners && listeners.length > 0) {
+ for (i=0,len=listeners.length; i<len ; ++i) {
+ l = listeners[i];
+ if (l) {
+ this.removeListener(l[this.EL], l[this.TYPE],
+ l[this.FN], i);
+ }
+ }
+
+ this.clearCache();
+ }
+
+ for (i=0,len=customEvents.length; i<len; ++i) {
+ customEvents[i].unsubscribeAll();
+ delete customEvents[i];
+ }
+
+ for (i=0,len=legacyEvents.length; i<len; ++i) {
+ // dereference the element
+ delete legacyEvents[i][0];
+ // delete the array item
+ delete legacyEvents[i];
+ }
+ },
+
+ /**
+ * Returns scrollLeft
+ * @private
+ */
+ _getScrollLeft: function() {
+ return this._getScroll()[1];
+ },
+
+ /**
+ * Returns scrollTop
+ * @private
+ */
+ _getScrollTop: function() {
+ return this._getScroll()[0];
+ },
+
+ /**
+ * Returns the scrollTop and scrollLeft. Used to calculate the
+ * pageX and pageY in Internet Explorer
+ * @private
+ */
+ _getScroll: function() {
+ var dd = document.documentElement; db = document.body;
+ if (dd && dd.scrollTop) {
+ return [dd.scrollTop, dd.scrollLeft];
+ } else if (db) {
+ return [db.scrollTop, db.scrollLeft];
+ } else {
+ return [0, 0];
+ }
+ }
+ };
+ } ();
+
+ /**
+ * @private
+ */
+ YAHOO.util.Event.on = YAHOO.util.Event.addListener;
+
+ if (document && document.body) {
+ YAHOO.util.Event._load();
+ } else {
+ YAHOO.util.Event.on(window, "load", YAHOO.util.Event._load,
+ YAHOO.util.Event, true);
+ }
+
+ YAHOO.util.Event.on(window, "unload", YAHOO.util.Event._unload,
+ YAHOO.util.Event, true);
+
+ YAHOO.util.Event._tryPreloadAttach();
+
+}
+
Added: branches/tomek/portal-dnd/dndRenderer.war/js/event/event-min.js
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/event/event-min.js 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/event/event-min.js 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1 @@
+/* Copyright (c) 2006, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.net/yui/license.txt version: 0.11.0 */ YAHOO.util.CustomEvent=function(_1,_2,_3){this.type=_1;this.scope=_2||window;this.silent=_3;this.subscribers=[];if(YAHOO.util.Event){YAHOO.util.Event.regCE(this);}if(!this.silent){}};YAHOO.util.CustomEvent.prototype={subscrib!
e:function(fn,_5,_6){this.subscribers.push(new YAHOO.util.Subscriber(fn,_5,_6));},unsubscribe:function(fn,_7){var _8=false;for(var i=0,len=this.subscribers.length;i<len;++i){var s=this.subscribers[i];if(s&&s.contains(fn,_7)){this._delete(i);_8=true;}}return _8;},fire:function(){var len=this.subscribers.length;var _12=[];for(var i=0;i<arguments.length;++i){_12.push(arguments[i]);}if(!this.silent){}for(i=0;i<len;++i){var s=this.subscribers[i];if(s){if(!this.silent){}var _13=(s.override)?s.obj:this.scope;s.fn.call(_13,this.type,_12,s.obj);}}},unsubscribeAll:function(){for(var i=0,len=this.subscribers.length;i<len;++i){this._delete(i);}},_delete:function(_14){var s=this.subscribers[_14];if(s){delete s.fn;delete s.obj;}delete this.subscribers[_14];},toString:function(){return "CustomEvent: "+"'"+this.type+"', "+"scope: "+this.scope;}};YAHOO.util.Subscriber=function(fn,obj,_16){this.fn=fn;this.obj=obj||null;this.override=(_16);};YAHOO.util.Subscriber.prototype.contains=function(f!
n,obj){return (this.fn==fn&&this.obj==obj);};YAHOO.util.Subscriber.pro
totype.toString=function(){return "Subscriber { obj: "+(this.obj||"")+", override: "+(this.override||"no")+" }";};if(!YAHOO.util.Event){YAHOO.util.Event=function(){var _17=false;var _18=[];var _19=[];var _20=[];var _21=[];var _22=[];var _23=[];var _24=0;var _25=[];var _26=[];var _27=0;return {POLL_RETRYS:200,POLL_INTERVAL:50,EL:0,TYPE:1,FN:2,WFN:3,SCOPE:3,ADJ_SCOPE:4,isSafari:(/Safari|Konqueror|KHTML/gi).test(navigator.userAgent),isIE:(!this.isSafari&&!navigator.userAgent.match(/opera/gi)&&navigator.userAgent.match(/msie/gi)),addDelayedListener:function(el,_29,fn,_30,_31){_19[_19.length]=[el,_29,fn,_30,_31];if(_17){_24=this.POLL_RETRYS;this.startTimeout(0);}},startTimeout:function(_32){var i=(_32||_32===0)?_32:this.POLL_INTERVAL;var _33=this;var _34=function(){_33._tryPreloadAttach();};this.timeout=setTimeout(_34,i);},onAvailable:function(_35,_36,_37,_38){_25.push({id:_35,fn:_36,obj:_37,override:_38});_24=this.POLL_RETRYS;this.startTimeout(0);},addListener:function(el,_39,fn!
,_40,_41){if(!fn||!fn.call){return false;}if(this._isValidCollection(el)){var ok=true;for(var i=0,len=el.length;i<len;++i){ok=(this.on(el[i],_39,fn,_40,_41)&&ok);}return ok;}else{if(typeof el=="string"){var oEl=this.getEl(el);if(_17&&oEl){el=oEl;}else{this.addDelayedListener(el,_39,fn,_40,_41);return true;}}}if(!el){return false;}if("unload"==_39&&_40!==this){_20[_20.length]=[el,_39,fn,_40,_41];return true;}var _44=(_41)?_40:el;var _45=function(e){return fn.call(_44,YAHOO.util.Event.getEvent(e),_40);};var li=[el,_39,fn,_45,_44];var _48=_18.length;_18[_48]=li;if(this.useLegacyEvent(el,_39)){var _49=this.getLegacyIndex(el,_39);if(_49==-1){_49=_22.length;_26[el.id+_39]=_49;_22[_49]=[el,_39,el["on"+_39]];_23[_49]=[];el["on"+_39]=function(e){YAHOO.util.Event.fireLegacyEvent(YAHOO.util.Event.getEvent(e),_49);};}_23[_49].push(_48);}else{if(el.addEventListener){el.addEventListener(_39,_45,false);}else{if(el.attachEvent){el.attachEvent("on"+_39,_45);}}}return true;},fireLegacyEvent:!
function(e,_50){var ok=true;var le=_23[_50];for(var i=0,len=le.length;
i<len;++i){var _52=le[i];if(_52){var li=_18[_52];if(li&&li[this.WFN]){var _53=li[this.ADJ_SCOPE];var ret=li[this.WFN].call(_53,e);ok=(ok&&ret);}else{delete le[i];}}}return ok;},getLegacyIndex:function(el,_55){var key=this.generateId(el)+_55;if(typeof _26[key]=="undefined"){return -1;}else{return _26[key];}},useLegacyEvent:function(el,_57){if(!el.addEventListener&&!el.attachEvent){return true;}else{if(this.isSafari){if("click"==_57||"dblclick"==_57){return true;}}}return false;},removeListener:function(el,_58,fn,_59){if(!fn||!fn.call){return false;}if(typeof el=="string"){el=this.getEl(el);}else{if(this._isValidCollection(el)){var ok=true;for(var i=0,len=el.length;i<len;++i){ok=(this.removeListener(el[i],_58,fn)&&ok);}return ok;}}if("unload"==_58){for(i=0,len=_20.length;i<len;i++){var li=_20[i];if(li&&li[0]==el&&li[1]==_58&&li[2]==fn){delete _20[i];return true;}}return false;}var _60=null;if("undefined"==typeof _59){_59=this._getCacheIndex(el,_58,fn);}if(_59>=0){_60=_18[_59];!
}if(!el||!_60){return false;}if(el.removeEventListener){el.removeEventListener(_58,_60[this.WFN],false);}else{if(el.detachEvent){el.detachEvent("on"+_58,_60[this.WFN]);}}delete _18[_59][this.WFN];delete _18[_59][this.FN];delete _18[_59];return true;},getTarget:function(ev,_62){var t=ev.target||ev.srcElement;return this.resolveTextNode(t);},resolveTextNode:function(_64){if(_64&&_64.nodeName&&"#TEXT"==_64.nodeName.toUpperCase()){return _64.parentNode;}else{return _64;}},getPageX:function(ev){var x=ev.pageX;if(!x&&0!==x){x=ev.clientX||0;if(this.isIE){x+=this._getScrollLeft();}}return x;},getPageY:function(ev){var y=ev.pageY;if(!y&&0!==y){y=ev.clientY||0;if(this.isIE){y+=this._getScrollTop();}}return y;},getXY:function(ev){return [this.getPageX(ev),this.getPageY(ev)];},getRelatedTarget:function(ev){var t=ev.relatedTarget;if(!t){if(ev.type=="mouseout"){t=ev.toElement;}else{if(ev.type=="mouseover"){t=ev.fromElement;}}}return this.resolveTextNode(t);},getTime:function(ev){if(!ev.t!
ime){var t=new Date().getTime();try{ev.time=t;}catch(e){return t;}}ret
urn ev.time;},stopEvent:function(ev){this.stopPropagation(ev);this.preventDefault(ev);},stopPropagation:function(ev){if(ev.stopPropagation){ev.stopPropagation();}else{ev.cancelBubble=true;}},preventDefault:function(ev){if(ev.preventDefault){ev.preventDefault();}else{ev.returnValue=false;}},getEvent:function(e){var ev=e||window.event;if(!ev){var c=this.getEvent.caller;while(c){ev=c.arguments[0];if(ev&&Event==ev.constructor){break;}c=c.caller;}}return ev;},getCharCode:function(ev){return ev.charCode||((ev.type=="keypress")?ev.keyCode:0);},_getCacheIndex:function(el,_68,fn){for(var i=0,len=_18.length;i<len;++i){var li=_18[i];if(li&&li[this.FN]==fn&&li[this.EL]==el&&li[this.TYPE]==_68){return i;}}return -1;},generateId:function(el){var id=el.id;if(!id){id="yuievtautoid-"+_27;++_27;el.id=id;}return id;},_isValidCollection:function(o){return (o&&o.length&&typeof o!="string"&&!o.tagName&&!o.alert&&typeof o[0]!="undefined");},elCache:{},getEl:function(id){return document.getElementB!
yId(id);},clearCache:function(){},regCE:function(ce){_21.push(ce);},_load:function(e){_17=true;},_tryPreloadAttach:function(){if(this.locked){return false;}this.locked=true;var _72=!_17;if(!_72){_72=(_24>0);}var _73=[];for(var i=0,len=_19.length;i<len;++i){var d=_19[i];if(d){var el=this.getEl(d[this.EL]);if(el){this.on(el,d[this.TYPE],d[this.FN],d[this.SCOPE],d[this.ADJ_SCOPE]);delete _19[i];}else{_73.push(d);}}}_19=_73;var _75=[];for(i=0,len=_25.length;i<len;++i){var _76=_25[i];if(_76){el=this.getEl(_76.id);if(el){var _77=(_76.override)?_76.obj:el;_76.fn.call(_77,_76.obj);delete _25[i];}else{_75.push(_76);}}}_24=(_73.length===0&&_75.length===0)?0:_24-1;if(_72){this.startTimeout();}this.locked=false;return true;},purgeElement:function(el,_78,_79){var _80=this.getListeners(el,_79);if(_80){for(var i=0,len=_80.length;i<len;++i){var l=_80[i];this.removeListener(el,l.type,l.fn,l.index);}}if(_78&&el&&el.childNodes){for(i=0,len=el.childNodes.length;i<len;++i){this.purgeElement(el.!
childNodes[i],_78,_79);}}},getListeners:function(el,_82){var _83=[];if
(_18&&_18.length>0){for(var i=0,len=_18.length;i<len;++i){var l=_18[i];if(l&&l[this.EL]===el&&(!_82||_82===l[this.TYPE])){_83.push({type:l[this.TYPE],fn:l[this.FN],obj:l[this.SCOPE],adjust:l[this.ADJ_SCOPE],index:i});}}}return (_83.length)?_83:null;},_unload:function(e,me){for(var i=0,len=_20.length;i<len;++i){var l=_20[i];if(l){var _85=(l[this.ADJ_SCOPE])?l[this.SCOPE]:window;l[this.FN].call(_85,this.getEvent(e),l[this.SCOPE]);}}if(_18&&_18.length>0){for(i=0,len=_18.length;i<len;++i){l=_18[i];if(l){this.removeListener(l[this.EL],l[this.TYPE],l[this.FN],i);}}this.clearCache();}for(i=0,len=_21.length;i<len;++i){_21[i].unsubscribeAll();delete _21[i];}for(i=0,len=_22.length;i<len;++i){delete _22[i][0];delete _22[i];}},_getScrollLeft:function(){return this._getScroll()[1];},_getScrollTop:function(){return this._getScroll()[0];},_getScroll:function(){var dd=document.documentElement;db=document.body;if(dd&&dd.scrollTop){return [dd.scrollTop,dd.scrollLeft];}else{if(db){return [db.s!
crollTop,db.scrollLeft];}else{return [0,0];}}}};}();YAHOO.util.Event.on=YAHOO.util.Event.addListener;if(document&&document.body){YAHOO.util.Event._load();}else{YAHOO.util.Event.on(window,"load",YAHOO.util.Event._load,YAHOO.util.Event,true);}YAHOO.util.Event.on(window,"unload",YAHOO.util.Event._unload,YAHOO.util.Event,true);YAHOO.util.Event._tryPreloadAttach();}
\ No newline at end of file
Added: branches/tomek/portal-dnd/dndRenderer.war/js/event/event.js
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/event/event.js 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/event/event.js 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,1200 @@
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 0.11.0
+*/
+
+/**
+ * The CustomEvent class lets you define events for your application
+ * that can be subscribed to by one or more independent component.
+ *
+ * @param {String} type The type of event, which is passed to the callback
+ * when the event fires
+ * @param {Object} oScope The context the event will fire from. "this" will
+ * refer to this object in the callback. Default value:
+ * the window object. The listener can override this.
+ * @constructor
+ */
+YAHOO.util.CustomEvent = function(type, oScope, silent) {
+
+ /**
+ * The type of event, returned to subscribers when the event fires
+ * @type string
+ */
+ this.type = type;
+
+ /**
+ * The scope the the event will fire from by default. Defaults to the window
+ * obj
+ * @type object
+ */
+ this.scope = oScope || window;
+
+ /**
+ * By default all custom events are logged in the debug build, set silent
+ * to true to disable logging for this event.
+ * @type boolean
+ */
+ this.silent = silent;
+
+ /**
+ * The subscribers to this event
+ * @type Subscriber[]
+ */
+ this.subscribers = [];
+
+ // Register with the event utility for automatic cleanup. Made optional
+ // so that CustomEvent can be used independently of pe.event
+ if (YAHOO.util.Event) {
+ YAHOO.util.Event.regCE(this);
+ }
+
+ if (!this.silent) {
+ }
+};
+
+YAHOO.util.CustomEvent.prototype = {
+ /**
+ * Subscribes the caller to this event
+ * @param {Function} fn The function to execute
+ * @param {Object} obj An object to be passed along when the event fires
+ * @param {boolean} bOverride If true, the obj passed in becomes the execution
+ * scope of the listener
+ */
+ subscribe: function(fn, obj, bOverride) {
+ this.subscribers.push( new YAHOO.util.Subscriber(fn, obj, bOverride) );
+ },
+
+ /**
+ * Unsubscribes the caller from this event
+ * @param {Function} fn The function to execute
+ * @param {Object} obj An object to be passed along when the event fires
+ * @return {boolean} True if the subscriber was found and detached.
+ */
+ unsubscribe: function(fn, obj) {
+ var found = false;
+ for (var i=0, len=this.subscribers.length; i<len; ++i) {
+ var s = this.subscribers[i];
+ if (s && s.contains(fn, obj)) {
+ this._delete(i);
+ found = true;
+ }
+ }
+
+ return found;
+ },
+
+ /**
+ * Notifies the subscribers. The callback functions will be executed
+ * from the scope specified when the event was created, and with the following
+ * parameters:
+ * <pre>
+ * - The type of event
+ * - All of the arguments fire() was executed with as an array
+ * - The custom object (if any) that was passed into the subscribe() method
+ * </pre>
+ *
+ * @param {Array} an arbitrary set of parameters to pass to the handler
+ */
+ fire: function() {
+ var len=this.subscribers.length;
+
+ var args = [];
+
+ for (var i=0; i<arguments.length; ++i) {
+ args.push(arguments[i]);
+ }
+
+ if (!this.silent) {
+ }
+
+ for (i=0; i<len; ++i) {
+ var s = this.subscribers[i];
+ if (s) {
+ if (!this.silent) {
+ }
+ var scope = (s.override) ? s.obj : this.scope;
+ s.fn.call(scope, this.type, args, s.obj);
+ }
+ }
+ },
+
+ /**
+ * Removes all listeners
+ */
+ unsubscribeAll: function() {
+ for (var i=0, len=this.subscribers.length; i<len; ++i) {
+ this._delete(i);
+ }
+ },
+
+ /**
+ * @private
+ */
+ _delete: function(index) {
+ var s = this.subscribers[index];
+ if (s) {
+ delete s.fn;
+ delete s.obj;
+ }
+
+ delete this.subscribers[index];
+ },
+
+ toString: function() {
+ return "CustomEvent: " + "'" + this.type + "', " +
+ "scope: " + this.scope;
+
+ }
+};
+
+/////////////////////////////////////////////////////////////////////
+
+/**
+ * @class Stores the subscriber information to be used when the event fires.
+ * @param {Function} fn The function to execute
+ * @param {Object} obj An object to be passed along when the event fires
+ * @param {boolean} bOverride If true, the obj passed in becomes the execution
+ * scope of the listener
+ * @constructor
+ */
+YAHOO.util.Subscriber = function(fn, obj, bOverride) {
+ /**
+ * The callback that will be execute when the event fires
+ * @type function
+ */
+ this.fn = fn;
+
+ /**
+ * An optional custom object that will passed to the callback when
+ * the event fires
+ * @type object
+ */
+ this.obj = obj || null;
+
+ /**
+ * The default execution scope for the event listener is defined when the
+ * event is created (usually the object which contains the event).
+ * By setting override to true, the execution scope becomes the custom
+ * object passed in by the subscriber
+ * @type boolean
+ */
+ this.override = (bOverride);
+};
+
+/**
+ * Returns true if the fn and obj match this objects properties.
+ * Used by the unsubscribe method to match the right subscriber.
+ *
+ * @param {Function} fn the function to execute
+ * @param {Object} obj an object to be passed along when the event fires
+ * @return {boolean} true if the supplied arguments match this
+ * subscriber's signature.
+ */
+YAHOO.util.Subscriber.prototype.contains = function(fn, obj) {
+ return (this.fn == fn && this.obj == obj);
+};
+
+YAHOO.util.Subscriber.prototype.toString = function() {
+ return "Subscriber { obj: " + (this.obj || "") +
+ ", override: " + (this.override || "no") + " }";
+};
+// Only load this library once. If it is loaded a second time, existing
+// events cannot be detached.
+if (!YAHOO.util.Event) {
+
+/**
+ * @class
+ * The event utility provides functions to add and remove event listeners,
+ * event cleansing. It also tries to automatically remove listeners it
+ * registers during the unload event.
+ * @constructor
+ */
+ YAHOO.util.Event = function() {
+
+ /**
+ * True after the onload event has fired
+ * @type boolean
+ * @private
+ */
+ var loadComplete = false;
+
+ /**
+ * Cache of wrapped listeners
+ * @type array
+ * @private
+ */
+ var listeners = [];
+
+ /**
+ * Listeners that will be attached during the onload event
+ * @type array
+ * @private
+ */
+ var delayedListeners = [];
+
+ /**
+ * User-defined unload function that will be fired before all events
+ * are detached
+ * @type array
+ * @private
+ */
+ var unloadListeners = [];
+
+ /**
+ * Cache of the custom events that have been defined. Used for
+ * automatic cleanup
+ * @type array
+ * @private
+ */
+ var customEvents = [];
+
+ /**
+ * Cache of DOM0 event handlers to work around issues with DOM2 events
+ * in Safari
+ * @private
+ */
+ var legacyEvents = [];
+
+ /**
+ * Listener stack for DOM0 events
+ * @private
+ */
+ var legacyHandlers = [];
+
+ /**
+ * The number of times to poll after window.onload. This number is
+ * increased if additional late-bound handlers are requested after
+ * the page load.
+ * @private
+ */
+ var retryCount = 0;
+
+ /**
+ * onAvailable listeners
+ * @private
+ */
+ var onAvailStack = [];
+
+ /**
+ * Lookup table for legacy events
+ * @private
+ */
+ var legacyMap = [];
+
+ /**
+ * Counter for auto id generation
+ * @private
+ */
+ var counter = 0;
+
+ return { // PREPROCESS
+
+ /**
+ * The number of times we should look for elements that are not
+ * in the DOM at the time the event is requested after the document
+ * has been loaded. The default is 200 at 50 ms, so it will poll
+ * for 10 seconds or until all outstanding handlers are bound
+ * (whichever comes first).
+ * @type int
+ */
+ POLL_RETRYS: 200,
+
+ /**
+ * The poll interval in milliseconds
+ * @type int
+ */
+ POLL_INTERVAL: 50,
+
+ /**
+ * Element to bind, int constant
+ * @type int
+ */
+ EL: 0,
+
+ /**
+ * Type of event, int constant
+ * @type int
+ */
+ TYPE: 1,
+
+ /**
+ * Function to execute, int constant
+ * @type int
+ */
+ FN: 2,
+
+ /**
+ * Function wrapped for scope correction and cleanup, int constant
+ * @type int
+ */
+ WFN: 3,
+
+ /**
+ * Object passed in by the user that will be returned as a
+ * parameter to the callback, int constant
+ * @type int
+ */
+ SCOPE: 3,
+
+ /**
+ * Adjusted scope, either the element we are registering the event
+ * on or the custom object passed in by the listener, int constant
+ * @type int
+ */
+ ADJ_SCOPE: 4,
+
+ /**
+ * Safari detection is necessary to work around the preventDefault
+ * bug that makes it so you can't cancel a href click from the
+ * handler. There is not a capabilities check we can use here.
+ * @private
+ */
+ isSafari: (/Safari|Konqueror|KHTML/gi).test(navigator.userAgent),
+
+ /**
+ * IE detection needed to properly calculate pageX and pageY.
+ * capabilities checking didn't seem to work because another
+ * browser that does not provide the properties have the values
+ * calculated in a different manner than IE.
+ * @private
+ */
+ isIE: (!this.isSafari && !navigator.userAgent.match(/opera/gi) &&
+ navigator.userAgent.match(/msie/gi)),
+
+ /**
+ * @private
+ */
+ addDelayedListener: function(el, sType, fn, oScope, bOverride) {
+ delayedListeners[delayedListeners.length] =
+ [el, sType, fn, oScope, bOverride];
+
+ // If this happens after the inital page load, we need to
+ // reset the poll counter so that we continue to search for
+ // the element for a fixed period of time.
+ if (loadComplete) {
+ retryCount = this.POLL_RETRYS;
+ this.startTimeout(0);
+ // this._tryPreloadAttach();
+ }
+ },
+
+ /**
+ * @private
+ */
+ startTimeout: function(interval) {
+ var i = (interval || interval === 0) ? interval : this.POLL_INTERVAL;
+ var self = this;
+ var callback = function() { self._tryPreloadAttach(); };
+ this.timeout = setTimeout(callback, i);
+ },
+
+ /**
+ * Executes the supplied callback when the item with the supplied
+ * id is found. This is meant to be used to execute behavior as
+ * soon as possible as the page loads. If you use this after the
+ * initial page load it will poll for a fixed time for the element.
+ * The number of times it will poll and the frequency are
+ * configurable. By default it will poll for 10 seconds.
+ * @param {string} p_id the id of the element to look for.
+ * @param {function} p_fn what to execute when the element is found.
+ * @param {object} p_obj an optional object to be passed back as
+ * a parameter to p_fn.
+ * @param {boolean} p_override If set to true, p_fn will execute
+ * in the scope of p_obj
+ *
+ */
+ onAvailable: function(p_id, p_fn, p_obj, p_override) {
+ onAvailStack.push( { id: p_id,
+ fn: p_fn,
+ obj: p_obj,
+ override: p_override } );
+
+ retryCount = this.POLL_RETRYS;
+ this.startTimeout(0);
+ // this._tryPreloadAttach();
+ },
+
+ /**
+ * Appends an event handler
+ *
+ * @param {Object} el The html element to assign the
+ * event to
+ * @param {String} sType The type of event to append
+ * @param {Function} fn The method the event invokes
+ * @param {Object} oScope An arbitrary object that will be
+ * passed as a parameter to the handler
+ * @param {boolean} bOverride If true, the obj passed in becomes
+ * the execution scope of the listener
+ * @return {boolean} True if the action was successful or defered,
+ * false if one or more of the elements
+ * could not have the event bound to it.
+ */
+ addListener: function(el, sType, fn, oScope, bOverride) {
+
+ if (!fn || !fn.call) {
+ return false;
+ }
+
+ // The el argument can be an array of elements or element ids.
+ if ( this._isValidCollection(el)) {
+ var ok = true;
+ for (var i=0,len=el.length; i<len; ++i) {
+ ok = ( this.on(el[i],
+ sType,
+ fn,
+ oScope,
+ bOverride) && ok );
+ }
+ return ok;
+
+ } else if (typeof el == "string") {
+ var oEl = this.getEl(el);
+ // If the el argument is a string, we assume it is
+ // actually the id of the element. If the page is loaded
+ // we convert el to the actual element, otherwise we
+ // defer attaching the event until onload event fires
+
+ // check to see if we need to delay hooking up the event
+ // until after the page loads.
+ if (loadComplete && oEl) {
+ el = oEl;
+ } else {
+ // defer adding the event until onload fires
+ this.addDelayedListener(el,
+ sType,
+ fn,
+ oScope,
+ bOverride);
+
+ return true;
+ }
+ }
+
+ // Element should be an html element or an array if we get
+ // here.
+ if (!el) {
+ return false;
+ }
+
+ // we need to make sure we fire registered unload events
+ // prior to automatically unhooking them. So we hang on to
+ // these instead of attaching them to the window and fire the
+ // handles explicitly during our one unload event.
+ if ("unload" == sType && oScope !== this) {
+ unloadListeners[unloadListeners.length] =
+ [el, sType, fn, oScope, bOverride];
+ return true;
+ }
+
+ // if the user chooses to override the scope, we use the custom
+ // object passed in, otherwise the executing scope will be the
+ // HTML element that the event is registered on
+ var scope = (bOverride) ? oScope : el;
+
+ // wrap the function so we can return the oScope object when
+ // the event fires;
+ var wrappedFn = function(e) {
+ return fn.call(scope, YAHOO.util.Event.getEvent(e),
+ oScope);
+ };
+
+ var li = [el, sType, fn, wrappedFn, scope];
+ var index = listeners.length;
+ // cache the listener so we can try to automatically unload
+ listeners[index] = li;
+
+ if (this.useLegacyEvent(el, sType)) {
+ var legacyIndex = this.getLegacyIndex(el, sType);
+ if (legacyIndex == -1) {
+
+ legacyIndex = legacyEvents.length;
+ legacyMap[el.id + sType] = legacyIndex;
+
+ // cache the signature for the DOM0 event, and
+ // include the existing handler for the event, if any
+ legacyEvents[legacyIndex] =
+ [el, sType, el["on" + sType]];
+ legacyHandlers[legacyIndex] = [];
+
+ el["on" + sType] =
+ function(e) {
+ YAHOO.util.Event.fireLegacyEvent(
+ YAHOO.util.Event.getEvent(e), legacyIndex);
+ };
+ }
+
+ // add a reference to the wrapped listener to our custom
+ // stack of events
+ legacyHandlers[legacyIndex].push(index);
+
+ // DOM2 Event model
+ } else if (el.addEventListener) {
+ el.addEventListener(sType, wrappedFn, false);
+ // IE
+ } else if (el.attachEvent) {
+ el.attachEvent("on" + sType, wrappedFn);
+ }
+
+ return true;
+
+ },
+
+ /**
+ * Shorthand for YAHOO.util.Event.addListener
+ * @type function
+ */
+ // on: this.addListener,
+
+ /**
+ * When using legacy events, the handler is routed to this object
+ * so we can fire our custom listener stack.
+ * @private
+ */
+ fireLegacyEvent: function(e, legacyIndex) {
+ var ok = true;
+
+ var le = legacyHandlers[legacyIndex];
+ for (var i=0,len=le.length; i<len; ++i) {
+ var index = le[i];
+ if (index) {
+ var li = listeners[index];
+ if ( li && li[this.WFN] ) {
+ var scope = li[this.ADJ_SCOPE];
+ var ret = li[this.WFN].call(scope, e);
+ ok = (ok && ret);
+ } else {
+ // This listener was removed, so delete it from
+ // the array
+ delete le[i];
+ }
+ }
+ }
+
+ return ok;
+ },
+
+ /**
+ * Returns the legacy event index that matches the supplied
+ * signature
+ * @private
+ */
+ getLegacyIndex: function(el, sType) {
+ /*
+ for (var i=0,len=legacyEvents.length; i<len; ++i) {
+ var le = legacyEvents[i];
+ if (le && le[0] === el && le[1] === sType) {
+ return i;
+ }
+ }
+ return -1;
+ */
+
+ var key = this.generateId(el) + sType;
+ if (typeof legacyMap[key] == "undefined") {
+ return -1;
+ } else {
+ return legacyMap[key];
+ }
+
+ },
+
+ /**
+ * Logic that determines when we should automatically use legacy
+ * events instead of DOM2 events.
+ * @private
+ */
+ useLegacyEvent: function(el, sType) {
+
+ if (!el.addEventListener && !el.attachEvent) {
+ return true;
+ } else if (this.isSafari) {
+ if ("click" == sType || "dblclick" == sType) {
+ return true;
+ }
+ }
+
+ return false;
+ },
+
+ /**
+ * Removes an event handler
+ *
+ * @param {Object} el the html element or the id of the element to
+ * assign the event to.
+ * @param {String} sType the type of event to remove
+ * @param {Function} fn the method the event invokes
+ * @return {boolean} true if the unbind was successful, false
+ * otherwise
+ */
+ removeListener: function(el, sType, fn, index) {
+
+ if (!fn || !fn.call) {
+ return false;
+ }
+
+ // The el argument can be a string
+ if (typeof el == "string") {
+ el = this.getEl(el);
+ // The el argument can be an array of elements or element ids.
+ } else if ( this._isValidCollection(el)) {
+ var ok = true;
+ for (var i=0,len=el.length; i<len; ++i) {
+ ok = ( this.removeListener(el[i], sType, fn) && ok );
+ }
+ return ok;
+ }
+
+ if ("unload" == sType) {
+
+ for (i=0, len=unloadListeners.length; i<len; i++) {
+ var li = unloadListeners[i];
+ if (li &&
+ li[0] == el &&
+ li[1] == sType &&
+ li[2] == fn) {
+ delete unloadListeners[i];
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ var cacheItem = null;
+
+ if ("undefined" == typeof index) {
+ index = this._getCacheIndex(el, sType, fn);
+ }
+
+ if (index >= 0) {
+ cacheItem = listeners[index];
+ }
+
+ if (!el || !cacheItem) {
+ return false;
+ }
+
+ if (el.removeEventListener) {
+ el.removeEventListener(sType, cacheItem[this.WFN], false);
+ } else if (el.detachEvent) {
+ el.detachEvent("on" + sType, cacheItem[this.WFN]);
+ }
+
+ // removed the wrapped handler
+ delete listeners[index][this.WFN];
+ delete listeners[index][this.FN];
+ delete listeners[index];
+
+ return true;
+
+ },
+
+ /**
+ * Returns the event's target element
+ * @param {Event} ev the event
+ * @param {boolean} resolveTextNode when set to true the target's
+ * parent will be returned if the target is a
+ * text node. @deprecated, the text node is
+ * now resolved automatically
+ * @return {HTMLElement} the event's target
+ */
+ getTarget: function(ev, resolveTextNode) {
+ var t = ev.target || ev.srcElement;
+ return this.resolveTextNode(t);
+ },
+
+ /**
+ * In some cases, some browsers will return a text node inside
+ * the actual element that was targeted. This normalizes the
+ * return value for getTarget and getRelatedTarget.
+ * @param {HTMLElement} node to resolve
+ * @return the normized node
+ */
+ resolveTextNode: function(node) {
+ if (node && node.nodeName &&
+ "#TEXT" == node.nodeName.toUpperCase()) {
+ return node.parentNode;
+ } else {
+ return node;
+ }
+ },
+
+ /**
+ * Returns the event's pageX
+ * @param {Event} ev the event
+ * @return {int} the event's pageX
+ */
+ getPageX: function(ev) {
+ var x = ev.pageX;
+ if (!x && 0 !== x) {
+ x = ev.clientX || 0;
+
+ if ( this.isIE ) {
+ x += this._getScrollLeft();
+ }
+ }
+
+ return x;
+ },
+
+ /**
+ * Returns the event's pageY
+ * @param {Event} ev the event
+ * @return {int} the event's pageY
+ */
+ getPageY: function(ev) {
+ var y = ev.pageY;
+ if (!y && 0 !== y) {
+ y = ev.clientY || 0;
+
+ if ( this.isIE ) {
+ y += this._getScrollTop();
+ }
+ }
+
+ return y;
+ },
+
+ /**
+ * Returns the pageX and pageY properties as an indexed array.
+ * @type int[]
+ */
+ getXY: function(ev) {
+ return [this.getPageX(ev), this.getPageY(ev)];
+ },
+
+ /**
+ * Returns the event's related target
+ * @param {Event} ev the event
+ * @return {HTMLElement} the event's relatedTarget
+ */
+ getRelatedTarget: function(ev) {
+ var t = ev.relatedTarget;
+ if (!t) {
+ if (ev.type == "mouseout") {
+ t = ev.toElement;
+ } else if (ev.type == "mouseover") {
+ t = ev.fromElement;
+ }
+ }
+
+ return this.resolveTextNode(t);
+ },
+
+ /**
+ * Returns the time of the event. If the time is not included, the
+ * event is modified using the current time.
+ * @param {Event} ev the event
+ * @return {Date} the time of the event
+ */
+ getTime: function(ev) {
+ if (!ev.time) {
+ var t = new Date().getTime();
+ try {
+ ev.time = t;
+ } catch(e) {
+ // can't set the time property
+ return t;
+ }
+ }
+
+ return ev.time;
+ },
+
+ /**
+ * Convenience method for stopPropagation + preventDefault
+ * @param {Event} ev the event
+ */
+ stopEvent: function(ev) {
+ this.stopPropagation(ev);
+ this.preventDefault(ev);
+ },
+
+ /**
+ * Stops event propagation
+ * @param {Event} ev the event
+ */
+ stopPropagation: function(ev) {
+ if (ev.stopPropagation) {
+ ev.stopPropagation();
+ } else {
+ ev.cancelBubble = true;
+ }
+ },
+
+ /**
+ * Prevents the default behavior of the event
+ * @param {Event} ev the event
+ */
+ preventDefault: function(ev) {
+ if (ev.preventDefault) {
+ ev.preventDefault();
+ } else {
+ ev.returnValue = false;
+ }
+ },
+
+ /**
+ * Finds the event in the window object, the caller's arguments, or
+ * in the arguments of another method in the callstack. This is
+ * executed automatically for events registered through the event
+ * manager, so the implementer should not normally need to execute
+ * this function at all.
+ * @param {Event} the event parameter from the handler
+ * @return {Event} the event
+ */
+ getEvent: function(e) {
+ var ev = e || window.event;
+
+ if (!ev) {
+ var c = this.getEvent.caller;
+ while (c) {
+ ev = c.arguments[0];
+ if (ev && Event == ev.constructor) {
+ break;
+ }
+ c = c.caller;
+ }
+ }
+
+ return ev;
+ },
+
+ /**
+ * Returns the charcode for an event
+ * @param {Event} ev the event
+ * @return {int} the event's charCode
+ */
+ getCharCode: function(ev) {
+ return ev.charCode || ((ev.type == "keypress") ? ev.keyCode : 0);
+ },
+
+ /**
+ * @private
+ * Locating the saved event handler data by function ref
+ */
+ _getCacheIndex: function(el, sType, fn) {
+ for (var i=0,len=listeners.length; i<len; ++i) {
+ var li = listeners[i];
+ if ( li &&
+ li[this.FN] == fn &&
+ li[this.EL] == el &&
+ li[this.TYPE] == sType ) {
+ return i;
+ }
+ }
+
+ return -1;
+ },
+
+ /**
+ * Generates an unique ID for the element if it does not already
+ * have one.
+ * @param el the element
+ * @return {string} the id of the element
+ */
+ generateId: function(el) {
+ var id = el.id;
+
+ if (!id) {
+ id = "yuievtautoid-" + counter;
+ ++counter;
+ el.id = id;
+ }
+
+ return id;
+ },
+
+ /**
+ * We want to be able to use getElementsByTagName as a collection
+ * to attach a group of events to. Unfortunately, different
+ * browsers return different types of collections. This function
+ * tests to determine if the object is array-like. It will also
+ * fail if the object is an array, but is empty.
+ * @param o the object to test
+ * @return {boolean} true if the object is array-like and populated
+ * @private
+ */
+ _isValidCollection: function(o) {
+
+ return ( o && // o is something
+ o.length && // o is indexed
+ typeof o != "string" && // o is not a string
+ !o.tagName && // o is not an HTML element
+ !o.alert && // o is not a window
+ typeof o[0] != "undefined" );
+
+ },
+
+ /**
+ * @private
+ * DOM element cache
+ */
+ elCache: {},
+
+ /**
+ * We cache elements bound by id because when the unload event
+ * fires, we can no longer use document.getElementById
+ * @private
+ */
+ getEl: function(id) {
+ return document.getElementById(id);
+ },
+
+ /**
+ * Clears the element cache
+ * @deprecated
+ * @private
+ */
+ clearCache: function() { },
+
+ /**
+ * Called by CustomEvent instances to provide a handle to the
+ * event * that can be removed later on. Should be package
+ * protected.
+ * @private
+ */
+ regCE: function(ce) {
+ customEvents.push(ce);
+ },
+
+ /**
+ * @private
+ * hook up any deferred listeners
+ */
+ _load: function(e) {
+ loadComplete = true;
+ },
+
+ /**
+ * Polling function that runs before the onload event fires,
+ * attempting to attach to DOM Nodes as soon as they are
+ * available
+ * @private
+ */
+ _tryPreloadAttach: function() {
+
+ if (this.locked) {
+ return false;
+ }
+
+ this.locked = true;
+
+ // keep trying until after the page is loaded. We need to
+ // check the page load state prior to trying to bind the
+ // elements so that we can be certain all elements have been
+ // tested appropriately
+ var tryAgain = !loadComplete;
+ if (!tryAgain) {
+ tryAgain = (retryCount > 0);
+ }
+
+ // Delayed listeners
+ var stillDelayed = [];
+
+ for (var i=0,len=delayedListeners.length; i<len; ++i) {
+ var d = delayedListeners[i];
+ // There may be a race condition here, so we need to
+ // verify the array element is usable.
+ if (d) {
+
+ // el will be null if document.getElementById did not
+ // work
+ var el = this.getEl(d[this.EL]);
+
+ if (el) {
+ this.on(el, d[this.TYPE], d[this.FN],
+ d[this.SCOPE], d[this.ADJ_SCOPE]);
+ delete delayedListeners[i];
+ } else {
+ stillDelayed.push(d);
+ }
+ }
+ }
+
+ delayedListeners = stillDelayed;
+
+ // onAvailable
+ var notAvail = [];
+ for (i=0,len=onAvailStack.length; i<len ; ++i) {
+ var item = onAvailStack[i];
+ if (item) {
+ el = this.getEl(item.id);
+
+ if (el) {
+ var scope = (item.override) ? item.obj : el;
+ item.fn.call(scope, item.obj);
+ delete onAvailStack[i];
+ } else {
+ notAvail.push(item);
+ }
+ }
+ }
+
+ retryCount = (stillDelayed.length === 0 &&
+ notAvail.length === 0) ? 0 : retryCount - 1;
+
+ if (tryAgain) {
+ this.startTimeout();
+ }
+
+ this.locked = false;
+
+ return true;
+
+ },
+
+ /**
+ * Removes all listeners attached to the given element via addListener.
+ * Optionally, the node's children can also be purged.
+ * Optionally, you can specify a specific type of event to remove.
+ * @param {HTMLElement} el the element to purge
+ * @param {boolean} recurse recursively purge this element's children
+ * as well. Use with caution.
+ * @param {string} sType optional type of listener to purge. If
+ * left out, all listeners will be removed
+ */
+ purgeElement: function(el, recurse, sType) {
+ var elListeners = this.getListeners(el, sType);
+ if (elListeners) {
+ for (var i=0,len=elListeners.length; i<len ; ++i) {
+ var l = elListeners[i];
+ this.removeListener(el, l.type, l.fn, l.index);
+ }
+ }
+
+ if (recurse && el && el.childNodes) {
+ for (i=0,len=el.childNodes.length; i<len ; ++i) {
+ this.purgeElement(el.childNodes[i], recurse, sType);
+ }
+ }
+ },
+
+ /**
+ * Returns all listeners attached to the given element via addListener.
+ * Optionally, you can specify a specific type of event to return.
+ * @param el {HTMLElement} the element to inspect
+ * @param sType {string} optional type of listener to return. If
+ * left out, all listeners will be returned
+ * @return {Object} the listener. Contains the following fields:
+ * type: (string) the type of event
+ * fn: (function) the callback supplied to addListener
+ * obj: (object) the custom object supplied to addListener
+ * adjust: (boolean) whether or not to adjust the default scope
+ * index: (int) its position in the Event util listener cache
+ */
+ getListeners: function(el, sType) {
+ var elListeners = [];
+ if (listeners && listeners.length > 0) {
+ for (var i=0,len=listeners.length; i<len ; ++i) {
+ var l = listeners[i];
+ if ( l && l[this.EL] === el &&
+ (!sType || sType === l[this.TYPE]) ) {
+ elListeners.push({
+ type: l[this.TYPE],
+ fn: l[this.FN],
+ obj: l[this.SCOPE],
+ adjust: l[this.ADJ_SCOPE],
+ index: i
+ });
+ }
+ }
+ }
+
+ return (elListeners.length) ? elListeners : null;
+ },
+
+ /**
+ * Removes all listeners registered by pe.event. Called
+ * automatically during the unload event.
+ * @private
+ */
+ _unload: function(e, me) {
+ for (var i=0,len=unloadListeners.length; i<len; ++i) {
+ var l = unloadListeners[i];
+ if (l) {
+ var scope = (l[this.ADJ_SCOPE]) ? l[this.SCOPE]: window;
+ l[this.FN].call(scope, this.getEvent(e), l[this.SCOPE] );
+ }
+ }
+
+ if (listeners && listeners.length > 0) {
+ for (i=0,len=listeners.length; i<len ; ++i) {
+ l = listeners[i];
+ if (l) {
+ this.removeListener(l[this.EL], l[this.TYPE],
+ l[this.FN], i);
+ }
+ }
+
+ this.clearCache();
+ }
+
+ for (i=0,len=customEvents.length; i<len; ++i) {
+ customEvents[i].unsubscribeAll();
+ delete customEvents[i];
+ }
+
+ for (i=0,len=legacyEvents.length; i<len; ++i) {
+ // dereference the element
+ delete legacyEvents[i][0];
+ // delete the array item
+ delete legacyEvents[i];
+ }
+ },
+
+ /**
+ * Returns scrollLeft
+ * @private
+ */
+ _getScrollLeft: function() {
+ return this._getScroll()[1];
+ },
+
+ /**
+ * Returns scrollTop
+ * @private
+ */
+ _getScrollTop: function() {
+ return this._getScroll()[0];
+ },
+
+ /**
+ * Returns the scrollTop and scrollLeft. Used to calculate the
+ * pageX and pageY in Internet Explorer
+ * @private
+ */
+ _getScroll: function() {
+ var dd = document.documentElement; db = document.body;
+ if (dd && dd.scrollTop) {
+ return [dd.scrollTop, dd.scrollLeft];
+ } else if (db) {
+ return [db.scrollTop, db.scrollLeft];
+ } else {
+ return [0, 0];
+ }
+ }
+ };
+ } ();
+
+ /**
+ * @private
+ */
+ YAHOO.util.Event.on = YAHOO.util.Event.addListener;
+
+ if (document && document.body) {
+ YAHOO.util.Event._load();
+ } else {
+ YAHOO.util.Event.on(window, "load", YAHOO.util.Event._load,
+ YAHOO.util.Event, true);
+ }
+
+ YAHOO.util.Event.on(window, "unload", YAHOO.util.Event._unload,
+ YAHOO.util.Event, true);
+
+ YAHOO.util.Event._tryPreloadAttach();
+
+}
+
Added: branches/tomek/portal-dnd/dndRenderer.war/js/fonts/README
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/fonts/README 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/fonts/README 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,9 @@
+CSS Fonts Release Notes
+
+*** version 0.11.0 ***
+
+* No changes.
+
+*** version 0.10.0 ***
+
+* Initial release.
Added: branches/tomek/portal-dnd/dndRenderer.war/js/fonts/fonts-min.css
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/fonts/fonts-min.css 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/fonts/fonts-min.css 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,7 @@
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 0.11.0
+*/
+body {font:13px arial,helvetica,clean,sans-serif;*font-size:small;*font:x-small;}table {font-size:inherit;font:100%;}select, input, textarea {font:99% arial,helvetica,clean,sans-serif;}pre, code {font:115% monospace;*font-size:100%;}body * {line-height:1.22em;}
Added: branches/tomek/portal-dnd/dndRenderer.war/js/fonts/fonts.css
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/fonts/fonts.css 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/fonts/fonts.css 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,31 @@
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 0.11.0
+*/
+
+/**
+ * 84.5% for !IE, keywords for IE
+ * Percents could work for IE, but for backCompat purposes, we are using keywords.
+ * x-small is for IE < 6 and IE6 quirks mode.
+ *
+ */
+body {font:13px arial,helvetica,clean,sans-serif;*font-size:small;*font:x-small;}
+table {font-size:inherit;font:100%;}
+
+/**
+ * 99% for safari; 100% is too large
+ */
+select, input, textarea {font:99% arial,helvetica,clean,sans-serif;}
+
+/**
+ * Bump up !IE to get to 13px equivalent
+ */
+pre, code {font:115% monospace;*font-size:100%;}
+
+/**
+ * Default line-height based on font-size rather than "computed-value"
+ * see: http://www.w3.org/TR/CSS21/visudet.html#line-height
+ */
+body * {line-height:1.22em;}
Added: branches/tomek/portal-dnd/dndRenderer.war/js/grids/README
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/grids/README 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/grids/README 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,10 @@
+CSS Grids Release Notes
+
+*** version 0.11.0 ***
+
+* Removed line #43 because it set an already-set value.
+ Was: ".yui-t7 #main .yui-b{min-width:750px;}"
+
+*** version 0.10.0 ***
+
+* Initial release.
\ No newline at end of file
Added: branches/tomek/portal-dnd/dndRenderer.war/js/grids/grids-min.css
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/grids/grids-min.css 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/grids/grids-min.css 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,7 @@
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 0.11.0
+*/
+body{text-align:center;}#doc{width:57.69em;*width:56.3em;min-width:750px;margin:auto;text-align:left;}#hd,#bd{margin-bottom:1em;text-align:left;}#ft{font-size:77%;font-family:verdana;clear:both;}.yui-t1 #yui-main .yui-b, .yui-t2 #yui-main .yui-b, .yui-t3 #yui-main .yui-b, .yui-t4 .yui-b, .yui-t5 .yui-b, .yui-t6 .yui-b{float:right;}.yui-t1 .yui-b, .yui-t2 .yui-b, .yui-t3 .yui-b, .yui-t4 #yui-main .yui-b, .yui-t5 #yui-main .yui-b, .yui-t6 #yui-main .yui-b{float:left;}.yui-t1 #yui-main .yui-b{width:76%;min-width:570px;}.yui-t1 .yui-b{width:21.33%;min-width:160px;}.yui-t2 #yui-main .yui-b, .yui-t4 #yui-main .yui-b{width:73.4%;min-width:550px;}.yui-t2 .yui-b, .yui-t4 .yui-b{width:24%;min-width:180px;}.yui-t3 #yui-main .yui-b, .yui-t6 #yui-main .yui-b{width:57.6%;min-width:430px;}.yui-t3 .yui-b, .yui-t6 .yui-b{width:40%;min-width:300px;}.yui-t5 #yui-main .yui-b{width:65.4%;min-width:490px;}.yui-t5 .yui-b{width:32%;min-width:240px;}.yui-g .yui-u, .yui-g .yui-g, .yui-ge .yui-u, .yu!
i-gf .yui-u{float:right;display:inline;}.yui-g .first, .yui-gd .first, .yui-ge .first, .yui-gf .first{float:left;}.yui-g .yui-u, .yui-g .yui-g{width:49.1%;}.yui-g .yui-g .yui-u{width:48.1%;}.yui-gb .yui-u, .yui-gc .yui-u, .yui-gd .yui-u{float:left;margin-left:2%;*margin-left:1.895%;width:32%;}.yui-gb .first, .yui-gc .first, .yui-gd .first{margin-left:0;}.yui-gc .first, .yui-gd .yui-u{width:66%;}.yui-gd .first{width:32%;}.yui-ge .yui-u{width:24%;}.yui-ge .first, .yui-gf .yui-u{width:74.2%;}.yui-gf .first{width:24%;}.yui-ge .first{width:74.2%;}#bd:after, .yui-g:after, .yui-gb:after, .yui-gc:after, .yui-gd:after, .yui-ge:after, .yui-gf:after{content:".";display:block;height:0;clear:both;visibility:hidden;}#bd, .yui-g, .yui-gb, .yui-gc, .yui-gd, .yui-ge, .yui-gf{zoom:1;}
\ No newline at end of file
Added: branches/tomek/portal-dnd/dndRenderer.war/js/grids/grids.css
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/grids/grids.css 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/grids/grids.css 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,82 @@
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 0.11.0
+*/
+body {
+ text-align:center;
+}
+
+#doc {
+ width:57.69em;
+ *width:56.3em; /* IE */
+ min-width:750px;
+ margin:auto;
+ text-align:left;
+}
+
+#hd,#bd {margin-bottom:1em;text-align:left;}
+#ft {font-size:77%;font-family:verdana;clear:both;}
+
+/* rules for main templates */
+.yui-t1 #yui-main .yui-b, .yui-t2 #yui-main .yui-b, .yui-t3 #yui-main .yui-b, .yui-t4 .yui-b, .yui-t5 .yui-b, .yui-t6 .yui-b {float:right;}
+.yui-t1 .yui-b, .yui-t2 .yui-b, .yui-t3 .yui-b, .yui-t4 #yui-main .yui-b, .yui-t5 #yui-main .yui-b, .yui-t6 #yui-main .yui-b {float:left;}
+
+/* t1: L160 */
+.yui-t1 #yui-main .yui-b {width:76%;min-width:570px;}
+.yui-t1 .yui-b {width:21.33%;min-width:160px;}
+
+/* t2 & t4: L180 & R180 */
+.yui-t2 #yui-main .yui-b, .yui-t4 #yui-main .yui-b {width:73.4%;min-width:550px;}
+.yui-t2 .yui-b, .yui-t4 .yui-b {width:24%;min-width:180px;}
+
+/* t3 & t6: L300 & R300 */
+.yui-t3 #yui-main .yui-b, .yui-t6 #yui-main .yui-b {width:57.6%;min-width:430px;}
+.yui-t3 .yui-b, .yui-t6 .yui-b {width:40%;min-width:300px;}
+
+/* t5: R240 */
+.yui-t5 #yui-main .yui-b {width:65.4%;min-width:490px;}
+.yui-t5 .yui-b {width:32%;min-width:240px;}
+
+/* t7: 750 */
+
+
+
+/* grid-generic rules for all templates */
+
+/* all modules and grids nested in a grid get floated */
+.yui-g .yui-u, .yui-g .yui-g, .yui-ge .yui-u, .yui-gf .yui-u {
+ float:right;
+ display:inline; /* IE */
+}
+
+/* float left and kill margin on first for added flex */
+.yui-g .first, .yui-gd .first, .yui-ge .first, .yui-gf .first {float:left; }
+
+/* 2 col */
+.yui-g .yui-u, .yui-g .yui-g {width:49.1%;}
+.yui-g .yui-g .yui-u {width:48.1%;} /* smaller for nested to preserve margins */
+
+/* 3 col */
+.yui-gb .yui-u, .yui-gc .yui-u, .yui-gd .yui-u {
+ float:left; /* need to reverse the order for 3 */
+ margin-left:2%; *margin-left:1.895%;
+ width:32%;
+}
+
+.yui-gb .first, .yui-gc .first, .yui-gd .first {margin-left:0;}
+
+/* colspan 2 */
+.yui-gc .first, .yui-gd .yui-u {width:66%;}
+.yui-gd .first {width:32%;}
+
+/* colspan 3 */
+.yui-ge .yui-u {width:24%;}
+.yui-ge .first, .yui-gf .yui-u {width:74.2%;}
+.yui-gf .first {width:24%;}
+.yui-ge .first {width:74.2%;}
+
+/* self clear floated parent containers */
+#bd:after, .yui-g:after, .yui-gb:after, .yui-gc:after, .yui-gd:after, .yui-ge:after, .yui-gf:after {content:".";display:block;height:0;clear:both;visibility:hidden;}
+#bd, .yui-g, .yui-gb, .yui-gc, .yui-gd, .yui-ge, .yui-gf {zoom:1;} /* IE */
\ No newline at end of file
Added: branches/tomek/portal-dnd/dndRenderer.war/js/logger/README
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/logger/README 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/logger/README 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,6 @@
+Logger Release Notes
+
+*** version 0.11.0 ***
+
+* Initial release
+
Added: branches/tomek/portal-dnd/dndRenderer.war/js/logger/assets/logger.css
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/logger/assets/logger.css 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/logger/assets/logger.css 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,20 @@
+/* logger default styles */
+/* font size is controlled here: default 77% */
+#yui-log {position:absolute;top:1em;right:1em;font-size:77%;text-align:left;}
+/* width is controlled here: default 31em */
+.yui-log {padding:1em;width:31em;background-color:#AAA;border:1px solid black;font-family:monospace;z-index:9000;}
+.yui-log p {margin:1px;padding:.1em;}
+.yui-log button {font-family:monospace;}
+.yui-log .yui-log-hd {margin-top:1em;padding:.5em;background-color:#575757;color:#FFF;}
+/* height is controlled here: default 20em*/
+.yui-log .yui-log-bd {width:100%;height:20em;background-color:#FFF;border:1px solid gray;overflow:auto;}
+.yui-log .yui-log-ft {margin-top:.5em;margin-bottom:1em;}
+.yui-log .yui-log-ft .yui-log-categoryfilters {}
+.yui-log .yui-log-ft .yui-log-sourcefilters {width:100%;border-top:1px solid #575757;margin-top:.75em;padding-top:.75em;}
+.yui-log .yui-log-btns {position:relative;float:right;bottom:.25em;}
+.yui-log .yui-log-filtergrp {margin-right:.5em;}
+.yui-log .info {background-color:#A7CC25;} /* A7CC25 green */
+.yui-log .warn {background-color:#F58516;} /* F58516 orange */
+.yui-log .error {background-color:#E32F0B;} /* E32F0B red */
+.yui-log .time {background-color:#A6C9D7;} /* A6C9D7 blue */
+.yui-log .window {background-color:#F2E886;} /* F2E886 tan */
Added: branches/tomek/portal-dnd/dndRenderer.war/js/logger/logger-debug.js
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/logger/logger-debug.js 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/logger/logger-debug.js 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,1186 @@
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 0.11.0
+*/
+
+/****************************************************************************/
+/****************************************************************************/
+/****************************************************************************/
+/**
+ * Singleton providing core logging functionality. Saves logs written through the
+ * global YAHOO.log function or written by LogWriter. Provides access to logs
+ * for reading by LogReader. Log messages are automatically output to Firebug,
+ * if present.
+ *
+ * requires YAHOO.util.Event Event utility
+ */
+YAHOO.widget.Logger = {
+ // Initialize members
+ loggerEnabled: true,
+ _firebugEnabled: true,
+ categories: ["info","warn","error","time","window"],
+ sources: ["global"],
+ _stack: [], // holds all log msgs
+ _startTime: new Date().getTime(), // static start timestamp
+ _lastTime: null // timestamp of last logged message
+};
+
+/***************************************************************************
+ * Events
+ ***************************************************************************/
+/**
+ * Fired when a new category has been created. Subscribers receive the following
+ * array:<br>
+ * - args[0] The category name
+ */
+YAHOO.widget.Logger.categoryCreateEvent = new YAHOO.util.CustomEvent("categoryCreate", this, true);
+
+/**
+ * Fired when a new source has been named. Subscribers receive the following
+ * array:<br>
+ * - args[0] The source name
+ */
+YAHOO.widget.Logger.sourceCreateEvent = new YAHOO.util.CustomEvent("sourceCreate", this, true);
+
+/**
+ * Fired when a new log message has been created. Subscribers receive the
+ * following array:<br>
+ * - args[0] The log message
+ */
+YAHOO.widget.Logger.newLogEvent = new YAHOO.util.CustomEvent("newLog", this, true);
+
+/**
+ * Fired when the Logger has been reset has been created.
+ */
+YAHOO.widget.Logger.logResetEvent = new YAHOO.util.CustomEvent("logReset", this, true);
+
+/***************************************************************************
+ * Public methods
+ ***************************************************************************/
+/**
+ * Saves a log message to the stack and fires newLogEvent. If the log message is
+ * assigned to an unknown category, creates a new category. If the log message is
+ * from an unknown source, creates a new source. If Firebug is enabled,
+ * outputs the log message to Firebug.
+ *
+ * @param {string} sMsg The log message
+ * @param {string} sCategory Category of log message, or null
+ * @param {string} sSource Source of LogWriter, or null if global
+ */
+YAHOO.widget.Logger.log = function(sMsg, sCategory, sSource) {
+ if(this.loggerEnabled) {
+ if(!sCategory) {
+ sCategory = "info"; // default category
+ }
+ else if(this._isNewCategory(sCategory)) {
+ this._createNewCategory(sCategory);
+ }
+ var sClass = "global"; // default source
+ var sDetail = null;
+ if(sSource) {
+ var spaceIndex = sSource.indexOf(" ");
+ if(spaceIndex > 0) {
+ sClass = sSource.substring(0,spaceIndex);// substring until first space
+ sDetail = sSource.substring(spaceIndex,sSource.length);// the rest of the source
+ }
+ else {
+ sClass = sSource;
+ }
+ if(this._isNewSource(sClass)) {
+ this._createNewSource(sClass);
+ }
+ }
+
+ var timestamp = new Date();
+ var logEntry = {
+ time: timestamp,
+ category: sCategory,
+ source: sClass,
+ sourceDetail: sDetail,
+ msg: sMsg
+ };
+
+ this._stack.push(logEntry);
+ this.newLogEvent.fire(logEntry);
+
+ if(this._firebugEnabled) {
+ this._printToFirebug(logEntry);
+ }
+ return true;
+ }
+ else {
+ return false;
+ }
+};
+
+/**
+ * Resets internal stack and startTime, enables Logger, and fires logResetEvent.
+ *
+ */
+YAHOO.widget.Logger.reset = function() {
+ this._stack = [];
+ this._startTime = new Date().getTime();
+ this.loggerEnabled = true;
+ this.log(null, "Logger reset");
+ this.logResetEvent.fire();
+};
+
+/**
+ * Public accessor to internal stack of log messages.
+ *
+ * @return {array} Array of log messages.
+ */
+YAHOO.widget.Logger.getStack = function() {
+ return this._stack;
+};
+
+/**
+ * Public accessor to internal start time.
+ *
+ * @return {date} Internal date of when Logger singleton was initialized.
+ */
+YAHOO.widget.Logger.getStartTime = function() {
+ return this._startTime;
+};
+
+/**
+ * Disables output to the Firebug Firefox extension.
+ */
+YAHOO.widget.Logger.disableFirebug = function() {
+ YAHOO.log("YAHOO.Logger output to Firebug has been disabled.");
+ this._firebugEnabled = false;
+};
+
+/**
+ * Enables output to the Firebug Firefox extension.
+ */
+YAHOO.widget.Logger.enableFirebug = function() {
+ this._firebugEnabled = true;
+ YAHOO.log("YAHOO.Logger output to Firebug has been enabled.");
+};
+
+/***************************************************************************
+ * Private methods
+ ***************************************************************************/
+/**
+ * Creates a new category of log messages and fires categoryCreateEvent.
+ *
+ * @param {string} category Category name
+ * @private
+ */
+YAHOO.widget.Logger._createNewCategory = function(category) {
+ this.categories.push(category);
+ this.categoryCreateEvent.fire(category);
+};
+
+/**
+ * Checks to see if a category has already been created.
+ *
+ * @param {string} category Category name
+ * @return {boolean} Returns true if category is unknown, else returns false
+ * @private
+ */
+YAHOO.widget.Logger._isNewCategory = function(category) {
+ for(var i=0; i < this.categories.length; i++) {
+ if(category == this.categories[i]) {
+ return false;
+ }
+ }
+ return true;
+};
+
+/**
+ * Creates a new source of log messages and fires sourceCreateEvent.
+ *
+ * @param {string} source Source name
+ * @private
+ */
+YAHOO.widget.Logger._createNewSource = function(source) {
+ this.sources.push(source);
+ this.sourceCreateEvent.fire(source);
+};
+
+/**
+ * Checks to see if a source has already been created.
+ *
+ * @param {string} source Source name
+ * @return {boolean} Returns true if source is unknown, else returns false
+ * @private
+ */
+YAHOO.widget.Logger._isNewSource = function(source) {
+ if(source) {
+ for(var i=0; i < this.sources.length; i++) {
+ if(source == this.sources[i]) {
+ return false;
+ }
+ }
+ return true;
+ }
+};
+
+/**
+ * Outputs a log message to Firebug.
+ *
+ * @param {object} entry Log entry object
+ * @private
+ */
+YAHOO.widget.Logger._printToFirebug = function(entry) {
+ if(window.console && console.log) {
+ var category = entry.category;
+ var label = entry.category.substring(0,4).toUpperCase();
+
+ var time = entry.time;
+ if (time.toLocaleTimeString) {
+ var localTime = time.toLocaleTimeString();
+ }
+ else {
+ localTime = time.toString();
+ }
+
+ var msecs = time.getTime();
+ var elapsedTime = (YAHOO.widget.Logger._lastTime) ?
+ (msecs - YAHOO.widget.Logger._lastTime) : 0;
+ YAHOO.widget.Logger._lastTime = msecs;
+
+ var output = //Firebug doesn't support HTML "<span class='"+category+"'>"+label+"</span> " +
+ localTime + " (" +
+ elapsedTime + "ms): " +
+ entry.source + ": " +
+ entry.msg;
+
+
+ console.log(output);
+ }
+};
+
+/***************************************************************************
+ * Private event handlers
+ ***************************************************************************/
+/**
+ * Handles logging of messages due to window error events.
+ *
+ * @param {string} msg The error message
+ * @param {string} url URL of the error
+ * @param {string} line Line number of the error
+ * @private
+ */
+YAHOO.widget.Logger._onWindowError = function(msg,url,line) {
+ // Logger is not in scope of this event handler
+ try {
+ YAHOO.widget.Logger.log(msg+' ('+url+', line '+line+')', "window");
+ if(YAHOO.widget.Logger._origOnWindowError) {
+ YAHOO.widget.Logger._origOnWindowError();
+ }
+ }
+ catch(e) {
+ return false;
+ }
+};
+
+/**
+ * Handle native JavaScript errors
+ */
+//NB: Not all browsers support the window.onerror event
+if(window.onerror) {
+ // Save any previously defined handler to call
+ YAHOO.widget.Logger._origOnWindowError = window.onerror;
+}
+window.onerror = YAHOO.widget.Logger._onWindowError;
+
+/**
+ * First log
+ */
+YAHOO.widget.Logger.log("Logger initialized");
+
+/****************************************************************************/
+/****************************************************************************/
+/****************************************************************************/
+/**
+ * Class providing ability to log messages through YAHOO.widget.Logger from a
+ * named source.
+ *
+ * @constructor
+ * @param {string} sSource Source of LogWriter instance
+ */
+YAHOO.widget.LogWriter = function(sSource) {
+ if(!sSource) {
+ YAHOO.log("Could not instantiate LogWriter due to invalid source.", "error", "LogWriter");
+ return;
+ }
+ this._source = sSource;
+ };
+
+/***************************************************************************
+ * Public methods
+ ***************************************************************************/
+ /**
+ * Public accessor to the unique name of the LogWriter instance.
+ *
+ * @return {string} Unique name of the LogWriter instance
+ */
+YAHOO.widget.LogWriter.prototype.toString = function() {
+ return "LogWriter " + this._sSource;
+};
+
+/**
+ * Logs a message attached to the source of the LogWriter.
+ *
+ * @param {string} sMsg The log message
+ * @param {string} sCategory Category name
+ */
+YAHOO.widget.LogWriter.prototype.log = function(sMsg, sCategory) {
+ YAHOO.widget.Logger.log(sMsg, sCategory, this._source);
+};
+
+/**
+ * Public accessor to get the source name.
+ *
+ * @return {string} The LogWriter source
+ */
+YAHOO.widget.LogWriter.prototype.getSource = function() {
+ return this._sSource;
+};
+
+/**
+ * Public accessor to set the source name.
+ *
+ * @param {string} sSource Source of LogWriter instance
+ */
+YAHOO.widget.LogWriter.prototype.setSource = function(sSource) {
+ if(!sSource) {
+ YAHOO.log("Could not set source due to invalid source.", "error", this.toString());
+ return;
+ }
+ else {
+ this._sSource = sSource;
+ }
+};
+/***************************************************************************
+ * Private members
+ ***************************************************************************/
+/**
+ * Source of the log writer instance.
+ *
+ * @type string
+ * @private
+ */
+YAHOO.widget.LogWriter.prototype._source = null;
+
+
+
+/****************************************************************************/
+/****************************************************************************/
+/****************************************************************************/
+
+/**
+ * Class providing UI to read messages logged to YAHOO.widget.Logger.
+ *
+ * requires YAHOO.util.Dom DOM utility
+ * requires YAHOO.util.Event Event utility
+ * optional YAHOO.util.DragDrop Drag and drop utility
+ *
+ * @constructor
+ * @param {el or ID} containerEl DOM element object or ID of container to wrap reader UI
+ * @param {object} oConfig Optional object literal of configuration params
+ */
+YAHOO.widget.LogReader = function(containerEl, oConfig) {
+ var oSelf = this;
+
+ // Parse config vars here
+ if (typeof oConfig == "object") {
+ for(var param in oConfig) {
+ this[param] = oConfig[param];
+ }
+ }
+
+ // Attach container...
+ if(containerEl) {
+ if(typeof containerEl == "string") {
+ this._containerEl = document.getElementById(containerEl);
+ }
+ else if(containerEl.tagName) {
+ this._containerEl = containerEl;
+ }
+ this._containerEl.className = "yui-log";
+ }
+ // ...or create container from scratch
+ if(!this._containerEl) {
+ if(YAHOO.widget.LogReader._defaultContainerEl) {
+ this._containerEl = YAHOO.widget.LogReader._defaultContainerEl;
+ }
+ else {
+ this._containerEl = document.body.appendChild(document.createElement("div"));
+ this._containerEl.id = "yui-log";
+ this._containerEl.className = "yui-log";
+
+ YAHOO.widget.LogReader._defaultContainerEl = this._containerEl;
+ }
+
+ // If implementer has provided container values, trust and set those
+ var containerStyle = this._containerEl.style;
+ if(this.width) {
+ containerStyle.width = this.width;
+ }
+ if(this.left) {
+ containerStyle.left = this.left;
+ }
+ if(this.right) {
+ containerStyle.right = this.right;
+ }
+ if(this.bottom) {
+ containerStyle.bottom = this.bottom;
+ }
+ if(this.top) {
+ containerStyle.top = this.top;
+ }
+ if(this.fontSize) {
+ containerStyle.fontSize = this.fontSize;
+ }
+ }
+
+ if(this._containerEl) {
+ // Create header
+ if(!this._hdEl) {
+ this._hdEl = this._containerEl.appendChild(document.createElement("div"));
+ this._hdEl.id = "yui-log-hd" + YAHOO.widget.LogReader._index;
+ this._hdEl.className = "yui-log-hd";
+
+ this._collapseEl = this._hdEl.appendChild(document.createElement("div"));
+ this._collapseEl.className = "yui-log-btns";
+
+ this._collapseBtn = document.createElement("input");
+ this._collapseBtn.type = "button";
+ this._collapseBtn.style.fontSize = YAHOO.util.Dom.getStyle(this._containerEl,"fontSize");
+ this._collapseBtn.className = "yui-log-button";
+ this._collapseBtn.value = "Collapse";
+ this._collapseBtn = this._collapseEl.appendChild(this._collapseBtn);
+ YAHOO.util.Event.addListener(oSelf._collapseBtn,'click',oSelf._onClickCollapseBtn,oSelf);
+
+ this._title = this._hdEl.appendChild(document.createElement("h4"));
+ this._title.innerHTML = "Logger Console";
+
+ // If Drag and Drop utility is available...
+ // ...and this container was created from scratch...
+ // ...then make the header draggable
+ if(YAHOO.util.DD &&
+ (YAHOO.widget.LogReader._defaultContainerEl == this._containerEl)) {
+ var ylog_dd = new YAHOO.util.DD(this._containerEl.id);
+ ylog_dd.setHandleElId(this._hdEl.id);
+ this._hdEl.style.cursor = "move";
+ }
+ }
+ // Ceate console
+ if(!this._consoleEl) {
+ this._consoleEl = this._containerEl.appendChild(document.createElement("div"));
+ this._consoleEl.className = "yui-log-bd";
+
+ // If implementer has provided console, trust and set those
+ if(this.height) {
+ this._consoleEl.style.height = this.height;
+ }
+ }
+ // Don't create footer if disabled
+ if(!this._ftEl && this.footerEnabled) {
+ this._ftEl = this._containerEl.appendChild(document.createElement("div"));
+ this._ftEl.className = "yui-log-ft";
+
+ this._btnsEl = this._ftEl.appendChild(document.createElement("div"));
+ this._btnsEl.className = "yui-log-btns";
+
+ this._pauseBtn = document.createElement("input");
+ this._pauseBtn.type = "button";
+ this._pauseBtn.style.fontSize = YAHOO.util.Dom.getStyle(this._containerEl,"fontSize");
+ this._pauseBtn.className = "yui-log-button";
+ this._pauseBtn.value = "Pause";
+ this._pauseBtn = this._btnsEl.appendChild(this._pauseBtn);
+ YAHOO.util.Event.addListener(oSelf._pauseBtn,'click',oSelf._onClickPauseBtn,oSelf);
+
+ this._clearBtn = document.createElement("input");
+ this._clearBtn.type = "button";
+ this._clearBtn.style.fontSize = YAHOO.util.Dom.getStyle(this._containerEl,"fontSize");
+ this._clearBtn.className = "yui-log-button";
+ this._clearBtn.value = "Clear";
+ this._clearBtn = this._btnsEl.appendChild(this._clearBtn);
+ YAHOO.util.Event.addListener(oSelf._clearBtn,'click',oSelf._onClickClearBtn,oSelf);
+
+ this._categoryFiltersEl = this._ftEl.appendChild(document.createElement("div"));
+ this._categoryFiltersEl.className = "yui-log-categoryfilters";
+ this._sourceFiltersEl = this._ftEl.appendChild(document.createElement("div"));
+ this._sourceFiltersEl.className = "yui-log-sourcefilters";
+ }
+ }
+
+ // Initialize buffer
+ if(!this._buffer) {
+ this._buffer = []; // output buffer
+ }
+ YAHOO.widget.Logger.newLogEvent.subscribe(this._onNewLog, this);
+ this._lastTime = YAHOO.widget.Logger.getStartTime(); // timestamp of last log message to console
+
+ // Initialize category filters
+ this._categoryFilters = [];
+ var catsLen = YAHOO.widget.Logger.categories.length;
+ if(this._categoryFiltersEl) {
+ for(var i=0; i < catsLen; i++) {
+ this._createCategoryCheckbox(YAHOO.widget.Logger.categories[i]);
+ }
+ }
+ // Initialize source filters
+ this._sourceFilters = [];
+ var sourcesLen = YAHOO.widget.Logger.sources.length;
+ if(this._sourceFiltersEl) {
+ for(var j=0; j < sourcesLen; j++) {
+ this._createSourceCheckbox(YAHOO.widget.Logger.sources[j]);
+ }
+ }
+ YAHOO.widget.Logger.categoryCreateEvent.subscribe(this._onCategoryCreate, this);
+ YAHOO.widget.Logger.sourceCreateEvent.subscribe(this._onSourceCreate, this);
+
+ YAHOO.widget.LogReader._index++;
+ this._filterLogs();
+};
+
+/***************************************************************************
+ * Public members
+ ***************************************************************************/
+/**
+ * Whether or not the log reader is enabled to output log messages. Default:
+ * true.
+ *
+ * @type boolean
+ */
+YAHOO.widget.LogReader.prototype.logReaderEnabled = true;
+
+/**
+ * Public member to access CSS width of the log reader container.
+ *
+ * @type string
+ */
+YAHOO.widget.LogReader.prototype.width = null;
+
+/**
+ * Public member to access CSS height of the log reader container.
+ *
+ * @type string
+ */
+YAHOO.widget.LogReader.prototype.height = null;
+
+/**
+ * Public member to access CSS top position of the log reader container.
+ *
+ * @type string
+ */
+YAHOO.widget.LogReader.prototype.top = null;
+
+/**
+ * Public member to access CSS left position of the log reader container.
+ *
+ * @type string
+ */
+YAHOO.widget.LogReader.prototype.left = null;
+
+/**
+ * Public member to access CSS right position of the log reader container.
+ *
+ * @type string
+ */
+YAHOO.widget.LogReader.prototype.right = null;
+
+/**
+ * Public member to access CSS bottom position of the log reader container.
+ *
+ * @type string
+ */
+YAHOO.widget.LogReader.prototype.bottom = null;
+
+/**
+ * Public member to access CSS font size of the log reader container.
+ *
+ * @type string
+ */
+YAHOO.widget.LogReader.prototype.fontSize = null;
+
+/**
+ * Whether or not the footer UI is enabled for the log reader. Default: true.
+ *
+ * @type boolean
+ */
+YAHOO.widget.LogReader.prototype.footerEnabled = true;
+
+/**
+ * Whether or not output is verbose (more readable). Setting to true will make
+ * output more compact (less readable). Default: true.
+ *
+ * @type boolean
+ */
+YAHOO.widget.LogReader.prototype.verboseOutput = true;
+
+/**
+ * Whether or not newest message is printed on top. Default: true.
+ *
+ * @type boolean
+ */
+YAHOO.widget.LogReader.prototype.newestOnTop = true;
+
+/***************************************************************************
+ * Public methods
+ ***************************************************************************/
+/**
+ * Pauses output of log messages. While paused, log messages are not lost, but
+ * get saved to a buffer and then output upon resume of log reader.
+ */
+YAHOO.widget.LogReader.prototype.pause = function() {
+ this._timeout = null;
+ this.logReaderEnabled = false;
+};
+
+/**
+ * Resumes output of log messages, including outputting any log messages that
+ * have been saved to buffer while paused.
+ */
+YAHOO.widget.LogReader.prototype.resume = function() {
+ this.logReaderEnabled = true;
+ this._printBuffer();
+};
+
+/**
+ * Hides UI of log reader. Logging functionality is not disrupted.
+ */
+YAHOO.widget.LogReader.prototype.hide = function() {
+ this._containerEl.style.display = "none";
+};
+
+/**
+ * Shows UI of log reader. Logging functionality is not disrupted.
+ */
+YAHOO.widget.LogReader.prototype.show = function() {
+ this._containerEl.style.display = "block";
+};
+
+/**
+ * Updates title to given string.
+ *
+ * @param {string} sTitle String to display in log reader's title bar.
+ */
+YAHOO.widget.LogReader.prototype.setTitle = function(sTitle) {
+ var regEx = />/g;
+ sTitle = sTitle.replace(regEx,">");
+ regEx = /</g;
+ sTitle = sTitle.replace(regEx,"<");
+ this._title.innerHTML = (sTitle);
+};
+ /***************************************************************************
+ * Private members
+ ***************************************************************************/
+/**
+ * Internal class member to index multiple log reader instances.
+ *
+ * @type number
+ * @private
+ */
+YAHOO.widget.LogReader._index = 0;
+
+/**
+ * A class member shared by all log readers if a container needs to be
+ * created during instantiation. Will be null if a container element never needs to
+ * be created on the fly, such as when the implementer passes in their own element.
+ *
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.LogReader._defaultContainerEl = null;
+
+/**
+ * Buffer of log messages for batch output.
+ *
+ * @type array
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._buffer = null;
+
+/**
+ * Date of last output log message.
+ *
+ * @type date
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._lastTime = null;
+
+/**
+ * Batched output timeout ID.
+ *
+ * @type number
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._timeout = null;
+
+/**
+ * Array of filters for log message categories.
+ *
+ * @type array
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._categoryFilters = null;
+
+/**
+ * Array of filters for log message sources.
+ *
+ * @type array
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._sourceFilters = null;
+
+/**
+ * Log reader container element.
+ *
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._containerEl = null;
+
+/**
+ * Log reader header element.
+ *
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._hdEl = null;
+
+/**
+ * Log reader collapse element.
+ *
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._collapseEl = null;
+
+/**
+ * Log reader collapse button element.
+ *
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._collapseBtn = null;
+
+/**
+ * Log reader title header element.
+ *
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._title = null;
+
+/**
+ * Log reader console element.
+ *
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._consoleEl = null;
+
+/**
+ * Log reader footer element.
+ *
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._ftEl = null;
+
+/**
+ * Log reader buttons container element.
+ *
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._btnsEl = null;
+
+/**
+ * Container element for log reader category filter checkboxes.
+ *
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._categoryFiltersEl = null;
+
+/**
+ * Container element for log reader source filter checkboxes.
+ *
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._sourceFiltersEl = null;
+
+/**
+ * Log reader pause button element.
+ *
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._pauseBtn = null;
+
+/**
+ * lear button element.
+ *
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._clearBtn = null;
+/***************************************************************************
+ * Private methods
+ ***************************************************************************/
+/**
+ * Creates the UI for a category filter in the log reader footer element.
+ *
+ * @param {string} category Category name
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._createCategoryCheckbox = function(category) {
+ var oSelf = this;
+
+ if(this._ftEl) {
+ var parentEl = this._categoryFiltersEl;
+ var filters = this._categoryFilters;
+
+ var filterEl = parentEl.appendChild(document.createElement("span"));
+ filterEl.className = "yui-log-filtergrp";
+ // Append el at the end so IE 5.5 can set "type" attribute
+ // and THEN set checked property
+ var categoryChk = document.createElement("input");
+ categoryChk.id = "yui-log-filter-" + category + YAHOO.widget.LogReader._index;
+ categoryChk.className = "yui-log-filter-" + category;
+ categoryChk.type = "checkbox";
+ categoryChk.category = category;
+ categoryChk = filterEl.appendChild(categoryChk);
+ categoryChk.checked = true;
+
+ // Add this checked filter to the internal array of filters
+ filters.push(category);
+ // Subscribe to the click event
+ YAHOO.util.Event.addListener(categoryChk,'click',oSelf._onCheckCategory,oSelf);
+
+ // Create and class the text label
+ var categoryChkLbl = filterEl.appendChild(document.createElement("label"));
+ categoryChkLbl.htmlFor = categoryChk.id;
+ categoryChkLbl.className = category;
+ categoryChkLbl.innerHTML = category;
+ }
+};
+
+YAHOO.widget.LogReader.prototype._createSourceCheckbox = function(source) {
+ var oSelf = this;
+
+ if(this._ftEl) {
+ var parentEl = this._sourceFiltersEl;
+ var filters = this._sourceFilters;
+
+ var filterEl = parentEl.appendChild(document.createElement("span"));
+ filterEl.className = "yui-log-filtergrp";
+
+ // Append el at the end so IE 5.5 can set "type" attribute
+ // and THEN set checked property
+ var sourceChk = document.createElement("input");
+ sourceChk.id = "yui-log-filter" + source + YAHOO.widget.LogReader._index;
+ sourceChk.className = "yui-log-filter" + source;
+ sourceChk.type = "checkbox";
+ sourceChk.source = source;
+ sourceChk = filterEl.appendChild(sourceChk);
+ sourceChk.checked = true;
+
+ // Add this checked filter to the internal array of filters
+ filters.push(source);
+ // Subscribe to the click event
+ YAHOO.util.Event.addListener(sourceChk,'click',oSelf._onCheckSource,oSelf);
+
+ // Create and class the text label
+ var sourceChkLbl = filterEl.appendChild(document.createElement("label"));
+ sourceChkLbl.htmlFor = sourceChk.id;
+ sourceChkLbl.className = source;
+ sourceChkLbl.innerHTML = source;
+ }
+};
+
+/**
+ * Reprints all log messages in the stack through filters.
+ *
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._filterLogs = function() {
+ // Reprint stack with new filters
+ if (this._consoleEl !== null) {
+ this._clearConsole();
+ this._printToConsole(YAHOO.widget.Logger.getStack());
+ }
+};
+
+/**
+ * Clears all outputted log messages from the console and resets the time of the
+ * last output log message.
+ *
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._clearConsole = function() {
+ // Clear the buffer of any pending messages
+ this._timeout = null;
+ this._buffer = [];
+
+ // Reset the rolling timer
+ this._lastTime = YAHOO.widget.Logger.getStartTime();
+
+ var consoleEl = this._consoleEl;
+ while(consoleEl.hasChildNodes()) {
+ consoleEl.removeChild(consoleEl.firstChild);
+ }
+};
+
+/**
+ * Sends buffer of log messages to output and clears buffer.
+ *
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._printBuffer = function() {
+ this._timeout = null;
+
+ if (this._consoleEl !== null) {
+ var entries = [];
+ for (var i=0; i<this._buffer.length; i++) {
+ entries[i] = this._buffer[i];
+ }
+ this._buffer = [];
+ this._printToConsole(entries);
+ if(!this.newestOnTop) {
+ this._consoleEl.scrollTop = this._consoleEl.scrollHeight;
+ }
+ }
+};
+
+/**
+ * Cycles through an array of log messages, and outputs each one to the console
+ * if its category has not been filtered out.
+ *
+ * @param {array} aEntries
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._printToConsole = function(aEntries) {
+ var entriesLen = aEntries.length;
+ var sourceFiltersLen = this._sourceFilters.length;
+ var categoryFiltersLen = this._categoryFilters.length;
+ // Iterate through all log entries to print the ones that filter through
+ for(var i=0; i<entriesLen; i++) {
+ var entry = aEntries[i];
+ var category = entry.category;
+ var source = entry.source;
+ var sourceDetail = entry.sourceDetail;
+ var okToPrint = false;
+ var okToFilterCats = false;
+
+ for(var j=0; j<sourceFiltersLen; j++) {
+ if(source == this._sourceFilters[j]) {
+ okToFilterCats = true;
+ break;
+ }
+ }
+ if(okToFilterCats) {
+ for(var k=0; k<categoryFiltersLen; k++) {
+ if(category == this._categoryFilters[k]) {
+ okToPrint = true;
+ break;
+ }
+ }
+ }
+ if(okToPrint) {
+ // To format for console, calculate the elapsed time
+ // to be from the last item that passed through the filter,
+ // not the absolute previous item in the stack
+ var label = entry.category.substring(0,4).toUpperCase();
+
+ var time = entry.time;
+ if (time.toLocaleTimeString) {
+ var localTime = time.toLocaleTimeString();
+ }
+ else {
+ localTime = time.toString();
+ }
+
+ var msecs = time.getTime();
+ var startTime = YAHOO.widget.Logger.getStartTime();
+ var totalTime = msecs - startTime;
+ var elapsedTime = msecs - this._lastTime;
+ this._lastTime = msecs;
+
+ var verboseOutput = (this.verboseOutput) ? "<br>" : "";
+ var sourceAndDetail = (sourceDetail) ?
+ source + " " + sourceDetail : source;
+
+ var output = "<span class='"+category+"'>"+label+"</span> " +
+ totalTime + "ms (+" +
+ elapsedTime + ") " + localTime + ": " +
+ sourceAndDetail + ": " +
+ verboseOutput +
+ entry.msg;
+
+ var oNewElement = (this.newestOnTop) ?
+ this._consoleEl.insertBefore(document.createElement("p"),this._consoleEl.firstChild):
+ this._consoleEl.appendChild(document.createElement("p"));
+ oNewElement.innerHTML = output;
+ }
+ }
+};
+
+/***************************************************************************
+ * Private event handlers
+ ***************************************************************************/
+/**
+ * Handles Logger's categoryCreateEvent.
+ *
+ * @param {string} type The event
+ * @param {array} args Data passed from event firer
+ * @param {object} oSelf The log reader instance
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._onCategoryCreate = function(type, args, oSelf) {
+ var category = args[0];
+ if(oSelf._ftEl) {
+ oSelf._createCategoryCheckbox(category);
+ }
+};
+
+/**
+ * Handles Logger's sourceCreateEvent.
+ *
+ * @param {string} type The event
+ * @param {array} args Data passed from event firer
+ * @param {object} oSelf The log reader instance
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._onSourceCreate = function(type, args, oSelf) {
+ var source = args[0];
+ if(oSelf._ftEl) {
+ oSelf._createSourceCheckbox(source);
+ }
+};
+
+/**
+ * Handles check events on the category filter checkboxes.
+ *
+ * @param {event} v The click event
+ * @param {object} oSelf The log reader instance
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._onCheckCategory = function(v, oSelf) {
+ var newFilter = this.category;
+ var filtersArray = oSelf._categoryFilters;
+
+ if(!this.checked) { // Remove category from filters
+ for(var i=0; i<filtersArray.length; i++) {
+ if(newFilter == filtersArray[i]) {
+ filtersArray.splice(i, 1);
+ break;
+ }
+ }
+ }
+ else { // Add category to filters
+ filtersArray.push(newFilter);
+ }
+ oSelf._filterLogs();
+};
+
+/**
+ * Handles check events on the category filter checkboxes.
+ *
+ * @param {event} v The click event
+ * @param {object} oSelf The log reader instance
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._onCheckSource = function(v, oSelf) {
+ var newFilter = this.source;
+ var filtersArray = oSelf._sourceFilters;
+
+ if(!this.checked) { // Remove category from filters
+ for(var i=0; i<filtersArray.length; i++) {
+ if(newFilter == filtersArray[i]) {
+ filtersArray.splice(i, 1);
+ break;
+ }
+ }
+ }
+ else { // Add category to filters
+ filtersArray.push(newFilter);
+ }
+ oSelf._filterLogs();
+};
+
+/**
+ * Handles click events on the collapse button.
+ *
+ * @param {event} v The click event
+ * @param {object} oSelf The log reader instance
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._onClickCollapseBtn = function(v, oSelf) {
+ var btn = oSelf._collapseBtn;
+ if(btn.value == "Expand") {
+ oSelf._consoleEl.style.display = "block";
+ if(oSelf._ftEl) {
+ oSelf._ftEl.style.display = "block";
+ }
+ btn.value = "Collapse";
+ }
+ else {
+ oSelf._consoleEl.style.display = "none";
+ if(oSelf._ftEl) {
+ oSelf._ftEl.style.display = "none";
+ }
+ btn.value = "Expand";
+ }
+};
+
+/**
+ * Handles click events on the pause button.
+ *
+ * @param {event} v The click event
+ * @param {object} oSelf The log reader instance
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._onClickPauseBtn = function(v, oSelf) {
+ var btn = oSelf._pauseBtn;
+ if(btn.value == "Resume") {
+ oSelf.resume();
+ btn.value = "Pause";
+ }
+ else {
+ oSelf.pause();
+ btn.value = "Resume";
+ }
+};
+
+/**
+ * Handles click events on the clear button.
+ *
+ * @param {event} v The click event
+ * @param {object} oSelf The log reader instance
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._onClickClearBtn = function(v, oSelf) {
+ oSelf._clearConsole();
+};
+
+/**
+ * Handles Logger's onNewEvent.
+ *
+ * @param {string} type The click event
+ * @param {array} args Data passed from event firer
+ * @param {object} oSelf The log reader instance
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._onNewLog = function(type, args, oSelf) {
+ var logEntry = args[0];
+ oSelf._buffer.push(logEntry);
+
+ if (oSelf.logReaderEnabled === true && oSelf._timeout === null) {
+ oSelf._timeout = setTimeout(function(){oSelf._printBuffer();}, 100);
+ }
+};
+
+
Added: branches/tomek/portal-dnd/dndRenderer.war/js/logger/logger-min.js
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/logger/logger-min.js 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/logger/logger-min.js 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,63 @@
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 0.11.0
+*/
+
+
+YAHOO.widget.Logger={loggerEnabled:true,_firebugEnabled:true,categories:["info","warn","error","time","window"],sources:["global"],_stack:[],_startTime:new Date().getTime(),_lastTime:null};YAHOO.widget.Logger.categoryCreateEvent=new YAHOO.util.CustomEvent("categoryCreate",this,true);YAHOO.widget.Logger.sourceCreateEvent=new YAHOO.util.CustomEvent("sourceCreate",this,true);YAHOO.widget.Logger.newLogEvent=new YAHOO.util.CustomEvent("newLog",this,true);YAHOO.widget.Logger.logResetEvent=new YAHOO.util.CustomEvent("logReset",this,true);YAHOO.widget.Logger.log=function(sMsg,sCategory,sSource){if(this.loggerEnabled){if(!sCategory){sCategory="info";}
+else if(this._isNewCategory(sCategory)){this._createNewCategory(sCategory);}
+var sClass="global";var sDetail=null;if(sSource){var spaceIndex=sSource.indexOf(" ");if(spaceIndex>0){sClass=sSource.substring(0,spaceIndex);sDetail=sSource.substring(spaceIndex,sSource.length);}
+else{sClass=sSource;}
+if(this._isNewSource(sClass)){this._createNewSource(sClass);}}
+var timestamp=new Date();var logEntry={time:timestamp,category:sCategory,source:sClass,sourceDetail:sDetail,msg:sMsg};this._stack.push(logEntry);this.newLogEvent.fire(logEntry);if(this._firebugEnabled){this._printToFirebug(logEntry);}
+return true;}
+else{return false;}};YAHOO.widget.Logger.reset=function(){this._stack=[];this._startTime=new Date().getTime();this.loggerEnabled=true;this.log(null,"Logger reset");this.logResetEvent.fire();};YAHOO.widget.Logger.getStack=function(){return this._stack;};YAHOO.widget.Logger.getStartTime=function(){return this._startTime;};YAHOO.widget.Logger.disableFirebug=function(){YAHOO.log("YAHOO.Logger output to Firebug has been disabled.");this._firebugEnabled=false;};YAHOO.widget.Logger.enableFirebug=function(){this._firebugEnabled=true;YAHOO.log("YAHOO.Logger output to Firebug has been enabled.");};YAHOO.widget.Logger._createNewCategory=function(category){this.categories.push(category);this.categoryCreateEvent.fire(category);};YAHOO.widget.Logger._isNewCategory=function(category){for(var i=0;i<this.categories.length;i++){if(category==this.categories[i]){return false;}}
+return true;};YAHOO.widget.Logger._createNewSource=function(source){this.sources.push(source);this.sourceCreateEvent.fire(source);};YAHOO.widget.Logger._isNewSource=function(source){if(source){for(var i=0;i<this.sources.length;i++){if(source==this.sources[i]){return false;}}
+return true;}};YAHOO.widget.Logger._printToFirebug=function(entry){if(window.console&&console.log){var category=entry.category;var label=entry.category.substring(0,4).toUpperCase();var time=entry.time;if(time.toLocaleTimeString){var localTime=time.toLocaleTimeString();}
+else{localTime=time.toString();}
+var msecs=time.getTime();var elapsedTime=(YAHOO.widget.Logger._lastTime)?(msecs-YAHOO.widget.Logger._lastTime):0;YAHOO.widget.Logger._lastTime=msecs;var output=localTime+" ("+
+elapsedTime+"ms): "+
+entry.source+": "+
+entry.msg;console.log(output);}};YAHOO.widget.Logger._onWindowError=function(msg,url,line){try{YAHOO.widget.Logger.log(msg+' ('+url+', line '+line+')',"window");if(YAHOO.widget.Logger._origOnWindowError){YAHOO.widget.Logger._origOnWindowError();}}
+catch(e){return false;}};if(window.onerror){YAHOO.widget.Logger._origOnWindowError=window.onerror;}
+window.onerror=YAHOO.widget.Logger._onWindowError;YAHOO.widget.Logger.log("Logger initialized");YAHOO.widget.LogWriter=function(sSource){if(!sSource){YAHOO.log("Could not instantiate LogWriter due to invalid source.","error","LogWriter");return;}
+this._source=sSource;};YAHOO.widget.LogWriter.prototype.toString=function(){return"LogWriter "+this._sSource;};YAHOO.widget.LogWriter.prototype.log=function(sMsg,sCategory){YAHOO.widget.Logger.log(sMsg,sCategory,this._source);};YAHOO.widget.LogWriter.prototype.getSource=function(){return this._sSource;};YAHOO.widget.LogWriter.prototype.setSource=function(sSource){if(!sSource){YAHOO.log("Could not set source due to invalid source.","error",this.toString());return;}
+else{this._sSource=sSource;}};YAHOO.widget.LogWriter.prototype._source=null;YAHOO.widget.LogReader=function(containerEl,oConfig){var oSelf=this;if(typeof oConfig=="object"){for(var param in oConfig){this[param]=oConfig[param];}}
+if(containerEl){if(typeof containerEl=="string"){this._containerEl=document.getElementById(containerEl);}
+else if(containerEl.tagName){this._containerEl=containerEl;}
+this._containerEl.className="yui-log";}
+if(!this._containerEl){if(YAHOO.widget.LogReader._defaultContainerEl){this._containerEl=YAHOO.widget.LogReader._defaultContainerEl;}
+else{this._containerEl=document.body.appendChild(document.createElement("div"));this._containerEl.id="yui-log";this._containerEl.className="yui-log";YAHOO.widget.LogReader._defaultContainerEl=this._containerEl;}
+var containerStyle=this._containerEl.style;if(this.width){containerStyle.width=this.width;}
+if(this.left){containerStyle.left=this.left;}
+if(this.right){containerStyle.right=this.right;}
+if(this.bottom){containerStyle.bottom=this.bottom;}
+if(this.top){containerStyle.top=this.top;}
+if(this.fontSize){containerStyle.fontSize=this.fontSize;}}
+if(this._containerEl){if(!this._hdEl){this._hdEl=this._containerEl.appendChild(document.createElement("div"));this._hdEl.id="yui-log-hd"+YAHOO.widget.LogReader._index;this._hdEl.className="yui-log-hd";this._collapseEl=this._hdEl.appendChild(document.createElement("div"));this._collapseEl.className="yui-log-btns";this._collapseBtn=document.createElement("input");this._collapseBtn.type="button";this._collapseBtn.style.fontSize=YAHOO.util.Dom.getStyle(this._containerEl,"fontSize");this._collapseBtn.className="yui-log-button";this._collapseBtn.value="Collapse";this._collapseBtn=this._collapseEl.appendChild(this._collapseBtn);YAHOO.util.Event.addListener(oSelf._collapseBtn,'click',oSelf._onClickCollapseBtn,oSelf);this._title=this._hdEl.appendChild(document.createElement("h4"));this._title.innerHTML="Logger Console";if(YAHOO.util.DD&&(YAHOO.widget.LogReader._defaultContainerEl==this._containerEl)){var ylog_dd=new YAHOO.util.DD(this._containerEl.id);ylog_dd.setHandleElId(this._hdE!
l.id);this._hdEl.style.cursor="move";}}
+if(!this._consoleEl){this._consoleEl=this._containerEl.appendChild(document.createElement("div"));this._consoleEl.className="yui-log-bd";if(this.height){this._consoleEl.style.height=this.height;}}
+if(!this._ftEl&&this.footerEnabled){this._ftEl=this._containerEl.appendChild(document.createElement("div"));this._ftEl.className="yui-log-ft";this._btnsEl=this._ftEl.appendChild(document.createElement("div"));this._btnsEl.className="yui-log-btns";this._pauseBtn=document.createElement("input");this._pauseBtn.type="button";this._pauseBtn.style.fontSize=YAHOO.util.Dom.getStyle(this._containerEl,"fontSize");this._pauseBtn.className="yui-log-button";this._pauseBtn.value="Pause";this._pauseBtn=this._btnsEl.appendChild(this._pauseBtn);YAHOO.util.Event.addListener(oSelf._pauseBtn,'click',oSelf._onClickPauseBtn,oSelf);this._clearBtn=document.createElement("input");this._clearBtn.type="button";this._clearBtn.style.fontSize=YAHOO.util.Dom.getStyle(this._containerEl,"fontSize");this._clearBtn.className="yui-log-button";this._clearBtn.value="Clear";this._clearBtn=this._btnsEl.appendChild(this._clearBtn);YAHOO.util.Event.addListener(oSelf._clearBtn,'click',oSelf._onClickClearBtn,oSelf);t!
his._categoryFiltersEl=this._ftEl.appendChild(document.createElement("div"));this._categoryFiltersEl.className="yui-log-categoryfilters";this._sourceFiltersEl=this._ftEl.appendChild(document.createElement("div"));this._sourceFiltersEl.className="yui-log-sourcefilters";}}
+if(!this._buffer){this._buffer=[];}
+YAHOO.widget.Logger.newLogEvent.subscribe(this._onNewLog,this);this._lastTime=YAHOO.widget.Logger.getStartTime();this._categoryFilters=[];var catsLen=YAHOO.widget.Logger.categories.length;if(this._categoryFiltersEl){for(var i=0;i<catsLen;i++){this._createCategoryCheckbox(YAHOO.widget.Logger.categories[i]);}}
+this._sourceFilters=[];var sourcesLen=YAHOO.widget.Logger.sources.length;if(this._sourceFiltersEl){for(var j=0;j<sourcesLen;j++){this._createSourceCheckbox(YAHOO.widget.Logger.sources[j]);}}
+YAHOO.widget.Logger.categoryCreateEvent.subscribe(this._onCategoryCreate,this);YAHOO.widget.Logger.sourceCreateEvent.subscribe(this._onSourceCreate,this);YAHOO.widget.LogReader._index++;this._filterLogs();};YAHOO.widget.LogReader.prototype.logReaderEnabled=true;YAHOO.widget.LogReader.prototype.width=null;YAHOO.widget.LogReader.prototype.height=null;YAHOO.widget.LogReader.prototype.top=null;YAHOO.widget.LogReader.prototype.left=null;YAHOO.widget.LogReader.prototype.right=null;YAHOO.widget.LogReader.prototype.bottom=null;YAHOO.widget.LogReader.prototype.fontSize=null;YAHOO.widget.LogReader.prototype.footerEnabled=true;YAHOO.widget.LogReader.prototype.verboseOutput=true;YAHOO.widget.LogReader.prototype.newestOnTop=true;YAHOO.widget.LogReader.prototype.pause=function(){this._timeout=null;this.logReaderEnabled=false;};YAHOO.widget.LogReader.prototype.resume=function(){this.logReaderEnabled=true;this._printBuffer();};YAHOO.widget.LogReader.prototype.hide=function(){this._containe!
rEl.style.display="none";};YAHOO.widget.LogReader.prototype.show=function(){this._containerEl.style.display="block";};YAHOO.widget.LogReader.prototype.setTitle=function(sTitle){var regEx=/>/g;sTitle=sTitle.replace(regEx,">");regEx=/</g;sTitle=sTitle.replace(regEx,"<");this._title.innerHTML=(sTitle);};YAHOO.widget.LogReader._index=0;YAHOO.widget.LogReader._defaultContainerEl=null;YAHOO.widget.LogReader.prototype._buffer=null;YAHOO.widget.LogReader.prototype._lastTime=null;YAHOO.widget.LogReader.prototype._timeout=null;YAHOO.widget.LogReader.prototype._categoryFilters=null;YAHOO.widget.LogReader.prototype._sourceFilters=null;YAHOO.widget.LogReader.prototype._containerEl=null;YAHOO.widget.LogReader.prototype._hdEl=null;YAHOO.widget.LogReader.prototype._collapseEl=null;YAHOO.widget.LogReader.prototype._collapseBtn=null;YAHOO.widget.LogReader.prototype._title=null;YAHOO.widget.LogReader.prototype._consoleEl=null;YAHOO.widget.LogReader.prototype._ftEl=null;YAHOO.widget.LogR!
eader.prototype._btnsEl=null;YAHOO.widget.LogReader.prototype._categor
yFiltersEl=null;YAHOO.widget.LogReader.prototype._sourceFiltersEl=null;YAHOO.widget.LogReader.prototype._pauseBtn=null;YAHOO.widget.LogReader.prototype._clearBtn=null;YAHOO.widget.LogReader.prototype._createCategoryCheckbox=function(category){var oSelf=this;if(this._ftEl){var parentEl=this._categoryFiltersEl;var filters=this._categoryFilters;var filterEl=parentEl.appendChild(document.createElement("span"));filterEl.className="yui-log-filtergrp";var categoryChk=document.createElement("input");categoryChk.id="yui-log-filter-"+category+YAHOO.widget.LogReader._index;categoryChk.className="yui-log-filter-"+category;categoryChk.type="checkbox";categoryChk.category=category;categoryChk=filterEl.appendChild(categoryChk);categoryChk.checked=true;filters.push(category);YAHOO.util.Event.addListener(categoryChk,'click',oSelf._onCheckCategory,oSelf);var categoryChkLbl=filterEl.appendChild(document.createElement("label"));categoryChkLbl.htmlFor=categoryChk.id;categoryChkLbl.className=cate!
gory;categoryChkLbl.innerHTML=category;}};YAHOO.widget.LogReader.prototype._createSourceCheckbox=function(source){var oSelf=this;if(this._ftEl){var parentEl=this._sourceFiltersEl;var filters=this._sourceFilters;var filterEl=parentEl.appendChild(document.createElement("span"));filterEl.className="yui-log-filtergrp";var sourceChk=document.createElement("input");sourceChk.id="yui-log-filter"+source+YAHOO.widget.LogReader._index;sourceChk.className="yui-log-filter"+source;sourceChk.type="checkbox";sourceChk.source=source;sourceChk=filterEl.appendChild(sourceChk);sourceChk.checked=true;filters.push(source);YAHOO.util.Event.addListener(sourceChk,'click',oSelf._onCheckSource,oSelf);var sourceChkLbl=filterEl.appendChild(document.createElement("label"));sourceChkLbl.htmlFor=sourceChk.id;sourceChkLbl.className=source;sourceChkLbl.innerHTML=source;}};YAHOO.widget.LogReader.prototype._filterLogs=function(){if(this._consoleEl!==null){this._clearConsole();this._printToConsole(YAHOO.widge!
t.Logger.getStack());}};YAHOO.widget.LogReader.prototype._clearConsole
=function(){this._timeout=null;this._buffer=[];this._lastTime=YAHOO.widget.Logger.getStartTime();var consoleEl=this._consoleEl;while(consoleEl.hasChildNodes()){consoleEl.removeChild(consoleEl.firstChild);}};YAHOO.widget.LogReader.prototype._printBuffer=function(){this._timeout=null;if(this._consoleEl!==null){var entries=[];for(var i=0;i<this._buffer.length;i++){entries[i]=this._buffer[i];}
+this._buffer=[];this._printToConsole(entries);if(!this.newestOnTop){this._consoleEl.scrollTop=this._consoleEl.scrollHeight;}}};YAHOO.widget.LogReader.prototype._printToConsole=function(aEntries){var entriesLen=aEntries.length;var sourceFiltersLen=this._sourceFilters.length;var categoryFiltersLen=this._categoryFilters.length;for(var i=0;i<entriesLen;i++){var entry=aEntries[i];var category=entry.category;var source=entry.source;var sourceDetail=entry.sourceDetail;var okToPrint=false;var okToFilterCats=false;for(var j=0;j<sourceFiltersLen;j++){if(source==this._sourceFilters[j]){okToFilterCats=true;break;}}
+if(okToFilterCats){for(var k=0;k<categoryFiltersLen;k++){if(category==this._categoryFilters[k]){okToPrint=true;break;}}}
+if(okToPrint){var label=entry.category.substring(0,4).toUpperCase();var time=entry.time;if(time.toLocaleTimeString){var localTime=time.toLocaleTimeString();}
+else{localTime=time.toString();}
+var msecs=time.getTime();var startTime=YAHOO.widget.Logger.getStartTime();var totalTime=msecs-startTime;var elapsedTime=msecs-this._lastTime;this._lastTime=msecs;var verboseOutput=(this.verboseOutput)?"<br>":"";var sourceAndDetail=(sourceDetail)?source+" "+sourceDetail:source;var output="<span class='"+category+"'>"+label+"</span> "+
+totalTime+"ms (+"+
+elapsedTime+") "+localTime+": "+
+sourceAndDetail+": "+
+verboseOutput+
+entry.msg;var oNewElement=(this.newestOnTop)?this._consoleEl.insertBefore(document.createElement("p"),this._consoleEl.firstChild):this._consoleEl.appendChild(document.createElement("p"));oNewElement.innerHTML=output;}}};YAHOO.widget.LogReader.prototype._onCategoryCreate=function(type,args,oSelf){var category=args[0];if(oSelf._ftEl){oSelf._createCategoryCheckbox(category);}};YAHOO.widget.LogReader.prototype._onSourceCreate=function(type,args,oSelf){var source=args[0];if(oSelf._ftEl){oSelf._createSourceCheckbox(source);}};YAHOO.widget.LogReader.prototype._onCheckCategory=function(v,oSelf){var newFilter=this.category;var filtersArray=oSelf._categoryFilters;if(!this.checked){for(var i=0;i<filtersArray.length;i++){if(newFilter==filtersArray[i]){filtersArray.splice(i,1);break;}}}
+else{filtersArray.push(newFilter);}
+oSelf._filterLogs();};YAHOO.widget.LogReader.prototype._onCheckSource=function(v,oSelf){var newFilter=this.source;var filtersArray=oSelf._sourceFilters;if(!this.checked){for(var i=0;i<filtersArray.length;i++){if(newFilter==filtersArray[i]){filtersArray.splice(i,1);break;}}}
+else{filtersArray.push(newFilter);}
+oSelf._filterLogs();};YAHOO.widget.LogReader.prototype._onClickCollapseBtn=function(v,oSelf){var btn=oSelf._collapseBtn;if(btn.value=="Expand"){oSelf._consoleEl.style.display="block";if(oSelf._ftEl){oSelf._ftEl.style.display="block";}
+btn.value="Collapse";}
+else{oSelf._consoleEl.style.display="none";if(oSelf._ftEl){oSelf._ftEl.style.display="none";}
+btn.value="Expand";}};YAHOO.widget.LogReader.prototype._onClickPauseBtn=function(v,oSelf){var btn=oSelf._pauseBtn;if(btn.value=="Resume"){oSelf.resume();btn.value="Pause";}
+else{oSelf.pause();btn.value="Resume";}};YAHOO.widget.LogReader.prototype._onClickClearBtn=function(v,oSelf){oSelf._clearConsole();};YAHOO.widget.LogReader.prototype._onNewLog=function(type,args,oSelf){var logEntry=args[0];oSelf._buffer.push(logEntry);if(oSelf.logReaderEnabled===true&&oSelf._timeout===null){oSelf._timeout=setTimeout(function(){oSelf._printBuffer();},100);}};
\ No newline at end of file
Added: branches/tomek/portal-dnd/dndRenderer.war/js/logger/logger.js
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/logger/logger.js 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/logger/logger.js 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,1186 @@
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 0.11.0
+*/
+
+/****************************************************************************/
+/****************************************************************************/
+/****************************************************************************/
+/**
+ * Singleton providing core logging functionality. Saves logs written through the
+ * global YAHOO.log function or written by LogWriter. Provides access to logs
+ * for reading by LogReader. Log messages are automatically output to Firebug,
+ * if present.
+ *
+ * requires YAHOO.util.Event Event utility
+ */
+YAHOO.widget.Logger = {
+ // Initialize members
+ loggerEnabled: true,
+ _firebugEnabled: true,
+ categories: ["info","warn","error","time","window"],
+ sources: ["global"],
+ _stack: [], // holds all log msgs
+ _startTime: new Date().getTime(), // static start timestamp
+ _lastTime: null // timestamp of last logged message
+};
+
+/***************************************************************************
+ * Events
+ ***************************************************************************/
+/**
+ * Fired when a new category has been created. Subscribers receive the following
+ * array:<br>
+ * - args[0] The category name
+ */
+YAHOO.widget.Logger.categoryCreateEvent = new YAHOO.util.CustomEvent("categoryCreate", this, true);
+
+/**
+ * Fired when a new source has been named. Subscribers receive the following
+ * array:<br>
+ * - args[0] The source name
+ */
+YAHOO.widget.Logger.sourceCreateEvent = new YAHOO.util.CustomEvent("sourceCreate", this, true);
+
+/**
+ * Fired when a new log message has been created. Subscribers receive the
+ * following array:<br>
+ * - args[0] The log message
+ */
+YAHOO.widget.Logger.newLogEvent = new YAHOO.util.CustomEvent("newLog", this, true);
+
+/**
+ * Fired when the Logger has been reset has been created.
+ */
+YAHOO.widget.Logger.logResetEvent = new YAHOO.util.CustomEvent("logReset", this, true);
+
+/***************************************************************************
+ * Public methods
+ ***************************************************************************/
+/**
+ * Saves a log message to the stack and fires newLogEvent. If the log message is
+ * assigned to an unknown category, creates a new category. If the log message is
+ * from an unknown source, creates a new source. If Firebug is enabled,
+ * outputs the log message to Firebug.
+ *
+ * @param {string} sMsg The log message
+ * @param {string} sCategory Category of log message, or null
+ * @param {string} sSource Source of LogWriter, or null if global
+ */
+YAHOO.widget.Logger.log = function(sMsg, sCategory, sSource) {
+ if(this.loggerEnabled) {
+ if(!sCategory) {
+ sCategory = "info"; // default category
+ }
+ else if(this._isNewCategory(sCategory)) {
+ this._createNewCategory(sCategory);
+ }
+ var sClass = "global"; // default source
+ var sDetail = null;
+ if(sSource) {
+ var spaceIndex = sSource.indexOf(" ");
+ if(spaceIndex > 0) {
+ sClass = sSource.substring(0,spaceIndex);// substring until first space
+ sDetail = sSource.substring(spaceIndex,sSource.length);// the rest of the source
+ }
+ else {
+ sClass = sSource;
+ }
+ if(this._isNewSource(sClass)) {
+ this._createNewSource(sClass);
+ }
+ }
+
+ var timestamp = new Date();
+ var logEntry = {
+ time: timestamp,
+ category: sCategory,
+ source: sClass,
+ sourceDetail: sDetail,
+ msg: sMsg
+ };
+
+ this._stack.push(logEntry);
+ this.newLogEvent.fire(logEntry);
+
+ if(this._firebugEnabled) {
+ this._printToFirebug(logEntry);
+ }
+ return true;
+ }
+ else {
+ return false;
+ }
+};
+
+/**
+ * Resets internal stack and startTime, enables Logger, and fires logResetEvent.
+ *
+ */
+YAHOO.widget.Logger.reset = function() {
+ this._stack = [];
+ this._startTime = new Date().getTime();
+ this.loggerEnabled = true;
+ this.log(null, "Logger reset");
+ this.logResetEvent.fire();
+};
+
+/**
+ * Public accessor to internal stack of log messages.
+ *
+ * @return {array} Array of log messages.
+ */
+YAHOO.widget.Logger.getStack = function() {
+ return this._stack;
+};
+
+/**
+ * Public accessor to internal start time.
+ *
+ * @return {date} Internal date of when Logger singleton was initialized.
+ */
+YAHOO.widget.Logger.getStartTime = function() {
+ return this._startTime;
+};
+
+/**
+ * Disables output to the Firebug Firefox extension.
+ */
+YAHOO.widget.Logger.disableFirebug = function() {
+ YAHOO.log("YAHOO.Logger output to Firebug has been disabled.");
+ this._firebugEnabled = false;
+};
+
+/**
+ * Enables output to the Firebug Firefox extension.
+ */
+YAHOO.widget.Logger.enableFirebug = function() {
+ this._firebugEnabled = true;
+ YAHOO.log("YAHOO.Logger output to Firebug has been enabled.");
+};
+
+/***************************************************************************
+ * Private methods
+ ***************************************************************************/
+/**
+ * Creates a new category of log messages and fires categoryCreateEvent.
+ *
+ * @param {string} category Category name
+ * @private
+ */
+YAHOO.widget.Logger._createNewCategory = function(category) {
+ this.categories.push(category);
+ this.categoryCreateEvent.fire(category);
+};
+
+/**
+ * Checks to see if a category has already been created.
+ *
+ * @param {string} category Category name
+ * @return {boolean} Returns true if category is unknown, else returns false
+ * @private
+ */
+YAHOO.widget.Logger._isNewCategory = function(category) {
+ for(var i=0; i < this.categories.length; i++) {
+ if(category == this.categories[i]) {
+ return false;
+ }
+ }
+ return true;
+};
+
+/**
+ * Creates a new source of log messages and fires sourceCreateEvent.
+ *
+ * @param {string} source Source name
+ * @private
+ */
+YAHOO.widget.Logger._createNewSource = function(source) {
+ this.sources.push(source);
+ this.sourceCreateEvent.fire(source);
+};
+
+/**
+ * Checks to see if a source has already been created.
+ *
+ * @param {string} source Source name
+ * @return {boolean} Returns true if source is unknown, else returns false
+ * @private
+ */
+YAHOO.widget.Logger._isNewSource = function(source) {
+ if(source) {
+ for(var i=0; i < this.sources.length; i++) {
+ if(source == this.sources[i]) {
+ return false;
+ }
+ }
+ return true;
+ }
+};
+
+/**
+ * Outputs a log message to Firebug.
+ *
+ * @param {object} entry Log entry object
+ * @private
+ */
+YAHOO.widget.Logger._printToFirebug = function(entry) {
+ if(window.console && console.log) {
+ var category = entry.category;
+ var label = entry.category.substring(0,4).toUpperCase();
+
+ var time = entry.time;
+ if (time.toLocaleTimeString) {
+ var localTime = time.toLocaleTimeString();
+ }
+ else {
+ localTime = time.toString();
+ }
+
+ var msecs = time.getTime();
+ var elapsedTime = (YAHOO.widget.Logger._lastTime) ?
+ (msecs - YAHOO.widget.Logger._lastTime) : 0;
+ YAHOO.widget.Logger._lastTime = msecs;
+
+ var output = //Firebug doesn't support HTML "<span class='"+category+"'>"+label+"</span> " +
+ localTime + " (" +
+ elapsedTime + "ms): " +
+ entry.source + ": " +
+ entry.msg;
+
+
+ console.log(output);
+ }
+};
+
+/***************************************************************************
+ * Private event handlers
+ ***************************************************************************/
+/**
+ * Handles logging of messages due to window error events.
+ *
+ * @param {string} msg The error message
+ * @param {string} url URL of the error
+ * @param {string} line Line number of the error
+ * @private
+ */
+YAHOO.widget.Logger._onWindowError = function(msg,url,line) {
+ // Logger is not in scope of this event handler
+ try {
+ YAHOO.widget.Logger.log(msg+' ('+url+', line '+line+')', "window");
+ if(YAHOO.widget.Logger._origOnWindowError) {
+ YAHOO.widget.Logger._origOnWindowError();
+ }
+ }
+ catch(e) {
+ return false;
+ }
+};
+
+/**
+ * Handle native JavaScript errors
+ */
+//NB: Not all browsers support the window.onerror event
+if(window.onerror) {
+ // Save any previously defined handler to call
+ YAHOO.widget.Logger._origOnWindowError = window.onerror;
+}
+window.onerror = YAHOO.widget.Logger._onWindowError;
+
+/**
+ * First log
+ */
+YAHOO.widget.Logger.log("Logger initialized");
+
+/****************************************************************************/
+/****************************************************************************/
+/****************************************************************************/
+/**
+ * Class providing ability to log messages through YAHOO.widget.Logger from a
+ * named source.
+ *
+ * @constructor
+ * @param {string} sSource Source of LogWriter instance
+ */
+YAHOO.widget.LogWriter = function(sSource) {
+ if(!sSource) {
+ YAHOO.log("Could not instantiate LogWriter due to invalid source.", "error", "LogWriter");
+ return;
+ }
+ this._source = sSource;
+ };
+
+/***************************************************************************
+ * Public methods
+ ***************************************************************************/
+ /**
+ * Public accessor to the unique name of the LogWriter instance.
+ *
+ * @return {string} Unique name of the LogWriter instance
+ */
+YAHOO.widget.LogWriter.prototype.toString = function() {
+ return "LogWriter " + this._sSource;
+};
+
+/**
+ * Logs a message attached to the source of the LogWriter.
+ *
+ * @param {string} sMsg The log message
+ * @param {string} sCategory Category name
+ */
+YAHOO.widget.LogWriter.prototype.log = function(sMsg, sCategory) {
+ YAHOO.widget.Logger.log(sMsg, sCategory, this._source);
+};
+
+/**
+ * Public accessor to get the source name.
+ *
+ * @return {string} The LogWriter source
+ */
+YAHOO.widget.LogWriter.prototype.getSource = function() {
+ return this._sSource;
+};
+
+/**
+ * Public accessor to set the source name.
+ *
+ * @param {string} sSource Source of LogWriter instance
+ */
+YAHOO.widget.LogWriter.prototype.setSource = function(sSource) {
+ if(!sSource) {
+ YAHOO.log("Could not set source due to invalid source.", "error", this.toString());
+ return;
+ }
+ else {
+ this._sSource = sSource;
+ }
+};
+/***************************************************************************
+ * Private members
+ ***************************************************************************/
+/**
+ * Source of the log writer instance.
+ *
+ * @type string
+ * @private
+ */
+YAHOO.widget.LogWriter.prototype._source = null;
+
+
+
+/****************************************************************************/
+/****************************************************************************/
+/****************************************************************************/
+
+/**
+ * Class providing UI to read messages logged to YAHOO.widget.Logger.
+ *
+ * requires YAHOO.util.Dom DOM utility
+ * requires YAHOO.util.Event Event utility
+ * optional YAHOO.util.DragDrop Drag and drop utility
+ *
+ * @constructor
+ * @param {el or ID} containerEl DOM element object or ID of container to wrap reader UI
+ * @param {object} oConfig Optional object literal of configuration params
+ */
+YAHOO.widget.LogReader = function(containerEl, oConfig) {
+ var oSelf = this;
+
+ // Parse config vars here
+ if (typeof oConfig == "object") {
+ for(var param in oConfig) {
+ this[param] = oConfig[param];
+ }
+ }
+
+ // Attach container...
+ if(containerEl) {
+ if(typeof containerEl == "string") {
+ this._containerEl = document.getElementById(containerEl);
+ }
+ else if(containerEl.tagName) {
+ this._containerEl = containerEl;
+ }
+ this._containerEl.className = "yui-log";
+ }
+ // ...or create container from scratch
+ if(!this._containerEl) {
+ if(YAHOO.widget.LogReader._defaultContainerEl) {
+ this._containerEl = YAHOO.widget.LogReader._defaultContainerEl;
+ }
+ else {
+ this._containerEl = document.body.appendChild(document.createElement("div"));
+ this._containerEl.id = "yui-log";
+ this._containerEl.className = "yui-log";
+
+ YAHOO.widget.LogReader._defaultContainerEl = this._containerEl;
+ }
+
+ // If implementer has provided container values, trust and set those
+ var containerStyle = this._containerEl.style;
+ if(this.width) {
+ containerStyle.width = this.width;
+ }
+ if(this.left) {
+ containerStyle.left = this.left;
+ }
+ if(this.right) {
+ containerStyle.right = this.right;
+ }
+ if(this.bottom) {
+ containerStyle.bottom = this.bottom;
+ }
+ if(this.top) {
+ containerStyle.top = this.top;
+ }
+ if(this.fontSize) {
+ containerStyle.fontSize = this.fontSize;
+ }
+ }
+
+ if(this._containerEl) {
+ // Create header
+ if(!this._hdEl) {
+ this._hdEl = this._containerEl.appendChild(document.createElement("div"));
+ this._hdEl.id = "yui-log-hd" + YAHOO.widget.LogReader._index;
+ this._hdEl.className = "yui-log-hd";
+
+ this._collapseEl = this._hdEl.appendChild(document.createElement("div"));
+ this._collapseEl.className = "yui-log-btns";
+
+ this._collapseBtn = document.createElement("input");
+ this._collapseBtn.type = "button";
+ this._collapseBtn.style.fontSize = YAHOO.util.Dom.getStyle(this._containerEl,"fontSize");
+ this._collapseBtn.className = "yui-log-button";
+ this._collapseBtn.value = "Collapse";
+ this._collapseBtn = this._collapseEl.appendChild(this._collapseBtn);
+ YAHOO.util.Event.addListener(oSelf._collapseBtn,'click',oSelf._onClickCollapseBtn,oSelf);
+
+ this._title = this._hdEl.appendChild(document.createElement("h4"));
+ this._title.innerHTML = "Logger Console";
+
+ // If Drag and Drop utility is available...
+ // ...and this container was created from scratch...
+ // ...then make the header draggable
+ if(YAHOO.util.DD &&
+ (YAHOO.widget.LogReader._defaultContainerEl == this._containerEl)) {
+ var ylog_dd = new YAHOO.util.DD(this._containerEl.id);
+ ylog_dd.setHandleElId(this._hdEl.id);
+ this._hdEl.style.cursor = "move";
+ }
+ }
+ // Ceate console
+ if(!this._consoleEl) {
+ this._consoleEl = this._containerEl.appendChild(document.createElement("div"));
+ this._consoleEl.className = "yui-log-bd";
+
+ // If implementer has provided console, trust and set those
+ if(this.height) {
+ this._consoleEl.style.height = this.height;
+ }
+ }
+ // Don't create footer if disabled
+ if(!this._ftEl && this.footerEnabled) {
+ this._ftEl = this._containerEl.appendChild(document.createElement("div"));
+ this._ftEl.className = "yui-log-ft";
+
+ this._btnsEl = this._ftEl.appendChild(document.createElement("div"));
+ this._btnsEl.className = "yui-log-btns";
+
+ this._pauseBtn = document.createElement("input");
+ this._pauseBtn.type = "button";
+ this._pauseBtn.style.fontSize = YAHOO.util.Dom.getStyle(this._containerEl,"fontSize");
+ this._pauseBtn.className = "yui-log-button";
+ this._pauseBtn.value = "Pause";
+ this._pauseBtn = this._btnsEl.appendChild(this._pauseBtn);
+ YAHOO.util.Event.addListener(oSelf._pauseBtn,'click',oSelf._onClickPauseBtn,oSelf);
+
+ this._clearBtn = document.createElement("input");
+ this._clearBtn.type = "button";
+ this._clearBtn.style.fontSize = YAHOO.util.Dom.getStyle(this._containerEl,"fontSize");
+ this._clearBtn.className = "yui-log-button";
+ this._clearBtn.value = "Clear";
+ this._clearBtn = this._btnsEl.appendChild(this._clearBtn);
+ YAHOO.util.Event.addListener(oSelf._clearBtn,'click',oSelf._onClickClearBtn,oSelf);
+
+ this._categoryFiltersEl = this._ftEl.appendChild(document.createElement("div"));
+ this._categoryFiltersEl.className = "yui-log-categoryfilters";
+ this._sourceFiltersEl = this._ftEl.appendChild(document.createElement("div"));
+ this._sourceFiltersEl.className = "yui-log-sourcefilters";
+ }
+ }
+
+ // Initialize buffer
+ if(!this._buffer) {
+ this._buffer = []; // output buffer
+ }
+ YAHOO.widget.Logger.newLogEvent.subscribe(this._onNewLog, this);
+ this._lastTime = YAHOO.widget.Logger.getStartTime(); // timestamp of last log message to console
+
+ // Initialize category filters
+ this._categoryFilters = [];
+ var catsLen = YAHOO.widget.Logger.categories.length;
+ if(this._categoryFiltersEl) {
+ for(var i=0; i < catsLen; i++) {
+ this._createCategoryCheckbox(YAHOO.widget.Logger.categories[i]);
+ }
+ }
+ // Initialize source filters
+ this._sourceFilters = [];
+ var sourcesLen = YAHOO.widget.Logger.sources.length;
+ if(this._sourceFiltersEl) {
+ for(var j=0; j < sourcesLen; j++) {
+ this._createSourceCheckbox(YAHOO.widget.Logger.sources[j]);
+ }
+ }
+ YAHOO.widget.Logger.categoryCreateEvent.subscribe(this._onCategoryCreate, this);
+ YAHOO.widget.Logger.sourceCreateEvent.subscribe(this._onSourceCreate, this);
+
+ YAHOO.widget.LogReader._index++;
+ this._filterLogs();
+};
+
+/***************************************************************************
+ * Public members
+ ***************************************************************************/
+/**
+ * Whether or not the log reader is enabled to output log messages. Default:
+ * true.
+ *
+ * @type boolean
+ */
+YAHOO.widget.LogReader.prototype.logReaderEnabled = true;
+
+/**
+ * Public member to access CSS width of the log reader container.
+ *
+ * @type string
+ */
+YAHOO.widget.LogReader.prototype.width = null;
+
+/**
+ * Public member to access CSS height of the log reader container.
+ *
+ * @type string
+ */
+YAHOO.widget.LogReader.prototype.height = null;
+
+/**
+ * Public member to access CSS top position of the log reader container.
+ *
+ * @type string
+ */
+YAHOO.widget.LogReader.prototype.top = null;
+
+/**
+ * Public member to access CSS left position of the log reader container.
+ *
+ * @type string
+ */
+YAHOO.widget.LogReader.prototype.left = null;
+
+/**
+ * Public member to access CSS right position of the log reader container.
+ *
+ * @type string
+ */
+YAHOO.widget.LogReader.prototype.right = null;
+
+/**
+ * Public member to access CSS bottom position of the log reader container.
+ *
+ * @type string
+ */
+YAHOO.widget.LogReader.prototype.bottom = null;
+
+/**
+ * Public member to access CSS font size of the log reader container.
+ *
+ * @type string
+ */
+YAHOO.widget.LogReader.prototype.fontSize = null;
+
+/**
+ * Whether or not the footer UI is enabled for the log reader. Default: true.
+ *
+ * @type boolean
+ */
+YAHOO.widget.LogReader.prototype.footerEnabled = true;
+
+/**
+ * Whether or not output is verbose (more readable). Setting to true will make
+ * output more compact (less readable). Default: true.
+ *
+ * @type boolean
+ */
+YAHOO.widget.LogReader.prototype.verboseOutput = true;
+
+/**
+ * Whether or not newest message is printed on top. Default: true.
+ *
+ * @type boolean
+ */
+YAHOO.widget.LogReader.prototype.newestOnTop = true;
+
+/***************************************************************************
+ * Public methods
+ ***************************************************************************/
+/**
+ * Pauses output of log messages. While paused, log messages are not lost, but
+ * get saved to a buffer and then output upon resume of log reader.
+ */
+YAHOO.widget.LogReader.prototype.pause = function() {
+ this._timeout = null;
+ this.logReaderEnabled = false;
+};
+
+/**
+ * Resumes output of log messages, including outputting any log messages that
+ * have been saved to buffer while paused.
+ */
+YAHOO.widget.LogReader.prototype.resume = function() {
+ this.logReaderEnabled = true;
+ this._printBuffer();
+};
+
+/**
+ * Hides UI of log reader. Logging functionality is not disrupted.
+ */
+YAHOO.widget.LogReader.prototype.hide = function() {
+ this._containerEl.style.display = "none";
+};
+
+/**
+ * Shows UI of log reader. Logging functionality is not disrupted.
+ */
+YAHOO.widget.LogReader.prototype.show = function() {
+ this._containerEl.style.display = "block";
+};
+
+/**
+ * Updates title to given string.
+ *
+ * @param {string} sTitle String to display in log reader's title bar.
+ */
+YAHOO.widget.LogReader.prototype.setTitle = function(sTitle) {
+ var regEx = />/g;
+ sTitle = sTitle.replace(regEx,">");
+ regEx = /</g;
+ sTitle = sTitle.replace(regEx,"<");
+ this._title.innerHTML = (sTitle);
+};
+ /***************************************************************************
+ * Private members
+ ***************************************************************************/
+/**
+ * Internal class member to index multiple log reader instances.
+ *
+ * @type number
+ * @private
+ */
+YAHOO.widget.LogReader._index = 0;
+
+/**
+ * A class member shared by all log readers if a container needs to be
+ * created during instantiation. Will be null if a container element never needs to
+ * be created on the fly, such as when the implementer passes in their own element.
+ *
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.LogReader._defaultContainerEl = null;
+
+/**
+ * Buffer of log messages for batch output.
+ *
+ * @type array
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._buffer = null;
+
+/**
+ * Date of last output log message.
+ *
+ * @type date
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._lastTime = null;
+
+/**
+ * Batched output timeout ID.
+ *
+ * @type number
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._timeout = null;
+
+/**
+ * Array of filters for log message categories.
+ *
+ * @type array
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._categoryFilters = null;
+
+/**
+ * Array of filters for log message sources.
+ *
+ * @type array
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._sourceFilters = null;
+
+/**
+ * Log reader container element.
+ *
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._containerEl = null;
+
+/**
+ * Log reader header element.
+ *
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._hdEl = null;
+
+/**
+ * Log reader collapse element.
+ *
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._collapseEl = null;
+
+/**
+ * Log reader collapse button element.
+ *
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._collapseBtn = null;
+
+/**
+ * Log reader title header element.
+ *
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._title = null;
+
+/**
+ * Log reader console element.
+ *
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._consoleEl = null;
+
+/**
+ * Log reader footer element.
+ *
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._ftEl = null;
+
+/**
+ * Log reader buttons container element.
+ *
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._btnsEl = null;
+
+/**
+ * Container element for log reader category filter checkboxes.
+ *
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._categoryFiltersEl = null;
+
+/**
+ * Container element for log reader source filter checkboxes.
+ *
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._sourceFiltersEl = null;
+
+/**
+ * Log reader pause button element.
+ *
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._pauseBtn = null;
+
+/**
+ * lear button element.
+ *
+ * @type HTMLElement
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._clearBtn = null;
+/***************************************************************************
+ * Private methods
+ ***************************************************************************/
+/**
+ * Creates the UI for a category filter in the log reader footer element.
+ *
+ * @param {string} category Category name
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._createCategoryCheckbox = function(category) {
+ var oSelf = this;
+
+ if(this._ftEl) {
+ var parentEl = this._categoryFiltersEl;
+ var filters = this._categoryFilters;
+
+ var filterEl = parentEl.appendChild(document.createElement("span"));
+ filterEl.className = "yui-log-filtergrp";
+ // Append el at the end so IE 5.5 can set "type" attribute
+ // and THEN set checked property
+ var categoryChk = document.createElement("input");
+ categoryChk.id = "yui-log-filter-" + category + YAHOO.widget.LogReader._index;
+ categoryChk.className = "yui-log-filter-" + category;
+ categoryChk.type = "checkbox";
+ categoryChk.category = category;
+ categoryChk = filterEl.appendChild(categoryChk);
+ categoryChk.checked = true;
+
+ // Add this checked filter to the internal array of filters
+ filters.push(category);
+ // Subscribe to the click event
+ YAHOO.util.Event.addListener(categoryChk,'click',oSelf._onCheckCategory,oSelf);
+
+ // Create and class the text label
+ var categoryChkLbl = filterEl.appendChild(document.createElement("label"));
+ categoryChkLbl.htmlFor = categoryChk.id;
+ categoryChkLbl.className = category;
+ categoryChkLbl.innerHTML = category;
+ }
+};
+
+YAHOO.widget.LogReader.prototype._createSourceCheckbox = function(source) {
+ var oSelf = this;
+
+ if(this._ftEl) {
+ var parentEl = this._sourceFiltersEl;
+ var filters = this._sourceFilters;
+
+ var filterEl = parentEl.appendChild(document.createElement("span"));
+ filterEl.className = "yui-log-filtergrp";
+
+ // Append el at the end so IE 5.5 can set "type" attribute
+ // and THEN set checked property
+ var sourceChk = document.createElement("input");
+ sourceChk.id = "yui-log-filter" + source + YAHOO.widget.LogReader._index;
+ sourceChk.className = "yui-log-filter" + source;
+ sourceChk.type = "checkbox";
+ sourceChk.source = source;
+ sourceChk = filterEl.appendChild(sourceChk);
+ sourceChk.checked = true;
+
+ // Add this checked filter to the internal array of filters
+ filters.push(source);
+ // Subscribe to the click event
+ YAHOO.util.Event.addListener(sourceChk,'click',oSelf._onCheckSource,oSelf);
+
+ // Create and class the text label
+ var sourceChkLbl = filterEl.appendChild(document.createElement("label"));
+ sourceChkLbl.htmlFor = sourceChk.id;
+ sourceChkLbl.className = source;
+ sourceChkLbl.innerHTML = source;
+ }
+};
+
+/**
+ * Reprints all log messages in the stack through filters.
+ *
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._filterLogs = function() {
+ // Reprint stack with new filters
+ if (this._consoleEl !== null) {
+ this._clearConsole();
+ this._printToConsole(YAHOO.widget.Logger.getStack());
+ }
+};
+
+/**
+ * Clears all outputted log messages from the console and resets the time of the
+ * last output log message.
+ *
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._clearConsole = function() {
+ // Clear the buffer of any pending messages
+ this._timeout = null;
+ this._buffer = [];
+
+ // Reset the rolling timer
+ this._lastTime = YAHOO.widget.Logger.getStartTime();
+
+ var consoleEl = this._consoleEl;
+ while(consoleEl.hasChildNodes()) {
+ consoleEl.removeChild(consoleEl.firstChild);
+ }
+};
+
+/**
+ * Sends buffer of log messages to output and clears buffer.
+ *
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._printBuffer = function() {
+ this._timeout = null;
+
+ if (this._consoleEl !== null) {
+ var entries = [];
+ for (var i=0; i<this._buffer.length; i++) {
+ entries[i] = this._buffer[i];
+ }
+ this._buffer = [];
+ this._printToConsole(entries);
+ if(!this.newestOnTop) {
+ this._consoleEl.scrollTop = this._consoleEl.scrollHeight;
+ }
+ }
+};
+
+/**
+ * Cycles through an array of log messages, and outputs each one to the console
+ * if its category has not been filtered out.
+ *
+ * @param {array} aEntries
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._printToConsole = function(aEntries) {
+ var entriesLen = aEntries.length;
+ var sourceFiltersLen = this._sourceFilters.length;
+ var categoryFiltersLen = this._categoryFilters.length;
+ // Iterate through all log entries to print the ones that filter through
+ for(var i=0; i<entriesLen; i++) {
+ var entry = aEntries[i];
+ var category = entry.category;
+ var source = entry.source;
+ var sourceDetail = entry.sourceDetail;
+ var okToPrint = false;
+ var okToFilterCats = false;
+
+ for(var j=0; j<sourceFiltersLen; j++) {
+ if(source == this._sourceFilters[j]) {
+ okToFilterCats = true;
+ break;
+ }
+ }
+ if(okToFilterCats) {
+ for(var k=0; k<categoryFiltersLen; k++) {
+ if(category == this._categoryFilters[k]) {
+ okToPrint = true;
+ break;
+ }
+ }
+ }
+ if(okToPrint) {
+ // To format for console, calculate the elapsed time
+ // to be from the last item that passed through the filter,
+ // not the absolute previous item in the stack
+ var label = entry.category.substring(0,4).toUpperCase();
+
+ var time = entry.time;
+ if (time.toLocaleTimeString) {
+ var localTime = time.toLocaleTimeString();
+ }
+ else {
+ localTime = time.toString();
+ }
+
+ var msecs = time.getTime();
+ var startTime = YAHOO.widget.Logger.getStartTime();
+ var totalTime = msecs - startTime;
+ var elapsedTime = msecs - this._lastTime;
+ this._lastTime = msecs;
+
+ var verboseOutput = (this.verboseOutput) ? "<br>" : "";
+ var sourceAndDetail = (sourceDetail) ?
+ source + " " + sourceDetail : source;
+
+ var output = "<span class='"+category+"'>"+label+"</span> " +
+ totalTime + "ms (+" +
+ elapsedTime + ") " + localTime + ": " +
+ sourceAndDetail + ": " +
+ verboseOutput +
+ entry.msg;
+
+ var oNewElement = (this.newestOnTop) ?
+ this._consoleEl.insertBefore(document.createElement("p"),this._consoleEl.firstChild):
+ this._consoleEl.appendChild(document.createElement("p"));
+ oNewElement.innerHTML = output;
+ }
+ }
+};
+
+/***************************************************************************
+ * Private event handlers
+ ***************************************************************************/
+/**
+ * Handles Logger's categoryCreateEvent.
+ *
+ * @param {string} type The event
+ * @param {array} args Data passed from event firer
+ * @param {object} oSelf The log reader instance
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._onCategoryCreate = function(type, args, oSelf) {
+ var category = args[0];
+ if(oSelf._ftEl) {
+ oSelf._createCategoryCheckbox(category);
+ }
+};
+
+/**
+ * Handles Logger's sourceCreateEvent.
+ *
+ * @param {string} type The event
+ * @param {array} args Data passed from event firer
+ * @param {object} oSelf The log reader instance
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._onSourceCreate = function(type, args, oSelf) {
+ var source = args[0];
+ if(oSelf._ftEl) {
+ oSelf._createSourceCheckbox(source);
+ }
+};
+
+/**
+ * Handles check events on the category filter checkboxes.
+ *
+ * @param {event} v The click event
+ * @param {object} oSelf The log reader instance
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._onCheckCategory = function(v, oSelf) {
+ var newFilter = this.category;
+ var filtersArray = oSelf._categoryFilters;
+
+ if(!this.checked) { // Remove category from filters
+ for(var i=0; i<filtersArray.length; i++) {
+ if(newFilter == filtersArray[i]) {
+ filtersArray.splice(i, 1);
+ break;
+ }
+ }
+ }
+ else { // Add category to filters
+ filtersArray.push(newFilter);
+ }
+ oSelf._filterLogs();
+};
+
+/**
+ * Handles check events on the category filter checkboxes.
+ *
+ * @param {event} v The click event
+ * @param {object} oSelf The log reader instance
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._onCheckSource = function(v, oSelf) {
+ var newFilter = this.source;
+ var filtersArray = oSelf._sourceFilters;
+
+ if(!this.checked) { // Remove category from filters
+ for(var i=0; i<filtersArray.length; i++) {
+ if(newFilter == filtersArray[i]) {
+ filtersArray.splice(i, 1);
+ break;
+ }
+ }
+ }
+ else { // Add category to filters
+ filtersArray.push(newFilter);
+ }
+ oSelf._filterLogs();
+};
+
+/**
+ * Handles click events on the collapse button.
+ *
+ * @param {event} v The click event
+ * @param {object} oSelf The log reader instance
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._onClickCollapseBtn = function(v, oSelf) {
+ var btn = oSelf._collapseBtn;
+ if(btn.value == "Expand") {
+ oSelf._consoleEl.style.display = "block";
+ if(oSelf._ftEl) {
+ oSelf._ftEl.style.display = "block";
+ }
+ btn.value = "Collapse";
+ }
+ else {
+ oSelf._consoleEl.style.display = "none";
+ if(oSelf._ftEl) {
+ oSelf._ftEl.style.display = "none";
+ }
+ btn.value = "Expand";
+ }
+};
+
+/**
+ * Handles click events on the pause button.
+ *
+ * @param {event} v The click event
+ * @param {object} oSelf The log reader instance
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._onClickPauseBtn = function(v, oSelf) {
+ var btn = oSelf._pauseBtn;
+ if(btn.value == "Resume") {
+ oSelf.resume();
+ btn.value = "Pause";
+ }
+ else {
+ oSelf.pause();
+ btn.value = "Resume";
+ }
+};
+
+/**
+ * Handles click events on the clear button.
+ *
+ * @param {event} v The click event
+ * @param {object} oSelf The log reader instance
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._onClickClearBtn = function(v, oSelf) {
+ oSelf._clearConsole();
+};
+
+/**
+ * Handles Logger's onNewEvent.
+ *
+ * @param {string} type The click event
+ * @param {array} args Data passed from event firer
+ * @param {object} oSelf The log reader instance
+ * @private
+ */
+YAHOO.widget.LogReader.prototype._onNewLog = function(type, args, oSelf) {
+ var logEntry = args[0];
+ oSelf._buffer.push(logEntry);
+
+ if (oSelf.logReaderEnabled === true && oSelf._timeout === null) {
+ oSelf._timeout = setTimeout(function(){oSelf._printBuffer();}, 100);
+ }
+};
+
+
Added: branches/tomek/portal-dnd/dndRenderer.war/js/menu/README
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/menu/README 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/menu/README 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,82 @@
+Menu Release Notes
+
+*** version 0.10.0 ***
+
+* Initial release
+
+* Known issues:
+
+ * Some Firefox extensions disable the ability for JavaScript to prevent
+ the display of the browser's default context menu. These extensions
+ can cause the YUI ContextMenu to stop working. If you encounter this
+ problem, you can reset the context menu preference in Firefox back to
+ the default by making sure the "Disable or replace context menus"
+ preference is checked:
+
+ Mac Firefox 1.0:
+ -------------------
+ Preferences > Web Features >
+ Advanced... > Disable or replace context menus
+
+ Mac Firefox 1.5
+ -------------------
+ Preferences > Context >
+ Advanced... > Disable or replace context menus
+
+ Windows Firefox 1.0
+ -------------------
+ Tools > Options > Web Features >
+ Advanced... > Disable or replace context menus
+
+ Windows Firefox 1.5
+ -------------------
+ Tools > Options > Context >
+ Advanced... > Disable or replace context menus
+
+
+*** version 0.11.0 ***
+
+Added the following features:
+-----------------------------
+* Overloaded the "addItem" and "insertItem" methods of MenuModule to accept a
+ string or a MenuModuleItem instance
+
+* Added the ability to define a MenuItem instance as being "checked"
+
+
+Fixed the following bugs:
+-------------------------
+* Changing the path for the submenu indicator image of one MenuModuleItem
+ subclass will no longer affect other subclasses
+
+* MenuItem instances built from existing markup without anchor tags will no
+ longer trigger a JavaScript error when clicked
+
+* Modified the implementation of the "imageRoot" property for the
+ MenuModuleItem class so that it is set to a secure/non-secure path when the
+ object is instantiated
+
+* Menu instances now resize in response to changes to the browser's font size
+
+* Modified the propagation of the MenuModule class's "submenualignment"
+ configuration property so that it only applies to instances of the same type
+
+* Adjusted the specificity of the style rule that controls the position of a
+ MenuItem instance's submenu indicator image to prevent it from wrapping in IE
+
+* Specified a width and height for submenu indicator images in the Menu
+ stylesheet to ensure that Menu instances are always rendered at the correct
+ width
+
+* Clicking a MenuItem instance will no longer trigger two HTTP GET requests
+
+* Users can now control or shift-click on MenuItem links
+
+
+Changes
+-------
+* In the Menu stylesheet (menu.css), switched from using "first" class to
+ "first-of-type" class
+
+* Changed case of MenuModuleItem class's "subMenuIndicator" property
+ to "submenuIndicator"
\ No newline at end of file
Added: branches/tomek/portal-dnd/dndRenderer.war/js/menu/assets/menu.css
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/menu/assets/menu.css 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/menu/assets/menu.css 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,288 @@
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+Version 0.11.0
+*/
+
+
+/* Menu styles */
+
+div.yuimenu {
+
+ z-index:1;
+ visibility:hidden;
+ background-color:#f6f7ee;
+ border:solid 1px #c4c4be;
+ padding:1px;
+
+}
+
+
+/* MenuBar Styles */
+
+div.yuimenubar {
+
+ background-color:#f6f7ee;
+
+}
+
+/*
+ Application of "zoom:1" triggers "haslayout" in IE so that the module's
+ body clears its floated elements
+*/
+div.yuimenubar div.bd {
+
+ zoom:1;
+
+}
+
+/*
+ Clear the module body for other browsers
+*/
+div.yuimenubar div.bd:after {
+
+ content:'.';
+ display:block;
+ clear:both;
+ visibility:hidden;
+ height:0;
+
+}
+
+
+/* Matches the group title (H6) inside a Menu or MenuBar instance */
+
+div.yuimenu h6,
+div.yuimenubar h6 {
+
+ font-size:100%;
+ font-weight:normal;
+ margin:0;
+ border:solid 1px #c4c4be;
+ color:#b9b9b9;
+
+}
+
+div.yuimenubar h6 {
+
+ float:left;
+ display:inline; /* Prevent margin doubling in IE */
+ padding:4px 12px;
+ border-width:0 1px 0 0;
+
+}
+
+div.yuimenu h6 {
+
+ float:none;
+ display:block;
+ border-width:1px 0 0 0;
+ padding:5px 10px 0 10px;
+
+}
+
+
+/* Matches the UL inside a Menu or MenuBar instance */
+
+div.yuimenubar ul {
+
+ list-style-type:none;
+ margin:0;
+ padding:0;
+ overflow:hidden;
+
+}
+
+div.yuimenu ul {
+
+ list-style-type:none;
+ border:solid 1px #c4c4be;
+ border-width:1px 0 0 0;
+ margin:0;
+ padding:10px 0;
+
+}
+
+
+div.yuimenu ul.first-of-type,
+div.yuimenu ul.hastitle,
+div.yuimenu h6.first-of-type {
+
+ border-width:0;
+
+}
+
+
+/* MenuItem and MenuBarItem styles */
+
+div.yuimenu li,
+div.yuimenubar li {
+
+ font-size:85%;
+ cursor:pointer;
+ cursor:hand;
+ white-space:nowrap;
+ text-align:left;
+
+}
+
+div.yuimenu li.yuimenuitem {
+
+ padding:2px 24px;
+
+}
+
+div.yuimenu li li,
+div.yuimenubar li li {
+
+ font-size:100%;
+
+}
+
+
+/* Matches the help text for a menu item */
+
+div.yuimenu li em {
+
+ font-style:normal;
+ margin:0 0 0 40px;
+
+}
+
+div.yuimenu li a em {
+
+ margin:0;
+
+}
+
+div.yuimenu li a,
+div.yuimenubar li a {
+
+ /*
+ "zoom:1" triggers "haslayout" in IE to ensure that the mouseover and
+ mouseout events bubble to the parent LI in IE.
+ */
+ zoom:1;
+ color:#000;
+ text-decoration:none;
+
+}
+
+div.yuimenu li.hassubmenu,
+div.yuimenu li.hashelptext {
+
+ text-align:right;
+
+}
+
+div.yuimenu li.hassubmenu a.hassubmenu,
+div.yuimenu li.hashelptext a.hashelptext {
+
+ float:left;
+ display:inline; /* Prevent margin doubling in IE */
+ text-align:left;
+
+}
+
+
+/* Matches focused and selected menu items */
+
+div.yuimenu li.selected,
+div.yuimenubar li.selected {
+
+ background-color:#8c8ad0;
+
+}
+
+div.yuimenu li.selected a.selected,
+div.yuimenubar li.selected a.selected {
+
+ text-decoration:underline;
+
+}
+
+div.yuimenu li.selected a.selected,
+div.yuimenu li.selected em.selected,
+div.yuimenubar li.selected a.selected {
+
+ color:#fff;
+
+}
+
+
+/* Matches disabled menu items */
+
+div.yuimenu li.disabled,
+div.yuimenubar li.disabled {
+
+ cursor:default;
+
+}
+
+div.yuimenu li.disabled a.disabled,
+div.yuimenu li.disabled em.disabled,
+div.yuimenubar li.disabled a.disabled {
+
+ color:#b9b9b9;
+ cursor:default;
+
+}
+
+div.yuimenubar li.yuimenubaritem {
+
+ float:left;
+ display:inline; /* Prevent margin doubling in IE */
+ border-width:0 0 0 1px;
+ border-style:solid;
+ border-color:#c4c4be;
+ padding:4px 24px;
+ margin:0;
+
+}
+
+div.yuimenubar li.yuimenubaritem.first-of-type {
+
+ border-width:0;
+
+}
+
+
+/* Matches the submenu indicator for menu items */
+
+div.yuimenubar li.yuimenubaritem img {
+
+ height:8px;
+ width:8px;
+ margin:0 0 0 10px;
+ vertical-align:middle;
+
+}
+
+div.yuimenu li.yuimenuitem img {
+
+ height:8px;
+ width:8px;
+ margin:0 -16px 0 10px;
+ border:0;
+
+}
+
+div.yuimenu li.checked {
+
+ position:relative;
+
+}
+
+div.yuimenu li.checked img.checked {
+
+ height:8px;
+ width:8px;
+ margin:0;
+ border:0;
+ position:absolute;
+ left:6px;
+ _left:-16px; /* Underscore hack b/c this is for IE 5.5 and IE 6 only */
+ top:.5em;
+
+}
\ No newline at end of file
Added: branches/tomek/portal-dnd/dndRenderer.war/js/menu/assets/menuarodwn8_dim_1.gif
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/dndRenderer.war/js/menu/assets/menuarodwn8_dim_1.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/dndRenderer.war/js/menu/assets/menuarodwn8_hov_1.gif
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/dndRenderer.war/js/menu/assets/menuarodwn8_hov_1.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/dndRenderer.war/js/menu/assets/menuarodwn8_nrm_1.gif
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/dndRenderer.war/js/menu/assets/menuarodwn8_nrm_1.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/dndRenderer.war/js/menu/assets/menuarorght8_dim_1.gif
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/dndRenderer.war/js/menu/assets/menuarorght8_dim_1.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/dndRenderer.war/js/menu/assets/menuarorght8_hov_1.gif
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/dndRenderer.war/js/menu/assets/menuarorght8_hov_1.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/dndRenderer.war/js/menu/assets/menuarorght8_nrm_1.gif
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/dndRenderer.war/js/menu/assets/menuarorght8_nrm_1.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/dndRenderer.war/js/menu/assets/menuchk8_dim_1.gif
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/dndRenderer.war/js/menu/assets/menuchk8_dim_1.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/dndRenderer.war/js/menu/assets/menuchk8_hov_1.gif
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/dndRenderer.war/js/menu/assets/menuchk8_hov_1.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/dndRenderer.war/js/menu/assets/menuchk8_nrm_1.gif
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/dndRenderer.war/js/menu/assets/menuchk8_nrm_1.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/dndRenderer.war/js/menu/menu-debug.js
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/menu/menu-debug.js 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/menu/menu-debug.js 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,5414 @@
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+Version 0.11.0
+*/
+
+
+/**
+* @class The superclass of all menu containers.
+* @constructor
+* @extends YAHOO.widget.Overlay
+* @base YAHOO.widget.Overlay
+* @param {String or HTMLElement} p_oElement String id or HTMLElement
+* (either HTMLSelectElement or HTMLDivElement) of the source HTMLElement node.
+* @param {Object} p_oConfig Optional. The configuration object literal
+* containing the configuration for a MenuModule instance. See
+* configuration class documentation for more details.
+*/
+YAHOO.widget.MenuModule = function(p_oElement, p_oConfig) {
+
+ YAHOO.widget.MenuModule.superclass.constructor.call(
+ this,
+ p_oElement,
+ p_oConfig
+ );
+
+};
+
+YAHOO.extend(YAHOO.widget.MenuModule, YAHOO.widget.Overlay);
+
+
+// Constants
+
+/**
+* Constant representing the CSS class(es) to be applied to the root
+* HTMLDivElement of the MenuModule instance.
+* @final
+* @type String
+*/
+YAHOO.widget.MenuModule.prototype.CSS_CLASS_NAME = "yuimenu";
+
+
+/**
+* Constant representing the type of item to instantiate and add when parsing
+* the child nodes (either HTMLLIElement, HTMLOptGroupElement or
+* HTMLOptionElement) of a menu's DOM. The default
+* is YAHOO.widget.MenuModuleItem.
+* @final
+* @type YAHOO.widget.MenuModuleItem
+*/
+YAHOO.widget.MenuModule.prototype.ITEM_TYPE = null;
+
+
+/**
+* Constant representing the tagname of the HTMLElement used to title
+* a group of items.
+* @final
+* @type String
+*/
+YAHOO.widget.MenuModule.prototype.GROUP_TITLE_TAG_NAME = "H6";
+
+
+// Private properties
+
+/**
+* Array of HTMLElements used to title groups of items.
+* @private
+* @type {Array}
+*/
+YAHOO.widget.MenuModule.prototype._aGroupTitleElements = null;
+
+
+/**
+* Multi-dimensional array of items.
+* @private
+* @type {Array}
+*/
+YAHOO.widget.MenuModule.prototype._aItemGroups = null;
+
+
+/**
+* An array of HTMLUListElements, each of which is the parent node of each
+* items's HTMLLIElement node.
+* @private
+* @type {Array}
+*/
+YAHOO.widget.MenuModule.prototype._aListElements = null;
+
+
+/**
+* Reference to the Event utility singleton.
+* @private
+* @type {YAHOO.util.Event}
+*/
+YAHOO.widget.MenuModule.prototype._oEventUtil = YAHOO.util.Event;
+
+
+/**
+* Reference to the Dom utility singleton.
+* @private
+* @type {YAHOO.util.Dom}
+*/
+YAHOO.widget.MenuModule.prototype._oDom = YAHOO.util.Dom;
+
+
+/**
+* Reference to the item the mouse is currently over.
+* @private
+* @type {YAHOO.widget.MenuModuleItem}
+*/
+YAHOO.widget.MenuModule.prototype._oCurrentItem = null;
+
+
+/**
+* The current state of a MenuModule instance's "mouseover" event
+* @private
+* @type {Boolean}
+*/
+YAHOO.widget.MenuModule.prototype._bFiredMouseOverEvent = false;
+
+
+/**
+* The current state of a MenuModule instance's "mouseout" event
+* @private
+* @type {Boolean}
+*/
+YAHOO.widget.MenuModule.prototype._bFiredMouseOutEvent = false;
+
+
+// Public properties
+
+/**
+* Reference to the item that has focus.
+* @private
+* @type {YAHOO.widget.MenuModuleItem}
+*/
+YAHOO.widget.MenuModule.prototype.activeItem = null;
+
+
+/**
+* Returns a MenuModule instance's parent object.
+* @type {YAHOO.widget.MenuModuleItem}
+*/
+YAHOO.widget.MenuModule.prototype.parent = null;
+
+
+/**
+* Returns the HTMLElement (either HTMLSelectElement or HTMLDivElement)
+* used create the MenuModule instance.
+* @type {HTMLSelectElement/HTMLDivElement}
+*/
+YAHOO.widget.MenuModule.prototype.srcElement = null;
+
+
+// Events
+
+/**
+* Fires when the mouse has entered a MenuModule instance. Passes back the
+* DOM Event object as an argument.
+* @type {YAHOO.util.CustomEvent}
+* @see YAHOO.util.CustomEvent
+*/
+YAHOO.widget.MenuModule.prototype.mouseOverEvent = null;
+
+
+/**
+* Fires when the mouse has left a MenuModule instance. Passes back the DOM
+* Event object as an argument.
+* @type {YAHOO.util.CustomEvent}
+* @see YAHOO.util.CustomEvent
+*/
+YAHOO.widget.MenuModule.prototype.mouseOutEvent = null;
+
+
+/**
+* Fires when the user mouses down on a MenuModule instance. Passes back the
+* DOM Event object as an argument.
+* @type {YAHOO.util.CustomEvent}
+* @see YAHOO.util.CustomEvent
+*/
+YAHOO.widget.MenuModule.prototype.mouseDownEvent = null;
+
+
+/**
+* Fires when the user releases a mouse button while the mouse is over
+* a MenuModule instance. Passes back the DOM Event object as an argument.
+* @type {YAHOO.util.CustomEvent}
+* @see YAHOO.util.CustomEvent
+*/
+YAHOO.widget.MenuModule.prototype.mouseUpEvent = null;
+
+
+/**
+* Fires when the user clicks the on a MenuModule instance. Passes back the
+* DOM Event object as an argument.
+* @type {YAHOO.util.CustomEvent}
+* @see YAHOO.util.CustomEvent
+*/
+YAHOO.widget.MenuModule.prototype.clickEvent = null;
+
+
+/**
+* Fires when the user presses an alphanumeric key. Passes back the
+* DOM Event object as an argument.
+* @type {YAHOO.util.CustomEvent}
+* @see YAHOO.util.CustomEvent
+*/
+YAHOO.widget.MenuModule.prototype.keyPressEvent = null;
+
+
+/**
+* Fires when the user presses a key. Passes back the DOM Event
+* object as an argument.
+* @type {YAHOO.util.CustomEvent}
+* @see YAHOO.util.CustomEvent
+*/
+YAHOO.widget.MenuModule.prototype.keyDownEvent = null;
+
+
+/**
+* Fires when the user releases a key. Passes back the DOM Event
+* object as an argument.
+* @type {YAHOO.util.CustomEvent}
+* @see YAHOO.util.CustomEvent
+*/
+YAHOO.widget.MenuModule.prototype.keyUpEvent = null;
+
+
+/**
+* The MenuModule class's initialization method. This method is automatically
+* called by the constructor, and sets up all DOM references for
+* pre-existing markup, and creates required markup if it is not already present.
+* @param {String or HTMLElement} p_oElement String id or HTMLElement
+* (either HTMLSelectElement or HTMLDivElement) of the source HTMLElement node.
+* @param {Object} p_oConfig Optional. The configuration object literal
+* containing the configuration for a MenuModule instance. See
+* configuration class documentation for more details.
+*/
+YAHOO.widget.MenuModule.prototype.init = function(p_oElement, p_oConfig) {
+
+ var Dom = this._oDom;
+ var Event = this._oEventUtil;
+
+
+ if(!this.ITEM_TYPE) {
+
+ this.ITEM_TYPE = YAHOO.widget.MenuModuleItem;
+
+ }
+
+
+ this._aItemGroups = [];
+ this._aListElements = [];
+ this._aGroupTitleElements = [];
+
+
+ var oElement;
+
+ if(typeof p_oElement == "string") {
+
+ oElement = document.getElementById(p_oElement);
+
+ }
+ else if(p_oElement.tagName) {
+
+ oElement = p_oElement;
+
+ }
+
+
+ if(oElement) {
+
+ switch(oElement.tagName) {
+
+ case "DIV":
+
+ this.srcElement = oElement;
+
+ /*
+ Note: we don't pass the user config in here yet
+ because we only want it executed once, at the lowest
+ subclass level.
+ */
+
+ YAHOO.widget.MenuModule.superclass.init.call(this, oElement);
+
+ this.beforeInitEvent.fire(YAHOO.widget.MenuModule);
+
+
+ /*
+ Populate the collection of item groups and item
+ group titles
+ */
+
+ var oNode = this.body.firstChild;
+ var i = 0;
+
+ do {
+
+ switch(oNode.tagName) {
+
+ case this.GROUP_TITLE_TAG_NAME:
+
+ this._aGroupTitleElements[i] = oNode;
+
+ break;
+
+ case "UL":
+
+ this._aListElements[i] = oNode;
+ this._aItemGroups[i] = [];
+ i++;
+
+ break;
+
+ }
+
+ }
+ while((oNode = oNode.nextSibling));
+
+
+ /*
+ Apply the "first-of-type" class to the first UL to mimic
+ the "first-of-type" CSS3 psuedo class.
+ */
+
+ if(this._aListElements[0]) {
+
+ Dom.addClass(this._aListElements[0], "first-of-type");
+
+ }
+
+ this.logger = new YAHOO.widget.LogWriter(this.toString());
+
+ this.logger.log("Source element: " + this.srcElement.tagName);
+
+ break;
+
+ case "SELECT":
+
+ this.srcElement = oElement;
+
+
+ /*
+ The source element is not something that we can use
+ outright, so we need to create a new Overlay
+ */
+
+ var sId = Dom.generateId();
+
+ /*
+ Note: we don't pass the user config in here yet
+ because we only want it executed once, at the lowest
+ subclass level.
+ */
+
+ YAHOO.widget.MenuModule.superclass.init.call(this, sId);
+
+ this.beforeInitEvent.fire(YAHOO.widget.MenuModule);
+
+ this.logger = new YAHOO.widget.LogWriter(this.toString());
+
+ this.logger.log("Source element: " + this.srcElement.tagName);
+
+ break;
+
+ }
+
+ }
+ else {
+
+ /*
+ Note: we don't pass the user config in here yet
+ because we only want it executed once, at the lowest
+ subclass level.
+ */
+
+ YAHOO.widget.MenuModule.superclass.init.call(this, p_oElement);
+
+ this.beforeInitEvent.fire(YAHOO.widget.MenuModule);
+
+ this.logger = new YAHOO.widget.LogWriter(this.toString());
+
+ this.logger.log("No source element found. " +
+ "Created element with id: " + this.id);
+
+ }
+
+
+ if(this.element) {
+
+ var oEl = this.element;
+ var CustomEvent = YAHOO.util.CustomEvent;
+
+ Dom.addClass(oEl, this.CSS_CLASS_NAME);
+
+ // Assign DOM event handlers
+
+ Event.addListener(
+ oEl,
+ "mouseover",
+ this._onElementMouseOver,
+ this,
+ true
+ );
+
+ Event.addListener(oEl, "mouseout", this._onElementMouseOut, this, true);
+ Event.addListener(oEl, "mousedown", this._onDOMEvent, this, true);
+ Event.addListener(oEl, "mouseup", this._onDOMEvent, this, true);
+ Event.addListener(oEl, "click", this._onElementClick, this, true);
+ Event.addListener(oEl, "keydown", this._onDOMEvent, this, true);
+ Event.addListener(oEl, "keyup", this._onDOMEvent, this, true);
+ Event.addListener(oEl, "keypress", this._onDOMEvent, this, true);
+
+
+ // Create custom events
+
+ this.mouseOverEvent = new CustomEvent("mouseOverEvent", this);
+ this.mouseOutEvent = new CustomEvent("mouseOutEvent", this);
+ this.mouseDownEvent = new CustomEvent("mouseDownEvent", this);
+ this.mouseUpEvent = new CustomEvent("mouseUpEvent", this);
+ this.clickEvent = new CustomEvent("clickEvent", this);
+ this.keyPressEvent = new CustomEvent("keyPressEvent", this);
+ this.keyDownEvent = new CustomEvent("keyDownEvent", this);
+ this.keyUpEvent = new CustomEvent("keyUpEvent", this);
+
+
+ // Subscribe to Custom Events
+
+ this.beforeRenderEvent.subscribe(this._onBeforeRender, this, true);
+ this.renderEvent.subscribe(this._onRender, this, true);
+ this.showEvent.subscribe(this._onShow, this, true);
+ this.beforeHideEvent.subscribe(this._onBeforeHide, this, true);
+
+
+ if(p_oConfig) {
+
+ this.cfg.applyConfig(p_oConfig, true);
+
+ }
+
+
+ this.cfg.queueProperty("visible", false);
+
+
+ if(this.srcElement) {
+
+ this._initSubTree();
+
+ }
+
+ }
+
+
+ this.initEvent.fire(YAHOO.widget.MenuModule);
+
+};
+
+
+// Private methods
+
+/**
+* Iterates the source element's childNodes collection and uses the child
+* nodes to instantiate MenuModule and MenuModuleItem instances.
+* @private
+*/
+YAHOO.widget.MenuModule.prototype._initSubTree = function() {
+
+ var oNode;
+
+ this.logger.log("Searching DOM for items to initialize.");
+
+ switch(this.srcElement.tagName) {
+
+ case "DIV":
+
+ if(this._aListElements.length > 0) {
+
+ this.logger.log("Found " +
+ this._aListElements.length + " item groups to initialize.");
+
+ var i = this._aListElements.length - 1;
+
+ do {
+
+ oNode = this._aListElements[i].firstChild;
+
+ this.logger.log("Scanning " +
+ this._aListElements[i].childNodes.length +
+ " child nodes for items to initialize.");
+
+ do {
+
+ switch(oNode.tagName) {
+
+ case "LI":
+
+ this.logger.log("Initializing " +
+ oNode.tagName + " node.");
+
+ this.addItem(new this.ITEM_TYPE(oNode), i);
+
+ break;
+
+ }
+
+ }
+ while((oNode = oNode.nextSibling));
+
+ }
+ while(i--);
+
+ }
+
+ break;
+
+ case "SELECT":
+
+ this.logger.log("Scanning " + this.srcElement.childNodes.length +
+ " child nodes for items to initialize.");
+
+ oNode = this.srcElement.firstChild;
+
+ do {
+
+ switch(oNode.tagName) {
+
+ case "OPTGROUP":
+ case "OPTION":
+
+ this.logger.log("Initializing " +
+ oNode.tagName + " node.");
+
+ this.addItem(new this.ITEM_TYPE(oNode));
+
+ break;
+
+ }
+
+ }
+ while((oNode = oNode.nextSibling));
+
+ break;
+
+ }
+
+};
+
+
+/**
+* Returns the first enabled item in a menu instance.
+* @return Returns a MenuModuleItem instance.
+* @type YAHOO.widget.MenuModuleItem
+* @private
+*/
+YAHOO.widget.MenuModule.prototype._getFirstEnabledItem = function() {
+
+ var nGroups = this._aItemGroups.length;
+ var oItem;
+ var aItemGroup;
+
+ for(var i=0; i<nGroups; i++) {
+
+ aItemGroup = this._aItemGroups[i];
+
+ if(aItemGroup) {
+
+ var nItems = aItemGroup.length;
+
+ for(var n=0; n<nItems; n++) {
+
+ oItem = aItemGroup[n];
+
+ if(!oItem.cfg.getProperty("disabled")) {
+
+ return oItem;
+
+ }
+
+ oItem = null;
+
+ }
+
+ }
+
+ }
+
+};
+
+
+/**
+* Determines if the value is one of the supported positions.
+* @private
+* @param {Object} p_sPosition The object to be evaluated.
+* @return Returns true if the position is supported.
+* @type Boolean
+*/
+YAHOO.widget.MenuModule.prototype._checkPosition = function(p_sPosition) {
+
+ if(typeof p_sPosition == "string") {
+
+ var sPosition = p_sPosition.toLowerCase();
+
+ return ("dynamic,static".indexOf(sPosition) != -1);
+
+ }
+
+};
+
+
+/**
+* Adds an item to a group.
+* @private
+* @param {Number} p_nGroupIndex Number indicating the group to which
+* the item belongs.
+* @param {YAHOO.widget.MenuModuleItem} p_oItem The item to be added.
+* @param {Number} p_nItemIndex Optional. Index at which the item
+* should be added.
+* @return The item that was added.
+* @type YAHOO.widget.MenuModuleItem
+*/
+YAHOO.widget.MenuModule.prototype._addItemToGroup =
+
+ function(p_nGroupIndex, p_oItem, p_nItemIndex) {
+
+ var Dom = this._oDom;
+ var oItem;
+
+ if(p_oItem instanceof this.ITEM_TYPE) {
+
+ oItem = p_oItem;
+
+ }
+ else if(typeof p_oItem == "string") {
+
+ oItem = new this.ITEM_TYPE(p_oItem);
+
+ }
+
+
+ if(oItem) {
+
+ var nGroupIndex = typeof p_nGroupIndex == "number" ?
+ p_nGroupIndex : 0;
+
+ var aGroup = this._getItemGroup(nGroupIndex);
+
+ var oGroupItem;
+
+
+ if(!aGroup) {
+
+ aGroup = this._createItemGroup(nGroupIndex);
+
+ }
+
+
+ if(typeof p_nItemIndex == "number") {
+
+ var bAppend = (p_nItemIndex >= aGroup.length);
+
+
+ if(aGroup[p_nItemIndex]) {
+
+ aGroup.splice(p_nItemIndex, 0, oItem);
+
+ }
+ else {
+
+ aGroup[p_nItemIndex] = oItem;
+
+ }
+
+
+ oGroupItem = aGroup[p_nItemIndex];
+
+ if(oGroupItem) {
+
+ if(bAppend && !oGroupItem.element.parentNode) {
+
+ this._aListElements[nGroupIndex].appendChild(
+ oGroupItem.element
+ );
+
+ }
+ else {
+
+
+ /**
+ * Returns the next sibling of an item in an array
+ * @param {p_aArray} An array
+ * @param {p_nStartIndex} The index to start searching
+ * the array
+ * @ignore
+ * @return Returns an item in an array
+ * @type Object
+ */
+ function getNextItemSibling(p_aArray, p_nStartIndex) {
+
+ return (
+ p_aArray[p_nStartIndex] ||
+ getNextItemSibling(
+ p_aArray,
+ (p_nStartIndex+1)
+ )
+ );
+
+ }
+
+
+ var oNextItemSibling =
+ getNextItemSibling(aGroup, (p_nItemIndex+1));
+
+ if(oNextItemSibling && !oGroupItem.element.parentNode) {
+
+ this._aListElements[nGroupIndex].insertBefore(
+ oGroupItem.element,
+ oNextItemSibling.element
+ );
+
+ }
+
+ }
+
+
+ oGroupItem.parent = this;
+
+ this._subscribeToItemEvents(oGroupItem);
+
+ this._configureItemSubmenuModule(oGroupItem);
+
+ this._updateItemProperties(nGroupIndex);
+
+ this.logger.log("Item inserted." +
+ " Text: " + oGroupItem.cfg.getProperty("text") + ", " +
+ " Index: " + oGroupItem.index + ", " +
+ " Group Index: " + oGroupItem.groupIndex);
+
+ return oGroupItem;
+
+ }
+
+ }
+ else {
+
+ var nItemIndex = aGroup.length;
+
+ aGroup[nItemIndex] = oItem;
+
+
+ oGroupItem = aGroup[nItemIndex];
+
+ if(oGroupItem) {
+
+ if(
+ !Dom.isAncestor(
+ this._aListElements[nGroupIndex],
+ oGroupItem.element
+ )
+ ) {
+
+ this._aListElements[nGroupIndex].appendChild(
+ oGroupItem.element
+ );
+
+ }
+
+ oGroupItem.element.setAttribute("groupindex", nGroupIndex);
+ oGroupItem.element.setAttribute("index", nItemIndex);
+
+ oGroupItem.parent = this;
+
+ oGroupItem.index = nItemIndex;
+ oGroupItem.groupIndex = nGroupIndex;
+
+ this._subscribeToItemEvents(oGroupItem);
+
+ this._configureItemSubmenuModule(oGroupItem);
+
+ if(nItemIndex === 0) {
+
+ Dom.addClass(oGroupItem.element, "first-of-type");
+
+ }
+
+ this.logger.log("Item added." +
+ " Text: " + oGroupItem.cfg.getProperty("text") + ", " +
+ " Index: " + oGroupItem.index + ", " +
+ " Group Index: " + oGroupItem.groupIndex);
+
+ return oGroupItem;
+
+ }
+
+ }
+
+ }
+
+ };
+
+
+/**
+* Removes an item from a group by index.
+* @private
+* @param {Number} p_nGroupIndex Number indicating the group to which
+* the item belongs.
+* @param {Number} p_nItemIndex Number indicating the index of the item to
+* be removed.
+* @return The item that was removed.
+* @type YAHOO.widget.MenuModuleItem
+*/
+YAHOO.widget.MenuModule.prototype._removeItemFromGroupByIndex =
+
+ function(p_nGroupIndex, p_nItemIndex) {
+
+ var nGroupIndex = typeof p_nGroupIndex == "number" ? p_nGroupIndex : 0;
+ var aGroup = this._getItemGroup(nGroupIndex);
+
+ if(aGroup) {
+
+ var aArray = aGroup.splice(p_nItemIndex, 1);
+ var oItem = aArray[0];
+
+ if(oItem) {
+
+ // Update the index and className properties of each member
+
+ this._updateItemProperties(nGroupIndex);
+
+ if(aGroup.length === 0) {
+
+ // Remove the UL
+
+ var oUL = this._aListElements[nGroupIndex];
+
+ if(this.body && oUL) {
+
+ this.body.removeChild(oUL);
+
+ }
+
+ // Remove the group from the array of items
+
+ this._aItemGroups.splice(nGroupIndex, 1);
+
+
+ // Remove the UL from the array of ULs
+
+ this._aListElements.splice(nGroupIndex, 1);
+
+
+ /*
+ Assign the "first-of-type" class to the new first UL
+ in the collection
+ */
+
+ oUL = this._aListElements[0];
+
+ if(oUL) {
+
+ this._oDom.addClass(oUL, "first-of-type");
+
+ }
+
+ }
+
+
+ // Return a reference to the item that was removed
+
+ return oItem;
+
+ }
+
+ }
+
+ };
+
+
+/**
+* Removes a item from a group by reference.
+* @private
+* @param {Number} p_nGroupIndex Number indicating the group to which
+* the item belongs.
+* @param {YAHOO.widget.MenuModuleItem} p_oItem The item to be removed.
+* @return The item that was removed.
+* @type YAHOO.widget.MenuModuleItem
+*/
+YAHOO.widget.MenuModule.prototype._removeItemFromGroupByValue =
+
+ function(p_nGroupIndex, p_oItem) {
+
+ var aGroup = this._getItemGroup(p_nGroupIndex);
+
+ if(aGroup) {
+
+ var nItems = aGroup.length;
+ var nItemIndex = -1;
+
+ if(nItems > 0) {
+
+ var i = nItems-1;
+
+ do {
+
+ if(aGroup[i] == p_oItem) {
+
+ nItemIndex = i;
+ break;
+
+ }
+
+ }
+ while(i--);
+
+ if(nItemIndex > -1) {
+
+ return this._removeItemFromGroupByIndex(
+ p_nGroupIndex,
+ nItemIndex
+ );
+
+ }
+
+ }
+
+ }
+
+ };
+
+
+/**
+* Updates the index, groupindex, and className properties of the items
+* in the specified group.
+* @private
+* @param {Number} p_nGroupIndex Number indicating the group of items to update.
+*/
+YAHOO.widget.MenuModule.prototype._updateItemProperties =
+
+ function(p_nGroupIndex) {
+
+ var aGroup = this._getItemGroup(p_nGroupIndex);
+ var nItems = aGroup.length;
+
+ if(nItems > 0) {
+
+ var Dom = this._oDom;
+ var i = nItems - 1;
+ var oItem;
+ var oLI;
+
+ // Update the index and className properties of each member
+
+ do {
+
+ oItem = aGroup[i];
+
+ if(oItem) {
+
+ oLI = oItem.element;
+
+ oItem.index = i;
+ oItem.groupIndex = p_nGroupIndex;
+
+ oLI.setAttribute("groupindex", p_nGroupIndex);
+ oLI.setAttribute("index", i);
+
+ Dom.removeClass(oLI, "first-of-type");
+
+ }
+
+ }
+ while(i--);
+
+
+ if(oLI) {
+
+ Dom.addClass(oLI, "first-of-type");
+
+ }
+
+ }
+
+ };
+
+
+/**
+* Creates a new item group (array) and it's associated HTMLUlElement node
+* @private
+* @param {Number} p_nIndex Number indicating the group to create.
+* @return An item group.
+* @type Array
+*/
+YAHOO.widget.MenuModule.prototype._createItemGroup = function(p_nIndex) {
+
+ if(!this._aItemGroups[p_nIndex]) {
+
+ this._aItemGroups[p_nIndex] = [];
+
+ var oUL = document.createElement("ul");
+
+ this._aListElements[p_nIndex] = oUL;
+
+ return this._aItemGroups[p_nIndex];
+
+ }
+
+};
+
+
+/**
+* Returns the item group at the specified index.
+* @private
+* @param {Number} p_nIndex Number indicating the index of the item group to
+* be retrieved.
+* @return An array of items.
+* @type Array
+*/
+YAHOO.widget.MenuModule.prototype._getItemGroup = function(p_nIndex) {
+
+ var nIndex = ((typeof p_nIndex == "number") ? p_nIndex : 0);
+
+ return this._aItemGroups[nIndex];
+
+};
+
+
+/**
+* Subscribe's a MenuModule instance to it's parent MenuModule instance's events.
+* @private
+* @param {YAHOO.widget.MenuModuleItem} p_oItem The item to listen
+* for events on.
+*/
+YAHOO.widget.MenuModule.prototype._configureItemSubmenuModule =
+
+ function(p_oItem) {
+
+ var oSubmenu = p_oItem.cfg.getProperty("submenu");
+
+ if(oSubmenu) {
+
+ /*
+ Listen for configuration changes to the parent MenuModule
+ instance so they they can be applied to the submenu.
+ */
+
+ this.cfg.configChangedEvent.subscribe(
+ this._onParentMenuModuleConfigChange,
+ oSubmenu,
+ true
+ );
+
+ this.renderEvent.subscribe(
+ this._onParentMenuModuleRender,
+ oSubmenu,
+ true
+ );
+
+ oSubmenu.beforeShowEvent.subscribe(
+ this._onSubmenuBeforeShow,
+ oSubmenu,
+ true
+ );
+
+ oSubmenu.showEvent.subscribe(this._onSubmenuShow, oSubmenu, true);
+
+ oSubmenu.hideEvent.subscribe(this._onSubmenuHide, oSubmenu, true);
+
+ }
+
+};
+
+
+/**
+* Subscribes a MenuModule instance to the specified item's Custom Events.
+* @private
+* @param {YAHOO.widget.MenuModuleItem} p_oItem The item to listen for events on.
+*/
+YAHOO.widget.MenuModule.prototype._subscribeToItemEvents = function(p_oItem) {
+
+ var aArguments = [this, p_oItem];
+
+ p_oItem.focusEvent.subscribe(this._onItemFocus, aArguments);
+
+ p_oItem.blurEvent.subscribe(this._onItemBlur, aArguments);
+
+ p_oItem.cfg.configChangedEvent.subscribe(
+ this._onItemConfigChange,
+ aArguments
+ );
+
+};
+
+
+/**
+* Returns the offset width of a MenuModule instance.
+* @private
+*/
+YAHOO.widget.MenuModule.prototype._getOffsetWidth = function() {
+
+ var oClone = this.element.cloneNode(true);
+
+ this._oDom.setStyle(oClone, "width", "");
+
+ document.body.appendChild(oClone);
+
+ var sWidth = oClone.offsetWidth;
+
+ document.body.removeChild(oClone);
+
+ return sWidth;
+
+};
+
+
+/**
+* Determines if a DOM event was fired on an item and (if so) fires the item's
+* associated Custom Event
+* @private
+* @param {HTMLElement} p_oElement The original target of the event.
+* @param {String} p_sEventType The type/name of the Custom Event to fire.
+* @param {Event} p_oDOMEvent The DOM event to pass back when firing the
+* Custom Event.
+* @return An item.
+* @type YAHOO.widget.MenuModuleItem
+*/
+YAHOO.widget.MenuModule.prototype._fireItemEvent =
+
+ function(p_oElement, p_sEventType, p_oDOMEvent) {
+
+ var me = this;
+
+ /**
+ * Returns the specified element's parent HTMLLIElement (<LI<)
+ * @param {p_oElement} An HTMLElement node
+ * @ignore
+ * @return Returns an HTMLElement node
+ * @type HTMLElement
+ */
+ function getItemElement(p_oElement) {
+
+ if(p_oElement == me.element) {
+
+ return;
+
+ }
+ else if(p_oElement.tagName == "LI") {
+
+ return p_oElement;
+
+ }
+ else if(p_oElement.parentNode) {
+
+ return getItemElement(p_oElement.parentNode);
+
+ }
+
+ }
+
+
+ var oElement = getItemElement(p_oElement);
+
+ if(oElement) {
+
+ /*
+ Retrieve the item that corresponds to the
+ HTMLLIElement (<LI<) and fire the Custom Event
+ */
+
+ var nGroupIndex = parseInt(oElement.getAttribute("groupindex"), 10);
+ var nIndex = parseInt(oElement.getAttribute("index"), 10);
+ var oItem = this._aItemGroups[nGroupIndex][nIndex];
+
+ if(!oItem.cfg.getProperty("disabled")) {
+
+ oItem[p_sEventType].fire(p_oDOMEvent);
+
+ return oItem;
+
+ }
+
+ }
+
+ };
+
+
+// Private DOM event handlers
+
+/**
+* Generic event handler for the MenuModule's root HTMLDivElement node. Used
+* to handle "mousedown," "mouseup," "keydown," "keyup," and "keypress" events.
+* @private
+* @param {Event} p_oEvent Event object passed back by the event
+* utility (YAHOO.util.Event).
+* @param {YAHOO.widget.MenuModule} p_oMenuModule The MenuModule instance
+* corresponding to the HTMLDivElement that fired the event.
+*/
+YAHOO.widget.MenuModule.prototype._onDOMEvent =
+
+ function(p_oEvent, p_oMenuModule) {
+
+ var Event = this._oEventUtil;
+
+ // Map of DOM event types to Custom Event types
+
+ var oEventTypes = {
+ "mousedown": "mouseDownEvent",
+ "mouseup": "mouseUpEvent",
+ "keydown": "keyDownEvent",
+ "keyup": "keyUpEvent",
+ "keypress": "keyPressEvent"
+ };
+
+ var sCustomEventType = oEventTypes[p_oEvent.type];
+
+ var oTarget = Event.getTarget(p_oEvent);
+
+ /*
+ Check if the target was an element that is a part of a
+ an item and (if so), fire the associated custom event.
+ */
+
+ this._fireItemEvent(oTarget, sCustomEventType, p_oEvent);
+
+
+ // Fire the associated custom event for the MenuModule
+
+ this[sCustomEventType].fire(p_oEvent);
+
+
+ /*
+ Stop the propagation of the event at each MenuModule instance
+ since menus can be embedded in eachother.
+ */
+
+ Event.stopPropagation(p_oEvent);
+
+ };
+
+
+/**
+* "mouseover" event handler for the MenuModule's root HTMLDivElement node.
+* @private
+* @param {Event} p_oEvent Event object passed back by the event
+* utility (YAHOO.util.Event).
+* @param {YAHOO.widget.MenuModule} p_oMenuModule The MenuModule instance
+* corresponding to the HTMLDivElement that fired the event.
+*/
+YAHOO.widget.MenuModule.prototype._onElementMouseOver =
+
+ function(p_oEvent, p_oMenuModule) {
+
+ var Event = this._oEventUtil;
+ var oTarget = Event.getTarget(p_oEvent);
+
+ if(
+ (
+ oTarget == this.element ||
+ this._oDom.isAncestor(this.element, oTarget)
+ ) &&
+ !this._bFiredMouseOverEvent
+ ) {
+
+ // Fire the "mouseover" Custom Event for the MenuModule instance
+
+ this.mouseOverEvent.fire(p_oEvent);
+
+ this._bFiredMouseOverEvent = true;
+ this._bFiredMouseOutEvent = false;
+
+ }
+
+
+ /*
+ Check if the target was an element that is a part of an item
+ and (if so), fire the "mouseover" Custom Event.
+ */
+
+ if(!this._oCurrentItem) {
+
+ this._oCurrentItem =
+ this._fireItemEvent(oTarget, "mouseOverEvent", p_oEvent);
+
+ }
+
+
+ /*
+ Stop the propagation of the event at each MenuModule instance
+ since menus can be embedded in eachother.
+ */
+
+ Event.stopPropagation(p_oEvent);
+
+ };
+
+
+/**
+* "mouseout" event handler for the MenuModule's root HTMLDivElement node.
+* @private
+* @param {Event} p_oEvent Event object passed back by the event
+* utility (YAHOO.util.Event).
+* @param {YAHOO.widget.MenuModule} p_oMenuModule The MenuModule instance
+* corresponding to the HTMLDivElement that fired the event.
+*/
+YAHOO.widget.MenuModule.prototype._onElementMouseOut =
+
+ function(p_oEvent, p_oMenuModule) {
+
+ var Dom = this._oDom;
+ var Event = this._oEventUtil;
+ var oRelatedTarget = Event.getRelatedTarget(p_oEvent);
+ var bLIMouseOut = true;
+ var bMovingToSubmenu = false;
+
+
+ // Determine where the mouse is going
+
+ if(this._oCurrentItem && oRelatedTarget) {
+
+ if(
+ oRelatedTarget == this._oCurrentItem.element ||
+ Dom.isAncestor(this._oCurrentItem.element, oRelatedTarget)
+ ) {
+
+ bLIMouseOut = false;
+
+ }
+
+
+ var oSubmenu = this._oCurrentItem.cfg.getProperty("submenu");
+
+ if(
+ oSubmenu &&
+ (
+ oRelatedTarget == oSubmenu.element ||
+ Dom.isAncestor(oSubmenu.element, oRelatedTarget)
+ )
+ ) {
+
+ bMovingToSubmenu = true;
+
+ }
+
+ }
+
+
+ if(this._oCurrentItem && (bLIMouseOut || bMovingToSubmenu)) {
+
+ // Fire the "mouseout" Custom Event for the item
+
+ this._oCurrentItem.mouseOutEvent.fire(p_oEvent);
+
+ this._oCurrentItem = null;
+
+ }
+
+
+ if(
+ !this._bFiredMouseOutEvent &&
+ (
+ !Dom.isAncestor(this.element, oRelatedTarget) ||
+ bMovingToSubmenu
+ )
+ ) {
+
+ // Fire the "mouseout" Custom Event for the MenuModule instance
+
+ this.mouseOutEvent.fire(p_oEvent);
+
+ this._bFiredMouseOutEvent = true;
+ this._bFiredMouseOverEvent = false;
+
+ }
+
+
+ /*
+ Stop the propagation of the event at each MenuModule instance
+ since menus can be embedded in eachother.
+ */
+
+ Event.stopPropagation(p_oEvent);
+
+ };
+
+
+/**
+* "click" event handler for the MenuModule's root HTMLDivElement node.
+* @private
+* @param {Event} p_oEvent Event object passed back by the
+* event utility (YAHOO.util.Event).
+* @param {YAHOO.widget.MenuModule} p_oMenuModule The MenuModule instance
+* corresponding to the HTMLDivElement that fired the event.
+*/
+YAHOO.widget.MenuModule.prototype._onElementClick =
+
+ function(p_oEvent, p_oMenuModule) {
+
+ var Event = this._oEventUtil;
+
+ var oTarget = Event.getTarget(p_oEvent);
+
+ /*
+ Check if the target was a DOM element that is a part of an
+ item and (if so), fire the associated "click"
+ Custom Event.
+ */
+
+ var oItem = this._fireItemEvent(oTarget, "clickEvent", p_oEvent);
+
+ var bCurrentPageURL; // Indicates if the URL points to the current page
+
+
+ if(oItem) {
+
+ var sURL = oItem.cfg.getProperty("url");
+ var oSubmenu = oItem.cfg.getProperty("submenu");
+
+ bCurrentPageURL = (sURL.substr((sURL.length-1),1) == "#");
+
+ /*
+ ACCESSIBILITY FEATURE FOR SCREEN READERS: Expand/collapse the
+ submenu when the user clicks on the submenu indicator image.
+ */
+
+ if(oTarget == oItem.submenuIndicator && oSubmenu) {
+
+ if(oSubmenu.cfg.getProperty("visible")) {
+
+ oSubmenu.hide();
+
+ }
+ else {
+
+ var oActiveItem = this.activeItem;
+
+
+ // Hide any other submenus that might be visible
+
+ if(oActiveItem && oActiveItem != this) {
+
+ this.clearActiveItem();
+
+ }
+
+ this.activeItem = oItem;
+
+ oItem.cfg.setProperty("selected", true);
+
+ oSubmenu.show();
+
+ }
+
+ }
+ else if(oTarget.tagName != "A" && !bCurrentPageURL) {
+
+ /*
+ Follow the URL of the item regardless of whether or
+ not the user clicked specifically on the
+ HTMLAnchorElement (<A<) node.
+ */
+
+ document.location = sURL;
+
+ }
+
+ }
+
+
+ switch(oTarget.tagName) {
+
+ case "A":
+
+ if(bCurrentPageURL) {
+
+ // Don't follow URLs that are equal to "#"
+
+ Event.preventDefault(p_oEvent);
+
+ }
+ else {
+
+ /*
+ Break if the anchor's URL is something other than "#"
+ to prevent the call to "stopPropagation" from be
+ executed. This is required for Safari to be able to
+ follow the URL.
+ */
+
+ break;
+
+ }
+
+ default:
+
+ /*
+ Stop the propagation of the event at each MenuModule
+ instance since Menus can be embedded in eachother.
+ */
+
+ Event.stopPropagation(p_oEvent);
+
+ break;
+
+ }
+
+
+ // Fire the associated "click" Custom Event for the MenuModule instance
+
+ this.clickEvent.fire(p_oEvent);
+
+ };
+
+
+// Private Custom Event handlers
+
+
+/**
+* "beforerender" Custom Event handler for a MenuModule instance. Appends all
+* of the HTMLUListElement (<UL<s) nodes (and their child
+* HTMLLIElement (<LI<)) nodes and their accompanying title nodes to
+* the body of the MenuModule instance.
+* @private
+* @param {String} p_sType The name of the event that was fired.
+* @param {Array} p_aArgs Collection of arguments sent when the event
+* was fired.
+* @param {YAHOO.widget.MenuModule} p_oMenuModule The MenuModule instance that
+* fired the event.
+*/
+YAHOO.widget.MenuModule.prototype._onBeforeRender =
+
+ function(p_sType, p_aArgs, p_oMenuModule) {
+
+ var Dom = this._oDom;
+ var oConfig = this.cfg;
+ var oEl = this.element;
+ var nListElements = this._aListElements.length;
+
+
+ if(oConfig.getProperty("position") == "static") {
+
+ oConfig.queueProperty("iframe", false);
+ oConfig.queueProperty("visible", true);
+
+ }
+
+
+ if(nListElements > 0) {
+
+ var i = 0;
+ var bFirstList = true;
+ var oUL;
+ var oGroupTitle;
+
+
+ do {
+
+ oUL = this._aListElements[i];
+
+ if(oUL) {
+
+ if(bFirstList) {
+
+ Dom.addClass(oUL, "first-of-type");
+ bFirstList = false;
+
+ }
+
+
+ if(!Dom.isAncestor(oEl, oUL)) {
+
+ this.appendToBody(oUL);
+
+ }
+
+
+ oGroupTitle = this._aGroupTitleElements[i];
+
+ if(oGroupTitle) {
+
+ if(!Dom.isAncestor(oEl, oGroupTitle)) {
+
+ oUL.parentNode.insertBefore(oGroupTitle, oUL);
+
+ }
+
+
+ Dom.addClass(oUL, "hastitle");
+
+ }
+
+ }
+
+ i++;
+
+ }
+ while(i < nListElements);
+
+ }
+
+ };
+
+
+/**
+* "render" Custom Event handler for a MenuModule instance.
+* @private
+* @param {String} p_sType The name of the event that was fired.
+* @param {Array} p_aArgs Collection of arguments sent when the event
+* was fired.
+* @param {YAHOO.widget.MenuModule} p_oMenuModule The MenuModule instance that
+* fired the event.
+*/
+YAHOO.widget.MenuModule.prototype._onRender =
+
+ function(p_sType, p_aArgs, p_oMenuModule) {
+
+ if(this.cfg.getProperty("position") == "dynamic") {
+
+ var sWidth = this.element.parentNode.tagName == "BODY" ?
+ this.element.offsetWidth : this._getOffsetWidth();
+
+ this.cfg.setProperty("width", (sWidth + "px"));
+
+ }
+
+ };
+
+
+/**
+* "show" Custom Event handler for a MenuModule instance.
+* @private
+* @param {String} p_sType The name of the event that was fired.
+* @param {Array} p_aArgs Collection of arguments sent when the event
+* was fired.
+* @param {YAHOO.widget.MenuModule} p_oMenuModule The MenuModule instance that
+* fired the event.
+*/
+YAHOO.widget.MenuModule.prototype._onShow =
+
+ function(p_sType, p_aArgs, p_oMenuModule) {
+
+ /*
+ Setting focus to an item in the newly visible submenu alerts the
+ contents of the submenu to the screen reader.
+ */
+
+ this.setInitialFocus();
+
+ };
+
+
+/**
+* "hide" Custom Event handler for a MenuModule instance.
+* @private
+* @param {String} p_sType The name of the event that was fired.
+* @param {Array} p_aArgs Collection of arguments sent when the event
+* was fired.
+* @param {YAHOO.widget.MenuModule} p_oMenuModule The MenuModule instance that
+* fired the event.
+*/
+YAHOO.widget.MenuModule.prototype._onBeforeHide =
+
+ function(p_sType, p_aArgs, p_oMenuModule) {
+
+ var oActiveItem = this.activeItem;
+
+ if(oActiveItem) {
+
+ oActiveItem.blur();
+
+ if(oActiveItem.cfg.getProperty("selected")) {
+
+ oActiveItem.cfg.setProperty("selected", false);
+
+ }
+
+ var oSubmenu = oActiveItem.cfg.getProperty("submenu");
+
+ if(oSubmenu && oSubmenu.cfg.getProperty("visible")) {
+
+ oSubmenu.hide();
+
+ }
+
+ }
+
+ };
+
+
+/**
+* "configchange" Custom Event handler for a submenu.
+* @private
+* @param {String} p_sType The name of the event that was fired.
+* @param {Array} p_aArgs Collection of arguments sent when the event
+* was fired.
+* @param {YAHOO.widget.MenuModule} p_oSubmenu The submenu that subscribed
+* to the event.
+*/
+YAHOO.widget.MenuModule.prototype._onParentMenuModuleConfigChange =
+
+ function(p_sType, p_aArgs, p_oSubmenu) {
+
+ var sPropertyName = p_aArgs[0][0];
+ var oPropertyValue = p_aArgs[0][1];
+
+ switch(sPropertyName) {
+
+ case "iframe":
+ case "constraintoviewport":
+
+ p_oSubmenu.cfg.setProperty(sPropertyName, oPropertyValue);
+
+ break;
+
+ }
+
+ };
+
+
+/**
+* "render" Custom Event handler for a MenuModule instance. Renders a
+* submenu in response to the firing of it's parent's "render" event.
+* @private
+* @param {String} p_sType The name of the event that was fired.
+* @param {Array} p_aArgs Collection of arguments sent when the event
+* was fired.
+* @param {YAHOO.widget.MenuModule} p_oSubmenu The submenu that subscribed
+* to the event.
+*/
+YAHOO.widget.MenuModule.prototype._onParentMenuModuleRender =
+
+ function(p_sType, p_aArgs, p_oSubmenu) {
+
+ /*
+ Set the "iframe" and "constraintoviewport" configuration
+ properties to match the parent MenuModule
+ */
+
+ var oParentMenu = p_oSubmenu.parent.parent;
+
+ p_oSubmenu.cfg.applyConfig(
+
+ {
+ constraintoviewport:
+ oParentMenu.cfg.getProperty("constraintoviewport"),
+
+ xy: [0,0],
+
+ iframe: oParentMenu.cfg.getProperty("iframe")
+
+ }
+
+ );
+
+
+ if(this._oDom.inDocument(this.element)) {
+
+ this.render();
+
+ }
+ else {
+
+ this.render(this.parent.element);
+
+ }
+
+ };
+
+
+/**
+* "beforeshow" Custom Event handler for a submenu.
+* @private
+* @param {String} p_sType The name of the event that was fired.
+* @param {Array} p_aArgs Collection of arguments sent when the event
+* was fired.
+* @param {YAHOO.widget.MenuModule} p_oSubmenu The submenu that fired
+* the event.
+*/
+YAHOO.widget.MenuModule.prototype._onSubmenuBeforeShow =
+
+ function(p_sType, p_aArgs, p_oSubmenu) {
+
+ var oParent = this.parent;
+ var aAlignment = oParent.parent.cfg.getProperty("submenualignment");
+
+ this.cfg.setProperty(
+ "context",
+ [
+ oParent.element,
+ aAlignment[0],
+ aAlignment[1]
+ ]
+ );
+
+ oParent.submenuIndicator.alt =
+ oParent.EXPANDED_SUBMENU_INDICATOR_ALT_TEXT;
+
+ };
+
+
+/**
+* "show" Custom Event handler for a submenu.
+* @private
+* @param {String} p_sType The name of the event that was fired.
+* @param {Array} p_aArgs Collection of arguments sent when the event
+* was fired.
+* @param {YAHOO.widget.MenuModule} p_oSubmenu The submenu that fired
+* the event.
+*/
+YAHOO.widget.MenuModule.prototype._onSubmenuShow =
+
+ function(p_sType, p_aArgs, p_oSubmenu) {
+
+ var oParent = this.parent;
+
+ oParent.submenuIndicator.alt =
+ oParent.EXPANDED_SUBMENU_INDICATOR_ALT_TEXT;
+
+ };
+
+
+/**
+* "hide" Custom Event handler for a submenu.
+* @private
+* @param {String} p_sType The name of the event that was fired.
+* @param {Array} p_aArgs Collection of arguments sent when the event
+* was fired.
+* @param {YAHOO.widget.MenuModule} p_oSubmenu The submenu that fired
+* the event.
+*/
+YAHOO.widget.MenuModule.prototype._onSubmenuHide =
+
+ function(p_sType, p_aArgs, p_oSubmenu) {
+
+ var oParent = this.parent;
+
+ if(oParent.parent.cfg.getProperty("visible")) {
+
+ oParent.cfg.setProperty("selected", false);
+
+ oParent.focus();
+
+ }
+
+ oParent.submenuIndicator.alt =
+ oParent.COLLAPSED_SUBMENU_INDICATOR_ALT_TEXT;
+
+ };
+
+
+/**
+* "focus" YAHOO.util.CustomEvent handler for a MenuModule instance's items.
+* @private
+* @param {String} p_sType The name of the event that was fired.
+* @param {Array} p_aArgs Collection of arguments sent when the event
+* was fired.
+* @param {Array} p_aObjects Array containing the current MenuModule instance
+* and the item that fired the event.
+*/
+YAHOO.widget.MenuModule.prototype._onItemFocus =
+
+ function(p_sType, p_aArgs, p_aObjects) {
+
+ var me = p_aObjects[0];
+ var oItem = p_aObjects[1];
+
+ me.activeItem = oItem;
+
+ };
+
+
+/**
+* "blur" YAHOO.util.CustomEvent handler for a MenuModule instance's items.
+* @private
+* @param {String} p_sType The name of the event that was fired.
+* @param {Array} p_aArgs Collection of arguments sent when the event
+* was fired.
+* @param {Array} p_aObjects Array containing the current MenuModule instance
+* and the item that fired the event.
+*/
+YAHOO.widget.MenuModule.prototype._onItemBlur =
+
+ function(p_sType, p_aArgs, p_aObjects) {
+
+ var me = p_aObjects[0];
+ var oItem = p_aObjects[1];
+ var oSubmenu = oItem.cfg.getProperty("submenu");
+
+ if(!oSubmenu || (oSubmenu && !oSubmenu.cfg.getProperty("visible"))) {
+
+ me.activeItem = null;
+
+ }
+
+ };
+
+
+/**
+* "configchange" YAHOO.util.CustomEvent handler for the MenuModule
+* instance's items.
+* @private
+* @param {String} p_sType The name of the event that was fired.
+* @param {Array} p_aArgs Collection of arguments sent when the
+* event was fired.
+* @param {Array} p_aObjects Array containing the current MenuModule instance
+* and the item that fired the event.
+*/
+YAHOO.widget.MenuModule.prototype._onItemConfigChange =
+
+ function(p_sType, p_aArgs, p_aObjects) {
+
+ var me = p_aObjects[0];
+ var sProperty = p_aArgs[0][0];
+ var oItem = p_aObjects[1];
+
+ switch(sProperty) {
+
+ case "submenu":
+
+ var oSubmenu = p_aArgs[0][1];
+
+ if(oSubmenu) {
+
+ me._configureItemSubmenuModule(oItem);
+
+ }
+
+ break;
+
+ case "text":
+ case "helptext":
+
+ /*
+ A change to an item's "text" or "helptext"
+ configuration properties requires the width of the parent
+ MenuModule instance to be recalculated.
+ */
+
+ if(me.element.style.width) {
+
+ var sWidth = me._getOffsetWidth() + "px";
+
+ me._oDom.setStyle(me.element, "width", sWidth);
+
+ }
+
+ break;
+
+ }
+
+ };
+
+
+/**
+* The default event handler executed when the moveEvent is fired, if the
+* "constraintoviewport" configuration property is set to true.
+*/
+YAHOO.widget.MenuModule.prototype.enforceConstraints =
+
+ function(type, args, obj) {
+
+ var Dom = this._oDom;
+ var oConfig = this.cfg;
+
+ var pos = args[0];
+
+ var x = pos[0];
+ var y = pos[1];
+
+ var bod = document.getElementsByTagName('body')[0];
+ var htm = document.getElementsByTagName('html')[0];
+
+ var bodyOverflow = Dom.getStyle(bod, "overflow");
+ var htmOverflow = Dom.getStyle(htm, "overflow");
+
+ var offsetHeight = this.element.offsetHeight;
+ var offsetWidth = this.element.offsetWidth;
+
+ var viewPortWidth = Dom.getClientWidth();
+ var viewPortHeight = Dom.getClientHeight();
+
+ var scrollX = window.scrollX || document.body.scrollLeft;
+ var scrollY = window.scrollY || document.body.scrollTop;
+
+ var topConstraint = scrollY + 10;
+ var leftConstraint = scrollX + 10;
+ var bottomConstraint = scrollY + viewPortHeight - offsetHeight - 10;
+ var rightConstraint = scrollX + viewPortWidth - offsetWidth - 10;
+
+ var aContext = oConfig.getProperty("context");
+ var oContextElement = aContext ? aContext[0] : null;
+
+
+ if (x < 10) {
+
+ x = leftConstraint;
+
+ } else if ((x + offsetWidth) > viewPortWidth) {
+
+ if(
+ oContextElement &&
+ ((x - oContextElement.offsetWidth) > offsetWidth)
+ ) {
+
+ x = (x - (oContextElement.offsetWidth + offsetWidth));
+
+ }
+ else {
+
+ x = rightConstraint;
+
+ }
+
+ }
+
+ if (y < 10) {
+
+ y = topConstraint;
+
+ } else if (y > bottomConstraint) {
+
+ if(oContextElement && (y > offsetHeight)) {
+
+ y = ((y + oContextElement.offsetHeight) - offsetHeight);
+
+ }
+ else {
+
+ y = bottomConstraint;
+
+ }
+
+ }
+
+ oConfig.setProperty("x", x, true);
+ oConfig.setProperty("y", y, true);
+
+ };
+
+
+// Event handlers for configuration properties
+
+/**
+* Event handler for when the "position" configuration property of a
+* MenuModule changes.
+* @param {String} p_sType The name of the event that was fired.
+* @param {Array} p_aArgs Collection of arguments sent when the event
+* was fired.
+* @param {YAHOO.widget.MenuModule} p_oMenuModule The MenuModule instance fired
+* the event.
+* @see YAHOO.widget.Overlay#configIframe
+*/
+YAHOO.widget.MenuModule.prototype.configPosition =
+
+ function(p_sType, p_aArgs, p_oMenuModule) {
+
+ var sCSSPosition = p_aArgs[0] == "static" ? "static" : "absolute";
+
+ this._oDom.setStyle(this.element, "position", sCSSPosition);
+
+ };
+
+
+// Public methods
+
+YAHOO.widget.MenuModule.prototype.toString = function() {
+
+ return ("Menu " + this.id);
+
+};
+
+
+/**
+* Sets the title of a group of items.
+* @param {String} p_sGroupTitle The title of the group.
+* @param {Number} p_nGroupIndex Optional. Number indicating the group to which
+* the title belongs.
+*/
+YAHOO.widget.MenuModule.prototype.setItemGroupTitle =
+
+ function(p_sGroupTitle, p_nGroupIndex) {
+
+ if(typeof p_sGroupTitle == "string" && p_sGroupTitle.length > 0) {
+
+ var Dom = this._oDom;
+
+ var nGroupIndex =
+ typeof p_nGroupIndex == "number" ? p_nGroupIndex : 0;
+
+ var oTitle = this._aGroupTitleElements[nGroupIndex];
+
+
+ if(oTitle) {
+
+ oTitle.innerHTML = p_sGroupTitle;
+
+ }
+ else {
+
+ oTitle = document.createElement(this.GROUP_TITLE_TAG_NAME);
+
+ oTitle.innerHTML = p_sGroupTitle;
+
+ this._aGroupTitleElements[nGroupIndex] = oTitle;
+
+ }
+
+
+ var i = this._aGroupTitleElements.length - 1;
+ var nFirstIndex;
+
+ do {
+
+ if(this._aGroupTitleElements[i]) {
+
+ Dom.removeClass(
+ this._aGroupTitleElements[i],
+ "first-of-type"
+ );
+
+ nFirstIndex = i;
+
+ }
+
+ }
+ while(i--);
+
+
+ if(nFirstIndex !== null) {
+
+ Dom.addClass(
+ this._aGroupTitleElements[nFirstIndex],
+ "first-of-type"
+ );
+
+ }
+
+ }
+
+ };
+
+
+/**
+* Appends the specified item to a MenuModule instance.
+* @param {YAHOO.widget.MenuModuleItem} p_oItem The item to be added.
+* @param {Number} p_nGroupIndex Optional. Number indicating the group to which
+* the item belongs.
+* @return The item that was added to the MenuModule.
+* @type YAHOO.widget.MenuModuleItem
+*/
+YAHOO.widget.MenuModule.prototype.addItem = function(p_oItem, p_nGroupIndex) {
+
+ if(p_oItem) {
+
+ return this._addItemToGroup(p_nGroupIndex, p_oItem);
+
+ }
+
+};
+
+
+/**
+* Inserts an item into a MenuModule instance at the specified index.
+* @param {YAHOO.widget.MenuModuleItem} p_oItem The item to be inserted.
+* @param {Number} p_nItemIndex Number indicating the ordinal position
+* at which the item should be added.
+* @param {Number} p_nGroupIndex Optional. Number indicating the group to which
+* the item belongs.
+* @return The item that was inserted into the MenuModule.
+* @type YAHOO.widget.MenuModuleItem
+*/
+YAHOO.widget.MenuModule.prototype.insertItem =
+
+ function(p_oItem, p_nItemIndex, p_nGroupIndex) {
+
+ if(p_oItem) {
+
+ return this._addItemToGroup(p_nGroupIndex, p_oItem, p_nItemIndex);
+
+ }
+
+ };
+
+
+/**
+* Removes the specified item from a MenuModule instance.
+* @param {YAHOO.widget.MenuModuleItem/Number} p_oObject The item or index of
+* the item to be removed.
+* @param {Number} p_nGroupIndex Optional. Number indicating the group to which
+* the item belongs.
+* @return The item that was removed from the MenuModule.
+* @type YAHOO.widget.MenuModuleItem
+*/
+YAHOO.widget.MenuModule.prototype.removeItem =
+
+ function(p_oObject, p_nGroupIndex) {
+
+ if(typeof p_oObject != "undefined") {
+
+ var oItem;
+
+ if(p_oObject instanceof YAHOO.widget.MenuModuleItem) {
+
+ oItem =
+ this._removeItemFromGroupByValue(p_nGroupIndex, p_oObject);
+
+ }
+ else if(typeof p_oObject == "number") {
+
+ oItem =
+ this._removeItemFromGroupByIndex(p_nGroupIndex, p_oObject);
+
+ }
+
+ if(oItem) {
+
+ oItem.destroy();
+
+ this.logger.log("Item removed." +
+ " Text: " + oItem.cfg.getProperty("text") + ", " +
+ " Index: " + oItem.index + ", " +
+ " Group Index: " + oItem.groupIndex);
+
+ return oItem;
+
+ }
+
+ }
+
+ };
+
+
+/**
+* Returns a multi-dimensional array of all of a MenuModule's items.
+* @return An array of items.
+* @type Array
+*/
+YAHOO.widget.MenuModule.prototype.getItemGroups = function() {
+
+ return this._aItemGroups;
+
+};
+
+
+/**
+* Returns the item at the specified index.
+* @param {Number} p_nItemIndex Number indicating the ordinal position of the
+* item to be retrieved.
+* @param {Number} p_nGroupIndex Optional. Number indicating the group to which
+* the item belongs.
+* @return An item.
+* @type YAHOO.widget.MenuModuleItem
+*/
+YAHOO.widget.MenuModule.prototype.getItem =
+
+ function(p_nItemIndex, p_nGroupIndex) {
+
+ if(typeof p_nItemIndex == "number") {
+
+ var aGroup = this._getItemGroup(p_nGroupIndex);
+
+ if(aGroup) {
+
+ return aGroup[p_nItemIndex];
+
+ }
+
+ }
+
+ };
+
+
+/**
+* Removes the MenuModule instance's element from the DOM and sets all child
+* elements to null.
+*/
+YAHOO.widget.MenuModule.prototype.destroy = function() {
+
+ // Remove DOM event handlers
+
+ this._oEventUtil.purgeElement(this.element);
+
+
+ // Remove Custom Event listeners
+
+ this.mouseOverEvent.unsubscribeAll();
+ this.mouseOutEvent.unsubscribeAll();
+ this.mouseDownEvent.unsubscribeAll();
+ this.mouseUpEvent.unsubscribeAll();
+ this.clickEvent.unsubscribeAll();
+ this.keyPressEvent.unsubscribeAll();
+ this.keyDownEvent.unsubscribeAll();
+ this.keyUpEvent.unsubscribeAll();
+ this.beforeMoveEvent.unsubscribeAll();
+
+
+ var nItemGroups = this._aItemGroups.length;
+ var nItems;
+ var oItemGroup;
+ var oItem;
+ var i;
+ var n;
+
+
+ // Remove all items
+
+ if(nItemGroups > 0) {
+
+ i = nItemGroups - 1;
+
+ do {
+
+ oItemGroup = this._aItemGroups[i];
+
+ if(oItemGroup) {
+
+ nItems = oItemGroup.length;
+
+ if(nItems > 0) {
+
+ n = nItems - 1;
+
+ do {
+
+ oItem = this._aItemGroups[i][n];
+
+ if(oItem) {
+
+ oItem.destroy();
+ }
+
+ }
+ while(n--);
+
+ }
+
+ }
+
+ }
+ while(i--);
+
+ }
+
+
+ // Continue with the superclass implementation of this method
+
+ YAHOO.widget.MenuModule.superclass.destroy.call(this);
+
+ this.logger.log("Destroyed.");
+
+};
+
+
+
+
+/**
+* Sets focus to a MenuModule instance's first enabled item.
+*/
+YAHOO.widget.MenuModule.prototype.setInitialFocus = function() {
+
+ var oItem = this._getFirstEnabledItem();
+
+ if(oItem) {
+
+ oItem.focus();
+ }
+
+};
+
+
+/**
+* Sets the "selected" configuration property of a MenuModule instance's first
+* enabled item to "true."
+*/
+YAHOO.widget.MenuModule.prototype.setInitialSelection = function() {
+
+ var oItem = this._getFirstEnabledItem();
+
+ if(oItem) {
+
+ oItem.cfg.setProperty("selected", true);
+ }
+
+};
+
+
+/**
+* Sets the "selected" configuration property of a MenuModule instance's active
+* item to "false," blurs the item and hide's the item's submenu.
+*/
+YAHOO.widget.MenuModule.prototype.clearActiveItem = function () {
+
+ if(this.activeItem) {
+
+ var oConfig = this.activeItem.cfg;
+
+ oConfig.setProperty("selected", false);
+
+ var oSubmenu = oConfig.getProperty("submenu");
+
+ if(oSubmenu) {
+
+ oSubmenu.hide();
+
+ }
+
+ }
+
+};
+
+
+/**
+* Initializes the class's configurable properties which can be changed using
+* the MenuModule's Config object (cfg).
+*/
+YAHOO.widget.MenuModule.prototype.initDefaultConfig = function() {
+
+ YAHOO.widget.MenuModule.superclass.initDefaultConfig.call(this);
+
+ var oConfig = this.cfg;
+
+ // Add configuration properties
+
+ oConfig.addProperty(
+ "position",
+ {
+ value: "dynamic",
+ handler: this.configPosition,
+ validator: this._checkPosition
+ }
+ );
+
+ oConfig.refireEvent("position");
+
+ oConfig.addProperty("submenualignment", { value: ["tl","tr"] } );
+
+};
+
+
+
+/**
+* @class The MenuModuleItem class allows you to create and modify an item for a
+* MenuModule instance.
+* @constructor
+* @param {String or HTMLElement} p_oObject String or HTMLElement
+* (either HTMLLIElement, HTMLOptGroupElement or HTMLOptionElement) of the
+* source HTMLElement node.
+* @param {Object} p_oConfig The configuration object literal containing
+* the configuration for a MenuModuleItem instance. See the configuration
+* class documentation for more details.
+*/
+YAHOO.widget.MenuModuleItem = function(p_oObject, p_oConfig) {
+
+ if(p_oObject) {
+
+ this.init(p_oObject, p_oConfig);
+
+ }
+
+};
+
+YAHOO.widget.MenuModuleItem.prototype = {
+
+ // Constants
+
+ /**
+ * Constant representing the path to the image to be used for the submenu
+ * arrow indicator.
+ * @final
+ * @type String
+ */
+ SUBMENU_INDICATOR_IMAGE_PATH: "nt/ic/ut/alt1/menuarorght8_nrm_1.gif",
+
+
+ /**
+ * Constant representing the path to the image to be used for the submenu
+ * arrow indicator when a MenuModuleItem instance is selected.
+ * @final
+ * @type String
+ */
+ SELECTED_SUBMENU_INDICATOR_IMAGE_PATH:
+ "nt/ic/ut/alt1/menuarorght8_hov_1.gif",
+
+
+ /**
+ * Constant representing the path to the image to be used for the submenu
+ * arrow indicator when a MenuModuleItem instance is disabled.
+ * @final
+ * @type String
+ */
+ DISABLED_SUBMENU_INDICATOR_IMAGE_PATH:
+ "nt/ic/ut/alt1/menuarorght8_dim_1.gif",
+
+
+ /**
+ * Constant representing the alt text for the image to be used for the
+ * submenu arrow indicator.
+ * @final
+ * @type String
+ */
+ COLLAPSED_SUBMENU_INDICATOR_ALT_TEXT: "Collapsed. Click to expand.",
+
+
+ /**
+ * Constant representing the alt text for the image to be used for the
+ * submenu arrow indicator when the submenu is visible.
+ * @final
+ * @type String
+ */
+ EXPANDED_SUBMENU_INDICATOR_ALT_TEXT: "Expanded. Click to collapse.",
+
+
+ /**
+ * Constant representing the alt text for the image to be used for the
+ * submenu arrow indicator when a MenuModuleItem instance is disabled.
+ * @final
+ * @type String
+ */
+ DISABLED_SUBMENU_INDICATOR_ALT_TEXT: "Disabled.",
+
+
+ /**
+ * Constant representing the CSS class(es) to be applied to the root
+ * HTMLLIElement of the MenuModuleItem.
+ * @final
+ * @type String
+ */
+ CSS_CLASS_NAME: "yuimenuitem",
+
+
+ /**
+ * Constant representing the type of menu to instantiate when creating
+ * submenu instances from parsing the child nodes (either HTMLSelectElement
+ * or HTMLDivElement) of the item's DOM. The default
+ * is YAHOO.widget.MenuModule.
+ * @final
+ * @type YAHOO.widget.MenuModule
+ */
+ SUBMENU_TYPE: null,
+
+
+ /**
+ * Constant representing the type of item to instantiate when
+ * creating item instances from parsing the child nodes (either
+ * HTMLLIElement, HTMLOptGroupElement or HTMLOptionElement) of the
+ * submenu's DOM.
+ * The default is YAHOO.widget.MenuModuleItem.
+ * @final
+ * @type YAHOO.widget.MenuModuleItem
+ */
+ SUBMENU_ITEM_TYPE: null,
+
+
+ /**
+ * Constant representing the prefix path to use for non-secure images
+ * @type string
+ */
+ IMG_ROOT: "http://us.i1.yimg.com/us.yimg.com/i/",
+
+
+ /**
+ * Constant representing the prefix path to use for securely served images
+ * @type string
+ */
+ IMG_ROOT_SSL: "https://a248.e.akamai.net/sec.yimg.com/i/",
+
+
+ // Private member variables
+
+ /**
+ * Reference to the HTMLAnchorElement of the MenuModuleItem's core internal
+ * DOM structure.
+ * @private
+ * @type {HTMLAnchorElement}
+ */
+ _oAnchor: null,
+
+
+ /**
+ * Reference to the text node of the MenuModuleItem's core internal
+ * DOM structure.
+ * @private
+ * @type {Text}
+ */
+ _oText: null,
+
+
+ /**
+ * Reference to the HTMLElement (<EM<) used to create the optional
+ * help text for a MenuModuleItem instance.
+ * @private
+ * @type {HTMLElement}
+ */
+ _oHelpTextEM: null,
+
+
+ /**
+ * Reference to the submenu for a MenuModuleItem instance.
+ * @private
+ * @type {YAHOO.widget.MenuModule}
+ */
+ _oSubmenu: null,
+
+
+ /**
+ * Reference to the Dom utility singleton.
+ * @private
+ * @type {YAHOO.util.Dom}
+ */
+ _oDom: YAHOO.util.Dom,
+
+
+ // Public properties
+
+ /**
+ * The class's constructor function
+ * @type YAHOO.widget.MenuModuleItem
+ */
+ constructor: YAHOO.widget.MenuModuleItem,
+
+
+ /**
+ * The string representing the image root
+ * @type string
+ */
+ imageRoot: null,
+
+
+ /**
+ * Boolean representing whether or not the current browsing context
+ * is secure (https)
+ * @type boolean
+ */
+ isSecure: YAHOO.widget.Module.prototype.isSecure,
+
+
+ /**
+ * Returns the ordinal position of a MenuModuleItem instance in a group.
+ * @type Number
+ */
+ index: null,
+
+
+ /**
+ * Returns the index of the group to which a MenuModuleItem instance belongs.
+ * @type Number
+ */
+ groupIndex: null,
+
+
+ /**
+ * Returns the parent object for a MenuModuleItem instance.
+ * @type {YAHOO.widget.MenuModule}
+ */
+ parent: null,
+
+
+ /**
+ * Returns the HTMLLIElement for a MenuModuleItem instance.
+ * @type {HTMLLIElement}
+ */
+ element: null,
+
+
+ /**
+ * Returns the HTMLElement (either HTMLLIElement, HTMLOptGroupElement or
+ * HTMLOptionElement) used create the MenuModuleItem instance.
+ * @type {HTMLLIElement/HTMLOptGroupElement/HTMLOptionElement}
+ */
+ srcElement: null,
+
+
+ /**
+ * Specifies an arbitrary value for a MenuModuleItem instance.
+ * @type {Object}
+ */
+ value: null,
+
+
+ /**
+ * Reference to the HTMLImageElement used to create the submenu
+ * indicator for a MenuModuleItem instance.
+ * @type {HTMLImageElement}
+ */
+ submenuIndicator: null,
+
+
+ /**
+ * String representing the browser
+ * @type string
+ */
+ browser: YAHOO.widget.Module.prototype.browser,
+
+
+ // Events
+
+ /**
+ * Fires when a MenuModuleItem instances's HTMLLIElement is removed from
+ * it's parent HTMLUListElement node.
+ * @type {YAHOO.util.CustomEvent}
+ * @see YAHOO.util.CustomEvent
+ */
+ destroyEvent: null,
+
+
+ /**
+ * Fires when the mouse has entered a MenuModuleItem instance. Passes
+ * back the DOM Event object as an argument.
+ * @type {YAHOO.util.CustomEvent}
+ * @see YAHOO.util.CustomEvent
+ */
+ mouseOverEvent: null,
+
+
+ /**
+ * Fires when the mouse has left a MenuModuleItem instance. Passes back
+ * the DOM Event object as an argument.
+ * @type {YAHOO.util.CustomEvent}
+ * @see YAHOO.util.CustomEvent
+ */
+ mouseOutEvent: null,
+
+
+ /**
+ * Fires when the user mouses down on a MenuModuleItem instance. Passes
+ * back the DOM Event object as an argument.
+ * @type {YAHOO.util.CustomEvent}
+ * @see YAHOO.util.CustomEvent
+ */
+ mouseDownEvent: null,
+
+
+ /**
+ * Fires when the user releases a mouse button while the mouse is
+ * over a MenuModuleItem instance. Passes back the DOM Event object as
+ * an argument.
+ * @type {YAHOO.util.CustomEvent}
+ * @see YAHOO.util.CustomEvent
+ */
+ mouseUpEvent: null,
+
+
+ /**
+ * Fires when the user clicks the on a MenuModuleItem instance. Passes
+ * back the DOM Event object as an argument.
+ * @type {YAHOO.util.CustomEvent}
+ * @see YAHOO.util.CustomEvent
+ */
+ clickEvent: null,
+
+
+ /**
+ * Fires when the user presses an alphanumeric key. Passes back the
+ * DOM Event object as an argument.
+ * @type {YAHOO.util.CustomEvent}
+ * @see YAHOO.util.CustomEvent
+ */
+ keyPressEvent: null,
+
+
+ /**
+ * Fires when the user presses a key. Passes back the DOM Event
+ * object as an argument.
+ * @type {YAHOO.util.CustomEvent}
+ * @see YAHOO.util.CustomEvent
+ */
+ keyDownEvent: null,
+
+
+ /**
+ * Fires when the user releases a key. Passes back the DOM Event
+ * object as an argument.
+ * @type {YAHOO.util.CustomEvent}
+ * @see YAHOO.util.CustomEvent
+ */
+ keyUpEvent: null,
+
+
+ /**
+ * Fires when a MenuModuleItem instance receives focus.
+ * @type {YAHOO.util.CustomEvent}
+ * @see YAHOO.util.CustomEvent
+ */
+ focusEvent: null,
+
+
+ /**
+ * Fires when a MenuModuleItem instance loses the input focus.
+ * @type {YAHOO.util.CustomEvent}
+ * @see YAHOO.util.CustomEvent
+ */
+ blurEvent: null,
+
+
+ /**
+ * The MenuModuleItem class's initialization method. This method is
+ * automatically called by the constructor, and sets up all DOM references
+ * for pre-existing markup, and creates required markup if it is not
+ * already present.
+ * @param {String or HTMLElement} p_oObject String or HTMLElement
+ * (either HTMLLIElement, HTMLOptGroupElement or HTMLOptionElement) of the
+ * source HTMLElement node.
+ * @param {Object} p_oConfig The configuration object literal containing
+ * the configuration for a MenuModuleItem instance. See the configuration
+ * class documentation for more details.
+ */
+ init: function(p_oObject, p_oConfig) {
+
+ this.imageRoot = (this.isSecure) ? this.IMG_ROOT_SSL : this.IMG_ROOT;
+
+
+ if(!this.SUBMENU_TYPE) {
+
+ this.SUBMENU_TYPE = YAHOO.widget.MenuModule;
+
+ }
+
+ if(!this.SUBMENU_ITEM_TYPE) {
+
+ this.SUBMENU_ITEM_TYPE = YAHOO.widget.MenuModuleItem;
+
+ }
+
+
+ // Create the config object
+
+ this.cfg = new YAHOO.util.Config(this);
+
+ this.initDefaultConfig();
+
+ var oConfig = this.cfg;
+
+
+ if(this._checkString(p_oObject)) {
+
+ this._createRootNodeStructure();
+
+ oConfig.setProperty("text", p_oObject);
+
+ }
+ else if(this._checkDOMNode(p_oObject)) {
+
+ switch(p_oObject.tagName) {
+
+ case "OPTION":
+
+ this._createRootNodeStructure();
+
+ oConfig.setProperty("text", p_oObject.text);
+
+ this.srcElement = p_oObject;
+
+ break;
+
+ case "OPTGROUP":
+
+ this._createRootNodeStructure();
+
+ oConfig.setProperty("text", p_oObject.label);
+
+ this.srcElement = p_oObject;
+
+ this._initSubTree();
+
+ break;
+
+ case "LI":
+
+ // Get the anchor node (if it exists)
+
+ var oAnchor = this._getFirstElement(p_oObject, "A");
+ var sURL = "#";
+ var sText = null;
+
+
+ // Capture the "text" and/or the "URL"
+
+ if(oAnchor) {
+
+ sURL = oAnchor.getAttribute("href");
+
+ if(oAnchor.innerText) {
+
+ sText = oAnchor.innerText;
+
+ }
+ else {
+
+ var oRange = oAnchor.ownerDocument.createRange();
+
+ oRange.selectNodeContents(oAnchor);
+
+ sText = oRange.toString();
+
+ }
+
+ }
+ else {
+
+ var oText = p_oObject.firstChild;
+
+ sText = oText.nodeValue;
+
+ oAnchor = document.createElement("a");
+
+ oAnchor.setAttribute("href", sURL);
+
+ p_oObject.replaceChild(oAnchor, oText);
+
+ oAnchor.appendChild(oText);
+
+ }
+
+
+ this.srcElement = p_oObject;
+ this.element = p_oObject;
+ this._oAnchor = oAnchor;
+
+
+ // Check if emphasis has been applied to the MenuModuleItem
+
+ var oEmphasisNode = this._getFirstElement(oAnchor);
+ var bEmphasis = false;
+ var bStrongEmphasis = false;
+
+ if(oEmphasisNode) {
+
+ // Set a reference to the text node
+
+ this._oText = oEmphasisNode.firstChild;
+
+ switch(oEmphasisNode.tagName) {
+
+ case "EM":
+
+ bEmphasis = true;
+
+ break;
+
+ case "STRONG":
+
+ bStrongEmphasis = true;
+
+ break;
+
+ }
+
+ }
+ else {
+
+ // Set a reference to the text node
+
+ this._oText = oAnchor.firstChild;
+
+ }
+
+
+ /*
+ Set these properties silently to sync up the
+ configuration object without making changes to the
+ element's DOM
+ */
+
+ oConfig.setProperty("text", sText, true);
+ oConfig.setProperty("url", sURL, true);
+ oConfig.setProperty("emphasis", bEmphasis, true);
+ oConfig.setProperty(
+ "strongemphasis",
+ bStrongEmphasis,
+ true
+ );
+
+ this._initSubTree();
+
+ break;
+
+ }
+
+ }
+
+
+ if(this.element) {
+
+
+ this._oDom.addClass(this.element, this.CSS_CLASS_NAME);
+
+
+ // Create custom events
+
+ var CustomEvent = YAHOO.util.CustomEvent;
+
+ this.destroyEvent = new CustomEvent("destroyEvent", this);
+ this.mouseOverEvent = new CustomEvent("mouseOverEvent", this);
+ this.mouseOutEvent = new CustomEvent("mouseOutEvent", this);
+ this.mouseDownEvent = new CustomEvent("mouseDownEvent", this);
+ this.mouseUpEvent = new CustomEvent("mouseUpEvent", this);
+ this.clickEvent = new CustomEvent("clickEvent", this);
+ this.keyPressEvent = new CustomEvent("keyPressEvent", this);
+ this.keyDownEvent = new CustomEvent("keyDownEvent", this);
+ this.keyUpEvent = new CustomEvent("keyUpEvent", this);
+ this.focusEvent = new CustomEvent("focusEvent", this);
+ this.blurEvent = new CustomEvent("blurEvent", this);
+
+
+ if(p_oConfig) {
+
+ oConfig.applyConfig(p_oConfig);
+
+ }
+
+ oConfig.fireQueue();
+
+ }
+
+ },
+
+
+ // Private methods
+
+ /**
+ * Returns an HTMLElement's first HTMLElement node
+ * @private
+ * @param {HTMLElement} p_oElement The element to be evaluated.
+ * @param {String} p_sTagName Optional. The tagname of the element.
+ * @return Returns an HTMLElement node.
+ * @type Boolean
+ */
+ _getFirstElement: function(p_oElement, p_sTagName) {
+
+ var oElement;
+
+ if(p_oElement.firstChild && p_oElement.firstChild.nodeType == 1) {
+
+ oElement = p_oElement.firstChild;
+
+ }
+ else if(
+ p_oElement.firstChild &&
+ p_oElement.firstChild.nextSibling &&
+ p_oElement.firstChild.nextSibling.nodeType == 1
+ ) {
+
+ oElement = p_oElement.firstChild.nextSibling;
+
+ }
+
+
+ if(p_sTagName) {
+
+ return (oElement && oElement.tagName == p_sTagName) ?
+ oElement : false;
+
+ }
+
+ return oElement;
+
+ },
+
+
+ /**
+ * Determines if an object is a string
+ * @private
+ * @param {Object} p_oObject The object to be evaluated.
+ * @return Returns true if the object is a string.
+ * @type Boolean
+ */
+ _checkString: function(p_oObject) {
+
+ return (typeof p_oObject == "string");
+
+ },
+
+
+ /**
+ * Determines if an object is an HTMLElement.
+ * @private
+ * @param {Object} p_oObject The object to be evaluated.
+ * @return Returns true if the object is an HTMLElement.
+ * @type Boolean
+ */
+ _checkDOMNode: function(p_oObject) {
+
+ return (p_oObject && p_oObject.tagName);
+
+ },
+
+
+ /**
+ * Creates the core DOM structure for a MenuModuleItem instance.
+ * @private
+ */
+ _createRootNodeStructure: function () {
+
+ this.element = document.createElement("li");
+
+ this._oText = document.createTextNode("");
+
+ this._oAnchor = document.createElement("a");
+ this._oAnchor.appendChild(this._oText);
+
+ this.cfg.refireEvent("url");
+
+ this.element.appendChild(this._oAnchor);
+
+ },
+
+
+ /**
+ * Iterates the source element's childNodes collection and uses the
+ * child nodes to instantiate other menus.
+ * @private
+ */
+ _initSubTree: function() {
+
+ var Menu = this.SUBMENU_TYPE;
+ var MenuModuleItem = this.SUBMENU_ITEM_TYPE;
+ var oSrcEl = this.srcElement;
+ var oConfig = this.cfg;
+
+
+ if(oSrcEl.childNodes.length > 0) {
+
+ var oNode = oSrcEl.firstChild;
+ var aOptions = [];
+
+ do {
+
+ switch(oNode.tagName) {
+
+ case "DIV":
+
+ oConfig.setProperty("submenu", (new Menu(oNode)));
+
+ break;
+
+ case "OPTION":
+
+ aOptions[aOptions.length] = oNode;
+
+ break;
+
+ }
+
+ }
+ while((oNode = oNode.nextSibling));
+
+
+ var nOptions = aOptions.length;
+
+ if(nOptions > 0) {
+
+ oConfig.setProperty(
+ "submenu",
+ (new Menu(this._oDom.generateId()))
+ );
+
+ for(var n=0; n<nOptions; n++) {
+
+ this._oSubmenu.addItem((new MenuModuleItem(aOptions[n])));
+
+ }
+
+ }
+
+ }
+
+ },
+
+
+ // Event handlers for configuration properties
+
+ /**
+ * Event handler for when the "text" configuration property of
+ * a MenuModuleItem instance changes.
+ * @param {String} p_sType The name of the event that was fired.
+ * @param {Array} p_aArgs Collection of arguments sent when the
+ * event was fired.
+ * @param {YAHOO.widget.MenuModuleItem} p_oItem The MenuModuleItem instance
+ * that fired the event.
+ */
+ configText: function(p_sType, p_aArgs, p_oItem) {
+
+ var sText = p_aArgs[0];
+
+
+ if(this._oText) {
+
+ this._oText.nodeValue = sText;
+
+ }
+
+ },
+
+
+ /**
+ * Event handler for when the "helptext" configuration property of
+ * a MenuModuleItem instance changes.
+ * @param {String} p_sType The name of the event that was fired.
+ * @param {Array} p_aArgs Collection of arguments sent when the
+ * event was fired.
+ * @param {YAHOO.widget.MenuModuleItem} p_oItem The MenuModuleItem instance
+ * that fired the event.
+ */
+ configHelpText: function(p_sType, p_aArgs, p_oItem) {
+
+ var me = this;
+ var Dom = this._oDom;
+ var oHelpText = p_aArgs[0];
+ var oEl = this.element;
+ var oConfig = this.cfg;
+ var aNodes = [oEl, this._oAnchor];
+ var oImg = this.submenuIndicator;
+
+
+ /**
+ * Adds the "hashelptext" class to the necessary nodes and refires the
+ * "selected" and "disabled" configuration events
+ * @ignore
+ */
+ function initHelpText() {
+
+ Dom.addClass(aNodes, "hashelptext");
+
+ if(oConfig.getProperty("disabled")) {
+
+ oConfig.refireEvent("disabled");
+
+ }
+
+ if(oConfig.getProperty("selected")) {
+
+ oConfig.refireEvent("selected");
+
+ }
+
+ }
+
+
+ /**
+ * Removes the "hashelptext" class and corresponding DOM element (EM)
+ * @ignore
+ */
+ function removeHelpText() {
+
+ Dom.removeClass(aNodes, "hashelptext");
+
+ oEl.removeChild(me._oHelpTextEM);
+ me._oHelpTextEM = null;
+
+ }
+
+
+ if(this._checkDOMNode(oHelpText)) {
+
+ if(this._oHelpTextEM) {
+
+ this._oHelpTextEM.parentNode.replaceChild(
+ oHelpText,
+ this._oHelpTextEM
+ );
+
+ }
+ else {
+
+ this._oHelpTextEM = oHelpText;
+
+ oEl.insertBefore(this._oHelpTextEM, oImg);
+
+ }
+
+ initHelpText();
+
+ }
+ else if(this._checkString(oHelpText)) {
+
+ if(oHelpText.length === 0) {
+
+ removeHelpText();
+
+ }
+ else {
+
+ if(!this._oHelpTextEM) {
+
+ this._oHelpTextEM = document.createElement("em");
+
+ oEl.insertBefore(this._oHelpTextEM, oImg);
+
+ }
+
+ this._oHelpTextEM.innerHTML = oHelpText;
+
+ initHelpText();
+
+ }
+
+ }
+ else if(!oHelpText && this._oHelpTextEM) {
+
+ removeHelpText();
+
+ }
+
+ },
+
+
+ /**
+ * Event handler for when the "url" configuration property of
+ * a MenuModuleItem instance changes.
+ * @param {String} p_sType The name of the event that was fired.
+ * @param {Array} p_aArgs Collection of arguments sent when the
+ * event was fired.
+ * @param {YAHOO.widget.MenuModuleItem} p_oItem The MenuModuleItem instance
+ * that fired the event.
+ */
+ configURL: function(p_sType, p_aArgs, p_oItem) {
+
+ var sURL = p_aArgs[0];
+
+ if(!sURL) {
+
+ sURL = "#";
+
+ }
+
+ this._oAnchor.setAttribute("href", sURL);
+
+ },
+
+
+ /**
+ * Event handler for when the "emphasis" configuration property of
+ * a MenuModuleItem instance changes.
+ * @param {String} p_sType The name of the event that was fired.
+ * @param {Array} p_aArgs Collection of arguments sent when the
+ * event was fired.
+ * @param {YAHOO.widget.MenuModuleItem} p_oItem The MenuModuleItem instance
+ * that fired the event.
+ */
+ configEmphasis: function(p_sType, p_aArgs, p_oItem) {
+
+ var bEmphasis = p_aArgs[0];
+ var oAnchor = this._oAnchor;
+ var oText = this._oText;
+ var oConfig = this.cfg;
+ var oEM;
+
+
+ if(bEmphasis && oConfig.getProperty("strongemphasis")) {
+
+ oConfig.setProperty("strongemphasis", false);
+
+ }
+
+
+ if(oAnchor) {
+
+ if(bEmphasis) {
+
+ oEM = document.createElement("em");
+ oEM.appendChild(oText);
+
+ oAnchor.appendChild(oEM);
+
+ }
+ else {
+
+ oEM = this._getFirstElement(oAnchor, "EM");
+
+ oAnchor.removeChild(oEM);
+ oAnchor.appendChild(oText);
+
+ }
+
+ }
+
+ },
+
+
+ /**
+ * Event handler for when the "strongemphasis" configuration property of
+ * a MenuModuleItem instance changes.
+ * @param {String} p_sType The name of the event that was fired.
+ * @param {Array} p_aArgs Collection of arguments sent when the
+ * event was fired.
+ * @param {YAHOO.widget.MenuModuleItem} p_oItem The MenuModuleItem instance
+ * that fired the event.
+ */
+ configStrongEmphasis: function(p_sType, p_aArgs, p_oItem) {
+
+ var bStrongEmphasis = p_aArgs[0];
+ var oAnchor = this._oAnchor;
+ var oText = this._oText;
+ var oConfig = this.cfg;
+ var oStrong;
+
+ if(bStrongEmphasis && oConfig.getProperty("emphasis")) {
+
+ oConfig.setProperty("emphasis", false);
+
+ }
+
+ if(oAnchor) {
+
+ if(bStrongEmphasis) {
+
+ oStrong = document.createElement("strong");
+ oStrong.appendChild(oText);
+
+ oAnchor.appendChild(oStrong);
+
+ }
+ else {
+
+ oStrong = this._getFirstElement(oAnchor, "STRONG");
+
+ oAnchor.removeChild(oStrong);
+ oAnchor.appendChild(oText);
+
+ }
+
+ }
+
+ },
+
+
+ /**
+ * Event handler for when the "disabled" configuration property of
+ * a MenuModuleItem instance changes.
+ * @param {String} p_sType The name of the event that was fired.
+ * @param {Array} p_aArgs Collection of arguments sent when the
+ * event was fired.
+ * @param {YAHOO.widget.MenuModuleItem} p_oItem The MenuModuleItem instance
+ * that fired the event.
+ */
+ configDisabled: function(p_sType, p_aArgs, p_oItem) {
+
+ var bDisabled = p_aArgs[0];
+ var Dom = this._oDom;
+ var oAnchor = this._oAnchor;
+ var aNodes = [this.element, oAnchor];
+ var oEM = this._oHelpTextEM;
+ var oConfig = this.cfg;
+ var oImg = this.submenuIndicator;
+ var sImageSrc;
+ var sImageAlt;
+
+
+ if(oEM) {
+
+ aNodes[2] = oEM;
+
+ }
+
+ if(bDisabled) {
+
+ if(oConfig.getProperty("selected")) {
+
+ oConfig.setProperty("selected", false);
+
+ }
+
+ oAnchor.removeAttribute("href");
+
+ Dom.addClass(aNodes, "disabled");
+
+ sImageSrc = this.DISABLED_SUBMENU_INDICATOR_IMAGE_PATH;
+ sImageAlt = this.DISABLED_SUBMENU_INDICATOR_ALT_TEXT;
+
+ }
+ else {
+
+ oAnchor.setAttribute("href", oConfig.getProperty("url"));
+
+ Dom.removeClass(aNodes, "disabled");
+
+ sImageSrc = this.SUBMENU_INDICATOR_IMAGE_PATH;
+ sImageAlt = this.COLLAPSED_SUBMENU_INDICATOR_ALT_TEXT;
+
+ }
+
+
+ if(oImg) {
+
+ oImg.src = this.imageRoot + sImageSrc;
+ oImg.alt = sImageAlt;
+
+ }
+
+ },
+
+
+ /**
+ * Event handler for when the "selected" configuration property of
+ * a MenuModuleItem instance changes.
+ * @param {String} p_sType The name of the event that was fired.
+ * @param {Array} p_aArgs Collection of arguments sent when the
+ * event was fired.
+ * @param {YAHOO.widget.MenuModuleItem} p_oItem The MenuModuleItem instance
+ * that fired the event.
+ */
+ configSelected: function(p_sType, p_aArgs, p_oItem) {
+
+ if(!this.cfg.getProperty("disabled")) {
+
+ var Dom = this._oDom;
+ var bSelected = p_aArgs[0];
+ var oEM = this._oHelpTextEM;
+ var aNodes = [this.element, this._oAnchor];
+ var oImg = this.submenuIndicator;
+ var sImageSrc;
+
+
+ if(oEM) {
+
+ aNodes[2] = oEM;
+
+ }
+
+ if(bSelected) {
+
+ Dom.addClass(aNodes, "selected");
+ sImageSrc = this.SELECTED_SUBMENU_INDICATOR_IMAGE_PATH;
+
+ }
+ else {
+
+ Dom.removeClass(aNodes, "selected");
+ sImageSrc = this.SUBMENU_INDICATOR_IMAGE_PATH;
+
+ }
+
+ if(oImg) {
+
+ oImg.src = document.images[(this.imageRoot + sImageSrc)].src;
+
+ }
+
+ }
+
+ },
+
+
+ /**
+ * Event handler for when the "submenu" configuration property of
+ * a MenuModuleItem instance changes.
+ * @param {String} p_sType The name of the event that was fired.
+ * @param {Array} p_aArgs Collection of arguments sent when the
+ * event was fired.
+ * @param {YAHOO.widget.MenuModuleItem} p_oItem The MenuModuleItem instance
+ * that fired the event.
+ */
+ configSubmenu: function(p_sType, p_aArgs, p_oItem) {
+
+ var Dom = this._oDom;
+ var oEl = this.element;
+ var oSubmenu = p_aArgs[0];
+ var oImg = this.submenuIndicator;
+ var oConfig = this.cfg;
+ var aNodes = [this.element, this._oAnchor];
+
+
+ if(oSubmenu) {
+
+ // Set the submenu's parent to this MenuModuleItem instance
+
+ oSubmenu.parent = this;
+
+ this._oSubmenu = oSubmenu;
+
+
+ if(!oImg) {
+
+ var me = this;
+
+ function preloadImage(p_sPath) {
+
+ var sPath = me.imageRoot + p_sPath;
+
+ if(!document.images[sPath]) {
+
+ var oImg = document.createElement("img");
+ oImg.src = sPath;
+ oImg.name = sPath;
+ oImg.id = sPath;
+ oImg.style.display = "none";
+
+ document.body.appendChild(oImg);
+
+ }
+
+ }
+
+ preloadImage(this.SUBMENU_INDICATOR_IMAGE_PATH);
+ preloadImage(this.SELECTED_SUBMENU_INDICATOR_IMAGE_PATH);
+ preloadImage(this.DISABLED_SUBMENU_INDICATOR_IMAGE_PATH);
+
+ oImg = document.createElement("img");
+ oImg.src = (this.imageRoot + this.SUBMENU_INDICATOR_IMAGE_PATH);
+ oImg.alt = this.COLLAPSED_SUBMENU_INDICATOR_ALT_TEXT;
+
+ oEl.appendChild(oImg);
+
+ this.submenuIndicator = oImg;
+
+ Dom.addClass(aNodes, "hassubmenu");
+
+
+ if(oConfig.getProperty("disabled")) {
+
+ oConfig.refireEvent("disabled");
+
+ }
+
+ if(oConfig.getProperty("selected")) {
+
+ oConfig.refireEvent("selected");
+
+ }
+
+ }
+
+ }
+ else {
+
+ Dom.removeClass(aNodes, "hassubmenu");
+
+ if(oImg) {
+
+ oEl.removeChild(oImg);
+
+ }
+
+ if(this._oSubmenu) {
+
+ this._oSubmenu.destroy();
+
+ }
+
+ }
+
+ },
+
+
+ // Public methods
+
+ /**
+ * Initializes an item's configurable properties.
+ */
+ initDefaultConfig : function() {
+
+ var oConfig = this.cfg;
+ var CheckBoolean = oConfig.checkBoolean;
+
+
+ // Define the config properties
+
+ oConfig.addProperty(
+ "text",
+ {
+ value: "",
+ handler: this.configText,
+ validator: this._checkString,
+ suppressEvent: true
+ }
+ );
+
+ oConfig.addProperty("helptext", { handler: this.configHelpText });
+
+ oConfig.addProperty(
+ "url",
+ { value: "#", handler: this.configURL, suppressEvent: true }
+ );
+
+ oConfig.addProperty(
+ "emphasis",
+ {
+ value: false,
+ handler: this.configEmphasis,
+ validator: CheckBoolean,
+ suppressEvent: true
+ }
+ );
+
+ oConfig.addProperty(
+ "strongemphasis",
+ {
+ value: false,
+ handler: this.configStrongEmphasis,
+ validator: CheckBoolean,
+ suppressEvent: true
+ }
+ );
+
+ oConfig.addProperty(
+ "disabled",
+ {
+ value: false,
+ handler: this.configDisabled,
+ validator: CheckBoolean,
+ suppressEvent: true
+ }
+ );
+
+ oConfig.addProperty(
+ "selected",
+ {
+ value: false,
+ handler: this.configSelected,
+ validator: CheckBoolean,
+ suppressEvent: true
+ }
+ );
+
+ oConfig.addProperty("submenu", { handler: this.configSubmenu });
+
+ },
+
+
+ /**
+ * Finds the next enabled MenuModuleItem instance in a MenuModule instance
+ * @return Returns a MenuModuleItem instance.
+ * @type YAHOO.widget.MenuModuleItem
+ */
+ getNextEnabledSibling: function() {
+
+ if(this.parent instanceof YAHOO.widget.MenuModule) {
+
+ var nGroupIndex = this.groupIndex;
+
+ /**
+ * Returns the next item in an array
+ * @param {p_aArray} An array
+ * @param {p_nStartIndex} The index to start searching the array
+ * @ignore
+ * @return Returns an item in an array
+ * @type Object
+ */
+ function getNextArrayItem(p_aArray, p_nStartIndex) {
+
+ return p_aArray[p_nStartIndex] ||
+ getNextArrayItem(p_aArray, (p_nStartIndex+1));
+
+ }
+
+
+ var aItemGroups = this.parent.getItemGroups();
+ var oNextItem;
+
+
+ if(this.index < (aItemGroups[nGroupIndex].length - 1)) {
+
+ oNextItem = getNextArrayItem(
+ aItemGroups[nGroupIndex],
+ (this.index+1)
+ );
+
+ }
+ else {
+
+ var nNextGroupIndex;
+
+ if(nGroupIndex < (aItemGroups.length - 1)) {
+
+ nNextGroupIndex = nGroupIndex + 1;
+
+ }
+ else {
+
+ nNextGroupIndex = 0;
+
+ }
+
+ var aNextGroup = getNextArrayItem(aItemGroups, nNextGroupIndex);
+
+ // Retrieve the first MenuModuleItem instance in the next group
+
+ oNextItem = getNextArrayItem(aNextGroup, 0);
+
+ }
+
+ return oNextItem.cfg.getProperty("disabled") ?
+ oNextItem.getNextEnabledSibling() : oNextItem;
+
+ }
+
+ },
+
+
+ /**
+ * Finds the previous enabled MenuModuleItem instance in a
+ * MenuModule instance
+ * @return Returns a MenuModuleItem instance.
+ * @type YAHOO.widget.MenuModuleItem
+ */
+ getPreviousEnabledSibling: function() {
+
+ if(this.parent instanceof YAHOO.widget.MenuModule) {
+
+ var nGroupIndex = this.groupIndex;
+
+ /**
+ * Returns the previous item in an array
+ * @param {p_aArray} An array
+ * @param {p_nStartIndex} The index to start searching the array
+ * @ignore
+ * @return Returns an item in an array
+ * @type Object
+ */
+ function getPreviousArrayItem(p_aArray, p_nStartIndex) {
+
+ return p_aArray[p_nStartIndex] ||
+ getPreviousArrayItem(p_aArray, (p_nStartIndex-1));
+
+ }
+
+
+ /**
+ * Get the index of the first item in an array
+ * @param {p_aArray} An array
+ * @param {p_nStartIndex} The index to start searching the array
+ * @ignore
+ * @return Returns an item in an array
+ * @type Object
+ */
+ function getFirstItemIndex(p_aArray, p_nStartIndex) {
+
+ return p_aArray[p_nStartIndex] ?
+ p_nStartIndex :
+ getFirstItemIndex(p_aArray, (p_nStartIndex+1));
+
+ }
+
+ var aItemGroups = this.parent.getItemGroups();
+ var oPreviousItem;
+
+ if(
+ this.index > getFirstItemIndex(aItemGroups[nGroupIndex], 0)
+ ) {
+
+ oPreviousItem =
+ getPreviousArrayItem(
+ aItemGroups[nGroupIndex],
+ (this.index-1)
+ );
+
+ }
+ else {
+
+ var nPreviousGroupIndex;
+
+ if(nGroupIndex > getFirstItemIndex(aItemGroups, 0)) {
+
+ nPreviousGroupIndex = nGroupIndex - 1;
+
+ }
+ else {
+
+ nPreviousGroupIndex = aItemGroups.length - 1;
+
+ }
+
+ var aPreviousGroup =
+ getPreviousArrayItem(aItemGroups, nPreviousGroupIndex);
+
+ oPreviousItem =
+ getPreviousArrayItem(
+ aPreviousGroup,
+ (aPreviousGroup.length - 1)
+ );
+
+ }
+
+ return oPreviousItem.cfg.getProperty("disabled") ?
+ oPreviousItem.getPreviousEnabledSibling() : oPreviousItem;
+
+ }
+
+ },
+
+
+ /**
+ * Causes a MenuModuleItem instance to receive the focus and fires the
+ * focus event.
+ */
+ focus: function() {
+
+ var oParent = this.parent;
+ var oAnchor = this._oAnchor;
+ var oActiveItem = oParent.activeItem;
+
+ if(
+ !this.cfg.getProperty("disabled") &&
+ oParent &&
+ oParent.cfg.getProperty("visible")
+ ) {
+
+ if(oActiveItem) {
+
+ oActiveItem.blur();
+
+ }
+
+ oAnchor.focus();
+
+ /*
+ Opera 8.5 doesn't always focus the anchor if a MenuModuleItem
+ instance has a submenu, this is fixed by calling "focus"
+ twice.
+ */
+ if(oParent && this.browser == "opera" && this._oSubmenu) {
+
+ oAnchor.focus();
+
+ }
+
+ this.focusEvent.fire();
+
+ }
+
+ },
+
+
+ /**
+ * Causes a MenuModuleItem instance to lose focus and fires the onblur event.
+ */
+ blur: function() {
+
+ var oParent = this.parent;
+
+ if(
+ !this.cfg.getProperty("disabled") &&
+ oParent &&
+ this._oDom.getStyle(oParent.element, "visibility") == "visible"
+ ) {
+
+ this._oAnchor.blur();
+
+ this.blurEvent.fire();
+
+ }
+
+ },
+
+
+ /**
+ * Removes a MenuModuleItem instance's HTMLLIElement from it's parent
+ * HTMLUListElement node.
+ */
+ destroy: function() {
+
+ var oEl = this.element;
+
+ if(oEl) {
+
+ // Remove CustomEvent listeners
+
+ this.mouseOverEvent.unsubscribeAll();
+ this.mouseOutEvent.unsubscribeAll();
+ this.mouseDownEvent.unsubscribeAll();
+ this.mouseUpEvent.unsubscribeAll();
+ this.clickEvent.unsubscribeAll();
+ this.keyPressEvent.unsubscribeAll();
+ this.keyDownEvent.unsubscribeAll();
+ this.keyUpEvent.unsubscribeAll();
+ this.focusEvent.unsubscribeAll();
+ this.blurEvent.unsubscribeAll();
+ this.cfg.configChangedEvent.unsubscribeAll();
+
+
+ // Remove the element from the parent node
+
+ var oParentNode = oEl.parentNode;
+
+ if(oParentNode) {
+
+ oParentNode.removeChild(oEl);
+
+ this.destroyEvent.fire();
+
+ }
+
+ this.destroyEvent.unsubscribeAll();
+
+ }
+
+ }
+
+};
+
+
+/**
+* @class Extends YAHOO.widget.MenuModule to provide a set of default mouse and
+* key event behaviors.
+* @constructor
+* @extends YAHOO.widget.MenuModule
+* @base YAHOO.widget.MenuModule
+* @param {String or HTMLElement} p_oElement String id or HTMLElement
+* (either HTMLSelectElement or HTMLDivElement) of the source HTMLElement node.
+* @param {Object} p_oConfig Optional. The configuration object literal
+* containing the configuration for a Menu instance. See
+* configuration class documentation for more details.
+*/
+YAHOO.widget.Menu = function(p_oElement, p_oConfig) {
+
+ YAHOO.widget.Menu.superclass.constructor.call(
+ this,
+ p_oElement,
+ p_oConfig
+ );
+
+};
+
+YAHOO.extend(YAHOO.widget.Menu, YAHOO.widget.MenuModule);
+
+
+/**
+* The Menu class's initialization method. This method is automatically
+* called by the constructor, and sets up all DOM references for pre-existing
+* markup, and creates required markup if it is not already present.
+* @param {String or HTMLElement} p_oElement String id or HTMLElement
+* (either HTMLSelectElement or HTMLDivElement) of the source HTMLElement node.
+* @param {Object} p_oConfig Optional. The configuration object literal
+* containing the configuration for a Menu instance. See
+* configuration class documentation for more details.
+*/
+YAHOO.widget.Menu.prototype.init = function(p_oElement, p_oConfig) {
+
+ if(!this.ITEM_TYPE) {
+
+ this.ITEM_TYPE = YAHOO.widget.MenuItem;
+
+ }
+
+
+ // Call the init of the superclass (YAHOO.widget.Menu)
+
+ YAHOO.widget.Menu.superclass.init.call(this, p_oElement);
+
+
+ this.beforeInitEvent.fire(YAHOO.widget.Menu);
+
+
+ // Add event handlers
+
+ this.showEvent.subscribe(this._onMenuShow, this, true);
+ this.mouseOverEvent.subscribe(this._onMenuMouseOver, this, true);
+ this.keyDownEvent.subscribe(this._onMenuKeyDown, this, true);
+
+
+ if(p_oConfig) {
+
+ this.cfg.applyConfig(p_oConfig, true);
+
+ }
+
+ this.initEvent.fire(YAHOO.widget.Menu);
+
+};
+
+
+// Private event handlers
+
+/**
+* "show" Custom Event handler for a menu.
+* @private
+* @param {String} p_sType The name of the event that was fired.
+* @param {Array} p_aArgs Collection of arguments sent when the event
+* was fired.
+* @param {YAHOO.widget.Menu} p_oMenu The menu that fired the event.
+*/
+YAHOO.widget.Menu.prototype._onMenuShow =
+
+ function(p_sType, p_aArgs, p_oMenu) {
+
+ var oParent = this.parent;
+
+ if(oParent && oParent.parent instanceof YAHOO.widget.Menu) {
+
+ var aAlignment = oParent.parent.cfg.getProperty("submenualignment");
+
+ this.cfg.setProperty(
+ "submenualignment",
+ [ aAlignment[0], aAlignment[1] ]
+ );
+
+ }
+
+ };
+
+
+/**
+* "mouseover" Custom Event handler for a Menu instance.
+* @private
+* @param {String} p_sType The name of the event that was fired.
+* @param {Array} p_aArgs Collection of arguments sent when the event
+* was fired.
+* @param {YAHOO.widget.Menu} p_oMenu The Menu instance that fired the event.
+*/
+YAHOO.widget.Menu.prototype._onMenuMouseOver =
+
+ function(p_sType, p_aArgs, p_oMenu) {
+
+ /*
+ If the menu is a submenu, then select the menu's parent
+ MenuItem instance
+ */
+
+ if(this.parent) {
+
+ this.parent.cfg.setProperty("selected", true);
+
+ }
+
+ };
+
+
+/**
+* "mouseover" Custom Event handler for a Menu instance.
+* @private
+* @param {String} p_sType The name of the event that was fired.
+* @param {Array} p_aArgs Collection of arguments sent when the event
+* was fired.
+* @param {YAHOO.widget.Menu} p_oMenu The Menu instance that fired the event.
+*/
+YAHOO.widget.Menu.prototype._onMenuKeyDown =
+
+ function(p_sType, p_aArgs, p_oMenu) {
+
+ if(this.cfg.getProperty("position") == "dynamic") {
+
+ var oDOMEvent = p_aArgs[0];
+ var oParent = this.parent;
+
+ if(oDOMEvent.keyCode == 27) { // Esc key
+
+ this.hide();
+
+ // Set focus to the parent MenuItem if one exists
+
+ if(oParent) {
+
+ oParent.focus();
+
+ if(oParent.parent instanceof YAHOO.widget.Menu) {
+
+ oParent.cfg.setProperty("selected", true);
+
+ }
+
+ YAHOO.util.Event.preventDefault(oDOMEvent);
+
+ }
+
+ }
+
+ }
+
+ };
+
+
+// Public event handlers
+
+/**
+* Event handler fired when the resize monitor element is resized.
+*/
+YAHOO.widget.Menu.prototype.onDomResize = function(e, obj) {
+
+ if(!this._handleResize) {
+
+ this._handleResize = true;
+ return;
+
+ }
+
+ this.logger.log("Browser font sized changed.");
+
+ var me = this;
+ var oConfig = this.cfg;
+
+ if(oConfig.getProperty("position") == "dynamic") {
+
+ oConfig.setProperty("width", (this._getOffsetWidth() + "px"));
+
+ if(this.parent && oConfig.getProperty("visible")) {
+
+ function align() {
+
+ me.align();
+
+ }
+
+ window.setTimeout(align, 0);
+
+ }
+
+ }
+
+ YAHOO.widget.Menu.superclass.onDomResize.call(this, e, obj);
+
+};
+
+
+/**
+* @class The MenuItem class allows you to create and modify an item for a
+* Menu instance. MenuItem extends YAHOO.widget.MenuModuleItem to provide a
+* set of default mouse and key event behaviors.
+* @constructor
+* @extends YAHOO.widget.MenuModuleItem
+* @base YAHOO.widget.MenuModuleItem
+* @param {String or HTMLElement} p_oObject String or HTMLElement
+* (either HTMLLIElement, HTMLOptGroupElement or HTMLOptionElement) of the
+* source HTMLElement node.
+* @param {Object} p_oConfig The configuration object literal containing
+* the configuration for a MenuItem instance. See the configuration
+* class documentation for more details.
+*/
+YAHOO.widget.MenuItem = function(p_oObject, p_oConfig) {
+
+ YAHOO.widget.MenuItem.superclass.constructor.call(
+ this,
+ p_oObject,
+ p_oConfig
+ );
+
+};
+
+YAHOO.extend(YAHOO.widget.MenuItem, YAHOO.widget.MenuModuleItem);
+
+
+/**
+* The MenuItem class's initialization method. This method is automatically
+* called by the constructor, and sets up all DOM references for
+* pre-existing markup, and creates required markup if it is not
+* already present.
+* @param {String or HTMLElement} p_oObject String or HTMLElement
+* (either HTMLLIElement, HTMLOptGroupElement or HTMLOptionElement) of the
+* source HTMLElement node.
+* @param {Object} p_oConfig The configuration object literal containing
+* the configuration for a MenuItem instance. See the configuration
+* class documentation for more details.
+*/
+YAHOO.widget.MenuItem.prototype.init = function(p_oObject, p_oConfig) {
+
+ if(!this.SUBMENU_TYPE) {
+
+ this.SUBMENU_TYPE = YAHOO.widget.Menu;
+
+ }
+
+ if(!this.SUBMENU_ITEM_TYPE) {
+
+ this.SUBMENU_ITEM_TYPE = YAHOO.widget.MenuItem;
+
+ }
+
+
+ /*
+ Call the init of the superclass (YAHOO.widget.MenuModuleItem)
+ Note: We don't pass the user config in here yet
+ because we only want it executed once, at the lowest
+ subclass level.
+ */
+
+ YAHOO.widget.MenuItem.superclass.init.call(this, p_oObject);
+
+
+ // Add event handlers to each "MenuItem" instance
+
+ this.keyDownEvent.subscribe(this._onKeyDown, this, true);
+ this.mouseOverEvent.subscribe(this._onMouseOver, this, true);
+ this.mouseOutEvent.subscribe(this._onMouseOut, this, true);
+
+ var oConfig = this.cfg;
+
+ if(p_oConfig) {
+
+ oConfig.applyConfig(p_oConfig, true);
+
+ }
+
+ oConfig.fireQueue();
+
+};
+
+
+// Constants
+
+/**
+* Constant representing the path to the image to be used for the checked state.
+* @final
+* @type String
+*/
+YAHOO.widget.MenuItem.prototype.CHECKED_IMAGE_PATH =
+ "nt/ic/ut/bsc/menuchk8_nrm_1.gif";
+
+/**
+* Constant representing the path to the image to be used for the selected
+* checked state.
+* @final
+* @type String
+*/
+YAHOO.widget.MenuItem.prototype.SELECTED_CHECKED_IMAGE_PATH =
+ "nt/ic/ut/bsc/menuchk8_hov_1.gif";
+
+/**
+* Constant representing the path to the image to be used for the disabled
+* checked state.
+* @final
+* @type String
+*/
+YAHOO.widget.MenuItem.prototype.DISABLED_CHECKED_IMAGE_PATH =
+ "nt/ic/ut/bsc/menuchk8_dim_1.gif";
+
+/**
+* Constant representing the alt text for the image to be used for the
+* checked image.
+* @final
+* @type String
+*/
+YAHOO.widget.MenuItem.prototype.CHECKED_IMAGE_ALT_TEXT = "Checked.";
+
+
+/**
+* Constant representing the alt text for the image to be used for the
+* checked image when the item is disabled.
+* @final
+* @type String
+*/
+YAHOO.widget.MenuItem.prototype.DISABLED_CHECKED_IMAGE_ALT_TEXT =
+ "Checked. (Item disabled.)";
+
+
+// Private properties
+
+/**
+* Reference to the HTMLImageElement used to create the checked
+* indicator for a MenuItem instance.
+* @private
+* @type {HTMLImageElement}
+*/
+YAHOO.widget.MenuItem.prototype._checkImage = null;
+
+
+// Private event handlers
+
+
+/**
+* "keydown" Custom Event handler for a MenuItem instance.
+* @private
+* @param {String} p_sType The name of the event that was fired.
+* @param {Array} p_aArgs Collection of arguments sent when the event
+* was fired.
+* @param {YAHOO.widget.MenuModule} p_oMenuModule The MenuModule instance that
+* fired the event.
+*/
+YAHOO.widget.MenuItem.prototype._onKeyDown =
+
+ function(p_sType, p_aArgs, p_oMenuItem) {
+
+ var Event = YAHOO.util.Event;
+ var oDOMEvent = p_aArgs[0];
+ var oParent = this.parent;
+ var oConfig = this.cfg;
+ var oMenuItem;
+
+
+ switch(oDOMEvent.keyCode) {
+
+ case 38: // Up arrow
+ case 40: // Down arrow
+
+ if(
+ this == oParent.activeItem &&
+ !oConfig.getProperty("selected")
+ ) {
+
+ oConfig.setProperty("selected", true);
+
+ }
+ else {
+
+ var oNextItem = (oDOMEvent.keyCode == 38) ?
+ this.getPreviousEnabledSibling() :
+ this.getNextEnabledSibling();
+
+ if(oNextItem) {
+
+ oParent.clearActiveItem();
+
+ oNextItem.cfg.setProperty("selected", true);
+
+ oNextItem.focus();
+
+ }
+
+ }
+
+ Event.preventDefault(oDOMEvent);
+
+ break;
+
+
+ case 39: // Right arrow
+
+ oParent.clearActiveItem();
+
+ oConfig.setProperty("selected", true);
+
+ this.focus();
+
+
+ var oSubmenu = oConfig.getProperty("submenu");
+
+ if(oSubmenu) {
+
+ oSubmenu.show();
+ oSubmenu.setInitialSelection();
+
+ }
+ else if(
+ YAHOO.widget.MenuBarItem &&
+ oParent.parent &&
+ oParent.parent instanceof YAHOO.widget.MenuBarItem
+ ) {
+
+ oParent.hide();
+
+ // Set focus to the parent MenuItem if one exists
+
+ oMenuItem = oParent.parent;
+
+ if(oMenuItem) {
+
+ oMenuItem.focus();
+ oMenuItem.cfg.setProperty("selected", true);
+
+ }
+
+ }
+
+ Event.preventDefault(oDOMEvent);
+
+ break;
+
+
+ case 37: // Left arrow
+
+ // Only hide if this this is a MenuItem of a submenu
+
+ if(oParent.parent) {
+
+ oParent.hide();
+
+ // Set focus to the parent MenuItem if one exists
+
+ oMenuItem = oParent.parent;
+
+ if(oMenuItem) {
+
+ oMenuItem.focus();
+ oMenuItem.cfg.setProperty("selected", true);
+
+ }
+
+ }
+
+ Event.preventDefault(oDOMEvent);
+
+ break;
+
+ }
+
+ };
+
+
+/**
+* "mouseover" Custom Event handler for a MenuItem instance.
+* @private
+* @param {String} p_sType The name of the event that was fired.
+* @param {Array} p_aArgs Collection of arguments sent when the event
+* was fired.
+* @param {YAHOO.widget.MenuModule} p_oMenuModule The MenuModule instance that
+* fired the event.
+*/
+YAHOO.widget.MenuItem.prototype._onMouseOver =
+
+ function(p_sType, p_aArgs, p_oMenuItem) {
+
+ var oParent = this.parent;
+ var oConfig = this.cfg;
+ var oActiveItem = oParent.activeItem;
+
+
+ // Hide any other submenus that might be visible
+
+ if(oActiveItem && oActiveItem != this) {
+
+ oParent.clearActiveItem();
+
+ }
+
+
+ // Select and focus the current MenuItem instance
+
+ oConfig.setProperty("selected", true);
+ this.focus();
+
+
+ // Show the submenu for this instance
+
+ var oSubmenu = oConfig.getProperty("submenu");
+
+ if(oSubmenu) {
+
+ oSubmenu.show();
+
+ }
+
+ };
+
+
+/**
+* "mouseout" Custom Event handler for a MenuItem instance.
+* @private
+* @param {String} p_sType The name of the event that was fired.
+* @param {Array} p_aArgs Collection of arguments sent when the event
+* was fired.
+* @param {YAHOO.widget.MenuModule} p_oMenuModule The MenuModule instance that
+* fired the event.
+*/
+YAHOO.widget.MenuItem.prototype._onMouseOut =
+
+ function(p_sType, p_aArgs, p_oMenuItem) {
+
+ var oConfig = this.cfg;
+ var oSubmenu = oConfig.getProperty("submenu");
+
+ oConfig.setProperty("selected", false);
+
+ if(oSubmenu) {
+
+ var oDOMEvent = p_aArgs[0];
+ var oRelatedTarget = YAHOO.util.Event.getRelatedTarget(oDOMEvent);
+
+ if(
+ !(
+ oRelatedTarget == oSubmenu.element ||
+ YAHOO.util.Dom.isAncestor(oSubmenu.element, oRelatedTarget)
+ )
+ ) {
+
+ oSubmenu.hide();
+
+ }
+
+ }
+
+ };
+
+
+// Event handlers for configuration properties
+
+/**
+* Event handler for when the "checked" configuration property of
+* a MenuItem instance changes.
+* @param {String} p_sType The name of the event that was fired.
+* @param {Array} p_aArgs Collection of arguments sent when the
+* event was fired.
+* @param {YAHOO.widget.MenuItem} p_oItem The MenuItem instance
+* that fired the event.
+*/
+YAHOO.widget.MenuItem.prototype.configChecked =
+
+ function(p_sType, p_aArgs, p_oItem) {
+
+ var Dom = YAHOO.util.Dom;
+ var bChecked = p_aArgs[0];
+ var oEl = this.element;
+ var oConfig = this.cfg;
+ var oImg;
+
+
+ if(bChecked) {
+
+ var me = this;
+
+ function preloadImage(p_sPath) {
+
+ var sPath = me.imageRoot + p_sPath;
+
+ if(!document.images[sPath]) {
+
+ var oImg = document.createElement("img");
+ oImg.src = sPath;
+ oImg.name = sPath;
+ oImg.id = sPath;
+ oImg.style.display = "none";
+
+ document.body.appendChild(oImg);
+
+ }
+
+ }
+
+ preloadImage(this.CHECKED_IMAGE_PATH);
+ preloadImage(this.SELECTED_CHECKED_IMAGE_PATH);
+ preloadImage(this.DISABLED_CHECKED_IMAGE_PATH);
+
+
+ oImg = document.createElement("img");
+ oImg.src = (this.imageRoot + this.CHECKED_IMAGE_PATH);
+ oImg.alt = this.CHECKED_IMAGE_ALT_TEXT;
+
+ var oSubmenu = this.cfg.getProperty("submenu");
+
+ if(oSubmenu) {
+
+ oEl.insertBefore(oImg, oSubmenu.element);
+
+ }
+ else {
+
+ oEl.appendChild(oImg);
+
+ }
+
+
+ Dom.addClass([oEl, oImg], "checked");
+
+ this._checkImage = oImg;
+
+ if(oConfig.getProperty("disabled")) {
+
+ oConfig.refireEvent("disabled");
+
+ }
+
+ if(oConfig.getProperty("selected")) {
+
+ oConfig.refireEvent("selected");
+
+ }
+
+ }
+ else {
+
+ oImg = this._checkImage;
+
+ Dom.removeClass([oEl, oImg], "checked");
+
+ if(oImg) {
+
+ oEl.removeChild(oImg);
+
+ }
+
+ this._checkImage = null;
+
+ }
+
+ };
+
+
+/**
+* Event handler for when the "selected" configuration property of
+* a MenuItem instance changes.
+* @param {String} p_sType The name of the event that was fired.
+* @param {Array} p_aArgs Collection of arguments sent when the
+* event was fired.
+* @param {YAHOO.widget.MenuItem} p_oItem The MenuItem instance
+* that fired the event.
+*/
+YAHOO.widget.MenuItem.prototype.configSelected =
+
+ function(p_sType, p_aArgs, p_oItem) {
+
+ YAHOO.widget.MenuItem.superclass.configSelected.call(
+ this, p_sType, p_aArgs, p_oItem
+ );
+
+ var oConfig = this.cfg;
+
+ if(!oConfig.getProperty("disabled") && oConfig.getProperty("checked")) {
+
+ var bSelected = p_aArgs[0];
+
+ var sSrc = this.imageRoot + (bSelected ?
+ this.SELECTED_CHECKED_IMAGE_PATH : this.CHECKED_IMAGE_PATH);
+
+ this._checkImage.src = document.images[sSrc].src;
+
+ }
+
+ };
+
+
+/**
+* Event handler for when the "disabled" configuration property of
+* a MenuItem instance changes.
+* @param {String} p_sType The name of the event that was fired.
+* @param {Array} p_aArgs Collection of arguments sent when the
+* event was fired.
+* @param {YAHOO.widget.MenuItem} p_oItem The MenuItem instance
+* that fired the event.
+*/
+YAHOO.widget.MenuItem.prototype.configDisabled =
+
+ function(p_sType, p_aArgs, p_oItem) {
+
+ YAHOO.widget.MenuItem.superclass.configDisabled.call(
+ this, p_sType, p_aArgs, p_oItem
+ );
+
+ if(this.cfg.getProperty("checked")) {
+
+ var bDisabled = p_aArgs[0];
+ var sAlt = this.CHECKED_IMAGE_ALT_TEXT;
+ var sSrc = this.CHECKED_IMAGE_PATH;
+ var oImg = this._checkImage;
+
+ if(bDisabled) {
+
+ sAlt = this.DISABLED_CHECKED_IMAGE_ALT_TEXT;
+ sSrc = this.DISABLED_CHECKED_IMAGE_PATH;
+
+ }
+
+ oImg.src = document.images[(this.imageRoot + sSrc)].src;
+ oImg.alt = sAlt;
+
+ }
+
+ };
+
+
+// Public methods
+
+/**
+* Initializes the class's configurable properties which can be changed using
+* the MenuModule's Config object (cfg).
+*/
+YAHOO.widget.MenuItem.prototype.initDefaultConfig = function() {
+
+ YAHOO.widget.MenuItem.superclass.initDefaultConfig.call(this);
+
+ // Add configuration properties
+
+ this.cfg.addProperty(
+ "checked",
+ {
+ value: false,
+ handler: this.configChecked,
+ validator: this.cfg.checkBoolean,
+ suppressEvent: true
+ }
+ );
+
+};
+
+
+/**
+* @class Creates a list of options which vary depending on the context in
+* which the menu is invoked.
+* @constructor
+* @extends YAHOO.widget.Menu
+* @base YAHOO.widget.Menu
+* @param {String or HTMLElement} p_oElement String id or HTMLElement
+* (either HTMLSelectElement or HTMLDivElement) of the source HTMLElement node.
+* @param {Object} p_oConfig Optional. The configuration object literal
+* containing the configuration for a ContextMenu instance. See
+* configuration class documentation for more details.
+*/
+YAHOO.widget.ContextMenu = function(p_oElement, p_oConfig) {
+
+ YAHOO.widget.ContextMenu.superclass.constructor.call(
+ this,
+ p_oElement,
+ p_oConfig
+ );
+
+};
+
+YAHOO.extend(YAHOO.widget.ContextMenu, YAHOO.widget.Menu);
+
+
+YAHOO.widget.ContextMenu.prototype._oTrigger = null;
+
+
+/**
+* The ContextMenu class's initialization method. This method is automatically
+* called by the constructor, and sets up all DOM references for pre-existing
+* markup, and creates required markup if it is not already present.
+* @param {String or HTMLElement} p_oElement String id or HTMLElement
+* (either HTMLSelectElement or HTMLDivElement) of the source HTMLElement node.
+* @param {Object} p_oConfig Optional. The configuration object literal
+* containing the configuration for a ContextMenu instance. See
+* configuration class documentation for more details.
+*/
+YAHOO.widget.ContextMenu.prototype.init = function(p_oElement, p_oConfig) {
+
+ if(!this.ITEM_TYPE) {
+
+ this.ITEM_TYPE = YAHOO.widget.ContextMenuItem;
+
+ }
+
+
+ // Call the init of the superclass (YAHOO.widget.Menu)
+
+ YAHOO.widget.ContextMenu.superclass.init.call(this, p_oElement);
+
+
+ this.beforeInitEvent.fire(YAHOO.widget.ContextMenu);
+
+
+ if(p_oConfig) {
+
+ this.cfg.applyConfig(p_oConfig, true);
+
+ }
+
+
+ this.initEvent.fire(YAHOO.widget.ContextMenu);
+
+
+};
+
+
+// Private event handlers
+
+/**
+* "mousedown" event handler for the document object.
+* @private
+* @param {Event} p_oEvent Event object passed back by the
+* event utility (YAHOO.util.Event).
+* @param {YAHOO.widget.ContextMenu} p_oMenu The ContextMenu instance
+* handling the event.
+*/
+YAHOO.widget.ContextMenu.prototype._onDocumentMouseDown =
+
+ function(p_oEvent, p_oMenu) {
+
+ var oTarget = YAHOO.util.Event.getTarget(p_oEvent);
+ var oTargetEl = this._oTargetElement;
+
+ if(
+ oTarget != oTargetEl ||
+ !YAHOO.util.Dom.isAncestor(oTargetEl, oTarget)
+ ) {
+
+ this.hide();
+
+ }
+
+ };
+
+
+/**
+* "click" event handler for the HTMLElement node that triggered the event.
+* Used to cancel default behaviors in Opera.
+* @private
+* @param {Event} p_oEvent Event object passed back by the
+* event utility (YAHOO.util.Event).
+* @param {YAHOO.widget.ContextMenu} p_oMenu The ContextMenu instance
+* handling the event.
+*/
+YAHOO.widget.ContextMenu.prototype._onTriggerClick =
+
+ function(p_oEvent, p_oMenu) {
+
+ if(p_oEvent.ctrlKey) {
+
+ YAHOO.util.Event.stopEvent(p_oEvent);
+
+ }
+
+ };
+
+
+/**
+* "contextmenu" event handler ("mousedown" for Opera) for the HTMLElement
+* node that triggered the event.
+* @private
+* @param {Event} p_oEvent Event object passed back by the
+* event utility (YAHOO.util.Event).
+* @param {YAHOO.widget.ContextMenu} p_oMenu The ContextMenu instance
+* handling the event.
+*/
+YAHOO.widget.ContextMenu.prototype._onTriggerContextMenu =
+
+ function(p_oEvent, p_oMenu) {
+
+ var Event = YAHOO.util.Event;
+ var oConfig = this.cfg;
+
+ if(p_oEvent.type == "mousedown") {
+
+ if(!p_oEvent.ctrlKey) {
+
+ return;
+
+ }
+
+ Event.stopEvent(p_oEvent);
+
+ }
+
+
+ this.contextEventTarget = Event.getTarget(p_oEvent);
+
+
+ // Position and display the context menu
+
+ var nX = Event.getPageX(p_oEvent);
+ var nY = Event.getPageY(p_oEvent);
+
+
+ oConfig.applyConfig( { x:nX, y:nY, visible:true } );
+ oConfig.fireQueue();
+
+
+ // Prevent the browser's default context menu from appearing
+
+ Event.preventDefault(p_oEvent);
+
+ };
+
+
+// Public properties
+
+/**
+* Returns the HTMLElement node that was the target of the "contextmenu"
+* DOM event.
+* @type HTMLElement
+*/
+YAHOO.widget.ContextMenu.prototype.contextEventTarget = null;
+
+
+// Public methods
+
+/**
+* Initializes the class's configurable properties which can be changed using
+* a ContextMenu instance's Config object (cfg).
+*/
+YAHOO.widget.ContextMenu.prototype.initDefaultConfig = function() {
+
+ YAHOO.widget.ContextMenu.superclass.initDefaultConfig.call(this);
+
+
+ // Add a configuration property
+
+ this.cfg.addProperty("trigger", { handler: this.configTrigger });
+
+};
+
+
+// Event handlers for configuration properties
+
+/**
+* Event handler for when the "trigger" configuration property of
+* a MenuItem instance.
+* @param {String} p_sType The name of the event that was fired.
+* @param {Array} p_aArgs Collection of arguments sent when the
+* event was fired.
+* @param {YAHOO.widget.ContextMenu} p_oMenu The ContextMenu that instance fired
+* the event.
+*/
+YAHOO.widget.ContextMenu.prototype.configTrigger =
+
+ function(p_sType, p_aArgs, p_oMenu) {
+
+ var Event = YAHOO.util.Event;
+ var oTrigger = p_aArgs[0];
+
+ if(oTrigger) {
+
+
+ /*
+ If there is a current "trigger" - remove the event handlers
+ from that element(s) before assigning new ones
+ */
+ if(this._oTrigger) {
+
+ Event.purgeElement(this._oTrigger);
+
+ }
+
+
+ this._oTrigger = oTrigger;
+
+
+ /*
+ Listen for the "mousedown" event in Opera b/c it does not
+ support the "contextmenu" event
+ */
+
+ var bOpera = (this.browser == "opera");
+
+ Event.addListener(
+ oTrigger,
+ (bOpera ? "mousedown" : "contextmenu"),
+ this._onTriggerContextMenu,
+ this,
+ true
+ );
+
+
+ /*
+ Assign a "click" event handler to the trigger element(s) for
+ Opera to prevent default browser behaviors.
+ */
+
+ if(bOpera) {
+
+ Event.addListener(
+ oTrigger,
+ "click",
+ this._onTriggerClick,
+ this,
+ true
+ );
+
+ }
+
+
+ // Assign a "mousedown" event handler to the document
+
+ Event.addListener(
+ document,
+ "mousedown",
+ this._onDocumentMouseDown,
+ this,
+ true
+ );
+
+ }
+
+ };
+
+
+/**
+* @class Creates an item for a context menu instance.
+* @constructor
+* @extends YAHOO.widget.MenuItem
+* @base YAHOO.widget.MenuItem
+* @param {String or HTMLElement} p_oObject String or HTMLElement
+* (either HTMLLIElement, HTMLOptGroupElement or HTMLOptionElement) of the
+* source HTMLElement node.
+* @param {Object} p_oConfig The configuration object literal containing
+* the configuration for a ContextMenuItem instance. See the configuration
+* class documentation for more details.
+*/
+YAHOO.widget.ContextMenuItem = function(p_oObject, p_oConfig) {
+
+ YAHOO.widget.ContextMenuItem.superclass.constructor.call(
+ this,
+ p_oObject,
+ p_oConfig
+ );
+
+};
+
+YAHOO.extend(YAHOO.widget.ContextMenuItem, YAHOO.widget.MenuItem);
+
+
+/**
+* The ContextMenuItem class's initialization method. This method is
+* automatically called by the constructor, and sets up all DOM references for
+* pre-existing markup, and creates required markup if it is not
+* already present.
+* @param {String or HTMLElement} p_oObject String or HTMLElement
+* (either HTMLLIElement, HTMLOptGroupElement or HTMLOptionElement) of the
+* source HTMLElement node.
+* @param {Object} p_oConfig The configuration object literal containing
+* the configuration for a ContextMenuItem instance. See the configuration
+* class documentation for more details.
+*/
+YAHOO.widget.ContextMenuItem.prototype.init =
+
+ function(p_oObject, p_oConfig) {
+
+ if(!this.SUBMENU_TYPE) {
+
+ this.SUBMENU_TYPE = YAHOO.widget.ContextMenu;
+
+ }
+
+ if(!this.SUBMENU_ITEM_TYPE) {
+
+ this.SUBMENU_ITEM_TYPE = YAHOO.widget.ContextMenuItem;
+
+ }
+
+
+ /*
+ Call the init of the superclass (YAHOO.widget.MenuItem)
+ Note: We don't pass the user config in here yet
+ because we only want it executed once, at the lowest
+ subclass level.
+ */
+
+ YAHOO.widget.ContextMenuItem.superclass.init.call(this, p_oObject);
+
+ var oConfig = this.cfg;
+
+ if(p_oConfig) {
+
+ oConfig.applyConfig(p_oConfig, true);
+
+ }
+
+ oConfig.fireQueue();
+
+ };
+
+
+/**
+* @class Horizontal collection of items, each of which can contain a submenu.
+* Extends YAHOO.widget.MenuModule to provide a set of default mouse and
+* key event behaviors.
+* @constructor
+* @extends YAHOO.widget.MenuModule
+* @base YAHOO.widget.MenuModule
+* @param {String or HTMLElement} p_oElement String id or HTMLElement
+* (either HTMLSelectElement or HTMLDivElement) of the source HTMLElement node.
+* @param {Object} p_oConfig Optional. The configuration object literal
+* containing the configuration for a MenuBar instance. See
+* configuration class documentation for more details.
+*/
+YAHOO.widget.MenuBar = function(p_oElement, p_oConfig) {
+
+ YAHOO.widget.MenuBar.superclass.constructor.call(
+ this,
+ p_oElement,
+ p_oConfig
+ );
+
+};
+
+YAHOO.extend(YAHOO.widget.MenuBar, YAHOO.widget.MenuModule);
+
+
+/**
+* The MenuBar class's initialization method. This method is automatically
+* called by the constructor, and sets up all DOM references for pre-existing
+* markup, and creates required markup if it is not already present.
+* @param {String or HTMLElement} p_oElement String id or HTMLElement
+* (either HTMLSelectElement or HTMLDivElement) of the source HTMLElement node.
+* @param {Object} p_oConfig Optional. The configuration object literal
+* containing the configuration for a MenuBar instance. See
+* configuration class documentation for more details.
+*/
+YAHOO.widget.MenuBar.prototype.init = function(p_oElement, p_oConfig) {
+
+ if(!this.ITEM_TYPE) {
+
+ this.ITEM_TYPE = YAHOO.widget.MenuBarItem;
+
+ }
+
+
+ // Call the init of the superclass (YAHOO.widget.MenuModule)
+
+ YAHOO.widget.MenuBar.superclass.init.call(this, p_oElement);
+
+
+ this.beforeInitEvent.fire(YAHOO.widget.MenuBar);
+
+ var oConfig = this.cfg;
+
+ /*
+ Set the default value for the "position" configuration property
+ to "static"
+ */
+ if(!p_oConfig || (p_oConfig && !p_oConfig.position)) {
+
+ oConfig.queueProperty("position", "static");
+
+ }
+
+ /*
+ Set the default value for the "submenualignment" configuration property
+ to "tl" and "bl"
+ */
+ if(!p_oConfig || (p_oConfig && !p_oConfig.submenualignment)) {
+
+ oConfig.queueProperty("submenualignment", ["tl","bl"]);
+
+ }
+
+
+ if(p_oConfig) {
+
+ oConfig.applyConfig(p_oConfig, true);
+
+ }
+
+ this.initEvent.fire(YAHOO.widget.MenuBar);
+
+};
+
+
+// Constants
+
+/**
+* Constant representing the CSS class(es) to be applied to the root
+* HTMLDivElement of the MenuBar instance.
+* @final
+* @type String
+*/
+YAHOO.widget.MenuBar.prototype.CSS_CLASS_NAME = "yuimenubar";
+
+
+/**
+* @class The MenuBarItem class allows you to create and modify an item for a
+* MenuBar instance. MenuBarItem extends YAHOO.widget.MenuModuleItem to provide
+* a set of default mouse and key event behaviors.
+* @constructor
+* @extends YAHOO.widget.MenuModuleItem
+* @base YAHOO.widget.MenuModuleItem
+* @param {String or HTMLElement} p_oObject String or HTMLElement
+* (either HTMLLIElement, HTMLOptGroupElement or HTMLOptionElement) of the
+* source HTMLElement node.
+* @param {Object} p_oConfig The configuration object literal containing
+* the configuration for a MenuBarItem instance. See the configuration
+* class documentation for more details.
+*/
+YAHOO.widget.MenuBarItem = function(p_oObject, p_oConfig) {
+
+ YAHOO.widget.MenuBarItem.superclass.constructor.call(
+ this,
+ p_oObject,
+ p_oConfig
+ );
+
+};
+
+YAHOO.extend(YAHOO.widget.MenuBarItem, YAHOO.widget.MenuModuleItem);
+
+
+/**
+* The MenuBarItem class's initialization method. This method is automatically
+* called by the constructor, and sets up all DOM references for
+* pre-existing markup, and creates required markup if it is not
+* already present.
+* @param {String or HTMLElement} p_oObject String or HTMLElement
+* (either HTMLLIElement, HTMLOptGroupElement or HTMLOptionElement) of the
+* source HTMLElement node.
+* @param {Object} p_oConfig The configuration object literal containing
+* the configuration for a MenuBarItem instance. See the configuration
+* class documentation for more details.
+*/
+YAHOO.widget.MenuBarItem.prototype.init = function(p_oObject, p_oConfig) {
+
+ if(!this.SUBMENU_TYPE) {
+
+ this.SUBMENU_TYPE = YAHOO.widget.Menu;
+
+ }
+
+ if(!this.SUBMENU_ITEM_TYPE) {
+
+ this.SUBMENU_ITEM_TYPE = YAHOO.widget.MenuItem;
+
+ }
+
+
+ /*
+ Call the init of the superclass (YAHOO.widget.MenuModuleItem)
+ Note: We don't pass the user config in here yet
+ because we only want it executed once, at the lowest
+ subclass level.
+ */
+
+ YAHOO.widget.MenuBarItem.superclass.init.call(this, p_oObject);
+
+
+ // Add event handlers to each "MenuBarItem" instance
+
+ this.keyDownEvent.subscribe(this._onKeyDown, this, true);
+
+ var oConfig = this.cfg;
+
+ if(p_oConfig) {
+
+ oConfig.applyConfig(p_oConfig, true);
+
+ }
+
+ oConfig.fireQueue();
+
+};
+
+
+// Constants
+
+/**
+* Constant representing the CSS class(es) to be applied to the root
+* HTMLLIElement of the MenuBarItem.
+* @final
+* @type String
+*/
+YAHOO.widget.MenuBarItem.prototype.CSS_CLASS_NAME = "yuimenubaritem";
+
+
+/**
+* Constant representing the path to the image to be used for the submenu
+* arrow indicator.
+* @final
+* @type String
+*/
+YAHOO.widget.MenuBarItem.prototype.SUBMENU_INDICATOR_IMAGE_PATH =
+ "nt/ic/ut/alt1/menuarodwn8_nrm_1.gif";
+
+
+/**
+* Constant representing the path to the image to be used for the submenu
+* arrow indicator when a MenuBarItem instance is selected.
+* @final
+* @type String
+*/
+YAHOO.widget.MenuBarItem.prototype.SELECTED_SUBMENU_INDICATOR_IMAGE_PATH =
+ "nt/ic/ut/alt1/menuarodwn8_hov_1.gif";
+
+
+/**
+* Constant representing the path to the image to be used for the submenu
+* arrow indicator when a MenuBarItem instance is disabled.
+* @final
+* @type String
+*/
+YAHOO.widget.MenuBarItem.prototype.DISABLED_SUBMENU_INDICATOR_IMAGE_PATH =
+ "nt/ic/ut/alt1/menuarodwn8_dim_1.gif";
+
+
+// Private event handlers
+
+/**
+* "keydown" Custom Event handler for a MenuBarItem instance.
+* @private
+* @param {String} p_sType The name of the event that was fired.
+* @param {Array} p_aArgs Collection of arguments sent when the event
+* was fired.
+* @param {YAHOO.widget.MenuModule} p_oMenuModule The MenuModule instance that
+* fired the event.
+*/
+YAHOO.widget.MenuBarItem.prototype._onKeyDown =
+
+ function(p_sType, p_aArgs, p_oMenuItem) {
+
+ var Event = YAHOO.util.Event;
+ var oDOMEvent = p_aArgs[0];
+ var oConfig = this.cfg;
+ var oParent = this.parent;
+
+ switch(oDOMEvent.keyCode) {
+
+ case 37: // Left arrow
+ case 39: // Right arrow
+
+ if(
+ this == oParent.activeItem &&
+ !oConfig.getProperty("selected")
+ ) {
+
+ oConfig.setProperty("selected", true);
+
+ }
+ else {
+
+ var oNextItem = (oDOMEvent.keyCode == 37) ?
+ this.getPreviousEnabledSibling() :
+ this.getNextEnabledSibling();
+
+ if(oNextItem) {
+
+ oParent.clearActiveItem();
+
+ oNextItem.cfg.setProperty("selected", true);
+
+ oNextItem.focus();
+
+ }
+
+ }
+
+ Event.preventDefault(oDOMEvent);
+
+ break;
+
+ case 40: // Down arrow
+
+ oParent.clearActiveItem();
+
+ oConfig.setProperty("selected", true);
+
+ this.focus();
+
+ var oSubmenu = oConfig.getProperty("submenu");
+
+ if(oSubmenu) {
+
+ oSubmenu.show();
+ oSubmenu.setInitialSelection();
+
+ }
+
+ Event.preventDefault(oDOMEvent);
+
+ break;
+
+ }
+
+ };
\ No newline at end of file
Added: branches/tomek/portal-dnd/dndRenderer.war/js/menu/menu-min.js
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/menu/menu-min.js 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/menu/menu-min.js 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,9 @@
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+Version 0.11.0
+*/
+
+
+YAHOO.widget.MenuModule=function(_1,_2){YAHOO.widget.MenuModule.superclass.constructor.call(this,_1,_2);};YAHOO.extend(YAHOO.widget.MenuModule,YAHOO.widget.Overlay);YAHOO.widget.MenuModule.prototype.CSS_CLASS_NAME="yuimenu";YAHOO.widget.MenuModule.prototype.ITEM_TYPE=null;YAHOO.widget.MenuModule.prototype.GROUP_TITLE_TAG_NAME="H6";YAHOO.widget.MenuModule.prototype._aGroupTitleElements=null;YAHOO.widget.MenuModule.prototype._aItemGroups=null;YAHOO.widget.MenuModule.prototype._aListElements=null;YAHOO.widget.MenuModule.prototype._oEventUtil=YAHOO.util.Event;YAHOO.widget.MenuModule.prototype._oDom=YAHOO.util.Dom;YAHOO.widget.MenuModule.prototype._oCurrentItem=null;YAHOO.widget.MenuModule.prototype._bFiredMouseOverEvent=false;YAHOO.widget.MenuModule.prototype._bFiredMouseOutEvent=false;YAHOO.widget.MenuModule.prototype.activeItem=null;YAHOO.widget.MenuModule.prototype.parent=null;YAHOO.widget.MenuModule.prototype.srcElement=null;YAHOO.widget.MenuModule.prototype.mouseOverEvent=!
null;YAHOO.widget.MenuModule.prototype.mouseOutEvent=null;YAHOO.widget.MenuModule.prototype.mouseDownEvent=null;YAHOO.widget.MenuModule.prototype.mouseUpEvent=null;YAHOO.widget.MenuModule.prototype.clickEvent=null;YAHOO.widget.MenuModule.prototype.keyPressEvent=null;YAHOO.widget.MenuModule.prototype.keyDownEvent=null;YAHOO.widget.MenuModule.prototype.keyUpEvent=null;YAHOO.widget.MenuModule.prototype.init=function(_3,_4){var _5=this._oDom;var _6=this._oEventUtil;if(!this.ITEM_TYPE){this.ITEM_TYPE=YAHOO.widget.MenuModuleItem;}this._aItemGroups=[];this._aListElements=[];this._aGroupTitleElements=[];var _7;if(typeof _3=="string"){_7=document.getElementById(_3);}else{if(_3.tagName){_7=_3;}}if(_7){switch(_7.tagName){case "DIV":this.srcElement=_7;YAHOO.widget.MenuModule.superclass.init.call(this,_7);this.beforeInitEvent.fire(YAHOO.widget.MenuModule);var _8=this.body.firstChild;var i=0;do{switch(_8.tagName){case this.GROUP_TITLE_TAG_NAME:this._aGroupTitleElements[i]=_8;break;case "!
UL":this._aListElements[i]=_8;this._aItemGroups[i]=[];i++;break;}}whil
e((_8=_8.nextSibling));if(this._aListElements[0]){_5.addClass(this._aListElements[0],"first-of-type");}break;case "SELECT":this.srcElement=_7;var _a=_5.generateId();YAHOO.widget.MenuModule.superclass.init.call(this,_a);this.beforeInitEvent.fire(YAHOO.widget.MenuModule);break;}}else{YAHOO.widget.MenuModule.superclass.init.call(this,_3);this.beforeInitEvent.fire(YAHOO.widget.MenuModule);}if(this.element){var _b=this.element;var _c=YAHOO.util.CustomEvent;_5.addClass(_b,this.CSS_CLASS_NAME);_6.addListener(_b,"mouseover",this._onElementMouseOver,this,true);_6.addListener(_b,"mouseout",this._onElementMouseOut,this,true);_6.addListener(_b,"mousedown",this._onDOMEvent,this,true);_6.addListener(_b,"mouseup",this._onDOMEvent,this,true);_6.addListener(_b,"click",this._onElementClick,this,true);_6.addListener(_b,"keydown",this._onDOMEvent,this,true);_6.addListener(_b,"keyup",this._onDOMEvent,this,true);_6.addListener(_b,"keypress",this._onDOMEvent,this,true);this.mouseOverEvent=new _c("!
mouseOverEvent",this);this.mouseOutEvent=new _c("mouseOutEvent",this);this.mouseDownEvent=new _c("mouseDownEvent",this);this.mouseUpEvent=new _c("mouseUpEvent",this);this.clickEvent=new _c("clickEvent",this);this.keyPressEvent=new _c("keyPressEvent",this);this.keyDownEvent=new _c("keyDownEvent",this);this.keyUpEvent=new _c("keyUpEvent",this);this.beforeRenderEvent.subscribe(this._onBeforeRender,this,true);this.renderEvent.subscribe(this._onRender,this,true);this.showEvent.subscribe(this._onShow,this,true);this.beforeHideEvent.subscribe(this._onBeforeHide,this,true);if(_4){this.cfg.applyConfig(_4,true);}this.cfg.queueProperty("visible",false);if(this.srcElement){this._initSubTree();}}this.initEvent.fire(YAHOO.widget.MenuModule);};YAHOO.widget.MenuModule.prototype._initSubTree=function(){var _d;switch(this.srcElement.tagName){case "DIV":if(this._aListElements.length>0){var i=this._aListElements.length-1;do{_d=this._aListElements[i].firstChild;do{switch(_d.tagName){case "LI":t!
his.addItem(new this.ITEM_TYPE(_d),i);break;}}while((_d=_d.nextSibling
));}while(i--);}break;case "SELECT":_d=this.srcElement.firstChild;do{switch(_d.tagName){case "OPTGROUP":case "OPTION":this.addItem(new this.ITEM_TYPE(_d));break;}}while((_d=_d.nextSibling));break;}};YAHOO.widget.MenuModule.prototype._getFirstEnabledItem=function(){var _f=this._aItemGroups.length;var _10;var _11;for(var i=0;i<_f;i++){_11=this._aItemGroups[i];if(_11){var _13=_11.length;for(var n=0;n<_13;n++){_10=_11[n];if(!_10.cfg.getProperty("disabled")){return _10;}_10=null;}}}};YAHOO.widget.MenuModule.prototype._checkPosition=function(_15){if(typeof _15=="string"){var _16=_15.toLowerCase();return ("dynamic,static".indexOf(_16)!=-1);}};YAHOO.widget.MenuModule.prototype._addItemToGroup=function(_17,_18,_19){var Dom=this._oDom;var _1b;if(_18 instanceof this.ITEM_TYPE){_1b=_18;}else{if(typeof _18=="string"){_1b=new this.ITEM_TYPE(_18);}}if(_1b){var _1c=typeof _17=="number"?_17:0;var _1d=this._getItemGroup(_1c);var _1e;if(!_1d){_1d=this._createItemGroup(_1c);}if(typeof _19=="num!
ber"){var _1f=(_19>=_1d.length);if(_1d[_19]){_1d.splice(_19,0,_1b);}else{_1d[_19]=_1b;}_1e=_1d[_19];if(_1e){if(_1f&&!_1e.element.parentNode){this._aListElements[_1c].appendChild(_1e.element);}else{function getNextItemSibling(_20,_21){return (_20[_21]||getNextItemSibling(_20,(_21+1)));}var _22=getNextItemSibling(_1d,(_19+1));if(_22&&!_1e.element.parentNode){this._aListElements[_1c].insertBefore(_1e.element,_22.element);}}_1e.parent=this;this._subscribeToItemEvents(_1e);this._configureItemSubmenuModule(_1e);this._updateItemProperties(_1c);return _1e;}}else{var _23=_1d.length;_1d[_23]=_1b;_1e=_1d[_23];if(_1e){if(!Dom.isAncestor(this._aListElements[_1c],_1e.element)){this._aListElements[_1c].appendChild(_1e.element);}_1e.element.setAttribute("groupindex",_1c);_1e.element.setAttribute("index",_23);_1e.parent=this;_1e.index=_23;_1e.groupIndex=_1c;this._subscribeToItemEvents(_1e);this._configureItemSubmenuModule(_1e);if(_23===0){Dom.addClass(_1e.element,"first-of-type");}return _1!
e;}}}};YAHOO.widget.MenuModule.prototype._removeItemFromGroupByIndex=f
unction(_24,_25){var _26=typeof _24=="number"?_24:0;var _27=this._getItemGroup(_26);if(_27){var _28=_27.splice(_25,1);var _29=_28[0];if(_29){this._updateItemProperties(_26);if(_27.length===0){var oUL=this._aListElements[_26];if(this.body&&oUL){this.body.removeChild(oUL);}this._aItemGroups.splice(_26,1);this._aListElements.splice(_26,1);oUL=this._aListElements[0];if(oUL){this._oDom.addClass(oUL,"first-of-type");}}return _29;}}};YAHOO.widget.MenuModule.prototype._removeItemFromGroupByValue=function(_2b,_2c){var _2d=this._getItemGroup(_2b);if(_2d){var _2e=_2d.length;var _2f=-1;if(_2e>0){var i=_2e-1;do{if(_2d[i]==_2c){_2f=i;break;}}while(i--);if(_2f>-1){return this._removeItemFromGroupByIndex(_2b,_2f);}}}};YAHOO.widget.MenuModule.prototype._updateItemProperties=function(_31){var _32=this._getItemGroup(_31);var _33=_32.length;if(_33>0){var Dom=this._oDom;var i=_33-1;var _36;var oLI;do{_36=_32[i];if(_36){oLI=_36.element;_36.index=i;_36.groupIndex=_31;oLI.setAttribute("groupindex",!
_31);oLI.setAttribute("index",i);Dom.removeClass(oLI,"first-of-type");}}while(i--);if(oLI){Dom.addClass(oLI,"first-of-type");}}};YAHOO.widget.MenuModule.prototype._createItemGroup=function(_38){if(!this._aItemGroups[_38]){this._aItemGroups[_38]=[];var oUL=document.createElement("ul");this._aListElements[_38]=oUL;return this._aItemGroups[_38];}};YAHOO.widget.MenuModule.prototype._getItemGroup=function(_3a){var _3b=((typeof _3a=="number")?_3a:0);return this._aItemGroups[_3b];};YAHOO.widget.MenuModule.prototype._configureItemSubmenuModule=function(_3c){var _3d=_3c.cfg.getProperty("submenu");if(_3d){this.cfg.configChangedEvent.subscribe(this._onParentMenuModuleConfigChange,_3d,true);this.renderEvent.subscribe(this._onParentMenuModuleRender,_3d,true);_3d.beforeShowEvent.subscribe(this._onSubmenuBeforeShow,_3d,true);_3d.showEvent.subscribe(this._onSubmenuShow,_3d,true);_3d.hideEvent.subscribe(this._onSubmenuHide,_3d,true);}};YAHOO.widget.MenuModule.prototype._subscribeToItemEvent!
s=function(_3e){var _3f=[this,_3e];_3e.focusEvent.subscribe(this._onIt
emFocus,_3f);_3e.blurEvent.subscribe(this._onItemBlur,_3f);_3e.cfg.configChangedEvent.subscribe(this._onItemConfigChange,_3f);};YAHOO.widget.MenuModule.prototype._getOffsetWidth=function(){var _40=this.element.cloneNode(true);this._oDom.setStyle(_40,"width","");document.body.appendChild(_40);var _41=_40.offsetWidth;document.body.removeChild(_40);return _41;};YAHOO.widget.MenuModule.prototype._fireItemEvent=function(_42,_43,_44){var me=this;function getItemElement(_46){if(_46==me.element){return;}else{if(_46.tagName=="LI"){return _46;}else{if(_46.parentNode){return getItemElement(_46.parentNode);}}}}var _47=getItemElement(_42);if(_47){var _48=parseInt(_47.getAttribute("groupindex"),10);var _49=parseInt(_47.getAttribute("index"),10);var _4a=this._aItemGroups[_48][_49];if(!_4a.cfg.getProperty("disabled")){_4a[_43].fire(_44);return _4a;}}};YAHOO.widget.MenuModule.prototype._onDOMEvent=function(_4b,_4c){var _4d=this._oEventUtil;var _4e={"mousedown":"mouseDownEvent","mouseup":"mou!
seUpEvent","keydown":"keyDownEvent","keyup":"keyUpEvent","keypress":"keyPressEvent"};var _4f=_4e[_4b.type];var _50=_4d.getTarget(_4b);this._fireItemEvent(_50,_4f,_4b);this[_4f].fire(_4b);_4d.stopPropagation(_4b);};YAHOO.widget.MenuModule.prototype._onElementMouseOver=function(_51,_52){var _53=this._oEventUtil;var _54=_53.getTarget(_51);if((_54==this.element||this._oDom.isAncestor(this.element,_54))&&!this._bFiredMouseOverEvent){this.mouseOverEvent.fire(_51);this._bFiredMouseOverEvent=true;this._bFiredMouseOutEvent=false;}if(!this._oCurrentItem){this._oCurrentItem=this._fireItemEvent(_54,"mouseOverEvent",_51);}_53.stopPropagation(_51);};YAHOO.widget.MenuModule.prototype._onElementMouseOut=function(_55,_56){var Dom=this._oDom;var _58=this._oEventUtil;var _59=_58.getRelatedTarget(_55);var _5a=true;var _5b=false;if(this._oCurrentItem&&_59){if(_59==this._oCurrentItem.element||Dom.isAncestor(this._oCurrentItem.element,_59)){_5a=false;}var _5c=this._oCurrentItem.cfg.getProperty("s!
ubmenu");if(_5c&&(_59==_5c.element||Dom.isAncestor(_5c.element,_59))){
_5b=true;}}if(this._oCurrentItem&&(_5a||_5b)){this._oCurrentItem.mouseOutEvent.fire(_55);this._oCurrentItem=null;}if(!this._bFiredMouseOutEvent&&(!Dom.isAncestor(this.element,_59)||_5b)){this.mouseOutEvent.fire(_55);this._bFiredMouseOutEvent=true;this._bFiredMouseOverEvent=false;}_58.stopPropagation(_55);};YAHOO.widget.MenuModule.prototype._onElementClick=function(_5d,_5e){var _5f=this._oEventUtil;var _60=_5f.getTarget(_5d);var _61=this._fireItemEvent(_60,"clickEvent",_5d);var _62;if(_61){var _63=_61.cfg.getProperty("url");var _64=_61.cfg.getProperty("submenu");_62=(_63.substr((_63.length-1),1)=="#");if(_60==_61.submenuIndicator&&_64){if(_64.cfg.getProperty("visible")){_64.hide();}else{var _65=this.activeItem;if(_65&&_65!=this){this.clearActiveItem();}this.activeItem=_61;_61.cfg.setProperty("selected",true);_64.show();}}else{if(_60.tagName!="A"&&!_62){document.location=_63;}}}switch(_60.tagName){case "A":if(_62){_5f.preventDefault(_5d);}else{break;}default:_5f.stopPropagatio!
n(_5d);break;}this.clickEvent.fire(_5d);};YAHOO.widget.MenuModule.prototype._onBeforeRender=function(_66,_67,_68){var Dom=this._oDom;var _6a=this.cfg;var oEl=this.element;var _6c=this._aListElements.length;if(_6a.getProperty("position")=="static"){_6a.queueProperty("iframe",false);_6a.queueProperty("visible",true);}if(_6c>0){var i=0;var _6e=true;var oUL;var _70;do{oUL=this._aListElements[i];if(oUL){if(_6e){Dom.addClass(oUL,"first-of-type");_6e=false;}if(!Dom.isAncestor(oEl,oUL)){this.appendToBody(oUL);}_70=this._aGroupTitleElements[i];if(_70){if(!Dom.isAncestor(oEl,_70)){oUL.parentNode.insertBefore(_70,oUL);}Dom.addClass(oUL,"hastitle");}}i++;}while(i<_6c);}};YAHOO.widget.MenuModule.prototype._onRender=function(_71,_72,_73){if(this.cfg.getProperty("position")=="dynamic"){var _74=this.element.parentNode.tagName=="BODY"?this.element.offsetWidth:this._getOffsetWidth();this.cfg.setProperty("width",(_74+"px"));}};YAHOO.widget.MenuModule.prototype._onShow=function(_75,_76,_77){th!
is.setInitialFocus();};YAHOO.widget.MenuModule.prototype._onBeforeHide
=function(_78,_79,_7a){var _7b=this.activeItem;if(_7b){_7b.blur();if(_7b.cfg.getProperty("selected")){_7b.cfg.setProperty("selected",false);}var _7c=_7b.cfg.getProperty("submenu");if(_7c&&_7c.cfg.getProperty("visible")){_7c.hide();}}};YAHOO.widget.MenuModule.prototype._onParentMenuModuleConfigChange=function(_7d,_7e,_7f){var _80=_7e[0][0];var _81=_7e[0][1];switch(_80){case "iframe":case "constraintoviewport":_7f.cfg.setProperty(_80,_81);break;}};YAHOO.widget.MenuModule.prototype._onParentMenuModuleRender=function(_82,_83,_84){var _85=_84.parent.parent;_84.cfg.applyConfig({constraintoviewport:_85.cfg.getProperty("constraintoviewport"),xy:[0,0],iframe:_85.cfg.getProperty("iframe")});if(this._oDom.inDocument(this.element)){this.render();}else{this.render(this.parent.element);}};YAHOO.widget.MenuModule.prototype._onSubmenuBeforeShow=function(_86,_87,_88){var _89=this.parent;var _8a=_89.parent.cfg.getProperty("submenualignment");this.cfg.setProperty("context",[_89.element,_8a[0],!
_8a[1]]);_89.submenuIndicator.alt=_89.EXPANDED_SUBMENU_INDICATOR_ALT_TEXT;};YAHOO.widget.MenuModule.prototype._onSubmenuShow=function(_8b,_8c,_8d){var _8e=this.parent;_8e.submenuIndicator.alt=_8e.EXPANDED_SUBMENU_INDICATOR_ALT_TEXT;};YAHOO.widget.MenuModule.prototype._onSubmenuHide=function(_8f,_90,_91){var _92=this.parent;if(_92.parent.cfg.getProperty("visible")){_92.cfg.setProperty("selected",false);_92.focus();}_92.submenuIndicator.alt=_92.COLLAPSED_SUBMENU_INDICATOR_ALT_TEXT;};YAHOO.widget.MenuModule.prototype._onItemFocus=function(_93,_94,_95){var me=_95[0];var _97=_95[1];me.activeItem=_97;};YAHOO.widget.MenuModule.prototype._onItemBlur=function(_98,_99,_9a){var me=_9a[0];var _9c=_9a[1];var _9d=_9c.cfg.getProperty("submenu");if(!_9d||(_9d&&!_9d.cfg.getProperty("visible"))){me.activeItem=null;}};YAHOO.widget.MenuModule.prototype._onItemConfigChange=function(_9e,_9f,_a0){var me=_a0[0];var _a2=_9f[0][0];var _a3=_a0[1];switch(_a2){case "submenu":var _a4=_9f[0][1];if(_a4){m!
e._configureItemSubmenuModule(_a3);}break;case "text":case "helptext":
if(me.element.style.width){var _a5=me._getOffsetWidth()+"px";me._oDom.setStyle(me.element,"width",_a5);}break;}};YAHOO.widget.MenuModule.prototype.enforceConstraints=function(_a6,_a7,obj){var Dom=this._oDom;var _aa=this.cfg;var pos=_a7[0];var x=pos[0];var y=pos[1];var bod=document.getElementsByTagName("body")[0];var htm=document.getElementsByTagName("html")[0];var _b0=Dom.getStyle(bod,"overflow");var _b1=Dom.getStyle(htm,"overflow");var _b2=this.element.offsetHeight;var _b3=this.element.offsetWidth;var _b4=Dom.getClientWidth();var _b5=Dom.getClientHeight();var _b6=window.scrollX||document.body.scrollLeft;var _b7=window.scrollY||document.body.scrollTop;var _b8=_b7+10;var _b9=_b6+10;var _ba=_b7+_b5-_b2-10;var _bb=_b6+_b4-_b3-10;var _bc=_aa.getProperty("context");var _bd=_bc?_bc[0]:null;if(x<10){x=_b9;}else{if((x+_b3)>_b4){if(_bd&&((x-_bd.offsetWidth)>_b3)){x=(x-(_bd.offsetWidth+_b3));}else{x=_bb;}}}if(y<10){y=_b8;}else{if(y>_ba){if(_bd&&(y>_b2)){y=((y+_bd.offsetHeight)-_b2);}e!
lse{y=_ba;}}}_aa.setProperty("x",x,true);_aa.setProperty("y",y,true);};YAHOO.widget.MenuModule.prototype.configPosition=function(_be,_bf,_c0){var _c1=_bf[0]=="static"?"static":"absolute";this._oDom.setStyle(this.element,"position",_c1);};YAHOO.widget.MenuModule.prototype.toString=function(){return ("Menu "+this.id);};YAHOO.widget.MenuModule.prototype.setItemGroupTitle=function(_c2,_c3){if(typeof _c2=="string"&&_c2.length>0){var Dom=this._oDom;var _c5=typeof _c3=="number"?_c3:0;var _c6=this._aGroupTitleElements[_c5];if(_c6){_c6.innerHTML=_c2;}else{_c6=document.createElement(this.GROUP_TITLE_TAG_NAME);_c6.innerHTML=_c2;this._aGroupTitleElements[_c5]=_c6;}var i=this._aGroupTitleElements.length-1;var _c8;do{if(this._aGroupTitleElements[i]){Dom.removeClass(this._aGroupTitleElements[i],"first-of-type");_c8=i;}}while(i--);if(_c8!==null){Dom.addClass(this._aGroupTitleElements[_c8],"first-of-type");}}};YAHOO.widget.MenuModule.prototype.addItem=function(_c9,_ca){if(_c9){return this._!
addItemToGroup(_ca,_c9);}};YAHOO.widget.MenuModule.prototype.insertIte
m=function(_cb,_cc,_cd){if(_cb){return this._addItemToGroup(_cd,_cb,_cc);}};YAHOO.widget.MenuModule.prototype.removeItem=function(_ce,_cf){if(typeof _ce!="undefined"){var _d0;if(_ce instanceof YAHOO.widget.MenuModuleItem){_d0=this._removeItemFromGroupByValue(_cf,_ce);}else{if(typeof _ce=="number"){_d0=this._removeItemFromGroupByIndex(_cf,_ce);}}if(_d0){_d0.destroy();return _d0;}}};YAHOO.widget.MenuModule.prototype.getItemGroups=function(){return this._aItemGroups;};YAHOO.widget.MenuModule.prototype.getItem=function(_d1,_d2){if(typeof _d1=="number"){var _d3=this._getItemGroup(_d2);if(_d3){return _d3[_d1];}}};YAHOO.widget.MenuModule.prototype.destroy=function(){this._oEventUtil.purgeElement(this.element);this.mouseOverEvent.unsubscribeAll();this.mouseOutEvent.unsubscribeAll();this.mouseDownEvent.unsubscribeAll();this.mouseUpEvent.unsubscribeAll();this.clickEvent.unsubscribeAll();this.keyPressEvent.unsubscribeAll();this.keyDownEvent.unsubscribeAll();this.keyUpEvent.unsubscribeA!
ll();this.beforeMoveEvent.unsubscribeAll();var _d4=this._aItemGroups.length;var _d5;var _d6;var _d7;var i;var n;if(_d4>0){i=_d4-1;do{_d6=this._aItemGroups[i];if(_d6){_d5=_d6.length;if(_d5>0){n=_d5-1;do{_d7=this._aItemGroups[i][n];if(_d7){_d7.destroy();}}while(n--);}}}while(i--);}YAHOO.widget.MenuModule.superclass.destroy.call(this);};YAHOO.widget.MenuModule.prototype.setInitialFocus=function(){var _da=this._getFirstEnabledItem();if(_da){_da.focus();}};YAHOO.widget.MenuModule.prototype.setInitialSelection=function(){var _db=this._getFirstEnabledItem();if(_db){_db.cfg.setProperty("selected",true);}};YAHOO.widget.MenuModule.prototype.clearActiveItem=function(){if(this.activeItem){var _dc=this.activeItem.cfg;_dc.setProperty("selected",false);var _dd=_dc.getProperty("submenu");if(_dd){_dd.hide();}}};YAHOO.widget.MenuModule.prototype.initDefaultConfig=function(){YAHOO.widget.MenuModule.superclass.initDefaultConfig.call(this);var _de=this.cfg;_de.addProperty("position",{value:"dyn!
amic",handler:this.configPosition,validator:this._checkPosition});_de.
refireEvent("position");_de.addProperty("submenualignment",{value:["tl","tr"]});};YAHOO.widget.MenuModuleItem=function(_df,_e0){if(_df){this.init(_df,_e0);}};YAHOO.widget.MenuModuleItem.prototype={SUBMENU_INDICATOR_IMAGE_PATH:"nt/ic/ut/alt1/menuarorght8_nrm_1.gif",SELECTED_SUBMENU_INDICATOR_IMAGE_PATH:"nt/ic/ut/alt1/menuarorght8_hov_1.gif",DISABLED_SUBMENU_INDICATOR_IMAGE_PATH:"nt/ic/ut/alt1/menuarorght8_dim_1.gif",COLLAPSED_SUBMENU_INDICATOR_ALT_TEXT:"Collapsed. Click to expand.",EXPANDED_SUBMENU_INDICATOR_ALT_TEXT:"Expanded. Click to collapse.",DISABLED_SUBMENU_INDICATOR_ALT_TEXT:"Disabled.",CSS_CLASS_NAME:"yuimenuitem",SUBMENU_TYPE:null,SUBMENU_ITEM_TYPE:null,IMG_ROOT:"http://us.i1.yimg.com/us.yimg.com/i/",IMG_ROOT_SSL:"https://a248.e.akamai.net/sec.yimg.com/i/",_oAnchor:null,_oText:null,_oHelpTextEM:null,_oSubmenu:null,_oDom:YAHOO.util.Dom,constructor:YAHOO.widget.MenuModuleItem,imageRoot:null,isSecure:YAHOO.widget.Module.prototype.isSecure,index:null,groupIndex:null,p!
arent:null,element:null,srcElement:null,value:null,submenuIndicator:null,browser:YAHOO.widget.Module.prototype.browser,destroyEvent:null,mouseOverEvent:null,mouseOutEvent:null,mouseDownEvent:null,mouseUpEvent:null,clickEvent:null,keyPressEvent:null,keyDownEvent:null,keyUpEvent:null,focusEvent:null,blurEvent:null,init:function(_e1,_e2){this.imageRoot=(this.isSecure)?this.IMG_ROOT_SSL:this.IMG_ROOT;if(!this.SUBMENU_TYPE){this.SUBMENU_TYPE=YAHOO.widget.MenuModule;}if(!this.SUBMENU_ITEM_TYPE){this.SUBMENU_ITEM_TYPE=YAHOO.widget.MenuModuleItem;}this.cfg=new YAHOO.util.Config(this);this.initDefaultConfig();var _e3=this.cfg;if(this._checkString(_e1)){this._createRootNodeStructure();_e3.setProperty("text",_e1);}else{if(this._checkDOMNode(_e1)){switch(_e1.tagName){case "OPTION":this._createRootNodeStructure();_e3.setProperty("text",_e1.text);this.srcElement=_e1;break;case "OPTGROUP":this._createRootNodeStructure();_e3.setProperty("text",_e1.label);this.srcElement=_e1;this._initSubTr!
ee();break;case "LI":var _e4=this._getFirstElement(_e1,"A");var _e5="#
";var _e6=null;if(_e4){_e5=_e4.getAttribute("href");if(_e4.innerText){_e6=_e4.innerText;}else{var _e7=_e4.ownerDocument.createRange();_e7.selectNodeContents(_e4);_e6=_e7.toString();}}else{var _e8=_e1.firstChild;_e6=_e8.nodeValue;_e4=document.createElement("a");_e4.setAttribute("href",_e5);_e1.replaceChild(_e4,_e8);_e4.appendChild(_e8);}this.srcElement=_e1;this.element=_e1;this._oAnchor=_e4;var _e9=this._getFirstElement(_e4);var _ea=false;var _eb=false;if(_e9){this._oText=_e9.firstChild;switch(_e9.tagName){case "EM":_ea=true;break;case "STRONG":_eb=true;break;}}else{this._oText=_e4.firstChild;}_e3.setProperty("text",_e6,true);_e3.setProperty("url",_e5,true);_e3.setProperty("emphasis",_ea,true);_e3.setProperty("strongemphasis",_eb,true);this._initSubTree();break;}}}if(this.element){this._oDom.addClass(this.element,this.CSS_CLASS_NAME);var _ec=YAHOO.util.CustomEvent;this.destroyEvent=new _ec("destroyEvent",this);this.mouseOverEvent=new _ec("mouseOverEvent",this);this.mouseOutEv!
ent=new _ec("mouseOutEvent",this);this.mouseDownEvent=new _ec("mouseDownEvent",this);this.mouseUpEvent=new _ec("mouseUpEvent",this);this.clickEvent=new _ec("clickEvent",this);this.keyPressEvent=new _ec("keyPressEvent",this);this.keyDownEvent=new _ec("keyDownEvent",this);this.keyUpEvent=new _ec("keyUpEvent",this);this.focusEvent=new _ec("focusEvent",this);this.blurEvent=new _ec("blurEvent",this);if(_e2){_e3.applyConfig(_e2);}_e3.fireQueue();}},_getFirstElement:function(_ed,_ee){var _ef;if(_ed.firstChild&&_ed.firstChild.nodeType==1){_ef=_ed.firstChild;}else{if(_ed.firstChild&&_ed.firstChild.nextSibling&&_ed.firstChild.nextSibling.nodeType==1){_ef=_ed.firstChild.nextSibling;}}if(_ee){return (_ef&&_ef.tagName==_ee)?_ef:false;}return _ef;},_checkString:function(_f0){return (typeof _f0=="string");},_checkDOMNode:function(_f1){return (_f1&&_f1.tagName);},_createRootNodeStructure:function(){this.element=document.createElement("li");this._oText=document.createTextNode("");this._oAnc!
hor=document.createElement("a");this._oAnchor.appendChild(this._oText)
;this.cfg.refireEvent("url");this.element.appendChild(this._oAnchor);},_initSubTree:function(){var _f2=this.SUBMENU_TYPE;var _f3=this.SUBMENU_ITEM_TYPE;var _f4=this.srcElement;var _f5=this.cfg;if(_f4.childNodes.length>0){var _f6=_f4.firstChild;var _f7=[];do{switch(_f6.tagName){case "DIV":_f5.setProperty("submenu",(new _f2(_f6)));break;case "OPTION":_f7[_f7.length]=_f6;break;}}while((_f6=_f6.nextSibling));var _f8=_f7.length;if(_f8>0){_f5.setProperty("submenu",(new _f2(this._oDom.generateId())));for(var n=0;n<_f8;n++){this._oSubmenu.addItem((new _f3(_f7[n])));}}}},configText:function(_fa,_fb,_fc){var _fd=_fb[0];if(this._oText){this._oText.nodeValue=_fd;}},configHelpText:function(_fe,_ff,_100){var me=this;var Dom=this._oDom;var _103=_ff[0];var oEl=this.element;var _105=this.cfg;var _106=[oEl,this._oAnchor];var oImg=this.submenuIndicator;function initHelpText(){Dom.addClass(_106,"hashelptext");if(_105.getProperty("disabled")){_105.refireEvent("disabled");}if(_105.getProperty("se!
lected")){_105.refireEvent("selected");}}function removeHelpText(){Dom.removeClass(_106,"hashelptext");oEl.removeChild(me._oHelpTextEM);me._oHelpTextEM=null;}if(this._checkDOMNode(_103)){if(this._oHelpTextEM){this._oHelpTextEM.parentNode.replaceChild(_103,this._oHelpTextEM);}else{this._oHelpTextEM=_103;oEl.insertBefore(this._oHelpTextEM,oImg);}initHelpText();}else{if(this._checkString(_103)){if(_103.length===0){removeHelpText();}else{if(!this._oHelpTextEM){this._oHelpTextEM=document.createElement("em");oEl.insertBefore(this._oHelpTextEM,oImg);}this._oHelpTextEM.innerHTML=_103;initHelpText();}}else{if(!_103&&this._oHelpTextEM){removeHelpText();}}}},configURL:function(_108,_109,_10a){var sURL=_109[0];if(!sURL){sURL="#";}this._oAnchor.setAttribute("href",sURL);},configEmphasis:function(_10c,_10d,_10e){var _10f=_10d[0];var _110=this._oAnchor;var _111=this._oText;var _112=this.cfg;var oEM;if(_10f&&_112.getProperty("strongemphasis")){_112.setProperty("strongemphasis",false);}if(_!
110){if(_10f){oEM=document.createElement("em");oEM.appendChild(_111);_
110.appendChild(oEM);}else{oEM=this._getFirstElement(_110,"EM");_110.removeChild(oEM);_110.appendChild(_111);}}},configStrongEmphasis:function(_114,_115,_116){var _117=_115[0];var _118=this._oAnchor;var _119=this._oText;var _11a=this.cfg;var _11b;if(_117&&_11a.getProperty("emphasis")){_11a.setProperty("emphasis",false);}if(_118){if(_117){_11b=document.createElement("strong");_11b.appendChild(_119);_118.appendChild(_11b);}else{_11b=this._getFirstElement(_118,"STRONG");_118.removeChild(_11b);_118.appendChild(_119);}}},configDisabled:function(_11c,_11d,_11e){var _11f=_11d[0];var Dom=this._oDom;var _121=this._oAnchor;var _122=[this.element,_121];var oEM=this._oHelpTextEM;var _124=this.cfg;var oImg=this.submenuIndicator;var _126;var _127;if(oEM){_122[2]=oEM;}if(_11f){if(_124.getProperty("selected")){_124.setProperty("selected",false);}_121.removeAttribute("href");Dom.addClass(_122,"disabled");_126=this.DISABLED_SUBMENU_INDICATOR_IMAGE_PATH;_127=this.DISABLED_SUBMENU_INDICATOR_ALT!
_TEXT;}else{_121.setAttribute("href",_124.getProperty("url"));Dom.removeClass(_122,"disabled");_126=this.SUBMENU_INDICATOR_IMAGE_PATH;_127=this.COLLAPSED_SUBMENU_INDICATOR_ALT_TEXT;}if(oImg){oImg.src=this.imageRoot+_126;oImg.alt=_127;}},configSelected:function(_128,_129,_12a){if(!this.cfg.getProperty("disabled")){var Dom=this._oDom;var _12c=_129[0];var oEM=this._oHelpTextEM;var _12e=[this.element,this._oAnchor];var oImg=this.submenuIndicator;var _130;if(oEM){_12e[2]=oEM;}if(_12c){Dom.addClass(_12e,"selected");_130=this.SELECTED_SUBMENU_INDICATOR_IMAGE_PATH;}else{Dom.removeClass(_12e,"selected");_130=this.SUBMENU_INDICATOR_IMAGE_PATH;}if(oImg){oImg.src=document.images[(this.imageRoot+_130)].src;}}},configSubmenu:function(_131,_132,_133){var Dom=this._oDom;var oEl=this.element;var _136=_132[0];var oImg=this.submenuIndicator;var _138=this.cfg;var _139=[this.element,this._oAnchor];if(_136){_136.parent=this;this._oSubmenu=_136;if(!oImg){var me=this;function preloadImage(_13b){va!
r _13c=me.imageRoot+_13b;if(!document.images[_13c]){var oImg=document.
createElement("img");oImg.src=_13c;oImg.name=_13c;oImg.id=_13c;oImg.style.display="none";document.body.appendChild(oImg);}}preloadImage(this.SUBMENU_INDICATOR_IMAGE_PATH);preloadImage(this.SELECTED_SUBMENU_INDICATOR_IMAGE_PATH);preloadImage(this.DISABLED_SUBMENU_INDICATOR_IMAGE_PATH);oImg=document.createElement("img");oImg.src=(this.imageRoot+this.SUBMENU_INDICATOR_IMAGE_PATH);oImg.alt=this.COLLAPSED_SUBMENU_INDICATOR_ALT_TEXT;oEl.appendChild(oImg);this.submenuIndicator=oImg;Dom.addClass(_139,"hassubmenu");if(_138.getProperty("disabled")){_138.refireEvent("disabled");}if(_138.getProperty("selected")){_138.refireEvent("selected");}}}else{Dom.removeClass(_139,"hassubmenu");if(oImg){oEl.removeChild(oImg);}if(this._oSubmenu){this._oSubmenu.destroy();}}},initDefaultConfig:function(){var _13e=this.cfg;var _13f=_13e.checkBoolean;_13e.addProperty("text",{value:"",handler:this.configText,validator:this._checkString,suppressEvent:true});_13e.addProperty("helptext",{handler:this.config!
HelpText});_13e.addProperty("url",{value:"#",handler:this.configURL,suppressEvent:true});_13e.addProperty("emphasis",{value:false,handler:this.configEmphasis,validator:_13f,suppressEvent:true});_13e.addProperty("strongemphasis",{value:false,handler:this.configStrongEmphasis,validator:_13f,suppressEvent:true});_13e.addProperty("disabled",{value:false,handler:this.configDisabled,validator:_13f,suppressEvent:true});_13e.addProperty("selected",{value:false,handler:this.configSelected,validator:_13f,suppressEvent:true});_13e.addProperty("submenu",{handler:this.configSubmenu});},getNextEnabledSibling:function(){if(this.parent instanceof YAHOO.widget.MenuModule){var _140=this.groupIndex;function getNextArrayItem(_141,_142){return _141[_142]||getNextArrayItem(_141,(_142+1));}var _143=this.parent.getItemGroups();var _144;if(this.index<(_143[_140].length-1)){_144=getNextArrayItem(_143[_140],(this.index+1));}else{var _145;if(_140<(_143.length-1)){_145=_140+1;}else{_145=0;}var _146=get!
NextArrayItem(_143,_145);_144=getNextArrayItem(_146,0);}return _144.cf
g.getProperty("disabled")?_144.getNextEnabledSibling():_144;}},getPreviousEnabledSibling:function(){if(this.parent instanceof YAHOO.widget.MenuModule){var _147=this.groupIndex;function getPreviousArrayItem(_148,_149){return _148[_149]||getPreviousArrayItem(_148,(_149-1));}function getFirstItemIndex(_14a,_14b){return _14a[_14b]?_14b:getFirstItemIndex(_14a,(_14b+1));}var _14c=this.parent.getItemGroups();var _14d;if(this.index>getFirstItemIndex(_14c[_147],0)){_14d=getPreviousArrayItem(_14c[_147],(this.index-1));}else{var _14e;if(_147>getFirstItemIndex(_14c,0)){_14e=_147-1;}else{_14e=_14c.length-1;}var _14f=getPreviousArrayItem(_14c,_14e);_14d=getPreviousArrayItem(_14f,(_14f.length-1));}return _14d.cfg.getProperty("disabled")?_14d.getPreviousEnabledSibling():_14d;}},focus:function(){var _150=this.parent;var _151=this._oAnchor;var _152=_150.activeItem;if(!this.cfg.getProperty("disabled")&&_150&&_150.cfg.getProperty("visible")){if(_152){_152.blur();}_151.focus();if(_150&&this.brow!
ser=="opera"&&this._oSubmenu){_151.focus();}this.focusEvent.fire();}},blur:function(){var _153=this.parent;if(!this.cfg.getProperty("disabled")&&_153&&this._oDom.getStyle(_153.element,"visibility")=="visible"){this._oAnchor.blur();this.blurEvent.fire();}},destroy:function(){var oEl=this.element;if(oEl){this.mouseOverEvent.unsubscribeAll();this.mouseOutEvent.unsubscribeAll();this.mouseDownEvent.unsubscribeAll();this.mouseUpEvent.unsubscribeAll();this.clickEvent.unsubscribeAll();this.keyPressEvent.unsubscribeAll();this.keyDownEvent.unsubscribeAll();this.keyUpEvent.unsubscribeAll();this.focusEvent.unsubscribeAll();this.blurEvent.unsubscribeAll();this.cfg.configChangedEvent.unsubscribeAll();var _155=oEl.parentNode;if(_155){_155.removeChild(oEl);this.destroyEvent.fire();}this.destroyEvent.unsubscribeAll();}}};YAHOO.widget.Menu=function(_156,_157){YAHOO.widget.Menu.superclass.constructor.call(this,_156,_157);};YAHOO.extend(YAHOO.widget.Menu,YAHOO.widget.MenuModule);YAHOO.widget.M!
enu.prototype.init=function(_158,_159){if(!this.ITEM_TYPE){this.ITEM_T
YPE=YAHOO.widget.MenuItem;}YAHOO.widget.Menu.superclass.init.call(this,_158);this.beforeInitEvent.fire(YAHOO.widget.Menu);this.showEvent.subscribe(this._onMenuShow,this,true);this.mouseOverEvent.subscribe(this._onMenuMouseOver,this,true);this.keyDownEvent.subscribe(this._onMenuKeyDown,this,true);if(_159){this.cfg.applyConfig(_159,true);}this.initEvent.fire(YAHOO.widget.Menu);};YAHOO.widget.Menu.prototype._onMenuShow=function(_15a,_15b,_15c){var _15d=this.parent;if(_15d&&_15d.parent instanceof YAHOO.widget.Menu){var _15e=_15d.parent.cfg.getProperty("submenualignment");this.cfg.setProperty("submenualignment",[_15e[0],_15e[1]]);}};YAHOO.widget.Menu.prototype._onMenuMouseOver=function(_15f,_160,_161){if(this.parent){this.parent.cfg.setProperty("selected",true);}};YAHOO.widget.Menu.prototype._onMenuKeyDown=function(_162,_163,_164){if(this.cfg.getProperty("position")=="dynamic"){var _165=_163[0];var _166=this.parent;if(_165.keyCode==27){this.hide();if(_166){_166.focus();if(_166.pa!
rent instanceof YAHOO.widget.Menu){_166.cfg.setProperty("selected",true);}YAHOO.util.Event.preventDefault(_165);}}}};YAHOO.widget.Menu.prototype.onDomResize=function(e,obj){if(!this._handleResize){this._handleResize=true;return;}var me=this;var _16a=this.cfg;if(_16a.getProperty("position")=="dynamic"){_16a.setProperty("width",(this._getOffsetWidth()+"px"));if(this.parent&&_16a.getProperty("visible")){function align(){me.align();}window.setTimeout(align,0);}}YAHOO.widget.Menu.superclass.onDomResize.call(this,e,obj);};YAHOO.widget.MenuItem=function(_16b,_16c){YAHOO.widget.MenuItem.superclass.constructor.call(this,_16b,_16c);};YAHOO.extend(YAHOO.widget.MenuItem,YAHOO.widget.MenuModuleItem);YAHOO.widget.MenuItem.prototype.init=function(_16d,_16e){if(!this.SUBMENU_TYPE){this.SUBMENU_TYPE=YAHOO.widget.Menu;}if(!this.SUBMENU_ITEM_TYPE){this.SUBMENU_ITEM_TYPE=YAHOO.widget.MenuItem;}YAHOO.widget.MenuItem.superclass.init.call(this,_16d);this.keyDownEvent.subscribe(this._onKeyDown,thi!
s,true);this.mouseOverEvent.subscribe(this._onMouseOver,this,true);thi
s.mouseOutEvent.subscribe(this._onMouseOut,this,true);var _16f=this.cfg;if(_16e){_16f.applyConfig(_16e,true);}_16f.fireQueue();};YAHOO.widget.MenuItem.prototype.CHECKED_IMAGE_PATH="nt/ic/ut/bsc/menuchk8_nrm_1.gif";YAHOO.widget.MenuItem.prototype.SELECTED_CHECKED_IMAGE_PATH="nt/ic/ut/bsc/menuchk8_hov_1.gif";YAHOO.widget.MenuItem.prototype.DISABLED_CHECKED_IMAGE_PATH="nt/ic/ut/bsc/menuchk8_dim_1.gif";YAHOO.widget.MenuItem.prototype.CHECKED_IMAGE_ALT_TEXT="Checked.";YAHOO.widget.MenuItem.prototype.DISABLED_CHECKED_IMAGE_ALT_TEXT="Checked. (Item disabled.)";YAHOO.widget.MenuItem.prototype._checkImage=null;YAHOO.widget.MenuItem.prototype._onKeyDown=function(_170,_171,_172){var _173=YAHOO.util.Event;var _174=_171[0];var _175=this.parent;var _176=this.cfg;var _177;switch(_174.keyCode){case 38:case 40:if(this==_175.activeItem&&!_176.getProperty("selected")){_176.setProperty("selected",true);}else{var _178=(_174.keyCode==38)?this.getPreviousEnabledSibling():this.getNextEnabledSibling!
();if(_178){_175.clearActiveItem();_178.cfg.setProperty("selected",true);_178.focus();}}_173.preventDefault(_174);break;case 39:_175.clearActiveItem();_176.setProperty("selected",true);this.focus();var _179=_176.getProperty("submenu");if(_179){_179.show();_179.setInitialSelection();}else{if(YAHOO.widget.MenuBarItem&&_175.parent&&_175.parent instanceof YAHOO.widget.MenuBarItem){_175.hide();_177=_175.parent;if(_177){_177.focus();_177.cfg.setProperty("selected",true);}}}_173.preventDefault(_174);break;case 37:if(_175.parent){_175.hide();_177=_175.parent;if(_177){_177.focus();_177.cfg.setProperty("selected",true);}}_173.preventDefault(_174);break;}};YAHOO.widget.MenuItem.prototype._onMouseOver=function(_17a,_17b,_17c){var _17d=this.parent;var _17e=this.cfg;var _17f=_17d.activeItem;if(_17f&&_17f!=this){_17d.clearActiveItem();}_17e.setProperty("selected",true);this.focus();var _180=_17e.getProperty("submenu");if(_180){_180.show();}};YAHOO.widget.MenuItem.prototype._onMouseOut=fun!
ction(_181,_182,_183){var _184=this.cfg;var _185=_184.getProperty("sub
menu");_184.setProperty("selected",false);if(_185){var _186=_182[0];var _187=YAHOO.util.Event.getRelatedTarget(_186);if(!(_187==_185.element||YAHOO.util.Dom.isAncestor(_185.element,_187))){_185.hide();}}};YAHOO.widget.MenuItem.prototype.configChecked=function(_188,_189,_18a){var Dom=YAHOO.util.Dom;var _18c=_189[0];var oEl=this.element;var _18e=this.cfg;var oImg;if(_18c){var me=this;function preloadImage(_191){var _192=me.imageRoot+_191;if(!document.images[_192]){var oImg=document.createElement("img");oImg.src=_192;oImg.name=_192;oImg.id=_192;oImg.style.display="none";document.body.appendChild(oImg);}}preloadImage(this.CHECKED_IMAGE_PATH);preloadImage(this.SELECTED_CHECKED_IMAGE_PATH);preloadImage(this.DISABLED_CHECKED_IMAGE_PATH);oImg=document.createElement("img");oImg.src=(this.imageRoot+this.CHECKED_IMAGE_PATH);oImg.alt=this.CHECKED_IMAGE_ALT_TEXT;var _194=this.cfg.getProperty("submenu");if(_194){oEl.insertBefore(oImg,_194.element);}else{oEl.appendChild(oImg);}Dom.addClass!
([oEl,oImg],"checked");this._checkImage=oImg;if(_18e.getProperty("disabled")){_18e.refireEvent("disabled");}if(_18e.getProperty("selected")){_18e.refireEvent("selected");}}else{oImg=this._checkImage;Dom.removeClass([oEl,oImg],"checked");if(oImg){oEl.removeChild(oImg);}this._checkImage=null;}};YAHOO.widget.MenuItem.prototype.configSelected=function(_195,_196,_197){YAHOO.widget.MenuItem.superclass.configSelected.call(this,_195,_196,_197);var _198=this.cfg;if(!_198.getProperty("disabled")&&_198.getProperty("checked")){var _199=_196[0];var sSrc=this.imageRoot+(_199?this.SELECTED_CHECKED_IMAGE_PATH:this.CHECKED_IMAGE_PATH);this._checkImage.src=document.images[sSrc].src;}};YAHOO.widget.MenuItem.prototype.configDisabled=function(_19b,_19c,_19d){YAHOO.widget.MenuItem.superclass.configDisabled.call(this,_19b,_19c,_19d);if(this.cfg.getProperty("checked")){var _19e=_19c[0];var sAlt=this.CHECKED_IMAGE_ALT_TEXT;var sSrc=this.CHECKED_IMAGE_PATH;var oImg=this._checkImage;if(_19e){sAlt=thi!
s.DISABLED_CHECKED_IMAGE_ALT_TEXT;sSrc=this.DISABLED_CHECKED_IMAGE_PAT
H;}oImg.src=document.images[(this.imageRoot+sSrc)].src;oImg.alt=sAlt;}};YAHOO.widget.MenuItem.prototype.initDefaultConfig=function(){YAHOO.widget.MenuItem.superclass.initDefaultConfig.call(this);this.cfg.addProperty("checked",{value:false,handler:this.configChecked,validator:this.cfg.checkBoolean,suppressEvent:true});};YAHOO.widget.ContextMenu=function(_1a2,_1a3){YAHOO.widget.ContextMenu.superclass.constructor.call(this,_1a2,_1a3);};YAHOO.extend(YAHOO.widget.ContextMenu,YAHOO.widget.Menu);YAHOO.widget.ContextMenu.prototype._oTrigger=null;YAHOO.widget.ContextMenu.prototype.init=function(_1a4,_1a5){if(!this.ITEM_TYPE){this.ITEM_TYPE=YAHOO.widget.ContextMenuItem;}YAHOO.widget.ContextMenu.superclass.init.call(this,_1a4);this.beforeInitEvent.fire(YAHOO.widget.ContextMenu);if(_1a5){this.cfg.applyConfig(_1a5,true);}this.initEvent.fire(YAHOO.widget.ContextMenu);};YAHOO.widget.ContextMenu.prototype._onDocumentMouseDown=function(_1a6,_1a7){var _1a8=YAHOO.util.Event.getTarget(_1a6);var!
_1a9=this._oTargetElement;if(_1a8!=_1a9||!YAHOO.util.Dom.isAncestor(_1a9,_1a8)){this.hide();}};YAHOO.widget.ContextMenu.prototype._onTriggerClick=function(_1aa,_1ab){if(_1aa.ctrlKey){YAHOO.util.Event.stopEvent(_1aa);}};YAHOO.widget.ContextMenu.prototype._onTriggerContextMenu=function(_1ac,_1ad){var _1ae=YAHOO.util.Event;var _1af=this.cfg;if(_1ac.type=="mousedown"){if(!_1ac.ctrlKey){return;}_1ae.stopEvent(_1ac);}this.contextEventTarget=_1ae.getTarget(_1ac);var nX=_1ae.getPageX(_1ac);var nY=_1ae.getPageY(_1ac);_1af.applyConfig({x:nX,y:nY,visible:true});_1af.fireQueue();_1ae.preventDefault(_1ac);};YAHOO.widget.ContextMenu.prototype.contextEventTarget=null;YAHOO.widget.ContextMenu.prototype.initDefaultConfig=function(){YAHOO.widget.ContextMenu.superclass.initDefaultConfig.call(this);this.cfg.addProperty("trigger",{handler:this.configTrigger});};YAHOO.widget.ContextMenu.prototype.configTrigger=function(_1b2,_1b3,_1b4){var _1b5=YAHOO.util.Event;var _1b6=_1b3[0];if(_1b6){if(this.!
_oTrigger){_1b5.purgeElement(this._oTrigger);}this._oTrigger=_1b6;var
_1b7=(this.browser=="opera");_1b5.addListener(_1b6,(_1b7?"mousedown":"contextmenu"),this._onTriggerContextMenu,this,true);if(_1b7){_1b5.addListener(_1b6,"click",this._onTriggerClick,this,true);}_1b5.addListener(document,"mousedown",this._onDocumentMouseDown,this,true);}};YAHOO.widget.ContextMenuItem=function(_1b8,_1b9){YAHOO.widget.ContextMenuItem.superclass.constructor.call(this,_1b8,_1b9);};YAHOO.extend(YAHOO.widget.ContextMenuItem,YAHOO.widget.MenuItem);YAHOO.widget.ContextMenuItem.prototype.init=function(_1ba,_1bb){if(!this.SUBMENU_TYPE){this.SUBMENU_TYPE=YAHOO.widget.ContextMenu;}if(!this.SUBMENU_ITEM_TYPE){this.SUBMENU_ITEM_TYPE=YAHOO.widget.ContextMenuItem;}YAHOO.widget.ContextMenuItem.superclass.init.call(this,_1ba);var _1bc=this.cfg;if(_1bb){_1bc.applyConfig(_1bb,true);}_1bc.fireQueue();};YAHOO.widget.MenuBar=function(_1bd,_1be){YAHOO.widget.MenuBar.superclass.constructor.call(this,_1bd,_1be);};YAHOO.extend(YAHOO.widget.MenuBar,YAHOO.widget.MenuModule);YAHOO.widget.!
MenuBar.prototype.init=function(_1bf,_1c0){if(!this.ITEM_TYPE){this.ITEM_TYPE=YAHOO.widget.MenuBarItem;}YAHOO.widget.MenuBar.superclass.init.call(this,_1bf);this.beforeInitEvent.fire(YAHOO.widget.MenuBar);var _1c1=this.cfg;if(!_1c0||(_1c0&&!_1c0.position)){_1c1.queueProperty("position","static");}if(!_1c0||(_1c0&&!_1c0.submenualignment)){_1c1.queueProperty("submenualignment",["tl","bl"]);}if(_1c0){_1c1.applyConfig(_1c0,true);}this.initEvent.fire(YAHOO.widget.MenuBar);};YAHOO.widget.MenuBar.prototype.CSS_CLASS_NAME="yuimenubar";YAHOO.widget.MenuBarItem=function(_1c2,_1c3){YAHOO.widget.MenuBarItem.superclass.constructor.call(this,_1c2,_1c3);};YAHOO.extend(YAHOO.widget.MenuBarItem,YAHOO.widget.MenuModuleItem);YAHOO.widget.MenuBarItem.prototype.init=function(_1c4,_1c5){if(!this.SUBMENU_TYPE){this.SUBMENU_TYPE=YAHOO.widget.Menu;}if(!this.SUBMENU_ITEM_TYPE){this.SUBMENU_ITEM_TYPE=YAHOO.widget.MenuItem;}YAHOO.widget.MenuBarItem.superclass.init.call(this,_1c4);this.keyDownEvent.sub!
scribe(this._onKeyDown,this,true);var _1c6=this.cfg;if(_1c5){_1c6.appl
yConfig(_1c5,true);}_1c6.fireQueue();};YAHOO.widget.MenuBarItem.prototype.CSS_CLASS_NAME="yuimenubaritem";YAHOO.widget.MenuBarItem.prototype.SUBMENU_INDICATOR_IMAGE_PATH="nt/ic/ut/alt1/menuarodwn8_nrm_1.gif";YAHOO.widget.MenuBarItem.prototype.SELECTED_SUBMENU_INDICATOR_IMAGE_PATH="nt/ic/ut/alt1/menuarodwn8_hov_1.gif";YAHOO.widget.MenuBarItem.prototype.DISABLED_SUBMENU_INDICATOR_IMAGE_PATH="nt/ic/ut/alt1/menuarodwn8_dim_1.gif";YAHOO.widget.MenuBarItem.prototype._onKeyDown=function(_1c7,_1c8,_1c9){var _1ca=YAHOO.util.Event;var _1cb=_1c8[0];var _1cc=this.cfg;var _1cd=this.parent;switch(_1cb.keyCode){case 37:case 39:if(this==_1cd.activeItem&&!_1cc.getProperty("selected")){_1cc.setProperty("selected",true);}else{var _1ce=(_1cb.keyCode==37)?this.getPreviousEnabledSibling():this.getNextEnabledSibling();if(_1ce){_1cd.clearActiveItem();_1ce.cfg.setProperty("selected",true);_1ce.focus();}}_1ca.preventDefault(_1cb);break;case 40:_1cd.clearActiveItem();_1cc.setProperty("selected",true);!
this.focus();var _1cf=_1cc.getProperty("submenu");if(_1cf){_1cf.show();_1cf.setInitialSelection();}_1ca.preventDefault(_1cb);break;}};
\ No newline at end of file
Added: branches/tomek/portal-dnd/dndRenderer.war/js/menu/menu.js
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/menu/menu.js 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/menu/menu.js 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,5152 @@
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+Version 0.11.0
+*/
+
+
+/**
+* @class The superclass of all menu containers.
+* @constructor
+* @extends YAHOO.widget.Overlay
+* @base YAHOO.widget.Overlay
+* @param {String or HTMLElement} p_oElement String id or HTMLElement
+* (either HTMLSelectElement or HTMLDivElement) of the source HTMLElement node.
+* @param {Object} p_oConfig Optional. The configuration object literal
+* containing the configuration for a MenuModule instance. See
+* configuration class documentation for more details.
+*/
+YAHOO.widget.MenuModule = function(p_oElement, p_oConfig) {
+
+ YAHOO.widget.MenuModule.superclass.constructor.call(
+ this,
+ p_oElement,
+ p_oConfig
+ );
+
+};
+
+YAHOO.extend(YAHOO.widget.MenuModule, YAHOO.widget.Overlay);
+
+// Constants
+
+/**
+* Constant representing the CSS class(es) to be applied to the root
+* HTMLDivElement of the MenuModule instance.
+* @final
+* @type String
+*/
+YAHOO.widget.MenuModule.prototype.CSS_CLASS_NAME = "yuimenu";
+
+/**
+* Constant representing the type of item to instantiate and add when parsing
+* the child nodes (either HTMLLIElement, HTMLOptGroupElement or
+* HTMLOptionElement) of a menu's DOM. The default
+* is YAHOO.widget.MenuModuleItem.
+* @final
+* @type YAHOO.widget.MenuModuleItem
+*/
+YAHOO.widget.MenuModule.prototype.ITEM_TYPE = null;
+
+/**
+* Constant representing the tagname of the HTMLElement used to title
+* a group of items.
+* @final
+* @type String
+*/
+YAHOO.widget.MenuModule.prototype.GROUP_TITLE_TAG_NAME = "H6";
+
+// Private properties
+
+/**
+* Array of HTMLElements used to title groups of items.
+* @private
+* @type {Array}
+*/
+YAHOO.widget.MenuModule.prototype._aGroupTitleElements = null;
+
+/**
+* Multi-dimensional array of items.
+* @private
+* @type {Array}
+*/
+YAHOO.widget.MenuModule.prototype._aItemGroups = null;
+
+/**
+* An array of HTMLUListElements, each of which is the parent node of each
+* items's HTMLLIElement node.
+* @private
+* @type {Array}
+*/
+YAHOO.widget.MenuModule.prototype._aListElements = null;
+
+/**
+* Reference to the Event utility singleton.
+* @private
+* @type {YAHOO.util.Event}
+*/
+YAHOO.widget.MenuModule.prototype._oEventUtil = YAHOO.util.Event;
+
+/**
+* Reference to the Dom utility singleton.
+* @private
+* @type {YAHOO.util.Dom}
+*/
+YAHOO.widget.MenuModule.prototype._oDom = YAHOO.util.Dom;
+
+/**
+* Reference to the item the mouse is currently over.
+* @private
+* @type {YAHOO.widget.MenuModuleItem}
+*/
+YAHOO.widget.MenuModule.prototype._oCurrentItem = null;
+
+/**
+* The current state of a MenuModule instance's "mouseover" event
+* @private
+* @type {Boolean}
+*/
+YAHOO.widget.MenuModule.prototype._bFiredMouseOverEvent = false;
+
+/**
+* The current state of a MenuModule instance's "mouseout" event
+* @private
+* @type {Boolean}
+*/
+YAHOO.widget.MenuModule.prototype._bFiredMouseOutEvent = false;
+
+// Public properties
+
+/**
+* Reference to the item that has focus.
+* @private
+* @type {YAHOO.widget.MenuModuleItem}
+*/
+YAHOO.widget.MenuModule.prototype.activeItem = null;
+
+/**
+* Returns a MenuModule instance's parent object.
+* @type {YAHOO.widget.MenuModuleItem}
+*/
+YAHOO.widget.MenuModule.prototype.parent = null;
+
+/**
+* Returns the HTMLElement (either HTMLSelectElement or HTMLDivElement)
+* used create the MenuModule instance.
+* @type {HTMLSelectElement/HTMLDivElement}
+*/
+YAHOO.widget.MenuModule.prototype.srcElement = null;
+
+// Events
+
+/**
+* Fires when the mouse has entered a MenuModule instance. Passes back the
+* DOM Event object as an argument.
+* @type {YAHOO.util.CustomEvent}
+* @see YAHOO.util.CustomEvent
+*/
+YAHOO.widget.MenuModule.prototype.mouseOverEvent = null;
+
+/**
+* Fires when the mouse has left a MenuModule instance. Passes back the DOM
+* Event object as an argument.
+* @type {YAHOO.util.CustomEvent}
+* @see YAHOO.util.CustomEvent
+*/
+YAHOO.widget.MenuModule.prototype.mouseOutEvent = null;
+
+/**
+* Fires when the user mouses down on a MenuModule instance. Passes back the
+* DOM Event object as an argument.
+* @type {YAHOO.util.CustomEvent}
+* @see YAHOO.util.CustomEvent
+*/
+YAHOO.widget.MenuModule.prototype.mouseDownEvent = null;
+
+/**
+* Fires when the user releases a mouse button while the mouse is over
+* a MenuModule instance. Passes back the DOM Event object as an argument.
+* @type {YAHOO.util.CustomEvent}
+* @see YAHOO.util.CustomEvent
+*/
+YAHOO.widget.MenuModule.prototype.mouseUpEvent = null;
+
+/**
+* Fires when the user clicks the on a MenuModule instance. Passes back the
+* DOM Event object as an argument.
+* @type {YAHOO.util.CustomEvent}
+* @see YAHOO.util.CustomEvent
+*/
+YAHOO.widget.MenuModule.prototype.clickEvent = null;
+
+/**
+* Fires when the user presses an alphanumeric key. Passes back the
+* DOM Event object as an argument.
+* @type {YAHOO.util.CustomEvent}
+* @see YAHOO.util.CustomEvent
+*/
+YAHOO.widget.MenuModule.prototype.keyPressEvent = null;
+
+/**
+* Fires when the user presses a key. Passes back the DOM Event
+* object as an argument.
+* @type {YAHOO.util.CustomEvent}
+* @see YAHOO.util.CustomEvent
+*/
+YAHOO.widget.MenuModule.prototype.keyDownEvent = null;
+
+/**
+* Fires when the user releases a key. Passes back the DOM Event
+* object as an argument.
+* @type {YAHOO.util.CustomEvent}
+* @see YAHOO.util.CustomEvent
+*/
+YAHOO.widget.MenuModule.prototype.keyUpEvent = null;
+
+/**
+* The MenuModule class's initialization method. This method is automatically
+* called by the constructor, and sets up all DOM references for
+* pre-existing markup, and creates required markup if it is not already present.
+* @param {String or HTMLElement} p_oElement String id or HTMLElement
+* (either HTMLSelectElement or HTMLDivElement) of the source HTMLElement node.
+* @param {Object} p_oConfig Optional. The configuration object literal
+* containing the configuration for a MenuModule instance. See
+* configuration class documentation for more details.
+*/
+YAHOO.widget.MenuModule.prototype.init = function(p_oElement, p_oConfig) {
+
+ var Dom = this._oDom;
+ var Event = this._oEventUtil;
+
+ if(!this.ITEM_TYPE) {
+
+ this.ITEM_TYPE = YAHOO.widget.MenuModuleItem;
+
+ }
+
+ this._aItemGroups = [];
+ this._aListElements = [];
+ this._aGroupTitleElements = [];
+
+ var oElement;
+
+ if(typeof p_oElement == "string") {
+
+ oElement = document.getElementById(p_oElement);
+
+ }
+ else if(p_oElement.tagName) {
+
+ oElement = p_oElement;
+
+ }
+
+ if(oElement) {
+
+ switch(oElement.tagName) {
+
+ case "DIV":
+
+ this.srcElement = oElement;
+
+ /*
+ Note: we don't pass the user config in here yet
+ because we only want it executed once, at the lowest
+ subclass level.
+ */
+
+ YAHOO.widget.MenuModule.superclass.init.call(this, oElement);
+
+ this.beforeInitEvent.fire(YAHOO.widget.MenuModule);
+
+ /*
+ Populate the collection of item groups and item
+ group titles
+ */
+
+ var oNode = this.body.firstChild;
+ var i = 0;
+
+ do {
+
+ switch(oNode.tagName) {
+
+ case this.GROUP_TITLE_TAG_NAME:
+
+ this._aGroupTitleElements[i] = oNode;
+
+ break;
+
+ case "UL":
+
+ this._aListElements[i] = oNode;
+ this._aItemGroups[i] = [];
+ i++;
+
+ break;
+
+ }
+
+ }
+ while((oNode = oNode.nextSibling));
+
+ /*
+ Apply the "first-of-type" class to the first UL to mimic
+ the "first-of-type" CSS3 psuedo class.
+ */
+
+ if(this._aListElements[0]) {
+
+ Dom.addClass(this._aListElements[0], "first-of-type");
+
+ }
+
+
+
+ break;
+
+ case "SELECT":
+
+ this.srcElement = oElement;
+
+
+ /*
+ The source element is not something that we can use
+ outright, so we need to create a new Overlay
+ */
+
+ var sId = Dom.generateId();
+
+ /*
+ Note: we don't pass the user config in here yet
+ because we only want it executed once, at the lowest
+ subclass level.
+ */
+
+ YAHOO.widget.MenuModule.superclass.init.call(this, sId);
+
+ this.beforeInitEvent.fire(YAHOO.widget.MenuModule);
+
+
+
+ break;
+
+ }
+
+ }
+ else {
+
+ /*
+ Note: we don't pass the user config in here yet
+ because we only want it executed once, at the lowest
+ subclass level.
+ */
+
+ YAHOO.widget.MenuModule.superclass.init.call(this, p_oElement);
+
+ this.beforeInitEvent.fire(YAHOO.widget.MenuModule);
+
+
+
+ }
+
+ if(this.element) {
+
+ var oEl = this.element;
+ var CustomEvent = YAHOO.util.CustomEvent;
+
+ Dom.addClass(oEl, this.CSS_CLASS_NAME);
+
+ // Assign DOM event handlers
+
+ Event.addListener(
+ oEl,
+ "mouseover",
+ this._onElementMouseOver,
+ this,
+ true
+ );
+
+ Event.addListener(oEl, "mouseout", this._onElementMouseOut, this, true);
+ Event.addListener(oEl, "mousedown", this._onDOMEvent, this, true);
+ Event.addListener(oEl, "mouseup", this._onDOMEvent, this, true);
+ Event.addListener(oEl, "click", this._onElementClick, this, true);
+ Event.addListener(oEl, "keydown", this._onDOMEvent, this, true);
+ Event.addListener(oEl, "keyup", this._onDOMEvent, this, true);
+ Event.addListener(oEl, "keypress", this._onDOMEvent, this, true);
+
+ // Create custom events
+
+ this.mouseOverEvent = new CustomEvent("mouseOverEvent", this);
+ this.mouseOutEvent = new CustomEvent("mouseOutEvent", this);
+ this.mouseDownEvent = new CustomEvent("mouseDownEvent", this);
+ this.mouseUpEvent = new CustomEvent("mouseUpEvent", this);
+ this.clickEvent = new CustomEvent("clickEvent", this);
+ this.keyPressEvent = new CustomEvent("keyPressEvent", this);
+ this.keyDownEvent = new CustomEvent("keyDownEvent", this);
+ this.keyUpEvent = new CustomEvent("keyUpEvent", this);
+
+ // Subscribe to Custom Events
+
+ this.beforeRenderEvent.subscribe(this._onBeforeRender, this, true);
+ this.renderEvent.subscribe(this._onRender, this, true);
+ this.showEvent.subscribe(this._onShow, this, true);
+ this.beforeHideEvent.subscribe(this._onBeforeHide, this, true);
+
+ if(p_oConfig) {
+
+ this.cfg.applyConfig(p_oConfig, true);
+
+ }
+
+ this.cfg.queueProperty("visible", false);
+
+ if(this.srcElement) {
+
+ this._initSubTree();
+
+ }
+
+ }
+
+ this.initEvent.fire(YAHOO.widget.MenuModule);
+
+};
+
+// Private methods
+
+/**
+* Iterates the source element's childNodes collection and uses the child
+* nodes to instantiate MenuModule and MenuModuleItem instances.
+* @private
+*/
+YAHOO.widget.MenuModule.prototype._initSubTree = function() {
+
+ var oNode;
+
+
+ switch(this.srcElement.tagName) {
+
+ case "DIV":
+
+ if(this._aListElements.length > 0) {
+
+
+ var i = this._aListElements.length - 1;
+
+ do {
+
+ oNode = this._aListElements[i].firstChild;
+
+
+ do {
+
+ switch(oNode.tagName) {
+
+ case "LI":
+
+
+ this.addItem(new this.ITEM_TYPE(oNode), i);
+
+ break;
+
+ }
+
+ }
+ while((oNode = oNode.nextSibling));
+
+ }
+ while(i--);
+
+ }
+
+ break;
+
+ case "SELECT":
+
+
+ oNode = this.srcElement.firstChild;
+
+ do {
+
+ switch(oNode.tagName) {
+
+ case "OPTGROUP":
+ case "OPTION":
+
+
+ this.addItem(new this.ITEM_TYPE(oNode));
+
+ break;
+
+ }
+
+ }
+ while((oNode = oNode.nextSibling));
+
+ break;
+
+ }
+
+};
+
+/**
+* Returns the first enabled item in a menu instance.
+* @return Returns a MenuModuleItem instance.
+* @type YAHOO.widget.MenuModuleItem
+* @private
+*/
+YAHOO.widget.MenuModule.prototype._getFirstEnabledItem = function() {
+
+ var nGroups = this._aItemGroups.length;
+ var oItem;
+ var aItemGroup;
+
+ for(var i=0; i<nGroups; i++) {
+
+ aItemGroup = this._aItemGroups[i];
+
+ if(aItemGroup) {
+
+ var nItems = aItemGroup.length;
+
+ for(var n=0; n<nItems; n++) {
+
+ oItem = aItemGroup[n];
+
+ if(!oItem.cfg.getProperty("disabled")) {
+
+ return oItem;
+
+ }
+
+ oItem = null;
+
+ }
+
+ }
+
+ }
+
+};
+
+/**
+* Determines if the value is one of the supported positions.
+* @private
+* @param {Object} p_sPosition The object to be evaluated.
+* @return Returns true if the position is supported.
+* @type Boolean
+*/
+YAHOO.widget.MenuModule.prototype._checkPosition = function(p_sPosition) {
+
+ if(typeof p_sPosition == "string") {
+
+ var sPosition = p_sPosition.toLowerCase();
+
+ return ("dynamic,static".indexOf(sPosition) != -1);
+
+ }
+
+};
+
+/**
+* Adds an item to a group.
+* @private
+* @param {Number} p_nGroupIndex Number indicating the group to which
+* the item belongs.
+* @param {YAHOO.widget.MenuModuleItem} p_oItem The item to be added.
+* @param {Number} p_nItemIndex Optional. Index at which the item
+* should be added.
+* @return The item that was added.
+* @type YAHOO.widget.MenuModuleItem
+*/
+YAHOO.widget.MenuModule.prototype._addItemToGroup =
+
+ function(p_nGroupIndex, p_oItem, p_nItemIndex) {
+
+ var Dom = this._oDom;
+ var oItem;
+
+ if(p_oItem instanceof this.ITEM_TYPE) {
+
+ oItem = p_oItem;
+
+ }
+ else if(typeof p_oItem == "string") {
+
+ oItem = new this.ITEM_TYPE(p_oItem);
+
+ }
+
+ if(oItem) {
+
+ var nGroupIndex = typeof p_nGroupIndex == "number" ?
+ p_nGroupIndex : 0;
+
+ var aGroup = this._getItemGroup(nGroupIndex);
+
+ var oGroupItem;
+
+
+ if(!aGroup) {
+
+ aGroup = this._createItemGroup(nGroupIndex);
+
+ }
+
+ if(typeof p_nItemIndex == "number") {
+
+ var bAppend = (p_nItemIndex >= aGroup.length);
+
+
+ if(aGroup[p_nItemIndex]) {
+
+ aGroup.splice(p_nItemIndex, 0, oItem);
+
+ }
+ else {
+
+ aGroup[p_nItemIndex] = oItem;
+
+ }
+
+
+ oGroupItem = aGroup[p_nItemIndex];
+
+ if(oGroupItem) {
+
+ if(bAppend && !oGroupItem.element.parentNode) {
+
+ this._aListElements[nGroupIndex].appendChild(
+ oGroupItem.element
+ );
+
+ }
+ else {
+
+
+ /**
+ * Returns the next sibling of an item in an array
+ * @param {p_aArray} An array
+ * @param {p_nStartIndex} The index to start searching
+ * the array
+ * @ignore
+ * @return Returns an item in an array
+ * @type Object
+ */
+ function getNextItemSibling(p_aArray, p_nStartIndex) {
+
+ return (
+ p_aArray[p_nStartIndex] ||
+ getNextItemSibling(
+ p_aArray,
+ (p_nStartIndex+1)
+ )
+ );
+
+ }
+
+
+ var oNextItemSibling =
+ getNextItemSibling(aGroup, (p_nItemIndex+1));
+
+ if(oNextItemSibling && !oGroupItem.element.parentNode) {
+
+ this._aListElements[nGroupIndex].insertBefore(
+ oGroupItem.element,
+ oNextItemSibling.element
+ );
+
+ }
+
+ }
+
+
+ oGroupItem.parent = this;
+
+ this._subscribeToItemEvents(oGroupItem);
+
+ this._configureItemSubmenuModule(oGroupItem);
+
+ this._updateItemProperties(nGroupIndex);
+
+
+ return oGroupItem;
+
+ }
+
+ }
+ else {
+
+ var nItemIndex = aGroup.length;
+
+ aGroup[nItemIndex] = oItem;
+
+
+ oGroupItem = aGroup[nItemIndex];
+
+ if(oGroupItem) {
+
+ if(
+ !Dom.isAncestor(
+ this._aListElements[nGroupIndex],
+ oGroupItem.element
+ )
+ ) {
+
+ this._aListElements[nGroupIndex].appendChild(
+ oGroupItem.element
+ );
+
+ }
+
+ oGroupItem.element.setAttribute("groupindex", nGroupIndex);
+ oGroupItem.element.setAttribute("index", nItemIndex);
+
+ oGroupItem.parent = this;
+
+ oGroupItem.index = nItemIndex;
+ oGroupItem.groupIndex = nGroupIndex;
+
+ this._subscribeToItemEvents(oGroupItem);
+
+ this._configureItemSubmenuModule(oGroupItem);
+
+ if(nItemIndex === 0) {
+
+ Dom.addClass(oGroupItem.element, "first-of-type");
+
+ }
+
+
+ return oGroupItem;
+
+ }
+
+ }
+
+ }
+
+ };
+
+/**
+* Removes an item from a group by index.
+* @private
+* @param {Number} p_nGroupIndex Number indicating the group to which
+* the item belongs.
+* @param {Number} p_nItemIndex Number indicating the index of the item to
+* be removed.
+* @return The item that was removed.
+* @type YAHOO.widget.MenuModuleItem
+*/
+YAHOO.widget.MenuModule.prototype._removeItemFromGroupByIndex =
+
+ function(p_nGroupIndex, p_nItemIndex) {
+
+ var nGroupIndex = typeof p_nGroupIndex == "number" ? p_nGroupIndex : 0;
+ var aGroup = this._getItemGroup(nGroupIndex);
+
+ if(aGroup) {
+
+ var aArray = aGroup.splice(p_nItemIndex, 1);
+ var oItem = aArray[0];
+
+ if(oItem) {
+
+ // Update the index and className properties of each member
+
+ this._updateItemProperties(nGroupIndex);
+
+ if(aGroup.length === 0) {
+
+ // Remove the UL
+
+ var oUL = this._aListElements[nGroupIndex];
+
+ if(this.body && oUL) {
+
+ this.body.removeChild(oUL);
+
+ }
+
+ // Remove the group from the array of items
+
+ this._aItemGroups.splice(nGroupIndex, 1);
+
+
+ // Remove the UL from the array of ULs
+
+ this._aListElements.splice(nGroupIndex, 1);
+
+
+ /*
+ Assign the "first-of-type" class to the new first UL
+ in the collection
+ */
+
+ oUL = this._aListElements[0];
+
+ if(oUL) {
+
+ this._oDom.addClass(oUL, "first-of-type");
+
+ }
+
+ }
+
+
+ // Return a reference to the item that was removed
+
+ return oItem;
+
+ }
+
+ }
+
+ };
+
+/**
+* Removes a item from a group by reference.
+* @private
+* @param {Number} p_nGroupIndex Number indicating the group to which
+* the item belongs.
+* @param {YAHOO.widget.MenuModuleItem} p_oItem The item to be removed.
+* @return The item that was removed.
+* @type YAHOO.widget.MenuModuleItem
+*/
+YAHOO.widget.MenuModule.prototype._removeItemFromGroupByValue =
+
+ function(p_nGroupIndex, p_oItem) {
+
+ var aGroup = this._getItemGroup(p_nGroupIndex);
+
+ if(aGroup) {
+
+ var nItems = aGroup.length;
+ var nItemIndex = -1;
+
+ if(nItems > 0) {
+
+ var i = nItems-1;
+
+ do {
+
+ if(aGroup[i] == p_oItem) {
+
+ nItemIndex = i;
+ break;
+
+ }
+
+ }
+ while(i--);
+
+ if(nItemIndex > -1) {
+
+ return this._removeItemFromGroupByIndex(
+ p_nGroupIndex,
+ nItemIndex
+ );
+
+ }
+
+ }
+
+ }
+
+ };
+
+/**
+* Updates the index, groupindex, and className properties of the items
+* in the specified group.
+* @private
+* @param {Number} p_nGroupIndex Number indicating the group of items to update.
+*/
+YAHOO.widget.MenuModule.prototype._updateItemProperties =
+
+ function(p_nGroupIndex) {
+
+ var aGroup = this._getItemGroup(p_nGroupIndex);
+ var nItems = aGroup.length;
+
+ if(nItems > 0) {
+
+ var Dom = this._oDom;
+ var i = nItems - 1;
+ var oItem;
+ var oLI;
+
+ // Update the index and className properties of each member
+
+ do {
+
+ oItem = aGroup[i];
+
+ if(oItem) {
+
+ oLI = oItem.element;
+
+ oItem.index = i;
+ oItem.groupIndex = p_nGroupIndex;
+
+ oLI.setAttribute("groupindex", p_nGroupIndex);
+ oLI.setAttribute("index", i);
+
+ Dom.removeClass(oLI, "first-of-type");
+
+ }
+
+ }
+ while(i--);
+
+
+ if(oLI) {
+
+ Dom.addClass(oLI, "first-of-type");
+
+ }
+
+ }
+
+ };
+
+/**
+* Creates a new item group (array) and it's associated HTMLUlElement node
+* @private
+* @param {Number} p_nIndex Number indicating the group to create.
+* @return An item group.
+* @type Array
+*/
+YAHOO.widget.MenuModule.prototype._createItemGroup = function(p_nIndex) {
+
+ if(!this._aItemGroups[p_nIndex]) {
+
+ this._aItemGroups[p_nIndex] = [];
+
+ var oUL = document.createElement("ul");
+
+ this._aListElements[p_nIndex] = oUL;
+
+ return this._aItemGroups[p_nIndex];
+
+ }
+
+};
+
+/**
+* Returns the item group at the specified index.
+* @private
+* @param {Number} p_nIndex Number indicating the index of the item group to
+* be retrieved.
+* @return An array of items.
+* @type Array
+*/
+YAHOO.widget.MenuModule.prototype._getItemGroup = function(p_nIndex) {
+
+ var nIndex = ((typeof p_nIndex == "number") ? p_nIndex : 0);
+
+ return this._aItemGroups[nIndex];
+
+};
+
+/**
+* Subscribe's a MenuModule instance to it's parent MenuModule instance's events.
+* @private
+* @param {YAHOO.widget.MenuModuleItem} p_oItem The item to listen
+* for events on.
+*/
+YAHOO.widget.MenuModule.prototype._configureItemSubmenuModule =
+
+ function(p_oItem) {
+
+ var oSubmenu = p_oItem.cfg.getProperty("submenu");
+
+ if(oSubmenu) {
+
+ /*
+ Listen for configuration changes to the parent MenuModule
+ instance so they they can be applied to the submenu.
+ */
+
+ this.cfg.configChangedEvent.subscribe(
+ this._onParentMenuModuleConfigChange,
+ oSubmenu,
+ true
+ );
+
+ this.renderEvent.subscribe(
+ this._onParentMenuModuleRender,
+ oSubmenu,
+ true
+ );
+
+ oSubmenu.beforeShowEvent.subscribe(
+ this._onSubmenuBeforeShow,
+ oSubmenu,
+ true
+ );
+
+ oSubmenu.showEvent.subscribe(this._onSubmenuShow, oSubmenu, true);
+
+ oSubmenu.hideEvent.subscribe(this._onSubmenuHide, oSubmenu, true);
+
+ }
+
+};
+
+/**
+* Subscribes a MenuModule instance to the specified item's Custom Events.
+* @private
+* @param {YAHOO.widget.MenuModuleItem} p_oItem The item to listen for events on.
+*/
+YAHOO.widget.MenuModule.prototype._subscribeToItemEvents = function(p_oItem) {
+
+ var aArguments = [this, p_oItem];
+
+ p_oItem.focusEvent.subscribe(this._onItemFocus, aArguments);
+
+ p_oItem.blurEvent.subscribe(this._onItemBlur, aArguments);
+
+ p_oItem.cfg.configChangedEvent.subscribe(
+ this._onItemConfigChange,
+ aArguments
+ );
+
+};
+
+/**
+* Returns the offset width of a MenuModule instance.
+* @private
+*/
+YAHOO.widget.MenuModule.prototype._getOffsetWidth = function() {
+
+ var oClone = this.element.cloneNode(true);
+
+ this._oDom.setStyle(oClone, "width", "");
+
+ document.body.appendChild(oClone);
+
+ var sWidth = oClone.offsetWidth;
+
+ document.body.removeChild(oClone);
+
+ return sWidth;
+
+};
+
+/**
+* Determines if a DOM event was fired on an item and (if so) fires the item's
+* associated Custom Event
+* @private
+* @param {HTMLElement} p_oElement The original target of the event.
+* @param {String} p_sEventType The type/name of the Custom Event to fire.
+* @param {Event} p_oDOMEvent The DOM event to pass back when firing the
+* Custom Event.
+* @return An item.
+* @type YAHOO.widget.MenuModuleItem
+*/
+YAHOO.widget.MenuModule.prototype._fireItemEvent =
+
+ function(p_oElement, p_sEventType, p_oDOMEvent) {
+
+ var me = this;
+
+ /**
+ * Returns the specified element's parent HTMLLIElement (<LI<)
+ * @param {p_oElement} An HTMLElement node
+ * @ignore
+ * @return Returns an HTMLElement node
+ * @type HTMLElement
+ */
+ function getItemElement(p_oElement) {
+
+ if(p_oElement == me.element) {
+
+ return;
+
+ }
+ else if(p_oElement.tagName == "LI") {
+
+ return p_oElement;
+
+ }
+ else if(p_oElement.parentNode) {
+
+ return getItemElement(p_oElement.parentNode);
+
+ }
+
+ }
+
+
+ var oElement = getItemElement(p_oElement);
+
+ if(oElement) {
+
+ /*
+ Retrieve the item that corresponds to the
+ HTMLLIElement (<LI<) and fire the Custom Event
+ */
+
+ var nGroupIndex = parseInt(oElement.getAttribute("groupindex"), 10);
+ var nIndex = parseInt(oElement.getAttribute("index"), 10);
+ var oItem = this._aItemGroups[nGroupIndex][nIndex];
+
+ if(!oItem.cfg.getProperty("disabled")) {
+
+ oItem[p_sEventType].fire(p_oDOMEvent);
+
+ return oItem;
+
+ }
+
+ }
+
+ };
+
+// Private DOM event handlers
+
+/**
+* Generic event handler for the MenuModule's root HTMLDivElement node. Used
+* to handle "mousedown," "mouseup," "keydown," "keyup," and "keypress" events.
+* @private
+* @param {Event} p_oEvent Event object passed back by the event
+* utility (YAHOO.util.Event).
+* @param {YAHOO.widget.MenuModule} p_oMenuModule The MenuModule instance
+* corresponding to the HTMLDivElement that fired the event.
+*/
+YAHOO.widget.MenuModule.prototype._onDOMEvent =
+
+ function(p_oEvent, p_oMenuModule) {
+
+ var Event = this._oEventUtil;
+
+ // Map of DOM event types to Custom Event types
+
+ var oEventTypes = {
+ "mousedown": "mouseDownEvent",
+ "mouseup": "mouseUpEvent",
+ "keydown": "keyDownEvent",
+ "keyup": "keyUpEvent",
+ "keypress": "keyPressEvent"
+ };
+
+ var sCustomEventType = oEventTypes[p_oEvent.type];
+
+ var oTarget = Event.getTarget(p_oEvent);
+
+ /*
+ Check if the target was an element that is a part of a
+ an item and (if so), fire the associated custom event.
+ */
+
+ this._fireItemEvent(oTarget, sCustomEventType, p_oEvent);
+
+
+ // Fire the associated custom event for the MenuModule
+
+ this[sCustomEventType].fire(p_oEvent);
+
+
+ /*
+ Stop the propagation of the event at each MenuModule instance
+ since menus can be embedded in eachother.
+ */
+
+ Event.stopPropagation(p_oEvent);
+
+ };
+
+/**
+* "mouseover" event handler for the MenuModule's root HTMLDivElement node.
+* @private
+* @param {Event} p_oEvent Event object passed back by the event
+* utility (YAHOO.util.Event).
+* @param {YAHOO.widget.MenuModule} p_oMenuModule The MenuModule instance
+* corresponding to the HTMLDivElement that fired the event.
+*/
+YAHOO.widget.MenuModule.prototype._onElementMouseOver =
+
+ function(p_oEvent, p_oMenuModule) {
+
+ var Event = this._oEventUtil;
+ var oTarget = Event.getTarget(p_oEvent);
+
+ if(
+ (
+ oTarget == this.element ||
+ this._oDom.isAncestor(this.element, oTarget)
+ ) &&
+ !this._bFiredMouseOverEvent
+ ) {
+
+ // Fire the "mouseover" Custom Event for the MenuModule instance
+
+ this.mouseOverEvent.fire(p_oEvent);
+
+ this._bFiredMouseOverEvent = true;
+ this._bFiredMouseOutEvent = false;
+
+ }
+
+
+ /*
+ Check if the target was an element that is a part of an item
+ and (if so), fire the "mouseover" Custom Event.
+ */
+
+ if(!this._oCurrentItem) {
+
+ this._oCurrentItem =
+ this._fireItemEvent(oTarget, "mouseOverEvent", p_oEvent);
+
+ }
+
+
+ /*
+ Stop the propagation of the event at each MenuModule instance
+ since menus can be embedded in eachother.
+ */
+
+ Event.stopPropagation(p_oEvent);
+
+ };
+
+/**
+* "mouseout" event handler for the MenuModule's root HTMLDivElement node.
+* @private
+* @param {Event} p_oEvent Event object passed back by the event
+* utility (YAHOO.util.Event).
+* @param {YAHOO.widget.MenuModule} p_oMenuModule The MenuModule instance
+* corresponding to the HTMLDivElement that fired the event.
+*/
+YAHOO.widget.MenuModule.prototype._onElementMouseOut =
+
+ function(p_oEvent, p_oMenuModule) {
+
+ var Dom = this._oDom;
+ var Event = this._oEventUtil;
+ var oRelatedTarget = Event.getRelatedTarget(p_oEvent);
+ var bLIMouseOut = true;
+ var bMovingToSubmenu = false;
+
+
+ // Determine where the mouse is going
+
+ if(this._oCurrentItem && oRelatedTarget) {
+
+ if(
+ oRelatedTarget == this._oCurrentItem.element ||
+ Dom.isAncestor(this._oCurrentItem.element, oRelatedTarget)
+ ) {
+
+ bLIMouseOut = false;
+
+ }
+
+
+ var oSubmenu = this._oCurrentItem.cfg.getProperty("submenu");
+
+ if(
+ oSubmenu &&
+ (
+ oRelatedTarget == oSubmenu.element ||
+ Dom.isAncestor(oSubmenu.element, oRelatedTarget)
+ )
+ ) {
+
+ bMovingToSubmenu = true;
+
+ }
+
+ }
+
+
+ if(this._oCurrentItem && (bLIMouseOut || bMovingToSubmenu)) {
+
+ // Fire the "mouseout" Custom Event for the item
+
+ this._oCurrentItem.mouseOutEvent.fire(p_oEvent);
+
+ this._oCurrentItem = null;
+
+ }
+
+
+ if(
+ !this._bFiredMouseOutEvent &&
+ (
+ !Dom.isAncestor(this.element, oRelatedTarget) ||
+ bMovingToSubmenu
+ )
+ ) {
+
+ // Fire the "mouseout" Custom Event for the MenuModule instance
+
+ this.mouseOutEvent.fire(p_oEvent);
+
+ this._bFiredMouseOutEvent = true;
+ this._bFiredMouseOverEvent = false;
+
+ }
+
+
+ /*
+ Stop the propagation of the event at each MenuModule instance
+ since menus can be embedded in eachother.
+ */
+
+ Event.stopPropagation(p_oEvent);
+
+ };
+
+/**
+* "click" event handler for the MenuModule's root HTMLDivElement node.
+* @private
+* @param {Event} p_oEvent Event object passed back by the
+* event utility (YAHOO.util.Event).
+* @param {YAHOO.widget.MenuModule} p_oMenuModule The MenuModule instance
+* corresponding to the HTMLDivElement that fired the event.
+*/
+YAHOO.widget.MenuModule.prototype._onElementClick =
+
+ function(p_oEvent, p_oMenuModule) {
+
+ var Event = this._oEventUtil;
+
+ var oTarget = Event.getTarget(p_oEvent);
+
+ /*
+ Check if the target was a DOM element that is a part of an
+ item and (if so), fire the associated "click"
+ Custom Event.
+ */
+
+ var oItem = this._fireItemEvent(oTarget, "clickEvent", p_oEvent);
+
+ var bCurrentPageURL; // Indicates if the URL points to the current page
+
+
+ if(oItem) {
+
+ var sURL = oItem.cfg.getProperty("url");
+ var oSubmenu = oItem.cfg.getProperty("submenu");
+
+ bCurrentPageURL = (sURL.substr((sURL.length-1),1) == "#");
+
+ /*
+ ACCESSIBILITY FEATURE FOR SCREEN READERS: Expand/collapse the
+ submenu when the user clicks on the submenu indicator image.
+ */
+
+ if(oTarget == oItem.submenuIndicator && oSubmenu) {
+
+ if(oSubmenu.cfg.getProperty("visible")) {
+
+ oSubmenu.hide();
+
+ }
+ else {
+
+ var oActiveItem = this.activeItem;
+
+
+ // Hide any other submenus that might be visible
+
+ if(oActiveItem && oActiveItem != this) {
+
+ this.clearActiveItem();
+
+ }
+
+ this.activeItem = oItem;
+
+ oItem.cfg.setProperty("selected", true);
+
+ oSubmenu.show();
+
+ }
+
+ }
+ else if(oTarget.tagName != "A" && !bCurrentPageURL) {
+
+ /*
+ Follow the URL of the item regardless of whether or
+ not the user clicked specifically on the
+ HTMLAnchorElement (<A<) node.
+ */
+
+ document.location = sURL;
+
+ }
+
+ }
+
+
+ switch(oTarget.tagName) {
+
+ case "A":
+
+ if(bCurrentPageURL) {
+
+ // Don't follow URLs that are equal to "#"
+
+ Event.preventDefault(p_oEvent);
+
+ }
+ else {
+
+ /*
+ Break if the anchor's URL is something other than "#"
+ to prevent the call to "stopPropagation" from be
+ executed. This is required for Safari to be able to
+ follow the URL.
+ */
+
+ break;
+
+ }
+
+ default:
+
+ /*
+ Stop the propagation of the event at each MenuModule
+ instance since Menus can be embedded in eachother.
+ */
+
+ Event.stopPropagation(p_oEvent);
+
+ break;
+
+ }
+
+
+ // Fire the associated "click" Custom Event for the MenuModule instance
+
+ this.clickEvent.fire(p_oEvent);
+
+ };
+
+// Private Custom Event handlers
+
+/**
+* "beforerender" Custom Event handler for a MenuModule instance. Appends all
+* of the HTMLUListElement (<UL<s) nodes (and their child
+* HTMLLIElement (<LI<)) nodes and their accompanying title nodes to
+* the body of the MenuModule instance.
+* @private
+* @param {String} p_sType The name of the event that was fired.
+* @param {Array} p_aArgs Collection of arguments sent when the event
+* was fired.
+* @param {YAHOO.widget.MenuModule} p_oMenuModule The MenuModule instance that
+* fired the event.
+*/
+YAHOO.widget.MenuModule.prototype._onBeforeRender =
+
+ function(p_sType, p_aArgs, p_oMenuModule) {
+
+ var Dom = this._oDom;
+ var oConfig = this.cfg;
+ var oEl = this.element;
+ var nListElements = this._aListElements.length;
+
+
+ if(oConfig.getProperty("position") == "static") {
+
+ oConfig.queueProperty("iframe", false);
+ oConfig.queueProperty("visible", true);
+
+ }
+
+
+ if(nListElements > 0) {
+
+ var i = 0;
+ var bFirstList = true;
+ var oUL;
+ var oGroupTitle;
+
+
+ do {
+
+ oUL = this._aListElements[i];
+
+ if(oUL) {
+
+ if(bFirstList) {
+
+ Dom.addClass(oUL, "first-of-type");
+ bFirstList = false;
+
+ }
+
+
+ if(!Dom.isAncestor(oEl, oUL)) {
+
+ this.appendToBody(oUL);
+
+ }
+
+
+ oGroupTitle = this._aGroupTitleElements[i];
+
+ if(oGroupTitle) {
+
+ if(!Dom.isAncestor(oEl, oGroupTitle)) {
+
+ oUL.parentNode.insertBefore(oGroupTitle, oUL);
+
+ }
+
+
+ Dom.addClass(oUL, "hastitle");
+
+ }
+
+ }
+
+ i++;
+
+ }
+ while(i < nListElements);
+
+ }
+
+ };
+
+/**
+* "render" Custom Event handler for a MenuModule instance.
+* @private
+* @param {String} p_sType The name of the event that was fired.
+* @param {Array} p_aArgs Collection of arguments sent when the event
+* was fired.
+* @param {YAHOO.widget.MenuModule} p_oMenuModule The MenuModule instance that
+* fired the event.
+*/
+YAHOO.widget.MenuModule.prototype._onRender =
+
+ function(p_sType, p_aArgs, p_oMenuModule) {
+
+ if(this.cfg.getProperty("position") == "dynamic") {
+
+ var sWidth = this.element.parentNode.tagName == "BODY" ?
+ this.element.offsetWidth : this._getOffsetWidth();
+
+ this.cfg.setProperty("width", (sWidth + "px"));
+
+ }
+
+ };
+
+/**
+* "show" Custom Event handler for a MenuModule instance.
+* @private
+* @param {String} p_sType The name of the event that was fired.
+* @param {Array} p_aArgs Collection of arguments sent when the event
+* was fired.
+* @param {YAHOO.widget.MenuModule} p_oMenuModule The MenuModule instance that
+* fired the event.
+*/
+YAHOO.widget.MenuModule.prototype._onShow =
+
+ function(p_sType, p_aArgs, p_oMenuModule) {
+
+ /*
+ Setting focus to an item in the newly visible submenu alerts the
+ contents of the submenu to the screen reader.
+ */
+
+ this.setInitialFocus();
+
+ };
+
+/**
+* "hide" Custom Event handler for a MenuModule instance.
+* @private
+* @param {String} p_sType The name of the event that was fired.
+* @param {Array} p_aArgs Collection of arguments sent when the event
+* was fired.
+* @param {YAHOO.widget.MenuModule} p_oMenuModule The MenuModule instance that
+* fired the event.
+*/
+YAHOO.widget.MenuModule.prototype._onBeforeHide =
+
+ function(p_sType, p_aArgs, p_oMenuModule) {
+
+ var oActiveItem = this.activeItem;
+
+ if(oActiveItem) {
+
+ oActiveItem.blur();
+
+ if(oActiveItem.cfg.getProperty("selected")) {
+
+ oActiveItem.cfg.setProperty("selected", false);
+
+ }
+
+ var oSubmenu = oActiveItem.cfg.getProperty("submenu");
+
+ if(oSubmenu && oSubmenu.cfg.getProperty("visible")) {
+
+ oSubmenu.hide();
+
+ }
+
+ }
+
+ };
+
+/**
+* "configchange" Custom Event handler for a submenu.
+* @private
+* @param {String} p_sType The name of the event that was fired.
+* @param {Array} p_aArgs Collection of arguments sent when the event
+* was fired.
+* @param {YAHOO.widget.MenuModule} p_oSubmenu The submenu that subscribed
+* to the event.
+*/
+YAHOO.widget.MenuModule.prototype._onParentMenuModuleConfigChange =
+
+ function(p_sType, p_aArgs, p_oSubmenu) {
+
+ var sPropertyName = p_aArgs[0][0];
+ var oPropertyValue = p_aArgs[0][1];
+
+ switch(sPropertyName) {
+
+ case "iframe":
+ case "constraintoviewport":
+
+ p_oSubmenu.cfg.setProperty(sPropertyName, oPropertyValue);
+
+ break;
+
+ }
+
+ };
+
+/**
+* "render" Custom Event handler for a MenuModule instance. Renders a
+* submenu in response to the firing of it's parent's "render" event.
+* @private
+* @param {String} p_sType The name of the event that was fired.
+* @param {Array} p_aArgs Collection of arguments sent when the event
+* was fired.
+* @param {YAHOO.widget.MenuModule} p_oSubmenu The submenu that subscribed
+* to the event.
+*/
+YAHOO.widget.MenuModule.prototype._onParentMenuModuleRender =
+
+ function(p_sType, p_aArgs, p_oSubmenu) {
+
+ /*
+ Set the "iframe" and "constraintoviewport" configuration
+ properties to match the parent MenuModule
+ */
+
+ var oParentMenu = p_oSubmenu.parent.parent;
+
+ p_oSubmenu.cfg.applyConfig(
+
+ {
+ constraintoviewport:
+ oParentMenu.cfg.getProperty("constraintoviewport"),
+
+ xy: [0,0],
+
+ iframe: oParentMenu.cfg.getProperty("iframe")
+
+ }
+
+ );
+
+
+ if(this._oDom.inDocument(this.element)) {
+
+ this.render();
+
+ }
+ else {
+
+ this.render(this.parent.element);
+
+ }
+
+ };
+
+/**
+* "beforeshow" Custom Event handler for a submenu.
+* @private
+* @param {String} p_sType The name of the event that was fired.
+* @param {Array} p_aArgs Collection of arguments sent when the event
+* was fired.
+* @param {YAHOO.widget.MenuModule} p_oSubmenu The submenu that fired
+* the event.
+*/
+YAHOO.widget.MenuModule.prototype._onSubmenuBeforeShow =
+
+ function(p_sType, p_aArgs, p_oSubmenu) {
+
+ var oParent = this.parent;
+ var aAlignment = oParent.parent.cfg.getProperty("submenualignment");
+
+ this.cfg.setProperty(
+ "context",
+ [
+ oParent.element,
+ aAlignment[0],
+ aAlignment[1]
+ ]
+ );
+
+ oParent.submenuIndicator.alt =
+ oParent.EXPANDED_SUBMENU_INDICATOR_ALT_TEXT;
+
+ };
+
+/**
+* "show" Custom Event handler for a submenu.
+* @private
+* @param {String} p_sType The name of the event that was fired.
+* @param {Array} p_aArgs Collection of arguments sent when the event
+* was fired.
+* @param {YAHOO.widget.MenuModule} p_oSubmenu The submenu that fired
+* the event.
+*/
+YAHOO.widget.MenuModule.prototype._onSubmenuShow =
+
+ function(p_sType, p_aArgs, p_oSubmenu) {
+
+ var oParent = this.parent;
+
+ oParent.submenuIndicator.alt =
+ oParent.EXPANDED_SUBMENU_INDICATOR_ALT_TEXT;
+
+ };
+
+/**
+* "hide" Custom Event handler for a submenu.
+* @private
+* @param {String} p_sType The name of the event that was fired.
+* @param {Array} p_aArgs Collection of arguments sent when the event
+* was fired.
+* @param {YAHOO.widget.MenuModule} p_oSubmenu The submenu that fired
+* the event.
+*/
+YAHOO.widget.MenuModule.prototype._onSubmenuHide =
+
+ function(p_sType, p_aArgs, p_oSubmenu) {
+
+ var oParent = this.parent;
+
+ if(oParent.parent.cfg.getProperty("visible")) {
+
+ oParent.cfg.setProperty("selected", false);
+
+ oParent.focus();
+
+ }
+
+ oParent.submenuIndicator.alt =
+ oParent.COLLAPSED_SUBMENU_INDICATOR_ALT_TEXT;
+
+ };
+
+/**
+* "focus" YAHOO.util.CustomEvent handler for a MenuModule instance's items.
+* @private
+* @param {String} p_sType The name of the event that was fired.
+* @param {Array} p_aArgs Collection of arguments sent when the event
+* was fired.
+* @param {Array} p_aObjects Array containing the current MenuModule instance
+* and the item that fired the event.
+*/
+YAHOO.widget.MenuModule.prototype._onItemFocus =
+
+ function(p_sType, p_aArgs, p_aObjects) {
+
+ var me = p_aObjects[0];
+ var oItem = p_aObjects[1];
+
+ me.activeItem = oItem;
+
+ };
+
+/**
+* "blur" YAHOO.util.CustomEvent handler for a MenuModule instance's items.
+* @private
+* @param {String} p_sType The name of the event that was fired.
+* @param {Array} p_aArgs Collection of arguments sent when the event
+* was fired.
+* @param {Array} p_aObjects Array containing the current MenuModule instance
+* and the item that fired the event.
+*/
+YAHOO.widget.MenuModule.prototype._onItemBlur =
+
+ function(p_sType, p_aArgs, p_aObjects) {
+
+ var me = p_aObjects[0];
+ var oItem = p_aObjects[1];
+ var oSubmenu = oItem.cfg.getProperty("submenu");
+
+ if(!oSubmenu || (oSubmenu && !oSubmenu.cfg.getProperty("visible"))) {
+
+ me.activeItem = null;
+
+ }
+
+ };
+
+/**
+* "configchange" YAHOO.util.CustomEvent handler for the MenuModule
+* instance's items.
+* @private
+* @param {String} p_sType The name of the event that was fired.
+* @param {Array} p_aArgs Collection of arguments sent when the
+* event was fired.
+* @param {Array} p_aObjects Array containing the current MenuModule instance
+* and the item that fired the event.
+*/
+YAHOO.widget.MenuModule.prototype._onItemConfigChange =
+
+ function(p_sType, p_aArgs, p_aObjects) {
+
+ var me = p_aObjects[0];
+ var sProperty = p_aArgs[0][0];
+ var oItem = p_aObjects[1];
+
+ switch(sProperty) {
+
+ case "submenu":
+
+ var oSubmenu = p_aArgs[0][1];
+
+ if(oSubmenu) {
+
+ me._configureItemSubmenuModule(oItem);
+
+ }
+
+ break;
+
+ case "text":
+ case "helptext":
+
+ /*
+ A change to an item's "text" or "helptext"
+ configuration properties requires the width of the parent
+ MenuModule instance to be recalculated.
+ */
+
+ if(me.element.style.width) {
+
+ var sWidth = me._getOffsetWidth() + "px";
+
+ me._oDom.setStyle(me.element, "width", sWidth);
+
+ }
+
+ break;
+
+ }
+
+ };
+
+/**
+* The default event handler executed when the moveEvent is fired, if the
+* "constraintoviewport" configuration property is set to true.
+*/
+YAHOO.widget.MenuModule.prototype.enforceConstraints =
+
+ function(type, args, obj) {
+
+ var Dom = this._oDom;
+ var oConfig = this.cfg;
+
+ var pos = args[0];
+
+ var x = pos[0];
+ var y = pos[1];
+
+ var bod = document.getElementsByTagName('body')[0];
+ var htm = document.getElementsByTagName('html')[0];
+
+ var bodyOverflow = Dom.getStyle(bod, "overflow");
+ var htmOverflow = Dom.getStyle(htm, "overflow");
+
+ var offsetHeight = this.element.offsetHeight;
+ var offsetWidth = this.element.offsetWidth;
+
+ var viewPortWidth = Dom.getClientWidth();
+ var viewPortHeight = Dom.getClientHeight();
+
+ var scrollX = window.scrollX || document.body.scrollLeft;
+ var scrollY = window.scrollY || document.body.scrollTop;
+
+ var topConstraint = scrollY + 10;
+ var leftConstraint = scrollX + 10;
+ var bottomConstraint = scrollY + viewPortHeight - offsetHeight - 10;
+ var rightConstraint = scrollX + viewPortWidth - offsetWidth - 10;
+
+ var aContext = oConfig.getProperty("context");
+ var oContextElement = aContext ? aContext[0] : null;
+
+
+ if (x < 10) {
+
+ x = leftConstraint;
+
+ } else if ((x + offsetWidth) > viewPortWidth) {
+
+ if(
+ oContextElement &&
+ ((x - oContextElement.offsetWidth) > offsetWidth)
+ ) {
+
+ x = (x - (oContextElement.offsetWidth + offsetWidth));
+
+ }
+ else {
+
+ x = rightConstraint;
+
+ }
+
+ }
+
+ if (y < 10) {
+
+ y = topConstraint;
+
+ } else if (y > bottomConstraint) {
+
+ if(oContextElement && (y > offsetHeight)) {
+
+ y = ((y + oContextElement.offsetHeight) - offsetHeight);
+
+ }
+ else {
+
+ y = bottomConstraint;
+
+ }
+
+ }
+
+ oConfig.setProperty("x", x, true);
+ oConfig.setProperty("y", y, true);
+
+ };
+
+// Event handlers for configuration properties
+
+/**
+* Event handler for when the "position" configuration property of a
+* MenuModule changes.
+* @param {String} p_sType The name of the event that was fired.
+* @param {Array} p_aArgs Collection of arguments sent when the event
+* was fired.
+* @param {YAHOO.widget.MenuModule} p_oMenuModule The MenuModule instance fired
+* the event.
+* @see YAHOO.widget.Overlay#configIframe
+*/
+YAHOO.widget.MenuModule.prototype.configPosition =
+
+ function(p_sType, p_aArgs, p_oMenuModule) {
+
+ var sCSSPosition = p_aArgs[0] == "static" ? "static" : "absolute";
+
+ this._oDom.setStyle(this.element, "position", sCSSPosition);
+
+ };
+
+// Public methods
+
+YAHOO.widget.MenuModule.prototype.toString = function() {
+
+ return ("Menu " + this.id);
+
+};
+
+/**
+* Sets the title of a group of items.
+* @param {String} p_sGroupTitle The title of the group.
+* @param {Number} p_nGroupIndex Optional. Number indicating the group to which
+* the title belongs.
+*/
+YAHOO.widget.MenuModule.prototype.setItemGroupTitle =
+
+ function(p_sGroupTitle, p_nGroupIndex) {
+
+ if(typeof p_sGroupTitle == "string" && p_sGroupTitle.length > 0) {
+
+ var Dom = this._oDom;
+
+ var nGroupIndex =
+ typeof p_nGroupIndex == "number" ? p_nGroupIndex : 0;
+
+ var oTitle = this._aGroupTitleElements[nGroupIndex];
+
+
+ if(oTitle) {
+
+ oTitle.innerHTML = p_sGroupTitle;
+
+ }
+ else {
+
+ oTitle = document.createElement(this.GROUP_TITLE_TAG_NAME);
+
+ oTitle.innerHTML = p_sGroupTitle;
+
+ this._aGroupTitleElements[nGroupIndex] = oTitle;
+
+ }
+
+
+ var i = this._aGroupTitleElements.length - 1;
+ var nFirstIndex;
+
+ do {
+
+ if(this._aGroupTitleElements[i]) {
+
+ Dom.removeClass(
+ this._aGroupTitleElements[i],
+ "first-of-type"
+ );
+
+ nFirstIndex = i;
+
+ }
+
+ }
+ while(i--);
+
+
+ if(nFirstIndex !== null) {
+
+ Dom.addClass(
+ this._aGroupTitleElements[nFirstIndex],
+ "first-of-type"
+ );
+
+ }
+
+ }
+
+ };
+
+/**
+* Appends the specified item to a MenuModule instance.
+* @param {YAHOO.widget.MenuModuleItem} p_oItem The item to be added.
+* @param {Number} p_nGroupIndex Optional. Number indicating the group to which
+* the item belongs.
+* @return The item that was added to the MenuModule.
+* @type YAHOO.widget.MenuModuleItem
+*/
+YAHOO.widget.MenuModule.prototype.addItem = function(p_oItem, p_nGroupIndex) {
+
+ if(p_oItem) {
+
+ return this._addItemToGroup(p_nGroupIndex, p_oItem);
+
+ }
+
+};
+
+/**
+* Inserts an item into a MenuModule instance at the specified index.
+* @param {YAHOO.widget.MenuModuleItem} p_oItem The item to be inserted.
+* @param {Number} p_nItemIndex Number indicating the ordinal position
+* at which the item should be added.
+* @param {Number} p_nGroupIndex Optional. Number indicating the group to which
+* the item belongs.
+* @return The item that was inserted into the MenuModule.
+* @type YAHOO.widget.MenuModuleItem
+*/
+YAHOO.widget.MenuModule.prototype.insertItem =
+
+ function(p_oItem, p_nItemIndex, p_nGroupIndex) {
+
+ if(p_oItem) {
+
+ return this._addItemToGroup(p_nGroupIndex, p_oItem, p_nItemIndex);
+
+ }
+
+ };
+
+/**
+* Removes the specified item from a MenuModule instance.
+* @param {YAHOO.widget.MenuModuleItem/Number} p_oObject The item or index of
+* the item to be removed.
+* @param {Number} p_nGroupIndex Optional. Number indicating the group to which
+* the item belongs.
+* @return The item that was removed from the MenuModule.
+* @type YAHOO.widget.MenuModuleItem
+*/
+YAHOO.widget.MenuModule.prototype.removeItem =
+
+ function(p_oObject, p_nGroupIndex) {
+
+ if(typeof p_oObject != "undefined") {
+
+ var oItem;
+
+ if(p_oObject instanceof YAHOO.widget.MenuModuleItem) {
+
+ oItem =
+ this._removeItemFromGroupByValue(p_nGroupIndex, p_oObject);
+
+ }
+ else if(typeof p_oObject == "number") {
+
+ oItem =
+ this._removeItemFromGroupByIndex(p_nGroupIndex, p_oObject);
+
+ }
+
+ if(oItem) {
+
+ oItem.destroy();
+
+
+ return oItem;
+
+ }
+
+ }
+
+ };
+
+/**
+* Returns a multi-dimensional array of all of a MenuModule's items.
+* @return An array of items.
+* @type Array
+*/
+YAHOO.widget.MenuModule.prototype.getItemGroups = function() {
+
+ return this._aItemGroups;
+
+};
+
+/**
+* Returns the item at the specified index.
+* @param {Number} p_nItemIndex Number indicating the ordinal position of the
+* item to be retrieved.
+* @param {Number} p_nGroupIndex Optional. Number indicating the group to which
+* the item belongs.
+* @return An item.
+* @type YAHOO.widget.MenuModuleItem
+*/
+YAHOO.widget.MenuModule.prototype.getItem =
+
+ function(p_nItemIndex, p_nGroupIndex) {
+
+ if(typeof p_nItemIndex == "number") {
+
+ var aGroup = this._getItemGroup(p_nGroupIndex);
+
+ if(aGroup) {
+
+ return aGroup[p_nItemIndex];
+
+ }
+
+ }
+
+ };
+
+/**
+* Removes the MenuModule instance's element from the DOM and sets all child
+* elements to null.
+*/
+YAHOO.widget.MenuModule.prototype.destroy = function() {
+
+ // Remove DOM event handlers
+
+ this._oEventUtil.purgeElement(this.element);
+
+ // Remove Custom Event listeners
+
+ this.mouseOverEvent.unsubscribeAll();
+ this.mouseOutEvent.unsubscribeAll();
+ this.mouseDownEvent.unsubscribeAll();
+ this.mouseUpEvent.unsubscribeAll();
+ this.clickEvent.unsubscribeAll();
+ this.keyPressEvent.unsubscribeAll();
+ this.keyDownEvent.unsubscribeAll();
+ this.keyUpEvent.unsubscribeAll();
+ this.beforeMoveEvent.unsubscribeAll();
+
+ var nItemGroups = this._aItemGroups.length;
+ var nItems;
+ var oItemGroup;
+ var oItem;
+ var i;
+ var n;
+
+ // Remove all items
+
+ if(nItemGroups > 0) {
+
+ i = nItemGroups - 1;
+
+ do {
+
+ oItemGroup = this._aItemGroups[i];
+
+ if(oItemGroup) {
+
+ nItems = oItemGroup.length;
+
+ if(nItems > 0) {
+
+ n = nItems - 1;
+
+ do {
+
+ oItem = this._aItemGroups[i][n];
+
+ if(oItem) {
+
+ oItem.destroy();
+ }
+
+ }
+ while(n--);
+
+ }
+
+ }
+
+ }
+ while(i--);
+
+ }
+
+ // Continue with the superclass implementation of this method
+
+ YAHOO.widget.MenuModule.superclass.destroy.call(this);
+
+
+};
+
+/**
+* Sets focus to a MenuModule instance's first enabled item.
+*/
+YAHOO.widget.MenuModule.prototype.setInitialFocus = function() {
+
+ var oItem = this._getFirstEnabledItem();
+
+ if(oItem) {
+
+ oItem.focus();
+ }
+
+};
+
+/**
+* Sets the "selected" configuration property of a MenuModule instance's first
+* enabled item to "true."
+*/
+YAHOO.widget.MenuModule.prototype.setInitialSelection = function() {
+
+ var oItem = this._getFirstEnabledItem();
+
+ if(oItem) {
+
+ oItem.cfg.setProperty("selected", true);
+ }
+
+};
+
+/**
+* Sets the "selected" configuration property of a MenuModule instance's active
+* item to "false," blurs the item and hide's the item's submenu.
+*/
+YAHOO.widget.MenuModule.prototype.clearActiveItem = function () {
+
+ if(this.activeItem) {
+
+ var oConfig = this.activeItem.cfg;
+
+ oConfig.setProperty("selected", false);
+
+ var oSubmenu = oConfig.getProperty("submenu");
+
+ if(oSubmenu) {
+
+ oSubmenu.hide();
+
+ }
+
+ }
+
+};
+
+/**
+* Initializes the class's configurable properties which can be changed using
+* the MenuModule's Config object (cfg).
+*/
+YAHOO.widget.MenuModule.prototype.initDefaultConfig = function() {
+
+ YAHOO.widget.MenuModule.superclass.initDefaultConfig.call(this);
+
+ var oConfig = this.cfg;
+
+ // Add configuration properties
+
+ oConfig.addProperty(
+ "position",
+ {
+ value: "dynamic",
+ handler: this.configPosition,
+ validator: this._checkPosition
+ }
+ );
+
+ oConfig.refireEvent("position");
+
+ oConfig.addProperty("submenualignment", { value: ["tl","tr"] } );
+
+};
+
+/**
+* @class The MenuModuleItem class allows you to create and modify an item for a
+* MenuModule instance.
+* @constructor
+* @param {String or HTMLElement} p_oObject String or HTMLElement
+* (either HTMLLIElement, HTMLOptGroupElement or HTMLOptionElement) of the
+* source HTMLElement node.
+* @param {Object} p_oConfig The configuration object literal containing
+* the configuration for a MenuModuleItem instance. See the configuration
+* class documentation for more details.
+*/
+YAHOO.widget.MenuModuleItem = function(p_oObject, p_oConfig) {
+
+ if(p_oObject) {
+
+ this.init(p_oObject, p_oConfig);
+
+ }
+
+};
+
+YAHOO.widget.MenuModuleItem.prototype = {
+
+ // Constants
+
+ /**
+ * Constant representing the path to the image to be used for the submenu
+ * arrow indicator.
+ * @final
+ * @type String
+ */
+ SUBMENU_INDICATOR_IMAGE_PATH: "nt/ic/ut/alt1/menuarorght8_nrm_1.gif",
+
+ /**
+ * Constant representing the path to the image to be used for the submenu
+ * arrow indicator when a MenuModuleItem instance is selected.
+ * @final
+ * @type String
+ */
+ SELECTED_SUBMENU_INDICATOR_IMAGE_PATH:
+ "nt/ic/ut/alt1/menuarorght8_hov_1.gif",
+
+ /**
+ * Constant representing the path to the image to be used for the submenu
+ * arrow indicator when a MenuModuleItem instance is disabled.
+ * @final
+ * @type String
+ */
+ DISABLED_SUBMENU_INDICATOR_IMAGE_PATH:
+ "nt/ic/ut/alt1/menuarorght8_dim_1.gif",
+
+ /**
+ * Constant representing the alt text for the image to be used for the
+ * submenu arrow indicator.
+ * @final
+ * @type String
+ */
+ COLLAPSED_SUBMENU_INDICATOR_ALT_TEXT: "Collapsed. Click to expand.",
+
+ /**
+ * Constant representing the alt text for the image to be used for the
+ * submenu arrow indicator when the submenu is visible.
+ * @final
+ * @type String
+ */
+ EXPANDED_SUBMENU_INDICATOR_ALT_TEXT: "Expanded. Click to collapse.",
+
+ /**
+ * Constant representing the alt text for the image to be used for the
+ * submenu arrow indicator when a MenuModuleItem instance is disabled.
+ * @final
+ * @type String
+ */
+ DISABLED_SUBMENU_INDICATOR_ALT_TEXT: "Disabled.",
+
+ /**
+ * Constant representing the CSS class(es) to be applied to the root
+ * HTMLLIElement of the MenuModuleItem.
+ * @final
+ * @type String
+ */
+ CSS_CLASS_NAME: "yuimenuitem",
+
+ /**
+ * Constant representing the type of menu to instantiate when creating
+ * submenu instances from parsing the child nodes (either HTMLSelectElement
+ * or HTMLDivElement) of the item's DOM. The default
+ * is YAHOO.widget.MenuModule.
+ * @final
+ * @type YAHOO.widget.MenuModule
+ */
+ SUBMENU_TYPE: null,
+
+ /**
+ * Constant representing the type of item to instantiate when
+ * creating item instances from parsing the child nodes (either
+ * HTMLLIElement, HTMLOptGroupElement or HTMLOptionElement) of the
+ * submenu's DOM.
+ * The default is YAHOO.widget.MenuModuleItem.
+ * @final
+ * @type YAHOO.widget.MenuModuleItem
+ */
+ SUBMENU_ITEM_TYPE: null,
+
+ /**
+ * Constant representing the prefix path to use for non-secure images
+ * @type string
+ */
+ IMG_ROOT: "http://us.i1.yimg.com/us.yimg.com/i/",
+
+
+ /**
+ * Constant representing the prefix path to use for securely served images
+ * @type string
+ */
+ IMG_ROOT_SSL: "https://a248.e.akamai.net/sec.yimg.com/i/",
+
+ // Private member variables
+
+ /**
+ * Reference to the HTMLAnchorElement of the MenuModuleItem's core internal
+ * DOM structure.
+ * @private
+ * @type {HTMLAnchorElement}
+ */
+ _oAnchor: null,
+
+
+ /**
+ * Reference to the text node of the MenuModuleItem's core internal
+ * DOM structure.
+ * @private
+ * @type {Text}
+ */
+ _oText: null,
+
+
+ /**
+ * Reference to the HTMLElement (<EM<) used to create the optional
+ * help text for a MenuModuleItem instance.
+ * @private
+ * @type {HTMLElement}
+ */
+ _oHelpTextEM: null,
+
+
+ /**
+ * Reference to the submenu for a MenuModuleItem instance.
+ * @private
+ * @type {YAHOO.widget.MenuModule}
+ */
+ _oSubmenu: null,
+
+
+ /**
+ * Reference to the Dom utility singleton.
+ * @private
+ * @type {YAHOO.util.Dom}
+ */
+ _oDom: YAHOO.util.Dom,
+
+ // Public properties
+
+ /**
+ * The class's constructor function
+ * @type YAHOO.widget.MenuModuleItem
+ */
+ constructor: YAHOO.widget.MenuModuleItem,
+
+ /**
+ * The string representing the image root
+ * @type string
+ */
+ imageRoot: null,
+
+ /**
+ * Boolean representing whether or not the current browsing context
+ * is secure (https)
+ * @type boolean
+ */
+ isSecure: YAHOO.widget.Module.prototype.isSecure,
+
+ /**
+ * Returns the ordinal position of a MenuModuleItem instance in a group.
+ * @type Number
+ */
+ index: null,
+
+ /**
+ * Returns the index of the group to which a MenuModuleItem instance belongs.
+ * @type Number
+ */
+ groupIndex: null,
+
+ /**
+ * Returns the parent object for a MenuModuleItem instance.
+ * @type {YAHOO.widget.MenuModule}
+ */
+ parent: null,
+
+ /**
+ * Returns the HTMLLIElement for a MenuModuleItem instance.
+ * @type {HTMLLIElement}
+ */
+ element: null,
+
+ /**
+ * Returns the HTMLElement (either HTMLLIElement, HTMLOptGroupElement or
+ * HTMLOptionElement) used create the MenuModuleItem instance.
+ * @type {HTMLLIElement/HTMLOptGroupElement/HTMLOptionElement}
+ */
+ srcElement: null,
+
+ /**
+ * Specifies an arbitrary value for a MenuModuleItem instance.
+ * @type {Object}
+ */
+ value: null,
+
+ /**
+ * Reference to the HTMLImageElement used to create the submenu
+ * indicator for a MenuModuleItem instance.
+ * @type {HTMLImageElement}
+ */
+ submenuIndicator: null,
+
+ /**
+ * String representing the browser
+ * @type string
+ */
+ browser: YAHOO.widget.Module.prototype.browser,
+
+ // Events
+
+ /**
+ * Fires when a MenuModuleItem instances's HTMLLIElement is removed from
+ * it's parent HTMLUListElement node.
+ * @type {YAHOO.util.CustomEvent}
+ * @see YAHOO.util.CustomEvent
+ */
+ destroyEvent: null,
+
+ /**
+ * Fires when the mouse has entered a MenuModuleItem instance. Passes
+ * back the DOM Event object as an argument.
+ * @type {YAHOO.util.CustomEvent}
+ * @see YAHOO.util.CustomEvent
+ */
+ mouseOverEvent: null,
+
+ /**
+ * Fires when the mouse has left a MenuModuleItem instance. Passes back
+ * the DOM Event object as an argument.
+ * @type {YAHOO.util.CustomEvent}
+ * @see YAHOO.util.CustomEvent
+ */
+ mouseOutEvent: null,
+
+ /**
+ * Fires when the user mouses down on a MenuModuleItem instance. Passes
+ * back the DOM Event object as an argument.
+ * @type {YAHOO.util.CustomEvent}
+ * @see YAHOO.util.CustomEvent
+ */
+ mouseDownEvent: null,
+
+ /**
+ * Fires when the user releases a mouse button while the mouse is
+ * over a MenuModuleItem instance. Passes back the DOM Event object as
+ * an argument.
+ * @type {YAHOO.util.CustomEvent}
+ * @see YAHOO.util.CustomEvent
+ */
+ mouseUpEvent: null,
+
+ /**
+ * Fires when the user clicks the on a MenuModuleItem instance. Passes
+ * back the DOM Event object as an argument.
+ * @type {YAHOO.util.CustomEvent}
+ * @see YAHOO.util.CustomEvent
+ */
+ clickEvent: null,
+
+ /**
+ * Fires when the user presses an alphanumeric key. Passes back the
+ * DOM Event object as an argument.
+ * @type {YAHOO.util.CustomEvent}
+ * @see YAHOO.util.CustomEvent
+ */
+ keyPressEvent: null,
+
+ /**
+ * Fires when the user presses a key. Passes back the DOM Event
+ * object as an argument.
+ * @type {YAHOO.util.CustomEvent}
+ * @see YAHOO.util.CustomEvent
+ */
+ keyDownEvent: null,
+
+ /**
+ * Fires when the user releases a key. Passes back the DOM Event
+ * object as an argument.
+ * @type {YAHOO.util.CustomEvent}
+ * @see YAHOO.util.CustomEvent
+ */
+ keyUpEvent: null,
+
+ /**
+ * Fires when a MenuModuleItem instance receives focus.
+ * @type {YAHOO.util.CustomEvent}
+ * @see YAHOO.util.CustomEvent
+ */
+ focusEvent: null,
+
+ /**
+ * Fires when a MenuModuleItem instance loses the input focus.
+ * @type {YAHOO.util.CustomEvent}
+ * @see YAHOO.util.CustomEvent
+ */
+ blurEvent: null,
+
+ /**
+ * The MenuModuleItem class's initialization method. This method is
+ * automatically called by the constructor, and sets up all DOM references
+ * for pre-existing markup, and creates required markup if it is not
+ * already present.
+ * @param {String or HTMLElement} p_oObject String or HTMLElement
+ * (either HTMLLIElement, HTMLOptGroupElement or HTMLOptionElement) of the
+ * source HTMLElement node.
+ * @param {Object} p_oConfig The configuration object literal containing
+ * the configuration for a MenuModuleItem instance. See the configuration
+ * class documentation for more details.
+ */
+ init: function(p_oObject, p_oConfig) {
+
+ this.imageRoot = (this.isSecure) ? this.IMG_ROOT_SSL : this.IMG_ROOT;
+
+ if(!this.SUBMENU_TYPE) {
+
+ this.SUBMENU_TYPE = YAHOO.widget.MenuModule;
+
+ }
+
+ if(!this.SUBMENU_ITEM_TYPE) {
+
+ this.SUBMENU_ITEM_TYPE = YAHOO.widget.MenuModuleItem;
+
+ }
+
+ // Create the config object
+
+ this.cfg = new YAHOO.util.Config(this);
+
+ this.initDefaultConfig();
+
+ var oConfig = this.cfg;
+
+ if(this._checkString(p_oObject)) {
+
+ this._createRootNodeStructure();
+
+ oConfig.setProperty("text", p_oObject);
+
+ }
+ else if(this._checkDOMNode(p_oObject)) {
+
+ switch(p_oObject.tagName) {
+
+ case "OPTION":
+
+ this._createRootNodeStructure();
+
+ oConfig.setProperty("text", p_oObject.text);
+
+ this.srcElement = p_oObject;
+
+ break;
+
+ case "OPTGROUP":
+
+ this._createRootNodeStructure();
+
+ oConfig.setProperty("text", p_oObject.label);
+
+ this.srcElement = p_oObject;
+
+ this._initSubTree();
+
+ break;
+
+ case "LI":
+
+ // Get the anchor node (if it exists)
+
+ var oAnchor = this._getFirstElement(p_oObject, "A");
+ var sURL = "#";
+ var sText = null;
+
+ // Capture the "text" and/or the "URL"
+
+ if(oAnchor) {
+
+ sURL = oAnchor.getAttribute("href");
+
+ if(oAnchor.innerText) {
+
+ sText = oAnchor.innerText;
+
+ }
+ else {
+
+ var oRange = oAnchor.ownerDocument.createRange();
+
+ oRange.selectNodeContents(oAnchor);
+
+ sText = oRange.toString();
+
+ }
+
+ }
+ else {
+
+ var oText = p_oObject.firstChild;
+
+ sText = oText.nodeValue;
+
+ oAnchor = document.createElement("a");
+
+ oAnchor.setAttribute("href", sURL);
+
+ p_oObject.replaceChild(oAnchor, oText);
+
+ oAnchor.appendChild(oText);
+
+ }
+
+ this.srcElement = p_oObject;
+ this.element = p_oObject;
+ this._oAnchor = oAnchor;
+
+
+ // Check if emphasis has been applied to the MenuModuleItem
+
+ var oEmphasisNode = this._getFirstElement(oAnchor);
+ var bEmphasis = false;
+ var bStrongEmphasis = false;
+
+ if(oEmphasisNode) {
+
+ // Set a reference to the text node
+
+ this._oText = oEmphasisNode.firstChild;
+
+ switch(oEmphasisNode.tagName) {
+
+ case "EM":
+
+ bEmphasis = true;
+
+ break;
+
+ case "STRONG":
+
+ bStrongEmphasis = true;
+
+ break;
+
+ }
+
+ }
+ else {
+
+ // Set a reference to the text node
+
+ this._oText = oAnchor.firstChild;
+
+ }
+
+ /*
+ Set these properties silently to sync up the
+ configuration object without making changes to the
+ element's DOM
+ */
+
+ oConfig.setProperty("text", sText, true);
+ oConfig.setProperty("url", sURL, true);
+ oConfig.setProperty("emphasis", bEmphasis, true);
+ oConfig.setProperty(
+ "strongemphasis",
+ bStrongEmphasis,
+ true
+ );
+
+ this._initSubTree();
+
+ break;
+
+ }
+
+ }
+
+ if(this.element) {
+
+ this._oDom.addClass(this.element, this.CSS_CLASS_NAME);
+
+ // Create custom events
+
+ var CustomEvent = YAHOO.util.CustomEvent;
+
+ this.destroyEvent = new CustomEvent("destroyEvent", this);
+ this.mouseOverEvent = new CustomEvent("mouseOverEvent", this);
+ this.mouseOutEvent = new CustomEvent("mouseOutEvent", this);
+ this.mouseDownEvent = new CustomEvent("mouseDownEvent", this);
+ this.mouseUpEvent = new CustomEvent("mouseUpEvent", this);
+ this.clickEvent = new CustomEvent("clickEvent", this);
+ this.keyPressEvent = new CustomEvent("keyPressEvent", this);
+ this.keyDownEvent = new CustomEvent("keyDownEvent", this);
+ this.keyUpEvent = new CustomEvent("keyUpEvent", this);
+ this.focusEvent = new CustomEvent("focusEvent", this);
+ this.blurEvent = new CustomEvent("blurEvent", this);
+
+ if(p_oConfig) {
+
+ oConfig.applyConfig(p_oConfig);
+
+ }
+
+ oConfig.fireQueue();
+
+ }
+
+ },
+
+ // Private methods
+
+ /**
+ * Returns an HTMLElement's first HTMLElement node
+ * @private
+ * @param {HTMLElement} p_oElement The element to be evaluated.
+ * @param {String} p_sTagName Optional. The tagname of the element.
+ * @return Returns an HTMLElement node.
+ * @type Boolean
+ */
+ _getFirstElement: function(p_oElement, p_sTagName) {
+
+ var oElement;
+
+ if(p_oElement.firstChild && p_oElement.firstChild.nodeType == 1) {
+
+ oElement = p_oElement.firstChild;
+
+ }
+ else if(
+ p_oElement.firstChild &&
+ p_oElement.firstChild.nextSibling &&
+ p_oElement.firstChild.nextSibling.nodeType == 1
+ ) {
+
+ oElement = p_oElement.firstChild.nextSibling;
+
+ }
+
+ if(p_sTagName) {
+
+ return (oElement && oElement.tagName == p_sTagName) ?
+ oElement : false;
+
+ }
+
+ return oElement;
+
+ },
+
+ /**
+ * Determines if an object is a string
+ * @private
+ * @param {Object} p_oObject The object to be evaluated.
+ * @return Returns true if the object is a string.
+ * @type Boolean
+ */
+ _checkString: function(p_oObject) {
+
+ return (typeof p_oObject == "string");
+
+ },
+
+ /**
+ * Determines if an object is an HTMLElement.
+ * @private
+ * @param {Object} p_oObject The object to be evaluated.
+ * @return Returns true if the object is an HTMLElement.
+ * @type Boolean
+ */
+ _checkDOMNode: function(p_oObject) {
+
+ return (p_oObject && p_oObject.tagName);
+
+ },
+
+ /**
+ * Creates the core DOM structure for a MenuModuleItem instance.
+ * @private
+ */
+ _createRootNodeStructure: function () {
+
+ this.element = document.createElement("li");
+
+ this._oText = document.createTextNode("");
+
+ this._oAnchor = document.createElement("a");
+ this._oAnchor.appendChild(this._oText);
+
+ this.cfg.refireEvent("url");
+
+ this.element.appendChild(this._oAnchor);
+
+ },
+
+ /**
+ * Iterates the source element's childNodes collection and uses the
+ * child nodes to instantiate other menus.
+ * @private
+ */
+ _initSubTree: function() {
+
+ var Menu = this.SUBMENU_TYPE;
+ var MenuModuleItem = this.SUBMENU_ITEM_TYPE;
+ var oSrcEl = this.srcElement;
+ var oConfig = this.cfg;
+
+ if(oSrcEl.childNodes.length > 0) {
+
+ var oNode = oSrcEl.firstChild;
+ var aOptions = [];
+
+ do {
+
+ switch(oNode.tagName) {
+
+ case "DIV":
+
+ oConfig.setProperty("submenu", (new Menu(oNode)));
+
+ break;
+
+ case "OPTION":
+
+ aOptions[aOptions.length] = oNode;
+
+ break;
+
+ }
+
+ }
+ while((oNode = oNode.nextSibling));
+
+ var nOptions = aOptions.length;
+
+ if(nOptions > 0) {
+
+ oConfig.setProperty(
+ "submenu",
+ (new Menu(this._oDom.generateId()))
+ );
+
+ for(var n=0; n<nOptions; n++) {
+
+ this._oSubmenu.addItem((new MenuModuleItem(aOptions[n])));
+
+ }
+
+ }
+
+ }
+
+ },
+
+ // Event handlers for configuration properties
+
+ /**
+ * Event handler for when the "text" configuration property of
+ * a MenuModuleItem instance changes.
+ * @param {String} p_sType The name of the event that was fired.
+ * @param {Array} p_aArgs Collection of arguments sent when the
+ * event was fired.
+ * @param {YAHOO.widget.MenuModuleItem} p_oItem The MenuModuleItem instance
+ * that fired the event.
+ */
+ configText: function(p_sType, p_aArgs, p_oItem) {
+
+ var sText = p_aArgs[0];
+
+ if(this._oText) {
+
+ this._oText.nodeValue = sText;
+
+ }
+
+ },
+
+ /**
+ * Event handler for when the "helptext" configuration property of
+ * a MenuModuleItem instance changes.
+ * @param {String} p_sType The name of the event that was fired.
+ * @param {Array} p_aArgs Collection of arguments sent when the
+ * event was fired.
+ * @param {YAHOO.widget.MenuModuleItem} p_oItem The MenuModuleItem instance
+ * that fired the event.
+ */
+ configHelpText: function(p_sType, p_aArgs, p_oItem) {
+
+ var me = this;
+ var Dom = this._oDom;
+ var oHelpText = p_aArgs[0];
+ var oEl = this.element;
+ var oConfig = this.cfg;
+ var aNodes = [oEl, this._oAnchor];
+ var oImg = this.submenuIndicator;
+
+ /**
+ * Adds the "hashelptext" class to the necessary nodes and refires the
+ * "selected" and "disabled" configuration events
+ * @ignore
+ */
+ function initHelpText() {
+
+ Dom.addClass(aNodes, "hashelptext");
+
+ if(oConfig.getProperty("disabled")) {
+
+ oConfig.refireEvent("disabled");
+
+ }
+
+ if(oConfig.getProperty("selected")) {
+
+ oConfig.refireEvent("selected");
+
+ }
+
+ }
+
+ /**
+ * Removes the "hashelptext" class and corresponding DOM element (EM)
+ * @ignore
+ */
+ function removeHelpText() {
+
+ Dom.removeClass(aNodes, "hashelptext");
+
+ oEl.removeChild(me._oHelpTextEM);
+ me._oHelpTextEM = null;
+
+ }
+
+ if(this._checkDOMNode(oHelpText)) {
+
+ if(this._oHelpTextEM) {
+
+ this._oHelpTextEM.parentNode.replaceChild(
+ oHelpText,
+ this._oHelpTextEM
+ );
+
+ }
+ else {
+
+ this._oHelpTextEM = oHelpText;
+
+ oEl.insertBefore(this._oHelpTextEM, oImg);
+
+ }
+
+ initHelpText();
+
+ }
+ else if(this._checkString(oHelpText)) {
+
+ if(oHelpText.length === 0) {
+
+ removeHelpText();
+
+ }
+ else {
+
+ if(!this._oHelpTextEM) {
+
+ this._oHelpTextEM = document.createElement("em");
+
+ oEl.insertBefore(this._oHelpTextEM, oImg);
+
+ }
+
+ this._oHelpTextEM.innerHTML = oHelpText;
+
+ initHelpText();
+
+ }
+
+ }
+ else if(!oHelpText && this._oHelpTextEM) {
+
+ removeHelpText();
+
+ }
+
+ },
+
+ /**
+ * Event handler for when the "url" configuration property of
+ * a MenuModuleItem instance changes.
+ * @param {String} p_sType The name of the event that was fired.
+ * @param {Array} p_aArgs Collection of arguments sent when the
+ * event was fired.
+ * @param {YAHOO.widget.MenuModuleItem} p_oItem The MenuModuleItem instance
+ * that fired the event.
+ */
+ configURL: function(p_sType, p_aArgs, p_oItem) {
+
+ var sURL = p_aArgs[0];
+
+ if(!sURL) {
+
+ sURL = "#";
+
+ }
+
+ this._oAnchor.setAttribute("href", sURL);
+
+ },
+
+ /**
+ * Event handler for when the "emphasis" configuration property of
+ * a MenuModuleItem instance changes.
+ * @param {String} p_sType The name of the event that was fired.
+ * @param {Array} p_aArgs Collection of arguments sent when the
+ * event was fired.
+ * @param {YAHOO.widget.MenuModuleItem} p_oItem The MenuModuleItem instance
+ * that fired the event.
+ */
+ configEmphasis: function(p_sType, p_aArgs, p_oItem) {
+
+ var bEmphasis = p_aArgs[0];
+ var oAnchor = this._oAnchor;
+ var oText = this._oText;
+ var oConfig = this.cfg;
+ var oEM;
+
+ if(bEmphasis && oConfig.getProperty("strongemphasis")) {
+
+ oConfig.setProperty("strongemphasis", false);
+
+ }
+
+ if(oAnchor) {
+
+ if(bEmphasis) {
+
+ oEM = document.createElement("em");
+ oEM.appendChild(oText);
+
+ oAnchor.appendChild(oEM);
+
+ }
+ else {
+
+ oEM = this._getFirstElement(oAnchor, "EM");
+
+ oAnchor.removeChild(oEM);
+ oAnchor.appendChild(oText);
+
+ }
+
+ }
+
+ },
+
+ /**
+ * Event handler for when the "strongemphasis" configuration property of
+ * a MenuModuleItem instance changes.
+ * @param {String} p_sType The name of the event that was fired.
+ * @param {Array} p_aArgs Collection of arguments sent when the
+ * event was fired.
+ * @param {YAHOO.widget.MenuModuleItem} p_oItem The MenuModuleItem instance
+ * that fired the event.
+ */
+ configStrongEmphasis: function(p_sType, p_aArgs, p_oItem) {
+
+ var bStrongEmphasis = p_aArgs[0];
+ var oAnchor = this._oAnchor;
+ var oText = this._oText;
+ var oConfig = this.cfg;
+ var oStrong;
+
+ if(bStrongEmphasis && oConfig.getProperty("emphasis")) {
+
+ oConfig.setProperty("emphasis", false);
+
+ }
+
+ if(oAnchor) {
+
+ if(bStrongEmphasis) {
+
+ oStrong = document.createElement("strong");
+ oStrong.appendChild(oText);
+
+ oAnchor.appendChild(oStrong);
+
+ }
+ else {
+
+ oStrong = this._getFirstElement(oAnchor, "STRONG");
+
+ oAnchor.removeChild(oStrong);
+ oAnchor.appendChild(oText);
+
+ }
+
+ }
+
+ },
+
+ /**
+ * Event handler for when the "disabled" configuration property of
+ * a MenuModuleItem instance changes.
+ * @param {String} p_sType The name of the event that was fired.
+ * @param {Array} p_aArgs Collection of arguments sent when the
+ * event was fired.
+ * @param {YAHOO.widget.MenuModuleItem} p_oItem The MenuModuleItem instance
+ * that fired the event.
+ */
+ configDisabled: function(p_sType, p_aArgs, p_oItem) {
+
+ var bDisabled = p_aArgs[0];
+ var Dom = this._oDom;
+ var oAnchor = this._oAnchor;
+ var aNodes = [this.element, oAnchor];
+ var oEM = this._oHelpTextEM;
+ var oConfig = this.cfg;
+ var oImg = this.submenuIndicator;
+ var sImageSrc;
+ var sImageAlt;
+
+ if(oEM) {
+
+ aNodes[2] = oEM;
+
+ }
+
+ if(bDisabled) {
+
+ if(oConfig.getProperty("selected")) {
+
+ oConfig.setProperty("selected", false);
+
+ }
+
+ oAnchor.removeAttribute("href");
+
+ Dom.addClass(aNodes, "disabled");
+
+ sImageSrc = this.DISABLED_SUBMENU_INDICATOR_IMAGE_PATH;
+ sImageAlt = this.DISABLED_SUBMENU_INDICATOR_ALT_TEXT;
+
+ }
+ else {
+
+ oAnchor.setAttribute("href", oConfig.getProperty("url"));
+
+ Dom.removeClass(aNodes, "disabled");
+
+ sImageSrc = this.SUBMENU_INDICATOR_IMAGE_PATH;
+ sImageAlt = this.COLLAPSED_SUBMENU_INDICATOR_ALT_TEXT;
+
+ }
+
+ if(oImg) {
+
+ oImg.src = this.imageRoot + sImageSrc;
+ oImg.alt = sImageAlt;
+
+ }
+
+ },
+
+ /**
+ * Event handler for when the "selected" configuration property of
+ * a MenuModuleItem instance changes.
+ * @param {String} p_sType The name of the event that was fired.
+ * @param {Array} p_aArgs Collection of arguments sent when the
+ * event was fired.
+ * @param {YAHOO.widget.MenuModuleItem} p_oItem The MenuModuleItem instance
+ * that fired the event.
+ */
+ configSelected: function(p_sType, p_aArgs, p_oItem) {
+
+ if(!this.cfg.getProperty("disabled")) {
+
+ var Dom = this._oDom;
+ var bSelected = p_aArgs[0];
+ var oEM = this._oHelpTextEM;
+ var aNodes = [this.element, this._oAnchor];
+ var oImg = this.submenuIndicator;
+ var sImageSrc;
+
+ if(oEM) {
+
+ aNodes[2] = oEM;
+
+ }
+
+ if(bSelected) {
+
+ Dom.addClass(aNodes, "selected");
+ sImageSrc = this.SELECTED_SUBMENU_INDICATOR_IMAGE_PATH;
+
+ }
+ else {
+
+ Dom.removeClass(aNodes, "selected");
+ sImageSrc = this.SUBMENU_INDICATOR_IMAGE_PATH;
+
+ }
+
+ if(oImg) {
+
+ oImg.src = document.images[(this.imageRoot + sImageSrc)].src;
+
+ }
+
+ }
+
+ },
+
+ /**
+ * Event handler for when the "submenu" configuration property of
+ * a MenuModuleItem instance changes.
+ * @param {String} p_sType The name of the event that was fired.
+ * @param {Array} p_aArgs Collection of arguments sent when the
+ * event was fired.
+ * @param {YAHOO.widget.MenuModuleItem} p_oItem The MenuModuleItem instance
+ * that fired the event.
+ */
+ configSubmenu: function(p_sType, p_aArgs, p_oItem) {
+
+ var Dom = this._oDom;
+ var oEl = this.element;
+ var oSubmenu = p_aArgs[0];
+ var oImg = this.submenuIndicator;
+ var oConfig = this.cfg;
+ var aNodes = [this.element, this._oAnchor];
+
+ if(oSubmenu) {
+
+ // Set the submenu's parent to this MenuModuleItem instance
+
+ oSubmenu.parent = this;
+
+ this._oSubmenu = oSubmenu;
+
+ if(!oImg) {
+
+ var me = this;
+
+ function preloadImage(p_sPath) {
+
+ var sPath = me.imageRoot + p_sPath;
+
+ if(!document.images[sPath]) {
+
+ var oImg = document.createElement("img");
+ oImg.src = sPath;
+ oImg.name = sPath;
+ oImg.id = sPath;
+ oImg.style.display = "none";
+
+ document.body.appendChild(oImg);
+
+ }
+
+ }
+
+ preloadImage(this.SUBMENU_INDICATOR_IMAGE_PATH);
+ preloadImage(this.SELECTED_SUBMENU_INDICATOR_IMAGE_PATH);
+ preloadImage(this.DISABLED_SUBMENU_INDICATOR_IMAGE_PATH);
+
+ oImg = document.createElement("img");
+ oImg.src = (this.imageRoot + this.SUBMENU_INDICATOR_IMAGE_PATH);
+ oImg.alt = this.COLLAPSED_SUBMENU_INDICATOR_ALT_TEXT;
+
+ oEl.appendChild(oImg);
+
+ this.submenuIndicator = oImg;
+
+ Dom.addClass(aNodes, "hassubmenu");
+
+ if(oConfig.getProperty("disabled")) {
+
+ oConfig.refireEvent("disabled");
+
+ }
+
+ if(oConfig.getProperty("selected")) {
+
+ oConfig.refireEvent("selected");
+
+ }
+
+ }
+
+ }
+ else {
+
+ Dom.removeClass(aNodes, "hassubmenu");
+
+ if(oImg) {
+
+ oEl.removeChild(oImg);
+
+ }
+
+ if(this._oSubmenu) {
+
+ this._oSubmenu.destroy();
+
+ }
+
+ }
+
+ },
+
+ // Public methods
+
+ /**
+ * Initializes an item's configurable properties.
+ */
+ initDefaultConfig : function() {
+
+ var oConfig = this.cfg;
+ var CheckBoolean = oConfig.checkBoolean;
+
+ // Define the config properties
+
+ oConfig.addProperty(
+ "text",
+ {
+ value: "",
+ handler: this.configText,
+ validator: this._checkString,
+ suppressEvent: true
+ }
+ );
+
+ oConfig.addProperty("helptext", { handler: this.configHelpText });
+
+ oConfig.addProperty(
+ "url",
+ { value: "#", handler: this.configURL, suppressEvent: true }
+ );
+
+ oConfig.addProperty(
+ "emphasis",
+ {
+ value: false,
+ handler: this.configEmphasis,
+ validator: CheckBoolean,
+ suppressEvent: true
+ }
+ );
+
+ oConfig.addProperty(
+ "strongemphasis",
+ {
+ value: false,
+ handler: this.configStrongEmphasis,
+ validator: CheckBoolean,
+ suppressEvent: true
+ }
+ );
+
+ oConfig.addProperty(
+ "disabled",
+ {
+ value: false,
+ handler: this.configDisabled,
+ validator: CheckBoolean,
+ suppressEvent: true
+ }
+ );
+
+ oConfig.addProperty(
+ "selected",
+ {
+ value: false,
+ handler: this.configSelected,
+ validator: CheckBoolean,
+ suppressEvent: true
+ }
+ );
+
+ oConfig.addProperty("submenu", { handler: this.configSubmenu });
+
+ },
+
+ /**
+ * Finds the next enabled MenuModuleItem instance in a MenuModule instance
+ * @return Returns a MenuModuleItem instance.
+ * @type YAHOO.widget.MenuModuleItem
+ */
+ getNextEnabledSibling: function() {
+
+ if(this.parent instanceof YAHOO.widget.MenuModule) {
+
+ var nGroupIndex = this.groupIndex;
+
+ /**
+ * Returns the next item in an array
+ * @param {p_aArray} An array
+ * @param {p_nStartIndex} The index to start searching the array
+ * @ignore
+ * @return Returns an item in an array
+ * @type Object
+ */
+ function getNextArrayItem(p_aArray, p_nStartIndex) {
+
+ return p_aArray[p_nStartIndex] ||
+ getNextArrayItem(p_aArray, (p_nStartIndex+1));
+
+ }
+
+
+ var aItemGroups = this.parent.getItemGroups();
+ var oNextItem;
+
+
+ if(this.index < (aItemGroups[nGroupIndex].length - 1)) {
+
+ oNextItem = getNextArrayItem(
+ aItemGroups[nGroupIndex],
+ (this.index+1)
+ );
+
+ }
+ else {
+
+ var nNextGroupIndex;
+
+ if(nGroupIndex < (aItemGroups.length - 1)) {
+
+ nNextGroupIndex = nGroupIndex + 1;
+
+ }
+ else {
+
+ nNextGroupIndex = 0;
+
+ }
+
+ var aNextGroup = getNextArrayItem(aItemGroups, nNextGroupIndex);
+
+ // Retrieve the first MenuModuleItem instance in the next group
+
+ oNextItem = getNextArrayItem(aNextGroup, 0);
+
+ }
+
+ return oNextItem.cfg.getProperty("disabled") ?
+ oNextItem.getNextEnabledSibling() : oNextItem;
+
+ }
+
+ },
+
+ /**
+ * Finds the previous enabled MenuModuleItem instance in a
+ * MenuModule instance
+ * @return Returns a MenuModuleItem instance.
+ * @type YAHOO.widget.MenuModuleItem
+ */
+ getPreviousEnabledSibling: function() {
+
+ if(this.parent instanceof YAHOO.widget.MenuModule) {
+
+ var nGroupIndex = this.groupIndex;
+
+ /**
+ * Returns the previous item in an array
+ * @param {p_aArray} An array
+ * @param {p_nStartIndex} The index to start searching the array
+ * @ignore
+ * @return Returns an item in an array
+ * @type Object
+ */
+ function getPreviousArrayItem(p_aArray, p_nStartIndex) {
+
+ return p_aArray[p_nStartIndex] ||
+ getPreviousArrayItem(p_aArray, (p_nStartIndex-1));
+
+ }
+
+ /**
+ * Get the index of the first item in an array
+ * @param {p_aArray} An array
+ * @param {p_nStartIndex} The index to start searching the array
+ * @ignore
+ * @return Returns an item in an array
+ * @type Object
+ */
+ function getFirstItemIndex(p_aArray, p_nStartIndex) {
+
+ return p_aArray[p_nStartIndex] ?
+ p_nStartIndex :
+ getFirstItemIndex(p_aArray, (p_nStartIndex+1));
+
+ }
+
+ var aItemGroups = this.parent.getItemGroups();
+ var oPreviousItem;
+
+ if(
+ this.index > getFirstItemIndex(aItemGroups[nGroupIndex], 0)
+ ) {
+
+ oPreviousItem =
+ getPreviousArrayItem(
+ aItemGroups[nGroupIndex],
+ (this.index-1)
+ );
+
+ }
+ else {
+
+ var nPreviousGroupIndex;
+
+ if(nGroupIndex > getFirstItemIndex(aItemGroups, 0)) {
+
+ nPreviousGroupIndex = nGroupIndex - 1;
+
+ }
+ else {
+
+ nPreviousGroupIndex = aItemGroups.length - 1;
+
+ }
+
+ var aPreviousGroup =
+ getPreviousArrayItem(aItemGroups, nPreviousGroupIndex);
+
+ oPreviousItem =
+ getPreviousArrayItem(
+ aPreviousGroup,
+ (aPreviousGroup.length - 1)
+ );
+
+ }
+
+ return oPreviousItem.cfg.getProperty("disabled") ?
+ oPreviousItem.getPreviousEnabledSibling() : oPreviousItem;
+
+ }
+
+ },
+
+ /**
+ * Causes a MenuModuleItem instance to receive the focus and fires the
+ * focus event.
+ */
+ focus: function() {
+
+ var oParent = this.parent;
+ var oAnchor = this._oAnchor;
+ var oActiveItem = oParent.activeItem;
+
+ if(
+ !this.cfg.getProperty("disabled") &&
+ oParent &&
+ oParent.cfg.getProperty("visible")
+ ) {
+
+ if(oActiveItem) {
+
+ oActiveItem.blur();
+
+ }
+
+ oAnchor.focus();
+
+ /*
+ Opera 8.5 doesn't always focus the anchor if a MenuModuleItem
+ instance has a submenu, this is fixed by calling "focus"
+ twice.
+ */
+ if(oParent && this.browser == "opera" && this._oSubmenu) {
+
+ oAnchor.focus();
+
+ }
+
+ this.focusEvent.fire();
+
+ }
+
+ },
+
+ /**
+ * Causes a MenuModuleItem instance to lose focus and fires the onblur event.
+ */
+ blur: function() {
+
+ var oParent = this.parent;
+
+ if(
+ !this.cfg.getProperty("disabled") &&
+ oParent &&
+ this._oDom.getStyle(oParent.element, "visibility") == "visible"
+ ) {
+
+ this._oAnchor.blur();
+
+ this.blurEvent.fire();
+
+ }
+
+ },
+
+ /**
+ * Removes a MenuModuleItem instance's HTMLLIElement from it's parent
+ * HTMLUListElement node.
+ */
+ destroy: function() {
+
+ var oEl = this.element;
+
+ if(oEl) {
+
+ // Remove CustomEvent listeners
+
+ this.mouseOverEvent.unsubscribeAll();
+ this.mouseOutEvent.unsubscribeAll();
+ this.mouseDownEvent.unsubscribeAll();
+ this.mouseUpEvent.unsubscribeAll();
+ this.clickEvent.unsubscribeAll();
+ this.keyPressEvent.unsubscribeAll();
+ this.keyDownEvent.unsubscribeAll();
+ this.keyUpEvent.unsubscribeAll();
+ this.focusEvent.unsubscribeAll();
+ this.blurEvent.unsubscribeAll();
+ this.cfg.configChangedEvent.unsubscribeAll();
+
+ // Remove the element from the parent node
+
+ var oParentNode = oEl.parentNode;
+
+ if(oParentNode) {
+
+ oParentNode.removeChild(oEl);
+
+ this.destroyEvent.fire();
+
+ }
+
+ this.destroyEvent.unsubscribeAll();
+
+ }
+
+ }
+
+};
+
+/**
+* @class Extends YAHOO.widget.MenuModule to provide a set of default mouse and
+* key event behaviors.
+* @constructor
+* @extends YAHOO.widget.MenuModule
+* @base YAHOO.widget.MenuModule
+* @param {String or HTMLElement} p_oElement String id or HTMLElement
+* (either HTMLSelectElement or HTMLDivElement) of the source HTMLElement node.
+* @param {Object} p_oConfig Optional. The configuration object literal
+* containing the configuration for a Menu instance. See
+* configuration class documentation for more details.
+*/
+YAHOO.widget.Menu = function(p_oElement, p_oConfig) {
+
+ YAHOO.widget.Menu.superclass.constructor.call(
+ this,
+ p_oElement,
+ p_oConfig
+ );
+
+};
+
+YAHOO.extend(YAHOO.widget.Menu, YAHOO.widget.MenuModule);
+
+/**
+* The Menu class's initialization method. This method is automatically
+* called by the constructor, and sets up all DOM references for pre-existing
+* markup, and creates required markup if it is not already present.
+* @param {String or HTMLElement} p_oElement String id or HTMLElement
+* (either HTMLSelectElement or HTMLDivElement) of the source HTMLElement node.
+* @param {Object} p_oConfig Optional. The configuration object literal
+* containing the configuration for a Menu instance. See
+* configuration class documentation for more details.
+*/
+YAHOO.widget.Menu.prototype.init = function(p_oElement, p_oConfig) {
+
+ if(!this.ITEM_TYPE) {
+
+ this.ITEM_TYPE = YAHOO.widget.MenuItem;
+
+ }
+
+ // Call the init of the superclass (YAHOO.widget.Menu)
+
+ YAHOO.widget.Menu.superclass.init.call(this, p_oElement);
+
+ this.beforeInitEvent.fire(YAHOO.widget.Menu);
+
+ // Add event handlers
+
+ this.showEvent.subscribe(this._onMenuShow, this, true);
+ this.mouseOverEvent.subscribe(this._onMenuMouseOver, this, true);
+ this.keyDownEvent.subscribe(this._onMenuKeyDown, this, true);
+
+ if(p_oConfig) {
+
+ this.cfg.applyConfig(p_oConfig, true);
+
+ }
+
+ this.initEvent.fire(YAHOO.widget.Menu);
+
+};
+
+// Private event handlers
+
+/**
+* "show" Custom Event handler for a menu.
+* @private
+* @param {String} p_sType The name of the event that was fired.
+* @param {Array} p_aArgs Collection of arguments sent when the event
+* was fired.
+* @param {YAHOO.widget.Menu} p_oMenu The menu that fired the event.
+*/
+YAHOO.widget.Menu.prototype._onMenuShow =
+
+ function(p_sType, p_aArgs, p_oMenu) {
+
+ var oParent = this.parent;
+
+ if(oParent && oParent.parent instanceof YAHOO.widget.Menu) {
+
+ var aAlignment = oParent.parent.cfg.getProperty("submenualignment");
+
+ this.cfg.setProperty(
+ "submenualignment",
+ [ aAlignment[0], aAlignment[1] ]
+ );
+
+ }
+
+ };
+
+/**
+* "mouseover" Custom Event handler for a Menu instance.
+* @private
+* @param {String} p_sType The name of the event that was fired.
+* @param {Array} p_aArgs Collection of arguments sent when the event
+* was fired.
+* @param {YAHOO.widget.Menu} p_oMenu The Menu instance that fired the event.
+*/
+YAHOO.widget.Menu.prototype._onMenuMouseOver =
+
+ function(p_sType, p_aArgs, p_oMenu) {
+
+ /*
+ If the menu is a submenu, then select the menu's parent
+ MenuItem instance
+ */
+
+ if(this.parent) {
+
+ this.parent.cfg.setProperty("selected", true);
+
+ }
+
+ };
+
+/**
+* "mouseover" Custom Event handler for a Menu instance.
+* @private
+* @param {String} p_sType The name of the event that was fired.
+* @param {Array} p_aArgs Collection of arguments sent when the event
+* was fired.
+* @param {YAHOO.widget.Menu} p_oMenu The Menu instance that fired the event.
+*/
+YAHOO.widget.Menu.prototype._onMenuKeyDown =
+
+ function(p_sType, p_aArgs, p_oMenu) {
+
+ if(this.cfg.getProperty("position") == "dynamic") {
+
+ var oDOMEvent = p_aArgs[0];
+ var oParent = this.parent;
+
+ if(oDOMEvent.keyCode == 27) { // Esc key
+
+ this.hide();
+
+ // Set focus to the parent MenuItem if one exists
+
+ if(oParent) {
+
+ oParent.focus();
+
+ if(oParent.parent instanceof YAHOO.widget.Menu) {
+
+ oParent.cfg.setProperty("selected", true);
+
+ }
+
+ YAHOO.util.Event.preventDefault(oDOMEvent);
+
+ }
+
+ }
+
+ }
+
+ };
+
+
+// Public event handlers
+
+/**
+* Event handler fired when the resize monitor element is resized.
+*/
+YAHOO.widget.Menu.prototype.onDomResize = function(e, obj) {
+
+ if(!this._handleResize) {
+
+ this._handleResize = true;
+ return;
+
+ }
+
+
+ var me = this;
+ var oConfig = this.cfg;
+
+ if(oConfig.getProperty("position") == "dynamic") {
+
+ oConfig.setProperty("width", (this._getOffsetWidth() + "px"));
+
+ if(this.parent && oConfig.getProperty("visible")) {
+
+ function align() {
+
+ me.align();
+
+ }
+
+ window.setTimeout(align, 0);
+
+ }
+
+ }
+
+ YAHOO.widget.Menu.superclass.onDomResize.call(this, e, obj);
+
+};
+
+/**
+* @class The MenuItem class allows you to create and modify an item for a
+* Menu instance. MenuItem extends YAHOO.widget.MenuModuleItem to provide a
+* set of default mouse and key event behaviors.
+* @constructor
+* @extends YAHOO.widget.MenuModuleItem
+* @base YAHOO.widget.MenuModuleItem
+* @param {String or HTMLElement} p_oObject String or HTMLElement
+* (either HTMLLIElement, HTMLOptGroupElement or HTMLOptionElement) of the
+* source HTMLElement node.
+* @param {Object} p_oConfig The configuration object literal containing
+* the configuration for a MenuItem instance. See the configuration
+* class documentation for more details.
+*/
+YAHOO.widget.MenuItem = function(p_oObject, p_oConfig) {
+
+ YAHOO.widget.MenuItem.superclass.constructor.call(
+ this,
+ p_oObject,
+ p_oConfig
+ );
+
+};
+
+YAHOO.extend(YAHOO.widget.MenuItem, YAHOO.widget.MenuModuleItem);
+
+/**
+* The MenuItem class's initialization method. This method is automatically
+* called by the constructor, and sets up all DOM references for
+* pre-existing markup, and creates required markup if it is not
+* already present.
+* @param {String or HTMLElement} p_oObject String or HTMLElement
+* (either HTMLLIElement, HTMLOptGroupElement or HTMLOptionElement) of the
+* source HTMLElement node.
+* @param {Object} p_oConfig The configuration object literal containing
+* the configuration for a MenuItem instance. See the configuration
+* class documentation for more details.
+*/
+YAHOO.widget.MenuItem.prototype.init = function(p_oObject, p_oConfig) {
+
+ if(!this.SUBMENU_TYPE) {
+
+ this.SUBMENU_TYPE = YAHOO.widget.Menu;
+
+ }
+
+ if(!this.SUBMENU_ITEM_TYPE) {
+
+ this.SUBMENU_ITEM_TYPE = YAHOO.widget.MenuItem;
+
+ }
+
+ /*
+ Call the init of the superclass (YAHOO.widget.MenuModuleItem)
+ Note: We don't pass the user config in here yet
+ because we only want it executed once, at the lowest
+ subclass level.
+ */
+
+ YAHOO.widget.MenuItem.superclass.init.call(this, p_oObject);
+
+ // Add event handlers to each "MenuItem" instance
+
+ this.keyDownEvent.subscribe(this._onKeyDown, this, true);
+ this.mouseOverEvent.subscribe(this._onMouseOver, this, true);
+ this.mouseOutEvent.subscribe(this._onMouseOut, this, true);
+
+ var oConfig = this.cfg;
+
+ if(p_oConfig) {
+
+ oConfig.applyConfig(p_oConfig, true);
+
+ }
+
+ oConfig.fireQueue();
+
+};
+
+// Constants
+
+/**
+* Constant representing the path to the image to be used for the checked state.
+* @final
+* @type String
+*/
+YAHOO.widget.MenuItem.prototype.CHECKED_IMAGE_PATH =
+ "nt/ic/ut/bsc/menuchk8_nrm_1.gif";
+
+/**
+* Constant representing the path to the image to be used for the selected
+* checked state.
+* @final
+* @type String
+*/
+YAHOO.widget.MenuItem.prototype.SELECTED_CHECKED_IMAGE_PATH =
+ "nt/ic/ut/bsc/menuchk8_hov_1.gif";
+
+/**
+* Constant representing the path to the image to be used for the disabled
+* checked state.
+* @final
+* @type String
+*/
+YAHOO.widget.MenuItem.prototype.DISABLED_CHECKED_IMAGE_PATH =
+ "nt/ic/ut/bsc/menuchk8_dim_1.gif";
+
+/**
+* Constant representing the alt text for the image to be used for the
+* checked image.
+* @final
+* @type String
+*/
+YAHOO.widget.MenuItem.prototype.CHECKED_IMAGE_ALT_TEXT = "Checked.";
+
+/**
+* Constant representing the alt text for the image to be used for the
+* checked image when the item is disabled.
+* @final
+* @type String
+*/
+YAHOO.widget.MenuItem.prototype.DISABLED_CHECKED_IMAGE_ALT_TEXT =
+ "Checked. (Item disabled.)";
+
+// Private properties
+
+/**
+* Reference to the HTMLImageElement used to create the checked
+* indicator for a MenuItem instance.
+* @private
+* @type {HTMLImageElement}
+*/
+YAHOO.widget.MenuItem.prototype._checkImage = null;
+
+// Private event handlers
+
+/**
+* "keydown" Custom Event handler for a MenuItem instance.
+* @private
+* @param {String} p_sType The name of the event that was fired.
+* @param {Array} p_aArgs Collection of arguments sent when the event
+* was fired.
+* @param {YAHOO.widget.MenuModule} p_oMenuModule The MenuModule instance that
+* fired the event.
+*/
+YAHOO.widget.MenuItem.prototype._onKeyDown =
+
+ function(p_sType, p_aArgs, p_oMenuItem) {
+
+ var Event = YAHOO.util.Event;
+ var oDOMEvent = p_aArgs[0];
+ var oParent = this.parent;
+ var oConfig = this.cfg;
+ var oMenuItem;
+
+
+ switch(oDOMEvent.keyCode) {
+
+ case 38: // Up arrow
+ case 40: // Down arrow
+
+ if(
+ this == oParent.activeItem &&
+ !oConfig.getProperty("selected")
+ ) {
+
+ oConfig.setProperty("selected", true);
+
+ }
+ else {
+
+ var oNextItem = (oDOMEvent.keyCode == 38) ?
+ this.getPreviousEnabledSibling() :
+ this.getNextEnabledSibling();
+
+ if(oNextItem) {
+
+ oParent.clearActiveItem();
+
+ oNextItem.cfg.setProperty("selected", true);
+
+ oNextItem.focus();
+
+ }
+
+ }
+
+ Event.preventDefault(oDOMEvent);
+
+ break;
+
+
+ case 39: // Right arrow
+
+ oParent.clearActiveItem();
+
+ oConfig.setProperty("selected", true);
+
+ this.focus();
+
+ var oSubmenu = oConfig.getProperty("submenu");
+
+ if(oSubmenu) {
+
+ oSubmenu.show();
+ oSubmenu.setInitialSelection();
+
+ }
+ else if(
+ YAHOO.widget.MenuBarItem &&
+ oParent.parent &&
+ oParent.parent instanceof YAHOO.widget.MenuBarItem
+ ) {
+
+ oParent.hide();
+
+ // Set focus to the parent MenuItem if one exists
+
+ oMenuItem = oParent.parent;
+
+ if(oMenuItem) {
+
+ oMenuItem.focus();
+ oMenuItem.cfg.setProperty("selected", true);
+
+ }
+
+ }
+
+ Event.preventDefault(oDOMEvent);
+
+ break;
+
+
+ case 37: // Left arrow
+
+ // Only hide if this this is a MenuItem of a submenu
+
+ if(oParent.parent) {
+
+ oParent.hide();
+
+ // Set focus to the parent MenuItem if one exists
+
+ oMenuItem = oParent.parent;
+
+ if(oMenuItem) {
+
+ oMenuItem.focus();
+ oMenuItem.cfg.setProperty("selected", true);
+
+ }
+
+ }
+
+ Event.preventDefault(oDOMEvent);
+
+ break;
+
+ }
+
+ };
+
+/**
+* "mouseover" Custom Event handler for a MenuItem instance.
+* @private
+* @param {String} p_sType The name of the event that was fired.
+* @param {Array} p_aArgs Collection of arguments sent when the event
+* was fired.
+* @param {YAHOO.widget.MenuModule} p_oMenuModule The MenuModule instance that
+* fired the event.
+*/
+YAHOO.widget.MenuItem.prototype._onMouseOver =
+
+ function(p_sType, p_aArgs, p_oMenuItem) {
+
+ var oParent = this.parent;
+ var oConfig = this.cfg;
+ var oActiveItem = oParent.activeItem;
+
+
+ // Hide any other submenus that might be visible
+
+ if(oActiveItem && oActiveItem != this) {
+
+ oParent.clearActiveItem();
+
+ }
+
+
+ // Select and focus the current MenuItem instance
+
+ oConfig.setProperty("selected", true);
+ this.focus();
+
+
+ // Show the submenu for this instance
+
+ var oSubmenu = oConfig.getProperty("submenu");
+
+ if(oSubmenu) {
+
+ oSubmenu.show();
+
+ }
+
+ };
+
+/**
+* "mouseout" Custom Event handler for a MenuItem instance.
+* @private
+* @param {String} p_sType The name of the event that was fired.
+* @param {Array} p_aArgs Collection of arguments sent when the event
+* was fired.
+* @param {YAHOO.widget.MenuModule} p_oMenuModule The MenuModule instance that
+* fired the event.
+*/
+YAHOO.widget.MenuItem.prototype._onMouseOut =
+
+ function(p_sType, p_aArgs, p_oMenuItem) {
+
+ var oConfig = this.cfg;
+ var oSubmenu = oConfig.getProperty("submenu");
+
+ oConfig.setProperty("selected", false);
+
+ if(oSubmenu) {
+
+ var oDOMEvent = p_aArgs[0];
+ var oRelatedTarget = YAHOO.util.Event.getRelatedTarget(oDOMEvent);
+
+ if(
+ !(
+ oRelatedTarget == oSubmenu.element ||
+ YAHOO.util.Dom.isAncestor(oSubmenu.element, oRelatedTarget)
+ )
+ ) {
+
+ oSubmenu.hide();
+
+ }
+
+ }
+
+ };
+
+// Event handlers for configuration properties
+
+/**
+* Event handler for when the "checked" configuration property of
+* a MenuItem instance changes.
+* @param {String} p_sType The name of the event that was fired.
+* @param {Array} p_aArgs Collection of arguments sent when the
+* event was fired.
+* @param {YAHOO.widget.MenuItem} p_oItem The MenuItem instance
+* that fired the event.
+*/
+YAHOO.widget.MenuItem.prototype.configChecked =
+
+ function(p_sType, p_aArgs, p_oItem) {
+
+ var Dom = YAHOO.util.Dom;
+ var bChecked = p_aArgs[0];
+ var oEl = this.element;
+ var oConfig = this.cfg;
+ var oImg;
+
+
+ if(bChecked) {
+
+ var me = this;
+
+ function preloadImage(p_sPath) {
+
+ var sPath = me.imageRoot + p_sPath;
+
+ if(!document.images[sPath]) {
+
+ var oImg = document.createElement("img");
+ oImg.src = sPath;
+ oImg.name = sPath;
+ oImg.id = sPath;
+ oImg.style.display = "none";
+
+ document.body.appendChild(oImg);
+
+ }
+
+ }
+
+ preloadImage(this.CHECKED_IMAGE_PATH);
+ preloadImage(this.SELECTED_CHECKED_IMAGE_PATH);
+ preloadImage(this.DISABLED_CHECKED_IMAGE_PATH);
+
+ oImg = document.createElement("img");
+ oImg.src = (this.imageRoot + this.CHECKED_IMAGE_PATH);
+ oImg.alt = this.CHECKED_IMAGE_ALT_TEXT;
+
+ var oSubmenu = this.cfg.getProperty("submenu");
+
+ if(oSubmenu) {
+
+ oEl.insertBefore(oImg, oSubmenu.element);
+
+ }
+ else {
+
+ oEl.appendChild(oImg);
+
+ }
+
+ Dom.addClass([oEl, oImg], "checked");
+
+ this._checkImage = oImg;
+
+ if(oConfig.getProperty("disabled")) {
+
+ oConfig.refireEvent("disabled");
+
+ }
+
+ if(oConfig.getProperty("selected")) {
+
+ oConfig.refireEvent("selected");
+
+ }
+
+ }
+ else {
+
+ oImg = this._checkImage;
+
+ Dom.removeClass([oEl, oImg], "checked");
+
+ if(oImg) {
+
+ oEl.removeChild(oImg);
+
+ }
+
+ this._checkImage = null;
+
+ }
+
+ };
+
+
+/**
+* Event handler for when the "selected" configuration property of
+* a MenuItem instance changes.
+* @param {String} p_sType The name of the event that was fired.
+* @param {Array} p_aArgs Collection of arguments sent when the
+* event was fired.
+* @param {YAHOO.widget.MenuItem} p_oItem The MenuItem instance
+* that fired the event.
+*/
+YAHOO.widget.MenuItem.prototype.configSelected =
+
+ function(p_sType, p_aArgs, p_oItem) {
+
+ YAHOO.widget.MenuItem.superclass.configSelected.call(
+ this, p_sType, p_aArgs, p_oItem
+ );
+
+ var oConfig = this.cfg;
+
+ if(!oConfig.getProperty("disabled") && oConfig.getProperty("checked")) {
+
+ var bSelected = p_aArgs[0];
+
+ var sSrc = this.imageRoot + (bSelected ?
+ this.SELECTED_CHECKED_IMAGE_PATH : this.CHECKED_IMAGE_PATH);
+
+ this._checkImage.src = document.images[sSrc].src;
+
+ }
+
+ };
+
+/**
+* Event handler for when the "disabled" configuration property of
+* a MenuItem instance changes.
+* @param {String} p_sType The name of the event that was fired.
+* @param {Array} p_aArgs Collection of arguments sent when the
+* event was fired.
+* @param {YAHOO.widget.MenuItem} p_oItem The MenuItem instance
+* that fired the event.
+*/
+YAHOO.widget.MenuItem.prototype.configDisabled =
+
+ function(p_sType, p_aArgs, p_oItem) {
+
+ YAHOO.widget.MenuItem.superclass.configDisabled.call(
+ this, p_sType, p_aArgs, p_oItem
+ );
+
+ if(this.cfg.getProperty("checked")) {
+
+ var bDisabled = p_aArgs[0];
+ var sAlt = this.CHECKED_IMAGE_ALT_TEXT;
+ var sSrc = this.CHECKED_IMAGE_PATH;
+ var oImg = this._checkImage;
+
+ if(bDisabled) {
+
+ sAlt = this.DISABLED_CHECKED_IMAGE_ALT_TEXT;
+ sSrc = this.DISABLED_CHECKED_IMAGE_PATH;
+
+ }
+
+ oImg.src = document.images[(this.imageRoot + sSrc)].src;
+ oImg.alt = sAlt;
+
+ }
+
+ };
+
+// Public methods
+
+/**
+* Initializes the class's configurable properties which can be changed using
+* the MenuModule's Config object (cfg).
+*/
+YAHOO.widget.MenuItem.prototype.initDefaultConfig = function() {
+
+ YAHOO.widget.MenuItem.superclass.initDefaultConfig.call(this);
+
+ // Add configuration properties
+
+ this.cfg.addProperty(
+ "checked",
+ {
+ value: false,
+ handler: this.configChecked,
+ validator: this.cfg.checkBoolean,
+ suppressEvent: true
+ }
+ );
+
+};
+
+/**
+* @class Creates a list of options which vary depending on the context in
+* which the menu is invoked.
+* @constructor
+* @extends YAHOO.widget.Menu
+* @base YAHOO.widget.Menu
+* @param {String or HTMLElement} p_oElement String id or HTMLElement
+* (either HTMLSelectElement or HTMLDivElement) of the source HTMLElement node.
+* @param {Object} p_oConfig Optional. The configuration object literal
+* containing the configuration for a ContextMenu instance. See
+* configuration class documentation for more details.
+*/
+YAHOO.widget.ContextMenu = function(p_oElement, p_oConfig) {
+
+ YAHOO.widget.ContextMenu.superclass.constructor.call(
+ this,
+ p_oElement,
+ p_oConfig
+ );
+
+};
+
+YAHOO.extend(YAHOO.widget.ContextMenu, YAHOO.widget.Menu);
+
+YAHOO.widget.ContextMenu.prototype._oTrigger = null;
+
+/**
+* The ContextMenu class's initialization method. This method is automatically
+* called by the constructor, and sets up all DOM references for pre-existing
+* markup, and creates required markup if it is not already present.
+* @param {String or HTMLElement} p_oElement String id or HTMLElement
+* (either HTMLSelectElement or HTMLDivElement) of the source HTMLElement node.
+* @param {Object} p_oConfig Optional. The configuration object literal
+* containing the configuration for a ContextMenu instance. See
+* configuration class documentation for more details.
+*/
+YAHOO.widget.ContextMenu.prototype.init = function(p_oElement, p_oConfig) {
+
+ if(!this.ITEM_TYPE) {
+
+ this.ITEM_TYPE = YAHOO.widget.ContextMenuItem;
+
+ }
+
+ // Call the init of the superclass (YAHOO.widget.Menu)
+
+ YAHOO.widget.ContextMenu.superclass.init.call(this, p_oElement);
+
+ this.beforeInitEvent.fire(YAHOO.widget.ContextMenu);
+
+ if(p_oConfig) {
+
+ this.cfg.applyConfig(p_oConfig, true);
+
+ }
+
+
+ this.initEvent.fire(YAHOO.widget.ContextMenu);
+
+};
+
+// Private event handlers
+
+/**
+* "mousedown" event handler for the document object.
+* @private
+* @param {Event} p_oEvent Event object passed back by the
+* event utility (YAHOO.util.Event).
+* @param {YAHOO.widget.ContextMenu} p_oMenu The ContextMenu instance
+* handling the event.
+*/
+YAHOO.widget.ContextMenu.prototype._onDocumentMouseDown =
+
+ function(p_oEvent, p_oMenu) {
+
+ var oTarget = YAHOO.util.Event.getTarget(p_oEvent);
+ var oTargetEl = this._oTargetElement;
+
+ if(
+ oTarget != oTargetEl ||
+ !YAHOO.util.Dom.isAncestor(oTargetEl, oTarget)
+ ) {
+
+ this.hide();
+
+ }
+
+ };
+
+/**
+* "click" event handler for the HTMLElement node that triggered the event.
+* Used to cancel default behaviors in Opera.
+* @private
+* @param {Event} p_oEvent Event object passed back by the
+* event utility (YAHOO.util.Event).
+* @param {YAHOO.widget.ContextMenu} p_oMenu The ContextMenu instance
+* handling the event.
+*/
+YAHOO.widget.ContextMenu.prototype._onTriggerClick =
+
+ function(p_oEvent, p_oMenu) {
+
+ if(p_oEvent.ctrlKey) {
+
+ YAHOO.util.Event.stopEvent(p_oEvent);
+
+ }
+
+ };
+
+/**
+* "contextmenu" event handler ("mousedown" for Opera) for the HTMLElement
+* node that triggered the event.
+* @private
+* @param {Event} p_oEvent Event object passed back by the
+* event utility (YAHOO.util.Event).
+* @param {YAHOO.widget.ContextMenu} p_oMenu The ContextMenu instance
+* handling the event.
+*/
+YAHOO.widget.ContextMenu.prototype._onTriggerContextMenu =
+
+ function(p_oEvent, p_oMenu) {
+
+ var Event = YAHOO.util.Event;
+ var oConfig = this.cfg;
+
+ if(p_oEvent.type == "mousedown") {
+
+ if(!p_oEvent.ctrlKey) {
+
+ return;
+
+ }
+
+ Event.stopEvent(p_oEvent);
+
+ }
+
+
+ this.contextEventTarget = Event.getTarget(p_oEvent);
+
+
+ // Position and display the context menu
+
+ var nX = Event.getPageX(p_oEvent);
+ var nY = Event.getPageY(p_oEvent);
+
+
+ oConfig.applyConfig( { x:nX, y:nY, visible:true } );
+ oConfig.fireQueue();
+
+
+ // Prevent the browser's default context menu from appearing
+
+ Event.preventDefault(p_oEvent);
+
+ };
+
+// Public properties
+
+/**
+* Returns the HTMLElement node that was the target of the "contextmenu"
+* DOM event.
+* @type HTMLElement
+*/
+YAHOO.widget.ContextMenu.prototype.contextEventTarget = null;
+
+// Public methods
+
+/**
+* Initializes the class's configurable properties which can be changed using
+* a ContextMenu instance's Config object (cfg).
+*/
+YAHOO.widget.ContextMenu.prototype.initDefaultConfig = function() {
+
+ YAHOO.widget.ContextMenu.superclass.initDefaultConfig.call(this);
+
+ // Add a configuration property
+
+ this.cfg.addProperty("trigger", { handler: this.configTrigger });
+
+};
+
+// Event handlers for configuration properties
+
+/**
+* Event handler for when the "trigger" configuration property of
+* a MenuItem instance.
+* @param {String} p_sType The name of the event that was fired.
+* @param {Array} p_aArgs Collection of arguments sent when the
+* event was fired.
+* @param {YAHOO.widget.ContextMenu} p_oMenu The ContextMenu that instance fired
+* the event.
+*/
+YAHOO.widget.ContextMenu.prototype.configTrigger =
+
+ function(p_sType, p_aArgs, p_oMenu) {
+
+ var Event = YAHOO.util.Event;
+ var oTrigger = p_aArgs[0];
+
+ if(oTrigger) {
+
+
+ /*
+ If there is a current "trigger" - remove the event handlers
+ from that element(s) before assigning new ones
+ */
+ if(this._oTrigger) {
+
+ Event.purgeElement(this._oTrigger);
+
+ }
+
+ this._oTrigger = oTrigger;
+
+ /*
+ Listen for the "mousedown" event in Opera b/c it does not
+ support the "contextmenu" event
+ */
+
+ var bOpera = (this.browser == "opera");
+
+ Event.addListener(
+ oTrigger,
+ (bOpera ? "mousedown" : "contextmenu"),
+ this._onTriggerContextMenu,
+ this,
+ true
+ );
+
+
+ /*
+ Assign a "click" event handler to the trigger element(s) for
+ Opera to prevent default browser behaviors.
+ */
+
+ if(bOpera) {
+
+ Event.addListener(
+ oTrigger,
+ "click",
+ this._onTriggerClick,
+ this,
+ true
+ );
+
+ }
+
+
+ // Assign a "mousedown" event handler to the document
+
+ Event.addListener(
+ document,
+ "mousedown",
+ this._onDocumentMouseDown,
+ this,
+ true
+ );
+
+ }
+
+ };
+
+/**
+* @class Creates an item for a context menu instance.
+* @constructor
+* @extends YAHOO.widget.MenuItem
+* @base YAHOO.widget.MenuItem
+* @param {String or HTMLElement} p_oObject String or HTMLElement
+* (either HTMLLIElement, HTMLOptGroupElement or HTMLOptionElement) of the
+* source HTMLElement node.
+* @param {Object} p_oConfig The configuration object literal containing
+* the configuration for a ContextMenuItem instance. See the configuration
+* class documentation for more details.
+*/
+YAHOO.widget.ContextMenuItem = function(p_oObject, p_oConfig) {
+
+ YAHOO.widget.ContextMenuItem.superclass.constructor.call(
+ this,
+ p_oObject,
+ p_oConfig
+ );
+
+};
+
+YAHOO.extend(YAHOO.widget.ContextMenuItem, YAHOO.widget.MenuItem);
+
+/**
+* The ContextMenuItem class's initialization method. This method is
+* automatically called by the constructor, and sets up all DOM references for
+* pre-existing markup, and creates required markup if it is not
+* already present.
+* @param {String or HTMLElement} p_oObject String or HTMLElement
+* (either HTMLLIElement, HTMLOptGroupElement or HTMLOptionElement) of the
+* source HTMLElement node.
+* @param {Object} p_oConfig The configuration object literal containing
+* the configuration for a ContextMenuItem instance. See the configuration
+* class documentation for more details.
+*/
+YAHOO.widget.ContextMenuItem.prototype.init =
+
+ function(p_oObject, p_oConfig) {
+
+ if(!this.SUBMENU_TYPE) {
+
+ this.SUBMENU_TYPE = YAHOO.widget.ContextMenu;
+
+ }
+
+ if(!this.SUBMENU_ITEM_TYPE) {
+
+ this.SUBMENU_ITEM_TYPE = YAHOO.widget.ContextMenuItem;
+
+ }
+
+
+ /*
+ Call the init of the superclass (YAHOO.widget.MenuItem)
+ Note: We don't pass the user config in here yet
+ because we only want it executed once, at the lowest
+ subclass level.
+ */
+
+ YAHOO.widget.ContextMenuItem.superclass.init.call(this, p_oObject);
+
+ var oConfig = this.cfg;
+
+ if(p_oConfig) {
+
+ oConfig.applyConfig(p_oConfig, true);
+
+ }
+
+ oConfig.fireQueue();
+
+ };
+
+/**
+* @class Horizontal collection of items, each of which can contain a submenu.
+* Extends YAHOO.widget.MenuModule to provide a set of default mouse and
+* key event behaviors.
+* @constructor
+* @extends YAHOO.widget.MenuModule
+* @base YAHOO.widget.MenuModule
+* @param {String or HTMLElement} p_oElement String id or HTMLElement
+* (either HTMLSelectElement or HTMLDivElement) of the source HTMLElement node.
+* @param {Object} p_oConfig Optional. The configuration object literal
+* containing the configuration for a MenuBar instance. See
+* configuration class documentation for more details.
+*/
+YAHOO.widget.MenuBar = function(p_oElement, p_oConfig) {
+
+ YAHOO.widget.MenuBar.superclass.constructor.call(
+ this,
+ p_oElement,
+ p_oConfig
+ );
+
+};
+
+YAHOO.extend(YAHOO.widget.MenuBar, YAHOO.widget.MenuModule);
+
+/**
+* The MenuBar class's initialization method. This method is automatically
+* called by the constructor, and sets up all DOM references for pre-existing
+* markup, and creates required markup if it is not already present.
+* @param {String or HTMLElement} p_oElement String id or HTMLElement
+* (either HTMLSelectElement or HTMLDivElement) of the source HTMLElement node.
+* @param {Object} p_oConfig Optional. The configuration object literal
+* containing the configuration for a MenuBar instance. See
+* configuration class documentation for more details.
+*/
+YAHOO.widget.MenuBar.prototype.init = function(p_oElement, p_oConfig) {
+
+ if(!this.ITEM_TYPE) {
+
+ this.ITEM_TYPE = YAHOO.widget.MenuBarItem;
+
+ }
+
+ // Call the init of the superclass (YAHOO.widget.MenuModule)
+
+ YAHOO.widget.MenuBar.superclass.init.call(this, p_oElement);
+
+ this.beforeInitEvent.fire(YAHOO.widget.MenuBar);
+
+ var oConfig = this.cfg;
+
+ /*
+ Set the default value for the "position" configuration property
+ to "static"
+ */
+ if(!p_oConfig || (p_oConfig && !p_oConfig.position)) {
+
+ oConfig.queueProperty("position", "static");
+
+ }
+
+ /*
+ Set the default value for the "submenualignment" configuration property
+ to "tl" and "bl"
+ */
+ if(!p_oConfig || (p_oConfig && !p_oConfig.submenualignment)) {
+
+ oConfig.queueProperty("submenualignment", ["tl","bl"]);
+
+ }
+
+ if(p_oConfig) {
+
+ oConfig.applyConfig(p_oConfig, true);
+
+ }
+
+ this.initEvent.fire(YAHOO.widget.MenuBar);
+
+};
+
+// Constants
+
+/**
+* Constant representing the CSS class(es) to be applied to the root
+* HTMLDivElement of the MenuBar instance.
+* @final
+* @type String
+*/
+YAHOO.widget.MenuBar.prototype.CSS_CLASS_NAME = "yuimenubar";
+
+/**
+* @class The MenuBarItem class allows you to create and modify an item for a
+* MenuBar instance. MenuBarItem extends YAHOO.widget.MenuModuleItem to provide
+* a set of default mouse and key event behaviors.
+* @constructor
+* @extends YAHOO.widget.MenuModuleItem
+* @base YAHOO.widget.MenuModuleItem
+* @param {String or HTMLElement} p_oObject String or HTMLElement
+* (either HTMLLIElement, HTMLOptGroupElement or HTMLOptionElement) of the
+* source HTMLElement node.
+* @param {Object} p_oConfig The configuration object literal containing
+* the configuration for a MenuBarItem instance. See the configuration
+* class documentation for more details.
+*/
+YAHOO.widget.MenuBarItem = function(p_oObject, p_oConfig) {
+
+ YAHOO.widget.MenuBarItem.superclass.constructor.call(
+ this,
+ p_oObject,
+ p_oConfig
+ );
+
+};
+
+YAHOO.extend(YAHOO.widget.MenuBarItem, YAHOO.widget.MenuModuleItem);
+
+/**
+* The MenuBarItem class's initialization method. This method is automatically
+* called by the constructor, and sets up all DOM references for
+* pre-existing markup, and creates required markup if it is not
+* already present.
+* @param {String or HTMLElement} p_oObject String or HTMLElement
+* (either HTMLLIElement, HTMLOptGroupElement or HTMLOptionElement) of the
+* source HTMLElement node.
+* @param {Object} p_oConfig The configuration object literal containing
+* the configuration for a MenuBarItem instance. See the configuration
+* class documentation for more details.
+*/
+YAHOO.widget.MenuBarItem.prototype.init = function(p_oObject, p_oConfig) {
+
+ if(!this.SUBMENU_TYPE) {
+
+ this.SUBMENU_TYPE = YAHOO.widget.Menu;
+
+ }
+
+ if(!this.SUBMENU_ITEM_TYPE) {
+
+ this.SUBMENU_ITEM_TYPE = YAHOO.widget.MenuItem;
+
+ }
+
+ /*
+ Call the init of the superclass (YAHOO.widget.MenuModuleItem)
+ Note: We don't pass the user config in here yet
+ because we only want it executed once, at the lowest
+ subclass level.
+ */
+
+ YAHOO.widget.MenuBarItem.superclass.init.call(this, p_oObject);
+
+ // Add event handlers to each "MenuBarItem" instance
+
+ this.keyDownEvent.subscribe(this._onKeyDown, this, true);
+
+ var oConfig = this.cfg;
+
+ if(p_oConfig) {
+
+ oConfig.applyConfig(p_oConfig, true);
+
+ }
+
+ oConfig.fireQueue();
+
+};
+
+// Constants
+
+/**
+* Constant representing the CSS class(es) to be applied to the root
+* HTMLLIElement of the MenuBarItem.
+* @final
+* @type String
+*/
+YAHOO.widget.MenuBarItem.prototype.CSS_CLASS_NAME = "yuimenubaritem";
+
+/**
+* Constant representing the path to the image to be used for the submenu
+* arrow indicator.
+* @final
+* @type String
+*/
+YAHOO.widget.MenuBarItem.prototype.SUBMENU_INDICATOR_IMAGE_PATH =
+ "nt/ic/ut/alt1/menuarodwn8_nrm_1.gif";
+
+/**
+* Constant representing the path to the image to be used for the submenu
+* arrow indicator when a MenuBarItem instance is selected.
+* @final
+* @type String
+*/
+YAHOO.widget.MenuBarItem.prototype.SELECTED_SUBMENU_INDICATOR_IMAGE_PATH =
+ "nt/ic/ut/alt1/menuarodwn8_hov_1.gif";
+
+/**
+* Constant representing the path to the image to be used for the submenu
+* arrow indicator when a MenuBarItem instance is disabled.
+* @final
+* @type String
+*/
+YAHOO.widget.MenuBarItem.prototype.DISABLED_SUBMENU_INDICATOR_IMAGE_PATH =
+ "nt/ic/ut/alt1/menuarodwn8_dim_1.gif";
+
+// Private event handlers
+
+/**
+* "keydown" Custom Event handler for a MenuBarItem instance.
+* @private
+* @param {String} p_sType The name of the event that was fired.
+* @param {Array} p_aArgs Collection of arguments sent when the event
+* was fired.
+* @param {YAHOO.widget.MenuModule} p_oMenuModule The MenuModule instance that
+* fired the event.
+*/
+YAHOO.widget.MenuBarItem.prototype._onKeyDown =
+
+ function(p_sType, p_aArgs, p_oMenuItem) {
+
+ var Event = YAHOO.util.Event;
+ var oDOMEvent = p_aArgs[0];
+ var oConfig = this.cfg;
+ var oParent = this.parent;
+
+ switch(oDOMEvent.keyCode) {
+
+ case 37: // Left arrow
+ case 39: // Right arrow
+
+ if(
+ this == oParent.activeItem &&
+ !oConfig.getProperty("selected")
+ ) {
+
+ oConfig.setProperty("selected", true);
+
+ }
+ else {
+
+ var oNextItem = (oDOMEvent.keyCode == 37) ?
+ this.getPreviousEnabledSibling() :
+ this.getNextEnabledSibling();
+
+ if(oNextItem) {
+
+ oParent.clearActiveItem();
+
+ oNextItem.cfg.setProperty("selected", true);
+
+ oNextItem.focus();
+
+ }
+
+ }
+
+ Event.preventDefault(oDOMEvent);
+
+ break;
+
+ case 40: // Down arrow
+
+ oParent.clearActiveItem();
+
+ oConfig.setProperty("selected", true);
+
+ this.focus();
+
+ var oSubmenu = oConfig.getProperty("submenu");
+
+ if(oSubmenu) {
+
+ oSubmenu.show();
+ oSubmenu.setInitialSelection();
+
+ }
+
+ Event.preventDefault(oDOMEvent);
+
+ break;
+
+ }
+
+ };
Added: branches/tomek/portal-dnd/dndRenderer.war/js/portal/PortalDD.js
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/portal/PortalDD.js 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/portal/PortalDD.js 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,201 @@
+log = new YAHOO.widget.LogWriter("portalDnD");
+
+var borderBefore = "";
+var borderTopBefore = "";
+var ajaxEnabled = true;
+
+var borderSet = false;
+
+var ajaxURI = "/dndRenderer/ajax";
+
+var host = "";
+
+function setAjaxEnabled(enabled) {
+ ajaxEnabled = enabled;
+}
+
+function getBorder(id) {
+ YAHOO.util.Dom.setStyle(id, "border-top", borderTopBefore);
+ YAHOO.util.Dom.setStyle(id, "border", borderBefore);
+ borderBefore = "";
+ borderTopBefore = "";
+ borderSet = false;
+}
+
+function setBorder(id) {
+ if (!borderSet) {
+ borderTopBefore = YAHOO.util.Dom.getStyle(id, "border-top");
+ borderBefore = YAHOO.util.Dom.getStyle(id, "border");
+ borderSet = true;
+ }
+
+ YAHOO.util.Dom.setStyle(id, "border-top", "2px solid red");
+}
+
+function persitNewPosition(positionNo, windowId, oldRegionId, newRegionId) {
+ postData = "action=PERSIST&positionNo="+encodeURI(positionNo)+"&windowId="+encodeURI(windowId)+"&oldRegionId="+encodeURI(oldRegionId)+"&newRegionId="+encodeURI(newRegionId);
+
+ log.log(postData);
+ invokeAjax(postData);
+}
+
+function invokeAjax(postData) {
+ if (ajaxEnabled) {
+ var handleSuccess = function(o){
+
+ if(o.responseText !== undefined){
+ log.log("Transaction id: " + o.tId);
+ log.log("HTTP status: " + o.status);
+ log.log("Status code message: " + o.statusText);
+ log.log("<li>HTTP headers: <ul>" + o.getAllResponseHeaders + "</ul></li>");
+ log.log("Servlet response: " + o.responseText);
+ log.log("Argument object: " + o.argument);
+ }
+ }
+
+ var handleFailure = function(o) {
+ log.log("Failure: " + o);
+ }
+
+ var callback =
+ {
+ success:handleSuccess,
+ failure: handleFailure,
+ argument: []
+ };
+
+ var request = YAHOO.util.Connect.asyncRequest('POST', host+ajaxURI, callback, postData);
+ }
+}
+
+YAHOO.util.PortalDD = function(id, sGroup, config) {
+ if (id) {
+ this.init(id, sGroup, config);
+ this.initFrame();
+ }
+};
+
+YAHOO.extend(YAHOO.util.PortalDD, YAHOO.util.DDProxy);
+
+YAHOO.util.PortalDD.prototype.onDragOver = function(e, id) {
+ YAHOO.util.PortalDD.superclass.onDragOver.call(this, e, id);
+
+ // draw a border around dropto portlet
+ setBorder(id);
+}
+
+YAHOO.util.PortalDD.prototype.onDragOut = function(e, id) {
+ YAHOO.util.PortalDD.superclass.onDragOut.call(this, e, id);
+
+ // remove the border around dropto portlet
+ getBorder(id);
+}
+
+YAHOO.util.PortalDD.prototype.onDragDrop = function(e, id) {
+
+ // remove the border around dropto portlet
+ getBorder(id);
+
+ var el = this.getEl();
+ var droped = document.getElementById(id);
+
+ var thisParent = el.parentNode;
+ var dropedParent = droped.parentNode;
+
+ // show region droper if needed
+ if (thisParent.childNodes.length == 2) {
+ var regToDrop = document.getElementById(thisParent.dropToRegion);
+
+ YAHOO.util.Dom.setStyle(regToDrop, "display", "block");
+ YAHOO.util.Dom.setStyle(regToDrop, "visibility", "");
+ }
+
+ thisParent.removeChild(el);
+ dropedParent.appendChild(el);
+
+ // hide region droper if needed
+ if (dropedParent.childNodes.length == 2) {
+ var regToDrop = document.getElementById(dropedParent.dropToRegion);
+
+ YAHOO.util.Dom.setStyle(regToDrop, "display", "none");
+ YAHOO.util.Dom.setStyle(regToDrop, "visibility", "hidden");
+ }
+
+ log.log("AFTER Parent: " + el.parentNode + "(" + el.parentNode.id +")"+" droped: " + droped.parentNode + "(" + droped.parentNode.id +")");
+
+ log.log( "position: " + YAHOO.util.Dom.getStyle(el, "position"));
+ YAHOO.util.Dom.setStyle(el, "position", "static");
+
+ var nodeList = dropedParent.childNodes;
+
+ var adding = false;YAHOO.util.PortalDD
+
+ // move down all the nodes under the portlet (including dropto portlet)
+ var i = 0;
+ while ((nodeList.item(i) != el) && (i < nodeList.length)) {
+ var nextNode = nodeList.item(i);
+ if (!adding && nextNode == droped) {
+ adding = true;
+ }
+
+ if (adding) {
+ dropedParent.appendChild(nextNode);
+ }
+ else {
+ i++;
+ }
+ }
+
+ if (nodeList.item(0).id.indexOf("regionDrop") == 0) {
+ i--;
+ }
+
+ log.log("new position: "+i+ " " + this.windowId);
+ persitNewPosition(i, this.windowId, thisParent.regionId, dropedParent.regionId);
+};
+
+YAHOO.util.PortalDD.prototype.endDrag = function(e) {
+ // PortalDD changes
+ // Don't move the portlet - it'll be placed by the browser
+ // Just remove the proxy frame
+
+ var DOM = YAHOO.util.Dom;
+ this.logger.log(this.id + " endDrag");
+ //var lel = this.getEl();
+ var del = this.getDragEl();
+
+ // Show the drag frame briefly so we can get its position
+ // del.style.visibility = "";
+ DOM.setStyle(del, "visibility", "");
+
+ // Hide the linked element before the move to get around a Safari
+ // rendering bug.
+ //lel.style.visibility = "hidden";
+ //DOM.setStyle(lel, "visibility", "hidden");
+ //YAHOO.util.DDM.moveToEl(lel, del);
+ //del.style.visibility = "hidden";
+ DOM.setStyle(del, "visibility", "hidden");
+ //lel.style.visibility = "";
+ //DOM.setStyle(lel, "visibility", "");
+};
+
+// cleans up regionDD renderer from some crap wrongly intepreted by a browser
+function cleanUpDocument(id) {
+ var region = document.getElementById(id);
+ var nodeList = region.childNodes;
+
+ // move down all the nodes under the portlet (including dropto portlet)
+ var i = 0;
+ while (i < nodeList.length) {
+ var nextNode = nodeList.item(i);
+
+ //log.log(nextNode);
+ if (nextNode instanceof Text) {
+ //log.log("next one: "+id+" "+ i);
+ region.removeChild(nextNode);
+ }
+ else {
+ i++;
+ }
+ }
+}
\ No newline at end of file
Added: branches/tomek/portal-dnd/dndRenderer.war/js/reset/README
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/reset/README 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/reset/README 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,9 @@
+CSS Reset Release Notes
+
+*** version 0.11.0 ***
+
+* No changes.
+
+*** version 0.10.0 ***
+
+* Initial release
\ No newline at end of file
Added: branches/tomek/portal-dnd/dndRenderer.war/js/reset/reset-min.css
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/reset/reset-min.css 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/reset/reset-min.css 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,7 @@
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 0.11.0
+*/
+body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,p,blockquote,th,td{margin:0;padding:0;}table{border-collapse:collapse;border-spacing:0;}fieldset,img{border:0;}address,caption,cite,code,dfn,em,strong,th,var{font-style:normal;font-weight:normal;}ol,ul {list-style:none;}caption,th {text-align:left;}h1,h2,h3,h4,h5,h6{font-size:100%;}q:before,q:after{content:'';}
\ No newline at end of file
Added: branches/tomek/portal-dnd/dndRenderer.war/js/reset/reset.css
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/reset/reset.css 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/reset/reset.css 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,14 @@
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 0.11.0
+*/
+body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,p,blockquote,th,td{margin:0;padding:0;}
+table{border-collapse:collapse;border-spacing:0;}
+fieldset,img{border:0;}
+address,caption,cite,code,dfn,em,strong,th,var{font-style:normal;font-weight:normal;}
+ol,ul {list-style:none;}
+caption,th {text-align:left;}
+h1,h2,h3,h4,h5,h6{font-size:100%;}
+q:before,q:after{content:'';}
\ No newline at end of file
Added: branches/tomek/portal-dnd/dndRenderer.war/js/slider/README
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/slider/README 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/slider/README 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,29 @@
+Slider - Release Notes
+
+0.11.0
+
+ * When the thumb is clicked and dragged, the click position delta is properly
+ applied.
+
+ * The slider background can be disabled by setting backgroundEnabled to false.
+
+ * Added SliderThumb->clearTicks
+
+ * Incorporated updated drag and drop performance improvements
+
+0.10.0
+
+ * Drag and drop's autoscroll feature is now turned off by default
+ in the slider.
+
+ * The slider no longer sets its initial value upon initialization
+
+ * RGB slider example fixed for IE7.
+
+ * Updated to work with the onAvailable feature in Drag and Drop.
+
+ * Updated the basic slider example page to make the control more
+ accessible to non-FF1.5 browsers.
+
+ * Split the examples into separate pages
+
Added: branches/tomek/portal-dnd/dndRenderer.war/js/slider/slider-debug.js
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/slider/slider-debug.js 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/slider/slider-debug.js 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,945 @@
+
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 0.11.0
+*/
+
+/**
+ * A DragDrop implementation that can be used as a background for a
+ * slider. It takes a reference to the thumb instance
+ * so it can delegate some of the events to it. The goal is to make the
+ * thumb jump to the location on the background when the background is
+ * clicked.
+ *
+ * @extends YAHOO.util.DragDrop
+ * @constructor
+ * @param {String} id The id of the element linked to this instance
+ * @param {String} sGroup The group of related DragDrop items
+ * @param {String} sType The type of slider (horiz, vert, region)
+ */
+YAHOO.widget.Slider = function(sElementId, sGroup, oThumb, sType) {
+ if (sElementId) {
+
+ /**
+ * The type of the slider (horiz, vert, region)
+ * @type string
+ */
+ this.type = sType;
+
+ this.init(sElementId, sGroup, true);
+
+ this.logger = new YAHOO.widget.LogWriter(this.toString());
+
+ var self = this;
+
+ /**
+ * a YAHOO.widget.SliderThumb instance that we will use to
+ * reposition the thumb when the background is clicked
+ *
+ * @type Slider
+ */
+ this.thumb = oThumb;
+
+ // add handler for the handle onchange event
+ oThumb.onChange = function() {
+ self.onThumbChange();
+ };
+
+
+ /**
+ * Overrides the isTarget property in YAHOO.util.DragDrop
+ * @private
+ */
+ this.isTarget = false;
+
+ /**
+ * Flag that determines if the thumb will animate when moved
+ * @type boolean
+ */
+ this.animate = YAHOO.widget.Slider.ANIM_AVAIL;
+
+ /**
+ * Set to false to disable a background click thumb move
+ */
+ this.backgroundEnabled = true;
+
+ /**
+ * Adjustment factor for tick animation, the more ticks, the
+ * faster the animation (by default)
+ *
+ * @type int
+ */
+ this.tickPause = 40;
+ if (oThumb._isHoriz && oThumb.xTicks && oThumb.xTicks.length) {
+ this.tickPause = Math.round(360 / oThumb.xTicks.length);
+ } else if (oThumb.yTicks && oThumb.yTicks.length) {
+ this.tickPause = Math.round(360 / oThumb.yTicks.length);
+ }
+
+ this.logger.log("tickPause: " + this.tickPause);
+
+ // delegate thumb methods
+ oThumb.onMouseDown = function () { return self.focus(); };
+ //oThumb.b4MouseDown = function () { return self.b4MouseDown(); };
+ // oThumb.lock = function() { self.lock(); };
+ // oThumb.unlock = function() { self.unlock(); };
+ oThumb.onMouseUp = function() { self.thumbMouseUp(); };
+ oThumb.onDrag = function() { self.fireEvents(); };
+ oThumb.onAvailable = function() { return self.setStartSliderState(); };
+ }
+};
+
+//YAHOO.widget.Slider.prototype = new YAHOO.util.DragDrop();
+YAHOO.extend(YAHOO.widget.Slider, YAHOO.util.DragDrop);
+
+// YAHOO.widget.Slider.prototype.onAvailable = function() {
+ // this.logger.log("bg avail");
+// };
+
+/**
+ * Factory method for creating a horizontal slider
+ *
+ * @param {String} sBGElId the id of the slider's background element
+ * @param {String} sHandleElId the id of the thumb element
+ * @param {int} iLeft the number of pixels the element can move left
+ * @param {int} iRight the number of pixels the element can move right
+ * @param {int} iTickSize optional parameter for specifying that the element
+ * should move a certain number pixels at a time.
+ * @return {Slider} a horizontal slider control
+ */
+YAHOO.widget.Slider.getHorizSlider =
+ function (sBGElId, sHandleElId, iLeft, iRight, iTickSize) {
+ return new YAHOO.widget.Slider(sBGElId, sBGElId,
+ new YAHOO.widget.SliderThumb(sHandleElId, sBGElId,
+ iLeft, iRight, 0, 0, iTickSize), "horiz");
+};
+
+/**
+ * Factory method for creating a vertical slider
+ *
+ * @param {String} sBGElId the id of the slider's background element
+ * @param {String} sHandleElId the id of the thumb element
+ * @param {int} iUp the number of pixels the element can move up
+ * @param {int} iDown the number of pixels the element can move down
+ * @param {int} iTickSize optional parameter for specifying that the element
+ * should move a certain number pixels at a time.
+ * @return {Slider} a vertical slider control
+ */
+YAHOO.widget.Slider.getVertSlider =
+ function (sBGElId, sHandleElId, iUp, iDown, iTickSize) {
+ return new YAHOO.widget.Slider(sBGElId, sBGElId,
+ new YAHOO.widget.SliderThumb(sHandleElId, sBGElId, 0, 0,
+ iUp, iDown, iTickSize), "vert");
+};
+
+/**
+ * Factory method for creating a slider region like the one in the color
+ * picker example
+ *
+ * @param {String} sBGElId the id of the slider's background element
+ * @param {String} sHandleElId the id of the thumb element
+ * @param {int} iLeft the number of pixels the element can move left
+ * @param {int} iRight the number of pixels the element can move right
+ * @param {int} iUp the number of pixels the element can move up
+ * @param {int} iDown the number of pixels the element can move down
+ * @param {int} iTickSize optional parameter for specifying that the element
+ * should move a certain number pixels at a time.
+ * @return {Slider} a slider region control
+ */
+YAHOO.widget.Slider.getSliderRegion =
+ function (sBGElId, sHandleElId, iLeft, iRight, iUp, iDown, iTickSize) {
+ return new YAHOO.widget.Slider(sBGElId, sBGElId,
+ new YAHOO.widget.SliderThumb(sHandleElId, sBGElId, iLeft, iRight,
+ iUp, iDown, iTickSize), "region");
+};
+
+/**
+ * By default, animation is available if the animation library is detected.
+ * @type boolean
+ */
+YAHOO.widget.Slider.ANIM_AVAIL = true;
+
+YAHOO.widget.Slider.prototype.setStartSliderState = function() {
+
+ this.logger.log("Fixing state");
+
+ this.setThumbCenterPoint();
+
+ /**
+ * The basline position of the background element, used
+ * to determine if the background has moved since the last
+ * operation.
+ * @type int[]
+ */
+ this.baselinePos = YAHOO.util.Dom.getXY(this.getEl());
+
+ this.thumb.startOffset = this.thumb.getOffsetFromParent(this.baselinePos);
+
+ if (this.thumb._isRegion) {
+ if (this.deferredSetRegionValue) {
+ this.setRegionValue.apply(this, this.deferredSetRegionValue, true);
+ } else {
+ this.setRegionValue(0, 0, true);
+ }
+ } else {
+ if (this.deferredSetValue) {
+ this.setValue.apply(this, this.deferredSetValue, true);
+ } else {
+ this.setValue(0, true, true);
+ }
+ }
+};
+
+YAHOO.widget.Slider.prototype.setThumbCenterPoint = function() {
+
+ var el = this.thumb.getEl();
+
+ if (el) {
+ /**
+ * the center of the slider element is stored so we can position
+ * place it in the correct position when the background is clicked
+ *
+ * @type Coordinate
+ */
+ this.thumbCenterPoint = {
+ x: parseInt(el.offsetWidth/2, 10),
+ y: parseInt(el.offsetHeight/2, 10)
+ };
+ }
+
+};
+
+/**
+ * Lock the slider, overrides YAHOO.util.DragDrop
+ */
+YAHOO.widget.Slider.prototype.lock = function() {
+ this.logger.log("locking");
+ this.thumb.lock();
+ this.locked = true;
+};
+
+/**
+ * Unlock the slider, overrides YAHOO.util.DragDrop
+ */
+YAHOO.widget.Slider.prototype.unlock = function() {
+ this.logger.log("unlocking");
+ this.thumb.unlock();
+ this.locked = false;
+};
+
+/**
+ * handles mouseup event on the slider background
+ *
+ * @private
+ */
+YAHOO.widget.Slider.prototype.thumbMouseUp = function() {
+ this.logger.log("bg mouseup");
+ if (!this.isLocked() && !this.moveComplete) {
+ this.endMove();
+ }
+
+};
+
+/**
+ * Returns a reference to this slider's thumb
+ */
+YAHOO.widget.Slider.prototype.getThumb = function() {
+ return this.thumb;
+};
+
+/**
+ * Try to focus the element when clicked so we can add
+ * accessibility features
+ *
+ * @private
+ */
+YAHOO.widget.Slider.prototype.focus = function() {
+ this.logger.log("focus");
+
+ // Focus the background element if possible
+ var el = this.getEl();
+
+ if (el.focus) {
+ el.focus();
+ }
+
+ this.verifyOffset();
+
+ if (this.isLocked()) {
+ return false;
+ } else {
+ this.onSlideStart();
+ return true;
+ }
+};
+
+/**
+ * Event that fires when the value of the slider has changed
+ *
+ * @param {int} offsetFromStart the number of pixels the thumb has moved
+ * from its start position. Normal horizontal and vertical sliders will only
+ * have the firstOffset. Regions will have both, the first is the horizontal
+ * offset, the second the vertical.
+ */
+YAHOO.widget.Slider.prototype.onChange = function (firstOffset, secondOffset) {
+ /* override me */
+ this.logger.log("onChange: " + firstOffset + ", " + secondOffset);
+};
+
+/**
+ * Event that fires when the at the beginning of the slider thumb move
+ */
+YAHOO.widget.Slider.prototype.onSlideStart = function () {
+ /* override me */
+ this.logger.log("onSlideStart");
+};
+
+/**
+ * Event that fires at the end of a slider thumb move
+ */
+YAHOO.widget.Slider.prototype.onSlideEnd = function () {
+ /* override me */
+ this.logger.log("onSlideEnd");
+};
+
+/**
+ * Returns the slider's thumb offset from the start position
+ *
+ * @return {int} the current value
+ */
+YAHOO.widget.Slider.prototype.getValue = function () {
+ return this.thumb.getValue();
+};
+
+/**
+ * Returns the slider's thumb X offset from the start position
+ *
+ * @return {int} the current horizontal offset
+ */
+YAHOO.widget.Slider.prototype.getXValue = function () {
+ return this.thumb.getXValue();
+};
+
+/**
+ * Returns the slider's thumb Y offset from the start position
+ *
+ * @return {int} the current vertical offset
+ */
+YAHOO.widget.Slider.prototype.getYValue = function () {
+ return this.thumb.getYValue();
+};
+
+/**
+ * Internal handler for the slider thumb's onChange event
+ * @private
+ */
+YAHOO.widget.Slider.prototype.onThumbChange = function () {
+ var t = this.thumb;
+ if (t._isRegion) {
+ t.onChange(t.getXValue(), t.getYValue());
+ } else {
+ t.onChange(t.getValue());
+ }
+
+};
+
+/**
+ * Provides a way to set the value of the slider in code.
+ *
+ * @param {int} newOffset the number of pixels the thumb should be
+ * positioned away from the initial start point
+ * @param {boolean} skipAnim set to true to disable the animation
+ * for this move action (but not others).
+ * @param {boolean} force ignore the locked setting and set value anyway
+ * @return {boolean} true if the move was performed, false if it failed
+ */
+YAHOO.widget.Slider.prototype.setValue = function(newOffset, skipAnim, force) {
+ this.logger.log("setValue " + newOffset);
+
+ if (!this.thumb.available) {
+ this.logger.log("defer setValue until after onAvailble");
+ this.deferredSetValue = arguments;
+ return false;
+ }
+
+ if (this.isLocked() && !force) {
+ this.logger.log("Can't set the value, the control is locked");
+ return false;
+ }
+
+ if ( isNaN(newOffset) ) {
+ this.logger.log("setValue, Illegal argument: " + newOffset);
+ return false;
+ }
+
+ var t = this.thumb;
+ var newX, newY;
+ this.verifyOffset();
+ if (t._isRegion) {
+ return false;
+ } else if (t._isHoriz) {
+ this.onSlideStart();
+ newX = t.initPageX + newOffset + this.thumbCenterPoint.x;
+ this.moveThumb(newX, t.initPageY, skipAnim);
+ } else {
+ this.onSlideStart();
+ newY = t.initPageY + newOffset + this.thumbCenterPoint.y;
+ this.moveThumb(t.initPageX, newY, skipAnim);
+ }
+
+ return true;
+};
+
+/**
+ * Provides a way to set the value of the region slider in code.
+ *
+ * @param {int} newOffset the number of pixels the thumb should be
+ * positioned away from the initial start point
+ * @param {int} newOffset2 the number of pixels the thumb should be
+ * positioned away from the initial start point (y axis for region)
+ * @param {boolean} skipAnim set to true to disable the animation
+ * for this move action (but not others).
+ * @param {boolean} force ignore the locked setting and set value anyway
+ * @return {boolean} true if the move was performed, false if it failed
+ */
+YAHOO.widget.Slider.prototype.setRegionValue = function(newOffset, newOffset2, skipAnim) {
+
+ if (!this.thumb.available) {
+ this.logger.log("defer setRegionValue until after onAvailble");
+ this.deferredSetRegionValue = arguments;
+ return false;
+ }
+
+ if (this.isLocked() && !force) {
+ this.logger.log("Can't set the value, the control is locked");
+ return false;
+ }
+
+ if ( isNaN(newOffset) ) {
+ this.logger.log("setRegionValue, Illegal argument: " + newOffset);
+ return false;
+ }
+
+ var t = this.thumb;
+ if (t._isRegion) {
+ this.onSlideStart();
+ var newX = t.initPageX + newOffset + this.thumbCenterPoint.x;
+ var newY = t.initPageY + newOffset2 + this.thumbCenterPoint.y;
+ this.moveThumb(newX, newY, skipAnim);
+ return true;
+ }
+
+ return false;
+
+};
+
+/**
+ * Checks the background position element position. If it has moved from the
+ * baseline position, the constraints for the thumb are reset
+ * @return {boolean} True if the offset is the same as the baseline.
+ */
+YAHOO.widget.Slider.prototype.verifyOffset = function() {
+
+ var newPos = YAHOO.util.Dom.getXY(this.getEl());
+ this.logger.log("newPos: " + newPos);
+
+ if (newPos[0] != this.baselinePos[0] || newPos[1] != this.baselinePos[1]) {
+ this.logger.log("background moved, resetting constraints");
+ this.thumb.resetConstraints();
+ this.baselinePos = newPos;
+ return false;
+ }
+
+ return true;
+};
+
+/**
+ * Move the associated slider moved to a timeout to try to get around the
+ * mousedown stealing moz does when I move the slider element between the
+ * cursor and the background during the mouseup event
+ *
+ * @param {int} x the X coordinate of the click
+ * @param {int} y the Y coordinate of the click
+ * @param {boolean} skipAnim don't animate if the move happend onDrag
+ * @private
+ */
+YAHOO.widget.Slider.prototype.moveThumb = function(x, y, skipAnim) {
+
+ this.logger.log("move thumb", "warn");
+
+ var t = this.thumb;
+ var self = this;
+
+ if (!t.available) {
+ this.logger.log("thumb is not available yet, aborting move");
+ return;
+ }
+
+ this.logger.log("move thumb, x: " + x + ", y: " + y);
+
+ // this.verifyOffset();
+
+ t.setDelta(this.thumbCenterPoint.x, this.thumbCenterPoint.y);
+
+ var _p = t.getTargetCoord(x, y);
+ var p = [_p.x, _p.y];
+
+
+ if (this.animate && YAHOO.widget.Slider.ANIM_AVAIL && t._graduated && !skipAnim) {
+ this.logger.log("graduated");
+ // this.thumb._animating = true;
+ this.lock();
+
+ setTimeout( function() { self.moveOneTick(p); }, this.tickPause );
+
+ } else if (this.animate && YAHOO.widget.Slider.ANIM_AVAIL && !skipAnim) {
+ this.logger.log("animating to " + p);
+
+ // this.thumb._animating = true;
+ this.lock();
+
+ var oAnim = new YAHOO.util.Motion(
+ t.id, { points: { to: p } }, 0.4, YAHOO.util.Easing.easeOut );
+
+ oAnim.onComplete.subscribe( function() { self.endMove(); } );
+ oAnim.animate();
+ } else {
+ t.setDragElPos(x, y);
+ // this.fireEvents();
+ this.endMove();
+ }
+};
+
+/**
+ * Move the slider one tick mark towards its final coordinate. Used
+ * for the animation when tick marks are defined
+ *
+ * @param {int[]} the destination coordinate
+ * @private
+ */
+YAHOO.widget.Slider.prototype.moveOneTick = function(finalCoord) {
+
+ var t = this.thumb;
+ var curCoord = YAHOO.util.Dom.getXY(t.getEl());
+ var tmp;
+
+ // var thresh = Math.min(t.tickSize + (Math.floor(t.tickSize/2)), 10);
+ // var thresh = 10;
+ // var thresh = t.tickSize + (Math.floor(t.tickSize/2));
+
+ var nextCoord = null;
+
+ if (t._isRegion) {
+ nextCoord = this._getNextX(curCoord, finalCoord);
+ var tmpX = (nextCoord) ? nextCoord[0] : curCoord[0];
+ nextCoord = this._getNextY([tmpX, curCoord[1]], finalCoord);
+
+ } else if (t._isHoriz) {
+ nextCoord = this._getNextX(curCoord, finalCoord);
+ } else {
+ nextCoord = this._getNextY(curCoord, finalCoord);
+ }
+
+ this.logger.log("moveOneTick: " +
+ " finalCoord: " + finalCoord +
+ " curCoord: " + curCoord +
+ " nextCoord: " + nextCoord);
+
+ if (nextCoord) {
+
+ // move to the next coord
+ // YAHOO.util.Dom.setXY(t.getEl(), nextCoord);
+
+ // var el = t.getEl();
+ // YAHOO.util.Dom.setStyle(el, "left", (nextCoord[0] + this.thumb.deltaSetXY[0]) + "px");
+ // YAHOO.util.Dom.setStyle(el, "top", (nextCoord[1] + this.thumb.deltaSetXY[1]) + "px");
+
+ this.thumb.alignElWithMouse(t.getEl(), nextCoord[0], nextCoord[1]);
+
+ // check if we are in the final position, if not make a recursive call
+ if (!(nextCoord[0] == finalCoord[0] && nextCoord[1] == finalCoord[1])) {
+ var self = this;
+ setTimeout(function() { self.moveOneTick(finalCoord); },
+ this.tickPause);
+ } else {
+ this.endMove();
+ }
+ } else {
+ this.endMove();
+ }
+
+ //this.tickPause = Math.round(this.tickPause/2);
+};
+
+/**
+ * Returns the next X tick value based on the current coord and the target coord.
+ * @private/
+ */
+YAHOO.widget.Slider.prototype._getNextX = function(curCoord, finalCoord) {
+ this.logger.log("getNextX: " + curCoord + ", " + finalCoord);
+ var t = this.thumb;
+ var thresh;
+ var tmp = [];
+ var nextCoord = null;
+ if (curCoord[0] > finalCoord[0]) {
+ thresh = t.tickSize - this.thumbCenterPoint.x;
+ tmp = t.getTargetCoord( curCoord[0] - thresh, curCoord[1] );
+ nextCoord = [tmp.x, tmp.y];
+ } else if (curCoord[0] < finalCoord[0]) {
+ thresh = t.tickSize + this.thumbCenterPoint.x;
+ tmp = t.getTargetCoord( curCoord[0] + thresh, curCoord[1] );
+ nextCoord = [tmp.x, tmp.y];
+ } else {
+ // equal, do nothing
+ }
+
+ return nextCoord;
+};
+
+/**
+ * Returns the next Y tick value based on the current coord and the target coord.
+ * @private/
+ */
+YAHOO.widget.Slider.prototype._getNextY = function(curCoord, finalCoord) {
+ var t = this.thumb;
+ // var thresh = t.tickSize;
+ // var thresh = t.tickSize + this.thumbCenterPoint.y;
+ var thresh;
+ var tmp = [];
+ var nextCoord = null;
+
+ if (curCoord[1] > finalCoord[1]) {
+ thresh = t.tickSize - this.thumbCenterPoint.y;
+ tmp = t.getTargetCoord( curCoord[0], curCoord[1] - thresh );
+ nextCoord = [tmp.x, tmp.y];
+ } else if (curCoord[1] < finalCoord[1]) {
+ thresh = t.tickSize + this.thumbCenterPoint.y;
+ tmp = t.getTargetCoord( curCoord[0], curCoord[1] + thresh );
+ nextCoord = [tmp.x, tmp.y];
+ } else {
+ // equal, do nothing
+ }
+
+ return nextCoord;
+};
+
+/**
+ * Resets the constraints before moving the thumb.
+ * @private
+ */
+YAHOO.widget.Slider.prototype.b4MouseDown = function(e) {
+ this.thumb.autoOffset();
+ this.thumb.resetConstraints();
+};
+
+
+/**
+ * Handles the mousedown event for the slider background
+ *
+ * @private
+ */
+YAHOO.widget.Slider.prototype.onMouseDown = function(e) {
+ // this.resetConstraints(true);
+ // this.thumb.resetConstraints(true);
+
+ if (! this.isLocked() && this.backgroundEnabled) {
+ var x = YAHOO.util.Event.getPageX(e);
+ var y = YAHOO.util.Event.getPageY(e);
+ this.logger.log("bg mousedown: " + x + "," + y);
+
+ this.focus();
+ this.moveThumb(x, y);
+ }
+
+};
+
+/**
+ * Handles the onDrag event for the slider background
+ *
+ * @private
+ */
+YAHOO.widget.Slider.prototype.onDrag = function(e) {
+ if (! this.isLocked()) {
+ var x = YAHOO.util.Event.getPageX(e);
+ var y = YAHOO.util.Event.getPageY(e);
+ this.moveThumb(x, y, true);
+ }
+};
+
+/**
+ * Fired when the slider movement ends
+ *
+ * @private
+ */
+YAHOO.widget.Slider.prototype.endMove = function () {
+ // this._animating = false;
+ this.unlock();
+ this.moveComplete = true;
+ this.fireEvents();
+
+};
+
+/**
+ * Fires the change event if the value has been changed. Ignored if we are in
+ * the middle of an animation as the event will fire when the animation is
+ * complete
+ *
+ * @private
+ */
+YAHOO.widget.Slider.prototype.fireEvents = function () {
+
+ var t = this.thumb;
+ // this.logger.log("FireEvents: " + t._isRegion);
+
+ t.cachePosition();
+
+ if (! this.isLocked()) {
+ if (t._isRegion) {
+ this.logger.log("region");
+ var newX = t.getXValue();
+ var newY = t.getYValue();
+
+ if (newX != this.previousX || newY != this.previousY) {
+ // this.logger.log("Firing onchange");
+ this.onChange( newX, newY );
+ }
+
+ this.previousX = newX;
+ this.previousY = newY;
+
+ } else {
+ var newVal = t.getValue();
+ if (newVal != this.previousVal) {
+ this.logger.log("Firing onchange: " + newVal);
+ this.onChange( newVal );
+ }
+ this.previousVal = newVal;
+ }
+
+ if (this.moveComplete) {
+ this.onSlideEnd();
+ this.moveComplete = false;
+ }
+
+ }
+};
+
+/**
+ * toString
+ * @return {string} string representation of the instance
+ */
+YAHOO.widget.Slider.prototype.toString = function () {
+ return ("Slider (" + this.type +") " + this.id);
+};
+
+/**
+ * A drag and drop implementation to be used as the thumb of a slider.
+ *
+ * @extends YAHOO.util.DD
+ * @constructor
+ * @param {String} id the id of the slider html element
+ * @param {String} sGroup the group of related DragDrop items
+ * @param {int} iLeft the number of pixels the element can move left
+ * @param {int} iRight the number of pixels the element can move right
+ * @param {int} iUp the number of pixels the element can move up
+ * @param {int} iDown the number of pixels the element can move down
+ * @param {int} iTickSize optional parameter for specifying that the element
+ * should move a certain number pixels at a time.
+ */
+YAHOO.widget.SliderThumb = function(id, sGroup, iLeft, iRight, iUp, iDown, iTickSize) {
+
+ if (id) {
+ this.init(id, sGroup);
+
+ /**
+ * The id of the thumbs parent HTML element (the slider background element).
+ * @type string
+ */
+ this.parentElId = sGroup;
+ }
+
+ this.logger = new YAHOO.widget.LogWriter(this.toString());
+
+ /**
+ * Overrides the isTarget property in YAHOO.util.DragDrop
+ * @private
+ */
+ this.isTarget = false;
+
+ /**
+ * The tick size for this slider
+ * @type int
+ */
+ this.tickSize = iTickSize;
+
+ /**
+ * Informs the drag and drop util that the offsets should remain when
+ * resetting the constraints. This preserves the slider value when
+ * the constraints are reset
+ * @type boolean
+ */
+ this.maintainOffset = true;
+
+ this.initSlider(iLeft, iRight, iUp, iDown, iTickSize);
+
+ this.scroll = false;
+
+};
+
+// YAHOO.widget.SliderThumb.prototype = new YAHOO.util.DD();
+YAHOO.extend(YAHOO.widget.SliderThumb, YAHOO.util.DD);
+
+/**
+ * Returns the difference between the location of the thumb and its parent.
+ * @param {Array} Optionally accepts the position of the parent
+ * @type int[]
+ */
+YAHOO.widget.SliderThumb.prototype.getOffsetFromParent = function(parentPos) {
+ var myPos = YAHOO.util.Dom.getXY(this.getEl());
+ var ppos = parentPos || YAHOO.util.Dom.getXY(this.parentElId);
+
+ return [ (myPos[0] - ppos[0]), (myPos[1] - ppos[1]) ];
+};
+
+/**
+ * The (X and Y) difference between the thumb location and its parent
+ * (the slider background) when the control is instantiated.
+ * @type int[]
+ */
+YAHOO.widget.SliderThumb.prototype.startOffset = null;
+
+/**
+ * Flag used to figure out if this is a horizontal or vertical slider
+ *
+ * @type boolean
+ * @private
+ */
+YAHOO.widget.SliderThumb.prototype._isHoriz = false;
+
+/**
+ * Cache the last value so we can check for change
+ *
+ * @type int
+ * @private
+ */
+YAHOO.widget.SliderThumb.prototype._prevVal = 0;
+
+/**
+ * initial element X
+ *
+ * @type int
+ * @private
+ */
+// YAHOO.widget.SliderThumb.prototype._initX = 0;
+
+/**
+ * initial element Y
+ *
+ * @type int
+ * @private
+ */
+// YAHOO.widget.SliderThumb.prototype._initY = 0;
+
+/**
+ * The slider is _graduated if there is a tick interval defined
+ *
+ * @type boolean
+ * @private
+ */
+YAHOO.widget.SliderThumb.prototype._graduated = false;
+
+/**
+ * Set up the slider, must be called in the constructor of all subclasses
+ *
+ * @param {int} iLeft the number of pixels the element can move left
+ * @param {int} iRight the number of pixels the element can move right
+ * @param {int} iUp the number of pixels the element can move up
+ * @param {int} iDown the number of pixels the element can move down
+ * @param {int} iTickSize the width of the tick interval.
+ */
+YAHOO.widget.SliderThumb.prototype.initSlider = function (iLeft, iRight, iUp, iDown,
+ iTickSize) {
+
+ this.setXConstraint(iLeft, iRight, iTickSize);
+ this.setYConstraint(iUp, iDown, iTickSize);
+
+ if (iTickSize && iTickSize > 1) {
+ this._graduated = true;
+ }
+
+ this._isHoriz = (iLeft > 0 || iRight > 0);
+ this._isVert = (iUp > 0 || iDown > 0);
+ this._isRegion = (this._isHoriz && this._isVert);
+
+};
+
+/**
+ * Clear's the slider's ticks
+ */
+YAHOO.widget.SliderThumb.prototype.clearTicks = function () {
+ YAHOO.widget.SliderThumb.superclass.clearTicks.call(this);
+ this._graduated = false;
+};
+
+/**
+ * Gets the current offset from the element's start position in
+ * pixels.
+ *
+ * @return {int} the number of pixels (positive or negative) the
+ * slider has moved from the start position.
+ */
+YAHOO.widget.SliderThumb.prototype.getValue = function () {
+ if (!this.available) { return 0; }
+ var val = (this._isHoriz) ? this.getXValue() : this.getYValue();
+ this.logger.log("getVal: " + val);
+ return val;
+};
+
+/**
+ * Gets the current X offset from the element's start position in
+ * pixels.
+ *
+ * @return {int} the number of pixels (positive or negative) the
+ * slider has moved horizontally from the start position.
+ */
+YAHOO.widget.SliderThumb.prototype.getXValue = function () {
+ if (!this.available) { return 0; }
+ var newOffset = this.getOffsetFromParent();
+ return (newOffset[0] - this.startOffset[0]);
+};
+
+/**
+ * Gets the current Y offset from the element's start position in
+ * pixels.
+ *
+ * @return {int} the number of pixels (positive or negative) the
+ * slider has moved vertically from the start position.
+ */
+YAHOO.widget.SliderThumb.prototype.getYValue = function () {
+ if (!this.available) { return 0; }
+ var newOffset = this.getOffsetFromParent();
+ return (newOffset[1] - this.startOffset[1]);
+};
+
+/**
+ * toString
+ * @return {string} string representation of the instance
+ */
+YAHOO.widget.SliderThumb.prototype.toString = function () {
+ return "SliderThumb " + this.id;
+};
+
+/**
+ * The onchange event for the handle/thumb is delegated to the YAHOO.widget.Slider
+ * instance it belongs to.
+ *
+ * @private
+ */
+YAHOO.widget.SliderThumb.prototype.onChange = function (x, y) { };
+
+if ("undefined" == typeof YAHOO.util.Anim) {
+ YAHOO.widget.Slider.ANIM_AVAIL = false;
+}
+
Added: branches/tomek/portal-dnd/dndRenderer.war/js/slider/slider-min.js
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/slider/slider-min.js 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/slider/slider-min.js 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1 @@
+/* Copyright (c) 2006, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.net/yui/license.txt version: 0.11.0 */ YAHOO.widget.Slider=function(_1,_2,_3,_4){if(_1){this.type=_4;this.init(_1,_2,true);var _5=this;this.thumb=_3;_3.onChange=function(){_5.onThumbChange();};this.isTarget=false;this.animate=YAHOO.widget.Slider.ANIM_AVAIL;this.ba!
ckgroundEnabled=true;this.tickPause=40;if(_3._isHoriz&&_3.xTicks&&_3.xTicks.length){this.tickPause=Math.round(360/_3.xTicks.length);}else{if(_3.yTicks&&_3.yTicks.length){this.tickPause=Math.round(360/_3.yTicks.length);}}_3.onMouseDown=function(){return _5.focus();};_3.onMouseUp=function(){_5.thumbMouseUp();};_3.onDrag=function(){_5.fireEvents();};_3.onAvailable=function(){return _5.setStartSliderState();};}};YAHOO.extend(YAHOO.widget.Slider,YAHOO.util.DragDrop);YAHOO.widget.Slider.getHorizSlider=function(_6,_7,_8,_9,_10){return new YAHOO.widget.Slider(_6,_6,new YAHOO.widget.SliderThumb(_7,_6,_8,_9,0,0,_10),"horiz");};YAHOO.widget.Slider.getVertSlider=function(_11,_12,iUp,_14,_15){return new YAHOO.widget.Slider(_11,_11,new YAHOO.widget.SliderThumb(_12,_11,0,0,iUp,_14,_15),"vert");};YAHOO.widget.Slider.getSliderRegion=function(_16,_17,_18,_19,iUp,_20,_21){return new YAHOO.widget.Slider(_16,_16,new YAHOO.widget.SliderThumb(_17,_16,_18,_19,iUp,_20,_21),"region");};YAHOO.widget.!
Slider.ANIM_AVAIL=true;YAHOO.widget.Slider.prototype.setStartSliderSta
te=function(){this.setThumbCenterPoint();this.baselinePos=YAHOO.util.Dom.getXY(this.getEl());this.thumb.startOffset=this.thumb.getOffsetFromParent(this.baselinePos);if(this.thumb._isRegion){if(this.deferredSetRegionValue){this.setRegionValue.apply(this,this.deferredSetRegionValue,true);}else{this.setRegionValue(0,0,true);}}else{if(this.deferredSetValue){this.setValue.apply(this,this.deferredSetValue,true);}else{this.setValue(0,true,true);}}};YAHOO.widget.Slider.prototype.setThumbCenterPoint=function(){var el=this.thumb.getEl();if(el){this.thumbCenterPoint={x:parseInt(el.offsetWidth/2,10),y:parseInt(el.offsetHeight/2,10)};}};YAHOO.widget.Slider.prototype.lock=function(){this.thumb.lock();this.locked=true;};YAHOO.widget.Slider.prototype.unlock=function(){this.thumb.unlock();this.locked=false;};YAHOO.widget.Slider.prototype.thumbMouseUp=function(){if(!this.isLocked()&&!this.moveComplete){this.endMove();}};YAHOO.widget.Slider.prototype.getThumb=function(){return this.thumb;};YAH!
OO.widget.Slider.prototype.focus=function(){var el=this.getEl();if(el.focus){el.focus();}this.verifyOffset();if(this.isLocked()){return false;}else{this.onSlideStart();return true;}};YAHOO.widget.Slider.prototype.onChange=function(_23,_24){};YAHOO.widget.Slider.prototype.onSlideStart=function(){};YAHOO.widget.Slider.prototype.onSlideEnd=function(){};YAHOO.widget.Slider.prototype.getValue=function(){return this.thumb.getValue();};YAHOO.widget.Slider.prototype.getXValue=function(){return this.thumb.getXValue();};YAHOO.widget.Slider.prototype.getYValue=function(){return this.thumb.getYValue();};YAHOO.widget.Slider.prototype.onThumbChange=function(){var t=this.thumb;if(t._isRegion){t.onChange(t.getXValue(),t.getYValue());}else{t.onChange(t.getValue());}};YAHOO.widget.Slider.prototype.setValue=function(_26,_27,_28){if(!this.thumb.available){this.deferredSetValue=arguments;return false;}if(this.isLocked()&&!_28){return false;}if(isNaN(_26)){return false;}var t=this.thumb;var _29,!
newY;this.verifyOffset();if(t._isRegion){return false;}else{if(t._isHo
riz){this.onSlideStart();_29=t.initPageX+_26+this.thumbCenterPoint.x;this.moveThumb(_29,t.initPageY,_27);}else{this.onSlideStart();newY=t.initPageY+_26+this.thumbCenterPoint.y;this.moveThumb(t.initPageX,newY,_27);}}return true;};YAHOO.widget.Slider.prototype.setRegionValue=function(_30,_31,_32){if(!this.thumb.available){this.deferredSetRegionValue=arguments;return false;}if(this.isLocked()&&!force){return false;}if(isNaN(_30)){return false;}var t=this.thumb;if(t._isRegion){this.onSlideStart();var _33=t.initPageX+_30+this.thumbCenterPoint.x;var _34=t.initPageY+_31+this.thumbCenterPoint.y;this.moveThumb(_33,_34,_32);return true;}return false;};YAHOO.widget.Slider.prototype.verifyOffset=function(){var _35=YAHOO.util.Dom.getXY(this.getEl());if(_35[0]!=this.baselinePos[0]||_35[1]!=this.baselinePos[1]){this.thumb.resetConstraints();this.baselinePos=_35;return false;}return true;};YAHOO.widget.Slider.prototype.moveThumb=function(x,y,_38){var t=this.thumb;var _39=this;if(!t.availabl!
e){return;}t.setDelta(this.thumbCenterPoint.x,this.thumbCenterPoint.y);var _p=t.getTargetCoord(x,y);var p=[_p.x,_p.y];if(this.animate&&YAHOO.widget.Slider.ANIM_AVAIL&&t._graduated&&!_38){this.lock();setTimeout(function(){_39.moveOneTick(p);},this.tickPause);}else{if(this.animate&&YAHOO.widget.Slider.ANIM_AVAIL&&!_38){this.lock();var _42=new YAHOO.util.Motion(t.id,{points:{to:p}},0.4,YAHOO.util.Easing.easeOut);_42.onComplete.subscribe(function(){_39.endMove();});_42.animate();}else{t.setDragElPos(x,y);this.endMove();}}};YAHOO.widget.Slider.prototype.moveOneTick=function(_43){var t=this.thumb;var _44=YAHOO.util.Dom.getXY(t.getEl());var tmp;var _46=null;if(t._isRegion){_46=this._getNextX(_44,_43);var _47=(_46)?_46[0]:_44[0];_46=this._getNextY([_47,_44[1]],_43);}else{if(t._isHoriz){_46=this._getNextX(_44,_43);}else{_46=this._getNextY(_44,_43);}}if(_46){this.thumb.alignElWithMouse(t.getEl(),_46[0],_46[1]);if(!(_46[0]==_43[0]&&_46[1]==_43[1])){var _48=this;setTimeout(function(){_!
48.moveOneTick(_43);},this.tickPause);}else{this.endMove();}}else{this
.endMove();}};YAHOO.widget.Slider.prototype._getNextX=function(_49,_50){var t=this.thumb;var _51;var tmp=[];var _52=null;if(_49[0]>_50[0]){_51=t.tickSize-this.thumbCenterPoint.x;tmp=t.getTargetCoord(_49[0]-_51,_49[1]);_52=[tmp.x,tmp.y];}else{if(_49[0]<_50[0]){_51=t.tickSize+this.thumbCenterPoint.x;tmp=t.getTargetCoord(_49[0]+_51,_49[1]);_52=[tmp.x,tmp.y];}else{}}return _52;};YAHOO.widget.Slider.prototype._getNextY=function(_53,_54){var t=this.thumb;var _55;var tmp=[];var _56=null;if(_53[1]>_54[1]){_55=t.tickSize-this.thumbCenterPoint.y;tmp=t.getTargetCoord(_53[0],_53[1]-_55);_56=[tmp.x,tmp.y];}else{if(_53[1]<_54[1]){_55=t.tickSize+this.thumbCenterPoint.y;tmp=t.getTargetCoord(_53[0],_53[1]+_55);_56=[tmp.x,tmp.y];}else{}}return _56;};YAHOO.widget.Slider.prototype.b4MouseDown=function(e){this.thumb.autoOffset();this.thumb.resetConstraints();};YAHOO.widget.Slider.prototype.onMouseDown=function(e){if(!this.isLocked()&&this.backgroundEnabled){var x=YAHOO.util.Event.getPageX(e);var!
y=YAHOO.util.Event.getPageY(e);this.focus();this.moveThumb(x,y);}};YAHOO.widget.Slider.prototype.onDrag=function(e){if(!this.isLocked()){var x=YAHOO.util.Event.getPageX(e);var y=YAHOO.util.Event.getPageY(e);this.moveThumb(x,y,true);}};YAHOO.widget.Slider.prototype.endMove=function(){this.unlock();this.moveComplete=true;this.fireEvents();};YAHOO.widget.Slider.prototype.fireEvents=function(){var t=this.thumb;t.cachePosition();if(!this.isLocked()){if(t._isRegion){var _58=t.getXValue();var _59=t.getYValue();if(_58!=this.previousX||_59!=this.previousY){this.onChange(_58,_59);}this.previousX=_58;this.previousY=_59;}else{var _60=t.getValue();if(_60!=this.previousVal){this.onChange(_60);}this.previousVal=_60;}if(this.moveComplete){this.onSlideEnd();this.moveComplete=false;}}};YAHOO.widget.Slider.prototype.toString=function(){return ("Slider ("+this.type+") "+this.id);};YAHOO.widget.SliderThumb=function(id,_62,_63,_64,iUp,_65,_66){if(id){this.init(id,_62);this.parentElId=_62;}this.!
isTarget=false;this.tickSize=_66;this.maintainOffset=true;this.initSli
der(_63,_64,iUp,_65,_66);this.scroll=false;};YAHOO.extend(YAHOO.widget.SliderThumb,YAHOO.util.DD);YAHOO.widget.SliderThumb.prototype.getOffsetFromParent=function(_67){var _68=YAHOO.util.Dom.getXY(this.getEl());var _69=_67||YAHOO.util.Dom.getXY(this.parentElId);return [(_68[0]-_69[0]),(_68[1]-_69[1])];};YAHOO.widget.SliderThumb.prototype.startOffset=null;YAHOO.widget.SliderThumb.prototype._isHoriz=false;YAHOO.widget.SliderThumb.prototype._prevVal=0;YAHOO.widget.SliderThumb.prototype._graduated=false;YAHOO.widget.SliderThumb.prototype.initSlider=function(_70,_71,iUp,_72,_73){this.setXConstraint(_70,_71,_73);this.setYConstraint(iUp,_72,_73);if(_73&&_73>1){this._graduated=true;}this._isHoriz=(_70>0||_71>0);this._isVert=(iUp>0||_72>0);this._isRegion=(this._isHoriz&&this._isVert);};YAHOO.widget.SliderThumb.prototype.clearTicks=function(){YAHOO.widget.SliderThumb.superclass.clearTicks.call(this);this._graduated=false;};YAHOO.widget.SliderThumb.prototype.getValue=function(){if(!this!
.available){return 0;}var val=(this._isHoriz)?this.getXValue():this.getYValue();return val;};YAHOO.widget.SliderThumb.prototype.getXValue=function(){if(!this.available){return 0;}var _75=this.getOffsetFromParent();return (_75[0]-this.startOffset[0]);};YAHOO.widget.SliderThumb.prototype.getYValue=function(){if(!this.available){return 0;}var _76=this.getOffsetFromParent();return (_76[1]-this.startOffset[1]);};YAHOO.widget.SliderThumb.prototype.toString=function(){return "SliderThumb "+this.id;};YAHOO.widget.SliderThumb.prototype.onChange=function(x,y){};if("undefined"==typeof YAHOO.util.Anim){YAHOO.widget.Slider.ANIM_AVAIL=false;}
\ No newline at end of file
Added: branches/tomek/portal-dnd/dndRenderer.war/js/slider/slider.js
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/slider/slider.js 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/slider/slider.js 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,904 @@
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 0.11.0
+*/
+
+/**
+ * A DragDrop implementation that can be used as a background for a
+ * slider. It takes a reference to the thumb instance
+ * so it can delegate some of the events to it. The goal is to make the
+ * thumb jump to the location on the background when the background is
+ * clicked.
+ *
+ * @extends YAHOO.util.DragDrop
+ * @constructor
+ * @param {String} id The id of the element linked to this instance
+ * @param {String} sGroup The group of related DragDrop items
+ * @param {String} sType The type of slider (horiz, vert, region)
+ */
+YAHOO.widget.Slider = function(sElementId, sGroup, oThumb, sType) {
+ if (sElementId) {
+
+ /**
+ * The type of the slider (horiz, vert, region)
+ * @type string
+ */
+ this.type = sType;
+
+ this.init(sElementId, sGroup, true);
+
+
+ var self = this;
+
+ /**
+ * a YAHOO.widget.SliderThumb instance that we will use to
+ * reposition the thumb when the background is clicked
+ *
+ * @type Slider
+ */
+ this.thumb = oThumb;
+
+ // add handler for the handle onchange event
+ oThumb.onChange = function() {
+ self.onThumbChange();
+ };
+
+ /**
+ * Overrides the isTarget property in YAHOO.util.DragDrop
+ * @private
+ */
+ this.isTarget = false;
+
+ /**
+ * Flag that determines if the thumb will animate when moved
+ * @type boolean
+ */
+ this.animate = YAHOO.widget.Slider.ANIM_AVAIL;
+
+ /**
+ * Set to false to disable a background click thumb move
+ */
+ this.backgroundEnabled = true;
+
+ /**
+ * Adjustment factor for tick animation, the more ticks, the
+ * faster the animation (by default)
+ *
+ * @type int
+ */
+ this.tickPause = 40;
+ if (oThumb._isHoriz && oThumb.xTicks && oThumb.xTicks.length) {
+ this.tickPause = Math.round(360 / oThumb.xTicks.length);
+ } else if (oThumb.yTicks && oThumb.yTicks.length) {
+ this.tickPause = Math.round(360 / oThumb.yTicks.length);
+ }
+
+
+ // delegate thumb methods
+ oThumb.onMouseDown = function () { return self.focus(); };
+ //oThumb.b4MouseDown = function () { return self.b4MouseDown(); };
+ // oThumb.lock = function() { self.lock(); };
+ // oThumb.unlock = function() { self.unlock(); };
+ oThumb.onMouseUp = function() { self.thumbMouseUp(); };
+ oThumb.onDrag = function() { self.fireEvents(); };
+ oThumb.onAvailable = function() { return self.setStartSliderState(); };
+ }
+};
+
+//YAHOO.widget.Slider.prototype = new YAHOO.util.DragDrop();
+YAHOO.extend(YAHOO.widget.Slider, YAHOO.util.DragDrop);
+
+// YAHOO.widget.Slider.prototype.onAvailable = function() {
+// };
+
+/**
+ * Factory method for creating a horizontal slider
+ *
+ * @param {String} sBGElId the id of the slider's background element
+ * @param {String} sHandleElId the id of the thumb element
+ * @param {int} iLeft the number of pixels the element can move left
+ * @param {int} iRight the number of pixels the element can move right
+ * @param {int} iTickSize optional parameter for specifying that the element
+ * should move a certain number pixels at a time.
+ * @return {Slider} a horizontal slider control
+ */
+YAHOO.widget.Slider.getHorizSlider =
+ function (sBGElId, sHandleElId, iLeft, iRight, iTickSize) {
+ return new YAHOO.widget.Slider(sBGElId, sBGElId,
+ new YAHOO.widget.SliderThumb(sHandleElId, sBGElId,
+ iLeft, iRight, 0, 0, iTickSize), "horiz");
+};
+
+/**
+ * Factory method for creating a vertical slider
+ *
+ * @param {String} sBGElId the id of the slider's background element
+ * @param {String} sHandleElId the id of the thumb element
+ * @param {int} iUp the number of pixels the element can move up
+ * @param {int} iDown the number of pixels the element can move down
+ * @param {int} iTickSize optional parameter for specifying that the element
+ * should move a certain number pixels at a time.
+ * @return {Slider} a vertical slider control
+ */
+YAHOO.widget.Slider.getVertSlider =
+ function (sBGElId, sHandleElId, iUp, iDown, iTickSize) {
+ return new YAHOO.widget.Slider(sBGElId, sBGElId,
+ new YAHOO.widget.SliderThumb(sHandleElId, sBGElId, 0, 0,
+ iUp, iDown, iTickSize), "vert");
+};
+
+/**
+ * Factory method for creating a slider region like the one in the color
+ * picker example
+ *
+ * @param {String} sBGElId the id of the slider's background element
+ * @param {String} sHandleElId the id of the thumb element
+ * @param {int} iLeft the number of pixels the element can move left
+ * @param {int} iRight the number of pixels the element can move right
+ * @param {int} iUp the number of pixels the element can move up
+ * @param {int} iDown the number of pixels the element can move down
+ * @param {int} iTickSize optional parameter for specifying that the element
+ * should move a certain number pixels at a time.
+ * @return {Slider} a slider region control
+ */
+YAHOO.widget.Slider.getSliderRegion =
+ function (sBGElId, sHandleElId, iLeft, iRight, iUp, iDown, iTickSize) {
+ return new YAHOO.widget.Slider(sBGElId, sBGElId,
+ new YAHOO.widget.SliderThumb(sHandleElId, sBGElId, iLeft, iRight,
+ iUp, iDown, iTickSize), "region");
+};
+
+/**
+ * By default, animation is available if the animation library is detected.
+ * @type boolean
+ */
+YAHOO.widget.Slider.ANIM_AVAIL = true;
+
+YAHOO.widget.Slider.prototype.setStartSliderState = function() {
+
+
+ this.setThumbCenterPoint();
+
+ /**
+ * The basline position of the background element, used
+ * to determine if the background has moved since the last
+ * operation.
+ * @type int[]
+ */
+ this.baselinePos = YAHOO.util.Dom.getXY(this.getEl());
+
+ this.thumb.startOffset = this.thumb.getOffsetFromParent(this.baselinePos);
+
+ if (this.thumb._isRegion) {
+ if (this.deferredSetRegionValue) {
+ this.setRegionValue.apply(this, this.deferredSetRegionValue, true);
+ } else {
+ this.setRegionValue(0, 0, true);
+ }
+ } else {
+ if (this.deferredSetValue) {
+ this.setValue.apply(this, this.deferredSetValue, true);
+ } else {
+ this.setValue(0, true, true);
+ }
+ }
+};
+
+YAHOO.widget.Slider.prototype.setThumbCenterPoint = function() {
+
+ var el = this.thumb.getEl();
+
+ if (el) {
+ /**
+ * the center of the slider element is stored so we can position
+ * place it in the correct position when the background is clicked
+ *
+ * @type Coordinate
+ */
+ this.thumbCenterPoint = {
+ x: parseInt(el.offsetWidth/2, 10),
+ y: parseInt(el.offsetHeight/2, 10)
+ };
+ }
+
+};
+
+/**
+ * Lock the slider, overrides YAHOO.util.DragDrop
+ */
+YAHOO.widget.Slider.prototype.lock = function() {
+ this.thumb.lock();
+ this.locked = true;
+};
+
+/**
+ * Unlock the slider, overrides YAHOO.util.DragDrop
+ */
+YAHOO.widget.Slider.prototype.unlock = function() {
+ this.thumb.unlock();
+ this.locked = false;
+};
+
+/**
+ * handles mouseup event on the slider background
+ *
+ * @private
+ */
+YAHOO.widget.Slider.prototype.thumbMouseUp = function() {
+ if (!this.isLocked() && !this.moveComplete) {
+ this.endMove();
+ }
+
+};
+
+/**
+ * Returns a reference to this slider's thumb
+ */
+YAHOO.widget.Slider.prototype.getThumb = function() {
+ return this.thumb;
+};
+
+/**
+ * Try to focus the element when clicked so we can add
+ * accessibility features
+ *
+ * @private
+ */
+YAHOO.widget.Slider.prototype.focus = function() {
+
+ // Focus the background element if possible
+ var el = this.getEl();
+
+ if (el.focus) {
+ el.focus();
+ }
+
+ this.verifyOffset();
+
+ if (this.isLocked()) {
+ return false;
+ } else {
+ this.onSlideStart();
+ return true;
+ }
+};
+
+/**
+ * Event that fires when the value of the slider has changed
+ *
+ * @param {int} offsetFromStart the number of pixels the thumb has moved
+ * from its start position. Normal horizontal and vertical sliders will only
+ * have the firstOffset. Regions will have both, the first is the horizontal
+ * offset, the second the vertical.
+ */
+YAHOO.widget.Slider.prototype.onChange = function (firstOffset, secondOffset) {
+ /* override me */
+};
+
+/**
+ * Event that fires when the at the beginning of the slider thumb move
+ */
+YAHOO.widget.Slider.prototype.onSlideStart = function () {
+ /* override me */
+};
+
+/**
+ * Event that fires at the end of a slider thumb move
+ */
+YAHOO.widget.Slider.prototype.onSlideEnd = function () {
+ /* override me */
+};
+
+/**
+ * Returns the slider's thumb offset from the start position
+ *
+ * @return {int} the current value
+ */
+YAHOO.widget.Slider.prototype.getValue = function () {
+ return this.thumb.getValue();
+};
+
+/**
+ * Returns the slider's thumb X offset from the start position
+ *
+ * @return {int} the current horizontal offset
+ */
+YAHOO.widget.Slider.prototype.getXValue = function () {
+ return this.thumb.getXValue();
+};
+
+/**
+ * Returns the slider's thumb Y offset from the start position
+ *
+ * @return {int} the current vertical offset
+ */
+YAHOO.widget.Slider.prototype.getYValue = function () {
+ return this.thumb.getYValue();
+};
+
+/**
+ * Internal handler for the slider thumb's onChange event
+ * @private
+ */
+YAHOO.widget.Slider.prototype.onThumbChange = function () {
+ var t = this.thumb;
+ if (t._isRegion) {
+ t.onChange(t.getXValue(), t.getYValue());
+ } else {
+ t.onChange(t.getValue());
+ }
+
+};
+
+/**
+ * Provides a way to set the value of the slider in code.
+ *
+ * @param {int} newOffset the number of pixels the thumb should be
+ * positioned away from the initial start point
+ * @param {boolean} skipAnim set to true to disable the animation
+ * for this move action (but not others).
+ * @param {boolean} force ignore the locked setting and set value anyway
+ * @return {boolean} true if the move was performed, false if it failed
+ */
+YAHOO.widget.Slider.prototype.setValue = function(newOffset, skipAnim, force) {
+
+ if (!this.thumb.available) {
+ this.deferredSetValue = arguments;
+ return false;
+ }
+
+ if (this.isLocked() && !force) {
+ return false;
+ }
+
+ if ( isNaN(newOffset) ) {
+ return false;
+ }
+
+ var t = this.thumb;
+ var newX, newY;
+ this.verifyOffset();
+ if (t._isRegion) {
+ return false;
+ } else if (t._isHoriz) {
+ this.onSlideStart();
+ newX = t.initPageX + newOffset + this.thumbCenterPoint.x;
+ this.moveThumb(newX, t.initPageY, skipAnim);
+ } else {
+ this.onSlideStart();
+ newY = t.initPageY + newOffset + this.thumbCenterPoint.y;
+ this.moveThumb(t.initPageX, newY, skipAnim);
+ }
+
+ return true;
+};
+
+/**
+ * Provides a way to set the value of the region slider in code.
+ *
+ * @param {int} newOffset the number of pixels the thumb should be
+ * positioned away from the initial start point
+ * @param {int} newOffset2 the number of pixels the thumb should be
+ * positioned away from the initial start point (y axis for region)
+ * @param {boolean} skipAnim set to true to disable the animation
+ * for this move action (but not others).
+ * @param {boolean} force ignore the locked setting and set value anyway
+ * @return {boolean} true if the move was performed, false if it failed
+ */
+YAHOO.widget.Slider.prototype.setRegionValue = function(newOffset, newOffset2, skipAnim) {
+
+ if (!this.thumb.available) {
+ this.deferredSetRegionValue = arguments;
+ return false;
+ }
+
+ if (this.isLocked() && !force) {
+ return false;
+ }
+
+ if ( isNaN(newOffset) ) {
+ return false;
+ }
+
+ var t = this.thumb;
+ if (t._isRegion) {
+ this.onSlideStart();
+ var newX = t.initPageX + newOffset + this.thumbCenterPoint.x;
+ var newY = t.initPageY + newOffset2 + this.thumbCenterPoint.y;
+ this.moveThumb(newX, newY, skipAnim);
+ return true;
+ }
+
+ return false;
+
+};
+
+/**
+ * Checks the background position element position. If it has moved from the
+ * baseline position, the constraints for the thumb are reset
+ * @return {boolean} True if the offset is the same as the baseline.
+ */
+YAHOO.widget.Slider.prototype.verifyOffset = function() {
+
+ var newPos = YAHOO.util.Dom.getXY(this.getEl());
+
+ if (newPos[0] != this.baselinePos[0] || newPos[1] != this.baselinePos[1]) {
+ this.thumb.resetConstraints();
+ this.baselinePos = newPos;
+ return false;
+ }
+
+ return true;
+};
+
+/**
+ * Move the associated slider moved to a timeout to try to get around the
+ * mousedown stealing moz does when I move the slider element between the
+ * cursor and the background during the mouseup event
+ *
+ * @param {int} x the X coordinate of the click
+ * @param {int} y the Y coordinate of the click
+ * @param {boolean} skipAnim don't animate if the move happend onDrag
+ * @private
+ */
+YAHOO.widget.Slider.prototype.moveThumb = function(x, y, skipAnim) {
+
+
+ var t = this.thumb;
+ var self = this;
+
+ if (!t.available) {
+ return;
+ }
+
+
+ // this.verifyOffset();
+
+ t.setDelta(this.thumbCenterPoint.x, this.thumbCenterPoint.y);
+
+ var _p = t.getTargetCoord(x, y);
+ var p = [_p.x, _p.y];
+
+ if (this.animate && YAHOO.widget.Slider.ANIM_AVAIL && t._graduated && !skipAnim) {
+ // this.thumb._animating = true;
+ this.lock();
+
+ setTimeout( function() { self.moveOneTick(p); }, this.tickPause );
+
+ } else if (this.animate && YAHOO.widget.Slider.ANIM_AVAIL && !skipAnim) {
+
+ // this.thumb._animating = true;
+ this.lock();
+
+ var oAnim = new YAHOO.util.Motion(
+ t.id, { points: { to: p } }, 0.4, YAHOO.util.Easing.easeOut );
+
+ oAnim.onComplete.subscribe( function() { self.endMove(); } );
+ oAnim.animate();
+ } else {
+ t.setDragElPos(x, y);
+ // this.fireEvents();
+ this.endMove();
+ }
+};
+
+/**
+ * Move the slider one tick mark towards its final coordinate. Used
+ * for the animation when tick marks are defined
+ *
+ * @param {int[]} the destination coordinate
+ * @private
+ */
+YAHOO.widget.Slider.prototype.moveOneTick = function(finalCoord) {
+
+ var t = this.thumb;
+ var curCoord = YAHOO.util.Dom.getXY(t.getEl());
+ var tmp;
+
+ // var thresh = Math.min(t.tickSize + (Math.floor(t.tickSize/2)), 10);
+ // var thresh = 10;
+ // var thresh = t.tickSize + (Math.floor(t.tickSize/2));
+
+ var nextCoord = null;
+
+ if (t._isRegion) {
+ nextCoord = this._getNextX(curCoord, finalCoord);
+ var tmpX = (nextCoord) ? nextCoord[0] : curCoord[0];
+ nextCoord = this._getNextY([tmpX, curCoord[1]], finalCoord);
+
+ } else if (t._isHoriz) {
+ nextCoord = this._getNextX(curCoord, finalCoord);
+ } else {
+ nextCoord = this._getNextY(curCoord, finalCoord);
+ }
+
+
+ if (nextCoord) {
+
+ // move to the next coord
+ // YAHOO.util.Dom.setXY(t.getEl(), nextCoord);
+
+ // var el = t.getEl();
+ // YAHOO.util.Dom.setStyle(el, "left", (nextCoord[0] + this.thumb.deltaSetXY[0]) + "px");
+ // YAHOO.util.Dom.setStyle(el, "top", (nextCoord[1] + this.thumb.deltaSetXY[1]) + "px");
+
+ this.thumb.alignElWithMouse(t.getEl(), nextCoord[0], nextCoord[1]);
+
+ // check if we are in the final position, if not make a recursive call
+ if (!(nextCoord[0] == finalCoord[0] && nextCoord[1] == finalCoord[1])) {
+ var self = this;
+ setTimeout(function() { self.moveOneTick(finalCoord); },
+ this.tickPause);
+ } else {
+ this.endMove();
+ }
+ } else {
+ this.endMove();
+ }
+
+ //this.tickPause = Math.round(this.tickPause/2);
+};
+
+/**
+ * Returns the next X tick value based on the current coord and the target coord.
+ * @private/
+ */
+YAHOO.widget.Slider.prototype._getNextX = function(curCoord, finalCoord) {
+ var t = this.thumb;
+ var thresh;
+ var tmp = [];
+ var nextCoord = null;
+ if (curCoord[0] > finalCoord[0]) {
+ thresh = t.tickSize - this.thumbCenterPoint.x;
+ tmp = t.getTargetCoord( curCoord[0] - thresh, curCoord[1] );
+ nextCoord = [tmp.x, tmp.y];
+ } else if (curCoord[0] < finalCoord[0]) {
+ thresh = t.tickSize + this.thumbCenterPoint.x;
+ tmp = t.getTargetCoord( curCoord[0] + thresh, curCoord[1] );
+ nextCoord = [tmp.x, tmp.y];
+ } else {
+ // equal, do nothing
+ }
+
+ return nextCoord;
+};
+
+/**
+ * Returns the next Y tick value based on the current coord and the target coord.
+ * @private/
+ */
+YAHOO.widget.Slider.prototype._getNextY = function(curCoord, finalCoord) {
+ var t = this.thumb;
+ // var thresh = t.tickSize;
+ // var thresh = t.tickSize + this.thumbCenterPoint.y;
+ var thresh;
+ var tmp = [];
+ var nextCoord = null;
+
+ if (curCoord[1] > finalCoord[1]) {
+ thresh = t.tickSize - this.thumbCenterPoint.y;
+ tmp = t.getTargetCoord( curCoord[0], curCoord[1] - thresh );
+ nextCoord = [tmp.x, tmp.y];
+ } else if (curCoord[1] < finalCoord[1]) {
+ thresh = t.tickSize + this.thumbCenterPoint.y;
+ tmp = t.getTargetCoord( curCoord[0], curCoord[1] + thresh );
+ nextCoord = [tmp.x, tmp.y];
+ } else {
+ // equal, do nothing
+ }
+
+ return nextCoord;
+};
+
+/**
+ * Resets the constraints before moving the thumb.
+ * @private
+ */
+YAHOO.widget.Slider.prototype.b4MouseDown = function(e) {
+ this.thumb.autoOffset();
+ this.thumb.resetConstraints();
+};
+
+/**
+ * Handles the mousedown event for the slider background
+ *
+ * @private
+ */
+YAHOO.widget.Slider.prototype.onMouseDown = function(e) {
+ // this.resetConstraints(true);
+ // this.thumb.resetConstraints(true);
+
+ if (! this.isLocked() && this.backgroundEnabled) {
+ var x = YAHOO.util.Event.getPageX(e);
+ var y = YAHOO.util.Event.getPageY(e);
+
+ this.focus();
+ this.moveThumb(x, y);
+ }
+
+};
+
+/**
+ * Handles the onDrag event for the slider background
+ *
+ * @private
+ */
+YAHOO.widget.Slider.prototype.onDrag = function(e) {
+ if (! this.isLocked()) {
+ var x = YAHOO.util.Event.getPageX(e);
+ var y = YAHOO.util.Event.getPageY(e);
+ this.moveThumb(x, y, true);
+ }
+};
+
+/**
+ * Fired when the slider movement ends
+ *
+ * @private
+ */
+YAHOO.widget.Slider.prototype.endMove = function () {
+ // this._animating = false;
+ this.unlock();
+ this.moveComplete = true;
+ this.fireEvents();
+
+};
+
+/**
+ * Fires the change event if the value has been changed. Ignored if we are in
+ * the middle of an animation as the event will fire when the animation is
+ * complete
+ *
+ * @private
+ */
+YAHOO.widget.Slider.prototype.fireEvents = function () {
+
+ var t = this.thumb;
+
+ t.cachePosition();
+
+ if (! this.isLocked()) {
+ if (t._isRegion) {
+ var newX = t.getXValue();
+ var newY = t.getYValue();
+
+ if (newX != this.previousX || newY != this.previousY) {
+ this.onChange( newX, newY );
+ }
+
+ this.previousX = newX;
+ this.previousY = newY;
+
+ } else {
+ var newVal = t.getValue();
+ if (newVal != this.previousVal) {
+ this.onChange( newVal );
+ }
+ this.previousVal = newVal;
+ }
+
+ if (this.moveComplete) {
+ this.onSlideEnd();
+ this.moveComplete = false;
+ }
+
+ }
+};
+
+/**
+ * toString
+ * @return {string} string representation of the instance
+ */
+YAHOO.widget.Slider.prototype.toString = function () {
+ return ("Slider (" + this.type +") " + this.id);
+};
+
+/**
+ * A drag and drop implementation to be used as the thumb of a slider.
+ *
+ * @extends YAHOO.util.DD
+ * @constructor
+ * @param {String} id the id of the slider html element
+ * @param {String} sGroup the group of related DragDrop items
+ * @param {int} iLeft the number of pixels the element can move left
+ * @param {int} iRight the number of pixels the element can move right
+ * @param {int} iUp the number of pixels the element can move up
+ * @param {int} iDown the number of pixels the element can move down
+ * @param {int} iTickSize optional parameter for specifying that the element
+ * should move a certain number pixels at a time.
+ */
+YAHOO.widget.SliderThumb = function(id, sGroup, iLeft, iRight, iUp, iDown, iTickSize) {
+
+ if (id) {
+ this.init(id, sGroup);
+
+ /**
+ * The id of the thumbs parent HTML element (the slider background element).
+ * @type string
+ */
+ this.parentElId = sGroup;
+ }
+
+
+ /**
+ * Overrides the isTarget property in YAHOO.util.DragDrop
+ * @private
+ */
+ this.isTarget = false;
+
+ /**
+ * The tick size for this slider
+ * @type int
+ */
+ this.tickSize = iTickSize;
+
+ /**
+ * Informs the drag and drop util that the offsets should remain when
+ * resetting the constraints. This preserves the slider value when
+ * the constraints are reset
+ * @type boolean
+ */
+ this.maintainOffset = true;
+
+ this.initSlider(iLeft, iRight, iUp, iDown, iTickSize);
+
+ this.scroll = false;
+
+};
+
+// YAHOO.widget.SliderThumb.prototype = new YAHOO.util.DD();
+YAHOO.extend(YAHOO.widget.SliderThumb, YAHOO.util.DD);
+
+/**
+ * Returns the difference between the location of the thumb and its parent.
+ * @param {Array} Optionally accepts the position of the parent
+ * @type int[]
+ */
+YAHOO.widget.SliderThumb.prototype.getOffsetFromParent = function(parentPos) {
+ var myPos = YAHOO.util.Dom.getXY(this.getEl());
+ var ppos = parentPos || YAHOO.util.Dom.getXY(this.parentElId);
+
+ return [ (myPos[0] - ppos[0]), (myPos[1] - ppos[1]) ];
+};
+
+/**
+ * The (X and Y) difference between the thumb location and its parent
+ * (the slider background) when the control is instantiated.
+ * @type int[]
+ */
+YAHOO.widget.SliderThumb.prototype.startOffset = null;
+
+/**
+ * Flag used to figure out if this is a horizontal or vertical slider
+ *
+ * @type boolean
+ * @private
+ */
+YAHOO.widget.SliderThumb.prototype._isHoriz = false;
+
+/**
+ * Cache the last value so we can check for change
+ *
+ * @type int
+ * @private
+ */
+YAHOO.widget.SliderThumb.prototype._prevVal = 0;
+
+/**
+ * initial element X
+ *
+ * @type int
+ * @private
+ */
+// YAHOO.widget.SliderThumb.prototype._initX = 0;
+
+/**
+ * initial element Y
+ *
+ * @type int
+ * @private
+ */
+// YAHOO.widget.SliderThumb.prototype._initY = 0;
+
+/**
+ * The slider is _graduated if there is a tick interval defined
+ *
+ * @type boolean
+ * @private
+ */
+YAHOO.widget.SliderThumb.prototype._graduated = false;
+
+/**
+ * Set up the slider, must be called in the constructor of all subclasses
+ *
+ * @param {int} iLeft the number of pixels the element can move left
+ * @param {int} iRight the number of pixels the element can move right
+ * @param {int} iUp the number of pixels the element can move up
+ * @param {int} iDown the number of pixels the element can move down
+ * @param {int} iTickSize the width of the tick interval.
+ */
+YAHOO.widget.SliderThumb.prototype.initSlider = function (iLeft, iRight, iUp, iDown,
+ iTickSize) {
+
+ this.setXConstraint(iLeft, iRight, iTickSize);
+ this.setYConstraint(iUp, iDown, iTickSize);
+
+ if (iTickSize && iTickSize > 1) {
+ this._graduated = true;
+ }
+
+ this._isHoriz = (iLeft > 0 || iRight > 0);
+ this._isVert = (iUp > 0 || iDown > 0);
+ this._isRegion = (this._isHoriz && this._isVert);
+
+};
+
+/**
+ * Clear's the slider's ticks
+ */
+YAHOO.widget.SliderThumb.prototype.clearTicks = function () {
+ YAHOO.widget.SliderThumb.superclass.clearTicks.call(this);
+ this._graduated = false;
+};
+
+/**
+ * Gets the current offset from the element's start position in
+ * pixels.
+ *
+ * @return {int} the number of pixels (positive or negative) the
+ * slider has moved from the start position.
+ */
+YAHOO.widget.SliderThumb.prototype.getValue = function () {
+ if (!this.available) { return 0; }
+ var val = (this._isHoriz) ? this.getXValue() : this.getYValue();
+ return val;
+};
+
+/**
+ * Gets the current X offset from the element's start position in
+ * pixels.
+ *
+ * @return {int} the number of pixels (positive or negative) the
+ * slider has moved horizontally from the start position.
+ */
+YAHOO.widget.SliderThumb.prototype.getXValue = function () {
+ if (!this.available) { return 0; }
+ var newOffset = this.getOffsetFromParent();
+ return (newOffset[0] - this.startOffset[0]);
+};
+
+/**
+ * Gets the current Y offset from the element's start position in
+ * pixels.
+ *
+ * @return {int} the number of pixels (positive or negative) the
+ * slider has moved vertically from the start position.
+ */
+YAHOO.widget.SliderThumb.prototype.getYValue = function () {
+ if (!this.available) { return 0; }
+ var newOffset = this.getOffsetFromParent();
+ return (newOffset[1] - this.startOffset[1]);
+};
+
+/**
+ * toString
+ * @return {string} string representation of the instance
+ */
+YAHOO.widget.SliderThumb.prototype.toString = function () {
+ return "SliderThumb " + this.id;
+};
+
+/**
+ * The onchange event for the handle/thumb is delegated to the YAHOO.widget.Slider
+ * instance it belongs to.
+ *
+ * @private
+ */
+YAHOO.widget.SliderThumb.prototype.onChange = function (x, y) { };
+
+if ("undefined" == typeof YAHOO.util.Anim) {
+ YAHOO.widget.Slider.ANIM_AVAIL = false;
+}
+
Added: branches/tomek/portal-dnd/dndRenderer.war/js/treeview/README
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/treeview/README 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/treeview/README 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,82 @@
+TreeView - Release Notes
+
+0.11.0
+
+ * Added TreeView -> popNode, which differs from removeNode in that the
+ node's children are preserved so the entire branch can be re-inserted
+ into another part of the tree, or another tree.
+
+ * Added TreeView -> getNodesByProperty, which differs from
+ getNodeByProperty by returning an array of all nodes that have the
+ specified property rather than just the first one.
+
+ * Added Node -> insertBefore, insertAfter, and appendTo. These method
+ can be used to reorganize the tree.
+
+ * removeChildren properly resets the node icon when executed against a
+ collpased node.
+
+ * Moved depth assignment from the constructor to appendChild so that the
+ value is set properly if the node is moved within the tree.
+
+ * Fixed broken loop in removeChildren.
+
+ * RootNode -> loadComplete calls tree.draw for hot-wiring the dynamic load
+ feature for the top level nodes.
+
+ * The treeview constructor will accept an element instead of an id.
+
+0.10.0
+
+ * If the child collection changes prior to a refresh(), the icon is now
+ changed appropriately.
+
+ * Added TreeView removeChildren(node). This will recursively purge the node's
+ children, and reset its dynamic load state.
+
+ * previousSibling and nextSibling are now adjusted correctly when a
+ node is deleted.
+
+ * expand()/collapse() now will not expand/collapse the node if false is
+ returned from the onExpand/onCollapse event handlers.
+
+ * The onExpand and onCollapse events now fire before the node is expanded
+ or collapsed so that the implementer can modify the node's child collection
+ prior to display.
+
+ * The childrenRendered property previous was used to indicate both that
+ a dynamically loaded node has received its data, and also to indicate
+ that the children html has been created. This has been split into
+ two properties. dynamicLoadComplete and childrenRendered.
+
+ * Implemented the renderHidden flag. If set to true, the html for the entire
+ tree will be created when tree.draw() is called, not just the html for the
+ visible nodes.
+
+ * Added an onLabelClick listener to TextNode
+
+ * TreeView.removeNode no longer automatically refreshes the tree. It has an
+ optional parameter to perform the refresh.
+
+ * removeNode can now be executed on nodes that have not been rendered.
+
+ * You can now delete top-level nodes.
+
+ * Added onCheckClick listener to the TaskNode example
+
+ * Added Node.iconMode, which is a property that configures the way
+ dynamically loaded nodes are displayed when they are expanded and contain
+ no children.
+
+ * TreeView/Node.setDynamicLoad now accepts an optional second parameter to
+ set the iconMode property.
+
+ * Fixed an issue in the TaskNode.js example that prevented setting the checked
+ state of a node through the constructor.
+
+ * Fixed an issue in HTMLNode that caused rendering issues when hasIcon was
+ set to true.
+
+ * Added TreeView.removeNode
+
+ * Added Node.refresh
Added: branches/tomek/portal-dnd/dndRenderer.war/js/treeview/assets/lm.gif
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/dndRenderer.war/js/treeview/assets/lm.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/dndRenderer.war/js/treeview/assets/lmh.gif
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/dndRenderer.war/js/treeview/assets/lmh.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/dndRenderer.war/js/treeview/assets/ln.gif
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/dndRenderer.war/js/treeview/assets/ln.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/dndRenderer.war/js/treeview/assets/loading.gif
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/dndRenderer.war/js/treeview/assets/loading.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/dndRenderer.war/js/treeview/assets/lp.gif
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/dndRenderer.war/js/treeview/assets/lp.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/dndRenderer.war/js/treeview/assets/lph.gif
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/dndRenderer.war/js/treeview/assets/lph.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/dndRenderer.war/js/treeview/assets/tm.gif
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/dndRenderer.war/js/treeview/assets/tm.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/dndRenderer.war/js/treeview/assets/tmh.gif
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/dndRenderer.war/js/treeview/assets/tmh.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/dndRenderer.war/js/treeview/assets/tn.gif
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/dndRenderer.war/js/treeview/assets/tn.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/dndRenderer.war/js/treeview/assets/tp.gif
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/dndRenderer.war/js/treeview/assets/tp.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/dndRenderer.war/js/treeview/assets/tph.gif
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/dndRenderer.war/js/treeview/assets/tph.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/dndRenderer.war/js/treeview/assets/tree.css
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/treeview/assets/tree.css 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/treeview/assets/tree.css 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,98 @@
+/* Copyright (c) 2006 Yahoo! Inc. All rights reserved. */
+
+/* first or middle sibling, no children */
+.ygtvtn {
+ width:16px; height:22px;
+ background: url(../../../../../../../i/us/nt/widg/tree/dflt/tn.gif) 0 0 no-repeat;
+}
+
+/* first or middle sibling, collapsable */
+.ygtvtm {
+ width:16px; height:22px;
+ cursor:pointer ;
+ background: url(../../../../../../../i/us/nt/widg/tree/dflt/tm.gif) 0 0 no-repeat;
+}
+
+/* first or middle sibling, collapsable, hover */
+.ygtvtmh {
+ width:16px; height:22px;
+ cursor:pointer ;
+ background: url(../../../../../../../i/us/nt/widg/tree/dflt/tmh.gif) 0 0 no-repeat;
+}
+
+/* first or middle sibling, expandable */
+.ygtvtp {
+ width:16px; height:22px;
+ cursor:pointer ;
+ background: url(../../../../../../../i/us/nt/widg/tree/dflt/tp.gif) 0 0 no-repeat;
+}
+
+/* first or middle sibling, expandable, hover */
+.ygtvtph {
+ width:16px; height:22px;
+ cursor:pointer ;
+ background: url(../../../../../../../i/us/nt/widg/tree/dflt/tph.gif) 0 0 no-repeat;
+}
+
+/* last sibling, no children */
+.ygtvln {
+ width:16px; height:22px;
+ background: url(../../../../../../../i/us/nt/widg/tree/dflt/ln.gif) 0 0 no-repeat;
+}
+
+/* Last sibling, collapsable */
+.ygtvlm {
+ width:16px; height:22px;
+ cursor:pointer ;
+ background: url(../../../../../../../i/us/nt/widg/tree/dflt/lm.gif) 0 0 no-repeat;
+}
+
+/* Last sibling, collapsable, hover */
+.ygtvlmh {
+ width:16px; height:22px;
+ cursor:pointer ;
+ background: url(../../../../../../../i/us/nt/widg/tree/dflt/lmh.gif) 0 0 no-repeat;
+}
+
+/* Last sibling, expandable */
+.ygtvlp {
+ width:16px; height:22px;
+ cursor:pointer ;
+ background: url(../../../../../../../i/us/nt/widg/tree/dflt/lp.gif) 0 0 no-repeat;
+}
+
+/* Last sibling, expandable, hover */
+.ygtvlph {
+ width:16px; height:22px; cursor:pointer ;
+ background: url(../../../../../../../i/us/nt/widg/tree/dflt/lph.gif) 0 0 no-repeat;
+}
+
+/* Loading icon */
+.ygtvloading {
+ width:16px; height:22px;
+ background: url(../../../../../../../i/us/nt/widg/tree/dflt/loading.gif) 0 0 no-repeat;
+}
+
+/* the style for the empty cells that are used for rendering the depth
+ * of the node */
+.ygtvdepthcell {
+ width:16px; height:22px;
+ background: url(../../../../../../../i/us/nt/widg/tree/dflt/vline.gif) 0 0 no-repeat;
+}
+
+.ygtvblankdepthcell { width:16px; height:22px; }
+
+/* the style of the div around each node */
+.ygtvitem { }
+
+/* the style of the div around each node's collection of children */
+.ygtvchildren { }
+* html .ygtvchildren { height:2%; }
+
+/* the style of the text label in ygTextNode */
+.ygtvlabel, .ygtvlabel:link, .ygtvlabel:visited, .ygtvlabel:hover {
+ margin-left:2px;
+ text-decoration: none;
+}
+
+.ygtvspacer { height: 10px; width: 10px; margin: 2px; }
Added: branches/tomek/portal-dnd/dndRenderer.war/js/treeview/assets/vline.gif
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/dndRenderer.war/js/treeview/assets/vline.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/dndRenderer.war/js/treeview/treeview-debug.js
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/treeview/treeview-debug.js 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/treeview/treeview-debug.js 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,2004 @@
+
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 0.11.0
+*/
+
+/**
+ * Contains the tree view state data and the root node. This is an
+ * ordered tree; child nodes will be displayed in the order created, and
+ * there currently is no way to change this.
+ *
+ * @constructor
+ * @param {string|HTMLElement} id The id of the element, or the element
+ * itself that the tree will be inserted into.
+ */
+YAHOO.widget.TreeView = function(id) {
+ if (id) { this.init(id); }
+};
+
+/**
+ * Count of all nodes in all trees
+ * @type int
+ */
+YAHOO.widget.TreeView.nodeCount = 0;
+
+YAHOO.widget.TreeView.prototype = {
+
+ /**
+ * The id of tree container element
+ *
+ * @type String
+ */
+ id: null,
+
+ /**
+ * The host element for this tree
+ * @private
+ */
+ _el: null,
+
+ /**
+ * Flat collection of all nodes in this tree
+ *
+ * @type Node[]
+ * @private
+ */
+ _nodes: null,
+
+ /**
+ * We lock the tree control while waiting for the dynamic loader to return
+ *
+ * @type boolean
+ */
+ locked: false,
+
+ /**
+ * The animation to use for expanding children, if any
+ *
+ * @type string
+ * @private
+ */
+ _expandAnim: null,
+
+ /**
+ * The animation to use for collapsing children, if any
+ *
+ * @type string
+ * @private
+ */
+ _collapseAnim: null,
+
+ /**
+ * The current number of animations that are executing
+ *
+ * @type int
+ * @private
+ */
+ _animCount: 0,
+
+ /**
+ * The maximum number of animations to run at one time.
+ *
+ * @type int
+ */
+ maxAnim: 2,
+
+ /**
+ * Sets up the animation for expanding children
+ *
+ * @param {string} the type of animation (acceptable values defined in
+ * YAHOO.widget.TVAnim)
+ */
+ setExpandAnim: function(type) {
+ if (YAHOO.widget.TVAnim.isValid(type)) {
+ this._expandAnim = type;
+ }
+ },
+
+ /**
+ * Sets up the animation for collapsing children
+ *
+ * @param {string} the type of animation (acceptable values defined in
+ * YAHOO.widget.TVAnim)
+ */
+ setCollapseAnim: function(type) {
+ if (YAHOO.widget.TVAnim.isValid(type)) {
+ this._collapseAnim = type;
+ }
+ },
+
+ /**
+ * Perform the expand animation if configured, or just show the
+ * element if not configured or too many animations are in progress
+ *
+ * @param el {HTMLElement} the element to animate
+ * @return {boolean} true if animation could be invoked, false otherwise
+ */
+ animateExpand: function(el) {
+ this.logger.log("animating expand");
+
+ if (this._expandAnim && this._animCount < this.maxAnim) {
+ // this.locked = true;
+ var tree = this;
+ var a = YAHOO.widget.TVAnim.getAnim(this._expandAnim, el,
+ function() { tree.expandComplete(); });
+ if (a) {
+ ++this._animCount;
+ a.animate();
+ }
+
+ return true;
+ }
+
+ return false;
+ },
+
+ /**
+ * Perform the collapse animation if configured, or just show the
+ * element if not configured or too many animations are in progress
+ *
+ * @param el {HTMLElement} the element to animate
+ * @return {boolean} true if animation could be invoked, false otherwise
+ */
+ animateCollapse: function(el) {
+ this.logger.log("animating collapse");
+
+ if (this._collapseAnim && this._animCount < this.maxAnim) {
+ // this.locked = true;
+ var tree = this;
+ var a = YAHOO.widget.TVAnim.getAnim(this._collapseAnim, el,
+ function() { tree.collapseComplete(); });
+ if (a) {
+ ++this._animCount;
+ a.animate();
+ }
+
+ return true;
+ }
+
+ return false;
+ },
+
+ /**
+ * Function executed when the expand animation completes
+ */
+ expandComplete: function() {
+ this.logger.log("expand complete: " + this.id);
+ --this._animCount;
+ // this.locked = false;
+ },
+
+ /**
+ * Function executed when the collapse animation completes
+ */
+ collapseComplete: function() {
+ this.logger.log("collapse complete: " + this.id);
+ --this._animCount;
+ // this.locked = false;
+ },
+
+ /**
+ * Initializes the tree
+ *
+ * @parm {string|HTMLElement} id the id of the element that will hold the tree
+ * @private
+ */
+ init: function(id) {
+
+ this.id = id;
+
+ if ("string" !== typeof id) {
+ this._el = id;
+ this.id = this.generateId(id);
+ }
+
+ this._nodes = [];
+
+ // store a global reference
+ YAHOO.widget.TreeView.trees[this.id] = this;
+
+ // Set up the root node
+ this.root = new YAHOO.widget.RootNode(this);
+
+ this.logger = new YAHOO.widget.LogWriter(this.toString());
+
+ this.logger.log("tree init: " + this.id);
+ },
+
+ /**
+ * Renders the tree boilerplate and visible nodes
+ */
+ draw: function() {
+ var html = this.root.getHtml();
+ this.getEl().innerHTML = html;
+ this.firstDraw = false;
+ },
+
+ /**
+ * Returns the tree's host element
+ * @return {HTMLElement} the host element
+ */
+ getEl: function() {
+ if (! this._el) {
+ this._el = document.getElementById(this.id);
+ }
+ return this._el;
+ },
+
+ /**
+ * Nodes register themselves with the tree instance when they are created.
+ *
+ * @param node {Node} the node to register
+ * @private
+ */
+ regNode: function(node) {
+ this._nodes[node.index] = node;
+ },
+
+ /**
+ * Returns the root node of this tree
+ *
+ * @return {Node} the root node
+ */
+ getRoot: function() {
+ return this.root;
+ },
+
+ /**
+ * Configures this tree to dynamically load all child data
+ *
+ * @param {function} fnDataLoader the function that will be called to get the data
+ * @param iconMode {int} configures the icon that is displayed when a dynamic
+ * load node is expanded the first time without children. By default, the
+ * "collapse" icon will be used. If set to 1, the leaf node icon will be
+ * displayed.
+ */
+ setDynamicLoad: function(fnDataLoader, iconMode) {
+ this.root.setDynamicLoad(fnDataLoader, iconMode);
+ },
+
+ /**
+ * Expands all child nodes. Note: this conflicts with the "multiExpand"
+ * node property. If expand all is called in a tree with nodes that
+ * do not allow multiple siblings to be displayed, only the last sibling
+ * will be expanded.
+ */
+ expandAll: function() {
+ if (!this.locked) {
+ this.root.expandAll();
+ }
+ },
+
+ /**
+ * Collapses all expanded child nodes in the entire tree.
+ */
+ collapseAll: function() {
+ if (!this.locked) {
+ this.root.collapseAll();
+ }
+ },
+
+ /**
+ * Returns a node in the tree that has the specified index (this index
+ * is created internally, so this function probably will only be used
+ * in html generated for a given node.)
+ *
+ * @param {int} nodeIndex the index of the node wanted
+ * @return {Node} the node with index=nodeIndex, null if no match
+ */
+ getNodeByIndex: function(nodeIndex) {
+ var n = this._nodes[nodeIndex];
+ return (n) ? n : null;
+ },
+
+ /**
+ * Returns a node that has a matching property and value in the data
+ * object that was passed into its constructor.
+ *
+ * @param {object} property the property to search (usually a string)
+ * @param {object} value the value we want to find (usuall an int or string)
+ * @return {Node} the matching node, null if no match
+ */
+ getNodeByProperty: function(property, value) {
+ for (var i in this._nodes) {
+ var n = this._nodes[i];
+ if (n.data && value == n.data[property]) {
+ return n;
+ }
+ }
+
+ return null;
+ },
+
+ /**
+ * Returns a collection of nodes that have a matching property
+ * and value in the data object that was passed into its constructor.
+ *
+ * @param {object} property the property to search (usually a string)
+ * @param {object} value the value we want to find (usuall an int or string)
+ * @return {Array} the matching collection of nodes, null if no match
+ */
+ getNodesByProperty: function(property, value) {
+ var values = [];
+ for (var i in this._nodes) {
+ var n = this._nodes[i];
+ if (n.data && value == n.data[property]) {
+ values.push(n);
+ }
+ }
+
+ return (values.length) ? values : null;
+ },
+
+ /**
+ * Removes the node and its children, and optionally refreshes the branch
+ * of the tree that was affected.
+ * @param {Node} The node to remove
+ * @param {boolean} autoRefresh automatically refreshes branch if true
+ * @return {boolean} False is there was a problem, true otherwise.
+ */
+ removeNode: function(node, autoRefresh) {
+
+ // Don't delete the root node
+ if (node.isRoot()) {
+ return false;
+ }
+
+ // Get the branch that we may need to refresh
+ var p = node.parent;
+ if (p.parent) {
+ p = p.parent;
+ }
+
+ // Delete the node and its children
+ this._deleteNode(node);
+
+ // Refresh the parent of the parent
+ if (autoRefresh && p && p.childrenRendered) {
+ p.refresh();
+ }
+
+ return true;
+ },
+
+ /**
+ * Deletes this nodes child collection, recursively. Also collapses
+ * the node, and resets the dynamic load flag. The primary use for
+ * this method is to purge a node and allow it to fetch its data
+ * dynamically again.
+ * @param {Node} node the node to purge
+ */
+ removeChildren: function(node) {
+ this.logger.log("Removing children for " + node);
+ while (node.children.length) {
+ this._deleteNode(node.children[0]);
+ }
+
+ node.childrenRendered = false;
+ node.dynamicLoadComplete = false;
+ // node.collapse();
+ node.expand();
+ node.collapse();
+ },
+
+ /**
+ * Deletes the node and recurses children
+ * @private
+ */
+ _deleteNode: function(node) {
+ // Remove all the child nodes first
+ this.removeChildren(node);
+
+ // Remove the node from the tree
+ this.popNode(node);
+ },
+
+ /**
+ * Removes the branch from the tree. This differs from removeNode in
+ * that the child collection is preserved to make it possible to
+ * insert the branch into another part of the tree, or another tree.
+ * @param {Node} the node to remove
+ */
+ popNode: function(node) {
+ var p = node.parent;
+
+ // Update the parent's collection of children
+ var a = [];
+
+ for (var i=0, len=p.children.length;i<len;++i) {
+ if (p.children[i] != node) {
+ a[a.length] = p.children[i];
+ }
+ }
+
+ p.children = a;
+
+ // reset the childrenRendered flag for the parent
+ p.childrenRendered = false;
+
+ // Update the sibling relationship
+ if (node.previousSibling) {
+ node.previousSibling.nextSibling = node.nextSibling;
+ }
+
+ if (node.nextSibling) {
+ node.nextSibling.previousSibling = node.previousSibling;
+ }
+
+ // Update the tree's node collection
+ delete this._nodes[node.index];
+ },
+
+
+ /**
+ * toString
+ * @return {string} string representation of the tree
+ */
+ toString: function() {
+ return "TreeView " + this.id;
+ },
+
+ /**
+ * private
+ */
+ generateId: function(el) {
+ var id = el.id;
+
+ if (!id) {
+ id = "yui-tv-auto-id-" + YAHOO.widget.TreeView.counter;
+ YAHOO.widget.TreeView.counter++;
+ }
+
+ return id;
+ },
+
+ /**
+ * Abstract method that is executed when a node is expanded
+ * @param node {Node} the node that was expanded
+ */
+ onExpand: function(node) { },
+
+ /**
+ * Abstract method that is executed when a node is collapsed
+ * @param node {Node} the node that was collapsed.
+ */
+ onCollapse: function(node) { }
+
+};
+
+/**
+ * Global cache of tree instances
+ *
+ * @type Array
+ * @private
+ */
+YAHOO.widget.TreeView.trees = [];
+
+/**
+ * @private
+ */
+YAHOO.widget.TreeView.counter = 0;
+
+/**
+ * Global method for getting a tree by its id. Used in the generated
+ * tree html.
+ *
+ * @param treeId {String} the id of the tree instance
+ * @return {TreeView} the tree instance requested, null if not found.
+ */
+YAHOO.widget.TreeView.getTree = function(treeId) {
+ var t = YAHOO.widget.TreeView.trees[treeId];
+ return (t) ? t : null;
+};
+
+
+/**
+ * Global method for getting a node by its id. Used in the generated
+ * tree html.
+ *
+ * @param treeId {String} the id of the tree instance
+ * @param nodeIndex {String} the index of the node to return
+ * @return {Node} the node instance requested, null if not found
+ */
+YAHOO.widget.TreeView.getNode = function(treeId, nodeIndex) {
+ var t = YAHOO.widget.TreeView.getTree(treeId);
+ return (t) ? t.getNodeByIndex(nodeIndex) : null;
+};
+
+/**
+ * Adds an event. Replace with event manager when available
+ *
+ * @param el the elment to bind the handler to
+ * @param {string} sType the type of event handler
+ * @param {function} fn the callback to invoke
+ * @param {boolean} capture if true event is capture phase, bubble otherwise
+ */
+YAHOO.widget.TreeView.addHandler = function (el, sType, fn, capture) {
+ capture = (capture) ? true : false;
+ if (el.addEventListener) {
+ el.addEventListener(sType, fn, capture);
+ } else if (el.attachEvent) {
+ el.attachEvent("on" + sType, fn);
+ } else {
+ el["on" + sType] = fn;
+ }
+};
+
+/**
+ * Attempts to preload the images defined in the styles used to draw the tree by
+ * rendering off-screen elements that use the styles.
+ */
+YAHOO.widget.TreeView.preload = function(prefix) {
+ prefix = prefix || "ygtv";
+ var styles = ["tn","tm","tmh","tp","tph","ln","lm","lmh","lp","lph","loading"];
+
+ var sb = [];
+
+ for (var i = 0; i < styles.length; ++i) {
+ sb[sb.length] = '<span class="' + prefix + styles[i] + '"> </span>';
+ }
+
+ var f = document.createElement("DIV");
+ var s = f.style;
+ s.position = "absolute";
+ s.top = "-1000px";
+ s.left = "-1000px";
+ f.innerHTML = sb.join("");
+
+ document.body.appendChild(f);
+};
+
+YAHOO.widget.TreeView.addHandler(window,
+ "load", YAHOO.widget.TreeView.preload);
+
+/**
+ * The base class for all tree nodes. The node's presentation and behavior in
+ * response to mouse events is handled in Node subclasses.
+ *
+ * @param oData {object} a string or object containing the data that will
+ * be used to render this node
+ * @param oParent {Node} this node's parent node
+ * @param expanded {boolean} the initial expanded/collapsed state
+ * @constructor
+ */
+YAHOO.widget.Node = function(oData, oParent, expanded) {
+ if (oData) { this.init(oData, oParent, expanded); }
+};
+
+YAHOO.widget.Node.prototype = {
+
+ /**
+ * The index for this instance obtained from global counter in YAHOO.widget.TreeView.
+ *
+ * @type int
+ */
+ index: 0,
+
+ /**
+ * This node's child node collection.
+ *
+ * @type Node[]
+ */
+ children: null,
+
+ /**
+ * Tree instance this node is part of
+ *
+ * @type TreeView
+ */
+ tree: null,
+
+ /**
+ * The data linked to this node. This can be any object or primitive
+ * value, and the data can be used in getNodeHtml().
+ *
+ * @type object
+ */
+ data: null,
+
+ /**
+ * Parent node
+ *
+ * @type Node
+ */
+ parent: null,
+
+ /**
+ * The depth of this node. We start at -1 for the root node.
+ *
+ * @type int
+ */
+ depth: -1,
+
+ /**
+ * The href for the node's label. If one is not specified, the href will
+ * be set so that it toggles the node.
+ *
+ * @type string
+ */
+ href: null,
+
+ /**
+ * The label href target, defaults to current window
+ *
+ * @type string
+ */
+ target: "_self",
+
+ /**
+ * The node's expanded/collapsed state
+ *
+ * @type boolean
+ */
+ expanded: false,
+
+ /**
+ * Can multiple children be expanded at once?
+ *
+ * @type boolean
+ */
+ multiExpand: true,
+
+ /**
+ * Should we render children for a collapsed node? It is possible that the
+ * implementer will want to render the hidden data... @todo verify that we
+ * need this, and implement it if we do.
+ *
+ * @type boolean
+ */
+ renderHidden: false,
+
+ /**
+ * This flag is set to true when the html is generated for this node's
+ * children, and set to false when new children are added.
+ * @type boolean
+ */
+ childrenRendered: false,
+
+ /**
+ * Dynamically loaded nodes only fetch the data the first time they are
+ * expanded. This flag is set to true once the data has been fetched.
+ * @type boolean
+ */
+ dynamicLoadComplete: false,
+
+ /**
+ * This node's previous sibling
+ *
+ * @type Node
+ */
+ previousSibling: null,
+
+ /**
+ * This node's next sibling
+ *
+ * @type Node
+ */
+ nextSibling: null,
+
+ /**
+ * We can set the node up to call an external method to get the child
+ * data dynamically.
+ *
+ * @type boolean
+ * @private
+ */
+ _dynLoad: false,
+
+ /**
+ * Function to execute when we need to get this node's child data.
+ *
+ * @type function
+ */
+ dataLoader: null,
+
+ /**
+ * This is true for dynamically loading nodes while waiting for the
+ * callback to return.
+ *
+ * @type boolean
+ */
+ isLoading: false,
+
+ /**
+ * The toggle/branch icon will not show if this is set to false. This
+ * could be useful if the implementer wants to have the child contain
+ * extra info about the parent, rather than an actual node.
+ *
+ * @type boolean
+ */
+ hasIcon: true,
+
+ /**
+ * Used to configure what happens when a dynamic load node is expanded
+ * and we discover that it does not have children. By default, it is
+ * treated as if it still could have children (plus/minus icon). Set
+ * iconMode to have it display like a leaf node instead.
+ * @type int
+ */
+ iconMode: 0,
+
+ /**
+ * The node type
+ * @private
+ */
+ _type: "Node",
+
+ /*
+ spacerPath: "http://us.i1.yimg.com/us.yimg.com/i/space.gif",
+ expandedText: "Expanded",
+ collapsedText: "Collapsed",
+ loadingText: "Loading",
+ */
+
+ /**
+ * Initializes this node, gets some of the properties from the parent
+ *
+ * @param oData {object} a string or object containing the data that will
+ * be used to render this node
+ * @param oParent {Node} this node's parent node
+ * @param expanded {boolean} the initial expanded/collapsed state
+ */
+ init: function(oData, oParent, expanded) {
+ this.data = oData;
+ this.children = [];
+ this.index = YAHOO.widget.TreeView.nodeCount;
+ ++YAHOO.widget.TreeView.nodeCount;
+ this.expanded = expanded;
+ this.logger = new YAHOO.widget.LogWriter(this.toString());
+
+ // oParent should never be null except when we create the root node.
+ if (oParent) {
+ oParent.appendChild(this);
+ }
+ },
+
+ /**
+ * Certain properties for the node cannot be set until the parent
+ * is known. This is called after the node is inserted into a tree.
+ * the parent is also applied to this node's children in order to
+ * make it possible to move a branch from one tree to another.
+ * @param {Node} parentNode this node's parent node
+ */
+ applyParent: function(parentNode) {
+ if (!parentNode) {
+ return false;
+ }
+
+ this.tree = parentNode.tree;
+ this.parent = parentNode;
+ this.depth = parentNode.depth + 1;
+
+ if (! this.href) {
+ this.href = "javascript:" + this.getToggleLink();
+ }
+
+ if (! this.multiExpand) {
+ this.multiExpand = parentNode.multiExpand;
+ }
+
+ this.tree.regNode(this);
+ parentNode.childrenRendered = false;
+
+ // cascade update existing children
+ for (var i=0, len=this.children.length;i<len;++i) {
+ this.children[i].applyParent(this);
+ }
+
+ return true;
+ },
+
+ /**
+ * Appends a node to the child collection.
+ *
+ * @param childNode {Node} the new node
+ * @return {Node} the child node
+ * @private
+ */
+ appendChild: function(childNode) {
+ if (this.hasChildren()) {
+ var sib = this.children[this.children.length - 1];
+ sib.nextSibling = childNode;
+ childNode.previousSibling = sib;
+ }
+ this.children[this.children.length] = childNode;
+ childNode.applyParent(this);
+
+ return childNode;
+ },
+
+ /**
+ * Appends this node to the supplied node's child collection
+ * @param parentNode {Node} the node to append to.
+ */
+ appendTo: function(parentNode) {
+ return parentNode.appendChild(this);
+ },
+
+ /**
+ * Inserts this node before this supplied node
+ *
+ * @param node {Node} the node to insert this node before
+ * @return {Node} the inserted node
+ */
+ insertBefore: function(node) {
+ this.logger.log("insertBefore: " + node);
+ var p = node.parent;
+ if (p) {
+
+ if (this.tree) {
+ this.tree.popNode(this);
+ }
+
+ var refIndex = node.isChildOf(p);
+ this.logger.log(refIndex);
+ p.children.splice(refIndex, 0, this);
+ if (node.previousSibling) {
+ node.previousSibling.nextSibling = this;
+ }
+ this.previousSibling = node.previousSibling;
+ this.nextSibling = node;
+ node.previousSibling = this;
+
+ this.applyParent(p);
+ }
+
+ return this;
+ },
+
+ /**
+ * Inserts this node after the supplied node
+ *
+ * @param node {Node} the node to insert after
+ * @return {Node} the inserted node
+ */
+ insertAfter: function(node) {
+ this.logger.log("insertAfter: " + node);
+ var p = node.parent;
+ if (p) {
+
+ if (this.tree) {
+ this.tree.popNode(this);
+ }
+
+ var refIndex = node.isChildOf(p);
+ this.logger.log(refIndex);
+
+ if (!node.nextSibling) {
+ return this.appendTo(p);
+ }
+
+ p.children.splice(refIndex + 1, 0, this);
+
+ node.nextSibling.previousSibling = this;
+ this.previousSibling = node;
+ this.nextSibling = node.nextSibling;
+ node.nextSibling = this;
+
+ this.applyParent(p);
+ }
+
+ return this;
+ },
+
+ /**
+ * Returns true if the Node is a child of supplied Node
+ *
+ * @param parentNode {Node} the Node to check
+ * @return {boolean} The node index if this Node is a child of
+ * supplied Node, else -1.
+ * @private
+ */
+ isChildOf: function(parentNode) {
+ if (parentNode && parentNode.children) {
+ for (var i=0, len=parentNode.children.length; i<len ; ++i) {
+ if (parentNode.children[i] === this) {
+ return i;
+ }
+ }
+ }
+
+ return -1;
+ },
+
+ /**
+ * Returns a node array of this node's siblings, null if none.
+ *
+ * @return Node[]
+ */
+ getSiblings: function() {
+ return this.parent.children;
+ },
+
+ /**
+ * Shows this node's children
+ */
+ showChildren: function() {
+ if (!this.tree.animateExpand(this.getChildrenEl())) {
+ if (this.hasChildren()) {
+ this.getChildrenEl().style.display = "";
+ }
+ }
+ },
+
+ /**
+ * Hides this node's children
+ */
+ hideChildren: function() {
+ this.logger.log("hiding " + this.index);
+
+ if (!this.tree.animateCollapse(this.getChildrenEl())) {
+ this.getChildrenEl().style.display = "none";
+ }
+ },
+
+ /**
+ * Returns the id for this node's container div
+ *
+ * @return {string} the element id
+ */
+ getElId: function() {
+ return "ygtv" + this.index;
+ },
+
+ /**
+ * Returns the id for this node's children div
+ *
+ * @return {string} the element id for this node's children div
+ */
+ getChildrenElId: function() {
+ return "ygtvc" + this.index;
+ },
+
+ /**
+ * Returns the id for this node's toggle element
+ *
+ * @return {string} the toggel element id
+ */
+ getToggleElId: function() {
+ return "ygtvt" + this.index;
+ },
+
+
+ /**
+ * Returns the id for this node's spacer image. The spacer is positioned
+ * over the toggle and provides feedback for screen readers.
+ * @return {string} the id for the spacer image
+ */
+ /*
+ getSpacerId: function() {
+ return "ygtvspacer" + this.index;
+ },
+ */
+
+ /**
+ * Returns this node's container html element
+ * @return {HTMLElement} the container html element
+ */
+ getEl: function() {
+ return document.getElementById(this.getElId());
+ },
+
+ /**
+ * Returns the div that was generated for this node's children
+ * @return {HTMLElement} this node's children div
+ */
+ getChildrenEl: function() {
+ return document.getElementById(this.getChildrenElId());
+ },
+
+ /**
+ * Returns the element that is being used for this node's toggle.
+ * @return {HTMLElement} this node's toggle html element
+ */
+ getToggleEl: function() {
+ return document.getElementById(this.getToggleElId());
+ },
+
+ /**
+ * Returns the element that is being used for this node's spacer.
+ * @return {HTMLElement} this node's spacer html element
+ */
+ /*
+ getSpacer: function() {
+ return document.getElementById( this.getSpacerId() ) || {};
+ },
+ */
+
+ /*
+ getStateText: function() {
+ if (this.isLoading) {
+ return this.loadingText;
+ } else if (this.hasChildren(true)) {
+ if (this.expanded) {
+ return this.expandedText;
+ } else {
+ return this.collapsedText;
+ }
+ } else {
+ return "";
+ }
+ },
+ */
+
+ /**
+ * Generates the link that will invoke this node's toggle method
+ * @return {string} the javascript url for toggling this node
+ */
+ getToggleLink: function() {
+ return "YAHOO.widget.TreeView.getNode(\'" + this.tree.id + "\'," +
+ this.index + ").toggle()";
+ },
+
+ /**
+ * Hides this nodes children (creating them if necessary), changes the
+ * toggle style.
+ */
+ collapse: function() {
+ // Only collapse if currently expanded
+ if (!this.expanded) { return; }
+
+ // fire the collapse event handler
+ var ret = this.tree.onCollapse(this);
+
+ if ("undefined" != typeof ret && !ret) {
+ this.logger.log("Collapse was stopped by the event handler");
+ return;
+ }
+
+ if (!this.getEl()) {
+ this.expanded = false;
+ return;
+ }
+
+ // hide the child div
+ this.hideChildren();
+ this.expanded = false;
+
+ if (this.hasIcon) {
+ this.getToggleEl().className = this.getStyle();
+ }
+
+ // this.getSpacer().title = this.getStateText();
+
+ },
+
+ /**
+ * Shows this nodes children (creating them if necessary), changes the
+ * toggle style, and collapses its siblings if multiExpand is not set.
+ */
+ expand: function() {
+ // Only expand if currently collapsed.
+ if (this.expanded) { return; }
+
+ // fire the expand event handler
+ var ret = this.tree.onExpand(this);
+
+ if ("undefined" != typeof ret && !ret) {
+ this.logger.log("Expand was stopped by the event handler");
+ return;
+ }
+
+ if (!this.getEl()) {
+ this.expanded = true;
+ return;
+ }
+
+ if (! this.childrenRendered) {
+ this.logger.log("children not rendered yet");
+ this.getChildrenEl().innerHTML = this.renderChildren();
+ } else {
+ this.logger.log("CHILDREN RENDERED");
+ }
+
+ this.expanded = true;
+ if (this.hasIcon) {
+ this.getToggleEl().className = this.getStyle();
+ }
+
+ // this.getSpacer().title = this.getStateText();
+
+ // We do an extra check for children here because the lazy
+ // load feature can expose nodes that have no children.
+
+ // if (!this.hasChildren()) {
+ if (this.isLoading) {
+ this.expanded = false;
+ return;
+ }
+
+ if (! this.multiExpand) {
+ var sibs = this.getSiblings();
+ for (var i=0; i<sibs.length; ++i) {
+ if (sibs[i] != this && sibs[i].expanded) {
+ sibs[i].collapse();
+ }
+ }
+ }
+
+ this.showChildren();
+ },
+
+ /**
+ * Returns the css style name for the toggle
+ *
+ * @return {string} the css class for this node's toggle
+ */
+ getStyle: function() {
+ // this.logger.log("No children, " + " isDyanmic: " + this.isDynamic() + " expanded: " + this.expanded);
+ if (this.isLoading) {
+ this.logger.log("returning the loading icon");
+ return "ygtvloading";
+ } else {
+ // location top or bottom, middle nodes also get the top style
+ var loc = (this.nextSibling) ? "t" : "l";
+
+ // type p=plus(expand), m=minus(collapase), n=none(no children)
+ var type = "n";
+ if (this.hasChildren(true) || (this.isDynamic() && !this.getIconMode())) {
+ // if (this.hasChildren(true)) {
+ type = (this.expanded) ? "m" : "p";
+ }
+
+ // this.logger.log("ygtv" + loc + type);
+ return "ygtv" + loc + type;
+ }
+ },
+
+ /**
+ * Returns the hover style for the icon
+ * @return {string} the css class hover state
+ */
+ getHoverStyle: function() {
+ var s = this.getStyle();
+ if (this.hasChildren(true) && !this.isLoading) {
+ s += "h";
+ }
+ return s;
+ },
+
+ /**
+ * Recursively expands all of this node's children.
+ */
+ expandAll: function() {
+ for (var i=0;i<this.children.length;++i) {
+ var c = this.children[i];
+ if (c.isDynamic()) {
+ alert("Not supported (lazy load + expand all)");
+ break;
+ } else if (! c.multiExpand) {
+ alert("Not supported (no multi-expand + expand all)");
+ break;
+ } else {
+ c.expand();
+ c.expandAll();
+ }
+ }
+ },
+
+ /**
+ * Recursively collapses all of this node's children.
+ */
+ collapseAll: function() {
+ for (var i=0;i<this.children.length;++i) {
+ this.children[i].collapse();
+ this.children[i].collapseAll();
+ }
+ },
+
+ /**
+ * Configures this node for dynamically obtaining the child data
+ * when the node is first expanded. Calling it without the callback
+ * will turn off dynamic load for the node.
+ *
+ * @param fmDataLoader {function} the function that will be used to get the data.
+ * @param iconMode {int} configures the icon that is displayed when a dynamic
+ * load node is expanded the first time without children. By default, the
+ * "collapse" icon will be used. If set to 1, the leaf node icon will be
+ * displayed.
+ */
+ setDynamicLoad: function(fnDataLoader, iconMode) {
+ if (fnDataLoader) {
+ this.dataLoader = fnDataLoader;
+ this._dynLoad = true;
+ } else {
+ this.dataLoader = null;
+ this._dynLoad = false;
+ }
+
+ if (iconMode) {
+ this.iconMode = iconMode;
+ }
+ },
+
+ /**
+ * Evaluates if this node is the root node of the tree
+ *
+ * @return {boolean} true if this is the root node
+ */
+ isRoot: function() {
+ return (this == this.tree.root);
+ },
+
+ /**
+ * Evaluates if this node's children should be loaded dynamically. Looks for
+ * the property both in this instance and the root node. If the tree is
+ * defined to load all children dynamically, the data callback function is
+ * defined in the root node
+ *
+ * @return {boolean} true if this node's children are to be loaded dynamically
+ */
+ isDynamic: function() {
+ var lazy = (!this.isRoot() && (this._dynLoad || this.tree.root._dynLoad));
+ // this.logger.log("isDynamic: " + lazy);
+ return lazy;
+ },
+
+ getIconMode: function() {
+ return (this.iconMode || this.tree.root.iconMode);
+ },
+
+ /**
+ * Checks if this node has children. If this node is lazy-loading and the
+ * children have not been rendered, we do not know whether or not there
+ * are actual children. In most cases, we need to assume that there are
+ * children (for instance, the toggle needs to show the expandable
+ * presentation state). In other times we want to know if there are rendered
+ * children. For the latter, "checkForLazyLoad" should be false.
+ *
+ * @param checkForLazyLoad {boolean} should we check for unloaded children?
+ * @return {boolean} true if this has children or if it might and we are
+ * checking for this condition.
+ */
+ hasChildren: function(checkForLazyLoad) {
+ return ( this.children.length > 0 ||
+ (checkForLazyLoad && this.isDynamic() && !this.dynamicLoadComplete) );
+ },
+
+ /**
+ * Expands if node is collapsed, collapses otherwise.
+ */
+ toggle: function() {
+ if (!this.tree.locked && ( this.hasChildren(true) || this.isDynamic()) ) {
+ if (this.expanded) { this.collapse(); } else { this.expand(); }
+ }
+ },
+
+ /**
+ * Returns the markup for this node and its children.
+ *
+ * @return {string} the markup for this node and its expanded children.
+ */
+ getHtml: function() {
+ var sb = [];
+ sb[sb.length] = '<div class="ygtvitem" id="' + this.getElId() + '">';
+ sb[sb.length] = this.getNodeHtml();
+ sb[sb.length] = this.getChildrenHtml();
+ sb[sb.length] = '</div>';
+ return sb.join("");
+ },
+
+ /**
+ * Called when first rendering the tree. We always build the div that will
+ * contain this nodes children, but we don't render the children themselves
+ * unless this node is expanded.
+ *
+ * @return {string} the children container div html and any expanded children
+ * @private
+ */
+ getChildrenHtml: function() {
+
+ var sb = [];
+ sb[sb.length] = '<div class="ygtvchildren"';
+ sb[sb.length] = ' id="' + this.getChildrenElId() + '"';
+ if (!this.expanded) {
+ sb[sb.length] = ' style="display:none;"';
+ }
+ sb[sb.length] = '>';
+
+ // Don't render the actual child node HTML unless this node is expanded.
+ if ( (this.hasChildren(true) && this.expanded) ||
+ (this.renderHidden && !this.isDynamic()) ) {
+ sb[sb.length] = this.renderChildren();
+ }
+
+ sb[sb.length] = '</div>';
+
+ return sb.join("");
+ },
+
+ /**
+ * Generates the markup for the child nodes. This is not done until the node
+ * is expanded.
+ *
+ * @return {string} the html for this node's children
+ * @private
+ */
+ renderChildren: function() {
+
+ this.logger.log("rendering children for " + this.index);
+
+ var node = this;
+
+ if (this.isDynamic() && !this.dynamicLoadComplete) {
+ this.isLoading = true;
+ this.tree.locked = true;
+
+ if (this.dataLoader) {
+ this.logger.log("Using dynamic loader defined for this node");
+
+ setTimeout(
+ function() {
+ node.dataLoader(node,
+ function() {
+ node.loadComplete();
+ });
+ }, 10);
+
+ } else if (this.tree.root.dataLoader) {
+ this.logger.log("Using the tree-level dynamic loader");
+
+ setTimeout(
+ function() {
+ node.tree.root.dataLoader(node,
+ function() {
+ node.loadComplete();
+ });
+ }, 10);
+
+ } else {
+ this.logger.log("no loader found");
+ return "Error: data loader not found or not specified.";
+ }
+
+ return "";
+
+ } else {
+ return this.completeRender();
+ }
+ },
+
+ /**
+ * Called when we know we have all the child data.
+ * @return {string} children html
+ */
+ completeRender: function() {
+ this.logger.log("completeRender: " + this.index + ", # of children: " + this.children.length);
+ var sb = [];
+
+ for (var i=0; i < this.children.length; ++i) {
+ this.children[i].childrenRendered = false;
+ sb[sb.length] = this.children[i].getHtml();
+ }
+
+ this.childrenRendered = true;
+
+ return sb.join("");
+ },
+
+ /**
+ * Load complete is the callback function we pass to the data provider
+ * in dynamic load situations.
+ */
+ loadComplete: function() {
+ this.logger.log("loadComplete: " + this.index);
+ this.getChildrenEl().innerHTML = this.completeRender();
+ this.dynamicLoadComplete = true;
+ this.isLoading = false;
+ this.expand();
+ this.tree.locked = false;
+ },
+
+ /**
+ * Returns this node's ancestor at the specified depth.
+ *
+ * @param {int} depth the depth of the ancestor.
+ * @return {Node} the ancestor
+ */
+ getAncestor: function(depth) {
+ if (depth >= this.depth || depth < 0) {
+ this.logger.log("illegal getAncestor depth: " + depth);
+ return null;
+ }
+
+ var p = this.parent;
+
+ while (p.depth > depth) {
+ p = p.parent;
+ }
+
+ return p;
+ },
+
+ /**
+ * Returns the css class for the spacer at the specified depth for
+ * this node. If this node's ancestor at the specified depth
+ * has a next sibling the presentation is different than if it
+ * does not have a next sibling
+ *
+ * @param {int} depth the depth of the ancestor.
+ * @return {string} the css class for the spacer
+ */
+ getDepthStyle: function(depth) {
+ return (this.getAncestor(depth).nextSibling) ?
+ "ygtvdepthcell" : "ygtvblankdepthcell";
+ },
+
+ /**
+ * Get the markup for the node. This is designed to be overrided so that we can
+ * support different types of nodes.
+ *
+ * @return {string} The HTML that will render this node.
+ */
+ getNodeHtml: function() {
+ this.logger.log("Generating html");
+ return "";
+ },
+
+ /**
+ * Regenerates the html for this node and its children. To be used when the
+ * node is expanded and new children have been added.
+ */
+ refresh: function() {
+ // this.loadComplete();
+ this.getChildrenEl().innerHTML = this.completeRender();
+
+ if (this.hasIcon) {
+ var el = this.getToggleEl();
+ if (el) {
+ el.className = this.getStyle();
+ }
+ }
+ },
+
+ /**
+ * toString
+ * @return {string} string representation of the node
+ */
+ toString: function() {
+ return "Node (" + this.index + ")";
+ }
+
+};
+
+/**
+ * A custom YAHOO.widget.Node that handles the unique nature of
+ * the virtual, presentationless root node.
+ *
+ * @extends YAHOO.widget.Node
+ * @constructor
+ */
+YAHOO.widget.RootNode = function(oTree) {
+ // Initialize the node with null params. The root node is a
+ // special case where the node has no presentation. So we have
+ // to alter the standard properties a bit.
+ this.init(null, null, true);
+
+ /**
+ * For the root node, we get the tree reference from as a param
+ * to the constructor instead of from the parent element.
+ *
+ * @type TreeView
+ */
+ this.tree = oTree;
+};
+
+YAHOO.widget.RootNode.prototype = new YAHOO.widget.Node();
+
+// overrides YAHOO.widget.Node
+YAHOO.widget.RootNode.prototype.getNodeHtml = function() {
+ return "";
+};
+
+YAHOO.widget.RootNode.prototype.toString = function() {
+ return "RootNode";
+};
+
+YAHOO.widget.RootNode.prototype.loadComplete = function() {
+ this.tree.draw();
+};
+/**
+ * The default node presentation. The first parameter should be
+ * either a string that will be used as the node's label, or an object
+ * that has a string propery called label. By default, the clicking the
+ * label will toggle the expanded/collapsed state of the node. By
+ * changing the href property of the instance, this behavior can be
+ * changed so that the label will go to the specified href.
+ *
+ * @extends YAHOO.widget.Node
+ * @constructor
+ * @param oData {object} a string or object containing the data that will
+ * be used to render this node
+ * @param oParent {YAHOO.widget.Node} this node's parent node
+ * @param expanded {boolean} the initial expanded/collapsed state
+ */
+YAHOO.widget.TextNode = function(oData, oParent, expanded) {
+ // this.type = "TextNode";
+
+ if (oData) {
+ this.init(oData, oParent, expanded);
+ this.setUpLabel(oData);
+ }
+
+ /**
+ * @private
+ */
+ this.logger = new YAHOO.widget.LogWriter(this.toString());
+};
+
+YAHOO.widget.TextNode.prototype = new YAHOO.widget.Node();
+
+/**
+ * The CSS class for the label href. Defaults to ygtvlabel, but can be
+ * overridden to provide a custom presentation for a specific node.
+ *
+ * @type string
+ */
+YAHOO.widget.TextNode.prototype.labelStyle = "ygtvlabel";
+
+/**
+ * The derived element id of the label for this node
+ *
+ * @type string
+ */
+YAHOO.widget.TextNode.prototype.labelElId = null;
+
+/**
+ * The text for the label. It is assumed that the oData parameter will
+ * either be a string that will be used as the label, or an object that
+ * has a property called "label" that we will use.
+ *
+ * @type string
+ */
+YAHOO.widget.TextNode.prototype.label = null;
+
+/**
+ * Sets up the node label
+ *
+ * @param oData string containing the label, or an object with a label property
+ */
+YAHOO.widget.TextNode.prototype.setUpLabel = function(oData) {
+ if (typeof oData == "string") {
+ oData = { label: oData };
+ }
+ this.label = oData.label;
+
+ // update the link
+ if (oData.href) {
+ this.href = oData.href;
+ }
+
+ // set the target
+ if (oData.target) {
+ this.target = oData.target;
+ }
+
+ if (oData.style) {
+ this.labelStyle = oData.style;
+ }
+
+ this.labelElId = "ygtvlabelel" + this.index;
+};
+
+/**
+ * Returns the label element
+ *
+ * @return {object} the element
+ */
+YAHOO.widget.TextNode.prototype.getLabelEl = function() {
+ return document.getElementById(this.labelElId);
+};
+
+// overrides YAHOO.widget.Node
+YAHOO.widget.TextNode.prototype.getNodeHtml = function() {
+ this.logger.log("Generating html");
+ var sb = [];
+
+ sb[sb.length] = '<table border="0" cellpadding="0" cellspacing="0">';
+ sb[sb.length] = '<tr>';
+
+ for (i=0;i<this.depth;++i) {
+ // sb[sb.length] = '<td class="ygtvdepthcell"> </td>';
+ sb[sb.length] = '<td class="' + this.getDepthStyle(i) + '"> </td>';
+ }
+
+ var getNode = 'YAHOO.widget.TreeView.getNode(\'' +
+ this.tree.id + '\',' + this.index + ')';
+
+ sb[sb.length] = '<td';
+ // sb[sb.length] = ' onselectstart="return false"';
+ sb[sb.length] = ' id="' + this.getToggleElId() + '"';
+ sb[sb.length] = ' class="' + this.getStyle() + '"';
+ if (this.hasChildren(true)) {
+ sb[sb.length] = ' onmouseover="this.className=';
+ sb[sb.length] = getNode + '.getHoverStyle()"';
+ sb[sb.length] = ' onmouseout="this.className=';
+ sb[sb.length] = getNode + '.getStyle()"';
+ }
+ sb[sb.length] = ' onclick="javascript:' + this.getToggleLink() + '">';
+
+ /*
+ sb[sb.length] = '<img id="' + this.getSpacerId() + '"';
+ sb[sb.length] = ' alt=""';
+ sb[sb.length] = ' tabindex=0';
+ sb[sb.length] = ' src="' + this.spacerPath + '"';
+ sb[sb.length] = ' title="' + this.getStateText() + '"';
+ sb[sb.length] = ' class="ygtvspacer"';
+ // sb[sb.length] = ' onkeypress="return ' + getNode + '".onKeyPress()"';
+ sb[sb.length] = ' />';
+ */
+
+ sb[sb.length] = ' ';
+
+ sb[sb.length] = '</td>';
+ sb[sb.length] = '<td>';
+ sb[sb.length] = '<a';
+ sb[sb.length] = ' id="' + this.labelElId + '"';
+ sb[sb.length] = ' class="' + this.labelStyle + '"';
+ sb[sb.length] = ' href="' + this.href + '"';
+ sb[sb.length] = ' target="' + this.target + '"';
+ sb[sb.length] = ' onclick="return ' + getNode + '.onLabelClick(' + getNode +')"';
+ if (this.hasChildren(true)) {
+ sb[sb.length] = ' onmouseover="document.getElementById(\'';
+ sb[sb.length] = this.getToggleElId() + '\').className=';
+ sb[sb.length] = getNode + '.getHoverStyle()"';
+ sb[sb.length] = ' onmouseout="document.getElementById(\'';
+ sb[sb.length] = this.getToggleElId() + '\').className=';
+ sb[sb.length] = getNode + '.getStyle()"';
+ }
+ sb[sb.length] = ' >';
+ sb[sb.length] = this.label;
+ sb[sb.length] = '</a>';
+ sb[sb.length] = '</td>';
+ sb[sb.length] = '</tr>';
+ sb[sb.length] = '</table>';
+
+ return sb.join("");
+};
+
+
+/**
+ * Executed when the label is clicked
+ * @param me {Node} this node
+ * @scope the anchor tag clicked
+ * @return false to cancel the anchor click
+ */
+YAHOO.widget.TextNode.prototype.onLabelClick = function(me) {
+ me.logger.log("onLabelClick " + this.label);
+ //return true;
+};
+
+YAHOO.widget.TextNode.prototype.toString = function() {
+ return "TextNode (" + this.index + ") " + this.label;
+};
+
+/**
+ * A menu-specific implementation that differs from TextNode in that only
+ * one sibling can be expanded at a time.
+ * @extends YAHOO.widget.TextNode
+ * @constructor
+ */
+YAHOO.widget.MenuNode = function(oData, oParent, expanded) {
+ if (oData) {
+ this.init(oData, oParent, expanded);
+ this.setUpLabel(oData);
+ }
+
+ /**
+ * Menus usually allow only one branch to be open at a time.
+ * @type boolean
+ */
+ this.multiExpand = false;
+
+ /**
+ * @private
+ */
+ this.logger = new YAHOO.widget.LogWriter(this.toString());
+
+};
+
+YAHOO.widget.MenuNode.prototype = new YAHOO.widget.TextNode();
+
+YAHOO.widget.MenuNode.prototype.toString = function() {
+ return "MenuNode (" + this.index + ") " + this.label;
+};
+
+/**
+ * This implementation takes either a string or object for the
+ * oData argument. If is it a string, we will use it for the display
+ * of this node (and it can contain any html code). If the parameter
+ * is an object, we look for a parameter called "html" that will be
+ * used for this node's display.
+ *
+ * @extends YAHOO.widget.Node
+ * @constructor
+ * @param oData {object} a string or object containing the data that will
+ * be used to render this node
+ * @param oParent {YAHOO.widget.Node} this node's parent node
+ * @param expanded {boolean} the initial expanded/collapsed state
+ * @param hasIcon {boolean} specifies whether or not leaf nodes should
+ * have an icon
+ */
+YAHOO.widget.HTMLNode = function(oData, oParent, expanded, hasIcon) {
+ if (oData) {
+ this.init(oData, oParent, expanded);
+ this.initContent(oData, hasIcon);
+ }
+};
+
+YAHOO.widget.HTMLNode.prototype = new YAHOO.widget.Node();
+
+/**
+ * The CSS class for the html content container. Defaults to ygtvhtml, but
+ * can be overridden to provide a custom presentation for a specific node.
+ *
+ * @type string
+ */
+YAHOO.widget.HTMLNode.prototype.contentStyle = "ygtvhtml";
+
+/**
+ * The generated id that will contain the data passed in by the implementer.
+ *
+ * @type string
+ */
+YAHOO.widget.HTMLNode.prototype.contentElId = null;
+
+/**
+ * The HTML content to use for this node's display
+ *
+ * @type string
+ */
+YAHOO.widget.HTMLNode.prototype.content = null;
+
+/**
+ * Sets up the node label
+ *
+ * @param {object} An html string or object containing an html property
+ * @param {boolean} hasIcon determines if the node will be rendered with an
+ * icon or not
+ */
+YAHOO.widget.HTMLNode.prototype.initContent = function(oData, hasIcon) {
+ if (typeof oData == "string") {
+ oData = { html: oData };
+ }
+
+ this.html = oData.html;
+ this.contentElId = "ygtvcontentel" + this.index;
+ this.hasIcon = hasIcon;
+
+ /**
+ * @private
+ */
+ this.logger = new YAHOO.widget.LogWriter(this.toString());
+};
+
+/**
+ * Returns the outer html element for this node's content
+ *
+ * @return {HTMLElement} the element
+ */
+YAHOO.widget.HTMLNode.prototype.getContentEl = function() {
+ return document.getElementById(this.contentElId);
+};
+
+// overrides YAHOO.widget.Node
+YAHOO.widget.HTMLNode.prototype.getNodeHtml = function() {
+ this.logger.log("Generating html");
+ var sb = [];
+
+ sb[sb.length] = '<table border="0" cellpadding="0" cellspacing="0">';
+ sb[sb.length] = '<tr>';
+
+ for (i=0;i<this.depth;++i) {
+ sb[sb.length] = '<td class="' + this.getDepthStyle(i) + '"> </td>';
+ }
+
+ if (this.hasIcon) {
+ sb[sb.length] = '<td';
+ sb[sb.length] = ' id="' + this.getToggleElId() + '"';
+ sb[sb.length] = ' class="' + this.getStyle() + '"';
+ sb[sb.length] = ' onclick="javascript:' + this.getToggleLink() + '"';
+ if (this.hasChildren(true)) {
+ sb[sb.length] = ' onmouseover="this.className=';
+ sb[sb.length] = 'YAHOO.widget.TreeView.getNode(\'';
+ sb[sb.length] = this.tree.id + '\',' + this.index + ').getHoverStyle()"';
+ sb[sb.length] = ' onmouseout="this.className=';
+ sb[sb.length] = 'YAHOO.widget.TreeView.getNode(\'';
+ sb[sb.length] = this.tree.id + '\',' + this.index + ').getStyle()"';
+ }
+ sb[sb.length] = '> </td>';
+ }
+
+ sb[sb.length] = '<td';
+ sb[sb.length] = ' id="' + this.contentElId + '"';
+ sb[sb.length] = ' class="' + this.contentStyle + '"';
+ sb[sb.length] = ' >';
+ sb[sb.length] = this.html;
+ sb[sb.length] = '</td>';
+ sb[sb.length] = '</tr>';
+ sb[sb.length] = '</table>';
+
+ return sb.join("");
+};
+
+YAHOO.widget.HTMLNode.prototype.toString = function() {
+ return "HTMLNode (" + this.index + ")";
+};
+
+/**
+ * A static factory class for tree view expand/collapse animations
+ *
+ * @constructor
+ */
+YAHOO.widget.TVAnim = function() {
+ return {
+ /**
+ * Constant for the fade in animation
+ *
+ * @type string
+ */
+ FADE_IN: "TVFadeIn",
+
+ /**
+ * Constant for the fade out animation
+ *
+ * @type string
+ */
+ FADE_OUT: "TVFadeOut",
+
+ /**
+ * Returns a ygAnim instance of the given type
+ *
+ * @param type {string} the type of animation
+ * @param el {HTMLElement} the element to element (probably the children div)
+ * @param callback {function} function to invoke when the animation is done.
+ * @return {YAHOO.util.Animation} the animation instance
+ */
+ getAnim: function(type, el, callback) {
+ if (YAHOO.widget[type]) {
+ return new YAHOO.widget[type](el, callback);
+ } else {
+ return null;
+ }
+ },
+
+ /**
+ * Returns true if the specified animation class is available
+ *
+ * @param type {string} the type of animation
+ * @return {boolean} true if valid, false if not
+ */
+ isValid: function(type) {
+ return (YAHOO.widget[type]);
+ }
+ };
+} ();
+
+/**
+ * A 1/2 second fade-in animation.
+ *
+ * @constructor
+ * @param el {HTMLElement} the element to animate
+ * @param callback {function} function to invoke when the animation is finished
+ */
+YAHOO.widget.TVFadeIn = function(el, callback) {
+ /**
+ * The element to animate
+ * @type HTMLElement
+ */
+ this.el = el;
+
+ /**
+ * the callback to invoke when the animation is complete
+ *
+ * @type function
+ */
+ this.callback = callback;
+
+ /**
+ * @private
+ */
+ this.logger = new YAHOO.widget.LogWriter(this.toString());
+};
+
+/**
+ * Performs the animation
+ */
+YAHOO.widget.TVFadeIn.prototype = {
+ animate: function() {
+ var tvanim = this;
+
+ var s = this.el.style;
+ s.opacity = 0.1;
+ s.filter = "alpha(opacity=10)";
+ s.display = "";
+
+ // var dur = ( navigator.userAgent.match(/msie/gi) ) ? 0.05 : 0.4;
+ var dur = 0.4;
+ // this.logger.log("duration: " + dur);
+ // var a = new ygAnim_Fade(this.el, dur, 1);
+ // a.setStart(0.1);
+ // a.onComplete = function() { tvanim.onComplete(); };
+
+ // var a = new YAHOO.util.Anim(this.el, 'opacity', 0.1, 1);
+ var a = new YAHOO.util.Anim(this.el, {opacity: {from: 0.1, to: 1, unit:""}}, dur);
+ a.onComplete.subscribe( function() { tvanim.onComplete(); } );
+ a.animate();
+ },
+
+ /**
+ * Clean up and invoke callback
+ */
+ onComplete: function() {
+ this.callback();
+ },
+
+ toString: function() {
+ return "TVFadeIn";
+ }
+};
+
+/**
+ * A 1/2 second fade out animation.
+ *
+ * @constructor
+ * @param el {HTMLElement} the element to animate
+ * @param callback {Function} function to invoke when the animation is finished
+ */
+YAHOO.widget.TVFadeOut = function(el, callback) {
+ /**
+ * The element to animate
+ * @type HTMLElement
+ */
+ this.el = el;
+
+ /**
+ * the callback to invoke when the animation is complete
+ *
+ * @type function
+ */
+ this.callback = callback;
+
+ /**
+ * @private
+ */
+ this.logger = new YAHOO.widget.LogWriter(this.toString());
+};
+
+/**
+ * Performs the animation
+ */
+YAHOO.widget.TVFadeOut.prototype = {
+ animate: function() {
+ var tvanim = this;
+ // var dur = ( navigator.userAgent.match(/msie/gi) ) ? 0.05 : 0.4;
+ var dur = 0.4;
+ // this.logger.log("duration: " + dur);
+ // var a = new ygAnim_Fade(this.el, dur, 0.1);
+ // a.onComplete = function() { tvanim.onComplete(); };
+
+ // var a = new YAHOO.util.Anim(this.el, 'opacity', 1, 0.1);
+ var a = new YAHOO.util.Anim(this.el, {opacity: {from: 1, to: 0.1, unit:""}}, dur);
+ a.onComplete.subscribe( function() { tvanim.onComplete(); } );
+ a.animate();
+ },
+
+ /**
+ * Clean up and invoke callback
+ */
+ onComplete: function() {
+ var s = this.el.style;
+ s.display = "none";
+ // s.opacity = 1;
+ s.filter = "alpha(opacity=100)";
+ this.callback();
+ },
+
+ toString: function() {
+ return "TVFadeOut";
+ }
+};
+
Added: branches/tomek/portal-dnd/dndRenderer.war/js/treeview/treeview-min.js
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/treeview/treeview-min.js 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/treeview/treeview-min.js 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1 @@
+/* Copyright (c) 2006, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.net/yui/license.txt version: 0.11.0 */ YAHOO.widget.TreeView=function(id){if(id){this.init(id);}};YAHOO.widget.TreeView.nodeCount=0;YAHOO.widget.TreeView.prototype={id:null,_el:null,_nodes:null,locked:false,_expandAnim:null,_collapseAnim:null,_animCount:0,maxAnim:!
2,setExpandAnim:function(_2){if(YAHOO.widget.TVAnim.isValid(_2)){this._expandAnim=_2;}},setCollapseAnim:function(_3){if(YAHOO.widget.TVAnim.isValid(_3)){this._collapseAnim=_3;}},animateExpand:function(el){if(this._expandAnim&&this._animCount<this.maxAnim){var _5=this;var a=YAHOO.widget.TVAnim.getAnim(this._expandAnim,el,function(){_5.expandComplete();});if(a){++this._animCount;a.animate();}return true;}return false;},animateCollapse:function(el){if(this._collapseAnim&&this._animCount<this.maxAnim){var _7=this;var a=YAHOO.widget.TVAnim.getAnim(this._collapseAnim,el,function(){_7.collapseComplete();});if(a){++this._animCount;a.animate();}return true;}return false;},expandComplete:function(){--this._animCount;},collapseComplete:function(){--this._animCount;},init:function(id){this.id=id;if("string"!==typeof id){this._el=id;this.id=this.generateId(id);}this._nodes=[];YAHOO.widget.TreeView.trees[this.id]=this;this.root=new YAHOO.widget.RootNode(this);},draw:function(){var _8=thi!
s.root.getHtml();this.getEl().innerHTML=_8;this.firstDraw=false;},getE
l:function(){if(!this._el){this._el=document.getElementById(this.id);}return this._el;},regNode:function(_9){this._nodes[_9.index]=_9;},getRoot:function(){return this.root;},setDynamicLoad:function(_10,_11){this.root.setDynamicLoad(_10,_11);},expandAll:function(){if(!this.locked){this.root.expandAll();}},collapseAll:function(){if(!this.locked){this.root.collapseAll();}},getNodeByIndex:function(_12){var n=this._nodes[_12];return (n)?n:null;},getNodeByProperty:function(_14,_15){for(var i in this._nodes){var n=this._nodes[i];if(n.data&&_15==n.data[_14]){return n;}}return null;},getNodesByProperty:function(_17,_18){var _19=[];for(var i in this._nodes){var n=this._nodes[i];if(n.data&&_18==n.data[_17]){_19.push(n);}}return (_19.length)?_19:null;},removeNode:function(_20,_21){if(_20.isRoot()){return false;}var p=_20.parent;if(p.parent){p=p.parent;}this._deleteNode(_20);if(_21&&p&&p.childrenRendered){p.refresh();}return true;},removeChildren:function(_23){while(_23.children.length){!
this._deleteNode(_23.children[0]);}_23.childrenRendered=false;_23.dynamicLoadComplete=false;_23.expand();_23.collapse();},_deleteNode:function(_24){this.removeChildren(_24);this.popNode(_24);},popNode:function(_25){var p=_25.parent;var a=[];for(var i=0,len=p.children.length;i<len;++i){if(p.children[i]!=_25){a[a.length]=p.children[i];}}p.children=a;p.childrenRendered=false;if(_25.previousSibling){_25.previousSibling.nextSibling=_25.nextSibling;}if(_25.nextSibling){_25.nextSibling.previousSibling=_25.previousSibling;}delete this._nodes[_25.index];},toString:function(){return "TreeView "+this.id;},generateId:function(el){var id=el.id;if(!id){id="yui-tv-auto-id-"+YAHOO.widget.TreeView.counter;YAHOO.widget.TreeView.counter++;}return id;},onExpand:function(_26){},onCollapse:function(_27){}};YAHOO.widget.TreeView.trees=[];YAHOO.widget.TreeView.counter=0;YAHOO.widget.TreeView.getTree=function(_28){var t=YAHOO.widget.TreeView.trees[_28];return (t)?t:null;};YAHOO.widget.TreeView.getN!
ode=function(_30,_31){var t=YAHOO.widget.TreeView.getTree(_30);return
(t)?t.getNodeByIndex(_31):null;};YAHOO.widget.TreeView.addHandler=function(el,_32,fn,_34){_34=(_34)?true:false;if(el.addEventListener){el.addEventListener(_32,fn,_34);}else{if(el.attachEvent){el.attachEvent("on"+_32,fn);}else{el["on"+_32]=fn;}}};YAHOO.widget.TreeView.preload=function(_35){_35=_35||"ygtv";var _36=["tn","tm","tmh","tp","tph","ln","lm","lmh","lp","lph","loading"];var sb=[];for(var i=0;i<_36.length;++i){sb[sb.length]="<span class=\""+_35+_36[i]+"\"> </span>";}var f=document.createElement("DIV");var s=f.style;s.position="absolute";s.top="-1000px";s.left="-1000px";f.innerHTML=sb.join("");document.body.appendChild(f);};YAHOO.widget.TreeView.addHandler(window,"load",YAHOO.widget.TreeView.preload);YAHOO.widget.Node=function(_40,_41,_42){if(_40){this.init(_40,_41,_42);}};YAHOO.widget.Node.prototype={index:0,children:null,tree:null,data:null,parent:null,depth:-1,href:null,target:"_self",expanded:false,multiExpand:true,renderHidden:false,childrenRendered:false,dyna!
micLoadComplete:false,previousSibling:null,nextSibling:null,_dynLoad:false,dataLoader:null,isLoading:false,hasIcon:true,iconMode:0,_type:"Node",init:function(_43,_44,_45){this.data=_43;this.children=[];this.index=YAHOO.widget.TreeView.nodeCount;++YAHOO.widget.TreeView.nodeCount;this.expanded=_45;if(_44){_44.appendChild(this);}},applyParent:function(_46){if(!_46){return false;}this.tree=_46.tree;this.parent=_46;this.depth=_46.depth+1;if(!this.href){this.href="javascript:"+this.getToggleLink();}if(!this.multiExpand){this.multiExpand=_46.multiExpand;}this.tree.regNode(this);_46.childrenRendered=false;for(var i=0,len=this.children.length;i<len;++i){this.children[i].applyParent(this);}return true;},appendChild:function(_47){if(this.hasChildren()){var sib=this.children[this.children.length-1];sib.nextSibling=_47;_47.previousSibling=sib;}this.children[this.children.length]=_47;_47.applyParent(this);return _47;},appendTo:function(_49){return _49.appendChild(this);},insertBefore:fun!
ction(_50){var p=_50.parent;if(p){if(this.tree){this.tree.popNode(this
);}var _51=_50.isChildOf(p);p.children.splice(_51,0,this);if(_50.previousSibling){_50.previousSibling.nextSibling=this;}this.previousSibling=_50.previousSibling;this.nextSibling=_50;_50.previousSibling=this;this.applyParent(p);}return this;},insertAfter:function(_52){var p=_52.parent;if(p){if(this.tree){this.tree.popNode(this);}var _53=_52.isChildOf(p);if(!_52.nextSibling){return this.appendTo(p);}p.children.splice(_53+1,0,this);_52.nextSibling.previousSibling=this;this.previousSibling=_52;this.nextSibling=_52.nextSibling;_52.nextSibling=this;this.applyParent(p);}return this;},isChildOf:function(_54){if(_54&&_54.children){for(var i=0,len=_54.children.length;i<len;++i){if(_54.children[i]===this){return i;}}}return -1;},getSiblings:function(){return this.parent.children;},showChildren:function(){if(!this.tree.animateExpand(this.getChildrenEl())){if(this.hasChildren()){this.getChildrenEl().style.display="";}}},hideChildren:function(){if(!this.tree.animateCollapse(this.getChildr!
enEl())){this.getChildrenEl().style.display="none";}},getElId:function(){return "ygtv"+this.index;},getChildrenElId:function(){return "ygtvc"+this.index;},getToggleElId:function(){return "ygtvt"+this.index;},getEl:function(){return document.getElementById(this.getElId());},getChildrenEl:function(){return document.getElementById(this.getChildrenElId());},getToggleEl:function(){return document.getElementById(this.getToggleElId());},getToggleLink:function(){return "YAHOO.widget.TreeView.getNode('"+this.tree.id+"',"+this.index+").toggle()";},collapse:function(){if(!this.expanded){return;}var ret=this.tree.onCollapse(this);if("undefined"!=typeof ret&&!ret){return;}if(!this.getEl()){this.expanded=false;return;}this.hideChildren();this.expanded=false;if(this.hasIcon){this.getToggleEl().className=this.getStyle();}},expand:function(){if(this.expanded){return;}var ret=this.tree.onExpand(this);if("undefined"!=typeof ret&&!ret){return;}if(!this.getEl()){this.expanded=true;return;}if(!t!
his.childrenRendered){this.getChildrenEl().innerHTML=this.renderChildr
en();}else{}this.expanded=true;if(this.hasIcon){this.getToggleEl().className=this.getStyle();}if(this.isLoading){this.expanded=false;return;}if(!this.multiExpand){var _56=this.getSiblings();for(var i=0;i<_56.length;++i){if(_56[i]!=this&&_56[i].expanded){_56[i].collapse();}}}this.showChildren();},getStyle:function(){if(this.isLoading){return "ygtvloading";}else{var loc=(this.nextSibling)?"t":"l";var _58="n";if(this.hasChildren(true)||(this.isDynamic()&&!this.getIconMode())){_58=(this.expanded)?"m":"p";}return "ygtv"+loc+_58;}},getHoverStyle:function(){var s=this.getStyle();if(this.hasChildren(true)&&!this.isLoading){s+="h";}return s;},expandAll:function(){for(var i=0;i<this.children.length;++i){var c=this.children[i];if(c.isDynamic()){alert("Not supported (lazy load + expand all)");break;}else{if(!c.multiExpand){alert("Not supported (no multi-expand + expand all)");break;}else{c.expand();c.expandAll();}}}},collapseAll:function(){for(var i=0;i<this.children.length;++i){this.ch!
ildren[i].collapse();this.children[i].collapseAll();}},setDynamicLoad:function(_60,_61){if(_60){this.dataLoader=_60;this._dynLoad=true;}else{this.dataLoader=null;this._dynLoad=false;}if(_61){this.iconMode=_61;}},isRoot:function(){return (this==this.tree.root);},isDynamic:function(){var _62=(!this.isRoot()&&(this._dynLoad||this.tree.root._dynLoad));return _62;},getIconMode:function(){return (this.iconMode||this.tree.root.iconMode);},hasChildren:function(_63){return (this.children.length>0||(_63&&this.isDynamic()&&!this.dynamicLoadComplete));},toggle:function(){if(!this.tree.locked&&(this.hasChildren(true)||this.isDynamic())){if(this.expanded){this.collapse();}else{this.expand();}}},getHtml:function(){var sb=[];sb[sb.length]="<div class=\"ygtvitem\" id=\""+this.getElId()+"\">";sb[sb.length]=this.getNodeHtml();sb[sb.length]=this.getChildrenHtml();sb[sb.length]="</div>";return sb.join("");},getChildrenHtml:function(){var sb=[];sb[sb.length]="<div class=\"ygtvchildren\"";sb[sb.l!
ength]=" id=\""+this.getChildrenElId()+"\"";if(!this.expanded){sb[sb.l
ength]=" style=\"display:none;\"";}sb[sb.length]=">";if((this.hasChildren(true)&&this.expanded)||(this.renderHidden&&!this.isDynamic())){sb[sb.length]=this.renderChildren();}sb[sb.length]="</div>";return sb.join("");},renderChildren:function(){var _64=this;if(this.isDynamic()&&!this.dynamicLoadComplete){this.isLoading=true;this.tree.locked=true;if(this.dataLoader){setTimeout(function(){_64.dataLoader(_64,function(){_64.loadComplete();});},10);}else{if(this.tree.root.dataLoader){setTimeout(function(){_64.tree.root.dataLoader(_64,function(){_64.loadComplete();});},10);}else{return "Error: data loader not found or not specified.";}}return "";}else{return this.completeRender();}},completeRender:function(){var sb=[];for(var i=0;i<this.children.length;++i){this.children[i].childrenRendered=false;sb[sb.length]=this.children[i].getHtml();}this.childrenRendered=true;return sb.join("");},loadComplete:function(){this.getChildrenEl().innerHTML=this.completeRender();this.dynamicLoadCompl!
ete=true;this.isLoading=false;this.expand();this.tree.locked=false;},getAncestor:function(_65){if(_65>=this.depth||_65<0){return null;}var p=this.parent;while(p.depth>_65){p=p.parent;}return p;},getDepthStyle:function(_66){return (this.getAncestor(_66).nextSibling)?"ygtvdepthcell":"ygtvblankdepthcell";},getNodeHtml:function(){return "";},refresh:function(){this.getChildrenEl().innerHTML=this.completeRender();if(this.hasIcon){var el=this.getToggleEl();if(el){el.className=this.getStyle();}}},toString:function(){return "Node ("+this.index+")";}};YAHOO.widget.RootNode=function(_67){this.init(null,null,true);this.tree=_67;};YAHOO.widget.RootNode.prototype=new YAHOO.widget.Node();YAHOO.widget.RootNode.prototype.getNodeHtml=function(){return "";};YAHOO.widget.RootNode.prototype.toString=function(){return "RootNode";};YAHOO.widget.RootNode.prototype.loadComplete=function(){this.tree.draw();};YAHOO.widget.TextNode=function(_68,_69,_70){if(_68){this.init(_68,_69,_70);this.setUpLabel(!
_68);}};YAHOO.widget.TextNode.prototype=new YAHOO.widget.Node();YAHOO.
widget.TextNode.prototype.labelStyle="ygtvlabel";YAHOO.widget.TextNode.prototype.labelElId=null;YAHOO.widget.TextNode.prototype.label=null;YAHOO.widget.TextNode.prototype.setUpLabel=function(_71){if(typeof _71=="string"){_71={label:_71};}this.label=_71.label;if(_71.href){this.href=_71.href;}if(_71.target){this.target=_71.target;}if(_71.style){this.labelStyle=_71.style;}this.labelElId="ygtvlabelel"+this.index;};YAHOO.widget.TextNode.prototype.getLabelEl=function(){return document.getElementById(this.labelElId);};YAHOO.widget.TextNode.prototype.getNodeHtml=function(){var sb=[];sb[sb.length]="<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";sb[sb.length]="<tr>";for(i=0;i<this.depth;++i){sb[sb.length]="<td class=\""+this.getDepthStyle(i)+"\"> </td>";}var _72="YAHOO.widget.TreeView.getNode('"+this.tree.id+"',"+this.index+")";sb[sb.length]="<td";sb[sb.length]=" id=\""+this.getToggleElId()+"\"";sb[sb.length]=" class=\""+this.getStyle()+"\"";if(this.hasChildren(true)){!
sb[sb.length]=" onmouseover=\"this.className=";sb[sb.length]=_72+".getHoverStyle()\"";sb[sb.length]=" onmouseout=\"this.className=";sb[sb.length]=_72+".getStyle()\"";}sb[sb.length]=" onclick=\"javascript:"+this.getToggleLink()+"\">";sb[sb.length]=" ";sb[sb.length]="</td>";sb[sb.length]="<td>";sb[sb.length]="<a";sb[sb.length]=" id=\""+this.labelElId+"\"";sb[sb.length]=" class=\""+this.labelStyle+"\"";sb[sb.length]=" href=\""+this.href+"\"";sb[sb.length]=" target=\""+this.target+"\"";sb[sb.length]=" onclick=\"return "+_72+".onLabelClick("+_72+")\"";if(this.hasChildren(true)){sb[sb.length]=" onmouseover=\"document.getElementById('";sb[sb.length]=this.getToggleElId()+"').className=";sb[sb.length]=_72+".getHoverStyle()\"";sb[sb.length]=" onmouseout=\"document.getElementById('";sb[sb.length]=this.getToggleElId()+"').className=";sb[sb.length]=_72+".getStyle()\"";}sb[sb.length]=" >";sb[sb.length]=this.label;sb[sb.length]="</a>";sb[sb.length]="</td>";sb[sb.length]="</tr>";sb[sb!
.length]="</table>";return sb.join("");};YAHOO.widget.TextNode.prototy
pe.onLabelClick=function(me){};YAHOO.widget.TextNode.prototype.toString=function(){return "TextNode ("+this.index+") "+this.label;};YAHOO.widget.MenuNode=function(_74,_75,_76){if(_74){this.init(_74,_75,_76);this.setUpLabel(_74);}this.multiExpand=false;};YAHOO.widget.MenuNode.prototype=new YAHOO.widget.TextNode();YAHOO.widget.MenuNode.prototype.toString=function(){return "MenuNode ("+this.index+") "+this.label;};YAHOO.widget.HTMLNode=function(_77,_78,_79,_80){if(_77){this.init(_77,_78,_79);this.initContent(_77,_80);}};YAHOO.widget.HTMLNode.prototype=new YAHOO.widget.Node();YAHOO.widget.HTMLNode.prototype.contentStyle="ygtvhtml";YAHOO.widget.HTMLNode.prototype.contentElId=null;YAHOO.widget.HTMLNode.prototype.content=null;YAHOO.widget.HTMLNode.prototype.initContent=function(_81,_82){if(typeof _81=="string"){_81={html:_81};}this.html=_81.html;this.contentElId="ygtvcontentel"+this.index;this.hasIcon=_82;};YAHOO.widget.HTMLNode.prototype.getContentEl=function(){return document.get!
ElementById(this.contentElId);};YAHOO.widget.HTMLNode.prototype.getNodeHtml=function(){var sb=[];sb[sb.length]="<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\">";sb[sb.length]="<tr>";for(i=0;i<this.depth;++i){sb[sb.length]="<td class=\""+this.getDepthStyle(i)+"\"> </td>";}if(this.hasIcon){sb[sb.length]="<td";sb[sb.length]=" id=\""+this.getToggleElId()+"\"";sb[sb.length]=" class=\""+this.getStyle()+"\"";sb[sb.length]=" onclick=\"javascript:"+this.getToggleLink()+"\"";if(this.hasChildren(true)){sb[sb.length]=" onmouseover=\"this.className=";sb[sb.length]="YAHOO.widget.TreeView.getNode('";sb[sb.length]=this.tree.id+"',"+this.index+").getHoverStyle()\"";sb[sb.length]=" onmouseout=\"this.className=";sb[sb.length]="YAHOO.widget.TreeView.getNode('";sb[sb.length]=this.tree.id+"',"+this.index+").getStyle()\"";}sb[sb.length]="> </td>";}sb[sb.length]="<td";sb[sb.length]=" id=\""+this.contentElId+"\"";sb[sb.length]=" class=\""+this.contentStyle+"\"";sb[sb.length]=" >"!
;sb[sb.length]=this.html;sb[sb.length]="</td>";sb[sb.length]="</tr>";s
b[sb.length]="</table>";return sb.join("");};YAHOO.widget.HTMLNode.prototype.toString=function(){return "HTMLNode ("+this.index+")";};YAHOO.widget.TVAnim=function(){return {FADE_IN:"TVFadeIn",FADE_OUT:"TVFadeOut",getAnim:function(_83,el,_84){if(YAHOO.widget[_83]){return new YAHOO.widget[_83](el,_84);}else{return null;}},isValid:function(_85){return (YAHOO.widget[_85]);}};}();YAHOO.widget.TVFadeIn=function(el,_86){this.el=el;this.callback=_86;};YAHOO.widget.TVFadeIn.prototype={animate:function(){var _87=this;var s=this.el.style;s.opacity=0.1;s.filter="alpha(opacity=10)";s.display="";var dur=0.4;var a=new YAHOO.util.Anim(this.el,{opacity:{from:0.1,to:1,unit:""}},dur);a.onComplete.subscribe(function(){_87.onComplete();});a.animate();},onComplete:function(){this.callback();},toString:function(){return "TVFadeIn";}};YAHOO.widget.TVFadeOut=function(el,_89){this.el=el;this.callback=_89;};YAHOO.widget.TVFadeOut.prototype={animate:function(){var _90=this;var dur=0.4;var a=new YAHOO.u!
til.Anim(this.el,{opacity:{from:1,to:0.1,unit:""}},dur);a.onComplete.subscribe(function(){_90.onComplete();});a.animate();},onComplete:function(){var s=this.el.style;s.display="none";s.filter="alpha(opacity=100)";this.callback();},toString:function(){return "TVFadeOut";}};
\ No newline at end of file
Added: branches/tomek/portal-dnd/dndRenderer.war/js/treeview/treeview.js
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/treeview/treeview.js 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/treeview/treeview.js 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,1960 @@
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 0.11.0
+*/
+
+/**
+ * Contains the tree view state data and the root node. This is an
+ * ordered tree; child nodes will be displayed in the order created, and
+ * there currently is no way to change this.
+ *
+ * @constructor
+ * @param {string|HTMLElement} id The id of the element, or the element
+ * itself that the tree will be inserted into.
+ */
+YAHOO.widget.TreeView = function(id) {
+ if (id) { this.init(id); }
+};
+
+/**
+ * Count of all nodes in all trees
+ * @type int
+ */
+YAHOO.widget.TreeView.nodeCount = 0;
+
+YAHOO.widget.TreeView.prototype = {
+
+ /**
+ * The id of tree container element
+ *
+ * @type String
+ */
+ id: null,
+
+ /**
+ * The host element for this tree
+ * @private
+ */
+ _el: null,
+
+ /**
+ * Flat collection of all nodes in this tree
+ *
+ * @type Node[]
+ * @private
+ */
+ _nodes: null,
+
+ /**
+ * We lock the tree control while waiting for the dynamic loader to return
+ *
+ * @type boolean
+ */
+ locked: false,
+
+ /**
+ * The animation to use for expanding children, if any
+ *
+ * @type string
+ * @private
+ */
+ _expandAnim: null,
+
+ /**
+ * The animation to use for collapsing children, if any
+ *
+ * @type string
+ * @private
+ */
+ _collapseAnim: null,
+
+ /**
+ * The current number of animations that are executing
+ *
+ * @type int
+ * @private
+ */
+ _animCount: 0,
+
+ /**
+ * The maximum number of animations to run at one time.
+ *
+ * @type int
+ */
+ maxAnim: 2,
+
+ /**
+ * Sets up the animation for expanding children
+ *
+ * @param {string} the type of animation (acceptable values defined in
+ * YAHOO.widget.TVAnim)
+ */
+ setExpandAnim: function(type) {
+ if (YAHOO.widget.TVAnim.isValid(type)) {
+ this._expandAnim = type;
+ }
+ },
+
+ /**
+ * Sets up the animation for collapsing children
+ *
+ * @param {string} the type of animation (acceptable values defined in
+ * YAHOO.widget.TVAnim)
+ */
+ setCollapseAnim: function(type) {
+ if (YAHOO.widget.TVAnim.isValid(type)) {
+ this._collapseAnim = type;
+ }
+ },
+
+ /**
+ * Perform the expand animation if configured, or just show the
+ * element if not configured or too many animations are in progress
+ *
+ * @param el {HTMLElement} the element to animate
+ * @return {boolean} true if animation could be invoked, false otherwise
+ */
+ animateExpand: function(el) {
+
+ if (this._expandAnim && this._animCount < this.maxAnim) {
+ // this.locked = true;
+ var tree = this;
+ var a = YAHOO.widget.TVAnim.getAnim(this._expandAnim, el,
+ function() { tree.expandComplete(); });
+ if (a) {
+ ++this._animCount;
+ a.animate();
+ }
+
+ return true;
+ }
+
+ return false;
+ },
+
+ /**
+ * Perform the collapse animation if configured, or just show the
+ * element if not configured or too many animations are in progress
+ *
+ * @param el {HTMLElement} the element to animate
+ * @return {boolean} true if animation could be invoked, false otherwise
+ */
+ animateCollapse: function(el) {
+
+ if (this._collapseAnim && this._animCount < this.maxAnim) {
+ // this.locked = true;
+ var tree = this;
+ var a = YAHOO.widget.TVAnim.getAnim(this._collapseAnim, el,
+ function() { tree.collapseComplete(); });
+ if (a) {
+ ++this._animCount;
+ a.animate();
+ }
+
+ return true;
+ }
+
+ return false;
+ },
+
+ /**
+ * Function executed when the expand animation completes
+ */
+ expandComplete: function() {
+ --this._animCount;
+ // this.locked = false;
+ },
+
+ /**
+ * Function executed when the collapse animation completes
+ */
+ collapseComplete: function() {
+ --this._animCount;
+ // this.locked = false;
+ },
+
+ /**
+ * Initializes the tree
+ *
+ * @parm {string|HTMLElement} id the id of the element that will hold the tree
+ * @private
+ */
+ init: function(id) {
+
+ this.id = id;
+
+ if ("string" !== typeof id) {
+ this._el = id;
+ this.id = this.generateId(id);
+ }
+
+ this._nodes = [];
+
+ // store a global reference
+ YAHOO.widget.TreeView.trees[this.id] = this;
+
+ // Set up the root node
+ this.root = new YAHOO.widget.RootNode(this);
+
+
+ },
+
+ /**
+ * Renders the tree boilerplate and visible nodes
+ */
+ draw: function() {
+ var html = this.root.getHtml();
+ this.getEl().innerHTML = html;
+ this.firstDraw = false;
+ },
+
+ /**
+ * Returns the tree's host element
+ * @return {HTMLElement} the host element
+ */
+ getEl: function() {
+ if (! this._el) {
+ this._el = document.getElementById(this.id);
+ }
+ return this._el;
+ },
+
+ /**
+ * Nodes register themselves with the tree instance when they are created.
+ *
+ * @param node {Node} the node to register
+ * @private
+ */
+ regNode: function(node) {
+ this._nodes[node.index] = node;
+ },
+
+ /**
+ * Returns the root node of this tree
+ *
+ * @return {Node} the root node
+ */
+ getRoot: function() {
+ return this.root;
+ },
+
+ /**
+ * Configures this tree to dynamically load all child data
+ *
+ * @param {function} fnDataLoader the function that will be called to get the data
+ * @param iconMode {int} configures the icon that is displayed when a dynamic
+ * load node is expanded the first time without children. By default, the
+ * "collapse" icon will be used. If set to 1, the leaf node icon will be
+ * displayed.
+ */
+ setDynamicLoad: function(fnDataLoader, iconMode) {
+ this.root.setDynamicLoad(fnDataLoader, iconMode);
+ },
+
+ /**
+ * Expands all child nodes. Note: this conflicts with the "multiExpand"
+ * node property. If expand all is called in a tree with nodes that
+ * do not allow multiple siblings to be displayed, only the last sibling
+ * will be expanded.
+ */
+ expandAll: function() {
+ if (!this.locked) {
+ this.root.expandAll();
+ }
+ },
+
+ /**
+ * Collapses all expanded child nodes in the entire tree.
+ */
+ collapseAll: function() {
+ if (!this.locked) {
+ this.root.collapseAll();
+ }
+ },
+
+ /**
+ * Returns a node in the tree that has the specified index (this index
+ * is created internally, so this function probably will only be used
+ * in html generated for a given node.)
+ *
+ * @param {int} nodeIndex the index of the node wanted
+ * @return {Node} the node with index=nodeIndex, null if no match
+ */
+ getNodeByIndex: function(nodeIndex) {
+ var n = this._nodes[nodeIndex];
+ return (n) ? n : null;
+ },
+
+ /**
+ * Returns a node that has a matching property and value in the data
+ * object that was passed into its constructor.
+ *
+ * @param {object} property the property to search (usually a string)
+ * @param {object} value the value we want to find (usuall an int or string)
+ * @return {Node} the matching node, null if no match
+ */
+ getNodeByProperty: function(property, value) {
+ for (var i in this._nodes) {
+ var n = this._nodes[i];
+ if (n.data && value == n.data[property]) {
+ return n;
+ }
+ }
+
+ return null;
+ },
+
+ /**
+ * Returns a collection of nodes that have a matching property
+ * and value in the data object that was passed into its constructor.
+ *
+ * @param {object} property the property to search (usually a string)
+ * @param {object} value the value we want to find (usuall an int or string)
+ * @return {Array} the matching collection of nodes, null if no match
+ */
+ getNodesByProperty: function(property, value) {
+ var values = [];
+ for (var i in this._nodes) {
+ var n = this._nodes[i];
+ if (n.data && value == n.data[property]) {
+ values.push(n);
+ }
+ }
+
+ return (values.length) ? values : null;
+ },
+
+ /**
+ * Removes the node and its children, and optionally refreshes the branch
+ * of the tree that was affected.
+ * @param {Node} The node to remove
+ * @param {boolean} autoRefresh automatically refreshes branch if true
+ * @return {boolean} False is there was a problem, true otherwise.
+ */
+ removeNode: function(node, autoRefresh) {
+
+ // Don't delete the root node
+ if (node.isRoot()) {
+ return false;
+ }
+
+ // Get the branch that we may need to refresh
+ var p = node.parent;
+ if (p.parent) {
+ p = p.parent;
+ }
+
+ // Delete the node and its children
+ this._deleteNode(node);
+
+ // Refresh the parent of the parent
+ if (autoRefresh && p && p.childrenRendered) {
+ p.refresh();
+ }
+
+ return true;
+ },
+
+ /**
+ * Deletes this nodes child collection, recursively. Also collapses
+ * the node, and resets the dynamic load flag. The primary use for
+ * this method is to purge a node and allow it to fetch its data
+ * dynamically again.
+ * @param {Node} node the node to purge
+ */
+ removeChildren: function(node) {
+ while (node.children.length) {
+ this._deleteNode(node.children[0]);
+ }
+
+ node.childrenRendered = false;
+ node.dynamicLoadComplete = false;
+ // node.collapse();
+ node.expand();
+ node.collapse();
+ },
+
+ /**
+ * Deletes the node and recurses children
+ * @private
+ */
+ _deleteNode: function(node) {
+ // Remove all the child nodes first
+ this.removeChildren(node);
+
+ // Remove the node from the tree
+ this.popNode(node);
+ },
+
+ /**
+ * Removes the branch from the tree. This differs from removeNode in
+ * that the child collection is preserved to make it possible to
+ * insert the branch into another part of the tree, or another tree.
+ * @param {Node} the node to remove
+ */
+ popNode: function(node) {
+ var p = node.parent;
+
+ // Update the parent's collection of children
+ var a = [];
+
+ for (var i=0, len=p.children.length;i<len;++i) {
+ if (p.children[i] != node) {
+ a[a.length] = p.children[i];
+ }
+ }
+
+ p.children = a;
+
+ // reset the childrenRendered flag for the parent
+ p.childrenRendered = false;
+
+ // Update the sibling relationship
+ if (node.previousSibling) {
+ node.previousSibling.nextSibling = node.nextSibling;
+ }
+
+ if (node.nextSibling) {
+ node.nextSibling.previousSibling = node.previousSibling;
+ }
+
+ // Update the tree's node collection
+ delete this._nodes[node.index];
+ },
+
+ /**
+ * toString
+ * @return {string} string representation of the tree
+ */
+ toString: function() {
+ return "TreeView " + this.id;
+ },
+
+ /**
+ * private
+ */
+ generateId: function(el) {
+ var id = el.id;
+
+ if (!id) {
+ id = "yui-tv-auto-id-" + YAHOO.widget.TreeView.counter;
+ YAHOO.widget.TreeView.counter++;
+ }
+
+ return id;
+ },
+
+ /**
+ * Abstract method that is executed when a node is expanded
+ * @param node {Node} the node that was expanded
+ */
+ onExpand: function(node) { },
+
+ /**
+ * Abstract method that is executed when a node is collapsed
+ * @param node {Node} the node that was collapsed.
+ */
+ onCollapse: function(node) { }
+
+};
+
+/**
+ * Global cache of tree instances
+ *
+ * @type Array
+ * @private
+ */
+YAHOO.widget.TreeView.trees = [];
+
+/**
+ * @private
+ */
+YAHOO.widget.TreeView.counter = 0;
+
+/**
+ * Global method for getting a tree by its id. Used in the generated
+ * tree html.
+ *
+ * @param treeId {String} the id of the tree instance
+ * @return {TreeView} the tree instance requested, null if not found.
+ */
+YAHOO.widget.TreeView.getTree = function(treeId) {
+ var t = YAHOO.widget.TreeView.trees[treeId];
+ return (t) ? t : null;
+};
+
+/**
+ * Global method for getting a node by its id. Used in the generated
+ * tree html.
+ *
+ * @param treeId {String} the id of the tree instance
+ * @param nodeIndex {String} the index of the node to return
+ * @return {Node} the node instance requested, null if not found
+ */
+YAHOO.widget.TreeView.getNode = function(treeId, nodeIndex) {
+ var t = YAHOO.widget.TreeView.getTree(treeId);
+ return (t) ? t.getNodeByIndex(nodeIndex) : null;
+};
+
+/**
+ * Adds an event. Replace with event manager when available
+ *
+ * @param el the elment to bind the handler to
+ * @param {string} sType the type of event handler
+ * @param {function} fn the callback to invoke
+ * @param {boolean} capture if true event is capture phase, bubble otherwise
+ */
+YAHOO.widget.TreeView.addHandler = function (el, sType, fn, capture) {
+ capture = (capture) ? true : false;
+ if (el.addEventListener) {
+ el.addEventListener(sType, fn, capture);
+ } else if (el.attachEvent) {
+ el.attachEvent("on" + sType, fn);
+ } else {
+ el["on" + sType] = fn;
+ }
+};
+
+/**
+ * Attempts to preload the images defined in the styles used to draw the tree by
+ * rendering off-screen elements that use the styles.
+ */
+YAHOO.widget.TreeView.preload = function(prefix) {
+ prefix = prefix || "ygtv";
+ var styles = ["tn","tm","tmh","tp","tph","ln","lm","lmh","lp","lph","loading"];
+
+ var sb = [];
+
+ for (var i = 0; i < styles.length; ++i) {
+ sb[sb.length] = '<span class="' + prefix + styles[i] + '"> </span>';
+ }
+
+ var f = document.createElement("DIV");
+ var s = f.style;
+ s.position = "absolute";
+ s.top = "-1000px";
+ s.left = "-1000px";
+ f.innerHTML = sb.join("");
+
+ document.body.appendChild(f);
+};
+
+YAHOO.widget.TreeView.addHandler(window,
+ "load", YAHOO.widget.TreeView.preload);
+
+/**
+ * The base class for all tree nodes. The node's presentation and behavior in
+ * response to mouse events is handled in Node subclasses.
+ *
+ * @param oData {object} a string or object containing the data that will
+ * be used to render this node
+ * @param oParent {Node} this node's parent node
+ * @param expanded {boolean} the initial expanded/collapsed state
+ * @constructor
+ */
+YAHOO.widget.Node = function(oData, oParent, expanded) {
+ if (oData) { this.init(oData, oParent, expanded); }
+};
+
+YAHOO.widget.Node.prototype = {
+
+ /**
+ * The index for this instance obtained from global counter in YAHOO.widget.TreeView.
+ *
+ * @type int
+ */
+ index: 0,
+
+ /**
+ * This node's child node collection.
+ *
+ * @type Node[]
+ */
+ children: null,
+
+ /**
+ * Tree instance this node is part of
+ *
+ * @type TreeView
+ */
+ tree: null,
+
+ /**
+ * The data linked to this node. This can be any object or primitive
+ * value, and the data can be used in getNodeHtml().
+ *
+ * @type object
+ */
+ data: null,
+
+ /**
+ * Parent node
+ *
+ * @type Node
+ */
+ parent: null,
+
+ /**
+ * The depth of this node. We start at -1 for the root node.
+ *
+ * @type int
+ */
+ depth: -1,
+
+ /**
+ * The href for the node's label. If one is not specified, the href will
+ * be set so that it toggles the node.
+ *
+ * @type string
+ */
+ href: null,
+
+ /**
+ * The label href target, defaults to current window
+ *
+ * @type string
+ */
+ target: "_self",
+
+ /**
+ * The node's expanded/collapsed state
+ *
+ * @type boolean
+ */
+ expanded: false,
+
+ /**
+ * Can multiple children be expanded at once?
+ *
+ * @type boolean
+ */
+ multiExpand: true,
+
+ /**
+ * Should we render children for a collapsed node? It is possible that the
+ * implementer will want to render the hidden data... @todo verify that we
+ * need this, and implement it if we do.
+ *
+ * @type boolean
+ */
+ renderHidden: false,
+
+ /**
+ * This flag is set to true when the html is generated for this node's
+ * children, and set to false when new children are added.
+ * @type boolean
+ */
+ childrenRendered: false,
+
+ /**
+ * Dynamically loaded nodes only fetch the data the first time they are
+ * expanded. This flag is set to true once the data has been fetched.
+ * @type boolean
+ */
+ dynamicLoadComplete: false,
+
+ /**
+ * This node's previous sibling
+ *
+ * @type Node
+ */
+ previousSibling: null,
+
+ /**
+ * This node's next sibling
+ *
+ * @type Node
+ */
+ nextSibling: null,
+
+ /**
+ * We can set the node up to call an external method to get the child
+ * data dynamically.
+ *
+ * @type boolean
+ * @private
+ */
+ _dynLoad: false,
+
+ /**
+ * Function to execute when we need to get this node's child data.
+ *
+ * @type function
+ */
+ dataLoader: null,
+
+ /**
+ * This is true for dynamically loading nodes while waiting for the
+ * callback to return.
+ *
+ * @type boolean
+ */
+ isLoading: false,
+
+ /**
+ * The toggle/branch icon will not show if this is set to false. This
+ * could be useful if the implementer wants to have the child contain
+ * extra info about the parent, rather than an actual node.
+ *
+ * @type boolean
+ */
+ hasIcon: true,
+
+ /**
+ * Used to configure what happens when a dynamic load node is expanded
+ * and we discover that it does not have children. By default, it is
+ * treated as if it still could have children (plus/minus icon). Set
+ * iconMode to have it display like a leaf node instead.
+ * @type int
+ */
+ iconMode: 0,
+
+ /**
+ * The node type
+ * @private
+ */
+ _type: "Node",
+
+ /*
+ spacerPath: "http://us.i1.yimg.com/us.yimg.com/i/space.gif",
+ expandedText: "Expanded",
+ collapsedText: "Collapsed",
+ loadingText: "Loading",
+ */
+
+ /**
+ * Initializes this node, gets some of the properties from the parent
+ *
+ * @param oData {object} a string or object containing the data that will
+ * be used to render this node
+ * @param oParent {Node} this node's parent node
+ * @param expanded {boolean} the initial expanded/collapsed state
+ */
+ init: function(oData, oParent, expanded) {
+ this.data = oData;
+ this.children = [];
+ this.index = YAHOO.widget.TreeView.nodeCount;
+ ++YAHOO.widget.TreeView.nodeCount;
+ this.expanded = expanded;
+
+ // oParent should never be null except when we create the root node.
+ if (oParent) {
+ oParent.appendChild(this);
+ }
+ },
+
+ /**
+ * Certain properties for the node cannot be set until the parent
+ * is known. This is called after the node is inserted into a tree.
+ * the parent is also applied to this node's children in order to
+ * make it possible to move a branch from one tree to another.
+ * @param {Node} parentNode this node's parent node
+ */
+ applyParent: function(parentNode) {
+ if (!parentNode) {
+ return false;
+ }
+
+ this.tree = parentNode.tree;
+ this.parent = parentNode;
+ this.depth = parentNode.depth + 1;
+
+ if (! this.href) {
+ this.href = "javascript:" + this.getToggleLink();
+ }
+
+ if (! this.multiExpand) {
+ this.multiExpand = parentNode.multiExpand;
+ }
+
+ this.tree.regNode(this);
+ parentNode.childrenRendered = false;
+
+ // cascade update existing children
+ for (var i=0, len=this.children.length;i<len;++i) {
+ this.children[i].applyParent(this);
+ }
+
+ return true;
+ },
+
+ /**
+ * Appends a node to the child collection.
+ *
+ * @param childNode {Node} the new node
+ * @return {Node} the child node
+ * @private
+ */
+ appendChild: function(childNode) {
+ if (this.hasChildren()) {
+ var sib = this.children[this.children.length - 1];
+ sib.nextSibling = childNode;
+ childNode.previousSibling = sib;
+ }
+ this.children[this.children.length] = childNode;
+ childNode.applyParent(this);
+
+ return childNode;
+ },
+
+ /**
+ * Appends this node to the supplied node's child collection
+ * @param parentNode {Node} the node to append to.
+ */
+ appendTo: function(parentNode) {
+ return parentNode.appendChild(this);
+ },
+
+ /**
+ * Inserts this node before this supplied node
+ *
+ * @param node {Node} the node to insert this node before
+ * @return {Node} the inserted node
+ */
+ insertBefore: function(node) {
+ var p = node.parent;
+ if (p) {
+
+ if (this.tree) {
+ this.tree.popNode(this);
+ }
+
+ var refIndex = node.isChildOf(p);
+ p.children.splice(refIndex, 0, this);
+ if (node.previousSibling) {
+ node.previousSibling.nextSibling = this;
+ }
+ this.previousSibling = node.previousSibling;
+ this.nextSibling = node;
+ node.previousSibling = this;
+
+ this.applyParent(p);
+ }
+
+ return this;
+ },
+
+ /**
+ * Inserts this node after the supplied node
+ *
+ * @param node {Node} the node to insert after
+ * @return {Node} the inserted node
+ */
+ insertAfter: function(node) {
+ var p = node.parent;
+ if (p) {
+
+ if (this.tree) {
+ this.tree.popNode(this);
+ }
+
+ var refIndex = node.isChildOf(p);
+
+ if (!node.nextSibling) {
+ return this.appendTo(p);
+ }
+
+ p.children.splice(refIndex + 1, 0, this);
+
+ node.nextSibling.previousSibling = this;
+ this.previousSibling = node;
+ this.nextSibling = node.nextSibling;
+ node.nextSibling = this;
+
+ this.applyParent(p);
+ }
+
+ return this;
+ },
+
+ /**
+ * Returns true if the Node is a child of supplied Node
+ *
+ * @param parentNode {Node} the Node to check
+ * @return {boolean} The node index if this Node is a child of
+ * supplied Node, else -1.
+ * @private
+ */
+ isChildOf: function(parentNode) {
+ if (parentNode && parentNode.children) {
+ for (var i=0, len=parentNode.children.length; i<len ; ++i) {
+ if (parentNode.children[i] === this) {
+ return i;
+ }
+ }
+ }
+
+ return -1;
+ },
+
+ /**
+ * Returns a node array of this node's siblings, null if none.
+ *
+ * @return Node[]
+ */
+ getSiblings: function() {
+ return this.parent.children;
+ },
+
+ /**
+ * Shows this node's children
+ */
+ showChildren: function() {
+ if (!this.tree.animateExpand(this.getChildrenEl())) {
+ if (this.hasChildren()) {
+ this.getChildrenEl().style.display = "";
+ }
+ }
+ },
+
+ /**
+ * Hides this node's children
+ */
+ hideChildren: function() {
+
+ if (!this.tree.animateCollapse(this.getChildrenEl())) {
+ this.getChildrenEl().style.display = "none";
+ }
+ },
+
+ /**
+ * Returns the id for this node's container div
+ *
+ * @return {string} the element id
+ */
+ getElId: function() {
+ return "ygtv" + this.index;
+ },
+
+ /**
+ * Returns the id for this node's children div
+ *
+ * @return {string} the element id for this node's children div
+ */
+ getChildrenElId: function() {
+ return "ygtvc" + this.index;
+ },
+
+ /**
+ * Returns the id for this node's toggle element
+ *
+ * @return {string} the toggel element id
+ */
+ getToggleElId: function() {
+ return "ygtvt" + this.index;
+ },
+
+ /**
+ * Returns the id for this node's spacer image. The spacer is positioned
+ * over the toggle and provides feedback for screen readers.
+ * @return {string} the id for the spacer image
+ */
+ /*
+ getSpacerId: function() {
+ return "ygtvspacer" + this.index;
+ },
+ */
+
+ /**
+ * Returns this node's container html element
+ * @return {HTMLElement} the container html element
+ */
+ getEl: function() {
+ return document.getElementById(this.getElId());
+ },
+
+ /**
+ * Returns the div that was generated for this node's children
+ * @return {HTMLElement} this node's children div
+ */
+ getChildrenEl: function() {
+ return document.getElementById(this.getChildrenElId());
+ },
+
+ /**
+ * Returns the element that is being used for this node's toggle.
+ * @return {HTMLElement} this node's toggle html element
+ */
+ getToggleEl: function() {
+ return document.getElementById(this.getToggleElId());
+ },
+
+ /**
+ * Returns the element that is being used for this node's spacer.
+ * @return {HTMLElement} this node's spacer html element
+ */
+ /*
+ getSpacer: function() {
+ return document.getElementById( this.getSpacerId() ) || {};
+ },
+ */
+
+ /*
+ getStateText: function() {
+ if (this.isLoading) {
+ return this.loadingText;
+ } else if (this.hasChildren(true)) {
+ if (this.expanded) {
+ return this.expandedText;
+ } else {
+ return this.collapsedText;
+ }
+ } else {
+ return "";
+ }
+ },
+ */
+
+ /**
+ * Generates the link that will invoke this node's toggle method
+ * @return {string} the javascript url for toggling this node
+ */
+ getToggleLink: function() {
+ return "YAHOO.widget.TreeView.getNode(\'" + this.tree.id + "\'," +
+ this.index + ").toggle()";
+ },
+
+ /**
+ * Hides this nodes children (creating them if necessary), changes the
+ * toggle style.
+ */
+ collapse: function() {
+ // Only collapse if currently expanded
+ if (!this.expanded) { return; }
+
+ // fire the collapse event handler
+ var ret = this.tree.onCollapse(this);
+
+ if ("undefined" != typeof ret && !ret) {
+ return;
+ }
+
+ if (!this.getEl()) {
+ this.expanded = false;
+ return;
+ }
+
+ // hide the child div
+ this.hideChildren();
+ this.expanded = false;
+
+ if (this.hasIcon) {
+ this.getToggleEl().className = this.getStyle();
+ }
+
+ // this.getSpacer().title = this.getStateText();
+
+ },
+
+ /**
+ * Shows this nodes children (creating them if necessary), changes the
+ * toggle style, and collapses its siblings if multiExpand is not set.
+ */
+ expand: function() {
+ // Only expand if currently collapsed.
+ if (this.expanded) { return; }
+
+ // fire the expand event handler
+ var ret = this.tree.onExpand(this);
+
+ if ("undefined" != typeof ret && !ret) {
+ return;
+ }
+
+ if (!this.getEl()) {
+ this.expanded = true;
+ return;
+ }
+
+ if (! this.childrenRendered) {
+ this.getChildrenEl().innerHTML = this.renderChildren();
+ } else {
+ }
+
+ this.expanded = true;
+ if (this.hasIcon) {
+ this.getToggleEl().className = this.getStyle();
+ }
+
+ // this.getSpacer().title = this.getStateText();
+
+ // We do an extra check for children here because the lazy
+ // load feature can expose nodes that have no children.
+
+ // if (!this.hasChildren()) {
+ if (this.isLoading) {
+ this.expanded = false;
+ return;
+ }
+
+ if (! this.multiExpand) {
+ var sibs = this.getSiblings();
+ for (var i=0; i<sibs.length; ++i) {
+ if (sibs[i] != this && sibs[i].expanded) {
+ sibs[i].collapse();
+ }
+ }
+ }
+
+ this.showChildren();
+ },
+
+ /**
+ * Returns the css style name for the toggle
+ *
+ * @return {string} the css class for this node's toggle
+ */
+ getStyle: function() {
+ if (this.isLoading) {
+ return "ygtvloading";
+ } else {
+ // location top or bottom, middle nodes also get the top style
+ var loc = (this.nextSibling) ? "t" : "l";
+
+ // type p=plus(expand), m=minus(collapase), n=none(no children)
+ var type = "n";
+ if (this.hasChildren(true) || (this.isDynamic() && !this.getIconMode())) {
+ // if (this.hasChildren(true)) {
+ type = (this.expanded) ? "m" : "p";
+ }
+
+ return "ygtv" + loc + type;
+ }
+ },
+
+ /**
+ * Returns the hover style for the icon
+ * @return {string} the css class hover state
+ */
+ getHoverStyle: function() {
+ var s = this.getStyle();
+ if (this.hasChildren(true) && !this.isLoading) {
+ s += "h";
+ }
+ return s;
+ },
+
+ /**
+ * Recursively expands all of this node's children.
+ */
+ expandAll: function() {
+ for (var i=0;i<this.children.length;++i) {
+ var c = this.children[i];
+ if (c.isDynamic()) {
+ alert("Not supported (lazy load + expand all)");
+ break;
+ } else if (! c.multiExpand) {
+ alert("Not supported (no multi-expand + expand all)");
+ break;
+ } else {
+ c.expand();
+ c.expandAll();
+ }
+ }
+ },
+
+ /**
+ * Recursively collapses all of this node's children.
+ */
+ collapseAll: function() {
+ for (var i=0;i<this.children.length;++i) {
+ this.children[i].collapse();
+ this.children[i].collapseAll();
+ }
+ },
+
+ /**
+ * Configures this node for dynamically obtaining the child data
+ * when the node is first expanded. Calling it without the callback
+ * will turn off dynamic load for the node.
+ *
+ * @param fmDataLoader {function} the function that will be used to get the data.
+ * @param iconMode {int} configures the icon that is displayed when a dynamic
+ * load node is expanded the first time without children. By default, the
+ * "collapse" icon will be used. If set to 1, the leaf node icon will be
+ * displayed.
+ */
+ setDynamicLoad: function(fnDataLoader, iconMode) {
+ if (fnDataLoader) {
+ this.dataLoader = fnDataLoader;
+ this._dynLoad = true;
+ } else {
+ this.dataLoader = null;
+ this._dynLoad = false;
+ }
+
+ if (iconMode) {
+ this.iconMode = iconMode;
+ }
+ },
+
+ /**
+ * Evaluates if this node is the root node of the tree
+ *
+ * @return {boolean} true if this is the root node
+ */
+ isRoot: function() {
+ return (this == this.tree.root);
+ },
+
+ /**
+ * Evaluates if this node's children should be loaded dynamically. Looks for
+ * the property both in this instance and the root node. If the tree is
+ * defined to load all children dynamically, the data callback function is
+ * defined in the root node
+ *
+ * @return {boolean} true if this node's children are to be loaded dynamically
+ */
+ isDynamic: function() {
+ var lazy = (!this.isRoot() && (this._dynLoad || this.tree.root._dynLoad));
+ return lazy;
+ },
+
+ getIconMode: function() {
+ return (this.iconMode || this.tree.root.iconMode);
+ },
+
+ /**
+ * Checks if this node has children. If this node is lazy-loading and the
+ * children have not been rendered, we do not know whether or not there
+ * are actual children. In most cases, we need to assume that there are
+ * children (for instance, the toggle needs to show the expandable
+ * presentation state). In other times we want to know if there are rendered
+ * children. For the latter, "checkForLazyLoad" should be false.
+ *
+ * @param checkForLazyLoad {boolean} should we check for unloaded children?
+ * @return {boolean} true if this has children or if it might and we are
+ * checking for this condition.
+ */
+ hasChildren: function(checkForLazyLoad) {
+ return ( this.children.length > 0 ||
+ (checkForLazyLoad && this.isDynamic() && !this.dynamicLoadComplete) );
+ },
+
+ /**
+ * Expands if node is collapsed, collapses otherwise.
+ */
+ toggle: function() {
+ if (!this.tree.locked && ( this.hasChildren(true) || this.isDynamic()) ) {
+ if (this.expanded) { this.collapse(); } else { this.expand(); }
+ }
+ },
+
+ /**
+ * Returns the markup for this node and its children.
+ *
+ * @return {string} the markup for this node and its expanded children.
+ */
+ getHtml: function() {
+ var sb = [];
+ sb[sb.length] = '<div class="ygtvitem" id="' + this.getElId() + '">';
+ sb[sb.length] = this.getNodeHtml();
+ sb[sb.length] = this.getChildrenHtml();
+ sb[sb.length] = '</div>';
+ return sb.join("");
+ },
+
+ /**
+ * Called when first rendering the tree. We always build the div that will
+ * contain this nodes children, but we don't render the children themselves
+ * unless this node is expanded.
+ *
+ * @return {string} the children container div html and any expanded children
+ * @private
+ */
+ getChildrenHtml: function() {
+
+ var sb = [];
+ sb[sb.length] = '<div class="ygtvchildren"';
+ sb[sb.length] = ' id="' + this.getChildrenElId() + '"';
+ if (!this.expanded) {
+ sb[sb.length] = ' style="display:none;"';
+ }
+ sb[sb.length] = '>';
+
+ // Don't render the actual child node HTML unless this node is expanded.
+ if ( (this.hasChildren(true) && this.expanded) ||
+ (this.renderHidden && !this.isDynamic()) ) {
+ sb[sb.length] = this.renderChildren();
+ }
+
+ sb[sb.length] = '</div>';
+
+ return sb.join("");
+ },
+
+ /**
+ * Generates the markup for the child nodes. This is not done until the node
+ * is expanded.
+ *
+ * @return {string} the html for this node's children
+ * @private
+ */
+ renderChildren: function() {
+
+
+ var node = this;
+
+ if (this.isDynamic() && !this.dynamicLoadComplete) {
+ this.isLoading = true;
+ this.tree.locked = true;
+
+ if (this.dataLoader) {
+
+ setTimeout(
+ function() {
+ node.dataLoader(node,
+ function() {
+ node.loadComplete();
+ });
+ }, 10);
+
+ } else if (this.tree.root.dataLoader) {
+
+ setTimeout(
+ function() {
+ node.tree.root.dataLoader(node,
+ function() {
+ node.loadComplete();
+ });
+ }, 10);
+
+ } else {
+ return "Error: data loader not found or not specified.";
+ }
+
+ return "";
+
+ } else {
+ return this.completeRender();
+ }
+ },
+
+ /**
+ * Called when we know we have all the child data.
+ * @return {string} children html
+ */
+ completeRender: function() {
+ var sb = [];
+
+ for (var i=0; i < this.children.length; ++i) {
+ this.children[i].childrenRendered = false;
+ sb[sb.length] = this.children[i].getHtml();
+ }
+
+ this.childrenRendered = true;
+
+ return sb.join("");
+ },
+
+ /**
+ * Load complete is the callback function we pass to the data provider
+ * in dynamic load situations.
+ */
+ loadComplete: function() {
+ this.getChildrenEl().innerHTML = this.completeRender();
+ this.dynamicLoadComplete = true;
+ this.isLoading = false;
+ this.expand();
+ this.tree.locked = false;
+ },
+
+ /**
+ * Returns this node's ancestor at the specified depth.
+ *
+ * @param {int} depth the depth of the ancestor.
+ * @return {Node} the ancestor
+ */
+ getAncestor: function(depth) {
+ if (depth >= this.depth || depth < 0) {
+ return null;
+ }
+
+ var p = this.parent;
+
+ while (p.depth > depth) {
+ p = p.parent;
+ }
+
+ return p;
+ },
+
+ /**
+ * Returns the css class for the spacer at the specified depth for
+ * this node. If this node's ancestor at the specified depth
+ * has a next sibling the presentation is different than if it
+ * does not have a next sibling
+ *
+ * @param {int} depth the depth of the ancestor.
+ * @return {string} the css class for the spacer
+ */
+ getDepthStyle: function(depth) {
+ return (this.getAncestor(depth).nextSibling) ?
+ "ygtvdepthcell" : "ygtvblankdepthcell";
+ },
+
+ /**
+ * Get the markup for the node. This is designed to be overrided so that we can
+ * support different types of nodes.
+ *
+ * @return {string} The HTML that will render this node.
+ */
+ getNodeHtml: function() {
+ return "";
+ },
+
+ /**
+ * Regenerates the html for this node and its children. To be used when the
+ * node is expanded and new children have been added.
+ */
+ refresh: function() {
+ // this.loadComplete();
+ this.getChildrenEl().innerHTML = this.completeRender();
+
+ if (this.hasIcon) {
+ var el = this.getToggleEl();
+ if (el) {
+ el.className = this.getStyle();
+ }
+ }
+ },
+
+ /**
+ * toString
+ * @return {string} string representation of the node
+ */
+ toString: function() {
+ return "Node (" + this.index + ")";
+ }
+
+};
+
+/**
+ * A custom YAHOO.widget.Node that handles the unique nature of
+ * the virtual, presentationless root node.
+ *
+ * @extends YAHOO.widget.Node
+ * @constructor
+ */
+YAHOO.widget.RootNode = function(oTree) {
+ // Initialize the node with null params. The root node is a
+ // special case where the node has no presentation. So we have
+ // to alter the standard properties a bit.
+ this.init(null, null, true);
+
+ /**
+ * For the root node, we get the tree reference from as a param
+ * to the constructor instead of from the parent element.
+ *
+ * @type TreeView
+ */
+ this.tree = oTree;
+};
+
+YAHOO.widget.RootNode.prototype = new YAHOO.widget.Node();
+
+// overrides YAHOO.widget.Node
+YAHOO.widget.RootNode.prototype.getNodeHtml = function() {
+ return "";
+};
+
+YAHOO.widget.RootNode.prototype.toString = function() {
+ return "RootNode";
+};
+
+YAHOO.widget.RootNode.prototype.loadComplete = function() {
+ this.tree.draw();
+};
+/**
+ * The default node presentation. The first parameter should be
+ * either a string that will be used as the node's label, or an object
+ * that has a string propery called label. By default, the clicking the
+ * label will toggle the expanded/collapsed state of the node. By
+ * changing the href property of the instance, this behavior can be
+ * changed so that the label will go to the specified href.
+ *
+ * @extends YAHOO.widget.Node
+ * @constructor
+ * @param oData {object} a string or object containing the data that will
+ * be used to render this node
+ * @param oParent {YAHOO.widget.Node} this node's parent node
+ * @param expanded {boolean} the initial expanded/collapsed state
+ */
+YAHOO.widget.TextNode = function(oData, oParent, expanded) {
+ // this.type = "TextNode";
+
+ if (oData) {
+ this.init(oData, oParent, expanded);
+ this.setUpLabel(oData);
+ }
+
+ /**
+ * @private
+ */
+};
+
+YAHOO.widget.TextNode.prototype = new YAHOO.widget.Node();
+
+/**
+ * The CSS class for the label href. Defaults to ygtvlabel, but can be
+ * overridden to provide a custom presentation for a specific node.
+ *
+ * @type string
+ */
+YAHOO.widget.TextNode.prototype.labelStyle = "ygtvlabel";
+
+/**
+ * The derived element id of the label for this node
+ *
+ * @type string
+ */
+YAHOO.widget.TextNode.prototype.labelElId = null;
+
+/**
+ * The text for the label. It is assumed that the oData parameter will
+ * either be a string that will be used as the label, or an object that
+ * has a property called "label" that we will use.
+ *
+ * @type string
+ */
+YAHOO.widget.TextNode.prototype.label = null;
+
+/**
+ * Sets up the node label
+ *
+ * @param oData string containing the label, or an object with a label property
+ */
+YAHOO.widget.TextNode.prototype.setUpLabel = function(oData) {
+ if (typeof oData == "string") {
+ oData = { label: oData };
+ }
+ this.label = oData.label;
+
+ // update the link
+ if (oData.href) {
+ this.href = oData.href;
+ }
+
+ // set the target
+ if (oData.target) {
+ this.target = oData.target;
+ }
+
+ if (oData.style) {
+ this.labelStyle = oData.style;
+ }
+
+ this.labelElId = "ygtvlabelel" + this.index;
+};
+
+/**
+ * Returns the label element
+ *
+ * @return {object} the element
+ */
+YAHOO.widget.TextNode.prototype.getLabelEl = function() {
+ return document.getElementById(this.labelElId);
+};
+
+// overrides YAHOO.widget.Node
+YAHOO.widget.TextNode.prototype.getNodeHtml = function() {
+ var sb = [];
+
+ sb[sb.length] = '<table border="0" cellpadding="0" cellspacing="0">';
+ sb[sb.length] = '<tr>';
+
+ for (i=0;i<this.depth;++i) {
+ // sb[sb.length] = '<td class="ygtvdepthcell"> </td>';
+ sb[sb.length] = '<td class="' + this.getDepthStyle(i) + '"> </td>';
+ }
+
+ var getNode = 'YAHOO.widget.TreeView.getNode(\'' +
+ this.tree.id + '\',' + this.index + ')';
+
+ sb[sb.length] = '<td';
+ // sb[sb.length] = ' onselectstart="return false"';
+ sb[sb.length] = ' id="' + this.getToggleElId() + '"';
+ sb[sb.length] = ' class="' + this.getStyle() + '"';
+ if (this.hasChildren(true)) {
+ sb[sb.length] = ' onmouseover="this.className=';
+ sb[sb.length] = getNode + '.getHoverStyle()"';
+ sb[sb.length] = ' onmouseout="this.className=';
+ sb[sb.length] = getNode + '.getStyle()"';
+ }
+ sb[sb.length] = ' onclick="javascript:' + this.getToggleLink() + '">';
+
+ /*
+ sb[sb.length] = '<img id="' + this.getSpacerId() + '"';
+ sb[sb.length] = ' alt=""';
+ sb[sb.length] = ' tabindex=0';
+ sb[sb.length] = ' src="' + this.spacerPath + '"';
+ sb[sb.length] = ' title="' + this.getStateText() + '"';
+ sb[sb.length] = ' class="ygtvspacer"';
+ // sb[sb.length] = ' onkeypress="return ' + getNode + '".onKeyPress()"';
+ sb[sb.length] = ' />';
+ */
+
+ sb[sb.length] = ' ';
+
+ sb[sb.length] = '</td>';
+ sb[sb.length] = '<td>';
+ sb[sb.length] = '<a';
+ sb[sb.length] = ' id="' + this.labelElId + '"';
+ sb[sb.length] = ' class="' + this.labelStyle + '"';
+ sb[sb.length] = ' href="' + this.href + '"';
+ sb[sb.length] = ' target="' + this.target + '"';
+ sb[sb.length] = ' onclick="return ' + getNode + '.onLabelClick(' + getNode +')"';
+ if (this.hasChildren(true)) {
+ sb[sb.length] = ' onmouseover="document.getElementById(\'';
+ sb[sb.length] = this.getToggleElId() + '\').className=';
+ sb[sb.length] = getNode + '.getHoverStyle()"';
+ sb[sb.length] = ' onmouseout="document.getElementById(\'';
+ sb[sb.length] = this.getToggleElId() + '\').className=';
+ sb[sb.length] = getNode + '.getStyle()"';
+ }
+ sb[sb.length] = ' >';
+ sb[sb.length] = this.label;
+ sb[sb.length] = '</a>';
+ sb[sb.length] = '</td>';
+ sb[sb.length] = '</tr>';
+ sb[sb.length] = '</table>';
+
+ return sb.join("");
+};
+
+/**
+ * Executed when the label is clicked
+ * @param me {Node} this node
+ * @scope the anchor tag clicked
+ * @return false to cancel the anchor click
+ */
+YAHOO.widget.TextNode.prototype.onLabelClick = function(me) {
+ //return true;
+};
+
+YAHOO.widget.TextNode.prototype.toString = function() {
+ return "TextNode (" + this.index + ") " + this.label;
+};
+
+/**
+ * A menu-specific implementation that differs from TextNode in that only
+ * one sibling can be expanded at a time.
+ * @extends YAHOO.widget.TextNode
+ * @constructor
+ */
+YAHOO.widget.MenuNode = function(oData, oParent, expanded) {
+ if (oData) {
+ this.init(oData, oParent, expanded);
+ this.setUpLabel(oData);
+ }
+
+ /**
+ * Menus usually allow only one branch to be open at a time.
+ * @type boolean
+ */
+ this.multiExpand = false;
+
+ /**
+ * @private
+ */
+
+};
+
+YAHOO.widget.MenuNode.prototype = new YAHOO.widget.TextNode();
+
+YAHOO.widget.MenuNode.prototype.toString = function() {
+ return "MenuNode (" + this.index + ") " + this.label;
+};
+
+/**
+ * This implementation takes either a string or object for the
+ * oData argument. If is it a string, we will use it for the display
+ * of this node (and it can contain any html code). If the parameter
+ * is an object, we look for a parameter called "html" that will be
+ * used for this node's display.
+ *
+ * @extends YAHOO.widget.Node
+ * @constructor
+ * @param oData {object} a string or object containing the data that will
+ * be used to render this node
+ * @param oParent {YAHOO.widget.Node} this node's parent node
+ * @param expanded {boolean} the initial expanded/collapsed state
+ * @param hasIcon {boolean} specifies whether or not leaf nodes should
+ * have an icon
+ */
+YAHOO.widget.HTMLNode = function(oData, oParent, expanded, hasIcon) {
+ if (oData) {
+ this.init(oData, oParent, expanded);
+ this.initContent(oData, hasIcon);
+ }
+};
+
+YAHOO.widget.HTMLNode.prototype = new YAHOO.widget.Node();
+
+/**
+ * The CSS class for the html content container. Defaults to ygtvhtml, but
+ * can be overridden to provide a custom presentation for a specific node.
+ *
+ * @type string
+ */
+YAHOO.widget.HTMLNode.prototype.contentStyle = "ygtvhtml";
+
+/**
+ * The generated id that will contain the data passed in by the implementer.
+ *
+ * @type string
+ */
+YAHOO.widget.HTMLNode.prototype.contentElId = null;
+
+/**
+ * The HTML content to use for this node's display
+ *
+ * @type string
+ */
+YAHOO.widget.HTMLNode.prototype.content = null;
+
+/**
+ * Sets up the node label
+ *
+ * @param {object} An html string or object containing an html property
+ * @param {boolean} hasIcon determines if the node will be rendered with an
+ * icon or not
+ */
+YAHOO.widget.HTMLNode.prototype.initContent = function(oData, hasIcon) {
+ if (typeof oData == "string") {
+ oData = { html: oData };
+ }
+
+ this.html = oData.html;
+ this.contentElId = "ygtvcontentel" + this.index;
+ this.hasIcon = hasIcon;
+
+ /**
+ * @private
+ */
+};
+
+/**
+ * Returns the outer html element for this node's content
+ *
+ * @return {HTMLElement} the element
+ */
+YAHOO.widget.HTMLNode.prototype.getContentEl = function() {
+ return document.getElementById(this.contentElId);
+};
+
+// overrides YAHOO.widget.Node
+YAHOO.widget.HTMLNode.prototype.getNodeHtml = function() {
+ var sb = [];
+
+ sb[sb.length] = '<table border="0" cellpadding="0" cellspacing="0">';
+ sb[sb.length] = '<tr>';
+
+ for (i=0;i<this.depth;++i) {
+ sb[sb.length] = '<td class="' + this.getDepthStyle(i) + '"> </td>';
+ }
+
+ if (this.hasIcon) {
+ sb[sb.length] = '<td';
+ sb[sb.length] = ' id="' + this.getToggleElId() + '"';
+ sb[sb.length] = ' class="' + this.getStyle() + '"';
+ sb[sb.length] = ' onclick="javascript:' + this.getToggleLink() + '"';
+ if (this.hasChildren(true)) {
+ sb[sb.length] = ' onmouseover="this.className=';
+ sb[sb.length] = 'YAHOO.widget.TreeView.getNode(\'';
+ sb[sb.length] = this.tree.id + '\',' + this.index + ').getHoverStyle()"';
+ sb[sb.length] = ' onmouseout="this.className=';
+ sb[sb.length] = 'YAHOO.widget.TreeView.getNode(\'';
+ sb[sb.length] = this.tree.id + '\',' + this.index + ').getStyle()"';
+ }
+ sb[sb.length] = '> </td>';
+ }
+
+ sb[sb.length] = '<td';
+ sb[sb.length] = ' id="' + this.contentElId + '"';
+ sb[sb.length] = ' class="' + this.contentStyle + '"';
+ sb[sb.length] = ' >';
+ sb[sb.length] = this.html;
+ sb[sb.length] = '</td>';
+ sb[sb.length] = '</tr>';
+ sb[sb.length] = '</table>';
+
+ return sb.join("");
+};
+
+YAHOO.widget.HTMLNode.prototype.toString = function() {
+ return "HTMLNode (" + this.index + ")";
+};
+
+/**
+ * A static factory class for tree view expand/collapse animations
+ *
+ * @constructor
+ */
+YAHOO.widget.TVAnim = function() {
+ return {
+ /**
+ * Constant for the fade in animation
+ *
+ * @type string
+ */
+ FADE_IN: "TVFadeIn",
+
+ /**
+ * Constant for the fade out animation
+ *
+ * @type string
+ */
+ FADE_OUT: "TVFadeOut",
+
+ /**
+ * Returns a ygAnim instance of the given type
+ *
+ * @param type {string} the type of animation
+ * @param el {HTMLElement} the element to element (probably the children div)
+ * @param callback {function} function to invoke when the animation is done.
+ * @return {YAHOO.util.Animation} the animation instance
+ */
+ getAnim: function(type, el, callback) {
+ if (YAHOO.widget[type]) {
+ return new YAHOO.widget[type](el, callback);
+ } else {
+ return null;
+ }
+ },
+
+ /**
+ * Returns true if the specified animation class is available
+ *
+ * @param type {string} the type of animation
+ * @return {boolean} true if valid, false if not
+ */
+ isValid: function(type) {
+ return (YAHOO.widget[type]);
+ }
+ };
+} ();
+
+/**
+ * A 1/2 second fade-in animation.
+ *
+ * @constructor
+ * @param el {HTMLElement} the element to animate
+ * @param callback {function} function to invoke when the animation is finished
+ */
+YAHOO.widget.TVFadeIn = function(el, callback) {
+ /**
+ * The element to animate
+ * @type HTMLElement
+ */
+ this.el = el;
+
+ /**
+ * the callback to invoke when the animation is complete
+ *
+ * @type function
+ */
+ this.callback = callback;
+
+ /**
+ * @private
+ */
+};
+
+/**
+ * Performs the animation
+ */
+YAHOO.widget.TVFadeIn.prototype = {
+ animate: function() {
+ var tvanim = this;
+
+ var s = this.el.style;
+ s.opacity = 0.1;
+ s.filter = "alpha(opacity=10)";
+ s.display = "";
+
+ // var dur = ( navigator.userAgent.match(/msie/gi) ) ? 0.05 : 0.4;
+ var dur = 0.4;
+ // var a = new ygAnim_Fade(this.el, dur, 1);
+ // a.setStart(0.1);
+ // a.onComplete = function() { tvanim.onComplete(); };
+
+ // var a = new YAHOO.util.Anim(this.el, 'opacity', 0.1, 1);
+ var a = new YAHOO.util.Anim(this.el, {opacity: {from: 0.1, to: 1, unit:""}}, dur);
+ a.onComplete.subscribe( function() { tvanim.onComplete(); } );
+ a.animate();
+ },
+
+ /**
+ * Clean up and invoke callback
+ */
+ onComplete: function() {
+ this.callback();
+ },
+
+ toString: function() {
+ return "TVFadeIn";
+ }
+};
+
+/**
+ * A 1/2 second fade out animation.
+ *
+ * @constructor
+ * @param el {HTMLElement} the element to animate
+ * @param callback {Function} function to invoke when the animation is finished
+ */
+YAHOO.widget.TVFadeOut = function(el, callback) {
+ /**
+ * The element to animate
+ * @type HTMLElement
+ */
+ this.el = el;
+
+ /**
+ * the callback to invoke when the animation is complete
+ *
+ * @type function
+ */
+ this.callback = callback;
+
+ /**
+ * @private
+ */
+};
+
+/**
+ * Performs the animation
+ */
+YAHOO.widget.TVFadeOut.prototype = {
+ animate: function() {
+ var tvanim = this;
+ // var dur = ( navigator.userAgent.match(/msie/gi) ) ? 0.05 : 0.4;
+ var dur = 0.4;
+ // var a = new ygAnim_Fade(this.el, dur, 0.1);
+ // a.onComplete = function() { tvanim.onComplete(); };
+
+ // var a = new YAHOO.util.Anim(this.el, 'opacity', 1, 0.1);
+ var a = new YAHOO.util.Anim(this.el, {opacity: {from: 1, to: 0.1, unit:""}}, dur);
+ a.onComplete.subscribe( function() { tvanim.onComplete(); } );
+ a.animate();
+ },
+
+ /**
+ * Clean up and invoke callback
+ */
+ onComplete: function() {
+ var s = this.el.style;
+ s.display = "none";
+ // s.opacity = 1;
+ s.filter = "alpha(opacity=100)";
+ this.callback();
+ },
+
+ toString: function() {
+ return "TVFadeOut";
+ }
+};
+
Added: branches/tomek/portal-dnd/dndRenderer.war/js/yahoo/README
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/yahoo/README 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/yahoo/README 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,10 @@
+YAHOO Global Namespace - Release Notes
+
+0.11.0
+ * Added YAHOO.extend, which provides an easy way to assign the prototype,
+ constructor, and superclass properties inheritance properties. It also
+ prevents the constructor of the superclass from being exectuted twice.
+
+0.10.0
+ * Added YAHOO.log that provides a safe way to plumb logging statements in
+ code that will work if the logging component isn't available.
Added: branches/tomek/portal-dnd/dndRenderer.war/js/yahoo/yahoo-debug.js
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/yahoo/yahoo-debug.js 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/yahoo/yahoo-debug.js 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,85 @@
+
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 0.11.0
+*/
+
+/**
+ * The Yahoo global namespace
+ * @constructor
+ */
+var YAHOO = window.YAHOO || {};
+
+/**
+ * Returns the namespace specified and creates it if it doesn't exist
+ *
+ * YAHOO.namespace("property.package");
+ * YAHOO.namespace("YAHOO.property.package");
+ *
+ * Either of the above would create YAHOO.property, then
+ * YAHOO.property.package
+ *
+ * @param {String} ns The name of the namespace
+ * @return {Object} A reference to the namespace object
+ */
+YAHOO.namespace = function(ns) {
+
+ if (!ns || !ns.length) {
+ return null;
+ }
+
+ var levels = ns.split(".");
+ var nsobj = YAHOO;
+
+ // YAHOO is implied, so it is ignored if it is included
+ for (var i=(levels[0] == "YAHOO") ? 1 : 0; i<levels.length; ++i) {
+ nsobj[levels[i]] = nsobj[levels[i]] || {};
+ nsobj = nsobj[levels[i]];
+ }
+
+ return nsobj;
+};
+
+/**
+ * Uses YAHOO.widget.Logger to output a log message, if the widget is available.
+ *
+ * @param {string} sMsg The message to log.
+ * @param {string} sCategory The log category for the message. Default
+ * categories are "info", "warn", "error", time".
+ * Custom categories can be used as well. (opt)
+ * @param {string} sSource The source of the the message (opt)
+ * @return {boolean} True if the log operation was successful.
+ */
+YAHOO.log = function(sMsg, sCategory, sSource) {
+ var l = YAHOO.widget.Logger;
+ if(l && l.log) {
+ return l.log(sMsg, sCategory, sSource);
+ } else {
+ return false;
+ }
+};
+
+/**
+ * Utility to set up the prototype, constructor and superclass properties to
+ * support an inheritance strategy that can chain constructors and methods.
+ *
+ * @param {Function} subclass the object to modify
+ * @param {Function} superclass the object to inherit
+ */
+YAHOO.extend = function(subclass, superclass) {
+ var f = function() {};
+ f.prototype = superclass.prototype;
+ subclass.prototype = new f();
+ subclass.prototype.constructor = subclass;
+ subclass.superclass = superclass.prototype;
+ if (superclass.prototype.constructor == Object.prototype.constructor) {
+ superclass.prototype.constructor = superclass;
+ }
+};
+
+YAHOO.namespace("util");
+YAHOO.namespace("widget");
+YAHOO.namespace("example");
+
Added: branches/tomek/portal-dnd/dndRenderer.war/js/yahoo/yahoo-min.js
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/yahoo/yahoo-min.js 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/yahoo/yahoo-min.js 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1 @@
+/* Copyright (c) 2006, Yahoo! Inc. All rights reserved. Code licensed under the BSD License: http://developer.yahoo.net/yui/license.txt version: 0.11.0 */ var YAHOO=window.YAHOO||{};YAHOO.namespace=function(ns){if(!ns||!ns.length){return null;}var _2=ns.split(".");var _3=YAHOO;for(var i=(_2[0]=="YAHOO")?1:0;i<_2.length;++i){_3[_2[i]]=_3[_2[i]]||{};_3=_3[_2[i]];}return _3;};YAHO!
O.log=function(_5,_6,_7){var l=YAHOO.widget.Logger;if(l&&l.log){return l.log(_5,_6,_7);}else{return false;}};YAHOO.extend=function(_9,_10){var f=function(){};f.prototype=_10.prototype;_9.prototype=new f();_9.prototype.constructor=_9;_9.superclass=_10.prototype;if(_10.prototype.constructor==Object.prototype.constructor){_10.prototype.constructor=_10;}};YAHOO.namespace("util");YAHOO.namespace("widget");YAHOO.namespace("example");
\ No newline at end of file
Added: branches/tomek/portal-dnd/dndRenderer.war/js/yahoo/yahoo.js
===================================================================
--- branches/tomek/portal-dnd/dndRenderer.war/js/yahoo/yahoo.js 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/dndRenderer.war/js/yahoo/yahoo.js 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,84 @@
+/*
+Copyright (c) 2006, Yahoo! Inc. All rights reserved.
+Code licensed under the BSD License:
+http://developer.yahoo.net/yui/license.txt
+version: 0.11.0
+*/
+
+/**
+ * The Yahoo global namespace
+ * @constructor
+ */
+var YAHOO = window.YAHOO || {};
+
+/**
+ * Returns the namespace specified and creates it if it doesn't exist
+ *
+ * YAHOO.namespace("property.package");
+ * YAHOO.namespace("YAHOO.property.package");
+ *
+ * Either of the above would create YAHOO.property, then
+ * YAHOO.property.package
+ *
+ * @param {String} ns The name of the namespace
+ * @return {Object} A reference to the namespace object
+ */
+YAHOO.namespace = function(ns) {
+
+ if (!ns || !ns.length) {
+ return null;
+ }
+
+ var levels = ns.split(".");
+ var nsobj = YAHOO;
+
+ // YAHOO is implied, so it is ignored if it is included
+ for (var i=(levels[0] == "YAHOO") ? 1 : 0; i<levels.length; ++i) {
+ nsobj[levels[i]] = nsobj[levels[i]] || {};
+ nsobj = nsobj[levels[i]];
+ }
+
+ return nsobj;
+};
+
+/**
+ * Uses YAHOO.widget.Logger to output a log message, if the widget is available.
+ *
+ * @param {string} sMsg The message to log.
+ * @param {string} sCategory The log category for the message. Default
+ * categories are "info", "warn", "error", time".
+ * Custom categories can be used as well. (opt)
+ * @param {string} sSource The source of the the message (opt)
+ * @return {boolean} True if the log operation was successful.
+ */
+YAHOO.log = function(sMsg, sCategory, sSource) {
+ var l = YAHOO.widget.Logger;
+ if(l && l.log) {
+ return l.log(sMsg, sCategory, sSource);
+ } else {
+ return false;
+ }
+};
+
+/**
+ * Utility to set up the prototype, constructor and superclass properties to
+ * support an inheritance strategy that can chain constructors and methods.
+ *
+ * @param {Function} subclass the object to modify
+ * @param {Function} superclass the object to inherit
+ */
+YAHOO.extend = function(subclass, superclass) {
+ var f = function() {};
+ f.prototype = superclass.prototype;
+ subclass.prototype = new f();
+ subclass.prototype.constructor = subclass;
+ subclass.superclass = superclass.prototype;
+ if (superclass.prototype.constructor == Object.prototype.constructor) {
+ superclass.prototype.constructor = superclass;
+ }
+};
+
+YAHOO.namespace("util");
+YAHOO.namespace("widget");
+YAHOO.namespace("example");
+
Added: branches/tomek/portal-dnd/jsunit/app/css/jsUnitStyle.css
===================================================================
--- branches/tomek/portal-dnd/jsunit/app/css/jsUnitStyle.css 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/app/css/jsUnitStyle.css 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,50 @@
+body {
+ margin-top: 0;
+ margin-bottom: 0;
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ color: #000;
+ font-size: 0.8em;
+ background-color: #fff;
+}
+
+a:link, a:visited {
+ color: #00F;
+}
+
+a:hover {
+ color: #F00;
+}
+
+h1 {
+ font-size: 1.2em;
+ font-weight: bold;
+ color: #039;
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+}
+
+h2 {
+ font-weight: bold;
+ color: #039;
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+}
+
+h3 {
+ font-weight: bold;
+ color: #039;
+ text-decoration: underline;
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+}
+
+h4 {
+ font-weight: bold;
+ color: #039;
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+}
+
+.jsUnitTestResultSuccess {
+ color: #000;
+}
+
+.jsUnitTestResultNotSuccess {
+ color: #F00;
+}
\ No newline at end of file
Added: branches/tomek/portal-dnd/jsunit/app/css/readme
===================================================================
--- branches/tomek/portal-dnd/jsunit/app/css/readme 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/app/css/readme 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,10 @@
+this file is required due to differences in behavior between Mozilla/Opera
+and Internet Explorer.
+
+main-data.html calls kickOffTests() which calls top.testManager.start()
+in the top most frame. top.testManager.start() initializes the output
+frames using document.write and HTML containing a relative <link> to the
+jsUnitStyle.css file. In MSIE, the base href used to find the CSS file is
+that of the top level frame however in Mozilla/Opera the base href is
+that of main-data.html. This leads to not-found for the jsUnitStyle.css
+in Mozilla/Opera. Creating app/css/jsUnitStyle.css works around this problem.
Added: branches/tomek/portal-dnd/jsunit/app/emptyPage.html
===================================================================
--- branches/tomek/portal-dnd/jsunit/app/emptyPage.html 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/app/emptyPage.html 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,11 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>emptyPage</title>
+</head>
+
+<body>
+</body>
+</html>
+
Added: branches/tomek/portal-dnd/jsunit/app/jsUnitCore.js
===================================================================
--- branches/tomek/portal-dnd/jsunit/app/jsUnitCore.js 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/app/jsUnitCore.js 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,534 @@
+var JSUNIT_UNDEFINED_VALUE;
+var JSUNIT_VERSION = 2.2;
+var isTestPageLoaded = false;
+
+//hack for NS62 bug
+function jsUnitFixTop() {
+ var tempTop = top;
+ if (!tempTop) {
+ tempTop = window;
+ while (tempTop.parent) {
+ tempTop = tempTop.parent;
+ if (tempTop.top && tempTop.top.jsUnitTestSuite) {
+ tempTop = tempTop.top;
+ break;
+ }
+ }
+ }
+ try {
+ window.top = tempTop;
+ } catch (e) {
+ }
+}
+
+jsUnitFixTop();
+
+/**
+ + * A more functional typeof
+ + * @param Object o
+ + * @return String
+ + */
+function _trueTypeOf(something) {
+ var result = typeof something;
+ try {
+ switch (result) {
+ case 'string':
+ case 'boolean':
+ case 'number':
+ break;
+ case 'object':
+ case 'function':
+ switch (something.constructor)
+ {
+ case String:
+ result = 'String';
+ break;
+ case Boolean:
+ result = 'Boolean';
+ break;
+ case Number:
+ result = 'Number';
+ break;
+ case Array:
+ result = 'Array';
+ break;
+ case RegExp:
+ result = 'RegExp';
+ break;
+ case Function:
+ result = 'Function';
+ break;
+ default:
+ var m = something.constructor.toString().match(/function\s*([^( ]+)\(/);
+ if (m)
+ result = m[1];
+ else
+ break;
+ }
+ break;
+ }
+ }
+ finally {
+ result = result.substr(0, 1).toUpperCase() + result.substr(1);
+ return result;
+ }
+}
+
+function _displayStringForValue(aVar) {
+ var result = '<' + aVar + '>';
+ if (!(aVar === null || aVar === top.JSUNIT_UNDEFINED_VALUE)) {
+ result += ' (' + _trueTypeOf(aVar) + ')';
+ }
+ return result;
+}
+
+function fail(failureMessage) {
+ throw new JsUnitException("Call to fail()", failureMessage);
+}
+
+function error(errorMessage) {
+ var errorObject = new Object();
+ errorObject.description = errorMessage;
+ errorObject.stackTrace = getStackTrace();
+ throw errorObject;
+}
+
+function argumentsIncludeComments(expectedNumberOfNonCommentArgs, args) {
+ return args.length == expectedNumberOfNonCommentArgs + 1;
+}
+
+function commentArg(expectedNumberOfNonCommentArgs, args) {
+ if (argumentsIncludeComments(expectedNumberOfNonCommentArgs, args))
+ return args[0];
+
+ return null;
+}
+
+function nonCommentArg(desiredNonCommentArgIndex, expectedNumberOfNonCommentArgs, args) {
+ return argumentsIncludeComments(expectedNumberOfNonCommentArgs, args) ?
+ args[desiredNonCommentArgIndex] :
+ args[desiredNonCommentArgIndex - 1];
+}
+
+function _validateArguments(expectedNumberOfNonCommentArgs, args) {
+ if (!( args.length == expectedNumberOfNonCommentArgs ||
+ (args.length == expectedNumberOfNonCommentArgs + 1 && typeof(args[0]) == 'string') ))
+ error('Incorrect arguments passed to assert function');
+}
+
+function _assert(comment, booleanValue, failureMessage) {
+ if (!booleanValue)
+ throw new JsUnitException(comment, failureMessage);
+}
+
+function assert() {
+ _validateArguments(1, arguments);
+ var booleanValue = nonCommentArg(1, 1, arguments);
+
+ if (typeof(booleanValue) != 'boolean')
+ error('Bad argument to assert(boolean)');
+
+ _assert(commentArg(1, arguments), booleanValue === true, 'Call to assert(boolean) with false');
+}
+
+function assertTrue() {
+ _validateArguments(1, arguments);
+ var booleanValue = nonCommentArg(1, 1, arguments);
+
+ if (typeof(booleanValue) != 'boolean')
+ error('Bad argument to assertTrue(boolean)');
+
+ _assert(commentArg(1, arguments), booleanValue === true, 'Call to assertTrue(boolean) with false');
+}
+
+function assertFalse() {
+ _validateArguments(1, arguments);
+ var booleanValue = nonCommentArg(1, 1, arguments);
+
+ if (typeof(booleanValue) != 'boolean')
+ error('Bad argument to assertFalse(boolean)');
+
+ _assert(commentArg(1, arguments), booleanValue === false, 'Call to assertFalse(boolean) with true');
+}
+
+function assertEquals() {
+ _validateArguments(2, arguments);
+ var var1 = nonCommentArg(1, 2, arguments);
+ var var2 = nonCommentArg(2, 2, arguments);
+ _assert(commentArg(2, arguments), var1 === var2, 'Expected ' + _displayStringForValue(var1) + ' but was ' + _displayStringForValue(var2));
+}
+
+function assertNotEquals() {
+ _validateArguments(2, arguments);
+ var var1 = nonCommentArg(1, 2, arguments);
+ var var2 = nonCommentArg(2, 2, arguments);
+ _assert(commentArg(2, arguments), var1 !== var2, 'Expected not to be ' + _displayStringForValue(var2));
+}
+
+function assertNull() {
+ _validateArguments(1, arguments);
+ var aVar = nonCommentArg(1, 1, arguments);
+ _assert(commentArg(1, arguments), aVar === null, 'Expected ' + _displayStringForValue(null) + ' but was ' + _displayStringForValue(aVar));
+}
+
+function assertNotNull() {
+ _validateArguments(1, arguments);
+ var aVar = nonCommentArg(1, 1, arguments);
+ _assert(commentArg(1, arguments), aVar !== null, 'Expected not to be ' + _displayStringForValue(null));
+}
+
+function assertUndefined() {
+ _validateArguments(1, arguments);
+ var aVar = nonCommentArg(1, 1, arguments);
+ _assert(commentArg(1, arguments), aVar === top.JSUNIT_UNDEFINED_VALUE, 'Expected ' + _displayStringForValue(top.JSUNIT_UNDEFINED_VALUE) + ' but was ' + _displayStringForValue(aVar));
+}
+
+function assertNotUndefined() {
+ _validateArguments(1, arguments);
+ var aVar = nonCommentArg(1, 1, arguments);
+ _assert(commentArg(1, arguments), aVar !== top.JSUNIT_UNDEFINED_VALUE, 'Expected not to be ' + _displayStringForValue(top.JSUNIT_UNDEFINED_VALUE));
+}
+
+function assertNaN() {
+ _validateArguments(1, arguments);
+ var aVar = nonCommentArg(1, 1, arguments);
+ _assert(commentArg(1, arguments), isNaN(aVar), 'Expected NaN');
+}
+
+function assertNotNaN() {
+ _validateArguments(1, arguments);
+ var aVar = nonCommentArg(1, 1, arguments);
+ _assert(commentArg(1, arguments), !isNaN(aVar), 'Expected not NaN');
+}
+
+function assertObjectEquals() {
+ _validateArguments(2, arguments);
+ var var1 = nonCommentArg(1, 2, arguments);
+ var var2 = nonCommentArg(2, 2, arguments);
+ var type;
+ var msg = commentArg(2, arguments)?commentArg(2, arguments):'';
+ var isSame = (var1 === var2);
+ //shortpath for references to same object
+ var isEqual = ( (type = _trueTypeOf(var1)) == _trueTypeOf(var2) );
+ if (isEqual && !isSame) {
+ switch (type) {
+ case 'String':
+ case 'Number':
+ isEqual = (var1 == var2);
+ break;
+ case 'Boolean':
+ case 'Date':
+ isEqual = (var1 === var2);
+ break;
+ case 'RegExp':
+ case 'Function':
+ isEqual = (var1.toString() === var2.toString());
+ break;
+ default: //Object | Array
+ var i;
+ if (isEqual = (var1.length === var2.length))
+ for (i in var1)
+ assertObjectEquals(msg + ' found nested ' + type + '@' + i + '\n', var1[i], var2[i]);
+ }
+ _assert(msg, isEqual, 'Expected ' + _displayStringForValue(var1) + ' but was ' + _displayStringForValue(var2));
+ }
+}
+
+assertArrayEquals = assertObjectEquals;
+
+function assertEvaluatesToTrue() {
+ _validateArguments(1, arguments);
+ var value = nonCommentArg(1, 1, arguments);
+ if (!value)
+ fail(commentArg(1, arguments));
+}
+
+function assertEvaluatesToFalse() {
+ _validateArguments(1, arguments);
+ var value = nonCommentArg(1, 1, arguments);
+ if (value)
+ fail(commentArg(1, arguments));
+}
+
+function assertHTMLEquals() {
+ _validateArguments(2, arguments);
+ var var1 = nonCommentArg(1, 2, arguments);
+ var var2 = nonCommentArg(2, 2, arguments);
+ var var1Standardized = standardizeHTML(var1);
+ var var2Standardized = standardizeHTML(var2);
+
+ _assert(commentArg(2, arguments), var1Standardized === var2Standardized, 'Expected ' + _displayStringForValue(var1Standardized) + ' but was ' + _displayStringForValue(var2Standardized));
+}
+
+function assertHashEquals() {
+ _validateArguments(2, arguments);
+ var var1 = nonCommentArg(1, 2, arguments);
+ var var2 = nonCommentArg(2, 2, arguments);
+ for (var key in var1) {
+ assertNotUndefined("Expected hash had key " + key + " that was not found", var2[key]);
+ assertEquals(
+ "Value for key " + key + " mismatch - expected = " + var1[key] + ", actual = " + var2[key],
+ var1[key], var2[key]
+ );
+ }
+ for (var key in var2) {
+ assertNotUndefined("Actual hash had key " + key + " that was not expected", var1[key]);
+ }
+}
+
+function assertRoughlyEquals() {
+ _validateArguments(3, arguments);
+ var expected = nonCommentArg(1, 3, arguments);
+ var actual = nonCommentArg(2, 3, arguments);
+ var tolerance = nonCommentArg(3, 3, arguments);
+ assertTrue(
+ "Expected " + expected + ", but got " + actual + " which was more than " + tolerance + " away",
+ Math.abs(expected - actual) < tolerance
+ );
+}
+
+function assertContains() {
+ _validateArguments(2, arguments);
+ var contained = nonCommentArg(1, 2, arguments);
+ var container = nonCommentArg(2, 2, arguments);
+ assertTrue(
+ "Expected '" + container + "' to contain '" + contained + "'",
+ container.indexOf(contained) != -1
+ );
+}
+
+function standardizeHTML(html) {
+ var translator = document.createElement("DIV");
+ translator.innerHTML = html;
+ return translator.innerHTML;
+}
+
+function isLoaded() {
+ return isTestPageLoaded;
+}
+
+function setUp() {
+}
+
+function tearDown() {
+}
+
+function getFunctionName(aFunction) {
+ var regexpResult = aFunction.toString().match(/function(\s*)(\w*)/);
+ if (regexpResult && regexpResult.length >= 2 && regexpResult[2]) {
+ return regexpResult[2];
+ }
+ return 'anonymous';
+}
+
+function getStackTrace() {
+ var result = '';
+
+ if (typeof(arguments.caller) != 'undefined') { // IE, not ECMA
+ for (var a = arguments.caller; a != null; a = a.caller) {
+ result += '> ' + getFunctionName(a.callee) + '\n';
+ if (a.caller == a) {
+ result += '*';
+ break;
+ }
+ }
+ }
+ else { // Mozilla, not ECMA
+ // fake an exception so we can get Mozilla's error stack
+ var testExcp;
+ try
+ {
+ foo.bar;
+ }
+ catch(testExcp)
+ {
+ var stack = parseErrorStack(testExcp);
+ for (var i = 1; i < stack.length; i++)
+ {
+ result += '> ' + stack[i] + '\n';
+ }
+ }
+ }
+
+ return result;
+}
+
+function parseErrorStack(excp)
+{
+ var stack = [];
+ var name;
+
+ if (!excp || !excp.stack)
+ {
+ return stack;
+ }
+
+ var stacklist = excp.stack.split('\n');
+
+ for (var i = 0; i < stacklist.length - 1; i++)
+ {
+ var framedata = stacklist[i];
+
+ name = framedata.match(/^(\w*)/)[1];
+ if (!name) {
+ name = 'anonymous';
+ }
+
+ stack[stack.length] = name;
+ }
+ // remove top level anonymous functions to match IE
+
+ while (stack.length && stack[stack.length - 1] == 'anonymous')
+ {
+ stack.length = stack.length - 1;
+ }
+ return stack;
+}
+
+function JsUnitException(comment, message) {
+ this.isJsUnitException = true;
+ this.comment = comment;
+ this.jsUnitMessage = message;
+ this.stackTrace = getStackTrace();
+}
+
+function warn() {
+ if (top.tracer != null)
+ top.tracer.warn(arguments[0], arguments[1]);
+}
+
+function inform() {
+ if (top.tracer != null)
+ top.tracer.inform(arguments[0], arguments[1]);
+}
+
+function info() {
+ inform(arguments[0], arguments[1]);
+}
+
+function debug() {
+ if (top.tracer != null)
+ top.tracer.debug(arguments[0], arguments[1]);
+}
+
+function setJsUnitTracer(aJsUnitTracer) {
+ top.tracer = aJsUnitTracer;
+}
+
+function trim(str) {
+ if (str == null)
+ return null;
+
+ var startingIndex = 0;
+ var endingIndex = str.length - 1;
+
+ while (str.substring(startingIndex, startingIndex + 1) == ' ')
+ startingIndex++;
+
+ while (str.substring(endingIndex, endingIndex + 1) == ' ')
+ endingIndex--;
+
+ if (endingIndex < startingIndex)
+ return '';
+
+ return str.substring(startingIndex, endingIndex + 1);
+}
+
+function isBlank(str) {
+ return trim(str) == '';
+}
+
+// the functions push(anArray, anObject) and pop(anArray)
+// exist because the JavaScript Array.push(anObject) and Array.pop()
+// functions are not available in IE 5.0
+
+function push(anArray, anObject) {
+ anArray[anArray.length] = anObject;
+}
+function pop(anArray) {
+ if (anArray.length >= 1) {
+ delete anArray[anArray.length - 1];
+ anArray.length--;
+ }
+}
+
+function jsUnitGetParm(name)
+{
+ if (typeof(top.jsUnitParmHash[name]) != 'undefined')
+ {
+ return top.jsUnitParmHash[name];
+ }
+ return null;
+}
+
+if (top && typeof(top.xbDEBUG) != 'undefined' && top.xbDEBUG.on && top.testManager)
+{
+ top.xbDebugTraceObject('top.testManager.containerTestFrame', 'JSUnitException');
+ // asserts
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', '_displayStringForValue');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'error');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'argumentsIncludeComments');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'commentArg');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'nonCommentArg');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', '_validateArguments');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', '_assert');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'assert');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'assertTrue');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'assertEquals');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'assertNotEquals');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'assertNull');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'assertNotNull');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'assertUndefined');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'assertNotUndefined');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'assertNaN');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'assertNotNaN');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'isLoaded');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'setUp');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'tearDown');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'getFunctionName');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'getStackTrace');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'warn');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'inform');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'debug');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'setJsUnitTracer');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'trim');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'isBlank');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'newOnLoadEvent');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'push');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'pop');
+}
+
+function newOnLoadEvent() {
+ isTestPageLoaded = true;
+}
+
+function jsUnitSetOnLoad(windowRef, onloadHandler)
+{
+ var isKonqueror = navigator.userAgent.indexOf('Konqueror/') != -1 ||
+ navigator.userAgent.indexOf('Safari/') != -1;
+
+ if (typeof(windowRef.attachEvent) != 'undefined') {
+ // Internet Explorer, Opera
+ windowRef.attachEvent("onload", onloadHandler);
+ } else if (typeof(windowRef.addEventListener) != 'undefined' && !isKonqueror) {
+ // Mozilla, Konqueror
+ // exclude Konqueror due to load issues
+ windowRef.addEventListener("load", onloadHandler, false);
+ } else if (typeof(windowRef.document.addEventListener) != 'undefined' && !isKonqueror) {
+ // DOM 2 Events
+ // exclude Mozilla, Konqueror due to load issues
+ windowRef.document.addEventListener("load", onloadHandler, false);
+ } else if (typeof(windowRef.onload) != 'undefined' && windowRef.onload) {
+ windowRef.jsunit_original_onload = windowRef.onload;
+ windowRef.onload = function() {
+ windowRef.jsunit_original_onload();
+ onloadHandler();
+ };
+ } else {
+ // browsers that do not support windowRef.attachEvent or
+ // windowRef.addEventListener will override a page's own onload event
+ windowRef.onload = onloadHandler;
+ }
+}
+
+jsUnitSetOnLoad(window, newOnLoadEvent);
\ No newline at end of file
Added: branches/tomek/portal-dnd/jsunit/app/jsUnitMockTimeout.js
===================================================================
--- branches/tomek/portal-dnd/jsunit/app/jsUnitMockTimeout.js 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/app/jsUnitMockTimeout.js 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,81 @@
+// Mock setTimeout, clearTimeout
+// Contributed by Pivotal Computer Systems, www.pivotalsf.com
+
+var Clock = {
+ timeoutsMade: 0,
+ scheduledFunctions: {},
+ nowMillis: 0,
+ reset: function() {
+ this.scheduledFunctions = {};
+ this.nowMillis = 0;
+ this.timeoutsMade = 0;
+ },
+ tick: function(millis) {
+ var oldMillis = this.nowMillis;
+ var newMillis = oldMillis + millis;
+ this.runFunctionsWithinRange(oldMillis, newMillis);
+ this.nowMillis = newMillis;
+ },
+ runFunctionsWithinRange: function(oldMillis, nowMillis) {
+ var scheduledFunc;
+ var funcsToRun = [];
+ for (var timeoutKey in this.scheduledFunctions) {
+ scheduledFunc = this.scheduledFunctions[timeoutKey];
+ if (scheduledFunc != undefined &&
+ scheduledFunc.runAtMillis >= oldMillis &&
+ scheduledFunc.runAtMillis <= nowMillis) {
+ funcsToRun.push(scheduledFunc);
+ this.scheduledFunctions[timeoutKey] = undefined;
+ }
+ }
+
+ if (funcsToRun.length > 0) {
+ funcsToRun.sort(function(a, b) {
+ return a.runAtMillis - b.runAtMillis;
+ });
+ for (var i = 0; i < funcsToRun.length; ++i) {
+ try {
+ this.nowMillis = funcsToRun[i].runAtMillis;
+ funcsToRun[i].funcToCall();
+ if (funcsToRun[i].recurring) {
+ Clock.scheduleFunction(funcsToRun[i].timeoutKey,
+ funcsToRun[i].funcToCall,
+ funcsToRun[i].millis,
+ true);
+ }
+ } catch(e) {
+ }
+ }
+ this.runFunctionsWithinRange(oldMillis, nowMillis);
+ }
+ },
+ scheduleFunction: function(timeoutKey, funcToCall, millis, recurring) {
+ Clock.scheduledFunctions[timeoutKey] = {
+ runAtMillis: Clock.nowMillis + millis,
+ funcToCall: funcToCall,
+ recurring: recurring,
+ timeoutKey: timeoutKey,
+ millis: millis
+ };
+ }
+};
+
+function setTimeout(funcToCall, millis) {
+ Clock.timeoutsMade = Clock.timeoutsMade + 1;
+ Clock.scheduleFunction(Clock.timeoutsMade, funcToCall, millis, false);
+ return Clock.timeoutsMade;
+}
+
+function setInterval(funcToCall, millis) {
+ Clock.timeoutsMade = Clock.timeoutsMade + 1;
+ Clock.scheduleFunction(Clock.timeoutsMade, funcToCall, millis, true);
+ return Clock.timeoutsMade;
+}
+
+function clearTimeout(timeoutKey) {
+ Clock.scheduledFunctions[timeoutKey] = undefined;
+}
+
+function clearInterval(timeoutKey) {
+ Clock.scheduledFunctions[timeoutKey] = undefined;
+}
Added: branches/tomek/portal-dnd/jsunit/app/jsUnitTestManager.js
===================================================================
--- branches/tomek/portal-dnd/jsunit/app/jsUnitTestManager.js 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/app/jsUnitTestManager.js 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,705 @@
+function jsUnitTestManager() {
+ this._windowForAllProblemMessages = null;
+
+ this.container = top.frames.testContainer
+ this.documentLoader = top.frames.documentLoader;
+ this.mainFrame = top.frames.mainFrame;
+
+ this.containerController = this.container.frames.testContainerController;
+ this.containerTestFrame = this.container.frames.testFrame;
+
+ var mainData = this.mainFrame.frames.mainData;
+
+ // form elements on mainData frame
+ this.testFileName = mainData.document.testRunnerForm.testFileName;
+ this.runButton = mainData.document.testRunnerForm.runButton;
+ this.traceLevel = mainData.document.testRunnerForm.traceLevel;
+ this.closeTraceWindowOnNewRun = mainData.document.testRunnerForm.closeTraceWindowOnNewRun;
+ this.timeout = mainData.document.testRunnerForm.timeout;
+ this.setUpPageTimeout = mainData.document.testRunnerForm.setUpPageTimeout;
+
+ // image output
+ this.progressBar = this.mainFrame.frames.mainProgress.document.progress;
+
+ this.problemsListField = this.mainFrame.frames.mainErrors.document.testRunnerForm.problemsList;
+ this.testCaseResultsField = this.mainFrame.frames.mainResults.document.resultsForm.testCases;
+ this.resultsTimeField = this.mainFrame.frames.mainResults.document.resultsForm.time;
+
+ // 'layer' output frames
+ this.uiFrames = new Object();
+ this.uiFrames.mainStatus = this.mainFrame.frames.mainStatus;
+
+ var mainCounts = this.mainFrame.frames.mainCounts;
+
+ this.uiFrames.mainCountsErrors = mainCounts.frames.mainCountsErrors;
+ this.uiFrames.mainCountsFailures = mainCounts.frames.mainCountsFailures;
+ this.uiFrames.mainCountsRuns = mainCounts.frames.mainCountsRuns;
+ this._baseURL = "";
+
+ this.setup();
+}
+
+// seconds to wait for each test page to load
+jsUnitTestManager.TESTPAGE_WAIT_SEC = 120;
+jsUnitTestManager.TIMEOUT_LENGTH = 20;
+
+// seconds to wait for setUpPage to complete
+jsUnitTestManager.SETUPPAGE_TIMEOUT = 120;
+
+// milliseconds to wait between polls on setUpPages
+jsUnitTestManager.SETUPPAGE_INTERVAL = 100;
+
+jsUnitTestManager.RESTORED_HTML_DIV_ID = "jsUnitRestoredHTML";
+
+jsUnitTestManager.prototype.setup = function () {
+ this.totalCount = 0;
+ this.errorCount = 0;
+ this.failureCount = 0;
+ this._suiteStack = Array();
+
+ var initialSuite = new top.jsUnitTestSuite();
+ push(this._suiteStack, initialSuite);
+}
+
+jsUnitTestManager.prototype.start = function () {
+ this._baseURL = this.resolveUserEnteredTestFileName();
+ var firstQuery = this._baseURL.indexOf("?");
+ if (firstQuery >= 0) {
+ this._baseURL = this._baseURL.substring(0, firstQuery);
+ }
+ var lastSlash = this._baseURL.lastIndexOf("/");
+ var lastRevSlash = this._baseURL.lastIndexOf("\\");
+ if (lastRevSlash > lastSlash) {
+ lastSlash = lastRevSlash;
+ }
+ if (lastSlash > 0) {
+ this._baseURL = this._baseURL.substring(0, lastSlash + 1);
+ }
+
+ this._timeRunStarted = new Date();
+ this.initialize();
+ setTimeout('top.testManager._nextPage();', jsUnitTestManager.TIMEOUT_LENGTH);
+}
+
+jsUnitTestManager.prototype.getBaseURL = function () {
+ return this._baseURL;
+}
+
+jsUnitTestManager.prototype.doneLoadingPage = function (pageName) {
+ //this.containerTestFrame.setTracer(top.tracer);
+ this._testFileName = pageName;
+ if (this.isTestPageSuite())
+ this._handleNewSuite();
+ else
+ {
+ this._testIndex = 0;
+ this._testsInPage = this.getTestFunctionNames();
+ this._numberOfTestsInPage = this._testsInPage.length;
+ this._runTest();
+ }
+}
+
+jsUnitTestManager.prototype._handleNewSuite = function () {
+ var allegedSuite = this.containerTestFrame.suite();
+ if (allegedSuite.isjsUnitTestSuite) {
+ var newSuite = allegedSuite.clone();
+ if (newSuite.containsTestPages())
+ push(this._suiteStack, newSuite);
+ this._nextPage();
+ }
+ else {
+ this.fatalError('Invalid test suite in file ' + this._testFileName);
+ this.abort();
+ }
+}
+
+jsUnitTestManager.prototype._runTest = function () {
+ if (this._testIndex + 1 > this._numberOfTestsInPage)
+ {
+ // execute tearDownPage *synchronously*
+ // (unlike setUpPage which is asynchronous)
+ if (typeof this.containerTestFrame.tearDownPage == 'function') {
+ this.containerTestFrame.tearDownPage();
+ }
+
+ this._nextPage();
+ return;
+ }
+
+ if (this._testIndex == 0) {
+ this.storeRestoredHTML();
+ if (typeof(this.containerTestFrame.setUpPage) == 'function') {
+ // first test for this page and a setUpPage is defined
+ if (typeof(this.containerTestFrame.setUpPageStatus) == 'undefined') {
+ // setUpPage() not called yet, so call it
+ this.containerTestFrame.setUpPageStatus = false;
+ this.containerTestFrame.startTime = new Date();
+ this.containerTestFrame.setUpPage();
+ // try test again later
+ setTimeout('top.testManager._runTest()', jsUnitTestManager.SETUPPAGE_INTERVAL);
+ return;
+ }
+
+ if (this.containerTestFrame.setUpPageStatus != 'complete') {
+ top.status = 'setUpPage not completed... ' + this.containerTestFrame.setUpPageStatus + ' ' + (new Date());
+ if ((new Date() - this.containerTestFrame.startTime) / 1000 > this.getsetUpPageTimeout()) {
+ this.fatalError('setUpPage timed out without completing.');
+ if (!this.userConfirm('Retry Test Run?')) {
+ this.abort();
+ return;
+ }
+ this.containerTestFrame.startTime = (new Date());
+ }
+ // try test again later
+ setTimeout('top.testManager._runTest()', jsUnitTestManager.SETUPPAGE_INTERVAL);
+ return;
+ }
+ }
+ }
+
+ top.status = '';
+ // either not first test, or no setUpPage defined, or setUpPage completed
+ this.executeTestFunction(this._testsInPage[this._testIndex]);
+ this.totalCount++;
+ this.updateProgressIndicators();
+ this._testIndex++;
+ setTimeout('top.testManager._runTest()', jsUnitTestManager.TIMEOUT_LENGTH);
+}
+
+jsUnitTestManager.prototype._done = function () {
+ var secondsSinceRunBegan = (new Date() - this._timeRunStarted) / 1000;
+ this.setStatus('Done (' + secondsSinceRunBegan + ' seconds)');
+ this._cleanUp();
+ if (top.shouldSubmitResults()) {
+ this.resultsTimeField.value = secondsSinceRunBegan;
+ top.submitResults();
+ }
+}
+
+jsUnitTestManager.prototype._nextPage = function () {
+ this._restoredHTML = null;
+ if (this._currentSuite().hasMorePages()) {
+ this.loadPage(this._currentSuite().nextPage());
+ }
+ else {
+ pop(this._suiteStack);
+ if (this._currentSuite() == null)
+ this._done();
+ else
+ this._nextPage();
+ }
+}
+
+jsUnitTestManager.prototype._currentSuite = function () {
+ var suite = null;
+
+ if (this._suiteStack && this._suiteStack.length > 0)
+ suite = this._suiteStack[this._suiteStack.length - 1];
+
+ return suite;
+}
+
+jsUnitTestManager.prototype.calculateProgressBarProportion = function () {
+ if (this.totalCount == 0)
+ return 0;
+ var currentDivisor = 1;
+ var result = 0;
+
+ for (var i = 0; i < this._suiteStack.length; i++) {
+ var aSuite = this._suiteStack[i];
+ currentDivisor *= aSuite.testPages.length;
+ result += (aSuite.pageIndex - 1) / currentDivisor;
+ }
+ result += (this._testIndex + 1) / (this._numberOfTestsInPage * currentDivisor);
+ return result;
+}
+
+jsUnitTestManager.prototype._cleanUp = function () {
+ this.containerController.setTestPage('./app/emptyPage.html');
+ this.finalize();
+ top.tracer.finalize();
+}
+
+jsUnitTestManager.prototype.abort = function () {
+ this.setStatus('Aborted');
+ this._cleanUp();
+}
+
+jsUnitTestManager.prototype.getTimeout = function () {
+ var result = jsUnitTestManager.TESTPAGE_WAIT_SEC;
+ try {
+ result = eval(this.timeout.value);
+ }
+ catch (e) {
+ }
+ return result;
+}
+
+jsUnitTestManager.prototype.getsetUpPageTimeout = function () {
+ var result = jsUnitTestManager.SETUPPAGE_TIMEOUT;
+ try {
+ result = eval(this.setUpPageTimeout.value);
+ }
+ catch (e) {
+ }
+ return result;
+}
+
+jsUnitTestManager.prototype.isTestPageSuite = function () {
+ var result = false;
+ if (typeof(this.containerTestFrame.suite) == 'function')
+ {
+ result = true;
+ }
+ return result;
+}
+
+jsUnitTestManager.prototype.getTestFunctionNames = function () {
+ var testFrame = this.containerTestFrame;
+ var testFunctionNames = new Array();
+ var i;
+
+ if (testFrame && typeof(testFrame.exposeTestFunctionNames) == 'function')
+ return testFrame.exposeTestFunctionNames();
+
+ if (testFrame &&
+ testFrame.document &&
+ typeof(testFrame.document.scripts) != 'undefined' &&
+ testFrame.document.scripts.length > 0) { // IE5 and up
+ var scriptsInTestFrame = testFrame.document.scripts;
+
+ for (i = 0; i < scriptsInTestFrame.length; i++) {
+ var someNames = this._extractTestFunctionNamesFromScript(scriptsInTestFrame[i]);
+ if (someNames)
+ testFunctionNames = testFunctionNames.concat(someNames);
+ }
+ }
+ else {
+ for (i in testFrame) {
+ if (i.substring(0, 4) == 'test' && typeof(testFrame[i]) == 'function')
+ push(testFunctionNames, i);
+ }
+ }
+ return testFunctionNames;
+}
+
+jsUnitTestManager.prototype._extractTestFunctionNamesFromScript = function (aScript) {
+ var result;
+ var remainingScriptToInspect = aScript.text;
+ var currentIndex = this._indexOfTestFunctionIn(remainingScriptToInspect);
+ while (currentIndex != -1) {
+ if (!result)
+ result = new Array();
+
+ var fragment = remainingScriptToInspect.substring(currentIndex, remainingScriptToInspect.length);
+ result = result.concat(fragment.substring('function '.length, fragment.indexOf('(')));
+ remainingScriptToInspect = remainingScriptToInspect.substring(currentIndex + 12, remainingScriptToInspect.length);
+ currentIndex = this._indexOfTestFunctionIn(remainingScriptToInspect);
+ }
+ return result;
+}
+
+jsUnitTestManager.prototype._indexOfTestFunctionIn = function (string) {
+ return string.indexOf('function test');
+}
+
+jsUnitTestManager.prototype.loadPage = function (testFileName) {
+ this._testFileName = testFileName;
+ this._loadAttemptStartTime = new Date();
+ this.setStatus('Opening Test Page "' + this._testFileName + '"');
+ this.containerController.setTestPage(this._testFileName);
+ this._callBackWhenPageIsLoaded();
+}
+
+jsUnitTestManager.prototype._callBackWhenPageIsLoaded = function () {
+ if ((new Date() - this._loadAttemptStartTime) / 1000 > this.getTimeout()) {
+ this.fatalError('Reading Test Page ' + this._testFileName + ' timed out.\nMake sure that the file exists and is a Test Page.');
+ if (this.userConfirm('Retry Test Run?')) {
+ this.loadPage(this._testFileName);
+ return;
+ } else {
+ this.abort();
+ return;
+ }
+ }
+ if (!this._isTestFrameLoaded()) {
+ setTimeout('top.testManager._callBackWhenPageIsLoaded();', jsUnitTestManager.TIMEOUT_LENGTH);
+ return;
+ }
+ this.doneLoadingPage(this._testFileName);
+}
+
+jsUnitTestManager.prototype._isTestFrameLoaded = function () {
+ try {
+ return this.containerController.isPageLoaded();
+ }
+ catch (e) {
+ }
+ return false;
+}
+
+jsUnitTestManager.prototype.executeTestFunction = function (functionName) {
+ this._testFunctionName = functionName;
+ this.setStatus('Running test "' + this._testFunctionName + '"');
+ var excep = null;
+ var timeBefore = new Date();
+ try {
+ if (this._restoredHTML)
+ top.testContainer.testFrame.document.getElementById(jsUnitTestManager.RESTORED_HTML_DIV_ID).innerHTML = this._restoredHTML;
+ if (this.containerTestFrame.setUp !== JSUNIT_UNDEFINED_VALUE)
+ this.containerTestFrame.setUp();
+ this.containerTestFrame[this._testFunctionName]();
+ }
+ catch (e1) {
+ excep = e1;
+ }
+ finally {
+ try {
+ if (this.containerTestFrame.tearDown !== JSUNIT_UNDEFINED_VALUE)
+ this.containerTestFrame.tearDown();
+ }
+ catch (e2) {
+ //Unlike JUnit, only assign a tearDown exception to excep if there is not already an exception from the test body
+ if (excep == null)
+ excep = e2;
+ }
+ }
+ var timeTaken = (new Date() - timeBefore) / 1000;
+ if (excep != null)
+ this._handleTestException(excep);
+ var serializedTestCaseString = this._currentTestFunctionNameWithTestPageName(true) + "|" + timeTaken + "|";
+ if (excep == null)
+ serializedTestCaseString += "S||";
+ else {
+ if (typeof(excep.isJsUnitException) != 'undefined' && excep.isJsUnitException)
+ serializedTestCaseString += "F|";
+ else {
+ serializedTestCaseString += "E|";
+ }
+ serializedTestCaseString += this._problemDetailMessageFor(excep);
+ }
+ this._addOption(this.testCaseResultsField,
+ serializedTestCaseString,
+ serializedTestCaseString);
+}
+
+jsUnitTestManager.prototype._currentTestFunctionNameWithTestPageName = function(useFullyQualifiedTestPageName) {
+ var testURL = this.containerTestFrame.location.href;
+ var testQuery = testURL.indexOf("?");
+ if (testQuery >= 0) {
+ testURL = testURL.substring(0, testQuery);
+ }
+ if (!useFullyQualifiedTestPageName) {
+ if (testURL.substring(0, this._baseURL.length) == this._baseURL)
+ testURL = testURL.substring(this._baseURL.length);
+ }
+ return testURL + ':' + this._testFunctionName;
+}
+
+jsUnitTestManager.prototype._addOption = function(listField, problemValue, problemMessage) {
+ if (typeof(listField.ownerDocument) != 'undefined'
+ && typeof(listField.ownerDocument.createElement) != 'undefined') {
+ // DOM Level 2 HTML method.
+ // this is required for Opera 7 since appending to the end of the
+ // options array does not work, and adding an Option created by new Option()
+ // and appended by listField.options.add() fails due to WRONG_DOCUMENT_ERR
+ var problemDocument = listField.ownerDocument;
+ var errOption = problemDocument.createElement('option');
+ errOption.setAttribute('value', problemValue);
+ errOption.appendChild(problemDocument.createTextNode(problemMessage));
+ listField.appendChild(errOption);
+ }
+ else {
+ // new Option() is DOM 0
+ errOption = new Option(problemMessage, problemValue);
+ if (typeof(listField.add) != 'undefined') {
+ // DOM 2 HTML
+ listField.add(errOption, null);
+ }
+ else if (typeof(listField.options.add) != 'undefined') {
+ // DOM 0
+ listField.options.add(errOption, null);
+ }
+ else {
+ // DOM 0
+ listField.options[listField.length] = errOption;
+ }
+ }
+}
+
+jsUnitTestManager.prototype._handleTestException = function (excep) {
+ var problemMessage = this._currentTestFunctionNameWithTestPageName(false) + ' ';
+ var errOption;
+ if (typeof(excep.isJsUnitException) == 'undefined' || !excep.isJsUnitException) {
+ problemMessage += 'had an error';
+ this.errorCount++;
+ }
+ else {
+ problemMessage += 'failed';
+ this.failureCount++;
+ }
+ var listField = this.problemsListField;
+ this._addOption(listField,
+ this._problemDetailMessageFor(excep),
+ problemMessage);
+}
+
+jsUnitTestManager.prototype._problemDetailMessageFor = function (excep) {
+ var result = null;
+ if (typeof(excep.isJsUnitException) != 'undefined' && excep.isJsUnitException) {
+ result = '';
+ if (excep.comment != null)
+ result += ('"' + excep.comment + '"\n');
+
+ result += excep.jsUnitMessage;
+
+ if (excep.stackTrace)
+ result += '\n\nStack trace follows:\n' + excep.stackTrace;
+ }
+ else {
+ result = 'Error message is:\n"';
+ result +=
+ (typeof(excep.description) == 'undefined') ?
+ excep :
+ excep.description;
+ result += '"';
+ if (typeof(excep.stack) != 'undefined') // Mozilla only
+ result += '\n\nStack trace follows:\n' + excep.stack;
+ }
+ return result;
+}
+
+jsUnitTestManager.prototype._setTextOnLayer = function (layerName, str) {
+ try {
+ var content;
+ if (content = this.uiFrames[layerName].document.getElementById('content'))
+ content.innerHTML = str;
+ else
+ throw 'No content div found.';
+ }
+ catch (e) {
+ var html = '';
+ html += '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
+ html += '<html><head><link rel="stylesheet" type="text/css" href="css/jsUnitStyle.css"><\/head>';
+ html += '<body><div id="content">';
+ html += str;
+ html += '<\/div><\/body>';
+ html += '<\/html>';
+ this.uiFrames[layerName].document.write(html);
+ this.uiFrames[layerName].document.close();
+ }
+}
+
+jsUnitTestManager.prototype.setStatus = function (str) {
+ this._setTextOnLayer('mainStatus', '<b>Status:<\/b> ' + str);
+}
+
+jsUnitTestManager.prototype._setErrors = function (n) {
+ this._setTextOnLayer('mainCountsErrors', '<b>Errors: <\/b>' + n);
+}
+
+jsUnitTestManager.prototype._setFailures = function (n) {
+ this._setTextOnLayer('mainCountsFailures', '<b>Failures:<\/b> ' + n);
+}
+
+jsUnitTestManager.prototype._setTotal = function (n) {
+ this._setTextOnLayer('mainCountsRuns', '<b>Runs:<\/b> ' + n);
+}
+
+jsUnitTestManager.prototype._setProgressBarImage = function (imgName) {
+ this.progressBar.src = imgName;
+}
+
+jsUnitTestManager.prototype._setProgressBarWidth = function (w) {
+ this.progressBar.width = w;
+}
+
+jsUnitTestManager.prototype.updateProgressIndicators = function () {
+ this._setTotal(this.totalCount);
+ this._setErrors(this.errorCount);
+ this._setFailures(this.failureCount);
+ this._setProgressBarWidth(300 * this.calculateProgressBarProportion());
+
+ if (this.errorCount > 0 || this.failureCount > 0)
+ this._setProgressBarImage('../images/red.gif');
+ else
+ this._setProgressBarImage('../images/green.gif');
+}
+
+jsUnitTestManager.prototype.showMessageForSelectedProblemTest = function () {
+ var problemTestIndex = this.problemsListField.selectedIndex;
+ if (problemTestIndex != -1)
+ this.fatalError(this.problemsListField[problemTestIndex].value);
+}
+
+jsUnitTestManager.prototype.showMessagesForAllProblemTests = function () {
+ if (this.problemsListField.length == 0)
+ return;
+
+ try {
+ if (this._windowForAllProblemMessages && !this._windowForAllProblemMessages.closed)
+ this._windowForAllProblemMessages.close();
+ }
+ catch(e) {
+ }
+
+ this._windowForAllProblemMessages = window.open('', '', 'width=600, height=350,status=no,resizable=yes,scrollbars=yes');
+ var resDoc = this._windowForAllProblemMessages.document;
+ resDoc.write('<html><head><link rel="stylesheet" href="../css/jsUnitStyle.css"><title>Tests with problems - JsUnit<\/title><head><body>');
+ resDoc.write('<p class="jsUnitSubHeading">Tests with problems (' + this.problemsListField.length + ' total) - JsUnit<\/p>');
+ resDoc.write('<p class="jsUnitSubSubHeading"><i>Running on ' + navigator.userAgent + '</i></p>');
+ for (var i = 0; i < this.problemsListField.length; i++)
+ {
+ resDoc.write('<p class="jsUnitDefault">');
+ resDoc.write('<b>' + (i + 1) + '. ');
+ resDoc.write(this.problemsListField[i].text);
+ resDoc.write('<\/b><\/p><p><pre>');
+ resDoc.write(this._makeHTMLSafe(this.problemsListField[i].value));
+ resDoc.write('<\/pre><\/p>');
+ }
+
+ resDoc.write('<\/body><\/html>');
+ resDoc.close();
+}
+
+jsUnitTestManager.prototype._makeHTMLSafe = function (string) {
+ string = string.replace(/&/g, '&');
+ string = string.replace(/</g, '<');
+ string = string.replace(/>/g, '>');
+ return string;
+}
+
+jsUnitTestManager.prototype._clearProblemsList = function () {
+ var listField = this.problemsListField;
+ var initialLength = listField.options.length;
+
+ for (var i = 0; i < initialLength; i++)
+ listField.remove(0);
+}
+
+jsUnitTestManager.prototype.initialize = function () {
+ this.setStatus('Initializing...');
+ this._setRunButtonEnabled(false);
+ this._clearProblemsList();
+ this.updateProgressIndicators();
+ this.setStatus('Done initializing');
+}
+
+jsUnitTestManager.prototype.finalize = function () {
+ this._setRunButtonEnabled(true);
+}
+
+jsUnitTestManager.prototype._setRunButtonEnabled = function (b) {
+ this.runButton.disabled = !b;
+}
+
+jsUnitTestManager.prototype.getTestFileName = function () {
+ var rawEnteredFileName = this.testFileName.value;
+ var result = rawEnteredFileName;
+
+ while (result.indexOf('\\') != -1)
+ result = result.replace('\\', '/');
+
+ return result;
+}
+
+jsUnitTestManager.prototype.getTestFunctionName = function () {
+ return this._testFunctionName;
+}
+
+jsUnitTestManager.prototype.resolveUserEnteredTestFileName = function (rawText) {
+ var userEnteredTestFileName = top.testManager.getTestFileName();
+
+ // only test for file:// since Opera uses a different format
+ if (userEnteredTestFileName.indexOf('http://') == 0 || userEnteredTestFileName.indexOf('https://') == 0 || userEnteredTestFileName.indexOf('file://') == 0)
+ return userEnteredTestFileName;
+
+ return getTestFileProtocol() + this.getTestFileName();
+}
+
+jsUnitTestManager.prototype.storeRestoredHTML = function () {
+ if (document.getElementById && top.testContainer.testFrame.document.getElementById(jsUnitTestManager.RESTORED_HTML_DIV_ID))
+ this._restoredHTML = top.testContainer.testFrame.document.getElementById(jsUnitTestManager.RESTORED_HTML_DIV_ID).innerHTML;
+}
+
+jsUnitTestManager.prototype.fatalError = function(aMessage) {
+ if (top.shouldSubmitResults())
+ this.setStatus(aMessage);
+ else
+ alert(aMessage);
+}
+
+jsUnitTestManager.prototype.userConfirm = function(aMessage) {
+ if (top.shouldSubmitResults())
+ return false;
+ else
+ return confirm(aMessage);
+}
+
+function getTestFileProtocol() {
+ return getDocumentProtocol();
+}
+
+function getDocumentProtocol() {
+ var protocol = top.document.location.protocol;
+
+ if (protocol == "file:")
+ return "file:///";
+
+ if (protocol == "http:")
+ return "http://";
+
+ if (protocol == 'https:')
+ return 'https://';
+
+ if (protocol == "chrome:")
+ return "chrome://";
+
+ return null;
+}
+
+function browserSupportsReadingFullPathFromFileField() {
+ return !isOpera() && !isIE7();
+}
+
+function isOpera() {
+ return navigator.userAgent.toLowerCase().indexOf("opera") != -1;
+}
+
+function isIE7() {
+ return navigator.userAgent.toLowerCase().indexOf("msie 7") != -1;
+}
+
+function isBeingRunOverHTTP() {
+ return getDocumentProtocol() == "http://";
+}
+
+function getWebserver() {
+ if (isBeingRunOverHTTP()) {
+ var myUrl = location.href;
+ var myUrlWithProtocolStripped = myUrl.substring(myUrl.indexOf("/") + 2);
+ return myUrlWithProtocolStripped.substring(0, myUrlWithProtocolStripped.indexOf("/"));
+ }
+ return null;
+}
+
+// the functions push(anArray, anObject) and pop(anArray)
+// exist because the JavaScript Array.push(anObject) and Array.pop()
+// functions are not available in IE 5.0
+
+function push(anArray, anObject) {
+ anArray[anArray.length] = anObject;
+}
+
+function pop(anArray) {
+ if (anArray.length >= 1) {
+ delete anArray[anArray.length - 1];
+ anArray.length--;
+ }
+}
+
+if (xbDEBUG.on) {
+ xbDebugTraceObject('window', 'jsUnitTestManager');
+ xbDebugTraceFunction('window', 'getTestFileProtocol');
+ xbDebugTraceFunction('window', 'getDocumentProtocol');
+}
Added: branches/tomek/portal-dnd/jsunit/app/jsUnitTestSuite.js
===================================================================
--- branches/tomek/portal-dnd/jsunit/app/jsUnitTestSuite.js 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/app/jsUnitTestSuite.js 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,44 @@
+function jsUnitTestSuite() {
+ this.isjsUnitTestSuite = true;
+ this.testPages = Array();
+ this.pageIndex = 0;
+}
+
+jsUnitTestSuite.prototype.addTestPage = function (pageName)
+{
+ this.testPages[this.testPages.length] = pageName;
+}
+
+jsUnitTestSuite.prototype.addTestSuite = function (suite)
+{
+ for (var i = 0; i < suite.testPages.length; i++)
+ this.addTestPage(suite.testPages[i]);
+}
+
+jsUnitTestSuite.prototype.containsTestPages = function ()
+{
+ return this.testPages.length > 0;
+}
+
+jsUnitTestSuite.prototype.nextPage = function ()
+{
+ return this.testPages[this.pageIndex++];
+}
+
+jsUnitTestSuite.prototype.hasMorePages = function ()
+{
+ return this.pageIndex < this.testPages.length;
+}
+
+jsUnitTestSuite.prototype.clone = function ()
+{
+ var clone = new jsUnitTestSuite();
+ clone.testPages = this.testPages;
+ return clone;
+}
+
+if (xbDEBUG.on)
+{
+ xbDebugTraceObject('window', 'jsUnitTestSuite');
+}
+
Added: branches/tomek/portal-dnd/jsunit/app/jsUnitTracer.js
===================================================================
--- branches/tomek/portal-dnd/jsunit/app/jsUnitTracer.js 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/app/jsUnitTracer.js 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,102 @@
+var TRACE_LEVEL_NONE = new JsUnitTraceLevel(0, null);
+var TRACE_LEVEL_WARNING = new JsUnitTraceLevel(1, "#FF0000");
+var TRACE_LEVEL_INFO = new JsUnitTraceLevel(2, "#009966");
+var TRACE_LEVEL_DEBUG = new JsUnitTraceLevel(3, "#0000FF");
+
+function JsUnitTracer(testManager) {
+ this._testManager = testManager;
+ this._traceWindow = null;
+ this.popupWindowsBlocked = false;
+}
+
+JsUnitTracer.prototype.initialize = function() {
+ if (this._traceWindow != null && top.testManager.closeTraceWindowOnNewRun.checked)
+ this._traceWindow.close();
+ this._traceWindow = null;
+}
+
+JsUnitTracer.prototype.finalize = function() {
+ if (this._traceWindow != null) {
+ this._traceWindow.document.write('<\/body>\n<\/html>');
+ this._traceWindow.document.close();
+ }
+}
+
+JsUnitTracer.prototype.warn = function() {
+ this._trace(arguments[0], arguments[1], TRACE_LEVEL_WARNING);
+}
+
+JsUnitTracer.prototype.inform = function() {
+ this._trace(arguments[0], arguments[1], TRACE_LEVEL_INFO);
+}
+
+JsUnitTracer.prototype.debug = function() {
+ this._trace(arguments[0], arguments[1], TRACE_LEVEL_DEBUG);
+}
+
+JsUnitTracer.prototype._trace = function(message, value, traceLevel) {
+ if (!top.shouldSubmitResults() && this._getChosenTraceLevel().matches(traceLevel)) {
+ var traceString = message;
+ if (value)
+ traceString += ': ' + value;
+ var prefix = this._testManager.getTestFileName() + ":" +
+ this._testManager.getTestFunctionName() + " - ";
+ this._writeToTraceWindow(prefix, traceString, traceLevel);
+ }
+}
+
+JsUnitTracer.prototype._getChosenTraceLevel = function() {
+ var levelNumber = eval(top.testManager.traceLevel.value);
+ return traceLevelByLevelNumber(levelNumber);
+}
+
+JsUnitTracer.prototype._writeToTraceWindow = function(prefix, traceString, traceLevel) {
+ var htmlToAppend = '<p class="jsUnitDefault">' + prefix + '<font color="' + traceLevel.getColor() + '">' + traceString + '</font><\/p>\n';
+ this._getTraceWindow().document.write(htmlToAppend);
+}
+
+JsUnitTracer.prototype._getTraceWindow = function() {
+ if (this._traceWindow == null && !top.shouldSubmitResults() && !this.popupWindowsBlocked) {
+ this._traceWindow = window.open('', '', 'width=600, height=350,status=no,resizable=yes,scrollbars=yes');
+ if (!this._traceWindow)
+ this.popupWindowsBlocked = true;
+ else {
+ var resDoc = this._traceWindow.document;
+ resDoc.write('<html>\n<head>\n<link rel="stylesheet" href="css/jsUnitStyle.css">\n<title>Tracing - JsUnit<\/title>\n<head>\n<body>');
+ resDoc.write('<h2>Tracing - JsUnit<\/h2>\n');
+ resDoc.write('<p class="jsUnitDefault"><i>(Traces are color coded: ');
+ resDoc.write('<font color="' + TRACE_LEVEL_WARNING.getColor() + '">Warning</font> - ');
+ resDoc.write('<font color="' + TRACE_LEVEL_INFO.getColor() + '">Information</font> - ');
+ resDoc.write('<font color="' + TRACE_LEVEL_DEBUG.getColor() + '">Debug</font>');
+ resDoc.write(')</i></p>');
+ }
+ }
+ return this._traceWindow;
+}
+
+if (xbDEBUG.on) {
+ xbDebugTraceObject('window', 'JsUnitTracer');
+}
+
+function JsUnitTraceLevel(levelNumber, color) {
+ this._levelNumber = levelNumber;
+ this._color = color;
+}
+
+JsUnitTraceLevel.prototype.matches = function(anotherTraceLevel) {
+ return this._levelNumber >= anotherTraceLevel._levelNumber;
+}
+
+JsUnitTraceLevel.prototype.getColor = function() {
+ return this._color;
+}
+
+function traceLevelByLevelNumber(levelNumber) {
+ switch (levelNumber) {
+ case 0: return TRACE_LEVEL_NONE;
+ case 1: return TRACE_LEVEL_WARNING;
+ case 2: return TRACE_LEVEL_INFO;
+ case 3: return TRACE_LEVEL_DEBUG;
+ }
+ return null;
+}
\ No newline at end of file
Added: branches/tomek/portal-dnd/jsunit/app/jsUnitVersionCheck.js
===================================================================
--- branches/tomek/portal-dnd/jsunit/app/jsUnitVersionCheck.js 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/app/jsUnitVersionCheck.js 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,59 @@
+var versionRequest;
+
+function isOutOfDate(newVersionNumber) {
+ return JSUNIT_VERSION < newVersionNumber;
+}
+
+function sendRequestForLatestVersion(url) {
+ versionRequest = createXmlHttpRequest();
+ if (versionRequest) {
+ versionRequest.onreadystatechange = requestStateChanged;
+ versionRequest.open("GET", url, true);
+ versionRequest.send(null);
+ }
+}
+
+function createXmlHttpRequest() {
+ if (window.XMLHttpRequest)
+ return new XMLHttpRequest();
+ else if (window.ActiveXObject)
+ return new ActiveXObject("Microsoft.XMLHTTP");
+}
+
+function requestStateChanged() {
+ if (versionRequest && versionRequest.readyState == 4) {
+ if (versionRequest.status == 200) {
+ var latestVersion = versionRequest.responseText;
+ if (isOutOfDate(latestVersion))
+ versionNotLatest(latestVersion);
+ else
+ versionLatest();
+ } else
+ versionCheckError();
+ }
+}
+
+function checkForLatestVersion(url) {
+ setLatestVersionDivHTML("Checking for newer version...");
+ try {
+ sendRequestForLatestVersion(url);
+ } catch (e) {
+ setLatestVersionDivHTML("An error occurred while checking for a newer version: " + e.message);
+ }
+}
+
+function versionNotLatest(latestVersion) {
+ setLatestVersionDivHTML('<font color="red">A newer version of JsUnit, version ' + latestVersion + ', is available.</font>');
+}
+
+function versionLatest() {
+ setLatestVersionDivHTML("You are running the latest version of JsUnit.");
+}
+
+function setLatestVersionDivHTML(string) {
+ document.getElementById("versionCheckDiv").innerHTML = string;
+}
+
+function versionCheckError() {
+ setLatestVersionDivHTML("An error occurred while checking for a newer version.");
+}
\ No newline at end of file
Added: branches/tomek/portal-dnd/jsunit/app/main-counts-errors.html
===================================================================
--- branches/tomek/portal-dnd/jsunit/app/main-counts-errors.html 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/app/main-counts-errors.html 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title></title>
+ <link rel="stylesheet" type="text/css" href="../css/jsUnitStyle.css">
+</head>
+
+<body>
+<div id="content"><b>Errors:</b> 0</div>
+</body>
+</html>
\ No newline at end of file
Added: branches/tomek/portal-dnd/jsunit/app/main-counts-failures.html
===================================================================
--- branches/tomek/portal-dnd/jsunit/app/main-counts-failures.html 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/app/main-counts-failures.html 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title></title>
+ <link rel="stylesheet" type="text/css" href="../css/jsUnitStyle.css">
+</head>
+
+<body>
+<div id="content"><b>Failures:</b> 0</div>
+
+</body>
+</html>
Added: branches/tomek/portal-dnd/jsunit/app/main-counts-runs.html
===================================================================
--- branches/tomek/portal-dnd/jsunit/app/main-counts-runs.html 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/app/main-counts-runs.html 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title></title>
+ <link rel="stylesheet" type="text/css" href="../css/jsUnitStyle.css">
+</head>
+
+<body>
+<div id="content"><b>Runs:</b> 0</div>
+
+</body>
+</html>
Added: branches/tomek/portal-dnd/jsunit/app/main-counts.html
===================================================================
--- branches/tomek/portal-dnd/jsunit/app/main-counts.html 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/app/main-counts.html 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,21 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title></title>
+</head>
+
+<frameset cols="200,190,*" border="0">
+ <frame name="mainCountsRuns" src="main-counts-runs.html" scrolling="no" frameborder="0">
+ <frame name="mainCountsErrors" src="main-counts-errors.html" scrolling="no" frameborder="0">
+ <frame name="mainCountsFailures" src="main-counts-failures.html" scrolling="no" frameborder="0">
+
+ <noframes>
+ <body>
+ <p>jsUnit uses frames in order to remove dependencies upon a browser's implementation of document.getElementById
+ and HTMLElement.innerHTML.</p>
+ </body>
+ </noframes>
+</frameset>
+</html>
+
Added: branches/tomek/portal-dnd/jsunit/app/main-data.html
===================================================================
--- branches/tomek/portal-dnd/jsunit/app/main-data.html 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/app/main-data.html 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,178 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>JsUnit main-data.html</title>
+ <link rel="stylesheet" type="text/css" href="../css/jsUnitStyle.css">
+ <script language="JavaScript" type="text/javascript" src="jsUnitCore.js"></script>
+ <script language="JavaScript" type="text/javascript" src="jsUnitVersionCheck.js"></script>
+ <script language="JavaScript" type="text/javascript">
+
+ function pageLoaded() {
+ giveFocusToTestFileNameField();
+ }
+
+ function giveFocusToTestFileNameField() {
+ if (document.testRunnerForm.testFileName.type != "hidden")
+ document.testRunnerForm.testFileName.focus();
+ }
+
+ function kickOffTests() {
+ //
+ // Check if Init was called by onload handler
+ //
+ if (typeof(top.testManager) == 'undefined') {
+ top.init();
+ }
+
+ if (isBlank(top.testManager.getTestFileName())) {
+ top.testManager.fatalError('No Test Page specified.');
+ return;
+ }
+
+ top.testManager.setup();
+
+ top.testManager._currentSuite().addTestPage(top.testManager.resolveUserEnteredTestFileName());
+ top.tracer.initialize();
+
+ var traceLevel = document.forms.testRunnerForm.traceLevel;
+ if (traceLevel.value != '0')
+ {
+ var traceWindow = top.tracer._getTraceWindow();
+ if (traceWindow) {
+ traceWindow.focus();
+ }
+ else {
+ top.testManager.fatalError('Tracing requires popup windows, and popups are blocked in your browser.\n\nPlease enable popups if you wish to use tracing.');
+ }
+ }
+
+ top.testManager.start();
+ }
+
+ </script>
+</head>
+
+<body onload="pageLoaded();">
+<table width="100%" cellpadding="0" cellspacing="0" border="0" summary="jsUnit Information" bgcolor="#DDDDDD">
+ <tr>
+ <td width="1"><a href="http://www.jsunit.net" target="_blank"><img src="../images/logo_jsunit.gif" alt="JsUnit" border="0"/></a></td>
+ <td width="50"> </td>
+ <th nowrap align="left">
+ <h4>JsUnit <script language="javascript">document.write(JSUNIT_VERSION);</script> TestRunner</h4>
+ <font size="-2"><i>Running on <script language="javascript" type="text/javascript">document.write(navigator.userAgent);</script>
+ </i></font>
+ </th>
+
+ <td nowrap align="right" valign="middle">
+ <font size="-2">
+ <b><a href="http://www.jsunit.net/" target="_blank">www.jsunit.net</a></b> <br>
+ </font>
+ <a href="http://www.pivotalsf.com/" target="top">
+ <img border="0" src="../images/powerby-transparent.gif" alt="Powered By Pivotal">
+ </a>
+ </td>
+ </tr>
+</table>
+
+<form name="testRunnerForm" action="">
+ <script type="text/javascript" language="javascript">
+ if (!jsUnitGetParm('testpage')) {
+ document.write("<p>Enter the filename of the Test Page to be run:</p>");
+ } else {
+ document.write("<br>");
+ };
+ </script>
+
+ <table cellpadding="0" cellspacing="0" border="0" summary="Form for entering test case location">
+ <tr>
+ <td align="center" valign="middle">
+ <script language="JavaScript" type="text/javascript">
+ document.write(top.getDocumentProtocol());
+ </script>
+ </td>
+
+ <td nowrap align="center" valign="bottom">
+
+ <script language="JavaScript" type="text/javascript">
+ var specifiedTestPage = jsUnitGetParm('testpage');
+ if (specifiedTestPage) {
+ var html = '<input type="hidden" name="testFileName" value="';
+ var valueString = '';
+ if ((top.getDocumentProtocol() == 'http://' || top.getDocumentProtocol() == 'https://') && jsUnitGetParm('testpage').indexOf('/') == 0)
+ valueString += top.location.host;
+ valueString += specifiedTestPage;
+ var testParms = top.jsUnitConstructTestParms();
+ if (testParms != '') {
+ valueString += '?';
+ valueString += testParms;
+ }
+ html += valueString;
+ html += '">';
+ html += valueString;
+ document.write(html);
+ } else {
+ if (top.getDocumentProtocol() == 'file:///' && top.browserSupportsReadingFullPathFromFileField())
+ document.write('<input type="file" name="testFileName" size="60">');
+ else
+ document.write('<input type="text" name="testFileName" size="60">');
+ }
+ </script>
+ <input type="button" name="runButton" value="Run" onclick="kickOffTests()">
+ </td>
+ </tr>
+ </table>
+ <br>
+ <hr>
+
+ <table cellpadding="0" cellspacing="0" border="0" summary="Choose Trace Level">
+ <tr>
+ <td nowrap>Trace level:</td>
+
+ <td><select name="traceLevel">
+ <option value="0" selected>
+ no tracing
+ </option>
+
+ <option value="1">
+ warning (lowest)
+ </option>
+
+ <option value="2">
+ info
+ </option>
+
+ <option value="3">
+ debug (highest)
+ </option>
+ </select></td>
+
+ <td> </td>
+
+ <td><input type="checkbox" name="closeTraceWindowOnNewRun" checked></td>
+ <td nowrap>Close old trace window on new run</td>
+
+ <td> </td>
+
+ <td nowrap>Page load timeout:</td>
+ <td>
+ <script language="javascript" type="text/javascript">
+ document.write('<input type="text" size="2" name="timeout" value="' + top.jsUnitTestManager.TESTPAGE_WAIT_SEC + '">');
+ </script>
+ </td>
+
+ <td> </td>
+
+ <td nowrap>Setup page timeout:</td>
+ <td>
+ <script language="javascript" type="text/javascript">
+ document.write('<input type="text" size="2" name="setUpPageTimeout" value="' + top.jsUnitTestManager.SETUPPAGE_TIMEOUT + '">');
+ </script>
+ </td>
+ </tr>
+ </table>
+ <hr>
+</form>
+</body>
+</html>
Added: branches/tomek/portal-dnd/jsunit/app/main-errors.html
===================================================================
--- branches/tomek/portal-dnd/jsunit/app/main-errors.html 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/app/main-errors.html 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,23 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>JsUnit main-errors.html</title>
+ <link rel="stylesheet" type="text/css" href="../css/jsUnitStyle.css">
+</head>
+
+<body>
+<hr>
+
+<form name="testRunnerForm" action="javascript:top.testManager.showMessageForSelectedProblemTest()">
+ <p>Errors and failures: </p>
+ <select size="5" ondblclick="top.testManager.showMessageForSelectedProblemTest()" name="problemsList">
+ <option> </option>
+ </select>
+ <br>
+ <input type="button" value="Show selected" onclick="top.testManager.showMessageForSelectedProblemTest()">
+
+ <input type="button" value="Show all" onclick="top.testManager.showMessagesForAllProblemTests()">
+</form>
+</body>
+</html>
Added: branches/tomek/portal-dnd/jsunit/app/main-frame.html
===================================================================
--- branches/tomek/portal-dnd/jsunit/app/main-frame.html 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/app/main-frame.html 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,19 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
+<html>
+<head>
+ <title>jsUnit Main Frame</title>
+</head>
+<frameset rows="230,30,30,30,0,*" border="0">>
+ <frame name="mainData" src="main-data.html" scrolling="no" frameborder="0">
+ <frame name="mainStatus" src="main-status.html" scrolling="no" frameborder="0">
+ <frame name="mainProgress" src="main-progress.html" scrolling="no" frameborder="0">
+ <frame name="mainCounts" src="main-counts.html" scrolling="no" frameborder="0">
+ <frame name="mainResults" src="main-results.html" scrolling="no" frameborder="0">
+ <frame name="mainErrors" src="main-errors.html" scrolling="no" frameborder="0">
+ <noframes>
+ <body>
+ <p>Sorry, JsUnit requires frames.</p>
+ </body>
+ </noframes>
+</frameset>
+</html>
Added: branches/tomek/portal-dnd/jsunit/app/main-loader.html
===================================================================
--- branches/tomek/portal-dnd/jsunit/app/main-loader.html 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/app/main-loader.html 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,45 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>jsUnit External Data Document loader</title>
+ <script language="JavaScript" type="text/javascript">
+
+ var loadStatus;
+ var callback = function () {
+ };
+
+ function buffer() {
+ return window.frames.documentBuffer;
+ }
+
+ function load(uri) {
+ loadStatus = 'loading';
+ buffer().document.location.href = uri;
+ }
+
+ function loadComplete() {
+ top.xbDEBUG.dump('main-loader.html:loadComplete(): loadStatus = ' + loadStatus + ' href=' + buffer().document.location.href);
+ if (loadStatus == 'loading') {
+ loadStatus = 'complete';
+ callback();
+ callback = function () {
+ };
+ }
+ }
+
+ if (top.xbDEBUG.on) {
+ var scopeName = 'main_loader_' + (new Date()).getTime();
+ top[scopeName] = window;
+ top.xbDebugTraceFunction(scopeName, 'buffer');
+ top.xbDebugTraceFunction(scopeName, 'load');
+ top.xbDebugTraceFunction(scopeName, 'loadComplete');
+ }
+
+ </script>
+</head>
+
+<body>
+<iframe name="documentBuffer" onload="loadComplete()"></iframe>
+</body>
+</html>
Added: branches/tomek/portal-dnd/jsunit/app/main-progress.html
===================================================================
--- branches/tomek/portal-dnd/jsunit/app/main-progress.html 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/app/main-progress.html 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,25 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>JsUnit main-progress.html</title>
+ <link rel="stylesheet" type="text/css" href="../css/jsUnitStyle.css">
+</head>
+
+<body>
+<table width="375" cellpadding="0" cellspacing="0" border="0" summary="Test progress indicator">
+ <tr>
+ <td width="65" valign="top"><b>Progress:</b></td>
+
+ <td width="300" height="14" valign="middle">
+ <table width="300" cellpadding="0" cellspacing="0" border="1" summary="Progress image">
+ <tr>
+ <td width="300" height="14" valign="top"><img name="progress" height="14" width="0"
+ alt="progress image" src="../images/green.gif"></td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+</table>
+</body>
+</html>
Added: branches/tomek/portal-dnd/jsunit/app/main-results.html
===================================================================
--- branches/tomek/portal-dnd/jsunit/app/main-results.html 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/app/main-results.html 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,67 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>JsUnit main-results.html</title>
+ <link rel="stylesheet" type="text/css" href="../css/jsUnitStyle.css">
+</head>
+
+<body>
+<script language="javascript" type="text/javascript">
+ var DEFAULT_SUBMIT_WEBSERVER = "localhost:8080";
+
+ function submitUrlFromSpecifiedUrl() {
+ var result = "";
+ var specifiedUrl = top.getSpecifiedResultUrl();
+ if (specifiedUrl.indexOf("http://") != 0)
+ result = "http://";
+ result += specifiedUrl;
+ return result;
+ }
+
+ function submitUrlFromTestRunnerLocation() {
+ var result = "http://";
+ var webserver = top.getWebserver();
+ if (webserver == null) // running over file:///
+ webserver = DEFAULT_SUBMIT_WEBSERVER;
+ result += webserver;
+ result += "/jsunit/acceptor";
+ return result;
+ }
+
+ var submitUrl = "";
+ if (top.wasResultUrlSpecified()) {
+ submitUrl = submitUrlFromSpecifiedUrl();
+ } else {
+ submitUrl = submitUrlFromTestRunnerLocation();
+ }
+
+ var formString = "<form name=\"resultsForm\" action=\"" + submitUrl + "\" method=\"post\" target=\"_top\">";
+ document.write(formString);
+</script>
+<input type="hidden" name="id">
+<input type="hidden" name="userAgent">
+<input type="hidden" name="jsUnitVersion">
+<input type="hidden" name="time">
+<input type="hidden" name="url">
+<input type="hidden" name="cacheBuster">
+<select size="5" name="testCases" multiple></select>
+</form>
+<script language="javascript" type="text/javascript">
+ function populateHeaderFields(id, userAgent, jsUnitVersion, baseURL) {
+ document.resultsForm.id.value = id;
+ document.resultsForm.userAgent.value = userAgent;
+ document.resultsForm.jsUnitVersion.value = jsUnitVersion;
+ document.resultsForm.url.value = baseURL;
+ document.resultsForm.cacheBuster.value = new Date().getTime();
+ }
+ function submitResults() {
+ var testCasesField = document.resultsForm.testCases;
+ for (var i = 0; i < testCasesField.length; i++) {
+ testCasesField[i].selected = true;
+ }
+ document.resultsForm.submit();
+ }
+</script>
+</body>
+</html>
Added: branches/tomek/portal-dnd/jsunit/app/main-status.html
===================================================================
--- branches/tomek/portal-dnd/jsunit/app/main-status.html 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/app/main-status.html 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,13 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>JsUnit main-status.html</title>
+ <link rel="stylesheet" type="text/css" href="../css/jsUnitStyle.css">
+</head>
+
+<body>
+<div id="content"><b>Status:</b> (Idle)</div>
+
+</body>
+</html>
Added: branches/tomek/portal-dnd/jsunit/app/testContainer.html
===================================================================
--- branches/tomek/portal-dnd/jsunit/app/testContainer.html 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/app/testContainer.html 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,16 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>JsUnit Test Container</title>
+</head>
+<frameset rows="0, *" border="0">
+ <frame name="testContainerController" src="testContainerController.html">
+ <frame name="testFrame" src="emptyPage.html">
+ <noframes>
+ <body>
+ <p>Sorry, JsUnit requires frames.</p>
+ </body>
+ </noframes>
+</frameset>
+</html>
Added: branches/tomek/portal-dnd/jsunit/app/testContainerController.html
===================================================================
--- branches/tomek/portal-dnd/jsunit/app/testContainerController.html 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/app/testContainerController.html 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,77 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>JsUnit Test Container Controller</title>
+ <script language="javascript" type="text/javascript">
+ var containerReady = false;
+
+ function init() {
+ containerReady = true;
+ }
+
+ function isPageLoaded() {
+ if (!containerReady)
+ return false;
+
+ var isTestPageLoaded = false;
+
+ try {
+ // attempt to access the var isTestPageLoaded in the testFrame
+ if (typeof(top.testManager.containerTestFrame.isTestPageLoaded) != 'undefined') {
+ isTestPageLoaded = top.testManager.containerTestFrame.isTestPageLoaded;
+ }
+
+ // ok, if the above did not throw an exception, then the
+ // variable is defined. If the onload has not fired in the
+ // testFrame then isTestPageLoaded is still false. Otherwise
+ // the testFrame has set it to true
+ }
+ catch (e) {
+ // an error occured while attempting to access the isTestPageLoaded
+ // in the testFrame, therefore the testFrame has not loaded yet
+ isTestPageLoaded = false;
+ }
+ return isTestPageLoaded;
+ }
+
+ function isContainerReady() {
+ return containerReady;
+ }
+
+ function setNotReady() {
+ try {
+ // attempt to set the isTestPageLoaded variable
+ // in the test frame to false.
+ top.testManager.containerTestFrame.isTestPageLoaded = false;
+ }
+ catch (e) {
+ // testFrame.isTestPageLoaded not available... ignore
+ }
+ }
+ function setTestPage(testPageURI) {
+ setNotReady();
+ top.jsUnitParseParms(testPageURI);
+ testPageURI = appendCacheBusterParameterTo(testPageURI);
+ try {
+ top.testManager.containerTestFrame.location.href = testPageURI;
+ } catch (e) {
+ }
+ }
+
+ function appendCacheBusterParameterTo(testPageURI) {
+ if (testPageURI.indexOf("?") == -1)
+ testPageURI += "?";
+ else
+ testPageURI += "&";
+ testPageURI += "cacheBuster=";
+ testPageURI += new Date().getTime();
+ return testPageURI;
+ }
+ </script>
+</head>
+
+<body onload="init()">
+Test Container Controller
+</body>
+</html>
\ No newline at end of file
Added: branches/tomek/portal-dnd/jsunit/app/xbDebug.js
===================================================================
--- branches/tomek/portal-dnd/jsunit/app/xbDebug.js 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/app/xbDebug.js 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,306 @@
+// xbDebug.js revision: 0.003 2002-02-26
+
+/* ***** BEGIN LICENSE BLOCK *****
+ * Licensed under Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ * Full Terms at /xbProjects-srce/license/mpl-tri-license.txt
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is Netscape code.
+ *
+ * The Initial Developer of the Original Code is
+ * Netscape Corporation.
+ * Portions created by the Initial Developer are Copyright (C) 2001
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s): Bob Clary <bclary at netscape.com>
+ *
+ * ***** END LICENSE BLOCK ***** */
+
+/*
+ChangeLog:
+
+2002-02-25: bclary - modified xbDebugTraceOject to make sure
+ that original versions of wrapped functions were not
+ rewrapped. This had caused an infinite loop in IE.
+
+2002-02-07: bclary - modified xbDebug.prototype.close to not null
+ the debug window reference. This can cause problems with
+ Internet Explorer if the page is refreshed. These issues will
+ be addressed at a later date.
+*/
+
+function xbDebug()
+{
+ this.on = false;
+ this.stack = new Array();
+ this.debugwindow = null;
+ this.execprofile = new Object();
+}
+
+xbDebug.prototype.push = function ()
+{
+ this.stack[this.stack.length] = this.on;
+ this.on = true;
+}
+
+xbDebug.prototype.pop = function ()
+{
+ this.on = this.stack[this.stack.length - 1];
+ --this.stack.length;
+}
+
+xbDebug.prototype.open = function ()
+{
+ if (this.debugwindow && !this.debugwindow.closed)
+ this.close();
+
+ this.debugwindow = window.open('about:blank', 'DEBUGWINDOW', 'height=400,width=600,resizable=yes,scrollbars=yes');
+
+ this.debugwindow.title = 'xbDebug Window';
+ this.debugwindow.document.write('<html><head><title>xbDebug Window</title></head><body><h3>Javascript Debug Window</h3></body></html>');
+ this.debugwindow.focus();
+}
+
+xbDebug.prototype.close = function ()
+{
+ if (!this.debugwindow)
+ return;
+
+ if (!this.debugwindow.closed)
+ this.debugwindow.close();
+
+ // bc 2002-02-07, other windows may still hold a reference to this: this.debugwindow = null;
+}
+
+xbDebug.prototype.dump = function (msg)
+{
+ if (!this.on)
+ return;
+
+ if (!this.debugwindow || this.debugwindow.closed)
+ this.open();
+
+ this.debugwindow.document.write(msg + '<br>');
+
+ return;
+}
+
+var xbDEBUG = new xbDebug();
+
+window.onunload = function () {
+ xbDEBUG.close();
+}
+
+function xbDebugGetFunctionName(funcref)
+{
+
+ if (!funcref)
+ {
+ return '';
+ }
+
+ if (funcref.name)
+ return funcref.name;
+
+ var name = funcref + '';
+ name = name.substring(name.indexOf(' ') + 1, name.indexOf('('));
+ funcref.name = name;
+
+ if (!name) alert('name not defined');
+ return name;
+}
+
+// emulate functionref.apply for IE mac and IE win < 5.5
+function xbDebugApplyFunction(funcname, funcref, thisref, argumentsref)
+{
+ var rv;
+
+ if (!funcref)
+ {
+ alert('xbDebugApplyFunction: funcref is null');
+ }
+
+ if (typeof(funcref.apply) != 'undefined')
+ return funcref.apply(thisref, argumentsref);
+
+ var applyexpr = 'thisref.xbDebug_orig_' + funcname + '(';
+ var i;
+
+ for (i = 0; i < argumentsref.length; i++)
+ {
+ applyexpr += 'argumentsref[' + i + '],';
+ }
+
+ if (argumentsref.length > 0)
+ {
+ applyexpr = applyexpr.substring(0, applyexpr.length - 1);
+ }
+
+ applyexpr += ')';
+
+ return eval(applyexpr);
+}
+
+function xbDebugCreateFunctionWrapper(scopename, funcname, precall, postcall)
+{
+ var wrappedfunc;
+ var scopeobject = eval(scopename);
+ var funcref = scopeobject[funcname];
+
+ scopeobject['xbDebug_orig_' + funcname] = funcref;
+
+ wrappedfunc = function ()
+ {
+ var rv;
+
+ precall(scopename, funcname, arguments);
+ rv = xbDebugApplyFunction(funcname, funcref, scopeobject, arguments);
+ postcall(scopename, funcname, arguments, rv);
+ return rv;
+ };
+
+ if (typeof(funcref.constructor) != 'undefined')
+ wrappedfunc.constructor = funcref.constuctor;
+
+ if (typeof(funcref.prototype) != 'undefined')
+ wrappedfunc.prototype = funcref.prototype;
+
+ scopeobject[funcname] = wrappedfunc;
+}
+
+function xbDebugCreateMethodWrapper(contextname, classname, methodname, precall, postcall)
+{
+ var context = eval(contextname);
+ var methodref = context[classname].prototype[methodname];
+
+ context[classname].prototype['xbDebug_orig_' + methodname] = methodref;
+
+ var wrappedmethod = function ()
+ {
+ var rv;
+ // eval 'this' at method run time to pick up reference to the object's instance
+ var thisref = eval('this');
+ // eval 'arguments' at method run time to pick up method's arguments
+ var argsref = arguments;
+
+ precall(contextname + '.' + classname, methodname, argsref);
+ rv = xbDebugApplyFunction(methodname, methodref, thisref, argsref);
+ postcall(contextname + '.' + classname, methodname, argsref, rv);
+ return rv;
+ };
+
+ return wrappedmethod;
+}
+
+function xbDebugPersistToString(obj)
+{
+ var s = '';
+ var p;
+
+ if (obj == null)
+ return 'null';
+
+ switch (typeof(obj))
+ {
+ case 'number':
+ return obj;
+ case 'string':
+ return '"' + obj + '"';
+ case 'undefined':
+ return 'undefined';
+ case 'boolean':
+ return obj + '';
+ }
+
+ if (obj.constructor)
+ return '[' + xbDebugGetFunctionName(obj.constructor) + ']';
+
+ return null;
+}
+
+function xbDebugTraceBefore(scopename, funcname, funcarguments)
+{
+ var i;
+ var s = '';
+ var execprofile = xbDEBUG.execprofile[scopename + '.' + funcname];
+ if (!execprofile)
+ execprofile = xbDEBUG.execprofile[scopename + '.' + funcname] = { started: 0, time: 0, count: 0 };
+
+ for (i = 0; i < funcarguments.length; i++)
+ {
+ s += xbDebugPersistToString(funcarguments[i]);
+ if (i < funcarguments.length - 1)
+ s += ', ';
+ }
+
+ xbDEBUG.dump('enter ' + scopename + '.' + funcname + '(' + s + ')');
+ execprofile.started = (new Date()).getTime();
+}
+
+function xbDebugTraceAfter(scopename, funcname, funcarguments, rv)
+{
+ var i;
+ var s = '';
+ var execprofile = xbDEBUG.execprofile[scopename + '.' + funcname];
+ if (!execprofile)
+ xbDEBUG.dump('xbDebugTraceAfter: execprofile not created for ' + scopename + '.' + funcname);
+ else if (execprofile.started == 0)
+ xbDEBUG.dump('xbDebugTraceAfter: execprofile.started == 0 for ' + scopename + '.' + funcname);
+ else
+ {
+ execprofile.time += (new Date()).getTime() - execprofile.started;
+ execprofile.count++;
+ execprofile.started = 0;
+ }
+
+ for (i = 0; i < funcarguments.length; i++)
+ {
+ s += xbDebugPersistToString(funcarguments[i]);
+ if (i < funcarguments.length - 1)
+ s += ', ';
+ }
+
+ xbDEBUG.dump('exit ' + scopename + '.' + funcname + '(' + s + ')==' + xbDebugPersistToString(rv));
+}
+
+function xbDebugTraceFunction(scopename, funcname)
+{
+ xbDebugCreateFunctionWrapper(scopename, funcname, xbDebugTraceBefore, xbDebugTraceAfter);
+}
+
+function xbDebugTraceObject(contextname, classname)
+{
+ var classref = eval(contextname + '.' + classname);
+ var p;
+ var sp;
+
+ if (!classref || !classref.prototype)
+ return;
+
+ for (p in classref.prototype)
+ {
+ sp = p + '';
+ if (typeof(classref.prototype[sp]) == 'function' && (sp).indexOf('xbDebug_orig') == -1)
+ {
+ classref.prototype[sp] = xbDebugCreateMethodWrapper(contextname, classname, sp, xbDebugTraceBefore, xbDebugTraceAfter);
+ }
+ }
+}
+
+function xbDebugDumpProfile()
+{
+ var p;
+ var execprofile;
+ var avg;
+
+ for (p in xbDEBUG.execprofile)
+ {
+ execprofile = xbDEBUG.execprofile[p];
+ avg = Math.round(100 * execprofile.time / execprofile.count) / 100;
+ xbDEBUG.dump('Execution profile ' + p + ' called ' + execprofile.count + ' times. Total time=' + execprofile.time + 'ms. Avg Time=' + avg + 'ms.');
+ }
+}
Added: branches/tomek/portal-dnd/jsunit/bin/mac/readme.txt
===================================================================
--- branches/tomek/portal-dnd/jsunit/bin/mac/readme.txt 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/bin/mac/readme.txt 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,3 @@
+This directory contains shell scripts (*.sh) and AppleScripts (*.scpt) to start and stop browsers.
+
+The shell scripts invoke the AppleScripts, so use the shell scripts.
\ No newline at end of file
Added: branches/tomek/portal-dnd/jsunit/bin/mac/start-firefox.scpt
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/jsunit/bin/mac/start-firefox.scpt
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/jsunit/bin/mac/start-firefox.sh
===================================================================
--- branches/tomek/portal-dnd/jsunit/bin/mac/start-firefox.sh 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/bin/mac/start-firefox.sh 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+# Starts Firefox. Use this instead of calling the AppleScripts directly.
+
+osascript bin/mac/stop-firefox.scpt
+osascript bin/mac/start-firefox.scpt $1
+
Added: branches/tomek/portal-dnd/jsunit/bin/mac/start-safari.scpt
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/jsunit/bin/mac/start-safari.scpt
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/jsunit/bin/mac/start-safari.sh
===================================================================
--- branches/tomek/portal-dnd/jsunit/bin/mac/start-safari.sh 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/bin/mac/start-safari.sh 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,7 @@
+#!/bin/sh
+
+# Starts Safari. Use this instead of calling the AppleScripts directly.
+
+osascript bin/mac/stop-safari.scpt
+osascript bin/mac/start-safari.scpt $1
+
Added: branches/tomek/portal-dnd/jsunit/bin/mac/stop-firefox.scpt
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/jsunit/bin/mac/stop-firefox.scpt
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/jsunit/bin/mac/stop-firefox.sh
===================================================================
--- branches/tomek/portal-dnd/jsunit/bin/mac/stop-firefox.sh 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/bin/mac/stop-firefox.sh 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# Stops Firefox. Use this instead of calling the AppleScripts directly.
+
+osascript bin/mac/stop-firefox.scpt
+
Added: branches/tomek/portal-dnd/jsunit/bin/mac/stop-safari.scpt
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/jsunit/bin/mac/stop-safari.scpt
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/jsunit/bin/mac/stop-safari.sh
===================================================================
--- branches/tomek/portal-dnd/jsunit/bin/mac/stop-safari.sh 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/bin/mac/stop-safari.sh 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,6 @@
+#!/bin/sh
+
+# Stops Safari. Use this instead of calling the AppleScripts directly.
+
+osascript bin/mac/stop-safari.scpt
+
Added: branches/tomek/portal-dnd/jsunit/bin/unix/start-firefox.sh
===================================================================
--- branches/tomek/portal-dnd/jsunit/bin/unix/start-firefox.sh 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/bin/unix/start-firefox.sh 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,3 @@
+#!/bin/sh
+killall -9 -w firefox-bin
+firefox $1 &
Added: branches/tomek/portal-dnd/jsunit/bin/unix/stop-firefox.sh
===================================================================
--- branches/tomek/portal-dnd/jsunit/bin/unix/stop-firefox.sh 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/bin/unix/stop-firefox.sh 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,2 @@
+#!/bin/sh
+killall -9 -w firefox-bin
Added: branches/tomek/portal-dnd/jsunit/build.xml
===================================================================
--- branches/tomek/portal-dnd/jsunit/build.xml 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/build.xml 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,271 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<project name="JsUnit" default="create_distribution" basedir=".">
+
+ <!--
+ The following are the properties used to configure the JsUnit server. You need to provide values for the mandatory properties.
+ See the documentation at http://www.jsunit.net for more information.
+ -->
+
+ <property
+ name="browserFileNames"
+ value=""
+ description="browserFileNames is the list of browsers in which to run tests when StandaloneTest is invoked on this machine. For a JsUnit Server, this is a mandatory property. For example: 'c:\program files\internet explorer\iexplore.exe,c:\program files\netscape\netscape7.1\netscp.exe'"
+ />
+
+ <property
+ id="closeBrowsersAfterTestRuns"
+ name="closeBrowsersAfterTestRuns"
+ value=""
+ description="closeBrowsersAfterTestRuns determines whether to attempt to close browsers after test runs. This is not a mandatory property. The default is true. For example: 'true'"
+ />
+
+ <property
+ id="description"
+ name="description"
+ value=""
+ description="description is a human-readable description of a standard or farm server. This is not a mandatory property. The default is blank. For example: 'This is our Mac - it's only running Safari right now'"
+ />
+
+ <property
+ id="ignoreUnresponsiveRemoteMachines"
+ name="ignoreUnresponsiveRemoteMachines"
+ value=""
+ description="ignoreUnresponsiveRemoteMachines is a property used only by the JsUnit Farm Server and the distributed_test target. Its value is whether to ignore a remove machine that does not respond. If true, test runs will be green even if one or more remove machines fail to respond; if false, an unresponsive remove machine results in a failure. This is not a mandatory property. Its default is false. For example: 'true'"
+ />
+
+ <property
+ id="logsDirectory"
+ name="logsDirectory"
+ value=""
+ description="logsDirectory is the directory in which the JsUnitStandardServer stores the XML logs produced from tests run. It can be specified relative to the working directory. This is not a mandatory property. If not specified, the directory called 'logs' inside resourceBase is assumed. For example: 'c:\jsunit\java\logs'"
+ />
+
+ <property
+ id="port"
+ name="port"
+ value=""
+ description="port is the port on which the JsUnitStandardServer runs. This is not a mandatory property. If not specified, 8080 is assumed. For exapmle: '8080'"
+ />
+
+ <property
+ id="remoteMachineURLs"
+ name="remoteMachineURLs"
+ value=""
+ description="remoteMachineURLs is a property used only by the JsUnit Farm Server and the distributed_test target. Its value is the list of URLs of remove machines to which a request to run tests will be sent. For example: 'http://machine1.company.com:8080,http://localhost:8080,http://192.168.1.200:9090'"
+ />
+
+ <property
+ id="resourceBase"
+ name="resourceBase"
+ value=""
+ description="resourceBase is the directory that the JsUnitStandardServer considers to be its document root. It can be specified relative to the working directory. This is not a mandatory property. If not specified, the working directory is assumed. For example: 'c:\jsunit'"
+ />
+
+ <property
+ id="timeoutSeconds"
+ name="timeoutSeconds"
+ value=""
+ description="timeoutSeconds is the number of seconds to wait before timing out a browser during a test run. This is not a mandatory property. If not specified, 60 is assumed. For example: '60'"
+ />
+
+ <property
+ id="url"
+ name="url"
+ value=""
+ description="url is the URL (HTTP or file protocol) to open in the browser. For a JsUnit Server, this is a mandatory property for a test run if the server is not passed the 'url' parameter. For example: 'file:///c:/jsunit/testRunner.html?testPage=c:/jsunit/tests/jsUnitTestSuite.html'"
+ />
+
+ <!--
+ The remainder of this build file is not intended to be modified by the end user.
+ Those targets whose name begins with an underscore are not intended to be run directly by the end user.
+ -->
+
+ <property name="source_core" location="java/source_core"/>
+ <property name="source_server" location="java/source_server"/>
+ <property name="tests_core" location="java/tests_core"/>
+ <property name="tests_server" location="java/tests_server"/>
+ <property name="bin" location="java/bin"/>
+ <property name="lib" location="java/lib"/>
+ <property name="testlib" location="java/testlib"/>
+ <property name="config" location="java/config"/>
+ <property name="loggingPropertiesFile" location="logging.properties"/>
+
+ <path id="classpath">
+ <fileset dir="${lib}">
+ <include name="*.jar"/>
+ </fileset>
+ <fileset dir="${bin}">
+ <include name="jsunit.jar"/>
+ </fileset>
+ <dirset dir="${config}"/>
+ </path>
+
+ <path id="self_tests_classpath">
+ <fileset dir="${lib}">
+ <include name="*.jar"/>
+ </fileset>
+ <fileset dir="${testlib}">
+ <include name="*.jar"/>
+ </fileset>
+ <fileset dir="${bin}">
+ <include name="jsunit.jar"/>
+ </fileset>
+ <dirset dir="${config}"/>
+ </path>
+
+ <target name="_compile_source" description="Compiles the source">
+ <delete dir="${bin}/net"/>
+ <javac srcdir="${source_core}" destdir="${bin}" debug="true">
+ <classpath>
+ <fileset dir="${lib}">
+ <include name="*.jar"/>
+ </fileset>
+ </classpath>
+ </javac>
+ <javac srcdir="${source_server}" destdir="${bin}" debug="true">
+ <classpath>
+ <fileset dir="${lib}">
+ <include name="*.jar"/>
+ </fileset>
+ <path location="${bin}"/>
+ </classpath>
+ </javac>
+ </target>
+
+ <target name="_compile_tests" description="Compiles the self-tests">
+ <javac srcdir="${tests_core}" destdir="${bin}" debug="true">
+ <classpath refid="self_tests_classpath"/>
+ </javac>
+ <javac srcdir="${tests_server}" destdir="${bin}" debug="true">
+ <classpath refid="self_tests_classpath"/>
+ </javac>
+ </target>
+
+ <target name="_create_jar" depends="_compile_source" description="Creates jsunit.jar">
+ <delete file="${bin}/jsunit.jar"/>
+ <jar jarfile="${bin}/jsunit.jar" basedir="${bin}"/>
+ <delete dir="${bin}/net"/>
+ </target>
+
+ <target name="_generateJsUnitPropertiesSample" description="Generates the jsunit.properties.sample file">
+ <xslt in="build.xml" out="jsunit.properties.sample" destdir="."
+ style="xsl/buildDotXmlToJsUnitDotProperties.xsl"></xslt>
+ </target>
+
+ <target name="_run_unit_tests" depends="_compile_tests" description="Runs the JsUnit Java unit tests">
+ <junit fork="yes" haltonfailure="false" forkmode="once" showoutput="yes" printsummary="withOutAndErr"
+ failureproperty="junit_test_failed">
+ <formatter type="plain" usefile="false"/>
+ <classpath refid="self_tests_classpath"/>
+ <classpath path="${bin}"/>
+ <test name="net.jsunit.UnitTestSuite"/>
+ </junit>
+ <fail if="junit_test_failed"/>
+ </target>
+
+ <target name="_run_all_tests" depends="_create_jar,_compile_tests"
+ description="Runs all the JsUnit Java tests. Used in the continuous build">
+ <junit fork="yes" haltonfailure="false" forkmode="once" showoutput="yes" printsummary="withOutAndErr"
+ failureproperty="junit_test_failed">
+ <formatter type="xml"/>
+ <classpath refid="self_tests_classpath"/>
+ <classpath path="${bin}"/>
+ <sysproperty key="java.security.manager" value="com.thoughtworks.ashcroft.runtime.JohnAshcroft"/>
+ <test name="net.jsunit.PureUnitTestSuite"/>
+ </junit>
+ <junit fork="yes" haltonfailure="false" forkmode="once" showoutput="yes" printsummary="withOutAndErr"
+ failureproperty="junit_test_failed">
+ <formatter type="xml"/>
+ <classpath refid="self_tests_classpath"/>
+ <classpath path="${bin}"/>
+ <test name="net.jsunit.ImpureUnitTestSuite"/>
+ </junit>
+ <junit fork="yes" haltonfailure="false" forkmode="once" showoutput="yes" printsummary="withOutAndErr"
+ failureproperty="junit_test_failed">
+ <formatter type="xml"/>
+ <classpath refid="self_tests_classpath"/>
+ <classpath path="${bin}"/>
+ <test name="net.jsunit.FunctionalTestSuite"/>
+ </junit>
+ <junit fork="yes" haltonfailure="false" forkmode="once" showoutput="yes" printsummary="withOutAndErr"
+ failureproperty="junit_test_failed">
+ <formatter type="xml"/>
+ <classpath refid="self_tests_classpath"/>
+ <classpath path="${bin}"/>
+ <test name="net.jsunit.FarmServerFunctionalTestSuite"/>
+ </junit>
+ <fail if="junit_test_failed"/>
+ </target>
+
+ <target name="create_distribution" depends="_create_jar,_run_unit_tests"
+ description="Creates and tests the JsUnit distribution"/>
+
+ <target name="start_server" description="Starts a JsUnit Server">
+ <java fork="true" classname="net.jsunit.JsUnitStandardServer">
+ <classpath refid="classpath"/>
+ <sysproperty key="java.util.logging.config.file" value="${loggingPropertiesFile}"/>
+ <sysproperty key="description" value="${description}"/>
+ <sysproperty key="browserFileNames" value="${browserFileNames}"/>
+ <sysproperty key="url" value="${url}"/>
+ <sysproperty key="port" value="${port}"/>
+ <sysproperty key="resourceBase" value="${resourceBase}"/>
+ <sysproperty key="logsDirectory" value="${logsDirectory}"/>
+ <sysproperty key="timeoutSeconds" value="${timeoutSeconds}"/>
+ <sysproperty key="closeBrowsersAfterTestRuns" value="${closeBrowsersAfterTestRuns}"/>
+ </java>
+ </target>
+
+ <target name="start_farm_server" description="Starts a JsUnit Farm Server">
+ <java fork="true" classname="net.jsunit.JsUnitFarmServer">
+ <classpath refid="classpath"/>
+ <sysproperty key="java.util.logging.config.file" value="${loggingPropertiesFile}"/>
+ <sysproperty key="description" value="${description}"/>
+ <sysproperty key="ignoreUnresponsiveRemoteMachines" value="${ignoreUnresponsiveRemoteMachines}"/>
+ <sysproperty key="logsDirectory" value="${logsDirectory}"/>
+ <sysproperty key="port" value="${port}"/>
+ <sysproperty key="remoteMachineURLs" value="${remoteMachineURLs}"/>
+ <sysproperty key="resourceBase" value="${resourceBase}"/>
+ <sysproperty key="url" value="${url}"/>
+ </java>
+ </target>
+
+ <target name="stop_server" description="Stops the JsUnit Server">
+ <java fork="true" classname="org.mortbay.stop.Main" failonerror="true">
+ <classpath refid="classpath"/>
+ </java>
+ </target>
+
+ <target name="standalone_test" description="Runs tests on the local machine">
+ <junit showoutput="true" haltonerror="true" haltonfailure="true">
+ <formatter type="plain" usefile="false"/>
+ <classpath refid="classpath"/>
+ <sysproperty key="browserFileNames" value="${browserFileNames}"/>
+ <sysproperty key="description" value="${description}"/>
+ <sysproperty key="closeBrowsersAfterTestRuns" value="${closeBrowsersAfterTestRuns}"/>
+ <sysproperty key="logsDirectory" value="${logsDirectory}"/>
+ <sysproperty key="port" value="${port}"/>
+ <sysproperty key="resourceBase" value="${resourceBase}"/>
+ <sysproperty key="timeoutSeconds" value="${timeoutSeconds}"/>
+ <sysproperty key="url" value="${url}"/>
+ <test name="net.jsunit.StandaloneTest"/>
+ </junit>
+ </target>
+
+ <target name="distributed_test" description="Runs tests the remote machines">
+ <junit showoutput="true" haltonerror="true" haltonfailure="true">
+ <formatter type="plain" usefile="false"/>
+ <classpath refid="classpath"/>
+ <sysproperty key="browserFileNames" value="${browserFileNames}"/>
+ <sysproperty key="description" value="${description}"/>
+ <sysproperty key="ignoreUnresponsiveRemoteMachines" value="${ignoreUnresponsiveRemoteMachines}"/>
+ <sysproperty key="logsDirectory" value="${logsDirectory}"/>
+ <sysproperty key="port" value="${port}"/>
+ <sysproperty key="remoteMachineURLs" value="${remoteMachineURLs}"/>
+ <sysproperty key="resourceBase" value="${resourceBase}"/>
+ <sysproperty key="url" value="${url}"/>
+ <test name="net.jsunit.DistributedTest"/>
+ </junit>
+ </target>
+
+</project>
Added: branches/tomek/portal-dnd/jsunit/changelog.txt
===================================================================
--- branches/tomek/portal-dnd/jsunit/changelog.txt 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/changelog.txt 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,60 @@
+TRACING
+- Tracing is now color coded by trace level
+- Traces are now prefixed with the Test Page and Test Function from which the trace is made
+
+ASSERTION FUNCTIONS
+- assertArrayEquals(array1, array2) introduced
+- assertObjectEquals(object1, object2) introduced
+- assertHTMLEquals function introduced
+- assertEvaluatesToTrue and assertEvaluatesToFalse introduced
+- assertHashEquals }
+- assertRoughlyEquals } Pivotal functions
+- assertContains }
+
+- changed expected/actual values display strings to use angle brackets, rather than square brackets
+
+- CLIENT-SIDE
+- HTML in result output is now correctly escaped
+- page load timeout changed to 120 seconds by default
+- setup page timeout change to 120 seconds by default
+- cache-buster for testpage retrieval & results submission
+- jsUnitRestoredHTMLDiv
+- turn off tracing, alerts, confirms when submitting
+- testPage parameter should be URL-encoded (only opera cares though)
+- Speed-up of Firefox/Mozilla (thanks to Chris Wesseling)
+- jsUnitMockTimeout.js (thanks to Pivotal, especially Nathan Wilmes)
+
+SERVER
+- start-browser scripts in bin
+- Migration of Java code to require Java 5.0
+- JSPs require a JDK
+- StandaloneTest and DistributedTest continue on after a failure in a particular browser or remote server respectively
+- StandaloneTest has a suite() method that makes the test run have multiple JUnit tests, one per browser
+- DistribuedTest has a suite() method that makes the test run have multiple JUnit tests, one per remote machine URL
+- Change to XML output format of test runs to include more information and be more hierarchical (machine->browser->test page->test case)
+- Logs are now prefixed with "JSTEST-" in order to match JUnit's "TEST-"
+- Logs now contain the browser ID (e.g. JSTEST-12345.5.xml means browser with ID 5); displayer servlet now takes an id and a browserId parameter
+- added support for launching the default system browser on Windows and UNIX (see the constant on net.jsunit.StandaloneTest)
+- StandaloneTest now runs tests in all specified browsers, even after an earlier browser failed
+- New "config" servlet that shows the configuration as XML of the server
+- Distributed Tests now send back an XML document that includes the XML for browser results as opposed to just a "success"/"failure" node
+- runner servlet takes a "url" querystring parameter that overrides the server's url property
+- test run requests to the JsUnitServer and the FarmServer are queued up and in serial so that different clients don't step on eachother
+- addition of new configuration parameter, "closeBrowsersAfterTestRuns", for whether to attempt to close browsers after test runs
+- addition of new configuration property, "timeoutSeconds", for how long to time browsers out
+- addition of new configuration property, "ignoreUnresponsiveRemoteMachines", for whether to care that remote machines don't uccessfully run the tests
+- addition of new configuration property, "description", which contains a human-readable description of the server
+- new index.jsp ("/") page
+- jsunit.org registered; redirects to edwardh.com/jsunit
+
+BUGS
+- fix for "retry test run" bug
+- bug 1070436 fixed
+- bug with multiple browsers and resultId specified fixed
+- Bug 1281427 fixed (test submission for Opera)
+- Safari fix
+- Bug 1431040 fixed
+
+ECLIPSE PLUGIN
+- Eclipse plugin version 1.0
+
Added: branches/tomek/portal-dnd/jsunit/css/jsUnitStyle.css
===================================================================
--- branches/tomek/portal-dnd/jsunit/css/jsUnitStyle.css 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/css/jsUnitStyle.css 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,83 @@
+body {
+ margin-top: 0;
+ margin-bottom: 0;
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ color: #000;
+ font-size: 0.8em;
+ background-color: #fff;
+}
+
+a:link, a:visited {
+ color: #00F;
+}
+
+a:hover {
+ color: #F00;
+}
+
+h1 {
+ font-size: 1.2em;
+ font-weight: bold;
+ color: #039;
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+}
+
+h2 {
+ font-weight: bold;
+ color: #039;
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+}
+
+h3 {
+ font-weight: bold;
+ color: #039;
+ text-decoration: underline;
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+}
+
+h4 {
+ font-weight: bold;
+ color: #039;
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+}
+
+.jsUnitTestResultSuccess {
+ color: #000;
+}
+
+.jsUnitTestResultNotSuccess {
+ color: #F00;
+}
+
+.unselectedTab {
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ height: 26px;
+ background: #FFFFFF;
+ border-style: solid;
+ border-bottom-width: 1px;
+ border-top-width: 1px;
+ border-left-width: 1px;
+ border-right-width: 1px;
+}
+
+.selectedTab {
+ font-family: Verdana, Arial, Helvetica, sans-serif;
+ height: 26px;
+ background: #DDDDDD;
+ font-weight: bold;
+ border-style: solid;
+ border-bottom-width: 0px;
+ border-top-width: 1px;
+ border-left-width: 1px;
+ border-right-width: 1px;
+}
+
+.tabHeaderSeparator {
+ height: 26px;
+ background: #FFFFFF;
+ border-style: solid;
+ border-bottom-width: 1px;
+ border-top-width: 0px;
+ border-left-width: 0px;
+ border-right-width: 0px;
+}
\ No newline at end of file
Added: branches/tomek/portal-dnd/jsunit/images/green.gif
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/jsunit/images/green.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/jsunit/images/logo_jsunit.gif
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/jsunit/images/logo_jsunit.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/jsunit/images/powerby-transparent.gif
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/jsunit/images/powerby-transparent.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/jsunit/images/red.gif
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/jsunit/images/red.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/jsunit/index.jsp
===================================================================
--- branches/tomek/portal-dnd/jsunit/index.jsp 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/index.jsp 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,252 @@
+<%@ page import="net.jsunit.JsUnitServer" %>
+<%@ page import="net.jsunit.ServerRegistry" %>
+<%@ page import="net.jsunit.configuration.Configuration" %>
+<%@ page import="net.jsunit.configuration.ConfigurationProperty" %>
+<%@ page import="net.jsunit.model.Browser" %>
+<%@ page import="net.jsunit.utility.SystemUtility" %>
+<%@ page import="java.text.SimpleDateFormat" %>
+<%JsUnitServer server = ServerRegistry.getServer();%>
+<%Configuration configuration = server.getConfiguration();%>
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>JsUnit <%if (server.isFarmServer()) {%> Farm<%}%> Server</title>
+ <script type="text/javascript" src="app/jsUnitCore.js"></script>
+ <script type="text/javascript" src="app/jsUnitVersionCheck.js"></script>
+ <script type="text/javascript">
+ function selectDiv(selectedDivName) {
+ updateDiv("testRunnerDiv", selectedDivName);
+ updateDiv("configDiv", selectedDivName);
+ updateDiv("runnerDiv", selectedDivName);
+ updateDiv("displayerDiv", selectedDivName);
+ }
+
+ function updateDiv(divName, selectedDivName) {
+ var isSelected = divName == selectedDivName;
+ var theDiv = document.getElementById(divName);
+ theDiv.style.visibility = isSelected ? "visible" : "hidden";
+ theDiv.style.height = isSelected ? "" : "0";
+
+ var theDivHeader = document.getElementById(divName + "Header");
+ theDivHeader.className = isSelected ? "selectedTab" : "unselectedTab";
+ }
+ </script>
+ <link rel="stylesheet" type="text/css" href="./css/jsUnitStyle.css">
+</head>
+
+<body onload="selectDiv('runnerDiv')">
+<table height="90" width="100%" cellpadding="0" cellspacing="0" border="0" summary="jsUnit Information"
+ bgcolor="#DDDDDD">
+ <tr>
+ <td width="1">
+ <a href="http://www.jsunit.net" target="_blank"><img src="images/logo_jsunit.gif" alt="JsUnit" border="0"/></a>
+ </td>
+ <td width="50"> </td>
+ <th nowrap align="left">
+ <h4>JsUnit <%=SystemUtility.jsUnitVersion()%><%if (server.isFarmServer()) {%> Farm<%}%> Server</h4>
+ <font size="-2"><i>Running on <%=SystemUtility.displayString()%>
+ since <%=new SimpleDateFormat().format(server.getStartDate())%></i></font>
+ <%if (!server.isFarmServer()) {%>
+ <br>
+ <font size="-2"><i><%=server.getTestRunCount()%> test run(s) completed</i></font>
+ <br>
+ <%}%>
+ </th>
+ <td nowrap align="right" valign="middle">
+ <font size="-2">
+ <b><a href="http://www.jsunit.net/" target="_blank">www.jsunit.net</a></b><br>
+
+ <div id="versionCheckDiv"><a href="javascript:checkForLatestVersion('latestversion')">Check for newer
+ version</a></div>
+ </font>
+ <a href="http://www.pivotalsf.com/" target="top">
+ <img border="0" src="images/powerby-transparent.gif" alt="Powered By Pivotal">
+ </a>
+ </td>
+
+ </tr>
+</table>
+<h4>
+ Server configuration
+</h4>
+<table border="0">
+ <tr>
+ <th nowrap align="right">Server type:</th>
+ <td width="10"> </td>
+ <td><%=server.serverType().getDisplayName()%></td>
+ </tr>
+ <%
+ for (ConfigurationProperty property : configuration.getRequiredAndOptionalConfigurationProperties(server.serverType())) {
+ %>
+ <tr>
+ <th nowrap align="right"><%=property.getDisplayName()%>:</th>
+ <td width="10"> </td>
+ <td>
+ <%
+ for (String valueString : property.getValueStrings(configuration)) {
+ %><div><%
+ if (valueString != null) {
+ if (property.isURL()) {
+ %><a href="<%=valueString%>"><%=valueString%></a><%
+ } else {
+ %><%=valueString%><%
+ }
+ }
+ %></div><%
+ }
+ %>
+ </td></tr>
+ <%
+ }
+ %>
+</table>
+<br>
+<h4>
+ Available services
+</h4>
+
+<table cellpadding="0" cellspacing="0">
+<tr>
+ <td class="tabHeaderSeparator"> </td>
+ <td id="runnerDivHeader" class="selectedTab">
+ <a href="javascript:selectDiv('runnerDiv')">runner</a>
+ </td>
+ <td class="tabHeaderSeparator"> </td>
+ <%if (!server.isFarmServer()) {%>
+ <td id="displayerDivHeader" class="unselectedTab">
+ <a href="javascript:selectDiv('displayerDiv')">displayer</a>
+ </td>
+ <td class="tabHeaderSeparator"> </td>
+ <%}%>
+ <td id="testRunnerDivHeader" class="unselectedTab">
+ <a href="javascript:selectDiv('testRunnerDiv')">testRunner.html</a>
+ </td>
+ <td class="tabHeaderSeparator"> </td>
+ <td id="configDivHeader" class="unselectedTab">
+ <a href="javascript:selectDiv('configDiv')">config</a>
+ </td>
+ <td class="tabHeaderSeparator" width="99%"> </td>
+</tr>
+<tr>
+<td colspan="9"
+ style="border-style: solid;border-bottom-width:1px;border-top-width:0px;border-left-width:1px;border-right-width:1px;">
+<div id="runnerDiv" style="width:100%;visibility:visible;background:#DDDDDD">
+ <br>
+
+ <form action="/jsunit/runner" method="get" name="runnerForm">
+ <table>
+ <tr>
+ <td colspan="2">
+ You can ask the server to run JsUnit tests using the <i>runner</i> servlet.
+ You can run using the server's default URL for tests by going to <a href="/jsunit/runner">runner</a>,
+ or you can specify a custom URL and/or browser ID using this form:
+ </td>
+ </tr>
+ <tr>
+ <td width="1">
+ URL:
+ </td>
+ <td>
+ <input type="text" name="url" size="100" value=""/>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2">
+ <font size="-2"><i>e.g.
+ http://www.jsunit.net/runner/testRunner.html?testPage=http://www.jsunit.net/runner/tests/jsUnitTestSuite.html</i>
+ </font>
+ </td>
+ </tr>
+ <tr>
+ <td width="1">
+ Browser:
+ </td>
+ <td>
+ <%if (!server.isFarmServer()) {%>
+
+ <select name="browserId">
+ <option value="">(All browsers)</option>
+ <%
+ for (Browser browser : configuration.getBrowsers()) {
+ %><option value="<%=browser.getId()%>"><%=browser.getFileName()%></option>
+ <%}%>
+ </select><br>
+ <%}%>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2">
+ <input type="submit" value="go"/>
+ </td>
+ </tr>
+ </table>
+ </form>
+ <br>
+</div>
+
+<%if (!server.isFarmServer()) {%>
+
+<div id="displayerDiv" style="width:100%;visibility:hidden;background:#DDDDDD">
+ <br>
+
+ <form action="/jsunit/displayer" name="displayerForm">
+ <table>
+ <tr>
+ <td colspan="2">
+ You can view the logs of past runs using the displayer command.
+ Use this form to specify the ID of the run you want to see:
+ </td>
+ </tr>
+ <tr>
+ <td width="1">
+ ID:
+ </td>
+ <td>
+ <input type="text" name="id" size="20"/>
+ </td>
+ </tr>
+ <tr>
+ <td width="1">
+ Browser:
+ </td>
+ <td>
+ <select name="browserId">
+ <%
+ for (Browser browser : configuration.getBrowsers()) {
+ %><option value="<%=browser.getId()%>"><%=browser.getFileName()%></option>
+ <%}%>
+ </select><br>
+ </td>
+ </tr>
+ <tr>
+ <td colspan="2">
+ <input type="submit" value="go"/>
+ </td>
+ </tr>
+ </table>
+ </form>
+ <br>
+</div>
+<%}%>
+
+<div id="testRunnerDiv" style="width:100%;visibility:hidden;background:#DDDDDD">
+ <br>
+ The manual Test Runner is at <a id="testRunnerHtml" href="./testRunner.html">testRunner.html</a>.
+ <br>
+</div>
+
+
+<div id="configDiv" style="width:100%;visibility:hidden;background:#DDDDDD">
+ <br>
+ You can see the configuration of this server as XML by going to <a id="config"
+ href="/jsunit/config">config</a>.
+ The config service is usually only used programmatically.
+ <br>
+</div>
+</td>
+</tr>
+</table>
+
+</body>
+</html>
\ No newline at end of file
Added: branches/tomek/portal-dnd/jsunit/java/bin/jsunit.jar
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/jsunit/java/bin/jsunit.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/jsunit/java/config/farm_xwork.xml
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/config/farm_xwork.xml 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/config/farm_xwork.xml 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,41 @@
+<!DOCTYPE xwork PUBLIC "-//OpenSymphony Group//XWork 1.0//EN"
+ "http://www.opensymphony.com/xwork/xwork-1.0.dtd">
+
+<xwork>
+
+ <include file="webwork-default.xml"/>
+
+ <package name="default" extends="webwork-default">
+
+ <result-types>
+ <result-type name="jsUnitXml" class="net.jsunit.action.XmlResult"/>
+ </result-types>
+
+ <interceptors>
+ <interceptor name="farmServer" class="net.jsunit.interceptor.FarmServerInterceptor"/>
+ <interceptor name="remoteRunnerHitter" class="net.jsunit.interceptor.RemoteRunnerHitterInterceptor"/>
+
+ <interceptor-stack name="defaultStack">
+ <interceptor-ref name="servlet-config"/>
+ <interceptor-ref name="prepare"/>
+ <interceptor-ref name="static-params"/>
+ <interceptor-ref name="params"/>
+ <interceptor-ref name="conversionError"/>
+ <interceptor-ref name="farmServer"/>
+ <interceptor-ref name="remoteRunnerHitter"/>
+ </interceptor-stack>
+ </interceptors>
+
+ <default-interceptor-ref name="defaultStack"/>
+
+ <action name="runner" class="net.jsunit.action.DistributedTestRunnerAction">
+ <result name="success" type="jsUnitXml"/>
+ </action>
+
+ <action name="config" class="net.jsunit.action.FarmServerConfigurationAction">
+ <result name="success" type="jsUnitXml"/>
+ </action>
+
+ </package>
+
+</xwork>
Added: branches/tomek/portal-dnd/jsunit/java/config/xwork.xml
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/config/xwork.xml 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/config/xwork.xml 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,62 @@
+<!DOCTYPE xwork PUBLIC "-//OpenSymphony Group//XWork 1.0//EN" "http://www.opensymphony.com/xwork/xwork-1.0.dtd">
+
+<xwork>
+
+ <include file="webwork-default.xml"/>
+
+ <package name="default" extends="webwork-default">
+
+ <result-types>
+ <result-type name="jsUnitXml" class="net.jsunit.action.XmlResult"/>
+ <result-type name="jsUnitLatestVersion" class="net.jsunit.action.LatestVersionResult"/>
+ </result-types>
+
+ <interceptors>
+ <interceptor name="browserTestRunner" class="net.jsunit.interceptor.BrowserTestRunnerInterceptor"/>
+ <interceptor name="browserResult" class="net.jsunit.interceptor.BrowserResultInterceptor"/>
+ <interceptor name="requestSource" class="net.jsunit.interceptor.RequestSourceInterceptor"/>
+ <interceptor name="versionGrabber" class="net.jsunit.interceptor.VersionGrabberInterceptor"/>
+
+ <interceptor-stack name="defaultStack">
+ <interceptor-ref name="servlet-config"/>
+ <interceptor-ref name="prepare"/>
+ <interceptor-ref name="params"/>
+ <interceptor-ref name="browserTestRunner"/>
+ </interceptor-stack>
+ </interceptors>
+
+ <default-interceptor-ref name="defaultStack"/>
+
+ <action name="acceptor" class="net.jsunit.action.ResultAcceptorAction">
+ <result name="success" type="jsUnitXml"/>
+ <interceptor-ref name="defaultStack"/>
+ <interceptor-ref name="browserResult"/>
+ </action>
+
+ <action name="runner" class="net.jsunit.action.TestRunnerAction">
+ <result name="success" type="jsUnitXml"/>
+ <result name="error" type="jsUnitXml"/>
+ <interceptor-ref name="defaultStack"/>
+ <interceptor-ref name="requestSource"/>
+ </action>
+
+ <action name="displayer" class="net.jsunit.action.ResultDisplayerAction">
+ <result name="success" type="jsUnitXml"/>
+ <result name="error" type="jsUnitXml"/>
+ </action>
+
+ <action name="config" class="net.jsunit.action.BrowserTestRunnerConfigurationAction">
+ <result name="success" type="jsUnitXml"/>
+ </action>
+
+ <action name="latestversion" class="net.jsunit.action.LatestVersionAction">
+ <result name="success" type="jsUnitLatestVersion"/>
+ <result name="error" type="httpheader">
+ <param name="status">500</param>
+ </result>
+ <interceptor-ref name="versionGrabber"/>
+ </action>
+
+ </package>
+
+</xwork>
Added: branches/tomek/portal-dnd/jsunit/java/lib/ant.jar
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/jsunit/java/lib/ant.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/jsunit/java/lib/commons-el.jar
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/jsunit/java/lib/commons-el.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/jsunit/java/lib/commons-logging.jar
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/jsunit/java/lib/commons-logging.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/jsunit/java/lib/jasper-compiler.jar
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/jsunit/java/lib/jasper-compiler.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/jsunit/java/lib/jasper-runtime.jar
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/jsunit/java/lib/jasper-runtime.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/jsunit/java/lib/javax.servlet.jar
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/jsunit/java/lib/javax.servlet.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/jsunit/java/lib/jdom.jar
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/jsunit/java/lib/jdom.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/jsunit/java/lib/junit.jar
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/jsunit/java/lib/junit.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/jsunit/java/lib/ognl.jar
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/jsunit/java/lib/ognl.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/jsunit/java/lib/org.mortbay.jetty.jar
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/jsunit/java/lib/org.mortbay.jetty.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/jsunit/java/lib/oscore.jar
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/jsunit/java/lib/oscore.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/jsunit/java/lib/rife-continuations.jar
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/jsunit/java/lib/rife-continuations.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/jsunit/java/lib/start.jar
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/jsunit/java/lib/start.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/jsunit/java/lib/stop.jar
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/jsunit/java/lib/stop.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/jsunit/java/lib/webwork-2.2-beta-4.jar
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/jsunit/java/lib/webwork-2.2-beta-4.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/jsunit/java/lib/xercesImpl-2.6.2.jar
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/jsunit/java/lib/xercesImpl-2.6.2.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/jsunit/java/lib/xwork-1.1.jar
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/jsunit/java/lib/xwork-1.1.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/BrowserLaunchSpecification.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/BrowserLaunchSpecification.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/BrowserLaunchSpecification.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,35 @@
+package net.jsunit;
+
+import net.jsunit.model.Browser;
+import net.jsunit.utility.StringUtility;
+
+public class BrowserLaunchSpecification {
+
+ private final Browser browser;
+ private final String overrideUrl;
+
+ public BrowserLaunchSpecification(Browser browser) {
+ this(browser, null);
+ }
+
+ public BrowserLaunchSpecification(Browser browser, String overrideUrl) {
+ this.browser = browser;
+ this.overrideUrl = overrideUrl;
+ }
+
+ public String getOverrideUrl() {
+ return overrideUrl;
+ }
+
+ public boolean hasOverrideUrl() {
+ return !StringUtility.isEmpty(overrideUrl);
+ }
+
+ public boolean isForDefaultBrowser() {
+ return browser.isDefault();
+ }
+
+ public Browser getBrowser() {
+ return browser;
+ }
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/BrowserTestRunner.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/BrowserTestRunner.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/BrowserTestRunner.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,34 @@
+package net.jsunit;
+
+import net.jsunit.model.Browser;
+import net.jsunit.model.BrowserResult;
+
+import java.util.List;
+
+public interface BrowserTestRunner extends XmlRenderable {
+
+ void startTestRun();
+
+ void finishTestRun();
+
+ long launchBrowserTestRun(BrowserLaunchSpecification launchSpec);
+
+ void accept(BrowserResult result);
+
+ boolean hasReceivedResultSince(long launchTime);
+
+ BrowserResult lastResult();
+
+ void dispose();
+
+ BrowserResult findResultWithId(String id, int browserId) throws InvalidBrowserIdException;
+
+ void logStatus(String message);
+
+ List<Browser> getBrowsers();
+
+ int timeoutSeconds();
+
+ boolean isAlive();
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/ClientSideConnection.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/ClientSideConnection.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/ClientSideConnection.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,59 @@
+/**
+ *
+ */
+package net.jsunit;
+
+import java.io.*;
+import java.net.ServerSocket;
+import java.net.Socket;
+
+public class ClientSideConnection extends Thread {
+
+ private MessageReceiver receiver;
+ private final int port;
+ private ServerSocket serverSocket;
+ private Socket socket;
+ private BufferedReader reader;
+ private PrintWriter writer;
+ private boolean running;
+
+ public ClientSideConnection(MessageReceiver receiver, int port) {
+ this.port = port;
+ this.receiver = receiver;
+ }
+
+ public void run() {
+ try {
+ serverSocket = new ServerSocket(port);
+ socket = serverSocket.accept();
+ reader = new BufferedReader(new InputStreamReader(socket.getInputStream(), "UTF-8"));
+ writer = new PrintWriter(new OutputStreamWriter(socket.getOutputStream(), "UTF-8"));
+ String message;
+ running = true;
+ while (running && reader != null && (message = reader.readLine()) != null)
+ receiver.messageReceived(message);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ shutdown();
+ }
+
+ public boolean isRunning() {
+ return running;
+ }
+
+ public void shutdown() {
+ try {
+ if (serverSocket != null)
+ serverSocket.close();
+ } catch (IOException e) {
+ }
+ running = false;
+ }
+
+ public void sendMessage(String message) {
+ writer.println(message);
+ writer.flush();
+ }
+
+}
\ No newline at end of file
Added: branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/InvalidBrowserIdException.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/InvalidBrowserIdException.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/InvalidBrowserIdException.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,7 @@
+package net.jsunit;
+
+public class InvalidBrowserIdException extends Throwable {
+ public InvalidBrowserIdException(int invalidBrowserId) {
+ super("Invalid browser ID: " + invalidBrowserId);
+ }
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/MessageReceiver.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/MessageReceiver.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/MessageReceiver.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,8 @@
+/**
+ *
+ */
+package net.jsunit;
+
+interface MessageReceiver {
+ public void messageReceived(String message);
+}
\ No newline at end of file
Added: branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/RemoteTestRunClient.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/RemoteTestRunClient.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/RemoteTestRunClient.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,75 @@
+package net.jsunit;
+
+import net.jsunit.model.Browser;
+import net.jsunit.model.BrowserResult;
+import net.jsunit.model.BrowserResultBuilder;
+import net.jsunit.model.BrowserSource;
+
+public class RemoteTestRunClient implements MessageReceiver {
+
+ private BrowserSource browserSource;
+ private final TestRunListener listener;
+ private MessageReceiver complexMessageReceiver;
+ private ClientSideConnection clientSideConnection;
+
+ public RemoteTestRunClient(BrowserSource browserSource, TestRunListener listener, int serverPort) {
+ this.browserSource = browserSource;
+ this.listener = listener;
+ clientSideConnection = new ClientSideConnection(this, serverPort);
+ }
+
+ public void startListening() {
+ clientSideConnection.start();
+ }
+
+ public void stopListening() {
+ clientSideConnection.shutdown();
+ }
+
+ public void messageReceived(String message) {
+ if (message.equals(TestRunNotifierServer.TEST_RUN_STARTED))
+ listener.testRunStarted();
+ else if (message.equals(TestRunNotifierServer.TEST_RUN_FINISHED))
+ listener.testRunFinished();
+ else if (message.equals(TestRunNotifierServer.BROWSER_TEST_RUN_STARTED))
+ complexMessageReceiver = new TestRunStartedReceiver();
+ else if (message.equals(TestRunNotifierServer.BROWSER_TEST_RUN_FINISHED))
+ complexMessageReceiver = new TestRunFinishedReceiver();
+ else
+ complexMessageReceiver.messageReceived(message);
+ }
+
+ private class TestRunStartedReceiver implements MessageReceiver {
+
+ public void messageReceived(String browserIdString) {
+ int browserId = Integer.parseInt(browserIdString);
+ Browser browser = browserSource.getBrowserById(browserId);
+ listener.browserTestRunStarted(browser);
+ }
+ }
+
+ private class TestRunFinishedReceiver implements MessageReceiver {
+
+ private Browser browser;
+ private String xmlString = "";
+
+ public void messageReceived(String message) {
+ if (browser == null) {
+ int browserId = Integer.parseInt(message);
+ browser = browserSource.getBrowserById(browserId);
+ } else if (message.equals(TestRunNotifierServer.END_XML)) {
+ BrowserResult result = new BrowserResultBuilder(browserSource).build(xmlString);
+ listener.browserTestRunFinished(browser, result);
+ } else if (message.trim().length() > 0) {
+ xmlString += message;
+ xmlString += "\n";
+ }
+ }
+
+ }
+
+ public void sendStopServer() {
+ clientSideConnection.sendMessage("stop");
+ }
+
+}
\ No newline at end of file
Added: branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/ServerSideConnection.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/ServerSideConnection.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/ServerSideConnection.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,77 @@
+package net.jsunit;
+
+import java.io.*;
+import java.net.Socket;
+
+public class ServerSideConnection {
+
+ private int port;
+ private Socket clientSocket;
+ private PrintWriter writer;
+ private String host = "localhost";
+ private boolean isConnected;
+ private final MessageReceiver receiver;
+ private BufferedReader reader;
+
+ public ServerSideConnection(MessageReceiver receiver, int port) {
+ this.receiver = receiver;
+ this.port = port;
+ }
+
+ public void connect() {
+ for (int i = 1; i < 30; i++) {
+ try {
+ clientSocket = new Socket(host, port);
+ writer = new PrintWriter(new OutputStreamWriter(clientSocket.getOutputStream(), "UTF-8"), false);
+ reader = new BufferedReader(new InputStreamReader(clientSocket.getInputStream(), "UTF-8"));
+ isConnected = true;
+ new ReaderThread().start();
+ return;
+ } catch (IOException e1) {
+ try {
+ Thread.sleep(250);
+ } catch (InterruptedException e2) {
+ }
+ }
+ }
+ throw new RuntimeException("server could not connect");
+ }
+
+ public void shutDown() {
+ if (writer != null) {
+ writer.close();
+ writer = null;
+ }
+
+ try {
+ if (clientSocket != null) {
+ clientSocket.close();
+ clientSocket = null;
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public void sendMessage(String message) {
+ writer.println(message);
+ writer.flush();
+ }
+
+ public boolean isConnected() {
+ return isConnected;
+ }
+
+ class ReaderThread extends Thread {
+ public void run() {
+ String message;
+ try {
+ while (isConnected && reader != null && (message = reader.readLine()) != null)
+ receiver.messageReceived(message);
+ } catch (IOException e) {
+ }
+
+ }
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/TestRunListener.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/TestRunListener.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/TestRunListener.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,18 @@
+package net.jsunit;
+
+import net.jsunit.model.Browser;
+import net.jsunit.model.BrowserResult;
+
+public interface TestRunListener {
+
+ boolean isReady();
+
+ void testRunStarted();
+
+ void testRunFinished();
+
+ void browserTestRunStarted(Browser browser);
+
+ void browserTestRunFinished(Browser browser, BrowserResult result);
+
+}
\ No newline at end of file
Added: branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/TestRunNotifierServer.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/TestRunNotifierServer.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/TestRunNotifierServer.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,63 @@
+package net.jsunit;
+
+import net.jsunit.model.Browser;
+import net.jsunit.model.BrowserResult;
+import net.jsunit.utility.XmlUtility;
+
+public class TestRunNotifierServer implements TestRunListener {
+
+ public static final String TEST_RUN_FINISHED = "testRunFinished";
+ public static final String TEST_RUN_STARTED = "testRunStarted";
+ public static final String BROWSER_TEST_RUN_FINISHED = "browserTestRunFinished";
+ public static final String BROWSER_TEST_RUN_STARTED = "browserTestRunStarted";
+ public static final String END_XML = "endXml";
+ private ServerSideConnection serverSideConnection;
+
+ public TestRunNotifierServer(BrowserTestRunner runner, int port) {
+ serverSideConnection = new ServerSideConnection(new StopMessageReceiver(runner), port);
+ }
+
+ public void browserTestRunStarted(Browser browser) {
+ serverSideConnection.sendMessage(BROWSER_TEST_RUN_STARTED);
+ serverSideConnection.sendMessage(String.valueOf(browser.getId()));
+ }
+
+ public void browserTestRunFinished(Browser browser, BrowserResult result) {
+ serverSideConnection.sendMessage(BROWSER_TEST_RUN_FINISHED);
+ serverSideConnection.sendMessage(String.valueOf(browser.getId()));
+ serverSideConnection.sendMessage(XmlUtility.asString(result.asXmlDocument()));
+ serverSideConnection.sendMessage(END_XML);
+ }
+
+ public void testRunStarted() {
+ serverSideConnection.connect();
+ serverSideConnection.sendMessage(TEST_RUN_STARTED);
+ }
+
+ public void testRunFinished() {
+ serverSideConnection.sendMessage(TEST_RUN_FINISHED);
+ serverSideConnection.shutDown();
+ }
+
+ public boolean isReady() {
+ return serverSideConnection.isConnected();
+ }
+
+ static class StopMessageReceiver implements MessageReceiver {
+
+ private final BrowserTestRunner runner;
+
+ public StopMessageReceiver(BrowserTestRunner runner) {
+ this.runner = runner;
+ }
+
+ public void messageReceived(String message) {
+ if ("stop".equals(message)) {
+ runner.logStatus("Stopping Test Run");
+ runner.dispose();
+ }
+ }
+
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/XmlRenderable.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/XmlRenderable.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/XmlRenderable.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,9 @@
+package net.jsunit;
+
+import org.jdom.Element;
+
+public interface XmlRenderable {
+
+ Element asXml();
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/configuration/ArgumentsConfigurationSource.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/configuration/ArgumentsConfigurationSource.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/configuration/ArgumentsConfigurationSource.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,66 @@
+package net.jsunit.configuration;
+
+import java.util.List;
+
+public class ArgumentsConfigurationSource implements ConfigurationSource {
+
+ private List<String> arguments;
+
+ public ArgumentsConfigurationSource(List<String> arguments) {
+ this.arguments = arguments;
+ }
+
+ private String argumentValue(ConfigurationProperty property) {
+ for (int i = 0; i < arguments.size(); i++) {
+ if (arguments.get(i).equalsIgnoreCase("-" + property.getName())) {
+ String value = arguments.get(i + 1);
+ if (!value.startsWith("-"))
+ return value;
+ else
+ return "";
+ }
+ }
+ return null;
+ }
+
+ public String resourceBase() {
+ return argumentValue(ConfigurationProperty.RESOURCE_BASE);
+ }
+
+ public String port() {
+ return argumentValue(ConfigurationProperty.PORT);
+ }
+
+ public String remoteMachineURLs() {
+ return argumentValue(ConfigurationProperty.REMOTE_MACHINE_URLS);
+ }
+
+ public String logsDirectory() {
+ return argumentValue(ConfigurationProperty.LOGS_DIRECTORY);
+ }
+
+ public String browserFileNames() {
+ return argumentValue(ConfigurationProperty.BROWSER_FILE_NAMES);
+ }
+
+ public String url() {
+ return argumentValue(ConfigurationProperty.URL);
+ }
+
+ public String ignoreUnresponsiveRemoteMachines() {
+ return argumentValue(ConfigurationProperty.IGNORE_UNRESPONSIVE_REMOTE_MACHINES);
+ }
+
+ public String closeBrowsersAfterTestRuns() {
+ return argumentValue(ConfigurationProperty.CLOSE_BROWSERS_AFTER_TEST_RUNS);
+ }
+
+ public String description() {
+ return argumentValue(ConfigurationProperty.DESCRIPTION);
+ }
+
+ public String timeoutSeconds() {
+ return argumentValue(ConfigurationProperty.TIMEOUT_SECONDS);
+ }
+
+}
\ No newline at end of file
Added: branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/configuration/CompositeConfigurationSource.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/configuration/CompositeConfigurationSource.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/configuration/CompositeConfigurationSource.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,135 @@
+package net.jsunit.configuration;
+
+import java.io.FileNotFoundException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+public class CompositeConfigurationSource implements ConfigurationSource {
+ private List<ConfigurationSource> sources;
+
+ public CompositeConfigurationSource() {
+ this.sources = new ArrayList<ConfigurationSource>();
+ }
+
+ public CompositeConfigurationSource(ConfigurationSource... sources) {
+ this();
+ add(sources);
+ }
+
+ public static ConfigurationSource productionConfiguration(String[] arguments) {
+ CompositeConfigurationSource result = new CompositeConfigurationSource(
+ new ArgumentsConfigurationSource(Arrays.asList(arguments)),
+ new EnvironmentVariablesConfigurationSource());
+ try {
+ result.add(new PropertiesFileConfigurationSource());
+ } catch (FileNotFoundException e) {
+ // Skip the properties file configuration source if there is no appropriately names properties file.
+ }
+ return result;
+ }
+
+ public void add(ConfigurationSource... sources) {
+ this.sources.addAll(Arrays.asList(sources));
+ }
+
+ public String browserFileNames() {
+ for (ConfigurationSource source : sources) {
+ String result = source.browserFileNames();
+ if (result != null) {
+ return result;
+ }
+ }
+ return null;
+ }
+
+ public String closeBrowsersAfterTestRuns() {
+ for (ConfigurationSource source : sources) {
+ String result = source.closeBrowsersAfterTestRuns();
+ if (result != null) {
+ return result;
+ }
+ }
+ return null;
+ }
+
+ public String description() {
+ for (ConfigurationSource source : sources) {
+ String result = source.description();
+ if (result != null) {
+ return result;
+ }
+ }
+ return null;
+ }
+
+ public String logsDirectory() {
+ for (ConfigurationSource source : sources) {
+ String result = source.logsDirectory();
+ if (result != null) {
+ return result;
+ }
+ }
+ return null;
+ }
+
+ public String port() {
+ for (ConfigurationSource source : sources) {
+ String result = source.port();
+ if (result != null) {
+ return result;
+ }
+ }
+ return null;
+ }
+
+ public String remoteMachineURLs() {
+ for (ConfigurationSource source : sources) {
+ String result = source.remoteMachineURLs();
+ if (result != null) {
+ return result;
+ }
+ }
+ return null;
+ }
+
+ public String resourceBase() {
+ for (ConfigurationSource source : sources) {
+ String result = source.resourceBase();
+ if (result != null) {
+ return result;
+ }
+ }
+ return null;
+ }
+
+ public String timeoutSeconds() {
+ for (ConfigurationSource source : sources) {
+ String result = source.timeoutSeconds();
+ if (result != null) {
+ return result;
+ }
+ }
+ return null;
+ }
+
+ public String url() {
+ for (ConfigurationSource source : sources) {
+ String result = source.url();
+ if (result != null) {
+ return result;
+ }
+ }
+ return null;
+ }
+
+ public String ignoreUnresponsiveRemoteMachines() {
+ for (ConfigurationSource source : sources) {
+ String result = source.ignoreUnresponsiveRemoteMachines();
+ if (result != null) {
+ return result;
+ }
+ }
+ return null;
+ }
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/configuration/Configuration.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/configuration/Configuration.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/configuration/Configuration.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,177 @@
+package net.jsunit.configuration;
+
+import net.jsunit.model.Browser;
+import net.jsunit.model.BrowserSource;
+import net.jsunit.utility.SystemUtility;
+import org.jdom.Element;
+
+import java.io.File;
+import java.net.URL;
+import java.util.List;
+
+public final class Configuration implements BrowserSource {
+
+ private List<Browser> browsers;
+ private boolean closeBrowsersAfterTestRuns;
+ private String description;
+ private boolean ignoreUnresponsiveRemoteMachines;
+ private File logsDirectory;
+ private int port;
+ private List<URL> remoteMachineURLs;
+ private File resourceBase;
+ private int timeoutSeconds;
+ private URL testURL;
+
+ public static Configuration resolve(String[] arguments) {
+ return new Configuration(resolveSource(arguments));
+ }
+
+ public static ConfigurationSource resolveSource(String[] arguments) {
+ return CompositeConfigurationSource.productionConfiguration(arguments);
+ }
+
+ public static ConfigurationSource resolveSource() {
+ return resolveSource(new String[]{});
+ }
+
+ public Configuration(ConfigurationSource source) {
+ for (ConfigurationProperty property : ConfigurationProperty.values())
+ property.configure(this, source);
+ }
+
+ public Element asXml(ServerType serverType) {
+ Element configurationElement = new Element("configuration");
+ configurationElement.setAttribute("type", serverType.name());
+ addSystemElementsTo(configurationElement);
+ for (ConfigurationProperty property : getRequiredAndOptionalConfigurationProperties(serverType))
+ property.addXmlTo(configurationElement, this);
+ return configurationElement;
+ }
+
+ private void addSystemElementsTo(Element element) {
+ Element osElement = new Element("os");
+ osElement.setText(SystemUtility.osString());
+ element.addContent(osElement);
+ Element ipAddressElement = new Element("ipAddress");
+ ipAddressElement.setText(SystemUtility.ipAddress());
+ element.addContent(ipAddressElement);
+ Element hostnameElement = new Element("hostname");
+ hostnameElement.setText(SystemUtility.hostname());
+ element.addContent(hostnameElement);
+ }
+
+ public List<ConfigurationProperty> getRequiredAndOptionalConfigurationProperties(ServerType serverType) {
+ return serverType.getRequiredAndOptionalConfigurationProperties();
+ }
+
+ public String[] asArgumentsArray() {
+ List<ConfigurationProperty> properties = ConfigurationProperty.all();
+ String[] arguments = new String[properties.size() * 2];
+ int i = 0;
+ for (ConfigurationProperty property : properties) {
+ arguments[i++] = "-" + property.getName();
+ arguments[i++] = property.getValueString(this);
+ }
+ return arguments;
+ }
+
+ public boolean isValidFor(ServerType type) {
+ return type.getPropertiesInvalidFor(this).isEmpty();
+ }
+
+ public String toString() {
+ return getDescription() == null ? super.toString() : getDescription();
+ }
+
+ public List<Browser> getBrowsers() {
+ return browsers;
+ }
+
+ public void setBrowsers(List<Browser> browsers) {
+ this.browsers = browsers;
+ }
+
+ public boolean shouldCloseBrowsersAfterTestRuns() {
+ return closeBrowsersAfterTestRuns;
+ }
+
+ public void setCloseBrowsersAfterTestRuns(boolean closeBrowsersAfterTestRuns) {
+ this.closeBrowsersAfterTestRuns = closeBrowsersAfterTestRuns;
+ }
+
+ public String getDescription() {
+ return description;
+ }
+
+ public void setDescription(String description) {
+ this.description = description;
+ }
+
+ public boolean shouldIgnoreUnresponsiveRemoteMachines() {
+ return ignoreUnresponsiveRemoteMachines;
+ }
+
+ public void setIgnoreUnresponsiveRemoteMachines(boolean ignoreUnresponsiveRemoteMachines) {
+ this.ignoreUnresponsiveRemoteMachines = ignoreUnresponsiveRemoteMachines;
+ }
+
+ public File getLogsDirectory() {
+ return logsDirectory;
+ }
+
+ public void setLogsDirectory(File logsDirectory) {
+ this.logsDirectory = logsDirectory;
+ }
+
+ public int getPort() {
+ return port;
+ }
+
+ public void setPort(int port) {
+ this.port = port;
+ }
+
+ public List<URL> getRemoteMachineURLs() {
+ return remoteMachineURLs;
+ }
+
+ public void setRemoteMachineURLs(List<URL> remoteMachineURLs) {
+ this.remoteMachineURLs = remoteMachineURLs;
+ }
+
+ public File getResourceBase() {
+ return resourceBase;
+ }
+
+ public void setResourceBase(File resourceBase) {
+ this.resourceBase = resourceBase;
+ }
+
+ public int getTimeoutSeconds() {
+ return timeoutSeconds;
+ }
+
+ public void setTimeoutSeconds(int timeoutSeconds) {
+ this.timeoutSeconds = timeoutSeconds;
+ }
+
+ public URL getTestURL() {
+ return testURL;
+ }
+
+ public void setTestURL(URL url) {
+ this.testURL = url;
+ }
+
+ public Browser getBrowserById(int id) {
+ for (Browser browser : browsers)
+ if (browser.hasId(id))
+ return browser;
+ return null;
+ }
+
+ public URL getRemoteMachineURLById(int id) {
+ return getRemoteMachineURLs().get(id);
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/configuration/ConfigurationException.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/configuration/ConfigurationException.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/configuration/ConfigurationException.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,36 @@
+package net.jsunit.configuration;
+
+public class ConfigurationException extends RuntimeException {
+ private ConfigurationProperty propertyInError;
+ private String invalidValue;
+
+ public ConfigurationException(ConfigurationProperty property, String invalidValue) {
+ this.propertyInError = property;
+ this.invalidValue = invalidValue;
+ }
+
+ public ConfigurationException(ConfigurationProperty property, String invalidValue, Exception exception) {
+ super(exception);
+ this.propertyInError = property;
+ this.invalidValue = invalidValue;
+ }
+
+ public ConfigurationProperty getPropertyInError() {
+ return propertyInError;
+ }
+
+ public String getInvalidValue() {
+ return invalidValue;
+ }
+
+ public String toString() {
+ StringBuffer result = new StringBuffer();
+ result.append("Invalid property ");
+ result.append(propertyInError.getName());
+ result.append(" - \"");
+ result.append(invalidValue);
+ result.append("\"");
+ return result.toString();
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/configuration/ConfigurationProperty.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/configuration/ConfigurationProperty.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/configuration/ConfigurationProperty.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,286 @@
+package net.jsunit.configuration;
+
+import net.jsunit.model.Browser;
+import net.jsunit.utility.StringUtility;
+import org.jdom.Element;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.*;
+
+public enum ConfigurationProperty {
+
+ BROWSER_FILE_NAMES("browserFileNames", "Browser file names", false, true) {
+
+ public String getValueString(Configuration configuration) {
+ StringBuffer buffer = new StringBuffer();
+ for (Iterator it = configuration.getBrowsers().iterator(); it.hasNext();) {
+ Browser browser = (Browser) it.next();
+ buffer.append(browser.getFileName());
+ if (it.hasNext())
+ buffer.append(",");
+ }
+ return buffer.toString();
+ }
+
+ protected void addContentTo(Configuration configuration, Element element) {
+ for (Browser browser : configuration.getBrowsers()) {
+ Element fileNameElement = new Element("browserFileName");
+ fileNameElement.setAttribute("id", String.valueOf(browser.getId()));
+ fileNameElement.setText(browser.getFileName());
+ element.addContent(fileNameElement);
+ }
+ }
+
+ public void configure(Configuration configuration, ConfigurationSource source) throws ConfigurationException {
+ String browserFileNamesString = source.browserFileNames();
+ try {
+ List<String> browserFileNames = StringUtility.listFromCommaDelimitedString(browserFileNamesString);
+ Set<String> alreadyAddedBrowserFileNames = new HashSet<String>();
+ int id = 0;
+ List<Browser> browsers = new ArrayList<Browser>();
+ for (String browserFileName : browserFileNames) {
+ if (!alreadyAddedBrowserFileNames.contains(browserFileName) || Browser.DEFAULT_SYSTEM_BROWSER.equals(browserFileName))
+ {
+ browsers.add(new Browser(browserFileName, id++));
+ alreadyAddedBrowserFileNames.add(browserFileName);
+ }
+ }
+ configuration.setBrowsers(browsers);
+ } catch (Exception e) {
+ throw new ConfigurationException(this, browserFileNamesString, e);
+ }
+ }
+ },
+
+ CLOSE_BROWSERS_AFTER_TEST_RUNS("closeBrowsersAfterTestRuns", "Close browsers?", false, false) {
+ public String getValueString(Configuration configuration) {
+ return String.valueOf(configuration.shouldCloseBrowsersAfterTestRuns());
+ }
+
+ public void configure(Configuration configuration, ConfigurationSource source) throws ConfigurationException {
+ String string = source.closeBrowsersAfterTestRuns();
+ if (StringUtility.isEmpty(string))
+ string = String.valueOf(true);
+ configuration.setCloseBrowsersAfterTestRuns(Boolean.valueOf(string));
+ }
+ },
+
+ DESCRIPTION("description", "Description", false, false) {
+ public String getValueString(Configuration configuration) {
+ String description = configuration.getDescription();
+ if (StringUtility.isEmpty(description))
+ return "";
+ return description;
+ }
+
+ public void configure(Configuration configuration, ConfigurationSource source) throws ConfigurationException {
+ configuration.setDescription(source.description());
+ }
+ },
+
+ IGNORE_UNRESPONSIVE_REMOTE_MACHINES("ignoreUnresponsiveRemoteMachines", "Ignore unresponsive remove machines?", false, false) {
+ public String getValueString(Configuration configuration) {
+ return String.valueOf(configuration.shouldIgnoreUnresponsiveRemoteMachines());
+ }
+
+ public void configure(Configuration configuration, ConfigurationSource source) throws ConfigurationException {
+ String string = source.ignoreUnresponsiveRemoteMachines();
+ if (StringUtility.isEmpty(string))
+ string = String.valueOf(false);
+ configuration.setIgnoreUnresponsiveRemoteMachines(Boolean.valueOf(string));
+ }
+ },
+
+ LOGS_DIRECTORY("logsDirectory", "Logs directory", false, false) {
+ public String getValueString(Configuration configuration) {
+ return configuration.getLogsDirectory().getAbsolutePath();
+ }
+
+ public void configure(Configuration configuration, ConfigurationSource source) throws ConfigurationException {
+ String logsDirectoryString = source.logsDirectory();
+ try {
+ if (StringUtility.isEmpty(logsDirectoryString))
+ logsDirectoryString = "logs";
+ configuration.setLogsDirectory(new File(logsDirectoryString));
+ } catch (Exception e) {
+ throw new ConfigurationException(this, logsDirectoryString, e);
+ }
+
+ }
+ },
+
+ PORT("port", "Port", false, false) {
+ public String getValueString(Configuration configuration) {
+ return String.valueOf(configuration.getPort());
+ }
+
+ public void configure(Configuration configuration, ConfigurationSource source) throws ConfigurationException {
+ String portString = source.port();
+ if (StringUtility.isEmpty(portString))
+ portString = "8080";
+ try {
+ configuration.setPort(Integer.parseInt(portString));
+ } catch (NumberFormatException e) {
+ throw new ConfigurationException(this, portString, e);
+ }
+ }
+ },
+
+ REMOTE_MACHINE_URLS("remoteMachineURLs", "Remote machine URLs", true, true) {
+ public String getValueString(Configuration configuration) {
+ return StringUtility.commaSeparatedString(configuration.getRemoteMachineURLs());
+ }
+
+ protected void addContentTo(Configuration configuration, Element element) {
+ for (int i = 0; i < configuration.getRemoteMachineURLs().size(); i++) {
+ URL remoteMachineURL = configuration.getRemoteMachineURLs().get(i);
+ Element urlElement = new Element("remoteMachineURL");
+ urlElement.setAttribute("id", String.valueOf(i));
+ urlElement.setText(remoteMachineURL.toString());
+ element.addContent(urlElement);
+ }
+ }
+
+ public void configure(Configuration configuration, ConfigurationSource source) throws ConfigurationException {
+ String remoteMachineURLs = source.remoteMachineURLs();
+ List<String> strings = StringUtility.listFromCommaDelimitedString(remoteMachineURLs);
+ List<URL> result = new ArrayList<URL>(strings.size());
+ Set<String> alreadyAddedURLStrings = new HashSet<String>();
+ for (String string : strings)
+ try {
+ URL attemptedURL = new URL(string);
+ URL normalizedURL = new URL(attemptedURL.getProtocol(), attemptedURL.getHost(), attemptedURL.getPort(), "/jsunit");
+ if (!alreadyAddedURLStrings.contains(normalizedURL.toString())) {
+ result.add(normalizedURL);
+ alreadyAddedURLStrings.add(normalizedURL.toString());
+ }
+ } catch (MalformedURLException e) {
+ throw new ConfigurationException(this, remoteMachineURLs, e);
+ }
+ configuration.setRemoteMachineURLs(result);
+ }
+ },
+
+ RESOURCE_BASE("resourceBase", "Resource base", false, false) {
+ public String getValueString(Configuration configuration) {
+ return configuration.getResourceBase().getAbsolutePath();
+ }
+
+ public void configure(Configuration configuration, ConfigurationSource source) throws ConfigurationException {
+ String resourceBaseString = source.resourceBase();
+ if (StringUtility.isEmpty(resourceBaseString))
+ resourceBaseString = ".";
+ try {
+ configuration.setResourceBase(new File(resourceBaseString));
+ } catch (Exception e) {
+ throw new ConfigurationException(this, resourceBaseString, e);
+ }
+ }
+ },
+
+ TIMEOUT_SECONDS("timeoutSeconds", "Test timeout (seconds)", false, false) {
+ public String getValueString(Configuration configuration) {
+ return String.valueOf(configuration.getTimeoutSeconds());
+ }
+
+ public void configure(Configuration configuration, ConfigurationSource source) throws ConfigurationException {
+ String timeoutSecondsString = source.timeoutSeconds();
+ if (StringUtility.isEmpty(timeoutSecondsString))
+ timeoutSecondsString = "60";
+ try {
+ configuration.setTimeoutSeconds(Integer.parseInt(timeoutSecondsString));
+ } catch (NumberFormatException e) {
+ throw new ConfigurationException(ConfigurationProperty.TIMEOUT_SECONDS, timeoutSecondsString, e);
+ }
+
+ }
+ },
+
+ URL("url", "Test Page URL", true, false) {
+ public String getValueString(Configuration configuration) {
+ URL testURL = configuration.getTestURL();
+ return testURL == null ? "" : testURL.toString();
+ }
+
+ public void configure(Configuration configuration, ConfigurationSource source) throws ConfigurationException {
+ String urlString = source.url();
+ if (StringUtility.isEmpty(urlString))
+ return;
+ try {
+ configuration.setTestURL(new URL(urlString));
+ } catch (MalformedURLException e) {
+ throw new ConfigurationException(this, urlString, e);
+ }
+
+ }
+ };
+
+ private String name;
+ private String displayName;
+ private boolean isURL;
+ private boolean isMultiValued;
+
+ private ConfigurationProperty(String name, String displayName, boolean isURL, boolean isMultiValued) {
+ this.displayName = displayName;
+ this.name = name;
+ this.isURL = isURL;
+ this.isMultiValued = isMultiValued;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public abstract String getValueString(Configuration configuration);
+
+ public void addXmlTo(Element parentElement, Configuration configuration) {
+ Element element = new Element(name);
+ addContentTo(configuration, element);
+ parentElement.addContent(element);
+ }
+
+ protected void addContentTo(Configuration configuration, Element element) {
+ element.setText(getValueString(configuration));
+ }
+
+ public static List<ConfigurationProperty> all() {
+ List<ConfigurationProperty> result = Arrays.asList(ConfigurationProperty.values());
+ Collections.sort(result, comparator());
+ return result;
+ }
+
+ public static Comparator<ConfigurationProperty> comparator() {
+ return new Comparator<ConfigurationProperty>() {
+ public int compare(ConfigurationProperty property1, ConfigurationProperty property2) {
+ return property1.name().compareTo(property2.name());
+ }
+ };
+ }
+
+ public String getDisplayName() {
+ return displayName;
+ }
+
+ public boolean isURL() {
+ return isURL;
+ }
+
+ public List<String> getValueStrings(Configuration configuration) {
+ List<String> result = new ArrayList<String>();
+ if (isMultiValued())
+ for (String value : StringUtility.listFromCommaDelimitedString(getValueString(configuration)))
+ result.add(value);
+ else
+ result.add(getValueString(configuration));
+ return result;
+ }
+
+ private boolean isMultiValued() {
+ return isMultiValued;
+ }
+
+ public abstract void configure(Configuration configuration, ConfigurationSource source) throws ConfigurationException;
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/configuration/ConfigurationSource.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/configuration/ConfigurationSource.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/configuration/ConfigurationSource.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,24 @@
+package net.jsunit.configuration;
+
+public interface ConfigurationSource {
+
+ String browserFileNames();
+
+ String closeBrowsersAfterTestRuns();
+
+ String description();
+
+ String logsDirectory();
+
+ String port();
+
+ String remoteMachineURLs();
+
+ String resourceBase();
+
+ String timeoutSeconds();
+
+ String url();
+
+ String ignoreUnresponsiveRemoteMachines();
+}
\ No newline at end of file
Added: branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/configuration/DelegatingConfigurationSource.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/configuration/DelegatingConfigurationSource.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/configuration/DelegatingConfigurationSource.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,49 @@
+package net.jsunit.configuration;
+
+public class DelegatingConfigurationSource implements ConfigurationSource {
+ private ConfigurationSource source;
+
+ public DelegatingConfigurationSource(ConfigurationSource source) {
+ this.source = source;
+ }
+
+ public String browserFileNames() {
+ return source.browserFileNames();
+ }
+
+ public String closeBrowsersAfterTestRuns() {
+ return source.closeBrowsersAfterTestRuns();
+ }
+
+ public String description() {
+ return source.description();
+ }
+
+ public String logsDirectory() {
+ return source.logsDirectory();
+ }
+
+ public String port() {
+ return source.port();
+ }
+
+ public String remoteMachineURLs() {
+ return source.remoteMachineURLs();
+ }
+
+ public String resourceBase() {
+ return source.resourceBase();
+ }
+
+ public String timeoutSeconds() {
+ return source.timeoutSeconds();
+ }
+
+ public String url() {
+ return source.url();
+ }
+
+ public String ignoreUnresponsiveRemoteMachines() {
+ return source.ignoreUnresponsiveRemoteMachines();
+ }
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/configuration/EnvironmentVariablesConfigurationSource.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/configuration/EnvironmentVariablesConfigurationSource.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/configuration/EnvironmentVariablesConfigurationSource.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,49 @@
+package net.jsunit.configuration;
+
+public class EnvironmentVariablesConfigurationSource implements ConfigurationSource {
+
+ private String environmentVariableValue(ConfigurationProperty property) {
+ return System.getProperty(property.getName());
+ }
+
+ public String resourceBase() {
+ return environmentVariableValue(ConfigurationProperty.RESOURCE_BASE);
+ }
+
+ public String port() {
+ return environmentVariableValue(ConfigurationProperty.PORT);
+ }
+
+ public String remoteMachineURLs() {
+ return environmentVariableValue(ConfigurationProperty.REMOTE_MACHINE_URLS);
+ }
+
+ public String logsDirectory() {
+ return environmentVariableValue(ConfigurationProperty.LOGS_DIRECTORY);
+ }
+
+ public String browserFileNames() {
+ return environmentVariableValue(ConfigurationProperty.BROWSER_FILE_NAMES);
+ }
+
+ public String url() {
+ return environmentVariableValue(ConfigurationProperty.URL);
+ }
+
+ public String closeBrowsersAfterTestRuns() {
+ return environmentVariableValue(ConfigurationProperty.CLOSE_BROWSERS_AFTER_TEST_RUNS);
+ }
+
+ public String description() {
+ return environmentVariableValue(ConfigurationProperty.DESCRIPTION);
+ }
+
+ public String timeoutSeconds() {
+ return environmentVariableValue(ConfigurationProperty.TIMEOUT_SECONDS);
+ }
+
+ public String ignoreUnresponsiveRemoteMachines() {
+ return environmentVariableValue(ConfigurationProperty.IGNORE_UNRESPONSIVE_REMOTE_MACHINES);
+ }
+
+}
\ No newline at end of file
Added: branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/configuration/FarmConfiguration.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/configuration/FarmConfiguration.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/configuration/FarmConfiguration.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,31 @@
+package net.jsunit.configuration;
+
+import net.jsunit.utility.StringUtility;
+
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+public class FarmConfiguration {
+
+ private final FarmConfigurationSource source;
+
+ public FarmConfiguration(FarmConfigurationSource source) {
+ this.source = source;
+ }
+
+ public List<URL> getRemoteMachineURLs() {
+ String remoteMachineURLs = source.remoteMachineURLs();
+ List<String> strings = StringUtility.listFromCommaDelimitedString(remoteMachineURLs);
+ List<URL> result = new ArrayList<URL>(strings.size());
+ for (String string : strings)
+ try {
+ result.add(new URL(string));
+ } catch (MalformedURLException e) {
+ throw new ConfigurationException(ConfigurationProperty.REMOTE_MACHINE_URLS, remoteMachineURLs, e);
+ }
+ return result;
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/configuration/FarmConfigurationSource.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/configuration/FarmConfigurationSource.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/configuration/FarmConfigurationSource.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,15 @@
+package net.jsunit.configuration;
+
+public interface FarmConfigurationSource {
+
+ String port();
+
+ String logsDirectory();
+
+ String logStatus();
+
+ String timeoutSeconds();
+
+ String remoteMachineURLs();
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/configuration/PropertiesFileConfigurationSource.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/configuration/PropertiesFileConfigurationSource.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/configuration/PropertiesFileConfigurationSource.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,80 @@
+package net.jsunit.configuration;
+
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.util.Properties;
+
+public class PropertiesFileConfigurationSource implements ConfigurationSource {
+
+ public static final String PROPERTIES_FILE_NAME = "jsunit.properties";
+
+ private Properties properties;
+ private String propertiesFileName;
+
+ public PropertiesFileConfigurationSource(String propertiesFileName) throws FileNotFoundException {
+ this.propertiesFileName = propertiesFileName;
+ loadProperties();
+ }
+
+ public PropertiesFileConfigurationSource() throws FileNotFoundException {
+ this(PROPERTIES_FILE_NAME);
+ }
+
+ private void loadProperties() throws FileNotFoundException {
+ properties = new Properties();
+ try {
+ FileInputStream fileInputStream = new FileInputStream(propertiesFileName);
+ properties.load(fileInputStream);
+ fileInputStream.close();
+ } catch (FileNotFoundException e) {
+ throw e;
+ } catch (Throwable t) {
+ throw new RuntimeException(t);
+ }
+ }
+
+ private String propertyValue(ConfigurationProperty property) {
+ return properties.getProperty(property.getName());
+ }
+
+ public String resourceBase() {
+ return propertyValue(ConfigurationProperty.RESOURCE_BASE);
+ }
+
+ public String logsDirectory() {
+ return propertyValue(ConfigurationProperty.LOGS_DIRECTORY);
+ }
+
+ public String port() {
+ return propertyValue(ConfigurationProperty.PORT);
+ }
+
+ public String remoteMachineURLs() {
+ return propertyValue(ConfigurationProperty.REMOTE_MACHINE_URLS);
+ }
+
+ public String url() {
+ return propertyValue(ConfigurationProperty.URL);
+ }
+
+ public String ignoreUnresponsiveRemoteMachines() {
+ return propertyValue(ConfigurationProperty.IGNORE_UNRESPONSIVE_REMOTE_MACHINES);
+ }
+
+ public String browserFileNames() {
+ return propertyValue(ConfigurationProperty.BROWSER_FILE_NAMES);
+ }
+
+ public String closeBrowsersAfterTestRuns() {
+ return propertyValue(ConfigurationProperty.CLOSE_BROWSERS_AFTER_TEST_RUNS);
+ }
+
+ public String description() {
+ return propertyValue(ConfigurationProperty.DESCRIPTION);
+ }
+
+ public String timeoutSeconds() {
+ return propertyValue(ConfigurationProperty.TIMEOUT_SECONDS);
+ }
+
+}
\ No newline at end of file
Added: branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/configuration/ServerType.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/configuration/ServerType.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/configuration/ServerType.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,129 @@
+package net.jsunit.configuration;
+
+import net.jsunit.utility.StringUtility;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+public enum ServerType {
+ STANDARD(
+ "Standard",
+ false,
+ true,
+ false,
+ Arrays.asList(new ConfigurationProperty[]{
+ ConfigurationProperty.CLOSE_BROWSERS_AFTER_TEST_RUNS,
+ ConfigurationProperty.LOGS_DIRECTORY,
+ ConfigurationProperty.PORT,
+ ConfigurationProperty.RESOURCE_BASE,
+ ConfigurationProperty.TIMEOUT_SECONDS,
+ }),
+ Arrays.asList(new ConfigurationProperty[]{
+ ConfigurationProperty.BROWSER_FILE_NAMES,
+ ConfigurationProperty.DESCRIPTION,
+ ConfigurationProperty.URL,
+ })
+ ),
+ STANDARD_TEMPORARY(
+ "Standard Temporary",
+ STANDARD.isFarm(),
+ false,
+ true,
+ STANDARD.getRequiredConfigurationProperties(),
+ STANDARD.getOptionalConfigurationProperties()
+ ),
+ FARM(
+ "Farm",
+ true,
+ true,
+ false,
+ Arrays.asList(new ConfigurationProperty[]{
+ ConfigurationProperty.LOGS_DIRECTORY,
+ ConfigurationProperty.PORT,
+ ConfigurationProperty.REMOTE_MACHINE_URLS,
+ ConfigurationProperty.IGNORE_UNRESPONSIVE_REMOTE_MACHINES,
+ }),
+ Arrays.asList(new ConfigurationProperty []{
+ ConfigurationProperty.DESCRIPTION,
+ ConfigurationProperty.RESOURCE_BASE,
+ ConfigurationProperty.URL,
+ })
+ );
+
+ private List<ConfigurationProperty> requiredProperties;
+ private List<ConfigurationProperty> optionalProperties;
+ private String displayName;
+ private boolean isFarm;
+ private boolean performUpToDateCheck;
+ private boolean isTemporary;
+
+ private ServerType(
+ String displayName,
+ boolean isFarm,
+ boolean performVersionUpToDateCheck,
+ boolean isTemporary,
+ List<ConfigurationProperty> required,
+ List<ConfigurationProperty> optional) {
+ this.performUpToDateCheck = performVersionUpToDateCheck;
+ this.displayName = displayName;
+ this.isFarm = isFarm;
+ this.isTemporary = isTemporary;
+ this.requiredProperties = required;
+ this.optionalProperties = optional;
+ }
+
+ public List<ConfigurationProperty> getRequiredConfigurationProperties() {
+ return requiredProperties;
+ }
+
+ public List<ConfigurationProperty> getOptionalConfigurationProperties() {
+ return optionalProperties;
+ }
+
+ public List<ConfigurationProperty> getPropertiesInvalidFor(Configuration configuration) {
+ List<ConfigurationProperty> result = new ArrayList<ConfigurationProperty>();
+
+ for (ConfigurationProperty property : getRequiredAndOptionalConfigurationProperties()) {
+ try {
+ String valueString = property.getValueString(configuration);
+ if (isPropertyRequired(property) && StringUtility.isEmpty(valueString))
+ result.add(property);
+ } catch (ConfigurationException e) {
+ result.add(property);
+ }
+ }
+
+ return result;
+
+ }
+
+ private boolean isPropertyRequired(ConfigurationProperty property) {
+ return getRequiredConfigurationProperties().contains(property);
+ }
+
+ public List<ConfigurationProperty> getRequiredAndOptionalConfigurationProperties() {
+ List<ConfigurationProperty> result = new ArrayList<ConfigurationProperty>();
+ result.addAll(getRequiredConfigurationProperties());
+ result.addAll(getOptionalConfigurationProperties());
+ Collections.sort(result, ConfigurationProperty.comparator());
+ return result;
+ }
+
+ public boolean isFarm() {
+ return isFarm;
+ }
+
+ public String getDisplayName() {
+ return displayName;
+ }
+
+ public boolean shouldPerformUpToDateCheck() {
+ return performUpToDateCheck;
+ }
+
+ public boolean isTemporary() {
+ return isTemporary;
+ }
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/logging/BrowserResultRepository.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/logging/BrowserResultRepository.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/logging/BrowserResultRepository.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,12 @@
+package net.jsunit.logging;
+
+import net.jsunit.model.Browser;
+import net.jsunit.model.BrowserResult;
+
+public interface BrowserResultRepository {
+
+ void store(BrowserResult result);
+
+ BrowserResult retrieve(String id, Browser browser);
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/logging/FileBrowserResultRepository.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/logging/FileBrowserResultRepository.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/logging/FileBrowserResultRepository.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,49 @@
+package net.jsunit.logging;
+
+import net.jsunit.model.Browser;
+import net.jsunit.model.BrowserResult;
+import net.jsunit.model.BrowserResultBuilder;
+import net.jsunit.model.BrowserSource;
+import net.jsunit.utility.FileUtility;
+import net.jsunit.utility.XmlUtility;
+
+import java.io.File;
+
+public class FileBrowserResultRepository implements BrowserResultRepository {
+
+ private static final String LOG_PREFIX = "JSTEST-";
+
+ private File logsDirectory;
+
+ public FileBrowserResultRepository(File logsDirectory) {
+ this.logsDirectory = logsDirectory;
+ if (!logsDirectory.exists())
+ logsDirectory.mkdir();
+ }
+
+ private File logFileForId(String id, Browser browser) {
+ return new File(logsDirectory + File.separator + LOG_PREFIX + id + "." + browser.getId() + ".xml");
+ }
+
+ public void deleteDirectory(String directoryName) {
+ File file = new File(directoryName);
+ file.delete();
+ }
+
+ public void store(BrowserResult result) {
+ String xml = XmlUtility.asString(result.asXml());
+ FileUtility.write(logFileForId(result.getId(), result.getBrowser()), xml);
+ }
+
+ public BrowserResult retrieve(String id, final Browser browser) {
+ File logFile = logFileForId(id, browser);
+ if (logFile.exists())
+ return new BrowserResultBuilder(new BrowserSource() {
+ public Browser getBrowserById(int id) {
+ return browser;
+ }
+ }).build(logFile);
+ return null;
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/logging/StubBrowserResultRepository.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/logging/StubBrowserResultRepository.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/logging/StubBrowserResultRepository.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,13 @@
+package net.jsunit.logging;
+
+import net.jsunit.model.Browser;
+import net.jsunit.model.BrowserResult;
+
+public class StubBrowserResultRepository implements BrowserResultRepository {
+ public void store(BrowserResult result) {
+ }
+
+ public BrowserResult retrieve(String id, Browser browser) {
+ return null;
+ }
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/AbstractResult.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/AbstractResult.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/AbstractResult.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,54 @@
+package net.jsunit.model;
+
+import java.util.List;
+
+public abstract class AbstractResult implements Result {
+
+ public ResultType getResultType() {
+ ResultType worstResultType = ResultType.SUCCESS;
+ for (Result childResult : getChildren()) {
+ ResultType childResultType = childResult.getResultType();
+ if (childResultType.isWorseThan(worstResultType))
+ worstResultType = childResultType;
+ }
+ return worstResultType;
+ }
+
+ public int getFailureCount() {
+ int failureCount = 0;
+ for (Result childResult : getChildren())
+ failureCount += childResult.getFailureCount();
+ return failureCount;
+ }
+
+ public int getErrorCount() {
+ int errorCount = 0;
+ for (Result childResult : getChildren())
+ errorCount += childResult.getErrorCount();
+ return errorCount;
+ }
+
+ public int getTestCount() {
+ int result = 0;
+ for (Result childResult : getChildren())
+ result += childResult.getTestCount();
+ return result;
+ }
+
+ public boolean wasSuccessful() {
+ return getResultType() == ResultType.SUCCESS;
+ }
+
+ protected abstract List<? extends Result> getChildren();
+
+ public String displayString() {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("The test run had ");
+ buffer.append(getErrorCount());
+ buffer.append(" error(s) and ");
+ buffer.append(getFailureCount());
+ buffer.append(" failure(s).");
+ return buffer.toString();
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/Browser.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/Browser.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/Browser.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,60 @@
+package net.jsunit.model;
+
+import net.jsunit.utility.StringUtility;
+
+import java.util.List;
+
+public class Browser {
+
+ public static final String DEFAULT_SYSTEM_BROWSER = "default";
+
+ private String fileName;
+ private String killCommand;
+ private int id;
+
+ public Browser(String fullFileName, int id) {
+ this.id = id;
+ List<String> launchAndKill = StringUtility.listFromSemiColonDelimitedString(fullFileName);
+ this.fileName = launchAndKill.size() >= 1 ? launchAndKill.get(0) : null;
+ this.killCommand = launchAndKill.size() >= 2 ? launchAndKill.get(1) : null;
+ }
+
+ public String getFileName() {
+ return fileName;
+ }
+
+ public String getKillCommand() {
+ return killCommand;
+ }
+
+ public int getId() {
+ return id;
+ }
+
+ public boolean hasId(int anId) {
+ return id == anId;
+ }
+
+ public boolean equals(Object o) {
+ if (this == o) return true;
+ if (o == null || getClass() != o.getClass()) return false;
+
+ final Browser browser = (Browser) o;
+
+ if (id != browser.id) return false;
+ return !(fileName != null ? !fileName.equals(browser.fileName) : browser.fileName != null);
+
+ }
+
+ public int hashCode() {
+ int result;
+ result = (fileName != null ? fileName.hashCode() : 0);
+ result = 29 * result + id;
+ return result;
+ }
+
+ public boolean isDefault() {
+ return fileName.equals(DEFAULT_SYSTEM_BROWSER);
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/BrowserResult.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/BrowserResult.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/BrowserResult.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,201 @@
+package net.jsunit.model;
+
+import net.jsunit.XmlRenderable;
+import net.jsunit.utility.StringUtility;
+import org.jdom.Document;
+import org.jdom.Element;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class BrowserResult extends AbstractResult implements XmlRenderable {
+
+ private Browser browser;
+ private String remoteAddress;
+ private String id;
+ private String jsUnitVersion;
+ private String userAgent;
+ private String baseURL;
+ private double time;
+ private List<TestPageResult> testPageResults = new ArrayList<TestPageResult>();
+ private String serverSideExceptionStackTrace;
+ private ResultType resultType;
+
+ public BrowserResult() {
+ this.id = String.valueOf(System.currentTimeMillis());
+ }
+
+ public Browser getBrowser() {
+ return browser;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ if (id != null)
+ this.id = id;
+ }
+
+ public boolean hasId(String id) {
+ return this.id.equals(id);
+ }
+
+ public String getJsUnitVersion() {
+ return jsUnitVersion;
+ }
+
+ public void setJsUnitVersion(String jsUnitVersion) {
+ this.jsUnitVersion = jsUnitVersion;
+ }
+
+ public String getBaseURL() {
+ return baseURL;
+ }
+
+ public void setBaseURL(String baseURL) {
+ this.baseURL = baseURL;
+ }
+
+ public String getUserAgent() {
+ return userAgent;
+ }
+
+ public void setUserAgent(String userAgent) {
+ this.userAgent = userAgent;
+ }
+
+ public double getTime() {
+ return time;
+ }
+
+ public void setTime(double time) {
+ this.time = time;
+ }
+
+ public List<TestCaseResult> getTestCaseResults() {
+ List<TestCaseResult> result = new ArrayList<TestCaseResult>();
+ for (TestPageResult pageResult : getTestPageResults())
+ result.addAll(pageResult.getTestCaseResults());
+ return result;
+ }
+
+ public void setTestCaseStrings(String[] testCaseResultStrings) {
+ buildTestCaseResults(testCaseResultStrings);
+ }
+
+ public String getRemoteAddress() {
+ return remoteAddress;
+ }
+
+ public void setRemoteAddress(String remoteAddress) {
+ this.remoteAddress = remoteAddress;
+ }
+
+ private void buildTestCaseResults(String[] testCaseResultStrings) {
+ if (testCaseResultStrings == null)
+ return;
+ for (String testCaseResultString : testCaseResultStrings)
+ addTestCaseResult(TestCaseResult.fromString(testCaseResultString));
+ }
+
+ public Element asXml() {
+ return new BrowserResultWriter(this).asXml();
+ }
+
+ public String asXmlFragment() {
+ return new BrowserResultWriter(this).writeXmlFragment();
+ }
+
+ public void addTestCaseResult(TestCaseResult testCaseResult) {
+ String testPageName = testCaseResult.getTestPageName();
+ TestPageResult testPageResult = findTestPageResultForTestPageWithName(testPageName);
+ if (testPageResult == null) {
+ testPageResult = new TestPageResult(testPageName);
+ testPageResults.add(testPageResult);
+ }
+ testPageResult.addTestCaseResult(testCaseResult);
+ }
+
+ private TestPageResult findTestPageResultForTestPageWithName(String testPageName) {
+ for (TestPageResult testPageResult : testPageResults)
+ if (testPageResult.getTestPageName().equals(testPageName))
+ return testPageResult;
+ return null;
+ }
+
+ public ResultType getResultType() {
+ if (resultType == null)
+ return super.getResultType();
+ return resultType;
+ }
+
+ public Document asXmlDocument() {
+ return new Document(asXml());
+ }
+
+ public List<TestPageResult> getTestPageResults() {
+ return testPageResults;
+ }
+
+ public String getDisplayString() {
+ return getResultType().getDisplayString();
+ }
+
+ public boolean completedTestRun() {
+ return getResultType().completedTestRun();
+ }
+
+ public boolean timedOut() {
+ return getResultType().timedOut();
+ }
+
+ public boolean failedToLaunch() {
+ return getResultType().failedToLaunch();
+ }
+
+ public boolean externallyShutDown() {
+ return getResultType().externallyShutDown();
+ }
+
+ public void setServerSideException(Throwable throwable) {
+ serverSideExceptionStackTrace = StringUtility.stackTraceAsString(throwable);
+ }
+
+ public void setFailedToLaunch() {
+ this.resultType = ResultType.FAILED_TO_LAUNCH;
+ }
+
+ public void setTimedOut() {
+ this.resultType = ResultType.TIMED_OUT;
+ }
+
+ public void setExternallyShutDown() {
+ this.resultType = ResultType.EXTERNALLY_SHUT_DOWN;
+ }
+
+ public String getServerSideExceptionStackTrace() {
+ return serverSideExceptionStackTrace;
+ }
+
+ public void setServerSideExceptionStackTrace(String serverSideExceptionStackTrace) {
+ this.serverSideExceptionStackTrace = serverSideExceptionStackTrace;
+ }
+
+ public boolean hasServerSideExceptionStackTrace() {
+ return getServerSideExceptionStackTrace() != null;
+ }
+
+ protected List<? extends Result> getChildren() {
+ return testPageResults;
+ }
+
+ public void setBrowser(Browser browser) {
+ this.browser = browser;
+ }
+
+ public boolean isForBrowser(Browser browser) {
+ return this.browser.equals(browser);
+ }
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/BrowserResultBuilder.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/BrowserResultBuilder.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/BrowserResultBuilder.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,118 @@
+package net.jsunit.model;
+
+import net.jsunit.utility.XmlUtility;
+import org.jdom.Attribute;
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jdom.input.SAXBuilder;
+
+import java.io.File;
+import java.util.List;
+import java.util.logging.Logger;
+
+public class BrowserResultBuilder {
+
+ private Logger logger = Logger.getLogger("net.jsunit");
+ private BrowserSource browserSource;
+
+ public BrowserResultBuilder(BrowserSource browserSource) {
+ this.browserSource = browserSource;
+ }
+
+ public BrowserResult build(File file) {
+ try {
+ Document document = new SAXBuilder().build(file);
+ return build(document);
+ } catch (Exception e) {
+ logger.severe("Failed to read file " + file + ": " + e.getMessage());
+ e.printStackTrace();
+ return null;
+ }
+ }
+
+ public BrowserResult build(String string) {
+ Document document = XmlUtility.asXmlDocument(string);
+ return build(document);
+ }
+
+ @SuppressWarnings("unchecked")
+ public BrowserResult build(Document document) {
+ Element root = document.getRootElement();
+ return build(root);
+ }
+
+ @SuppressWarnings("unchecked")
+ public BrowserResult build(Element root) {
+ BrowserResult result = new BrowserResult();
+ if (failedToLaunch(root))
+ result.setFailedToLaunch();
+ else if (timedOut(root))
+ result.setTimedOut();
+ else if (externallyShutDown(root))
+ result.setExternallyShutDown();
+ updateWithHeaders(result, root);
+ updateWithProperties(root.getChild(BrowserResultWriter.PROPERTIES), result);
+ Element testCasesElement = root.getChild(BrowserResultWriter.TEST_CASES);
+ if (testCasesElement != null) {
+ List children = testCasesElement.getChildren(TestCaseResultWriter.TEST_CASE);
+ updateWithTestCaseResults(children, result);
+ }
+ return result;
+ }
+
+ private boolean failedToLaunch(Element root) {
+ Attribute failedToLaunchAttribute = root.getAttribute(BrowserResultWriter.FAILED_TO_LAUNCH);
+ return failedToLaunchAttribute != null && failedToLaunchAttribute.getValue().equals(String.valueOf(true));
+ }
+
+ private boolean timedOut(Element root) {
+ Attribute timedOutAttribute = root.getAttribute(BrowserResultWriter.TIMED_OUT);
+ return timedOutAttribute != null && timedOutAttribute.getValue().equals(String.valueOf(true));
+ }
+
+ private boolean externallyShutDown(Element root) {
+ Attribute externallyShutDownAttribute = root.getAttribute(BrowserResultWriter.EXTERNALLY_SHUT_DOWN);
+ return externallyShutDownAttribute != null && externallyShutDownAttribute.getValue().equals(String.valueOf(true));
+ }
+
+ private void updateWithHeaders(BrowserResult result, Element element) {
+ String id = element.getAttributeValue(BrowserResultWriter.ID);
+ if (id != null)
+ result.setId(id);
+ String time = element.getAttributeValue(BrowserResultWriter.TIME);
+ if (time != null)
+ result.setTime(Double.parseDouble(time));
+ }
+
+ private void updateWithProperties(Element element, BrowserResult result) {
+ for (Object child : element.getChildren()) {
+ Element next = (Element) child;
+ String key = next.getAttributeValue(BrowserResultWriter.PROPERTY_KEY);
+ String value = next.getAttributeValue(BrowserResultWriter.PROPERTY_VALUE);
+
+ if (BrowserResultWriter.JSUNIT_VERSION.equals(key))
+ result.setJsUnitVersion(value);
+ else if (BrowserResultWriter.BROWSER_ID.equals(key)) {
+ int browserId = Integer.valueOf(value);
+ Browser browser = browserSource.getBrowserById(browserId);
+ result.setBrowser(browser);
+ } else if (BrowserResultWriter.USER_AGENT.equals(key))
+ result.setUserAgent(value);
+ else if (BrowserResultWriter.REMOTE_ADDRESS.equals(key))
+ result.setRemoteAddress(value);
+ else if (BrowserResultWriter.URL.equals(key))
+ result.setBaseURL(value);
+ else if (BrowserResultWriter.SERVER_SIDE_EXCEPTION_STACK_TRACE.equals(key)) {
+ String stackTrace = next.getText();
+ result.setServerSideExceptionStackTrace(stackTrace);
+ }
+ }
+ }
+
+ private void updateWithTestCaseResults(List<Element> testCaseElements, BrowserResult result) {
+ TestCaseResultBuilder testCaseBuilder = new TestCaseResultBuilder();
+ for (Element element : testCaseElements) {
+ result.addTestCaseResult(testCaseBuilder.build(element));
+ }
+ }
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/BrowserResultWriter.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/BrowserResultWriter.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/BrowserResultWriter.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,122 @@
+package net.jsunit.model;
+
+import org.jdom.CDATA;
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jdom.output.XMLOutputter;
+
+public class BrowserResultWriter {
+
+ public static final String
+ ID = "id",
+ BROWSER_RESULT = "browserResult",
+ BROWSER_FILE_NAME = "browserFileName",
+ BROWSER_ID = "browserId",
+ USER_AGENT = "userAgent",
+ TIME = "time",
+ TEST_CASES = "testCases",
+ TEST_CASE = "testCase",
+ TIMED_OUT = "timedOut",
+ FAILED_TO_LAUNCH = "failedToLaunch",
+ EXTERNALLY_SHUT_DOWN = "externallyShutDown",
+ JSUNIT_VERSION = "jsUnitVersion",
+ REMOTE_ADDRESS = "remoteAddress",
+ SERVER_SIDE_EXCEPTION_STACK_TRACE = "serverSideExceptionStackTrace",
+ PROPERTIES = "properties",
+ PROPERTY = "property",
+ PROPERTY_KEY = "name",
+ PROPERTY_VALUE = "value",
+ URL = "url";
+
+ BrowserResult browserResult;
+
+ public BrowserResultWriter(BrowserResult result) {
+ this.browserResult = result;
+ }
+
+ public String writeXml() {
+ Element root = createRootElement();
+ Document document = new Document(root);
+ return new XMLOutputter().outputString(document);
+ }
+
+ public String writeXmlFragment() {
+ return new XMLOutputter().outputString(createRootElement());
+ }
+
+ private Element createRootElement() {
+ Element root = new Element(BROWSER_RESULT);
+ if (browserResult.timedOut())
+ root.setAttribute(TIMED_OUT, String.valueOf(true));
+ if (browserResult.failedToLaunch())
+ root.setAttribute(FAILED_TO_LAUNCH, String.valueOf(true));
+ if (browserResult.externallyShutDown())
+ root.setAttribute(EXTERNALLY_SHUT_DOWN, String.valueOf(true));
+ addPropertiesElementTo(root);
+ if (browserResult.completedTestRun()) {
+ root.setAttribute(ID, browserResult.getId());
+ root.setAttribute(TIME, String.valueOf(browserResult.getTime()));
+ addTestCasesElementTo(root);
+ }
+ return root;
+ }
+
+ private void addPropertiesElementTo(Element element) {
+ Element properties = new Element(PROPERTIES);
+ element.addContent(properties);
+
+ Browser browser = browserResult.getBrowser();
+ if (browser != null) {
+ addProperty(properties, BROWSER_FILE_NAME, browser.getFileName());
+ addProperty(properties, BROWSER_ID, String.valueOf(browserResult.getBrowser().getId()));
+ }
+ if (browserResult.completedTestRun()) {
+ addProperty(properties, JSUNIT_VERSION, browserResult.getJsUnitVersion());
+ addProperty(properties, USER_AGENT, browserResult.getUserAgent());
+ addProperty(properties, REMOTE_ADDRESS, browserResult.getRemoteAddress());
+ addProperty(properties, URL, browserResult.getBaseURL());
+ }
+ if (browserResult.hasServerSideExceptionStackTrace()) {
+ Element stackTrace = createPropertyElement(SERVER_SIDE_EXCEPTION_STACK_TRACE);
+ stackTrace.addContent(new CDATA(browserResult.getServerSideExceptionStackTrace()));
+ properties.addContent(stackTrace);
+ }
+ }
+
+ private void addProperty(Element parent, String name, String value) {
+ Element property = createPropertyElement(name);
+ property.setAttribute(PROPERTY_VALUE, value == null ? "" : value);
+ parent.addContent(property);
+ }
+
+ private Element createPropertyElement(String name) {
+ Element property = new Element(PROPERTY);
+ property.setAttribute(PROPERTY_KEY, name);
+ return property;
+ }
+
+ private void addTestCasesElementTo(Element element) {
+ Element testCasesElement = new Element(TEST_CASES);
+ for (TestCaseResult result : browserResult.getTestCaseResults()) {
+ new TestCaseResultWriter(result).addXmlTo(testCasesElement);
+ }
+ element.addContent(testCasesElement);
+ }
+
+ public String writeProblems() {
+ StringBuffer buffer = new StringBuffer();
+ for (TestCaseResult result : browserResult.getTestCaseResults()) {
+ if (!result.wasSuccessful()) {
+ if (buffer.length() > 0)
+ buffer.append("\n");
+ String problemMessage = result.getProblemSummary();
+ buffer.append(problemMessage);
+ }
+ }
+ return buffer.toString();
+ }
+
+ public Element asXml() {
+ return createRootElement();
+ }
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/BrowserSource.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/BrowserSource.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/BrowserSource.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,6 @@
+package net.jsunit.model;
+
+public interface BrowserSource {
+
+ Browser getBrowserById(int id);
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/DistributedTestRunResult.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/DistributedTestRunResult.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/DistributedTestRunResult.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,37 @@
+package net.jsunit.model;
+
+import net.jsunit.XmlRenderable;
+import org.jdom.Element;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+public class DistributedTestRunResult extends AbstractResult implements XmlRenderable {
+
+ public static final String NAME = "distributedTestRunResult";
+
+ private List<TestRunResult> testRunResults = new ArrayList<TestRunResult>();
+
+ protected List<? extends Result> getChildren() {
+ return testRunResults;
+ }
+
+ public void addTestRunResult(TestRunResult result) {
+ testRunResults.add(result);
+ Collections.sort(testRunResults);
+ }
+
+ public Element asXml() {
+ Element root = new Element(NAME);
+ root.setAttribute("type", getResultType().name());
+ for (TestRunResult testRunResult : testRunResults)
+ root.addContent(testRunResult.asXml());
+ return root;
+ }
+
+ public List<TestRunResult> getTestRunResults() {
+ return testRunResults;
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/DistributedTestRunResultBuilder.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/DistributedTestRunResultBuilder.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/DistributedTestRunResultBuilder.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,29 @@
+package net.jsunit.model;
+
+import org.jdom.Document;
+import org.jdom.Element;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class DistributedTestRunResultBuilder {
+
+ private BrowserSource browserSource;
+
+ public DistributedTestRunResultBuilder(BrowserSource browserSource) {
+ this.browserSource = browserSource;
+ }
+
+ public DistributedTestRunResult build(Document document) {
+ DistributedTestRunResult result = new DistributedTestRunResult();
+ Element root = document.getRootElement();
+ TestRunResultBuilder individualTestRunResultBuilder = new TestRunResultBuilder(browserSource);
+ for (Element testRunResultElement : new ArrayList<Element>((List<Element>) root.getChildren(TestRunResultBuilder.NAME)))
+ {
+ testRunResultElement.detach();
+ TestRunResult testRunResult = individualTestRunResultBuilder.build(new Document(testRunResultElement));
+ result.addTestRunResult(testRunResult);
+ }
+ return result;
+ }
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/Result.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/Result.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/Result.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,17 @@
+package net.jsunit.model;
+
+public interface Result {
+
+ public int getErrorCount();
+
+ public int getFailureCount();
+
+ public int getTestCount();
+
+ public ResultType getResultType();
+
+ public boolean wasSuccessful();
+
+ public String displayString();
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/ResultType.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/ResultType.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/ResultType.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,76 @@
+package net.jsunit.model;
+
+public enum ResultType {
+ UNRESPONSIVE {
+ public String getDisplayString() {
+ return "unresponsive";
+ }
+
+ },
+ FAILED_TO_LAUNCH {
+ public String getDisplayString() {
+ return "failed to launch";
+ }
+
+ public boolean failedToLaunch() {
+ return true;
+ }
+ },
+ TIMED_OUT {
+ public String getDisplayString() {
+ return "timed out";
+ }
+
+ public boolean timedOut() {
+ return true;
+ }
+ },
+ EXTERNALLY_SHUT_DOWN {
+ public String getDisplayString() {
+ return "externally shut down";
+ }
+
+ public boolean externallyShutDown() {
+ return true;
+ }
+
+ },
+ ERROR {
+ public String getDisplayString() {
+ return "error";
+ }
+ },
+ FAILURE {
+ public String getDisplayString() {
+ return "failure";
+ }
+ },
+ SUCCESS {
+ public String getDisplayString() {
+ return "success";
+ }
+ };
+
+ public abstract String getDisplayString();
+
+ public final boolean completedTestRun() {
+ return !timedOut() && !failedToLaunch() && !externallyShutDown();
+ }
+
+ public boolean timedOut() {
+ return false;
+ }
+
+ public boolean failedToLaunch() {
+ return false;
+ }
+
+ public boolean externallyShutDown() {
+ return false;
+ }
+
+ public boolean isWorseThan(ResultType other) {
+ return ordinal() < other.ordinal();
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/TestCaseResult.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/TestCaseResult.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/TestCaseResult.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,147 @@
+package net.jsunit.model;
+
+import org.jdom.Element;
+
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import java.util.List;
+import java.util.NoSuchElementException;
+import java.util.StringTokenizer;
+
+public class TestCaseResult extends AbstractResult {
+
+ public static final String TEST_PAGE_TEST_NAME_DELIMITER = ":";
+ public static final String DELIMITER = "|";
+ public static final String ERROR_INDICATOR = "E";
+ public static final String FAILURE_INDICATOR = "F";
+ private String testPageName;
+ private String name;
+ private double time;
+ private String failure, error;
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getError() {
+ return error;
+ }
+
+ public void setError(String error) {
+ this.error = error;
+ }
+
+ public String getFailure() {
+ return failure;
+ }
+
+ public void setFailure(String failure) {
+ this.failure = failure;
+ }
+
+ public double getTime() {
+ return time;
+ }
+
+ public void setTimeTaken(double time) {
+ this.time = time;
+ }
+
+ public boolean hadError() {
+ return error != null;
+ }
+
+ public boolean hadFailure() {
+ return failure != null;
+ }
+
+ public static TestCaseResult fromString(String string) {
+ TestCaseResult result = new TestCaseResult();
+ StringTokenizer toker = new StringTokenizer(string, DELIMITER);
+ try {
+ String fullyQualifiedName;
+ try {
+ fullyQualifiedName = URLDecoder.decode(toker.nextToken(), "UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ throw new RuntimeException(e);
+ }
+ result.setFullyQualifiedName(fullyQualifiedName);
+ result.setTimeTaken(Double.parseDouble(toker.nextToken()));
+ String successString = toker.nextToken();
+ if (successString.equals(ERROR_INDICATOR))
+ result.setError(toker.nextToken());
+ else if (successString.equals(FAILURE_INDICATOR))
+ result.setFailure(toker.nextToken());
+ } catch (NoSuchElementException ex) {
+ result.setError("Malformed test result: '" + string + "'.");
+ }
+ return result;
+ }
+
+ public void setFullyQualifiedName(String fullyQualifiedName) {
+ int colonIndex = fullyQualifiedName.lastIndexOf(TEST_PAGE_TEST_NAME_DELIMITER);
+ setTestPageName(fullyQualifiedName.substring(0, colonIndex));
+ setName(fullyQualifiedName.substring(colonIndex + 1));
+ }
+
+ public static TestCaseResult fromXmlElement(Element testCaseElement) {
+ return new TestCaseResultBuilder().build(testCaseElement);
+ }
+
+ public String getXmlFragment() {
+ return new TestCaseResultWriter(this).getXmlFragment();
+ }
+
+ public String getProblemSummary() {
+ return new TestCaseResultWriter(this).getProblemSummary();
+ }
+
+ public void setTestPageName(String testPageName) {
+ this.testPageName = testPageName;
+ }
+
+ public String getFullyQualifiedName() {
+ return testPageName + TEST_PAGE_TEST_NAME_DELIMITER + name;
+ }
+
+ public String getTestPageName() {
+ return testPageName;
+ }
+
+ public String toString() {
+ return getFullyQualifiedName() + ": " + getResultType().getDisplayString();
+ }
+
+ public int getErrorCount() {
+ return hadError() ? 1 : 0;
+ }
+
+ public int getFailureCount() {
+ return hadFailure() ? 1 : 0;
+ }
+
+ public int getTestCount() {
+ return 1;
+ }
+
+ protected List<? extends Result> getChildren() {
+ return null;
+ }
+
+ public boolean wasSuccessful() {
+ return !hadError() && !hadFailure();
+ }
+
+ public ResultType getResultType() {
+ if (hadError())
+ return ResultType.ERROR;
+ if (hadFailure())
+ return ResultType.FAILURE;
+ return ResultType.SUCCESS;
+ }
+
+}
\ No newline at end of file
Added: branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/TestCaseResultBuilder.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/TestCaseResultBuilder.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/TestCaseResultBuilder.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,32 @@
+package net.jsunit.model;
+
+import org.jdom.Element;
+
+public class TestCaseResultBuilder {
+
+ public TestCaseResult build(Element element) {
+ TestCaseResult result = new TestCaseResult();
+ updateWithHeaders(result, element);
+ updateWithMessage(result, element);
+ return result;
+ }
+
+ private void updateWithHeaders(TestCaseResult result, Element element) {
+ String fullyQualifiedName = element.getAttributeValue(TestCaseResultWriter.NAME);
+ result.setFullyQualifiedName(fullyQualifiedName);
+ result.setTimeTaken(Double.parseDouble(element.getAttributeValue(TestCaseResultWriter.TIME)));
+ }
+
+ private void updateWithMessage(TestCaseResult result, Element element) {
+ for (Object object : element.getChildren()) {
+ Element next = (Element) object;
+ String type = next.getName();
+ String message = next.getText();
+ if (TestCaseResultWriter.FAILURE.equals(type))
+ result.setFailure(message);
+ else if (TestCaseResultWriter.ERROR.equals(type))
+ result.setError(message);
+ }
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/TestCaseResultWriter.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/TestCaseResultWriter.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/TestCaseResultWriter.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,64 @@
+package net.jsunit.model;
+
+import org.jdom.Element;
+import org.jdom.output.XMLOutputter;
+
+public class TestCaseResultWriter {
+ public static final String
+ TEST_CASE = "testCase",
+ NAME = "name",
+ TIME = "time",
+ FAILURE = "failure",
+ ERROR = "error",
+ MESSAGE = "message";
+
+ private TestCaseResult result;
+
+ public TestCaseResultWriter(TestCaseResult result) {
+ this.result = result;
+ }
+
+ public void addXmlTo(Element element) {
+ element.addContent(createTestCaseElement());
+ }
+
+ public Element createTestCaseElement() {
+ Element testCaseElement = new Element(TEST_CASE);
+ try {
+ testCaseElement.setAttribute(NAME, result.getFullyQualifiedName().replace('\u0000', ' '));
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ testCaseElement.setAttribute(TIME, String.valueOf(result.getTime()));
+ if (result.hadFailure()) {
+ Element failureElement = new Element(FAILURE);
+ try {
+ failureElement.setText(result.getFailure().replace('\u0000', ' '));
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ testCaseElement.addContent(failureElement);
+ } else if (result.hadError()) {
+ Element errorElement = new Element(ERROR);
+ try {
+ errorElement.setText(result.getError().replace('\u0000', ' '));
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ testCaseElement.addContent(errorElement);
+ }
+ return testCaseElement;
+ }
+
+ public String getProblemSummary() {
+ if (result.hadFailure())
+ return result.getFullyQualifiedName() + " failed:\n" + result.getFailure();
+ else if (result.hadError())
+ return result.getFullyQualifiedName() + " had an error:\n" + result.getError();
+ return null;
+ }
+
+ public String getXmlFragment() {
+ return new XMLOutputter().outputString(createTestCaseElement());
+ }
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/TestPageResult.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/TestPageResult.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/TestPageResult.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,31 @@
+package net.jsunit.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class TestPageResult extends AbstractResult {
+
+ private final String testPageName;
+ private List<TestCaseResult> testCaseResults = new ArrayList<TestCaseResult>();
+
+ public TestPageResult(String testPageName) {
+ this.testPageName = testPageName;
+ }
+
+ public void addTestCaseResult(TestCaseResult testCaseResult) {
+ testCaseResults.add(testCaseResult);
+ }
+
+ public String getTestPageName() {
+ return testPageName;
+ }
+
+ public List<TestCaseResult> getTestCaseResults() {
+ return testCaseResults;
+ }
+
+ protected List<? extends Result> getChildren() {
+ return testCaseResults;
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/TestRunResult.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/TestRunResult.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/TestRunResult.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,129 @@
+package net.jsunit.model;
+
+import net.jsunit.XmlRenderable;
+import net.jsunit.utility.SystemUtility;
+import org.jdom.Element;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+public class TestRunResult extends AbstractResult implements XmlRenderable, Comparable<TestRunResult> {
+
+ private List<BrowserResult> browserResults = new ArrayList<BrowserResult>();
+ private URL url;
+ private String osString;
+ private String ipAddress;
+ private String hostname;
+ private boolean unresponsive = false;
+
+ public TestRunResult() {
+ this(null);
+ }
+
+ public TestRunResult(URL url) {
+ this.url = url;
+ }
+
+ public void addBrowserResult(BrowserResult browserResult) {
+ browserResults.add(browserResult);
+ }
+
+ public Element asXml() {
+ Element root = new Element("testRunResult");
+ root.setAttribute("type", getResultType().name());
+ if (url != null)
+ root.setAttribute("url", url.toString());
+ if (hasProperties()) {
+ Element properties = new Element("properties");
+ addProperties(properties);
+ root.addContent(properties);
+ }
+ for (BrowserResult browserResult : browserResults)
+ root.addContent(browserResult.asXml());
+ return root;
+ }
+
+ private boolean hasProperties() {
+ return osString != null || ipAddress != null || hostname != null;
+ }
+
+ private void addProperties(Element element) {
+ if (osString != null)
+ addProperty(element, "os", osString);
+ if (ipAddress != null)
+ addProperty(element, "ipAddress", ipAddress);
+ if (hostname != null)
+ addProperty(element, "hostname", hostname);
+ }
+
+ private void addProperty(Element element, String name, String value) {
+ Element property = new Element("property");
+ property.setAttribute("name", name);
+ property.setAttribute("value", value);
+ element.addContent(property);
+ }
+
+ protected List<? extends Result> getChildren() {
+ return browserResults;
+ }
+
+ public void setUnresponsive() {
+ unresponsive = true;
+ }
+
+ public boolean wasUnresponsive() {
+ return unresponsive;
+ }
+
+ public URL getUrl() {
+ return url;
+ }
+
+ public ResultType getResultType() {
+ if (unresponsive)
+ return ResultType.UNRESPONSIVE;
+ else
+ return super.getResultType();
+ }
+
+ public void setOsString(String osString) {
+ this.osString = osString;
+ }
+
+ public void setIpAddress(String ipAddress) {
+ this.ipAddress = ipAddress;
+ }
+
+ public void setHostname(String hostname) {
+ this.hostname = hostname;
+ }
+
+ public void setURL(URL url) {
+ this.url = url;
+ }
+
+ public String getOsString() {
+ return osString;
+ }
+
+ public String getIpAddress() {
+ return ipAddress;
+ }
+
+ public String getHostname() {
+ return hostname;
+ }
+
+ public int compareTo(TestRunResult other) {
+ if (url == null | other.getUrl() == null)
+ return 0;
+ return url.toString().compareTo(other.getUrl().toString());
+ }
+
+ public void initializeProperties() {
+ setOsString(SystemUtility.osString());
+ setHostname(SystemUtility.hostname());
+ setIpAddress(SystemUtility.ipAddress());
+ }
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/TestRunResultBuilder.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/TestRunResultBuilder.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/model/TestRunResultBuilder.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,50 @@
+package net.jsunit.model;
+
+import org.jdom.Document;
+import org.jdom.Element;
+
+import java.util.List;
+
+ at SuppressWarnings({"unchecked"})
+public class TestRunResultBuilder {
+
+ public static final String NAME = "testRunResult";
+
+ private BrowserSource browserSource;
+
+ public TestRunResultBuilder(BrowserSource browserSource) {
+ this.browserSource = browserSource;
+ }
+
+ public TestRunResult build(Document document) {
+ TestRunResult result = new TestRunResult();
+ Element propertiesElement = document.getRootElement().getChild("properties");
+ if (propertiesElement != null)
+ updateWithProperties(result, propertiesElement.getChildren());
+ updateWithBrowserResults(document, result);
+ return result;
+ }
+
+ private void updateWithBrowserResults(Document document, TestRunResult result) {
+ BrowserResultBuilder browserBuilder = new BrowserResultBuilder(browserSource);
+ List<Element> children = document.getRootElement().getChildren("browserResult");
+ for (Element element : children) {
+ BrowserResult browserResult = browserBuilder.build(element);
+ result.addBrowserResult(browserResult);
+ }
+ }
+
+ private void updateWithProperties(TestRunResult result, List<Element> properties) {
+ for (Element propertyElement : properties) {
+ String name = propertyElement.getAttribute("name").getValue();
+ String value = propertyElement.getAttribute("value").getValue();
+ if (name.equals("os"))
+ result.setOsString(value);
+ else if (name.equals("ipAddress"))
+ result.setIpAddress(value);
+ else if (name.equals("hostname"))
+ result.setHostname(value);
+ }
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/utility/CollectionUtility.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/utility/CollectionUtility.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/utility/CollectionUtility.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,12 @@
+package net.jsunit.utility;
+
+import java.util.Arrays;
+import java.util.List;
+
+public class CollectionUtility {
+
+ public static List listWith(Object object1, Object object2) {
+ return Arrays.asList(new Object[]{object1, object2});
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/utility/FileUtility.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/utility/FileUtility.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/utility/FileUtility.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,25 @@
+package net.jsunit.utility;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+
+public class FileUtility {
+
+ public static void delete(File file) {
+ if (file.exists())
+ file.delete();
+ }
+
+ public static void write(File file, String contents) {
+ try {
+ if (file.exists())
+ file.delete();
+ BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(file));
+ out.write(contents.getBytes());
+ out.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/utility/StreamUtility.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/utility/StreamUtility.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/utility/StreamUtility.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,18 @@
+package net.jsunit.utility;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+
+public class StreamUtility {
+
+ public static String readAllFromStream(InputStream inputStream) throws IOException {
+ ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+ int aByte;
+ while ((aByte = inputStream.read()) != -1)
+ outStream.write(aByte);
+ inputStream.close();
+ return outStream.toString();
+
+ }
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/utility/StringUtility.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/utility/StringUtility.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/utility/StringUtility.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,59 @@
+package net.jsunit.utility;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+public class StringUtility {
+
+ public static boolean isEmpty(String s) {
+ return s == null || s.trim().equals("");
+ }
+
+ public static List<String> listFromCommaDelimitedString(String string) {
+ return listFromDelimitedString(string, ",");
+ }
+
+ public static List<String> listFromSemiColonDelimitedString(String string) {
+ return listFromDelimitedString(string, ";");
+ }
+
+ private static List<String> listFromDelimitedString(String string, String delimiter) {
+ if (isEmpty(string))
+ return new ArrayList<String>();
+ String[] array = string.split(delimiter);
+ for (int i = 0; i < array.length; i++)
+ array[i] = array[i].trim();
+ return Arrays.asList(array);
+ }
+
+ public static String stackTraceAsString(Throwable throwable) {
+ StringWriter writer = new StringWriter();
+ throwable.printStackTrace(new PrintWriter(writer));
+ return writer.toString();
+ }
+
+ public static String commaSeparatedString(List<? extends Object> strings) {
+ StringBuffer result = new StringBuffer();
+ for (Iterator it = strings.iterator(); it.hasNext();) {
+ result.append(it.next());
+ if (it.hasNext())
+ result.append(",");
+ }
+ return result.toString();
+ }
+
+ public static String unqualify(String string) {
+ int indexOfForwardSlash = string.lastIndexOf("/");
+ if (indexOfForwardSlash >= 0 && indexOfForwardSlash < string.length())
+ string = string.substring(indexOfForwardSlash + 1);
+ int indexOfBackSlash = string.lastIndexOf("\\");
+ if (indexOfBackSlash >= 0 && indexOfBackSlash < string.length())
+ string = string.substring(indexOfBackSlash + 1);
+ return string;
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/utility/SystemUtility.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/utility/SystemUtility.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/utility/SystemUtility.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,53 @@
+package net.jsunit.utility;
+
+import java.net.InetAddress;
+import java.net.UnknownHostException;
+
+public class SystemUtility {
+ private static String hostname;
+
+ public static String osArchitecture() {
+ return System.getProperty("os.arch");
+ }
+
+ public static String osName() {
+ return System.getProperty("os.name");
+ }
+
+ public static String osString() {
+ StringBuffer result = new StringBuffer();
+ result.append(osArchitecture());
+ result.append(" - ");
+ result.append(osName());
+ return result.toString();
+ }
+
+ public static double jsUnitVersion() {
+ //TODO: get this from jsUnitCore.js
+ return 2.2;
+ }
+
+ public static String hostname() {
+ if (hostname == null) {
+ try {
+ InetAddress addr = InetAddress.getLocalHost();
+ hostname = addr.getCanonicalHostName();
+ } catch (UnknownHostException e) {
+ }
+ }
+ return hostname;
+ }
+
+ public static String ipAddress() {
+ try {
+ InetAddress addr = InetAddress.getLocalHost();
+ return addr.getHostAddress();
+ } catch (UnknownHostException e) {
+ return null;
+ }
+ }
+
+ public static String displayString() {
+ return hostname() + " (" + ipAddress() + "), " + osString();
+ }
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/utility/XmlUtility.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/utility/XmlUtility.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/utility/XmlUtility.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,33 @@
+package net.jsunit.utility;
+
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jdom.input.SAXBuilder;
+import org.jdom.output.Format;
+import org.jdom.output.XMLOutputter;
+
+import java.io.StringReader;
+
+public class XmlUtility {
+
+ public static String asString(Element element) {
+ return new XMLOutputter().outputString(element);
+ }
+
+ public static String asPrettyString(Element element) {
+ return new XMLOutputter(Format.getPrettyFormat()).outputString(element);
+ }
+
+ public static String asString(Document document) {
+ return new XMLOutputter().outputString(document);
+ }
+
+ public static Document asXmlDocument(String xmlDocumentString) {
+ try {
+ return new SAXBuilder().build(new StringReader(xmlDocumentString));
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/version/JsUnitWebsiteVersionGrabber.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/version/JsUnitWebsiteVersionGrabber.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/version/JsUnitWebsiteVersionGrabber.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,14 @@
+package net.jsunit.version;
+
+import net.jsunit.utility.StreamUtility;
+
+import java.net.URL;
+
+public class JsUnitWebsiteVersionGrabber implements VersionGrabber {
+
+ public double grabVersion() throws Exception {
+ URL url = new URL("http://www.jsunit.net/version.txt");
+ String string = StreamUtility.readAllFromStream(url.openStream());
+ return Double.parseDouble(string);
+ }
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/version/VersionChecker.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/version/VersionChecker.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/version/VersionChecker.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,49 @@
+package net.jsunit.version;
+
+import net.jsunit.utility.SystemUtility;
+
+public class VersionChecker {
+
+ private double installedVersion;
+ private Double latestVersion;
+ private VersionGrabber grabber;
+
+ public static VersionChecker forDefault() {
+ return new VersionChecker(SystemUtility.jsUnitVersion(), new JsUnitWebsiteVersionGrabber());
+ }
+
+ public VersionChecker(double currentVersion, VersionGrabber grabber) {
+ this.installedVersion = currentVersion;
+ this.grabber = grabber;
+ }
+
+ public boolean isUpToDate() {
+ return installedVersion >= getLatestVersion();
+ }
+
+ public double getLatestVersion() {
+ if (latestVersion == null) {
+ try {
+ latestVersion = grabber.grabVersion();
+ } catch (Exception e) {
+ latestVersion = 0d;
+ }
+ }
+ return latestVersion;
+ }
+
+ public void setLatestVersion(double version) {
+ latestVersion = version;
+ }
+
+ public String outOfDateString() {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append("*** Your JsUnit version (");
+ buffer.append(installedVersion);
+ buffer.append(") is out of date. There is a newer version available (");
+ buffer.append(getLatestVersion());
+ buffer.append(") at http://www.jsunit.net ***");
+ return buffer.toString();
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/version/VersionGrabber.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/version/VersionGrabber.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_core/net/jsunit/version/VersionGrabber.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,5 @@
+package net.jsunit.version;
+
+public interface VersionGrabber {
+ double grabVersion() throws Exception;
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/AbstractJsUnitServer.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/AbstractJsUnitServer.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/AbstractJsUnitServer.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,163 @@
+package net.jsunit;
+
+import com.opensymphony.webwork.dispatcher.ServletDispatcher;
+import com.opensymphony.xwork.config.ConfigurationManager;
+import com.opensymphony.xwork.config.providers.XmlConfigurationProvider;
+import net.jsunit.configuration.Configuration;
+import net.jsunit.configuration.ConfigurationException;
+import net.jsunit.configuration.ConfigurationProperty;
+import net.jsunit.configuration.ServerType;
+import net.jsunit.utility.XmlUtility;
+import net.jsunit.version.VersionChecker;
+import org.apache.jasper.servlet.JspServlet;
+import org.jdom.Element;
+import org.mortbay.http.HttpServer;
+import org.mortbay.http.SocketListener;
+import org.mortbay.http.handler.ResourceHandler;
+import org.mortbay.jetty.servlet.ServletHttpContext;
+import org.mortbay.start.Monitor;
+
+import java.util.Date;
+import java.util.List;
+import java.util.logging.Logger;
+
+public abstract class AbstractJsUnitServer implements JsUnitServer {
+
+ private HttpServer server;
+ private Logger logger = Logger.getLogger("net.jsunit");
+ protected Configuration configuration;
+ private final ServerType serverType;
+ private Date startDate;
+ protected int testRunCount = 0;
+
+ protected AbstractJsUnitServer(Configuration configuration, ServerType type) {
+ this.configuration = configuration;
+ this.serverType = type;
+ ensureConfigurationIsValid();
+ }
+
+ protected void ensureConfigurationIsValid() {
+ if (!configuration.isValidFor(serverType)) {
+ ConfigurationProperty property = serverType.getPropertiesInvalidFor(configuration).get(0);
+ throw new ConfigurationException(property, property.getValueString(configuration));
+ }
+ }
+
+ public boolean isFarmServer() {
+ return serverType.isFarm();
+ }
+
+ public boolean isTemporary() {
+ return serverType.isTemporary();
+ }
+
+ public Configuration getConfiguration() {
+ return configuration;
+ }
+
+ public void start() throws Exception {
+ setUpHttpServer();
+ logStatus(startingServerStatusMessage());
+ server.start();
+ startDate = new Date();
+ if (serverType.shouldPerformUpToDateCheck())
+ performUpToDateCheck();
+ }
+
+ private void performUpToDateCheck() {
+ VersionChecker checker = VersionChecker.forDefault();
+ if (!checker.isUpToDate())
+ logger.warning(checker.outOfDateString());
+ }
+
+ private String startingServerStatusMessage() {
+ return "Starting " +
+ serverTypeName() +
+ " Server with configuration:\r\n" +
+ XmlUtility.asPrettyString(configuration.asXml(serverType));
+ }
+
+ protected String serverTypeName() {
+ return serverType.getDisplayName();
+ }
+
+ private void setUpHttpServer() throws Exception {
+ server = new HttpServer();
+ SocketListener listener = new SocketListener();
+ listener.setPort(configuration.getPort());
+ server.addListener(listener);
+
+ ServletHttpContext servletContext = new ServletHttpContext();
+ servletContext.setContextPath("jsunit");
+ servletContext.setResourceBase(configuration.getResourceBase().toString());
+
+ servletContext.addServlet("JSP", "*.jsp", JspServlet.class.getName());
+ servletContext.addHandler(new ResourceHandler());
+
+ ConfigurationManager.clearConfigurationProviders();
+ ConfigurationManager.addConfigurationProvider(new XmlConfigurationProvider(xworkXmlName()));
+ com.opensymphony.webwork.config.Configuration.set("webwork.action.extension", "");
+
+ for (String servletName : servletNames())
+ addWebworkServlet(servletContext, servletName);
+ server.addContext(servletContext);
+
+ if (Monitor.activeCount() == 0)
+ Monitor.monitor();
+ }
+
+ protected abstract String xworkXmlName();
+
+ protected abstract List<String> servletNames();
+
+ private void addWebworkServlet(ServletHttpContext servletContext, String name) throws Exception {
+ servletContext.addServlet(
+ "webwork",
+ "/" + name,
+ ServletDispatcher.class.getName()
+ );
+ }
+
+ public void logStatus(String message) {
+ logger.info(message);
+ }
+
+ public Element asXml() {
+ return configuration.asXml(serverType);
+ }
+
+ public void finalize() throws Throwable {
+ super.finalize();
+ dispose();
+ }
+
+ public void dispose() {
+ logStatus("Stopping server");
+ try {
+ if (server != null)
+ server.stop();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public boolean isAlive() {
+ return server != null && server.isStarted();
+ }
+
+ public Logger getLogger() {
+ return logger;
+ }
+
+ public ServerType serverType() {
+ return serverType;
+ }
+
+ public Date getStartDate() {
+ return startDate;
+ }
+
+ public long getTestRunCount() {
+ return testRunCount;
+ }
+}
\ No newline at end of file
Added: branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/BlowingUpProcessStarter.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/BlowingUpProcessStarter.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/BlowingUpProcessStarter.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,12 @@
+package net.jsunit;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+public class BlowingUpProcessStarter implements ProcessStarter {
+
+ public Process execute(String[] command) throws IOException {
+ throw new FileNotFoundException();
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/BrowserResultLogWriter.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/BrowserResultLogWriter.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/BrowserResultLogWriter.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,32 @@
+package net.jsunit;
+
+import net.jsunit.logging.BrowserResultRepository;
+import net.jsunit.model.Browser;
+import net.jsunit.model.BrowserResult;
+
+public class BrowserResultLogWriter implements TestRunListener {
+
+ private BrowserResultRepository repository;
+
+ public BrowserResultLogWriter(BrowserResultRepository repository) {
+ this.repository = repository;
+ }
+
+ public void browserTestRunFinished(Browser browser, BrowserResult result) {
+ repository.store(result);
+ }
+
+ public void browserTestRunStarted(Browser browser) {
+ }
+
+ public boolean isReady() {
+ return true;
+ }
+
+ public void testRunStarted() {
+ }
+
+ public void testRunFinished() {
+ }
+
+}
\ No newline at end of file
Added: branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/DefaultProcessStarter.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/DefaultProcessStarter.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/DefaultProcessStarter.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,11 @@
+package net.jsunit;
+
+import java.io.IOException;
+
+public class DefaultProcessStarter implements ProcessStarter {
+
+ public Process execute(String[] command) throws IOException {
+ return Runtime.getRuntime().exec(command);
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/DistributedTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/DistributedTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/DistributedTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,107 @@
+package net.jsunit;
+
+import junit.extensions.ActiveTestSuite;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import net.jsunit.configuration.Configuration;
+import net.jsunit.configuration.ConfigurationSource;
+import net.jsunit.model.Browser;
+import net.jsunit.model.DistributedTestRunResult;
+import net.jsunit.utility.XmlUtility;
+import org.mortbay.util.MultiException;
+
+import java.net.BindException;
+import java.util.List;
+
+public class DistributedTest extends TestCase {
+
+ protected DistributedTestRunManager manager;
+ private static JsUnitStandardServer temporaryStandardServer;
+ private static Object blocker = new Object();
+ private static int serverCount = 0;
+
+ public DistributedTest(ConfigurationSource serverSource, ConfigurationSource farmSource) {
+ super(farmSource.remoteMachineURLs());
+ ensureTemporaryStandardServerIsCreated(serverSource);
+ manager = DistributedTestRunManager.forConfiguration(new Configuration(farmSource));
+ }
+
+ private void ensureTemporaryStandardServerIsCreated(ConfigurationSource serverSource) {
+ //noinspection SynchronizeOnNonFinalField
+ synchronized (blocker) {
+ if (temporaryStandardServer == null) {
+ temporaryStandardServer = new JsUnitStandardServer(new Configuration(serverSource), true);
+ }
+ }
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
+ startServerIfNecessary();
+ }
+
+ private void startServerIfNecessary() throws Exception {
+ serverCount ++;
+ //noinspection SynchronizeOnNonFinalField
+ synchronized (blocker) {
+ if (!temporaryStandardServer.isAlive()) {
+ try {
+ temporaryStandardServer.start();
+ } catch (MultiException e) {
+ if (!isMultiExceptionASingleBindException(e))
+ throw e;
+ //if a temporaryStandardServer is already running, fine -
+ //we only need it to serve content to remove machines
+ }
+ }
+ }
+ }
+
+ private boolean isMultiExceptionASingleBindException(MultiException e) {
+ List exceptions = e.getExceptions();
+ return exceptions.size() == 1 && exceptions.get(0) instanceof BindException;
+ }
+
+ public void tearDown() throws Exception {
+ serverCount --;
+ if (serverCount == 0) {
+ if (temporaryStandardServer != null && temporaryStandardServer.isAlive()) {
+ temporaryStandardServer.dispose();
+ temporaryStandardServer = null;
+ }
+ }
+ super.tearDown();
+ }
+
+ public static Test suite(ConfigurationSource source) {
+ TestSuite suite = new ActiveTestSuite();
+ new DistributedTestSuiteBuilder(source).addTestsTo(suite);
+ return suite;
+ }
+
+ public static Test suite() {
+ return suite(Configuration.resolveSource());
+ }
+
+ protected void runTest() throws Throwable {
+ manager.runTests();
+ DistributedTestRunResult result = manager.getDistributedTestRunResult();
+ temporaryStandardServer.logStatus(XmlUtility.asPrettyString(result.asXml()));
+ if (!result.wasSuccessful())
+ fail(result.displayString());
+ }
+
+ public DistributedTestRunManager getDistributedTestRunManager() {
+ return manager;
+ }
+
+ public JsUnitStandardServer getTemporaryStandardServer() {
+ return temporaryStandardServer;
+ }
+
+ public void limitToBrowser(Browser remoteBrowser) {
+ manager.limitToBrowser(remoteBrowser);
+ setName(remoteBrowser.getFileName());
+ }
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/DistributedTestRunManager.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/DistributedTestRunManager.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/DistributedTestRunManager.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,128 @@
+package net.jsunit;
+
+import net.jsunit.configuration.Configuration;
+import net.jsunit.model.*;
+import org.jdom.Document;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLEncoder;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Logger;
+
+public class DistributedTestRunManager {
+
+ private Logger logger = Logger.getLogger("net.jsunit");
+ private RemoteServerHitter hitter;
+ private Configuration configuration;
+ private String overrideURL;
+ private DistributedTestRunResult distributedTestRunResult = new DistributedTestRunResult();
+ private Browser remoteBrowser;
+
+ public static DistributedTestRunManager forConfiguration(Configuration configuration) {
+ return new DistributedTestRunManager(new RemoteMachineServerHitter(), configuration, null);
+ }
+
+ public static DistributedTestRunManager forConfigurationAndURL(RemoteServerHitter hitter, Configuration configuration, String overrideURL) {
+ return new DistributedTestRunManager(hitter, configuration, overrideURL);
+ }
+
+ protected DistributedTestRunManager(RemoteServerHitter hitter, Configuration configuration, String overrideURL) {
+ this.hitter = hitter;
+ this.configuration = configuration;
+ this.overrideURL = overrideURL;
+ }
+
+ public void runTests() {
+ List<Thread> threads = new ArrayList<Thread>();
+ for (final URL baseURL : configuration.getRemoteMachineURLs())
+ threads.add(new Thread("Run JsUnit tests on " + baseURL) {
+ public void run() {
+ runTestsOnRemoteMachine(baseURL);
+ }
+ });
+ for (Thread thread : threads)
+ thread.start();
+ for (Thread thread : threads) {
+ try {
+ thread.join();
+ } catch (InterruptedException e) {
+ throw new RuntimeException("One of the test threads was interrupted.");
+ }
+ }
+ }
+
+ private void runTestsOnRemoteMachine(URL baseURL) {
+ List<TestRunResult> results = new ArrayList<TestRunResult>();
+ try {
+ URL fullURL = buildURL(baseURL);
+ logger.info("Requesting run on remove machine URL " + baseURL);
+ Document documentFromRemoteMachine = hitter.hitURL(fullURL);
+ logger.info("Received response from remove machine URL " + baseURL);
+ if (isMultipleTestRunResultsResult(documentFromRemoteMachine)) {
+ DistributedTestRunResult multiple = new DistributedTestRunResultBuilder(configuration).build(documentFromRemoteMachine);
+ results.addAll(multiple.getTestRunResults());
+ } else {
+ TestRunResult single = new TestRunResultBuilder(configuration).build(documentFromRemoteMachine);
+ results.add(single);
+ }
+ } catch (IOException e) {
+ if (configuration.shouldIgnoreUnresponsiveRemoteMachines())
+ logger.info("Ignoring unresponsive machine " + baseURL.toString());
+ else {
+ logger.info("Remote machine URL is unresponsive: " + baseURL.toString());
+ TestRunResult unresponsiveResult = new TestRunResult(baseURL);
+ unresponsiveResult.setUnresponsive();
+ results.add(unresponsiveResult);
+ }
+ }
+ for (TestRunResult result : results) {
+ result.setURL(baseURL);
+ //noinspection SynchronizeOnNonFinalField
+ synchronized (distributedTestRunResult) {
+ distributedTestRunResult.addTestRunResult(result);
+ }
+ }
+ }
+
+ private boolean isMultipleTestRunResultsResult(Document document) {
+ return document.getRootElement().getName().equals(DistributedTestRunResult.NAME);
+ }
+
+ private URL buildURL(URL url) throws UnsupportedEncodingException, MalformedURLException {
+ String fullURLString = url.toString();
+ fullURLString += "/runner";
+ boolean hasFirstParameter = false;
+ if (overrideURL != null) {
+ fullURLString += "?url=" + URLEncoder.encode(overrideURL, "UTF-8");
+ hasFirstParameter = true;
+ } else if (configuration.getTestURL() != null) {
+ fullURLString += "?url=" + URLEncoder.encode(configuration.getTestURL().toString(), "UTF-8");
+ hasFirstParameter = true;
+ }
+ if (remoteBrowser != null) {
+ fullURLString += (hasFirstParameter ? "&" : "?");
+ fullURLString += "browserId=" + remoteBrowser.getId();
+ }
+ return new URL(fullURLString);
+ }
+
+ public DistributedTestRunResult getDistributedTestRunResult() {
+ return distributedTestRunResult;
+ }
+
+ public String getOverrideURL() {
+ return overrideURL;
+ }
+
+ public void setOverrideURL(String overrideURL) {
+ this.overrideURL = overrideURL;
+ }
+
+ public void limitToBrowser(Browser remoteBrowser) {
+ this.remoteBrowser = remoteBrowser;
+ }
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/DistributedTestSuiteBuilder.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/DistributedTestSuiteBuilder.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/DistributedTestSuiteBuilder.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,72 @@
+package net.jsunit;
+
+import junit.framework.TestSuite;
+import net.jsunit.configuration.Configuration;
+import net.jsunit.configuration.ConfigurationSource;
+import net.jsunit.configuration.DelegatingConfigurationSource;
+import net.jsunit.model.Browser;
+
+import java.net.URL;
+import java.util.List;
+
+public class DistributedTestSuiteBuilder {
+ private ConfigurationSource localeSource;
+ private RemoteServerHitter hitter;
+ private Configuration localConfiguration;
+ private int browserCount;
+
+ public DistributedTestSuiteBuilder(ConfigurationSource localSource) {
+ this(localSource, new RemoteMachineServerHitter());
+ }
+
+ public DistributedTestSuiteBuilder(ConfigurationSource localSource, RemoteServerHitter hitter) {
+ this.localeSource = localSource;
+ this.hitter = hitter;
+ this.localConfiguration = new Configuration(localeSource);
+ }
+
+ public void addTestsTo(TestSuite suite) {
+ for (final URL remoteMachineURL : localConfiguration.getRemoteMachineURLs()) {
+ ConfigurationSource remoteSource = new RemoteConfigurationSource(hitter, remoteMachineURL.toString());
+ Configuration remoteConfiguration = new Configuration(remoteSource);
+ addTestsForRemoteConfigurationTo(remoteConfiguration, remoteMachineURL, suite);
+ }
+ suite.setName("JsUnit Tests (" + getRemoteMachineURLCount() + " machines, " + getBrowserCount() + " direct browsers)");
+ }
+
+ private void addTestsForRemoteConfigurationTo(Configuration remoteConfiguration, URL remoteMachineURL, TestSuite suite) {
+ List<Browser> browsers = remoteConfiguration.getBrowsers();
+ if (browsers.isEmpty()) {
+ DistributedTest distributedTest = createDistributedTest(localeSource, remoteMachineURL);
+ suite.addTest(distributedTest);
+ } else {
+ TestSuite suiteForRemoteMachine = new TestSuite(remoteMachineURL.toString());
+ for (Browser browser : browsers) {
+ browserCount++;
+ DistributedTest distributedTest = createDistributedTest(localeSource, remoteMachineURL);
+ distributedTest.limitToBrowser(browser);
+ suiteForRemoteMachine.addTest(distributedTest);
+ }
+ suite.addTest(suiteForRemoteMachine);
+ }
+ }
+
+ private DistributedTest createDistributedTest(ConfigurationSource originalSource, final URL remoteMachineURL) {
+ return new DistributedTest(
+ originalSource,
+ new DelegatingConfigurationSource(originalSource) {
+ public String remoteMachineURLs() {
+ return remoteMachineURL.toString();
+ }
+ }
+ );
+ }
+
+ public int getRemoteMachineURLCount() {
+ return localConfiguration.getRemoteMachineURLs().size();
+ }
+
+ public int getBrowserCount() {
+ return browserCount;
+ }
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/JsUnitFarmServer.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/JsUnitFarmServer.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/JsUnitFarmServer.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,46 @@
+package net.jsunit;
+
+import net.jsunit.configuration.Configuration;
+import net.jsunit.configuration.ServerType;
+
+import java.util.Arrays;
+import java.util.List;
+
+public class JsUnitFarmServer extends AbstractJsUnitServer {
+
+ public JsUnitFarmServer(Configuration configuration) {
+ super(configuration, ServerType.FARM);
+ ServerRegistry.registerFarmServer(this);
+ }
+
+ protected List<String> servletNames() {
+ return Arrays.asList(new String[]{
+ "index",
+ "config",
+ "latestversion",
+ "runner"
+ });
+ }
+
+ public static void main(String args[]) {
+ try {
+ JsUnitFarmServer server = new JsUnitFarmServer(Configuration.resolve(args));
+ server.start();
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ }
+
+ public String toString() {
+ return "JsUnit Farm Server";
+ }
+
+ protected String xworkXmlName() {
+ return "farm_xwork.xml";
+ }
+
+ public ServerType serverType() {
+ return ServerType.FARM;
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/JsUnitServer.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/JsUnitServer.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/JsUnitServer.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,18 @@
+package net.jsunit;
+
+import net.jsunit.configuration.Configuration;
+import net.jsunit.configuration.ServerType;
+
+import java.util.Date;
+
+public interface JsUnitServer extends XmlRenderable {
+ Configuration getConfiguration();
+
+ ServerType serverType();
+
+ boolean isFarmServer();
+
+ Date getStartDate();
+
+ long getTestRunCount();
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/JsUnitStandardServer.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/JsUnitStandardServer.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/JsUnitStandardServer.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,263 @@
+package net.jsunit;
+
+import net.jsunit.configuration.Configuration;
+import net.jsunit.configuration.ServerType;
+import net.jsunit.logging.BrowserResultRepository;
+import net.jsunit.logging.FileBrowserResultRepository;
+import net.jsunit.model.Browser;
+import net.jsunit.model.BrowserResult;
+import net.jsunit.utility.StringUtility;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+public class JsUnitStandardServer extends AbstractJsUnitServer implements BrowserTestRunner {
+
+ private List<BrowserResult> results = new ArrayList<BrowserResult>();
+ private List<TestRunListener> browserTestRunListeners = new ArrayList<TestRunListener>();
+
+ private ProcessStarter processStarter = new DefaultProcessStarter();
+ private LaunchTestRunCommand launchTestRunCommand;
+ private TimeoutChecker timeoutChecker;
+ private Process browserProcess;
+ private long timeLastResultReceived;
+
+ private BrowserResultRepository browserResultRepository;
+
+ public JsUnitStandardServer(Configuration configuration, boolean temporary) {
+ this(configuration, new FileBrowserResultRepository(configuration.getLogsDirectory()), temporary);
+ }
+
+ public JsUnitStandardServer(Configuration configuration, BrowserResultRepository browserResultRepository, boolean temporary) {
+ super(configuration, temporary ? ServerType.STANDARD_TEMPORARY : ServerType.STANDARD);
+ this.browserResultRepository = browserResultRepository;
+ addBrowserTestRunListener(new BrowserResultLogWriter(browserResultRepository));
+ ServerRegistry.registerServer(this);
+ }
+
+ public static void main(String args[]) {
+ try {
+ JsUnitStandardServer server = new JsUnitStandardServer(Configuration.resolve(args), false);
+ server.start();
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ }
+
+ protected List<String> servletNames() {
+ return Arrays.asList(new String[]{
+ "acceptor",
+ "config",
+ "displayer",
+ "index",
+ "latestversion",
+ "runner"
+ });
+ }
+
+ public void accept(BrowserResult result) {
+ long timeReceived = System.currentTimeMillis();
+ if (launchTestRunCommand == null)
+ return;
+ Browser submittingBrowser = launchTestRunCommand.getBrowser();
+ endBrowser();
+
+ result.setBrowser(submittingBrowser);
+
+ killTimeoutChecker();
+ BrowserResult existingResultWithSameId = findResultWithId(result.getId(), submittingBrowser);
+ for (TestRunListener listener : browserTestRunListeners)
+ listener.browserTestRunFinished(submittingBrowser, result);
+ if (existingResultWithSameId != null)
+ results.remove(existingResultWithSameId);
+ results.add(result);
+ timeLastResultReceived = timeReceived;
+ }
+
+ private void killTimeoutChecker() {
+ if (timeoutChecker != null) {
+ timeoutChecker.die();
+ timeoutChecker = null;
+ }
+ }
+
+ public List<BrowserResult> getResults() {
+ return results;
+ }
+
+ public void clearResults() {
+ results.clear();
+ }
+
+ public BrowserResult findResultWithId(String id, int browserId) throws InvalidBrowserIdException {
+ Browser browser = configuration.getBrowserById(browserId);
+ if (browser == null)
+ throw new InvalidBrowserIdException(browserId);
+ return findResultWithId(id, browser);
+ }
+
+ private BrowserResult findResultWithId(String id, Browser browser) {
+ BrowserResult result = findResultWithIdInResultList(id, browser);
+ if (result == null)
+ result = browserResultRepository.retrieve(id, browser);
+ return result;
+ }
+
+ private BrowserResult findResultWithIdInResultList(String id, Browser browser) {
+ for (BrowserResult result : getResults()) {
+ if (result.hasId(id) && result.isForBrowser(browser))
+ return result;
+ }
+ return null;
+ }
+
+ public BrowserResult lastResult() {
+ List results = getResults();
+ return results.isEmpty()
+ ? null
+ : (BrowserResult) results.get(results.size() - 1);
+ }
+
+ public int resultsCount() {
+ return getResults().size();
+ }
+
+ public String toString() {
+ return "JsUnit Server";
+ }
+
+ public List<Browser> getBrowsers() {
+ return configuration.getBrowsers();
+ }
+
+ public boolean hasReceivedResultSince(long launchTime) {
+ return timeLastResultReceived >= launchTime;
+ }
+
+ public void addBrowserTestRunListener(TestRunListener listener) {
+ browserTestRunListeners.add(listener);
+ }
+
+ public List<TestRunListener> getBrowserTestRunListeners() {
+ return browserTestRunListeners;
+ }
+
+ private void endBrowser() {
+ if (browserProcess != null && configuration.shouldCloseBrowsersAfterTestRuns()) {
+ if (launchTestRunCommand.getBrowserKillCommand() != null) {
+ try {
+ processStarter.execute(new String[]{launchTestRunCommand.getBrowserKillCommand()});
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ } else {
+ browserProcess.destroy();
+ try {
+ browserProcess.waitFor();
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ waitUntilProcessHasExitValue(browserProcess);
+ }
+ }
+ browserProcess = null;
+ launchTestRunCommand = null;
+ killTimeoutChecker();
+ }
+
+ private void waitUntilProcessHasExitValue(Process browserProcess) {
+ while (true) {
+ try {
+ if (browserProcess != null)
+ browserProcess.exitValue();
+ return;
+ } catch (IllegalThreadStateException e) {
+ }
+ }
+ }
+
+ public long launchBrowserTestRun(BrowserLaunchSpecification launchSpec) {
+ waitUntilLastReceivedTimeHasPassed();
+ long launchTime = System.currentTimeMillis();
+ launchTestRunCommand = new LaunchTestRunCommand(launchSpec, configuration);
+ Browser browser = launchTestRunCommand.getBrowser();
+ String browserFileName = browser.getFileName();
+ try {
+ logStatus("Launching " + browserFileName + " on " + launchTestRunCommand.getTestURL());
+ for (TestRunListener listener : browserTestRunListeners)
+ listener.browserTestRunStarted(browser);
+ this.browserProcess = processStarter.execute(launchTestRunCommand.generateArray());
+ startTimeoutChecker(launchTime);
+ } catch (Throwable throwable) {
+ handleCrashWhileLaunching(throwable);
+ }
+ return launchTime;
+ }
+
+ private void handleCrashWhileLaunching(Throwable throwable) {
+ Browser browser = launchTestRunCommand.getBrowser();
+ logStatus("Browser " + browser.getFileName() + " failed to launch: " + StringUtility.stackTraceAsString(throwable));
+ BrowserResult failedToLaunchBrowserResult = new BrowserResult();
+ failedToLaunchBrowserResult.setFailedToLaunch();
+ failedToLaunchBrowserResult.setBrowser(browser);
+ failedToLaunchBrowserResult.setServerSideException(throwable);
+ accept(failedToLaunchBrowserResult);
+ }
+
+ private void waitUntilLastReceivedTimeHasPassed() {
+ while (System.currentTimeMillis() == timeLastResultReceived)
+ try {
+ Thread.sleep(1);
+ } catch (InterruptedException e) {
+ }
+ }
+
+ private void startTimeoutChecker(long launchTime) {
+ timeoutChecker = new TimeoutChecker(browserProcess, launchTestRunCommand.getBrowser(), launchTime, this);
+ timeoutChecker.start();
+ }
+
+ void setProcessStarter(ProcessStarter starter) {
+ this.processStarter = starter;
+ }
+
+ public void startTestRun() {
+ for (TestRunListener listener : browserTestRunListeners) {
+ listener.testRunStarted();
+ while (!listener.isReady())
+ try {
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ }
+ }
+ }
+
+ public void finishTestRun() {
+ for (TestRunListener listener : browserTestRunListeners)
+ listener.testRunFinished();
+ testRunCount ++;
+ }
+
+ public Process getBrowserProcess() {
+ return browserProcess;
+ }
+
+ public void dispose() {
+ super.dispose();
+ endBrowser();
+ }
+
+ protected String xworkXmlName() {
+ return "xwork.xml";
+ }
+
+ public int timeoutSeconds() {
+ return configuration.getTimeoutSeconds();
+ }
+
+ public boolean isAwaitingBrowserSubmission() {
+ return launchTestRunCommand != null;
+ }
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/LaunchTestRunCommand.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/LaunchTestRunCommand.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/LaunchTestRunCommand.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,78 @@
+package net.jsunit;
+
+import net.jsunit.configuration.Configuration;
+import net.jsunit.model.Browser;
+
+public class LaunchTestRunCommand {
+
+ private Configuration configuration;
+ private BrowserLaunchSpecification launchSpec;
+
+ public LaunchTestRunCommand(BrowserLaunchSpecification launchSpec, Configuration configuration) {
+ this.configuration = configuration;
+ this.launchSpec = launchSpec;
+ }
+
+ public Browser getBrowser() {
+ return launchSpec.getBrowser();
+ }
+
+ public String getBrowserKillCommand() {
+ String killCommand = launchSpec.getBrowser().getKillCommand();
+ if (killCommand == null && launchSpec.isForDefaultBrowser()) {
+ killCommand = PlatformType.resolve().getDefaultBrowserKillCommand();
+ }
+ return killCommand;
+ }
+
+ public String[] generateArray() throws NoUrlSpecifiedException {
+ String[] browserCommandArray = openBrowserCommandArray();
+ String[] commandWithUrl = new String[browserCommandArray.length + 1];
+ System.arraycopy(browserCommandArray, 0, commandWithUrl, 0, browserCommandArray.length);
+ commandWithUrl[browserCommandArray.length] = generateTestUrlString();
+ return commandWithUrl;
+ }
+
+ private String[] openBrowserCommandArray() {
+ if (launchSpec.isForDefaultBrowser()) {
+ PlatformType platformType = PlatformType.resolve();
+ return platformType.getDefaultCommandLineBrowserArray();
+ }
+ return new String[]{launchSpec.getBrowser().getFileName()};
+ }
+
+ private String generateTestUrlString() throws NoUrlSpecifiedException {
+ if (!launchSpec.hasOverrideUrl() && configuration.getTestURL() == null)
+ throw new NoUrlSpecifiedException();
+ String urlString = launchSpec.hasOverrideUrl() ? launchSpec.getOverrideUrl() : configuration.getTestURL().toString();
+ urlString = addAutoRunParameterIfNeeded(urlString);
+ urlString = addSubmitResultsParameterIfNeeded(urlString);
+ return urlString;
+ }
+
+ private String addSubmitResultsParameterIfNeeded(String urlString) {
+ if (urlString.toLowerCase().indexOf("submitresults") == -1)
+ urlString = addParameter(urlString, "submitResults=localhost:" + configuration.getPort() + "/jsunit/acceptor");
+ return urlString;
+ }
+
+ private String addAutoRunParameterIfNeeded(String urlString) {
+ if (urlString.toLowerCase().indexOf("autorun") == -1) {
+ urlString = addParameter(urlString, "autoRun=true");
+ }
+ return urlString;
+ }
+
+ private String addParameter(String urlString, String paramAndValue) {
+ if (urlString.indexOf("?") == -1)
+ urlString += "?";
+ else
+ urlString += "&";
+ urlString += paramAndValue;
+ return urlString;
+ }
+
+ public String getTestURL() throws NoUrlSpecifiedException {
+ return generateTestUrlString();
+ }
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/NoUrlSpecifiedException.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/NoUrlSpecifiedException.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/NoUrlSpecifiedException.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,4 @@
+package net.jsunit;
+
+public class NoUrlSpecifiedException extends Exception {
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/PlatformType.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/PlatformType.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/PlatformType.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,53 @@
+package net.jsunit;
+
+import net.jsunit.utility.SystemUtility;
+
+public enum PlatformType {
+
+ WINDOWS(new String[]{"rundll32", "url.dll,FileProtocolHandler"}, null) {
+ public boolean matchesSystem() {
+ String os = SystemUtility.osName();
+ return os != null && os.startsWith("Windows");
+ }
+ },
+ MACINTOSH(new String[]{"bin/mac/start-firefox.sh"}, "bin/mac/stop-firefox.sh") {
+ public boolean matchesSystem() {
+ String os = SystemUtility.osName();
+ return os != null && os.startsWith("Mac");
+ }
+ },
+ UNIX(new String[]{"bin/unix/start-firefox.sh"}, "bin/unix/stop-firefox.sh") {
+ public boolean matchesSystem() {
+ //TODO: uhhh...
+ return false;
+ }
+ };
+
+ public static PlatformType DEFAULT = UNIX;
+
+ private String[] defaultBrowserCommandLineArray;
+ private String defaultBrowserKillCommand;
+
+ private PlatformType(String[] defaultBrowserCommandLineArray, String defaultBrowserKillCommand) {
+ this.defaultBrowserKillCommand = defaultBrowserKillCommand;
+ this.defaultBrowserCommandLineArray = defaultBrowserCommandLineArray;
+ }
+
+ public static PlatformType resolve() {
+ for (PlatformType type : values()) {
+ if (type.matchesSystem())
+ return type;
+ }
+ return DEFAULT;
+ }
+
+ protected abstract boolean matchesSystem();
+
+ public String[] getDefaultCommandLineBrowserArray() {
+ return defaultBrowserCommandLineArray;
+ }
+
+ public String getDefaultBrowserKillCommand() {
+ return defaultBrowserKillCommand;
+ }
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/ProcessStarter.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/ProcessStarter.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/ProcessStarter.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,9 @@
+package net.jsunit;
+
+import java.io.IOException;
+
+public interface ProcessStarter {
+
+ Process execute(String[] command) throws IOException;
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/RemoteConfigurationSource.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/RemoteConfigurationSource.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/RemoteConfigurationSource.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,94 @@
+package net.jsunit;
+
+import net.jsunit.configuration.ConfigurationProperty;
+import net.jsunit.configuration.ConfigurationSource;
+import org.jdom.Document;
+import org.jdom.Element;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.Iterator;
+import java.util.List;
+import java.util.logging.Logger;
+
+public class RemoteConfigurationSource implements ConfigurationSource {
+
+ private Logger logger = Logger.getLogger("net.jsunit");
+
+ private Document document;
+
+ public RemoteConfigurationSource(RemoteServerHitter hitter, String remoteMachineURL) {
+ try {
+ document = hitter.hitURL(new URL(remoteMachineURL + "/config"));
+ } catch (IOException e) {
+ logger.severe("Could not retrieve configuration from remoteMachine URL " + remoteMachineURL);
+ }
+ }
+
+ public boolean isInitialized() {
+ return document != null;
+ }
+
+ public String browserFileNames() {
+ return commaSeparatedTextOfChildrenOfElement(ConfigurationProperty.BROWSER_FILE_NAMES);
+ }
+
+ public String closeBrowsersAfterTestRuns() {
+ return textOfElement(ConfigurationProperty.CLOSE_BROWSERS_AFTER_TEST_RUNS);
+ }
+
+ public String description() {
+ return textOfElement(ConfigurationProperty.DESCRIPTION);
+ }
+
+ public String logsDirectory() {
+ return textOfElement(ConfigurationProperty.LOGS_DIRECTORY);
+ }
+
+ public String port() {
+ return textOfElement(ConfigurationProperty.PORT);
+ }
+
+ public String remoteMachineURLs() {
+ return commaSeparatedTextOfChildrenOfElement(ConfigurationProperty.REMOTE_MACHINE_URLS);
+ }
+
+ public String resourceBase() {
+ return textOfElement(ConfigurationProperty.RESOURCE_BASE);
+ }
+
+ public String timeoutSeconds() {
+ return textOfElement(ConfigurationProperty.TIMEOUT_SECONDS);
+ }
+
+ public String url() {
+ return textOfElement(ConfigurationProperty.URL);
+ }
+
+ public String ignoreUnresponsiveRemoteMachines() {
+ return textOfElement(ConfigurationProperty.IGNORE_UNRESPONSIVE_REMOTE_MACHINES);
+ }
+
+ private String textOfElement(ConfigurationProperty property) {
+ Element element = document.getRootElement().getChild(property.getName());
+ if (element == null)
+ return "";
+ return element.getTextTrim();
+ }
+
+ private String commaSeparatedTextOfChildrenOfElement(ConfigurationProperty property) {
+ Element parent = document.getRootElement().getChild(property.getName());
+ if (parent == null)
+ return "";
+ List<Element> children = parent.getChildren();
+ StringBuffer buffer = new StringBuffer();
+ for (Iterator<Element> it = children.iterator(); it.hasNext();) {
+ Element child = it.next();
+ buffer.append(child.getTextTrim());
+ if (it.hasNext())
+ buffer.append(",");
+ }
+ return buffer.toString();
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/RemoteMachineServerHitter.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/RemoteMachineServerHitter.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/RemoteMachineServerHitter.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,23 @@
+package net.jsunit;
+
+import net.jsunit.utility.StreamUtility;
+import net.jsunit.utility.XmlUtility;
+import org.jdom.Document;
+
+import java.io.IOException;
+import java.net.URL;
+import java.net.URLConnection;
+
+public class RemoteMachineServerHitter implements RemoteServerHitter {
+
+ public Document hitURL(URL url) throws IOException {
+ String xmlResultString = submitRequestTo(url);
+ return XmlUtility.asXmlDocument(xmlResultString);
+ }
+
+ private String submitRequestTo(URL url) throws IOException {
+ URLConnection connection = url.openConnection();
+ return StreamUtility.readAllFromStream(connection.getInputStream());
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/RemoteServerHitter.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/RemoteServerHitter.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/RemoteServerHitter.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,12 @@
+package net.jsunit;
+
+import org.jdom.Document;
+
+import java.io.IOException;
+import java.net.URL;
+
+public interface RemoteServerHitter {
+
+ public Document hitURL(URL url) throws IOException;
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/ServerRegistry.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/ServerRegistry.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/ServerRegistry.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,26 @@
+package net.jsunit;
+
+public class ServerRegistry {
+ private static JsUnitStandardServer standardServer;
+ private static JsUnitFarmServer farmServer;
+
+ public static void registerServer(JsUnitStandardServer server) {
+ standardServer = server;
+ }
+
+ public static void registerFarmServer(JsUnitFarmServer server) {
+ farmServer = server;
+ }
+
+ public static JsUnitStandardServer getStandardServer() {
+ return standardServer;
+ }
+
+ public static JsUnitFarmServer getFarmServer() {
+ return farmServer;
+ }
+
+ public static JsUnitServer getServer() {
+ return standardServer != null ? standardServer : farmServer;
+ }
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/StandaloneTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/StandaloneTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/StandaloneTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,88 @@
+package net.jsunit;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import net.jsunit.configuration.Configuration;
+import net.jsunit.configuration.ConfigurationSource;
+import net.jsunit.configuration.DelegatingConfigurationSource;
+import net.jsunit.model.Browser;
+import net.jsunit.model.TestRunResult;
+import net.jsunit.utility.XmlUtility;
+
+public class StandaloneTest extends TestCase {
+
+ protected JsUnitStandardServer server;
+ private TestRunManager testRunManager;
+ private ConfigurationSource configurationSource;
+ private String overrideURL;
+
+ public StandaloneTest(String name) {
+ super(name);
+ this.configurationSource = configurationSource();
+ }
+
+ public StandaloneTest(ConfigurationSource source) {
+ super(source.browserFileNames());
+ this.configurationSource = source;
+ }
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite();
+ ConfigurationSource originalSource = Configuration.resolveSource();
+ Configuration configuration = new Configuration(originalSource);
+ for (final Browser browser : configuration.getBrowsers())
+ suite.addTest(new StandaloneTest(new DelegatingConfigurationSource(originalSource) {
+ public String browserFileNames() {
+ return browser.getFileName();
+ }
+ }));
+ return suite;
+ }
+
+ public void setUp() throws Exception {
+ super.setUp();
+ server = new JsUnitStandardServer(new Configuration(configurationSource), false);
+ server.start();
+ testRunManager = createTestRunManager();
+ }
+
+ protected ConfigurationSource configurationSource() {
+ return Configuration.resolveSource();
+ }
+
+ protected TestRunManager createTestRunManager() {
+ return new TestRunManager(server, overrideURL);
+ }
+
+ public void tearDown() throws Exception {
+ if (server != null)
+ server.dispose();
+ super.tearDown();
+ }
+
+ public void runTest() throws Exception {
+ testStandaloneRun();
+ }
+
+ public void testStandaloneRun() throws Exception {
+ testRunManager.runTests();
+ TestRunResult testRunResult = testRunManager.getTestRunResult();
+ if (!testRunResult.wasSuccessful()) {
+ StringBuffer buffer = new StringBuffer();
+ buffer.append(testRunResult.displayString());
+ buffer.append("\n");
+ String xml = XmlUtility.asPrettyString(testRunManager.getTestRunResult().asXml());
+ buffer.append(xml);
+ fail(buffer.toString());
+ }
+ }
+
+ public JsUnitStandardServer getServer() {
+ return server;
+ }
+
+ public void setOverrideURL(String url) {
+ this.overrideURL = url;
+ }
+}
\ No newline at end of file
Added: branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/TestRunManager.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/TestRunManager.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/TestRunManager.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,108 @@
+package net.jsunit;
+
+import net.jsunit.configuration.Configuration;
+import net.jsunit.model.Browser;
+import net.jsunit.model.TestRunResult;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+public class TestRunManager {
+
+ private BrowserTestRunner testRunner;
+ private TestRunResult testRunResult;
+ private final String overrideUrl;
+ private List<Browser> browsers;
+
+ public static void main(String[] args) throws Exception {
+ JsUnitStandardServer server = new JsUnitStandardServer(Configuration.resolve(args), true);
+ int port = Integer.parseInt(args[args.length - 1]);
+ if (noLogging(args))
+ shutOffAllLogging();
+ server.addBrowserTestRunListener(new TestRunNotifierServer(server, port));
+ server.start();
+ TestRunManager manager = new TestRunManager(server);
+ manager.runTests();
+ if (server.isAlive())
+ server.dispose();
+ }
+
+ private static void shutOffAllLogging() {
+ Logger.getLogger("net.jsunit").setLevel(Level.OFF);
+ Logger.getLogger("org.mortbay").setLevel(Level.OFF);
+ Logger.getLogger("com.opensymphony").setLevel(Level.OFF);
+ }
+
+ private static boolean noLogging(String[] arguments) {
+ for (String string : arguments)
+ if (string.equals("-noLogging"))
+ return true;
+ return false;
+ }
+
+ public TestRunManager(BrowserTestRunner testRunner) {
+ this(testRunner, null);
+ }
+
+ public TestRunManager(BrowserTestRunner testRunner, String overrideUrl) {
+ this.testRunner = testRunner;
+ this.overrideUrl = overrideUrl;
+ browsers = testRunner.getBrowsers();
+ }
+
+ public void runTests() {
+ initializeTestRunResult();
+ testRunner.logStatus("Starting Test Run");
+ testRunner.startTestRun();
+ try {
+ for (Browser browser : browsers) {
+ BrowserLaunchSpecification launchSpec = new BrowserLaunchSpecification(browser, overrideUrl);
+ long launchTime = testRunner.launchBrowserTestRun(launchSpec);
+ waitForResultToBeSubmitted(browser, launchTime);
+ if (testRunner.isAlive())
+ testRunResult.addBrowserResult(testRunner.lastResult());
+ else
+ return;
+ }
+ } finally {
+ testRunner.finishTestRun();
+ }
+ testRunner.logStatus("Test Run Completed");
+ }
+
+ private void initializeTestRunResult() {
+ testRunResult = new TestRunResult();
+ testRunResult.initializeProperties();
+ }
+
+ private void waitForResultToBeSubmitted(Browser browser, long launchTime) {
+ testRunner.logStatus("Waiting for " + browser.getFileName() + " to submit result");
+ long secondsWaited = 0;
+ while (testRunner.isAlive() && !testRunner.hasReceivedResultSince(launchTime)) {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ }
+ secondsWaited++;
+ if (secondsWaited > (testRunner.timeoutSeconds()) + 3)
+ throw new RuntimeException("Server not responding");
+ }
+ }
+
+ public TestRunResult getTestRunResult() {
+ return testRunResult;
+ }
+
+ public void limitToBrowserWithId(int chosenBrowserId) throws InvalidBrowserIdException {
+ Browser chosenBrowser = null;
+ for (Browser browser : browsers) {
+ if (browser.hasId(chosenBrowserId))
+ chosenBrowser = browser;
+ }
+ if (chosenBrowser == null)
+ throw new InvalidBrowserIdException(chosenBrowserId);
+ browsers = Arrays.asList(chosenBrowser);
+ }
+}
\ No newline at end of file
Added: branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/TimeoutChecker.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/TimeoutChecker.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/TimeoutChecker.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,93 @@
+package net.jsunit;
+
+import net.jsunit.model.Browser;
+import net.jsunit.model.BrowserResult;
+
+public class TimeoutChecker extends Thread {
+
+ private final BrowserTestRunner runner;
+ private long launchTime;
+ private final Browser browser;
+ private boolean alive;
+ private long checkInterval;
+ private Process browserProcess;
+
+ public TimeoutChecker(Process browserProcess, Browser browser, long launchTime, BrowserTestRunner runner) {
+ this(browserProcess, browser, launchTime, runner, 100);
+ }
+
+ public TimeoutChecker(Process browserProcess, Browser browser, long launchTime, BrowserTestRunner runner, long checkInterval) {
+ this.browser = browser;
+ this.runner = runner;
+ this.launchTime = launchTime;
+ this.checkInterval = checkInterval;
+ this.browserProcess = browserProcess;
+ alive = true;
+ }
+
+ public void run() {
+
+ while (alive && !runner.hasReceivedResultSince(launchTime)) {
+ if (waitedTooLong()) {
+ runner.logStatus("Browser " + browser.getFileName() + " timed out after " + runner.timeoutSeconds() + " seconds");
+ runner.accept(createTimedOutBrowserResult());
+ return;
+ }
+// else if (!isBrowserProcessAlive()) {
+// if (!runner.hasReceivedResultSince(launchTime)) {
+// runner.logStatus("Browser " + browserFileName + " was shutdown externally");
+// runner.accept(createExternallyShutdownBrowserResult());
+// return;
+// }
+// }
+ else
+ try {
+ Thread.sleep(checkInterval);
+ } catch (InterruptedException e) {
+ }
+ }
+ }
+
+ //TODO: finish implementing external shutdown
+ @SuppressWarnings("unused")
+ private BrowserResult createExternallyShutdownBrowserResult() {
+ BrowserResult result = createRawBrowserResult();
+ result.setExternallyShutDown();
+ return result;
+ }
+
+ private BrowserResult createTimedOutBrowserResult() {
+ BrowserResult result = createRawBrowserResult();
+ result.setTimedOut();
+ return result;
+ }
+
+ private BrowserResult createRawBrowserResult() {
+ BrowserResult result = new BrowserResult();
+ result.setBrowser(browser);
+ return result;
+ }
+
+ //TODO: finish implementing external shutdown
+ @SuppressWarnings("unused")
+ private boolean isBrowserProcessAlive() {
+ try {
+ if (browserProcess == null)
+ return false;
+ browserProcess.exitValue();
+ return false;
+ } catch (IllegalThreadStateException e) {
+ return true;
+ }
+ }
+
+ public void die() {
+ alive = false;
+ }
+
+ private boolean waitedTooLong() {
+ long secondsWaited = (System.currentTimeMillis() - launchTime) / 1000;
+ return secondsWaited > runner.timeoutSeconds();
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/BrowserResultAware.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/BrowserResultAware.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/BrowserResultAware.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,9 @@
+package net.jsunit.action;
+
+import net.jsunit.model.BrowserResult;
+
+public interface BrowserResultAware {
+
+ public void setBrowserResult(BrowserResult result);
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/BrowserTestRunnerConfigurationAction.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/BrowserTestRunnerConfigurationAction.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/BrowserTestRunnerConfigurationAction.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,13 @@
+package net.jsunit.action;
+
+import net.jsunit.XmlRenderable;
+
+public class BrowserTestRunnerConfigurationAction extends JsUnitBrowserTestRunnerAction {
+ public String execute() throws Exception {
+ return SUCCESS;
+ }
+
+ public XmlRenderable getXmlRenderable() {
+ return runner;
+ }
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/DistributedTestRunnerAction.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/DistributedTestRunnerAction.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/DistributedTestRunnerAction.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,36 @@
+package net.jsunit.action;
+
+import net.jsunit.DistributedTestRunManager;
+import net.jsunit.XmlRenderable;
+
+public class DistributedTestRunnerAction extends JsUnitFarmServerAction {
+
+ private DistributedTestRunManager manager;
+ private String overrideURL;
+
+ public String execute() throws Exception {
+ String message = "Received request to run farm tests";
+ if (overrideURL != null)
+ message += " with URL " + overrideURL;
+ server.logStatus(message);
+ //noinspection SynchronizeOnNonFinalField
+ synchronized (server) {
+ manager = DistributedTestRunManager.forConfigurationAndURL(hitter, server.getConfiguration(), overrideURL);
+ manager.runTests();
+ }
+ server.logStatus("Done running farm tests");
+ return SUCCESS;
+ }
+
+ public XmlRenderable getXmlRenderable() {
+ return manager.getDistributedTestRunResult();
+ }
+
+ public DistributedTestRunManager getTestRunManager() {
+ return manager;
+ }
+
+ public void setUrl(String overrideURL) {
+ this.overrideURL = overrideURL;
+ }
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/ErrorXmlRenderable.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/ErrorXmlRenderable.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/ErrorXmlRenderable.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,16 @@
+package net.jsunit.action;
+
+import net.jsunit.XmlRenderable;
+import org.jdom.Element;
+
+public class ErrorXmlRenderable implements XmlRenderable {
+ private String message;
+
+ public ErrorXmlRenderable(String message) {
+ this.message = message;
+ }
+
+ public Element asXml() {
+ return new Element("error").setText(message);
+ }
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/FarmServerConfigurationAction.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/FarmServerConfigurationAction.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/FarmServerConfigurationAction.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,52 @@
+package net.jsunit.action;
+
+import net.jsunit.XmlRenderable;
+import org.jdom.CDATA;
+import org.jdom.Document;
+import org.jdom.Element;
+
+import java.io.IOException;
+import java.net.URL;
+
+public class FarmServerConfigurationAction extends JsUnitFarmServerAction {
+
+ private Element result;
+
+ public String execute() throws Exception {
+ result = new Element("remoteConfigurations");
+ for (URL url : server.getConfiguration().getRemoteMachineURLs()) {
+ URL configurationURL = new URL(url.toString() + "/config");
+ Element configurationElement;
+ try {
+ Document document = hitter.hitURL(configurationURL);
+ configurationElement = document.getRootElement();
+ configurationElement.detach();
+ } catch (IOException e) {
+ configurationElement = new Element("configuration");
+ configurationElement.setAttribute("failedToConnect", String.valueOf(true));
+ configurationElement.addContent(new CDATA(e.toString()));
+ }
+
+ addRemoteConfigurationElementToResult(url, configurationElement);
+ }
+ return SUCCESS;
+ }
+
+ private void addRemoteConfigurationElementToResult(URL remoteMachineURL, Element configurationElement) {
+ Element remoteConfigurationElement = new Element("remoteConfiguration");
+ remoteConfigurationElement.setAttribute("remoteMachineURL", remoteMachineURL.toString());
+ remoteConfigurationElement.addContent(configurationElement);
+ result.addContent(remoteConfigurationElement);
+ }
+
+ public XmlRenderable getXmlRenderable() {
+ return new XmlRenderable() {
+
+ public Element asXml() {
+ return result;
+ }
+
+ };
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/IndexAction.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/IndexAction.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/IndexAction.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,9 @@
+package net.jsunit.action;
+
+import com.opensymphony.xwork.Action;
+
+public class IndexAction implements Action {
+ public String execute() throws Exception {
+ return SUCCESS;
+ }
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/JsUnitBrowserTestRunnerAction.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/JsUnitBrowserTestRunnerAction.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/JsUnitBrowserTestRunnerAction.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,18 @@
+package net.jsunit.action;
+
+import com.opensymphony.xwork.Action;
+import net.jsunit.BrowserTestRunner;
+
+public abstract class JsUnitBrowserTestRunnerAction implements Action, XmlProducer {
+
+ protected BrowserTestRunner runner;
+
+ public void setBrowserTestRunner(BrowserTestRunner runner) {
+ this.runner = runner;
+ }
+
+ public BrowserTestRunner getBrowserTestRunner() {
+ return runner;
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/JsUnitFarmServerAction.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/JsUnitFarmServerAction.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/JsUnitFarmServerAction.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,24 @@
+package net.jsunit.action;
+
+import com.opensymphony.xwork.Action;
+import net.jsunit.JsUnitFarmServer;
+import net.jsunit.RemoteServerHitter;
+
+public abstract class JsUnitFarmServerAction
+ implements Action,
+ XmlProducer,
+ RemoteRunnerHitterAware,
+ JsUnitServerAware {
+
+ protected JsUnitFarmServer server;
+ protected RemoteServerHitter hitter;
+
+ public void setFarmServer(JsUnitFarmServer server) {
+ this.server = server;
+ }
+
+ public void setRemoteRunnerHitter(RemoteServerHitter hitter) {
+ this.hitter = hitter;
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/JsUnitServerAware.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/JsUnitServerAware.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/JsUnitServerAware.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,7 @@
+package net.jsunit.action;
+
+import net.jsunit.JsUnitFarmServer;
+
+public interface JsUnitServerAware {
+ void setFarmServer(JsUnitFarmServer farmServer);
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/LatestVersionAction.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/LatestVersionAction.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/LatestVersionAction.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,26 @@
+package net.jsunit.action;
+
+import com.opensymphony.xwork.Action;
+import net.jsunit.version.VersionGrabber;
+
+public class LatestVersionAction implements Action, LatestVersionSource, VersionGrabberAware {
+ private VersionGrabber versionGrabber;
+ private double latestVersion;
+
+ public String execute() throws Exception {
+ try {
+ latestVersion = versionGrabber.grabVersion();
+ return SUCCESS;
+ } catch (Exception e) {
+ return ERROR;
+ }
+ }
+
+ public double getLatestVersion() {
+ return latestVersion;
+ }
+
+ public void setVersionGrabber(VersionGrabber versionGrabber) {
+ this.versionGrabber = versionGrabber;
+ }
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/LatestVersionResult.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/LatestVersionResult.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/LatestVersionResult.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,22 @@
+package net.jsunit.action;
+
+import com.opensymphony.webwork.ServletActionContext;
+import com.opensymphony.xwork.ActionInvocation;
+import com.opensymphony.xwork.Result;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.OutputStream;
+
+public class LatestVersionResult implements Result {
+
+ public void execute(ActionInvocation invocation) throws Exception {
+ LatestVersionSource source = (LatestVersionSource) invocation.getAction();
+ double latestVersion = source.getLatestVersion();
+ HttpServletResponse response = ServletActionContext.getResponse();
+ response.setContentType("text/xml");
+ OutputStream out = response.getOutputStream();
+ out.write(String.valueOf(latestVersion).getBytes());
+ out.close();
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/LatestVersionSource.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/LatestVersionSource.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/LatestVersionSource.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,5 @@
+package net.jsunit.action;
+
+public interface LatestVersionSource {
+ double getLatestVersion();
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/RemoteRunnerHitterAware.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/RemoteRunnerHitterAware.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/RemoteRunnerHitterAware.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,9 @@
+package net.jsunit.action;
+
+import net.jsunit.RemoteServerHitter;
+
+public interface RemoteRunnerHitterAware {
+
+ public void setRemoteRunnerHitter(RemoteServerHitter hitter);
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/RequestSourceAware.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/RequestSourceAware.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/RequestSourceAware.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,8 @@
+package net.jsunit.action;
+
+public interface RequestSourceAware {
+
+ void setRequestIPAddress(String ipAddress);
+
+ void setRequestHost(String host);
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/ResultAcceptorAction.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/ResultAcceptorAction.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/ResultAcceptorAction.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,28 @@
+package net.jsunit.action;
+
+import net.jsunit.XmlRenderable;
+import net.jsunit.model.BrowserResult;
+
+public class ResultAcceptorAction extends JsUnitBrowserTestRunnerAction implements BrowserResultAware {
+
+ protected BrowserResult result;
+
+ public String execute() throws Exception {
+ runner.logStatus("Received submission");
+ runner.accept(result);
+ return SUCCESS;
+ }
+
+ public void setBrowserResult(BrowserResult result) {
+ this.result = result;
+ }
+
+ public BrowserResult getResult() {
+ return result;
+ }
+
+ public XmlRenderable getXmlRenderable() {
+ return getResult();
+ }
+
+}
\ No newline at end of file
Added: branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/ResultDisplayerAction.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/ResultDisplayerAction.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/ResultDisplayerAction.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,47 @@
+package net.jsunit.action;
+
+import net.jsunit.InvalidBrowserIdException;
+import net.jsunit.XmlRenderable;
+import net.jsunit.model.BrowserResult;
+
+public class ResultDisplayerAction extends JsUnitBrowserTestRunnerAction {
+
+ private String id;
+ private BrowserResult result;
+ private Integer browserId;
+ private boolean browserIdInvalid;
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public void setBrowserId(Integer browserId) {
+ this.browserId = browserId;
+ }
+
+ public String execute() throws Exception {
+ if (id == null || browserId == null)
+ return ERROR;
+ try {
+ result = runner.findResultWithId(id, browserId);
+ } catch (InvalidBrowserIdException e) {
+ browserIdInvalid = true;
+ return ERROR;
+ }
+ return SUCCESS;
+ }
+
+ public XmlRenderable getXmlRenderable() {
+ if (result != null)
+ return result;
+ String message;
+ if (browserIdInvalid)
+ message = "Invalid Browser ID '" + browserId + "'";
+ else if (id != null && browserId != null)
+ message = "No Test Result has been submitted with ID '" + id + "' for browser ID '" + browserId + "'";
+ else
+ message = "A Test Result ID and a browser ID must both be given";
+ return new ErrorXmlRenderable(message);
+ }
+
+}
\ No newline at end of file
Added: branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/StandaloneTestAware.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/StandaloneTestAware.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/StandaloneTestAware.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,9 @@
+package net.jsunit.action;
+
+import net.jsunit.StandaloneTest;
+
+public interface StandaloneTestAware {
+
+ public void setStandaloneTest(StandaloneTest test);
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/TestRunnerAction.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/TestRunnerAction.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/TestRunnerAction.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,76 @@
+package net.jsunit.action;
+
+import net.jsunit.InvalidBrowserIdException;
+import net.jsunit.TestRunManager;
+import net.jsunit.XmlRenderable;
+import net.jsunit.utility.StringUtility;
+
+public class TestRunnerAction extends JsUnitBrowserTestRunnerAction implements RequestSourceAware {
+
+ private TestRunManager manager;
+ private String url;
+ private String remoteAddress;
+ private String remoteHost;
+ private String browserId;
+ private boolean badBrowserId = false;
+
+ public String execute() throws Exception {
+ runner.logStatus(requestReceivedMessage());
+ //noinspection SynchronizeOnNonFinalField
+ synchronized (runner) {
+ manager = new TestRunManager(runner, url);
+ if (!StringUtility.isEmpty(browserId)) {
+ try {
+ manager.limitToBrowserWithId(Integer.parseInt(browserId));
+ } catch (InvalidBrowserIdException e) {
+ badBrowserId = true;
+ return ERROR;
+ } catch (NumberFormatException e) {
+ badBrowserId = true;
+ return ERROR;
+ }
+ }
+ manager.runTests();
+ }
+ runner.logStatus("Done running tests");
+ return SUCCESS;
+ }
+
+ private String requestReceivedMessage() {
+ String message = "Received request to run tests";
+ if (!StringUtility.isEmpty(remoteAddress) || !StringUtility.isEmpty(remoteHost)) {
+ message += " from ";
+ if (!StringUtility.isEmpty(remoteHost)) {
+ message += remoteHost;
+ if (!StringUtility.isEmpty(remoteAddress) && !remoteAddress.equals(remoteHost))
+ message += " (" + remoteAddress + ")";
+ } else {
+ message += remoteAddress;
+ }
+ }
+ return message;
+ }
+
+ public XmlRenderable getXmlRenderable() {
+ if (badBrowserId) {
+ return new ErrorXmlRenderable("Invalid browser ID: " + browserId);
+ }
+ return manager.getTestRunResult();
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ }
+
+ public void setRequestIPAddress(String ipAddress) {
+ remoteAddress = ipAddress;
+ }
+
+ public void setRequestHost(String host) {
+ remoteHost = host;
+ }
+
+ public void setBrowserId(String browserId) {
+ this.browserId = browserId;
+ }
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/VersionGrabberAware.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/VersionGrabberAware.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/VersionGrabberAware.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,7 @@
+package net.jsunit.action;
+
+import net.jsunit.version.VersionGrabber;
+
+public interface VersionGrabberAware {
+ void setVersionGrabber(VersionGrabber versionGrabber);
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/XmlProducer.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/XmlProducer.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/XmlProducer.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,9 @@
+package net.jsunit.action;
+
+import net.jsunit.XmlRenderable;
+
+public interface XmlProducer {
+
+ public XmlRenderable getXmlRenderable();
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/XmlResult.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/XmlResult.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/action/XmlResult.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,39 @@
+package net.jsunit.action;
+
+import com.opensymphony.webwork.ServletActionContext;
+import com.opensymphony.xwork.ActionInvocation;
+import com.opensymphony.xwork.Result;
+import net.jsunit.XmlRenderable;
+import net.jsunit.utility.XmlUtility;
+import org.jdom.Document;
+import org.jdom.Element;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.BufferedOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.logging.Logger;
+
+public class XmlResult implements Result {
+
+ private Logger logger = Logger.getLogger(XmlResult.class.getName());
+
+ public void execute(ActionInvocation invocation) throws Exception {
+ XmlProducer producer = (XmlProducer) invocation.getAction();
+ XmlRenderable xmlRenderable = producer.getXmlRenderable();
+ Element element = xmlRenderable.asXml();
+ Document document = new Document(element);
+ String xmlString = XmlUtility.asString(document);
+ HttpServletResponse response = ServletActionContext.getResponse();
+ response.setContentType("text/xml");
+ try {
+ OutputStream out = response.getOutputStream();
+ BufferedOutputStream bufferedOut = new BufferedOutputStream(out);
+ bufferedOut.write(xmlString.getBytes());
+ bufferedOut.close();
+ } catch (IOException e) {
+ logger.warning("Failed to write result XML response to browser: " + e.toString());
+ }
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/interceptor/BrowserResultInterceptor.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/interceptor/BrowserResultInterceptor.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/interceptor/BrowserResultInterceptor.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,37 @@
+package net.jsunit.interceptor;
+
+import com.opensymphony.webwork.ServletActionContext;
+import com.opensymphony.xwork.Action;
+import net.jsunit.action.BrowserResultAware;
+import net.jsunit.model.BrowserResult;
+import net.jsunit.model.BrowserResultWriter;
+import net.jsunit.utility.StringUtility;
+
+import javax.servlet.http.HttpServletRequest;
+
+public class BrowserResultInterceptor extends JsUnitInterceptor {
+
+ protected void execute(Action targetAction) {
+ HttpServletRequest request = ServletActionContext.getRequest();
+ BrowserResult result = build(request);
+ BrowserResultAware aware = (BrowserResultAware) targetAction;
+ aware.setBrowserResult(result);
+ }
+
+ public BrowserResult build(HttpServletRequest request) {
+ BrowserResult result = new BrowserResult();
+ String testId = request.getParameter(BrowserResultWriter.ID);
+ if (!StringUtility.isEmpty(testId))
+ result.setId(testId);
+ result.setRemoteAddress(request.getRemoteAddr());
+ result.setUserAgent(request.getParameter(BrowserResultWriter.USER_AGENT));
+ result.setBaseURL(request.getParameter(BrowserResultWriter.URL));
+ String time = request.getParameter(BrowserResultWriter.TIME);
+ if (!StringUtility.isEmpty(time))
+ result.setTime(Double.parseDouble(time));
+ result.setJsUnitVersion(request.getParameter(BrowserResultWriter.JSUNIT_VERSION));
+ result.setTestCaseStrings(request.getParameterValues(BrowserResultWriter.TEST_CASES));
+ return result;
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/interceptor/BrowserTestRunnerInterceptor.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/interceptor/BrowserTestRunnerInterceptor.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/interceptor/BrowserTestRunnerInterceptor.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,21 @@
+package net.jsunit.interceptor;
+
+import com.opensymphony.xwork.Action;
+import net.jsunit.BrowserTestRunner;
+import net.jsunit.action.JsUnitBrowserTestRunnerAction;
+
+public class BrowserTestRunnerInterceptor extends JsUnitInterceptor {
+
+ private static BrowserTestRunnerSource source = new DefaultBrowserTestRunnerSource();
+
+ public static void setBrowserTestRunnerSource(BrowserTestRunnerSource aSource) {
+ source = aSource;
+ }
+
+ protected void execute(Action action) {
+ JsUnitBrowserTestRunnerAction jsUnitAction = ((JsUnitBrowserTestRunnerAction) action);
+ BrowserTestRunner runner = source.getRunner();
+ jsUnitAction.setBrowserTestRunner(runner);
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/interceptor/BrowserTestRunnerSource.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/interceptor/BrowserTestRunnerSource.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/interceptor/BrowserTestRunnerSource.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,9 @@
+package net.jsunit.interceptor;
+
+import net.jsunit.BrowserTestRunner;
+
+public interface BrowserTestRunnerSource {
+
+ BrowserTestRunner getRunner();
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/interceptor/DefaultBrowserTestRunnerSource.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/interceptor/DefaultBrowserTestRunnerSource.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/interceptor/DefaultBrowserTestRunnerSource.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,12 @@
+package net.jsunit.interceptor;
+
+import net.jsunit.BrowserTestRunner;
+import net.jsunit.ServerRegistry;
+
+public class DefaultBrowserTestRunnerSource implements BrowserTestRunnerSource {
+
+ public BrowserTestRunner getRunner() {
+ return ServerRegistry.getStandardServer();
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/interceptor/FarmServerInterceptor.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/interceptor/FarmServerInterceptor.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/interceptor/FarmServerInterceptor.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,14 @@
+package net.jsunit.interceptor;
+
+import com.opensymphony.xwork.Action;
+import net.jsunit.ServerRegistry;
+import net.jsunit.action.JsUnitServerAware;
+
+public class FarmServerInterceptor extends JsUnitInterceptor {
+
+ protected void execute(Action targetAction) {
+ JsUnitServerAware action = (JsUnitServerAware) targetAction;
+ action.setFarmServer(ServerRegistry.getFarmServer());
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/interceptor/JsUnitInterceptor.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/interceptor/JsUnitInterceptor.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/interceptor/JsUnitInterceptor.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,22 @@
+package net.jsunit.interceptor;
+
+import com.opensymphony.xwork.Action;
+import com.opensymphony.xwork.ActionInvocation;
+import com.opensymphony.xwork.interceptor.Interceptor;
+
+public abstract class JsUnitInterceptor implements Interceptor {
+
+ public void destroy() {
+ }
+
+ public void init() {
+ }
+
+ public String intercept(ActionInvocation invocation) throws Exception {
+ execute((Action) invocation.getAction());
+ return invocation.invoke();
+ }
+
+ protected abstract void execute(Action targetAction);
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/interceptor/RemoteRunnerHitterInterceptor.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/interceptor/RemoteRunnerHitterInterceptor.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/interceptor/RemoteRunnerHitterInterceptor.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,14 @@
+package net.jsunit.interceptor;
+
+import com.opensymphony.xwork.Action;
+import net.jsunit.RemoteMachineServerHitter;
+import net.jsunit.action.RemoteRunnerHitterAware;
+
+public class RemoteRunnerHitterInterceptor extends JsUnitInterceptor {
+
+ protected void execute(Action targetAction) {
+ RemoteRunnerHitterAware aware = ((RemoteRunnerHitterAware) targetAction);
+ aware.setRemoteRunnerHitter(new RemoteMachineServerHitter());
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/interceptor/RequestSourceInterceptor.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/interceptor/RequestSourceInterceptor.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/interceptor/RequestSourceInterceptor.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,15 @@
+package net.jsunit.interceptor;
+
+import com.opensymphony.webwork.ServletActionContext;
+import com.opensymphony.xwork.Action;
+import net.jsunit.action.RequestSourceAware;
+
+public class RequestSourceInterceptor extends JsUnitInterceptor {
+
+ protected void execute(Action targetAction) {
+ RequestSourceAware aware = ((RequestSourceAware) targetAction);
+ aware.setRequestIPAddress(ServletActionContext.getRequest().getRemoteAddr());
+ aware.setRequestHost(ServletActionContext.getRequest().getRemoteHost());
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/interceptor/VersionGrabberInterceptor.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/interceptor/VersionGrabberInterceptor.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/source_server/net/jsunit/interceptor/VersionGrabberInterceptor.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,12 @@
+package net.jsunit.interceptor;
+
+import com.opensymphony.xwork.Action;
+import net.jsunit.version.JsUnitWebsiteVersionGrabber;
+import net.jsunit.action.VersionGrabberAware;
+
+public class VersionGrabberInterceptor extends JsUnitInterceptor {
+ protected void execute(Action targetAction) {
+ VersionGrabberAware aware = ((VersionGrabberAware) targetAction);
+ aware.setVersionGrabber(new JsUnitWebsiteVersionGrabber());
+ }
+}
Added: branches/tomek/portal-dnd/jsunit/java/testlib/ashcroft.jar
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/jsunit/java/testlib/ashcroft.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/jsunit/java/testlib/httpunit-1.5.4.jar
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/jsunit/java/testlib/httpunit-1.5.4.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/jsunit/java/testlib/js-1.5R4.1.jar
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/jsunit/java/testlib/js-1.5R4.1.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/jsunit/java/testlib/jwebunit-1.2.jar
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/jsunit/java/testlib/jwebunit-1.2.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/jsunit/java/testlib/nekohtml-0.8.1.jar
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/jsunit/java/testlib/nekohtml-0.8.1.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/jsunit/java/testlib/xml-apis-1.0.b2.jar
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/jsunit/java/testlib/xml-apis-1.0.b2.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/BrowserLaunchSpecificationTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/BrowserLaunchSpecificationTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/BrowserLaunchSpecificationTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,26 @@
+package net.jsunit;
+
+import junit.framework.TestCase;
+import net.jsunit.model.Browser;
+
+public class BrowserLaunchSpecificationTest extends TestCase {
+
+ public void testNoOverride() {
+ BrowserLaunchSpecification spec = new BrowserLaunchSpecification(new Browser("mybrowser.exe", 0));
+ assertFalse(spec.hasOverrideUrl());
+ assertNull(spec.getOverrideUrl());
+
+ spec = new BrowserLaunchSpecification(new Browser("mybrowser.exe", 0), " ");
+ assertFalse(spec.hasOverrideUrl());
+ }
+
+ public void testOverride() {
+ BrowserLaunchSpecification spec = new BrowserLaunchSpecification(
+ new Browser("mybrowser.exe", 0),
+ "http://www.example.com"
+ );
+ assertTrue(spec.hasOverrideUrl());
+ assertEquals("http://www.example.com", spec.getOverrideUrl());
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/ClientServerConnectionTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/ClientServerConnectionTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/ClientServerConnectionTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,43 @@
+package net.jsunit;
+
+import junit.framework.TestCase;
+
+public class ClientServerConnectionTest extends TestCase {
+
+ private ServerSideConnection serverSideConnection;
+ private ClientSideConnection clientSideConnection;
+ private MockMessageReceiver mockReceiver1;
+ private MockMessageReceiver mockReceiver2;
+
+ public void setUp() throws Exception {
+ super.setUp();
+ mockReceiver1 = new MockMessageReceiver();
+ mockReceiver2 = new MockMessageReceiver();
+ serverSideConnection = new ServerSideConnection(mockReceiver1, 8083);
+ clientSideConnection = new ClientSideConnection(mockReceiver2, 8083);
+ clientSideConnection.start();
+ serverSideConnection.connect();
+
+ while (!serverSideConnection.isConnected() || !clientSideConnection.isRunning())
+ Thread.sleep(3);
+ }
+
+ public void tearDown() throws Exception {
+ serverSideConnection.shutDown();
+ clientSideConnection.shutdown();
+ super.tearDown();
+ }
+
+ public void testSimple() throws InterruptedException {
+ serverSideConnection.sendMessage("hello");
+ while (mockReceiver2.message == null)
+ Thread.sleep(3);
+ assertEquals("hello", mockReceiver2.message);
+
+ clientSideConnection.sendMessage("bonjour");
+ while (mockReceiver1.message == null)
+ Thread.sleep(3);
+ assertEquals("bonjour", mockReceiver1.message);
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/ClientServerInteractionTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/ClientServerInteractionTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/ClientServerInteractionTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,36 @@
+package net.jsunit;
+
+import junit.framework.TestCase;
+import net.jsunit.model.Browser;
+import net.jsunit.model.DummyBrowserSource;
+
+public class ClientServerInteractionTest extends TestCase {
+
+ private RemoteTestRunClient client;
+ private TestRunNotifierServer server;
+ private MockTestRunListener mockTestRunListener;
+
+ public void setUp() throws Exception {
+ super.setUp();
+ mockTestRunListener = new MockTestRunListener();
+ client = new RemoteTestRunClient(new DummyBrowserSource("mybrowser.exe", 4), mockTestRunListener, 8083);
+ client.startListening();
+ server = new TestRunNotifierServer(new MockBrowserTestRunner(), 8083);
+ server.testRunStarted();
+ }
+
+ public void tearDown() throws Exception {
+ server.testRunFinished();
+ client.stopListening();
+ super.tearDown();
+ }
+
+ public void testSimple() throws InterruptedException {
+
+ server.browserTestRunStarted(new Browser("mybrowser.exe", 4));
+ while (!mockTestRunListener.browserTestRunStartedCalled)
+ Thread.sleep(3);
+ assertEquals(new Browser("mybrowser.exe", 4), mockTestRunListener.browser);
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/DistributedTestRunResultTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/DistributedTestRunResultTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/DistributedTestRunResultTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,94 @@
+package net.jsunit;
+
+import junit.framework.TestCase;
+import net.jsunit.model.BrowserResult;
+import net.jsunit.model.DistributedTestRunResult;
+import net.jsunit.model.ResultType;
+import net.jsunit.model.TestRunResult;
+import net.jsunit.utility.XmlUtility;
+
+import java.net.URL;
+
+public class DistributedTestRunResultTest extends TestCase {
+
+ public void testSimple() throws Exception {
+ DistributedTestRunResult distributedResult = new DistributedTestRunResult();
+
+ TestRunResult result1 = new TestRunResult();
+ result1.addBrowserResult(successResult());
+ result1.addBrowserResult(successResult());
+ distributedResult.addTestRunResult(result1);
+
+ assertEquals(ResultType.SUCCESS, distributedResult.getResultType());
+ assertTrue(distributedResult.wasSuccessful());
+
+ TestRunResult result2 = new TestRunResult();
+ result2.addBrowserResult(failureResult());
+ result2.addBrowserResult(errorResult());
+ distributedResult.addTestRunResult(result2);
+
+ assertEquals(ResultType.ERROR, distributedResult.getResultType());
+ assertFalse(distributedResult.wasSuccessful());
+ assertEquals(1, distributedResult.getFailureCount());
+ assertEquals(1, distributedResult.getErrorCount());
+ }
+
+ public void testUnresponsiveRemoteURL() throws Exception {
+ DistributedTestRunResult distributedResult = new DistributedTestRunResult();
+
+ TestRunResult result1 = new TestRunResult();
+ result1.addBrowserResult(successResult());
+ result1.addBrowserResult(successResult());
+ distributedResult.addTestRunResult(result1);
+
+ TestRunResult result2 = new TestRunResult(new URL("http://my.domain.com:8201"));
+ result2.setUnresponsive();
+ distributedResult.addTestRunResult(result2);
+
+ TestRunResult result3 = new TestRunResult(new URL("http://my.domain.com:8201"));
+ result3.setUnresponsive();
+ distributedResult.addTestRunResult(result3);
+
+ assertEquals(ResultType.UNRESPONSIVE, distributedResult.getResultType());
+ }
+
+ public void testAsXml() throws Exception {
+ DistributedTestRunResult distributedResult = new DistributedTestRunResult();
+
+ TestRunResult result1 = new TestRunResult();
+ result1.addBrowserResult(successResult());
+ result1.addBrowserResult(successResult());
+ distributedResult.addTestRunResult(result1);
+
+ TestRunResult result2 = new TestRunResult();
+ result2.addBrowserResult(failureResult());
+ result2.addBrowserResult(errorResult());
+ distributedResult.addTestRunResult(result2);
+
+ TestRunResult result3 = new TestRunResult(new URL("http://my.domain.com:4732"));
+ result3.setUnresponsive();
+ distributedResult.addTestRunResult(result3);
+
+ assertEquals(
+ "<distributedTestRunResult type=\"UNRESPONSIVE\">" +
+ XmlUtility.asString(result1.asXml()) +
+ XmlUtility.asString(result2.asXml()) +
+ "<testRunResult type=\"UNRESPONSIVE\" url=\"http://my.domain.com:4732\" />" +
+ "</distributedTestRunResult>",
+ XmlUtility.asString(distributedResult.asXml())
+ );
+ }
+
+ private BrowserResult successResult() {
+ return new BrowserResult();
+ }
+
+ private BrowserResult failureResult() {
+ return new DummyBrowserResult(false, 1, 0);
+ }
+
+ private BrowserResult errorResult() {
+ return new DummyBrowserResult(false, 0, 1);
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/DummyBrowserResult.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/DummyBrowserResult.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/DummyBrowserResult.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,43 @@
+package net.jsunit;
+
+import net.jsunit.model.BrowserResult;
+import net.jsunit.model.ResultType;
+import org.jdom.Document;
+
+public class DummyBrowserResult extends BrowserResult {
+
+ private final boolean success;
+ private final int failureCount;
+ private final int errorCount;
+
+ public DummyBrowserResult(boolean success, int failureCount, int errorCount) {
+ this.success = success;
+ this.failureCount = failureCount;
+ this.errorCount = errorCount;
+ }
+
+ public boolean wasSuccessful() {
+ return success;
+ }
+
+ public int getFailureCount() {
+ return failureCount;
+ }
+
+ public int getErrorCount() {
+ return errorCount;
+ }
+
+ public ResultType getResultType() {
+ if (getErrorCount() > 0)
+ return ResultType.ERROR;
+ if (getFailureCount() > 0)
+ return ResultType.FAILURE;
+ return ResultType.SUCCESS;
+ }
+
+ public Document asXmlDocument() {
+ return new Document(asXml());
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/MockBrowserTestRunner.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/MockBrowserTestRunner.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/MockBrowserTestRunner.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,77 @@
+package net.jsunit;
+
+import net.jsunit.model.Browser;
+import net.jsunit.model.BrowserResult;
+import org.jdom.Element;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+public class MockBrowserTestRunner implements BrowserTestRunner {
+
+ public boolean disposeCalled;
+ public BrowserResult acceptedResult;
+ public BrowserResult resultToReturn;
+ public boolean shouldSucceed;
+ public String idPassed;
+ public Integer browserIdPassed;
+ public int timeoutSeconds;
+ public boolean hasReceivedResult;
+ public List<String> logMessages = new ArrayList<String>();
+ public List<BrowserLaunchSpecification> launchSpecs = new ArrayList<BrowserLaunchSpecification>();
+
+ public void startTestRun() {
+ }
+
+ public void finishTestRun() {
+ }
+
+ public long launchBrowserTestRun(BrowserLaunchSpecification launchSpec) {
+ launchSpecs.add(launchSpec);
+ return 0;
+ }
+
+ public void accept(BrowserResult result) {
+ this.acceptedResult = result;
+ }
+
+ public boolean hasReceivedResultSince(long launchTime) {
+ return hasReceivedResult;
+ }
+
+ public BrowserResult lastResult() {
+ return new DummyBrowserResult(shouldSucceed, shouldSucceed ? 0 : 1, 0);
+ }
+
+ public void dispose() {
+ disposeCalled = true;
+ }
+
+ public BrowserResult findResultWithId(String id, int browserId) throws InvalidBrowserIdException {
+ idPassed = id;
+ browserIdPassed = browserId;
+ return resultToReturn;
+ }
+
+ public void logStatus(String message) {
+ logMessages.add(message);
+ }
+
+ public List<Browser> getBrowsers() {
+ return Arrays.asList(new Browser[]{new Browser("mybrowser1.exe", 0), new Browser("mybrowser2.exe", 1)});
+ }
+
+ public int timeoutSeconds() {
+ return timeoutSeconds;
+ }
+
+ public Element asXml() {
+ return null;
+ }
+
+ public boolean isAlive() {
+ return true;
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/MockMessageReceiver.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/MockMessageReceiver.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/MockMessageReceiver.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,14 @@
+/**
+ *
+ */
+package net.jsunit;
+
+class MockMessageReceiver implements MessageReceiver {
+
+ public String message;
+
+ public void messageReceived(String message) {
+ this.message = message;
+ }
+
+}
\ No newline at end of file
Added: branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/MockTestRunListener.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/MockTestRunListener.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/MockTestRunListener.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,49 @@
+package net.jsunit;
+
+import net.jsunit.model.Browser;
+import net.jsunit.model.BrowserResult;
+
+public class MockTestRunListener implements TestRunListener {
+
+ public boolean testRunStartedCalled;
+ public boolean testRunFinishedCalled;
+ public boolean browserTestRunStartedCalled;
+ public boolean browserTestRunFinishedCalled;
+ public Browser browser;
+ public boolean isReady;
+ public BrowserResult result;
+
+ public void browserTestRunFinished(Browser browser, BrowserResult result) {
+ browserTestRunFinishedCalled = true;
+ this.browser = browser;
+ this.result = result;
+ }
+
+ public void browserTestRunStarted(Browser browser) {
+ browserTestRunStartedCalled = true;
+ this.browser = browser;
+ }
+
+ public boolean isReady() {
+ return isReady;
+ }
+
+ public void testRunStarted() {
+ testRunStartedCalled = true;
+ }
+
+ public void testRunFinished() {
+ testRunFinishedCalled = true;
+ }
+
+ public void reset() {
+ testRunStartedCalled = false;
+ testRunFinishedCalled = false;
+ browserTestRunStartedCalled = false;
+ browserTestRunFinishedCalled = false;
+ browser = null;
+ isReady = false;
+ result = null;
+ }
+
+}
\ No newline at end of file
Added: branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/RemoteTestRunClientTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/RemoteTestRunClientTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/RemoteTestRunClientTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,58 @@
+package net.jsunit;
+
+import junit.framework.TestCase;
+import net.jsunit.model.Browser;
+import net.jsunit.model.BrowserResult;
+import net.jsunit.model.DummyBrowserSource;
+import net.jsunit.utility.XmlUtility;
+
+public class RemoteTestRunClientTest extends TestCase {
+
+ private MockTestRunListener listener;
+ private RemoteTestRunClient client;
+
+ public void setUp() throws Exception {
+ super.setUp();
+ listener = new MockTestRunListener();
+ client = new RemoteTestRunClient(new DummyBrowserSource("mybrowser.exe", 3), listener, -1);
+ }
+
+ public void testTestRunStartedMessage() {
+ client.messageReceived("testRunStarted");
+ assertTrue(listener.testRunStartedCalled);
+ }
+
+ public void testTestRunFinishedMessage() {
+ client.messageReceived("testRunFinished");
+ assertTrue(listener.testRunFinishedCalled);
+ }
+
+ public void testBrowserTestRunStartedMessage() {
+ client.messageReceived("browserTestRunStarted");
+ client.messageReceived("3");
+ assertTrue(listener.browserTestRunStartedCalled);
+ assertEquals(new Browser("mybrowser.exe", 3), listener.browser);
+ }
+
+ public void testBrowserTestRunFinishedMessage() {
+ BrowserResult result = new BrowserResult();
+ result.setBaseURL("http://www.example.com");
+ result.setId("1234329439824");
+ result.setJsUnitVersion("905.43");
+ result.setRemoteAddress("http://123.45.67.89");
+ result.setTime(123.45);
+ result.setUserAgent("my browser version 5.6");
+ result.setTestCaseStrings(new String[]{"file:///dummy/path/dummyPage.html:testFoo|1.3|S||"});
+ client.messageReceived("browserTestRunFinished");
+ client.messageReceived("3");
+ String xml = XmlUtility.asString(result.asXmlDocument());
+ String[] lines = xml.split("\r\n");
+ for (String line : lines)
+ client.messageReceived(line);
+ client.messageReceived("endXml");
+ assertTrue(listener.browserTestRunFinishedCalled);
+ assertEquals(new Browser("mybrowser.exe", 3), listener.browser);
+ assertEquals(xml, XmlUtility.asString(listener.result.asXmlDocument()));
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/StubConfigurationSource.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/StubConfigurationSource.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/StubConfigurationSource.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,51 @@
+package net.jsunit;
+
+import net.jsunit.configuration.ConfigurationSource;
+
+public class StubConfigurationSource implements ConfigurationSource {
+
+ public String browserFileNames() {
+ return null;
+ }
+
+ public String closeBrowsersAfterTestRuns() {
+ return null;
+ }
+
+ public String description() {
+ return null;
+ }
+
+ public String logsDirectory() {
+ return null;
+ }
+
+ public String logStatus() {
+ return null;
+ }
+
+ public String port() {
+ return null;
+ }
+
+ public String remoteMachineURLs() {
+ return null;
+ }
+
+ public String resourceBase() {
+ return null;
+ }
+
+ public String timeoutSeconds() {
+ return null;
+ }
+
+ public String url() {
+ return null;
+ }
+
+ public String ignoreUnresponsiveRemoteMachines() {
+ return null;
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/TestRunNotifierServerTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/TestRunNotifierServerTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/TestRunNotifierServerTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,84 @@
+package net.jsunit;
+
+import junit.framework.TestCase;
+import net.jsunit.model.Browser;
+import net.jsunit.utility.XmlUtility;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class TestRunNotifierServerTest extends TestCase implements MessageReceiver {
+
+ private TestRunNotifierServer server;
+ private ClientSideConnection clientSideConnection;
+ private List<String> messages = new ArrayList<String>();
+ private MockBrowserTestRunner mockRunner;
+
+ public void setUp() throws Exception {
+ super.setUp();
+ mockRunner = new MockBrowserTestRunner();
+ server = new TestRunNotifierServer(mockRunner, 8083);
+ clientSideConnection = new ClientSideConnection(this, 8083);
+ new Thread() {
+ public void run() {
+ server.testRunStarted();
+ }
+ }.start();
+
+ clientSideConnection.start();
+ waitForServerConnectionToStartRunning();
+ }
+
+ public void testMessagesSentAsTestRunProceeds() throws InterruptedException {
+ while (messages.size() < 1)
+ Thread.sleep(10);
+
+ assertEquals(1, messages.size());
+ assertEquals("testRunStarted", messages.get(0));
+
+ server.browserTestRunStarted(new Browser("mybrowser1.exe", 0));
+ while (messages.size() < 3)
+ Thread.sleep(10);
+
+ assertEquals("browserTestRunStarted", messages.get(1));
+ assertEquals("0", messages.get(2));
+
+ DummyBrowserResult browserResult = new DummyBrowserResult(false, 2, 3);
+ server.browserTestRunFinished(new Browser("mybrowser2.exe", 1), browserResult);
+ while (messages.size() < 8)
+ Thread.sleep(10);
+
+ assertEquals("browserTestRunFinished", messages.get(3));
+ assertEquals("1", messages.get(4));
+ String line1 = messages.get(5);
+ String line2 = messages.get(6);
+ String line3 = messages.get(7);
+ assertEquals(XmlUtility.asString(browserResult.asXmlDocument()), line1 + "\r\n" + line2 + "\r\n" + line3);
+
+ assertEquals("endXml", messages.get(8));
+ }
+
+ public void testStopRunner() throws InterruptedException {
+ assertFalse(mockRunner.disposeCalled);
+ clientSideConnection.sendMessage("foo");
+ assertFalse(mockRunner.disposeCalled);
+ clientSideConnection.sendMessage("stop");
+ while (!mockRunner.disposeCalled)
+ Thread.sleep(10);
+ }
+
+ private void waitForServerConnectionToStartRunning() throws InterruptedException {
+ while (!clientSideConnection.isRunning() || !server.isReady())
+ Thread.sleep(10);
+ }
+
+ public void messageReceived(String message) {
+ messages.add(message);
+ }
+
+ public void tearDown() throws Exception {
+ server.testRunFinished();
+ clientSideConnection.shutdown();
+ super.tearDown();
+ }
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/TestRunResultTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/TestRunResultTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/TestRunResultTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,101 @@
+package net.jsunit;
+
+import junit.framework.TestCase;
+import net.jsunit.model.BrowserResult;
+import net.jsunit.model.ResultType;
+import net.jsunit.model.TestRunResult;
+import net.jsunit.utility.XmlUtility;
+
+import java.net.URL;
+
+public class TestRunResultTest extends TestCase {
+ private TestRunResult testRunResult;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ testRunResult = new TestRunResult(new URL("http://www.example.com"));
+ }
+
+ public void testSuccess() throws Exception {
+ testRunResult.addBrowserResult(successResult());
+ testRunResult.addBrowserResult(successResult());
+ assertTrue(testRunResult.wasSuccessful());
+ assertEquals(0, testRunResult.getErrorCount());
+ assertEquals(0, testRunResult.getFailureCount());
+ assertFalse(testRunResult.wasUnresponsive());
+ }
+
+ public void testFailuresAndErrors() throws Exception {
+ testRunResult.addBrowserResult(failureResult());
+ assertFalse(testRunResult.wasSuccessful());
+ assertEquals(0, testRunResult.getErrorCount());
+ assertEquals(1, testRunResult.getFailureCount());
+
+ testRunResult.addBrowserResult(failureResult());
+ assertFalse(testRunResult.wasSuccessful());
+ assertEquals(0, testRunResult.getErrorCount());
+ assertEquals(2, testRunResult.getFailureCount());
+
+ testRunResult.addBrowserResult(errorResult());
+ assertFalse(testRunResult.wasSuccessful());
+ assertEquals(1, testRunResult.getErrorCount());
+ assertEquals(2, testRunResult.getFailureCount());
+ }
+
+ public void testAsXml() throws Exception {
+ testRunResult.addBrowserResult(successResult());
+ testRunResult.addBrowserResult(failureResult());
+ testRunResult.addBrowserResult(errorResult());
+ testRunResult.setOsString("my cool os");
+ testRunResult.setIpAddress("127.0.0.1");
+ testRunResult.setHostname("machine.example.com");
+ testRunResult.setURL(new URL("http://www.example.com"));
+ assertEquals(
+ "<testRunResult type=\"ERROR\" url=\"http://www.example.com\">" +
+ "<properties>" +
+ "<property name=\"os\" value=\"my cool os\" />" +
+ "<property name=\"ipAddress\" value=\"127.0.0.1\" />" +
+ "<property name=\"hostname\" value=\"machine.example.com\" />" +
+ "</properties>" +
+ successResult().asXmlFragment() +
+ failureResult().asXmlFragment() +
+ errorResult().asXmlFragment() +
+ "</testRunResult>",
+ XmlUtility.asString(testRunResult.asXml())
+ );
+ }
+
+ public void testUnresponsive() throws Exception {
+ testRunResult.setUnresponsive();
+ assertTrue(testRunResult.wasUnresponsive());
+ assertEquals(ResultType.UNRESPONSIVE, testRunResult.getResultType());
+ assertEquals(
+ "<testRunResult type=\"UNRESPONSIVE\" url=\"http://www.example.com\" />",
+ XmlUtility.asString(testRunResult.asXml())
+ );
+ }
+
+ public void testAsXmlWithNoUrl() throws Exception {
+ TestRunResult result = new TestRunResult();
+ assertEquals("<testRunResult type=\"SUCCESS\" />", XmlUtility.asString(result.asXml()));
+ }
+
+ private BrowserResult successResult() {
+ BrowserResult browserResult = new BrowserResult();
+ browserResult.setId("foo");
+ return browserResult;
+ }
+
+ private BrowserResult failureResult() {
+ DummyBrowserResult dummyBrowserResult = new DummyBrowserResult(false, 1, 0);
+ dummyBrowserResult.setId("foo");
+ return dummyBrowserResult;
+ }
+
+ private BrowserResult errorResult() {
+ DummyBrowserResult dummyBrowserResult = new DummyBrowserResult(false, 0, 1);
+ dummyBrowserResult.setId("foo");
+ return dummyBrowserResult;
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/configuration/ArgumentsConfigurationSourceTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/configuration/ArgumentsConfigurationSourceTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/configuration/ArgumentsConfigurationSourceTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,59 @@
+package net.jsunit.configuration;
+
+import junit.framework.TestCase;
+
+import java.util.Arrays;
+import java.util.List;
+
+public class ArgumentsConfigurationSourceTest extends TestCase {
+ public ArgumentsConfigurationSourceTest(String name) {
+ super(name);
+ }
+
+ public void testSimple() throws Exception {
+ List<String> args = Arrays.asList(new String[]{
+ "-browserFileNames", "aaa",
+ "-closeBrowsersAfterTestRuns", "bbb",
+ "-logsDirectory", "ccc",
+ "-logStatus", "ddd",
+ "-port", "eee",
+ "-remoteMachineURLs", "fff",
+ "-resourceBase", "ggg",
+ "-timeoutSeconds", "hhh",
+ "-url", "iii",
+ });
+ ArgumentsConfigurationSource source = new ArgumentsConfigurationSource(args);
+ assertEquals("aaa", source.browserFileNames());
+ assertEquals("bbb", source.closeBrowsersAfterTestRuns());
+ assertEquals("ccc", source.logsDirectory());
+ assertEquals("eee", source.port());
+ assertEquals("fff", source.remoteMachineURLs());
+ assertEquals("ggg", source.resourceBase());
+ assertEquals("hhh", source.timeoutSeconds());
+ assertEquals("iii", source.url());
+ }
+
+ public void testIncomplete() {
+ List<String> args = Arrays.asList(new String[]{
+ "-browserFileNames",
+ "-closeBrowsersAfterTestRuns",
+ "-logsDirectory", "ccc",
+ "-logStatus", "ddd",
+ "-port", "eee",
+ "-remoteMachineURLs",
+ "-resourceBase", "ggg",
+ "-timeoutSeconds", "hhh",
+ "-url", "iii",
+ });
+ ArgumentsConfigurationSource source = new ArgumentsConfigurationSource(args);
+ assertEquals("", source.browserFileNames());
+ assertEquals("", source.closeBrowsersAfterTestRuns());
+ assertEquals("ccc", source.logsDirectory());
+ assertEquals("eee", source.port());
+ assertEquals("", source.remoteMachineURLs());
+ assertEquals("ggg", source.resourceBase());
+ assertEquals("hhh", source.timeoutSeconds());
+ assertEquals("iii", source.url());
+ }
+
+}
\ No newline at end of file
Added: branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/configuration/CompositeConfigurationSourceTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/configuration/CompositeConfigurationSourceTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/configuration/CompositeConfigurationSourceTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,38 @@
+package net.jsunit.configuration;
+
+import junit.framework.TestCase;
+import net.jsunit.StubConfigurationSource;
+
+import java.io.FileNotFoundException;
+
+public class CompositeConfigurationSourceTest extends TestCase {
+
+ public void testSingleSource() throws FileNotFoundException {
+ CompositeConfigurationSource compositeSource = new CompositeConfigurationSource(new Source1());
+ assertEquals("foo", compositeSource.url());
+ }
+
+ public void testPrecedence() {
+ CompositeConfigurationSource compositeSource = new CompositeConfigurationSource(
+ new Source1(),
+ new Source2());
+ assertEquals("foo", compositeSource.url());
+ assertEquals("1234", compositeSource.port());
+ }
+
+ public static class Source1 extends StubConfigurationSource {
+ public String url() {
+ return "foo";
+ }
+ }
+
+ public static class Source2 extends StubConfigurationSource {
+ public String url() {
+ return "bar";
+ }
+
+ public String port() {
+ return "1234";
+ }
+ }
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/configuration/ConfigurationSourceResolutionTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/configuration/ConfigurationSourceResolutionTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/configuration/ConfigurationSourceResolutionTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,38 @@
+package net.jsunit.configuration;
+
+import junit.framework.TestCase;
+import net.jsunit.utility.FileUtility;
+
+import java.io.File;
+
+public class ConfigurationSourceResolutionTest extends TestCase {
+
+ public void testResolveArgumentsConfiguration() {
+ ConfigurationSource source = Configuration.resolveSource(new String[]{"-url", "foo"});
+ assertEquals("foo", source.url());
+ }
+
+ public void testResolveEnvironmentVariablesConfiguration() {
+ System.setProperty(ConfigurationProperty.URL.getName(), "http://localhost:8080/");
+ ConfigurationSource source = Configuration.resolveSource(new String[]{});
+ assertEquals("http://localhost:8080/", source.url());
+ }
+
+ public void testResolvePropertiesConfiguration() {
+ writePropertiesFile(PropertiesFileConfigurationSource.PROPERTIES_FILE_NAME,
+ ConfigurationProperty.BROWSER_FILE_NAMES.getName() + "=aaa");
+ ConfigurationSource source = Configuration.resolveSource(new String[]{});
+ assertEquals("aaa", source.browserFileNames());
+ }
+
+ private void writePropertiesFile(String fileName, String contents) {
+ FileUtility.write(new File(fileName), contents);
+ }
+
+ protected void tearDown() throws Exception {
+ System.getProperties().remove(ConfigurationProperty.URL.getName());
+ FileUtility.delete(new File(PropertiesFileConfigurationSource.PROPERTIES_FILE_NAME));
+ super.tearDown();
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/configuration/ConfigurationTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/configuration/ConfigurationTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/configuration/ConfigurationTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,315 @@
+package net.jsunit.configuration;
+
+import junit.framework.TestCase;
+import net.jsunit.StubConfigurationSource;
+import net.jsunit.model.Browser;
+import net.jsunit.utility.SystemUtility;
+import net.jsunit.utility.XmlUtility;
+
+import java.io.File;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+public class ConfigurationTest extends TestCase {
+
+ public void testFull() throws Exception {
+ Configuration configuration = new Configuration(new FullValidForBothConfigurationSource());
+ List<Browser> expectedBrowsers = new ArrayList<Browser>();
+ expectedBrowsers.add(new Browser("browser1.exe", 0));
+ expectedBrowsers.add(new Browser("browser2.exe", 1));
+ assertEquals(expectedBrowsers, configuration.getBrowsers());
+ assertEquals(new File("logs" + File.separator + "directory"), configuration.getLogsDirectory());
+ assertEquals(1234, configuration.getPort());
+ assertEquals(new File("resource" + File.separator + "base"), configuration.getResourceBase());
+ assertEquals("http://www.example.com:1234/", configuration.getTestURL().toString());
+ assertTrue(configuration.shouldCloseBrowsersAfterTestRuns());
+ assertEquals(76, configuration.getTimeoutSeconds());
+ List<URL> expectedRemoteMachineURLs = new ArrayList<URL>();
+ expectedRemoteMachineURLs.add(new URL("http://localhost:8081/jsunit"));
+ expectedRemoteMachineURLs.add(new URL("http://127.0.0.1:8082/jsunit"));
+ assertEquals(expectedRemoteMachineURLs, configuration.getRemoteMachineURLs());
+ assertTrue(configuration.shouldIgnoreUnresponsiveRemoteMachines());
+
+ assertTrue(configuration.isValidFor(ServerType.STANDARD));
+ assertTrue(configuration.isValidFor(ServerType.FARM));
+ }
+
+ public void testMinimal() throws Exception {
+ Configuration configuration = new Configuration(new MinimalValidForBothConfigurationSource());
+ assertEquals(new File("."), configuration.getResourceBase());
+ assertEquals(new File("logs"), configuration.getLogsDirectory());
+ assertTrue(configuration.shouldCloseBrowsersAfterTestRuns());
+ assertEquals(60, configuration.getTimeoutSeconds());
+ assertFalse(configuration.shouldIgnoreUnresponsiveRemoteMachines());
+
+ assertTrue(configuration.isValidFor(ServerType.STANDARD));
+ assertTrue(configuration.isValidFor(ServerType.FARM));
+ }
+
+ public void testBadRemoteMachineURLs() throws Exception {
+ try {
+ new Configuration(new StubConfigurationSource() {
+ public String remoteMachineURLs() {
+ return "invalid url";
+ }
+ });
+ fail();
+ } catch (ConfigurationException e) {
+ }
+ }
+
+ public void testBadURL() throws Exception {
+ try {
+ new Configuration(new StubConfigurationSource() {
+ public String url() {
+ return "invalid url";
+ }
+ });
+ fail();
+ } catch (ConfigurationException e) {
+ }
+ }
+
+ public void testBadPort() throws Exception {
+ try {
+ new Configuration(new StubConfigurationSource() {
+ public String port() {
+ return "invalid number";
+ }
+ });
+ fail();
+ } catch (ConfigurationException e) {
+ }
+ }
+
+ public void testBadTimeoutSeconds() throws Exception {
+ try {
+ new Configuration(new StubConfigurationSource() {
+ public String timeoutSeconds() {
+ return "invalid number";
+ }
+ });
+ fail();
+ } catch (ConfigurationException e) {
+ }
+ }
+
+ public void testValidForStandardInvalidForFarm() throws Exception {
+ Configuration configuration = new Configuration(new ValidForStandardInvalidForFarmConfigurationSource());
+ assertTrue(configuration.isValidFor(ServerType.STANDARD));
+ assertFalse(configuration.isValidFor(ServerType.FARM));
+ List<ConfigurationProperty> invalidProperties = ServerType.FARM.getPropertiesInvalidFor(configuration);
+ assertEquals(1, invalidProperties.size());
+ assertEquals(ConfigurationProperty.REMOTE_MACHINE_URLS, invalidProperties.get(0));
+ }
+
+ public void testAsXmlForStandardConfiguration() throws Exception {
+ FullValidForBothConfigurationSource source = new FullValidForBothConfigurationSource();
+ Configuration configuration = new Configuration(source);
+ File logsDirectory = new File(source.logsDirectory());
+ File resourceBase = new File(source.resourceBase());
+ String expectedXML = "<configuration type=\"" + ServerType.STANDARD.name() + "\">" +
+ "<os>" + SystemUtility.osString() + "</os>" +
+ "<ipAddress>" + SystemUtility.ipAddress() + "</ipAddress>" +
+ "<hostname>" + SystemUtility.hostname() + "</hostname>" +
+ "<browserFileNames>" +
+ "<browserFileName id=\"0\">browser1.exe</browserFileName>" +
+ "<browserFileName id=\"1\">browser2.exe</browserFileName>" +
+ "</browserFileNames>" +
+ "<closeBrowsersAfterTestRuns>true</closeBrowsersAfterTestRuns>" +
+ "<description>This is the best server ever</description>" +
+ "<logsDirectory>" + logsDirectory.getAbsolutePath() + "</logsDirectory>" +
+ "<port>1234</port>" +
+ "<resourceBase>" + resourceBase.getAbsolutePath() + "</resourceBase>" +
+ "<timeoutSeconds>76</timeoutSeconds>" +
+ "<url>http://www.example.com:1234/</url>" +
+ "</configuration>";
+ assertEquals(expectedXML, XmlUtility.asString(configuration.asXml(ServerType.STANDARD)));
+ }
+
+ public void testAsXmlForStandardTemporaryConfiguration() throws Exception {
+ FullValidForBothConfigurationSource source = new FullValidForBothConfigurationSource();
+ Configuration configuration = new Configuration(source);
+ File logsDirectory = new File(source.logsDirectory());
+ File resourceBase = new File(source.resourceBase());
+ String expectedXML = "<configuration type=\"" + ServerType.STANDARD_TEMPORARY.name() + "\">" +
+ "<os>" + SystemUtility.osString() + "</os>" +
+ "<ipAddress>" + SystemUtility.ipAddress() + "</ipAddress>" +
+ "<hostname>" + SystemUtility.hostname() + "</hostname>" +
+ "<browserFileNames>" +
+ "<browserFileName id=\"0\">browser1.exe</browserFileName>" +
+ "<browserFileName id=\"1\">browser2.exe</browserFileName>" +
+ "</browserFileNames>" +
+ "<closeBrowsersAfterTestRuns>true</closeBrowsersAfterTestRuns>" +
+ "<description>This is the best server ever</description>" +
+ "<logsDirectory>" + logsDirectory.getAbsolutePath() + "</logsDirectory>" +
+ "<port>1234</port>" +
+ "<resourceBase>" + resourceBase.getAbsolutePath() + "</resourceBase>" +
+ "<timeoutSeconds>76</timeoutSeconds>" +
+ "<url>http://www.example.com:1234/</url>" +
+ "</configuration>";
+ assertEquals(expectedXML, XmlUtility.asString(configuration.asXml(ServerType.STANDARD_TEMPORARY)));
+ }
+
+ public void testAsXmlForFarmConfiguration() throws Exception {
+ FullValidForBothConfigurationSource source = new FullValidForBothConfigurationSource();
+ Configuration configuration = new Configuration(source);
+ File logsDirectory = new File(source.logsDirectory());
+ File resourceBase = new File(source.resourceBase());
+ assertEquals(
+ "<configuration type=\"" + ServerType.FARM.name() + "\">" +
+ "<os>" + SystemUtility.osString() + "</os>" +
+ "<ipAddress>" + SystemUtility.ipAddress() + "</ipAddress>" +
+ "<hostname>" + SystemUtility.hostname() + "</hostname>" +
+ "<description>This is the best server ever</description>" +
+ "<ignoreUnresponsiveRemoteMachines>true</ignoreUnresponsiveRemoteMachines>" +
+ "<logsDirectory>" + logsDirectory.getAbsolutePath() + "</logsDirectory>" +
+ "<port>1234</port>" +
+ "<remoteMachineURLs>" +
+ "<remoteMachineURL id=\"0\">http://localhost:8081/jsunit</remoteMachineURL>" +
+ "<remoteMachineURL id=\"1\">http://127.0.0.1:8082/jsunit</remoteMachineURL>" +
+ "</remoteMachineURLs>" +
+ "<resourceBase>" + resourceBase.getAbsolutePath() + "</resourceBase>" +
+ "<url>http://www.example.com:1234/</url>" +
+ "</configuration>",
+ XmlUtility.asString(configuration.asXml(ServerType.FARM))
+ );
+ }
+
+ public void testGetBrowserById() throws Exception {
+ Configuration configuration = new Configuration(new FullValidForBothConfigurationSource());
+ assertEquals(new Browser("browser1.exe", 0), configuration.getBrowserById(0));
+ assertEquals(new Browser("browser2.exe", 1), configuration.getBrowserById(1));
+ assertNull(configuration.getBrowserById(900));
+ }
+
+ public void testGetRemoteMachineURLById() throws Exception {
+ Configuration configuration = new Configuration(new FullValidForBothConfigurationSource());
+ assertEquals(
+ "http://localhost:8081/jsunit",
+ configuration.getRemoteMachineURLById(0).toString()
+ );
+ assertEquals(
+ "http://127.0.0.1:8082/jsunit",
+ configuration.getRemoteMachineURLById(1).toString()
+ );
+ }
+
+ public void testAsArgumentsArray() throws Exception {
+ Configuration configuration = new Configuration(new FullValidForBothConfigurationSource());
+ String[] arguments = configuration.asArgumentsArray();
+
+ assertEquals(20, arguments.length);
+ int index = 0;
+
+ assertEquals("-browserFileNames", arguments[index++]);
+ assertEquals("browser1.exe,browser2.exe", arguments[index++]);
+
+ assertEquals("-closeBrowsersAfterTestRuns", arguments[index++]);
+ assertEquals("true", arguments[index++]);
+
+ assertEquals("-description", arguments[index++]);
+ assertEquals("This is the best server ever", arguments[index++]);
+
+ assertEquals("-ignoreUnresponsiveRemoteMachines", arguments[index++]);
+ assertEquals("true", arguments[index++]);
+
+ assertEquals("-logsDirectory", arguments[index++]);
+ assertEquals(new File("logs" + File.separator + "directory").getAbsolutePath(), arguments[index++]);
+
+ assertEquals("-port", arguments[index++]);
+ assertEquals("1234", arguments[index++]);
+
+ assertEquals("-remoteMachineURLs", arguments[index++]);
+ assertEquals("http://localhost:8081/jsunit,http://127.0.0.1:8082/jsunit", arguments[index++]);
+
+ assertEquals("-resourceBase", arguments[index++]);
+ assertEquals(new File("resource/base").getAbsolutePath(), arguments[index++]);
+
+ assertEquals("-timeoutSeconds", arguments[index++]);
+ assertEquals("76", arguments[index++]);
+
+ assertEquals("-url", arguments[index++]);
+ assertEquals("http://www.example.com:1234/", arguments[index]);
+ }
+
+ public void testDuplicateBrowserFileNamesAndRemoteMachineURLs() throws Exception {
+ Configuration configuration = new Configuration(new DuplicatesConfigurationSource());
+ List<Browser> browsers = configuration.getBrowsers();
+ assertEquals(3, browsers.size());
+ assertEquals(new Browser("browser1.exe", 0), browsers.get(0));
+ assertEquals(new Browser("browser2.exe", 1), browsers.get(1));
+ assertEquals(new Browser("browser3.exe", 2), browsers.get(2));
+
+ List<URL> remoteMachineURLs = configuration.getRemoteMachineURLs();
+ assertEquals(4, remoteMachineURLs.size());
+ assertEquals("http://machine1:8080/jsunit", remoteMachineURLs.get(0).toString());
+ assertEquals("http://machine2:9090/jsunit", remoteMachineURLs.get(1).toString());
+ assertEquals("http://machine1:8081/jsunit", remoteMachineURLs.get(2).toString());
+ assertEquals("http://machine3:9090/jsunit", remoteMachineURLs.get(3).toString());
+ }
+
+ static class FullValidForBothConfigurationSource implements ConfigurationSource {
+
+ public String resourceBase() {
+ return "resource" + File.separator + "base";
+ }
+
+ public String port() {
+ return "1234";
+ }
+
+ public String logsDirectory() {
+ return "logs" + File.separator + "directory";
+ }
+
+ public String browserFileNames() {
+ return "browser1.exe,browser2.exe";
+ }
+
+ public String url() {
+ return "http://www.example.com:1234/";
+ }
+
+ public String ignoreUnresponsiveRemoteMachines() {
+ return "true";
+ }
+
+ public String closeBrowsersAfterTestRuns() {
+ return "true";
+ }
+
+ public String description() {
+ return "This is the best server ever";
+ }
+
+ public String timeoutSeconds() {
+ return "76";
+ }
+
+ public String remoteMachineURLs() {
+ return "http://localhost:8081,http://127.0.0.1:8082";
+ }
+ }
+
+ static class MinimalValidForBothConfigurationSource extends StubConfigurationSource {
+ public String remoteMachineURLs() {
+ return "http://localhost:8081,http://127.0.0.1:8082";
+ }
+
+ }
+
+ static class ValidForStandardInvalidForFarmConfigurationSource extends StubConfigurationSource {
+ }
+
+ static class DuplicatesConfigurationSource extends StubConfigurationSource {
+ public String browserFileNames() {
+ return "browser1.exe,browser2.exe,browser1.exe,browser1.exe,browser3.exe";
+ }
+
+ public String remoteMachineURLs() {
+ return "http://machine1:8080,http://machine2:9090/jsunit,http://machine1:8081,http://machine1:8080,http://machine1:8080/jsunit,http://machine3:9090";
+ }
+ }
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/configuration/EnvironmentVariablesConfigurationSourceTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/configuration/EnvironmentVariablesConfigurationSourceTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/configuration/EnvironmentVariablesConfigurationSourceTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,38 @@
+package net.jsunit.configuration;
+
+import junit.framework.TestCase;
+
+public class EnvironmentVariablesConfigurationSourceTest extends TestCase {
+ private EnvironmentVariablesConfigurationSource source;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ source = new EnvironmentVariablesConfigurationSource();
+ }
+
+ public void testSimple() {
+ System.setProperty(ConfigurationProperty.BROWSER_FILE_NAMES.getName(), "aaa");
+ System.setProperty(ConfigurationProperty.CLOSE_BROWSERS_AFTER_TEST_RUNS.getName(), "bbb");
+ System.setProperty(ConfigurationProperty.LOGS_DIRECTORY.getName(), "ddd");
+ System.setProperty(ConfigurationProperty.PORT.getName(), "eee");
+ System.setProperty(ConfigurationProperty.REMOTE_MACHINE_URLS.getName(), "fff");
+ System.setProperty(ConfigurationProperty.RESOURCE_BASE.getName(), "ggg");
+ System.setProperty(ConfigurationProperty.TIMEOUT_SECONDS.getName(), "hhh");
+ System.setProperty(ConfigurationProperty.URL.getName(), "iii");
+ assertEquals("aaa", source.browserFileNames());
+ assertEquals("bbb", source.closeBrowsersAfterTestRuns());
+ assertEquals("ddd", source.logsDirectory());
+ assertEquals("eee", source.port());
+ assertEquals("fff", source.remoteMachineURLs());
+ assertEquals("ggg", source.resourceBase());
+ assertEquals("hhh", source.timeoutSeconds());
+ assertEquals("iii", source.url());
+ }
+
+ public void tearDown() throws Exception {
+ for (ConfigurationProperty property : ConfigurationProperty.values())
+ System.getProperties().remove(property.getName());
+ super.tearDown();
+ }
+
+}
\ No newline at end of file
Added: branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/configuration/PropertiesConfigurationSourceTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/configuration/PropertiesConfigurationSourceTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/configuration/PropertiesConfigurationSourceTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,50 @@
+package net.jsunit.configuration;
+
+import junit.framework.TestCase;
+import net.jsunit.utility.FileUtility;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+
+public class PropertiesConfigurationSourceTest extends TestCase {
+
+ public void testNoFile() throws Exception {
+ try {
+ new PropertiesFileConfigurationSource("nosuch.file");
+ fail("Should have thrown a RuntimeException because no properties file exists");
+ } catch (FileNotFoundException e) {
+ }
+ }
+
+ public void testSimple() throws Exception {
+ writePropertiesFile("temp.file");
+ PropertiesFileConfigurationSource configuration = new PropertiesFileConfigurationSource("temp.file");
+ assertEquals("aaa", configuration.browserFileNames());
+ assertEquals("bbb", configuration.closeBrowsersAfterTestRuns());
+ assertEquals("ccc", configuration.logsDirectory());
+ assertEquals("eee", configuration.port());
+ assertEquals("fff", configuration.remoteMachineURLs());
+ assertEquals("ggg", configuration.resourceBase());
+ assertEquals("hhh", configuration.timeoutSeconds());
+ assertEquals("iii", configuration.url());
+ }
+
+ public void tearDown() throws Exception {
+ FileUtility.delete(new File("temp.file"));
+ super.tearDown();
+ }
+
+ private void writePropertiesFile(String fileName) {
+ String contents =
+ ConfigurationProperty.BROWSER_FILE_NAMES.getName() + "=aaa\n" +
+ ConfigurationProperty.CLOSE_BROWSERS_AFTER_TEST_RUNS.getName() + "=bbb\n" +
+ ConfigurationProperty.LOGS_DIRECTORY.getName() + "=ccc\n" +
+ ConfigurationProperty.PORT.getName() + "=eee\n" +
+ ConfigurationProperty.REMOTE_MACHINE_URLS.getName() + "=fff\n" +
+ ConfigurationProperty.RESOURCE_BASE.getName() + "=ggg\n" +
+ ConfigurationProperty.TIMEOUT_SECONDS.getName() + "=hhh\n" +
+ ConfigurationProperty.URL.getName() + "=iii\n";
+ FileUtility.write(new File(fileName), contents);
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/model/BrowserResultTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/model/BrowserResultTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/model/BrowserResultTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,158 @@
+package net.jsunit.model;
+
+import junit.framework.TestCase;
+import net.jsunit.utility.FileUtility;
+
+import java.io.File;
+import java.util.List;
+
+public class BrowserResultTest extends TestCase {
+ private BrowserResult result;
+
+ private String expectedXmlFragment =
+ "<browserResult id=\"An ID\" time=\"4.3\">" +
+ "<properties>" +
+ "<property name=\"browserFileName\" value=\"c:\\Program Files\\Internet Explorer\\iexplore.exe\" />" +
+ "<property name=\"browserId\" value=\"7\" />" +
+ "<property name=\"jsUnitVersion\" value=\"2.5\" />" +
+ "<property name=\"userAgent\" value=\"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)\" />" +
+ "<property name=\"remoteAddress\" value=\"Dummy Remote Address\" />" +
+ "<property name=\"url\" value=\"http://www.example.com/\" />" +
+ "</properties>" +
+ "<testCases>" +
+ "<testCase name=\"page1.html:testFoo\" time=\"1.3\" />" +
+ "<testCase name=\"page1.html:testFoo\" time=\"1.3\">" +
+ "<error>Test Error Message</error>" +
+ "</testCase>" +
+ "<testCase name=\"page2.html:testFoo\" time=\"1.3\">" +
+ "<failure>Test Failure Message</failure>" +
+ "</testCase>" +
+ "</testCases>" +
+ "</browserResult>";
+
+ private BrowserSource browserSource = new DummyBrowserSource("c:\\Program Files\\Internet Explorer\\iexplore.exe", 7);
+
+ public void setUp() throws Exception {
+ super.setUp();
+ result = createBrowserResult();
+ result.setTestCaseStrings(new String[]{
+ "page1.html:testFoo|1.3|S||",
+ "page1.html:testFoo|1.3|E|Test Error Message|",
+ "page2.html:testFoo|1.3|F|Test Failure Message|"}
+ );
+ }
+
+ public void testId() {
+ assertNotNull(result.getId());
+ result = new BrowserResult();
+ result.setId("foo");
+ assertEquals("foo", result.getId());
+ }
+
+ public void testFields() {
+ assertFields(result);
+ }
+
+ public void testXml() {
+ assertEquals(expectedXmlFragment, result.asXmlFragment());
+ }
+
+ public void testResultType() {
+ assertFalse(result.wasSuccessful());
+ assertEquals(ResultType.ERROR, result.getResultType());
+ }
+
+ public void testDisplayString() {
+ assertEquals(ResultType.ERROR.getDisplayString(), result.getDisplayString());
+ }
+
+ public void testBuildFromXmlFile() {
+ File file = null;
+ try {
+ FileUtility.write(new File("resultXml.xml"), expectedXmlFragment);
+ file = new File("resultXml.xml");
+ BrowserResult reconstitutedResult = new BrowserResultBuilder(browserSource).build(file);
+ assertEquals(BrowserResult.class, reconstitutedResult.getClass());
+ assertFields(reconstitutedResult);
+ } finally {
+ if (file != null)
+ file.delete();
+ }
+ }
+
+ public void testBuildFromXmlDocument() {
+ BrowserResult reconstitutedResult = new BrowserResultBuilder(browserSource).build(result.asXmlDocument());
+ assertFields(reconstitutedResult);
+ }
+
+ public void testFailure() {
+ BrowserResult result = createBrowserResult();
+ result.setTestCaseStrings(new String[]{
+ "page.html:testFoo|1.3|S||",
+ "page.html:testBar|1.3|F|Test Failure Message|"
+ });
+ assertFalse(result.wasSuccessful());
+ assertEquals(ResultType.FAILURE, result.getResultType());
+ assertEquals("The test run had 0 error(s) and 1 failure(s).", result.displayString());
+ }
+
+ public void testSuccess() {
+ BrowserResult result = createBrowserResult();
+ result.setTestCaseStrings(new String[]{
+ "page.html:testFoo|1.3|S||",
+ "page.html:testBar|1.3|S||"
+ });
+ assertTrue(result.wasSuccessful());
+ assertEquals(ResultType.SUCCESS, result.getResultType());
+ }
+
+ public void testGetTestPageResults() {
+ List<TestPageResult> testPageResults = result.getTestPageResults();
+ assertEquals(2, testPageResults.size());
+ TestPageResult result1 = testPageResults.get(0);
+ assertEquals("page1.html", result1.getTestPageName());
+ assertEquals(2, result1.getTestCaseResults().size());
+ TestPageResult result2 = testPageResults.get(1);
+ assertEquals("page2.html", result2.getTestPageName());
+ assertEquals(1, result2.getTestCaseResults().size());
+ }
+
+ public void testCompleted() {
+ assertTrue(result.completedTestRun());
+ assertFalse(result.timedOut());
+ assertFalse(result.failedToLaunch());
+ assertFalse(result.externallyShutDown());
+ }
+
+ public void testIsForBrowser() throws Exception {
+ assertFalse(result.isForBrowser(new Browser("mybrowser.exe", 9)));
+ assertFalse(result.isForBrowser(new Browser("c:\\Program Files\\Internet Explorer\\iexplore.exe", 9)));
+ assertFalse(result.isForBrowser(new Browser("mybrowser.exe", 7)));
+ assertTrue(result.isForBrowser(new Browser("c:\\Program Files\\Internet Explorer\\iexplore.exe", 7)));
+ }
+
+ private BrowserResult createBrowserResult() {
+ BrowserResult browserResult = new BrowserResult();
+ browserResult.setBrowser(new Browser("c:\\Program Files\\Internet Explorer\\iexplore.exe", 7));
+ browserResult.setJsUnitVersion("2.5");
+ browserResult.setId("An ID");
+ browserResult.setUserAgent("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
+ browserResult.setRemoteAddress("Dummy Remote Address");
+ browserResult.setBaseURL("http://www.example.com/");
+ browserResult.setTime(4.3);
+ return browserResult;
+ }
+
+ private void assertFields(BrowserResult aResult) {
+ assertEquals("2.5", aResult.getJsUnitVersion());
+ assertEquals("An ID", aResult.getId());
+ assertEquals("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)", aResult.getUserAgent());
+ assertEquals("Dummy Remote Address", aResult.getRemoteAddress());
+ assertEquals(4.3d, aResult.getTime(), 0.001d);
+ assertEquals(3, aResult.getTestCaseResults().size());
+ for (TestCaseResult testCaseResult : aResult.getTestCaseResults()) {
+ assertNotNull(testCaseResult);
+ }
+ }
+
+}
\ No newline at end of file
Added: branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/model/BrowserTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/model/BrowserTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/model/BrowserTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,29 @@
+package net.jsunit.model;
+
+import junit.framework.TestCase;
+
+public class BrowserTest extends TestCase {
+
+ public void testSimple() throws Exception {
+ Browser browser = new Browser("c:\\program files\\internet explorer\\iexplore.exe", 4);
+ assertEquals("c:\\program files\\internet explorer\\iexplore.exe", browser.getFileName());
+ assertEquals(4, browser.getId());
+ assertTrue(browser.hasId(4));
+ assertFalse(browser.hasId(2));
+ }
+
+ public void testKillCommand() throws Exception {
+ Browser browser = new Browser("mybrowser.exe", 0);
+ assertEquals("mybrowser.exe", browser.getFileName());
+ assertNull(browser.getKillCommand());
+
+ browser = new Browser("mybrowser.exe;", 0);
+ assertEquals("mybrowser.exe", browser.getFileName());
+ assertNull(browser.getKillCommand());
+
+ browser = new Browser("mybrowser.exe;kill-mybrowser.bat", 0);
+ assertEquals("mybrowser.exe", browser.getFileName());
+ assertEquals("kill-mybrowser.bat", browser.getKillCommand());
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/model/DistributedTestRunResultBuilderTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/model/DistributedTestRunResultBuilderTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/model/DistributedTestRunResultBuilderTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,43 @@
+package net.jsunit.model;
+
+import junit.framework.TestCase;
+import net.jsunit.DummyBrowserResult;
+import net.jsunit.utility.XmlUtility;
+
+public class DistributedTestRunResultBuilderTest extends TestCase {
+
+ public void testSimple() throws Exception {
+ DistributedTestRunResultBuilder builder = new DistributedTestRunResultBuilder(new DummyBrowserSource("mybrowser.exe", 0));
+ DistributedTestRunResult result = builder.build(XmlUtility.asXmlDocument(distributedTestRunResultString()));
+ assertEquals(2, result.getTestRunResults().size());
+ }
+
+ private String distributedTestRunResultString() {
+ return "<distributedTestRunResult>" +
+ testRunResultString() +
+ testRunResultString() +
+ "</distributedTestRunResult>";
+ }
+
+ private String testRunResultString() {
+ return
+ "<testRunResult>" +
+ "<properties>" +
+ "<property name=\"os\" value=\"my cool os\"></property>" +
+ "<property name=\"ipAddress\" value=\"127.0.0.1\"></property>" +
+ "<property name=\"hostname\" value=\"machine.example.com\"></property>" +
+ "</properties>" +
+ successResult().asXmlFragment() +
+ errorResult().asXmlFragment() +
+ "</testRunResult>";
+ }
+
+ private BrowserResult successResult() {
+ return new DummyBrowserResult(true, 0, 0);
+ }
+
+ private BrowserResult errorResult() {
+ return new DummyBrowserResult(false, 1, 2);
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/model/DummyBrowserSource.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/model/DummyBrowserSource.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/model/DummyBrowserSource.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,16 @@
+package net.jsunit.model;
+
+public class DummyBrowserSource implements BrowserSource {
+
+ private String fileName;
+ private int id;
+
+ public DummyBrowserSource(String fileName, int id) {
+ this.fileName = fileName;
+ this.id = id;
+ }
+
+ public Browser getBrowserById(int requestedId) {
+ return requestedId == id ? new Browser(fileName, id) : null;
+ }
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/model/ExternallyShutDownBrowserResultTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/model/ExternallyShutDownBrowserResultTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/model/ExternallyShutDownBrowserResultTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,52 @@
+package net.jsunit.model;
+
+import junit.framework.TestCase;
+
+public class ExternallyShutDownBrowserResultTest extends TestCase {
+
+ private String xml =
+ "<browserResult externallyShutDown=\"true\">" +
+ "<properties>" +
+ "<property name=\"browserFileName\" value=\"c:\\Program Files\\Internet Explorer\\iexplore.exe\" />" +
+ "<property name=\"browserId\" value=\"17\" />" +
+ "</properties>" +
+ "</browserResult>";
+
+ private BrowserResult result;
+
+ public void setUp() throws Exception {
+ super.setUp();
+ result = new BrowserResult();
+ result.setExternallyShutDown();
+ result.setBrowser(new Browser("c:\\Program Files\\Internet Explorer\\iexplore.exe", 17));
+ }
+
+ public void testSimple() {
+ assertEquals("c:\\Program Files\\Internet Explorer\\iexplore.exe", result.getBrowser().getFileName());
+ assertEquals(0d, result.getTime());
+ assertEquals(ResultType.EXTERNALLY_SHUT_DOWN.getDisplayString(), result.getDisplayString());
+ assertEquals(0, result.getTestCount());
+ assertEquals(ResultType.EXTERNALLY_SHUT_DOWN, result.getResultType());
+ assertEquals(0, result.getTestPageResults().size());
+ }
+
+ public void testCompleted() {
+ assertFalse(result.completedTestRun());
+ assertFalse(result.timedOut());
+ assertFalse(result.failedToLaunch());
+ assertTrue(result.externallyShutDown());
+ }
+
+ public void testXml() {
+ assertEquals(xml, result.asXmlFragment());
+ }
+
+ public void testReconstituteFromXml() {
+ BrowserResultBuilder builder = new BrowserResultBuilder(new DummyBrowserSource("c:\\Program Files\\Internet Explorer\\iexplore.exe", 17));
+ BrowserResult reconstitutedResult = builder.build(xml);
+ assertEquals("c:\\Program Files\\Internet Explorer\\iexplore.exe", reconstitutedResult.getBrowser().getFileName());
+ assertTrue(reconstitutedResult.externallyShutDown());
+ assertEquals(ResultType.EXTERNALLY_SHUT_DOWN, reconstitutedResult.getResultType());
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/model/FailedToLaunchBrowserResultTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/model/FailedToLaunchBrowserResultTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/model/FailedToLaunchBrowserResultTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,63 @@
+package net.jsunit.model;
+
+import junit.framework.TestCase;
+import net.jsunit.utility.StringUtility;
+
+import java.io.FileNotFoundException;
+
+public class FailedToLaunchBrowserResultTest extends TestCase {
+
+ private Throwable exception = new FileNotFoundException();
+ private String xml =
+ "<browserResult failedToLaunch=\"true\">" +
+ "<properties>" +
+ "<property name=\"browserFileName\" value=\"c:\\Program Files\\Internet Explorer\\iexplore.exe\" />" +
+ "<property name=\"browserId\" value=\"3\" />" +
+ "<property name=\"serverSideExceptionStackTrace\"><![CDATA[" +
+ StringUtility.stackTraceAsString(exception) +
+ "]]></property>" +
+ "</properties>" +
+ "</browserResult>";
+
+ private BrowserResult result;
+
+ public void setUp() throws Exception {
+ super.setUp();
+ result = new BrowserResult();
+ result.setFailedToLaunch();
+ result.setBrowser(new Browser("c:\\Program Files\\Internet Explorer\\iexplore.exe", 3));
+ result.setServerSideException(exception);
+ }
+
+ public void testSimple() {
+ assertEquals("c:\\Program Files\\Internet Explorer\\iexplore.exe", result.getBrowser().getFileName());
+ assertEquals(0d, result.getTime());
+ assertEquals(ResultType.FAILED_TO_LAUNCH.getDisplayString(), result.getDisplayString());
+ assertEquals(0, result.getTestCount());
+ assertEquals(ResultType.FAILED_TO_LAUNCH, result.getResultType());
+ assertEquals(0, result.getTestPageResults().size());
+ assertEquals(StringUtility.stackTraceAsString(exception), result.getServerSideExceptionStackTrace());
+ }
+
+ public void testCompleted() {
+ assertFalse(result.completedTestRun());
+ assertFalse(result.timedOut());
+ assertFalse(result.externallyShutDown());
+ assertTrue(result.failedToLaunch());
+ }
+
+ public void testXml() {
+ assertEquals(xml, result.asXmlFragment());
+ }
+
+ public void testReconstituteFromXml() {
+ BrowserResultBuilder builder = new BrowserResultBuilder(new DummyBrowserSource("c:\\Program Files\\Internet Explorer\\iexplore.exe", 3));
+ BrowserResult reconstitutedResult = builder.build(xml);
+ assertEquals("c:\\Program Files\\Internet Explorer\\iexplore.exe", reconstitutedResult.getBrowser().getFileName());
+ assertTrue(reconstitutedResult.failedToLaunch());
+ assertEquals(ResultType.FAILED_TO_LAUNCH, reconstitutedResult.getResultType());
+ //TODO: somehow they're not quite equal
+ //assertEquals(Utility.stackTraceAsString(exception), reconstitutedResult.getServerSideExceptionStackTrace());
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/model/TestCaseResultTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/model/TestCaseResultTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/model/TestCaseResultTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,56 @@
+package net.jsunit.model;
+
+import junit.framework.TestCase;
+
+public class TestCaseResultTest extends TestCase {
+ public TestCaseResultTest(String name) {
+ super(name);
+ }
+
+ public void testBuildSuccessfulResultFromString() {
+ TestCaseResult result = TestCaseResult.fromString("file:///dummy%20path/dummyPage.html:testFoo|1.3|S||");
+ assertEquals("file:///dummy path/dummyPage.html", result.getTestPageName());
+ assertEquals("testFoo", result.getName());
+ assertEquals("file:///dummy path/dummyPage.html:testFoo", result.getFullyQualifiedName());
+ assertEquals(1.3d, result.getTime(), 0.1d);
+ assertFalse(result.hadError());
+ assertFalse(result.hadFailure());
+ assertTrue(result.wasSuccessful());
+ assertNull(result.getError());
+ assertNull(result.getFailure());
+ assertEquals(ResultType.SUCCESS, result.getResultType());
+ assertEquals("<testCase name=\"file:///dummy path/dummyPage.html:testFoo\" time=\"1.3\" />", result.getXmlFragment());
+ }
+
+ public void testProblemSummary() {
+ TestCaseResult result = TestCaseResult.fromString("file:///dummy/path/dummyPage.html:testFoo|1.3|E|Test Error Message|");
+ assertEquals("file:///dummy/path/dummyPage.html:testFoo had an error:\nTest Error Message", result.getProblemSummary());
+ }
+
+ public void testBuildErrorResultFromString() {
+ TestCaseResult result = TestCaseResult.fromString("file:///dummy/path/dummyPage.html:testFoo|1.3|E|Test Error Message|");
+ assertEquals("file:///dummy/path/dummyPage.html:testFoo", result.getFullyQualifiedName());
+ assertEquals(1.3d, result.getTime());
+ assertTrue(result.hadError());
+ assertFalse(result.hadFailure());
+ assertFalse(result.wasSuccessful());
+ assertEquals("Test Error Message", result.getError());
+ assertNull(result.getFailure());
+ assertEquals(ResultType.ERROR, result.getResultType());
+ assertEquals("<testCase name=\"file:///dummy/path/dummyPage.html:testFoo\" time=\"1.3\"><error>Test Error Message</error></testCase>", result.getXmlFragment());
+ }
+
+ public void testBuildFailureResultFromString() {
+ TestCaseResult result = TestCaseResult.fromString("file:///dummy/path/dummyPage.html:testFoo|1.3|F|Test Failure Message|");
+ assertEquals("file:///dummy/path/dummyPage.html:testFoo", result.getFullyQualifiedName());
+ assertEquals(1.3d, result.getTime());
+ assertFalse(result.hadError());
+ assertTrue(result.hadFailure());
+ assertFalse(result.wasSuccessful());
+ assertNull(result.getError());
+ assertEquals("Test Failure Message", result.getFailure());
+ assertEquals(ResultType.FAILURE, result.getResultType());
+ assertEquals("<testCase name=\"file:///dummy/path/dummyPage.html:testFoo\" time=\"1.3\"><failure>Test Failure Message</failure></testCase>", result.getXmlFragment());
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/model/TestPageResultTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/model/TestPageResultTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/model/TestPageResultTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,38 @@
+package net.jsunit.model;
+
+import junit.framework.TestCase;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class TestPageResultTest extends TestCase {
+
+ public void testSimple() {
+ TestPageResult result = new TestPageResult("mypage.html");
+ assertEquals("mypage.html", result.getTestPageName());
+ TestCaseResult testCase1 = new TestCaseResult();
+ TestCaseResult testCase2 = new TestCaseResult();
+ result.addTestCaseResult(testCase1);
+ result.addTestCaseResult(testCase2);
+ List<TestCaseResult> expected = new ArrayList<TestCaseResult>();
+ expected.add(testCase1);
+ expected.add(testCase2);
+ assertEquals(expected, result.getTestCaseResults());
+ }
+
+ public void testResultType() {
+ TestPageResult result = new TestPageResult("mypage.html");
+ TestCaseResult success = new TestCaseResult();
+ result.addTestCaseResult(success);
+ assertEquals(ResultType.SUCCESS, result.getResultType());
+ TestCaseResult failure = new TestCaseResult();
+ failure.setFailure("not right");
+ result.addTestCaseResult(failure);
+ assertEquals(ResultType.FAILURE, result.getResultType());
+ TestCaseResult error = new TestCaseResult();
+ error.setError("disaster");
+ result.addTestCaseResult(error);
+ assertEquals(ResultType.ERROR, result.getResultType());
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/model/TestRunResultBuilderTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/model/TestRunResultBuilderTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/model/TestRunResultBuilderTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,37 @@
+package net.jsunit.model;
+
+import junit.framework.TestCase;
+import net.jsunit.DummyBrowserResult;
+import net.jsunit.utility.XmlUtility;
+
+public class TestRunResultBuilderTest extends TestCase {
+
+ public void testSimple() throws Exception {
+ TestRunResultBuilder builder = new TestRunResultBuilder(new DummyBrowserSource("mybrowser.exe", 1));
+ TestRunResult result = builder.build(XmlUtility.asXmlDocument(fullValidResult()));
+ assertEquals(ResultType.SUCCESS, result.getResultType());
+ assertEquals(2, result.getChildren().size());
+ assertEquals("my cool os", result.getOsString());
+ assertEquals("127.0.0.1", result.getIpAddress());
+ assertEquals("machine.example.com", result.getHostname());
+ }
+
+ private String fullValidResult() {
+ return
+ "<testRunResult>" +
+ "<properties>" +
+ "<property name=\"os\" value=\"my cool os\"></property>" +
+ "<property name=\"ipAddress\" value=\"127.0.0.1\"></property>" +
+ "<property name=\"hostname\" value=\"machine.example.com\"></property>" +
+ "</properties>" +
+ successResult().asXmlFragment() +
+ successResult().asXmlFragment() +
+ "</testRunResult>";
+ }
+
+ private BrowserResult successResult() {
+ return new DummyBrowserResult(true, 0, 0);
+ }
+
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/model/TimedOutBrowerResultTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/model/TimedOutBrowerResultTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/model/TimedOutBrowerResultTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,49 @@
+package net.jsunit.model;
+
+import junit.framework.TestCase;
+
+public class TimedOutBrowerResultTest extends TestCase {
+
+ private String xml =
+ "<browserResult timedOut=\"true\">" +
+ "<properties>" +
+ "<property name=\"browserFileName\" value=\"c:\\Program Files\\Internet Explorer\\iexplore.exe\" />" +
+ "<property name=\"browserId\" value=\"3\" />" +
+ "</properties>" +
+ "</browserResult>";
+
+ private BrowserResult browserResult;
+
+ public void setUp() throws Exception {
+ super.setUp();
+ browserResult = new BrowserResult();
+ browserResult.setTimedOut();
+ browserResult.setBrowser(new Browser("c:\\Program Files\\Internet Explorer\\iexplore.exe", 3));
+ }
+
+ public void testSimple() {
+ assertEquals("c:\\Program Files\\Internet Explorer\\iexplore.exe", browserResult.getBrowser().getFileName());
+ assertEquals(ResultType.TIMED_OUT, browserResult.getResultType());
+ }
+
+ public void testCompleted() {
+ assertFalse(browserResult.completedTestRun());
+ assertTrue(browserResult.timedOut());
+ assertFalse(browserResult.failedToLaunch());
+ assertFalse(browserResult.externallyShutDown());
+ }
+
+ public void testAsXml() {
+ assertEquals(xml, browserResult.asXmlFragment());
+ }
+
+ public void testReconstituteFromXml() {
+ BrowserResultBuilder builder = new BrowserResultBuilder(new DummyBrowserSource("c:\\Program Files\\Internet Explorer\\iexplore.exe", 3));
+ BrowserResult reconstitutedResult = builder.build(xml);
+ assertEquals("c:\\Program Files\\Internet Explorer\\iexplore.exe", reconstitutedResult.getBrowser().getFileName());
+ assertTrue(reconstitutedResult.timedOut());
+ assertEquals(ResultType.TIMED_OUT, reconstitutedResult.getResultType());
+
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/version/BlowingUpVersionGrabber.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/version/BlowingUpVersionGrabber.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/version/BlowingUpVersionGrabber.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,7 @@
+package net.jsunit.version;
+
+public class BlowingUpVersionGrabber implements VersionGrabber {
+ public double grabVersion() throws Exception {
+ throw new Exception();
+ }
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/version/MockVersionGrabber.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/version/MockVersionGrabber.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/version/MockVersionGrabber.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,14 @@
+package net.jsunit.version;
+
+public class MockVersionGrabber implements VersionGrabber {
+
+ public double version;
+
+ public MockVersionGrabber(double version) {
+ this.version = version;
+ }
+
+ public double grabVersion() {
+ return version;
+ }
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/version/VersionCheckerTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/version/VersionCheckerTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_core/net/jsunit/version/VersionCheckerTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,22 @@
+package net.jsunit.version;
+
+import junit.framework.TestCase;
+
+public class VersionCheckerTest extends TestCase {
+
+ public void testOutOfDate() throws Exception {
+ VersionChecker checker = new VersionChecker(1.1, new MockVersionGrabber(1.2));
+ assertFalse(checker.isUpToDate());
+ }
+
+ public void testUpToDate() throws Exception {
+ VersionChecker checker = new VersionChecker(1.1, new MockVersionGrabber(1.1));
+ assertTrue(checker.isUpToDate());
+ }
+
+ public void testBlowsUp() throws Exception {
+ VersionChecker checker = new VersionChecker(1.1, new BlowingUpVersionGrabber());
+ assertTrue(checker.isUpToDate());
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/AcceptorFunctionalTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/AcceptorFunctionalTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/AcceptorFunctionalTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,45 @@
+package net.jsunit;
+
+import net.jsunit.model.Browser;
+import net.jsunit.model.BrowserResult;
+import net.jsunit.model.BrowserResultWriter;
+import net.jsunit.utility.XmlUtility;
+import org.jdom.Document;
+
+public class AcceptorFunctionalTest extends FunctionalTestCase {
+
+ public void testSubmission() throws Exception {
+ server.launchBrowserTestRun(new BrowserLaunchSpecification(new Browser(Browser.DEFAULT_SYSTEM_BROWSER, 0)));
+
+ StringBuffer buffer = new StringBuffer();
+ addParameter(buffer, BrowserResultWriter.ID, "ID_foo", true);
+ addParameter(buffer, BrowserResultWriter.USER_AGENT, "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)", false);
+ addParameter(buffer, BrowserResultWriter.TIME, "4.3", false);
+ addParameter(buffer, BrowserResultWriter.JSUNIT_VERSION, "12.5", false);
+ addParameter(buffer, BrowserResultWriter.TEST_CASES, "/dummy/path/dummyPage.html:testFoo|1.3|S||", false);
+
+ webTester.beginAt("acceptor" + buffer.toString());
+
+ BrowserResult result = new BrowserResult();
+ result.setId("ID_foo");
+ result.setBrowser(new Browser(Browser.DEFAULT_SYSTEM_BROWSER, 0));
+ result.setUserAgent("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
+ result.setTime(4.3);
+ result.setJsUnitVersion("12.5");
+ result.setTestCaseStrings(new String[]{"/dummy/path/dummyPage.html:testFoo|1.3|S||"});
+ result.setRemoteAddress("127.0.0.1");
+
+ assertEquals(XmlUtility.asString(new Document(result.asXml())), webTester.getDialog().getResponseText());
+ }
+
+ private void addParameter(StringBuffer buffer, String key, String value, boolean isFirst) {
+ if (isFirst)
+ buffer.append("?");
+ else
+ buffer.append("&");
+ buffer.append(key);
+ buffer.append("=");
+ buffer.append(value);
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/BlowingUpRemoteServerHitter.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/BlowingUpRemoteServerHitter.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/BlowingUpRemoteServerHitter.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,16 @@
+/**
+ *
+ */
+package net.jsunit;
+
+import org.jdom.Document;
+
+import java.io.IOException;
+import java.net.URL;
+
+public class BlowingUpRemoteServerHitter implements RemoteServerHitter {
+
+ public Document hitURL(URL url) throws IOException {
+ throw new IOException();
+ }
+}
\ No newline at end of file
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/BrowserResultLogWriterTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/BrowserResultLogWriterTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/BrowserResultLogWriterTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,12 @@
+package net.jsunit;
+
+import junit.framework.TestCase;
+import net.jsunit.logging.StubBrowserResultRepository;
+
+public class BrowserResultLogWriterTest extends TestCase {
+
+ public void testSimple() {
+ assertTrue(new BrowserResultLogWriter(new StubBrowserResultRepository()).isReady());
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/ConfigurationFunctionalTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/ConfigurationFunctionalTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/ConfigurationFunctionalTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,10 @@
+package net.jsunit;
+
+public class ConfigurationFunctionalTest extends FunctionalTestCase {
+
+ public void testSimple() throws Exception {
+ webTester.beginAt("config");
+ assertConfigXml();
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/DisplayerFunctionalTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/DisplayerFunctionalTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/DisplayerFunctionalTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,47 @@
+package net.jsunit;
+
+import net.jsunit.model.Browser;
+import net.jsunit.model.BrowserResult;
+import net.jsunit.utility.XmlUtility;
+import org.jdom.Document;
+import org.jdom.Element;
+
+public class DisplayerFunctionalTest extends FunctionalTestCase {
+
+ public void testNoId() throws Exception {
+ webTester.beginAt("displayer");
+ Document responseDocument = responseXmlDocument();
+
+ Element rootElement = responseDocument.getRootElement();
+ assertErrorResponse(rootElement, "A Test Result ID and a browser ID must both be given");
+ }
+
+ public void testInvalidId() throws Exception {
+ String id = String.valueOf(System.currentTimeMillis());
+ webTester.beginAt("displayer?id=" + id + "&browserId=0");
+ Document responseDocument = responseXmlDocument();
+
+ Element rootElement = responseDocument.getRootElement();
+ assertErrorResponse(rootElement, "No Test Result has been submitted with ID '" + id + "' for browser ID '0'");
+ }
+
+ public void testInvalidBrowserId() throws Exception {
+ String id = String.valueOf(System.currentTimeMillis());
+ webTester.beginAt("displayer?id=" + id + "&browserId=1000");
+ Document responseDocument = responseXmlDocument();
+
+ Element rootElement = responseDocument.getRootElement();
+ assertErrorResponse(rootElement, "Invalid Browser ID '1000'");
+ }
+
+ public void testValid() throws Exception {
+ server.launchBrowserTestRun(new BrowserLaunchSpecification(new Browser(Browser.DEFAULT_SYSTEM_BROWSER, 0)));
+ BrowserResult browserResult = new BrowserResult();
+ String id = String.valueOf(System.currentTimeMillis());
+ browserResult.setId(id);
+ server.accept(browserResult);
+ webTester.beginAt("displayer?id=" + id + "&browserId=0");
+ assertEquals(XmlUtility.asString(new Document(browserResult.asXml())), webTester.getDialog().getResponseText());
+ }
+
+}
\ No newline at end of file
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/DistributedTestRunManagerTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/DistributedTestRunManagerTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/DistributedTestRunManagerTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,175 @@
+package net.jsunit;
+
+import junit.framework.TestCase;
+import net.jsunit.configuration.Configuration;
+import net.jsunit.model.*;
+import net.jsunit.utility.XmlUtility;
+import org.jdom.Document;
+
+import java.io.UnsupportedEncodingException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLEncoder;
+import java.util.List;
+
+public class DistributedTestRunManagerTest extends TestCase {
+
+ private Configuration configuration;
+
+ public void setUp() throws Exception {
+ super.setUp();
+ configuration = new Configuration(new DummyConfigurationSource());
+ }
+
+ public void testSimple() throws MalformedURLException, UnsupportedEncodingException {
+ String encodedURL = URLEncoder.encode(DummyConfigurationSource.DUMMY_URL, "UTF-8");
+ String url1 = DummyConfigurationSource.REMOTE_URL_1 + "/runner?url=" + encodedURL;
+ String url2 = DummyConfigurationSource.REMOTE_URL_2 + "/runner?url=" + encodedURL;
+ MockRemoteServerHitter hitter = createMockHitter(url1, url2);
+ DistributedTestRunManager manager = new DistributedTestRunManager(hitter, configuration, null);
+ manager.runTests();
+ assertEquals(2, hitter.urlsPassed.size());
+ assertTrue(hitter.urlsPassed.contains(url1));
+ assertTrue(hitter.urlsPassed.contains(url2));
+ DistributedTestRunResult result = manager.getDistributedTestRunResult();
+
+ DistributedTestRunResult expectedResult = new DistributedTestRunResult();
+ expectedResult.addTestRunResult(createResult1());
+ expectedResult.addTestRunResult(createResult2());
+
+ assertEquals(XmlUtility.asString(expectedResult.asXml()), XmlUtility.asString(result.asXml()));
+ }
+
+ public void testRemoteURLBlowsUp() {
+ DistributedTestRunManager manager = new DistributedTestRunManager(new BlowingUpRemoteServerHitter(), configuration, null);
+ assertFalse(configuration.shouldIgnoreUnresponsiveRemoteMachines());
+ manager.runTests();
+ DistributedTestRunResult result = manager.getDistributedTestRunResult();
+ assertFalse(result.wasSuccessful());
+ List<TestRunResult> testRunResults = result.getTestRunResults();
+ assertEquals(2, testRunResults.size());
+ assertEquals(ResultType.UNRESPONSIVE, testRunResults.get(0).getResultType());
+ assertEquals(DummyConfigurationSource.REMOTE_URL_1, testRunResults.get(0).getUrl().toString());
+ assertEquals(DummyConfigurationSource.REMOTE_URL_2, testRunResults.get(1).getUrl().toString());
+ assertEquals(ResultType.UNRESPONSIVE, testRunResults.get(1).getResultType());
+ }
+
+ public void testRemoteURLBlowsUpButIgnored() {
+ configuration = new Configuration(new DummyConfigurationSource() {
+ public String ignoreUnresponsiveRemoteMachines() {
+ return "true";
+ }
+ });
+ assertTrue(configuration.shouldIgnoreUnresponsiveRemoteMachines());
+ DistributedTestRunManager manager = new DistributedTestRunManager(new BlowingUpRemoteServerHitter(), configuration, null);
+ manager.runTests();
+ DistributedTestRunResult result = manager.getDistributedTestRunResult();
+ assertTrue(result.wasSuccessful());
+ assertEquals(0, result.getTestRunResults().size());
+ }
+
+ public void testOverrideURL() throws Exception {
+ String overrideURL = "http://my.override.com:1234?foo=bar&bar=foo";
+ String encodedOverrideURL = URLEncoder.encode(overrideURL, "UTF-8");
+ String url1 = DummyConfigurationSource.REMOTE_URL_1 + "/runner?url=" + encodedOverrideURL;
+ String url2 = DummyConfigurationSource.REMOTE_URL_2 + "/runner?url=" + encodedOverrideURL;
+ MockRemoteServerHitter hitter = createMockHitter(url1, url2);
+ DistributedTestRunManager manager = new DistributedTestRunManager(hitter, configuration, overrideURL);
+ manager.runTests();
+ assertEquals(2, hitter.urlsPassed.size());
+ assertTrue(hitter.urlsPassed.contains(url1));
+ assertTrue(hitter.urlsPassed.contains(url2));
+ }
+
+ public void testNoURL() throws Exception {
+ configuration = new Configuration(new DummyConfigurationSource() {
+ public String url() {
+ return null;
+ }
+ });
+ String url1 = DummyConfigurationSource.REMOTE_URL_1 + "/runner";
+ String url2 = DummyConfigurationSource.REMOTE_URL_2 + "/runner";
+ MockRemoteServerHitter hitter = createMockHitter(url1, url2);
+
+ DistributedTestRunManager manager = new DistributedTestRunManager(hitter, configuration, null);
+ manager.runTests();
+ assertEquals(2, hitter.urlsPassed.size());
+ assertTrue(hitter.urlsPassed.contains(url1));
+ assertTrue(hitter.urlsPassed.contains(url2));
+ DistributedTestRunResult result = manager.getDistributedTestRunResult();
+
+ DistributedTestRunResult expectedResult = new DistributedTestRunResult();
+ expectedResult.addTestRunResult(createResult1());
+ expectedResult.addTestRunResult(createResult2());
+
+ assertEquals(XmlUtility.asString(expectedResult.asXml()), XmlUtility.asString(result.asXml()));
+ }
+
+ public void testDistributedResultReturned() throws Exception {
+ String encodedURL = URLEncoder.encode(DummyConfigurationSource.DUMMY_URL, "UTF-8");
+ String url1 = DummyConfigurationSource.REMOTE_URL_1 + "/runner?url=" + encodedURL;
+ String url2 = DummyConfigurationSource.REMOTE_URL_2 + "/runner?url=" + encodedURL;
+ MockRemoteServerHitter hitter = createMockHitterWithDistributedResults(url1, url2);
+ DistributedTestRunManager manager = new DistributedTestRunManager(hitter, configuration, null);
+ manager.runTests();
+ DistributedTestRunResult result = manager.getDistributedTestRunResult();
+ assertEquals(4, result.getTestRunResults().size());
+ }
+
+ private MockRemoteServerHitter createMockHitter(String url1, String url2) throws MalformedURLException {
+ MockRemoteServerHitter hitter = new MockRemoteServerHitter();
+ hitter.urlToDocument.put(url1, new Document(createResult1().asXml()));
+ hitter.urlToDocument.put(url2, new Document(createResult2().asXml()));
+ return hitter;
+ }
+
+ private MockRemoteServerHitter createMockHitterWithDistributedResults(String url1, String url2) throws MalformedURLException {
+ MockRemoteServerHitter hitter = new MockRemoteServerHitter();
+ DistributedTestRunResult distributedResult = new DistributedTestRunResult();
+ distributedResult.addTestRunResult(createResult1());
+ distributedResult.addTestRunResult(createResult2());
+ hitter.urlToDocument.put(url1, new Document(distributedResult.asXml()));
+ hitter.urlToDocument.put(url2, new Document(distributedResult.asXml()));
+ return hitter;
+ }
+
+ private TestRunResult createResult1() throws MalformedURLException {
+ TestRunResult result = new TestRunResult(new URL(DummyConfigurationSource.REMOTE_URL_1));
+ result.setOsString("my os");
+ BrowserResult browserResult1 = new BrowserResult();
+ browserResult1.setId("1");
+ browserResult1.setBrowser(new Browser("mybrowser.exe", 0));
+ browserResult1.setTime(123.45);
+ result.addBrowserResult(browserResult1);
+
+ BrowserResult browserResult2 = new BrowserResult();
+ browserResult2.setId("2");
+ browserResult2.setBrowser(new Browser("mybrowser.exe", 0));
+ browserResult2.setFailedToLaunch();
+ result.addBrowserResult(browserResult2);
+
+ return result;
+ }
+
+ private TestRunResult createResult2() throws MalformedURLException {
+ TestRunResult result = new TestRunResult(new URL(DummyConfigurationSource.REMOTE_URL_2));
+ result.setOsString("my other os");
+ BrowserResult browserResult1 = new BrowserResult();
+ browserResult1.setBrowser(new Browser("mybrowser.exe", 0));
+ browserResult1.setId("a");
+ browserResult1.setTime(123.45);
+ browserResult1.setBaseURL("http://www.example.com");
+ browserResult1.setId("12345");
+ browserResult1.setUserAgent("foo bar");
+ result.addBrowserResult(browserResult1);
+
+ BrowserResult browserResult2 = new BrowserResult();
+ browserResult1.setId("b");
+ browserResult2.setBrowser(new Browser("mybrowser.exe", 0));
+ browserResult2.setTimedOut();
+ result.addBrowserResult(browserResult2);
+
+ return result;
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/DistributedTestSuiteBuilderTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/DistributedTestSuiteBuilderTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/DistributedTestSuiteBuilderTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,61 @@
+package net.jsunit;
+
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+import net.jsunit.configuration.Configuration;
+import net.jsunit.configuration.ServerType;
+import org.jdom.Document;
+
+public class DistributedTestSuiteBuilderTest extends TestCase {
+ private DummyConfigurationSource originalSource;
+ private MockRemoteServerHitter mockHitter;
+ private DistributedTestSuiteBuilder builder;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ originalSource = new DummyConfigurationSource();
+ mockHitter = new MockRemoteServerHitter();
+ originalSource.setNeeds3rdRemoteMachineURL();
+ mockHitter.urlToDocument.put(DummyConfigurationSource.REMOTE_URL_1 + "/config", remoteConfiguration1XmlDocument());
+ mockHitter.urlToDocument.put(DummyConfigurationSource.REMOTE_URL_2 + "/config", remoteConfiguration2XmlDocument());
+ mockHitter.urlToDocument.put(DummyConfigurationSource.REMOTE_URL_3 + "/config", remoteConfiguration3XmlDocument());
+ builder = new DistributedTestSuiteBuilder(originalSource, mockHitter);
+ }
+
+ public void testSimple() throws Exception {
+ TestSuite aSuite = new TestSuite();
+ builder.addTestsTo(aSuite);
+
+ assertEquals(3, builder.getRemoteMachineURLCount());
+ assertEquals(5, builder.getBrowserCount());
+ assertEquals("JsUnit Tests (3 machines, 5 direct browsers)", aSuite.getName());
+ }
+
+ private Document remoteConfiguration1XmlDocument() {
+ Configuration configuration = new Configuration(new StubConfigurationSource() {
+ public String browserFileNames() {
+ return "browser1.exe,browser2.exe";
+ }
+ });
+ return new Document(configuration.asXml(ServerType.STANDARD));
+ }
+
+ private Document remoteConfiguration2XmlDocument() {
+ Configuration configuration = new Configuration(new StubConfigurationSource() {
+ public String browserFileNames() {
+ return "browser3.exe,browser4.exe,browser5";
+ }
+ });
+ return new Document(configuration.asXml(ServerType.STANDARD));
+ }
+
+ private Document remoteConfiguration3XmlDocument() {
+ Configuration configuration = new Configuration(new StubConfigurationSource() {
+ public String remoteMachineURLs() {
+ return "http://machine4:6060/jsunit";
+ }
+ });
+ return new Document(configuration.asXml(ServerType.FARM));
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/DummyConfigurationSource.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/DummyConfigurationSource.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/DummyConfigurationSource.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,65 @@
+package net.jsunit;
+
+import net.jsunit.configuration.ConfigurationSource;
+
+public class DummyConfigurationSource implements ConfigurationSource {
+
+ public static final String DUMMY_URL = "http://www.example.com:1234/jsunit/runner?autoRun=true&submitResults=true";
+ public static final String REMOTE_URL_1 = "http://my.machine.com:8080/jsunit";
+ public static final String REMOTE_URL_2 = "http://your.machine.com:9090/jsunit";
+ public static final String REMOTE_URL_3 = "http://his.machine.com:7070/jsunit";
+ public static final String BROWSER_FILE_NAME = "mybrowser.exe";
+ private boolean needs3rdRemoteMachineURL;
+
+ public String resourceBase() {
+ return ".";
+ }
+
+ public String port() {
+ return "1234";
+ }
+
+ public String logsDirectory() {
+ return "";
+ }
+
+ public String browserFileNames() {
+ return BROWSER_FILE_NAME;
+ }
+
+ public String url() {
+ return DUMMY_URL;
+ }
+
+ public String ignoreUnresponsiveRemoteMachines() {
+ return "";
+ }
+
+ public String closeBrowsersAfterTestRuns() {
+ return "true";
+ }
+
+ public String description() {
+ return "This is my server!";
+ }
+
+ public String logStatus() {
+ return "false";
+ }
+
+ public String timeoutSeconds() {
+ return "60";
+ }
+
+ public String remoteMachineURLs() {
+ String result = REMOTE_URL_1 + "," + REMOTE_URL_2;
+ if (needs3rdRemoteMachineURL)
+ result += ("," + REMOTE_URL_3);
+ return result;
+ }
+
+ public void setNeeds3rdRemoteMachineURL() {
+ this.needs3rdRemoteMachineURL = true;
+ }
+
+}
\ No newline at end of file
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/DummyFarmConfigurationSource.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/DummyFarmConfigurationSource.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/DummyFarmConfigurationSource.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,51 @@
+package net.jsunit;
+
+import net.jsunit.configuration.ConfigurationSource;
+
+public class DummyFarmConfigurationSource implements ConfigurationSource {
+
+ public String resourceBase() {
+ return ".";
+ }
+
+ public String port() {
+ return "1234";
+ }
+
+ public String logsDirectory() {
+ return "c:\\logs";
+ }
+
+ public String browserFileNames() {
+ return null;
+ }
+
+ public String url() {
+ return null;
+ }
+
+ public String ignoreUnresponsiveRemoteMachines() {
+ return null;
+ }
+
+ public String closeBrowsersAfterTestRuns() {
+ return null;
+ }
+
+ public String description() {
+ return "This is a cool server";
+ }
+
+ public String logStatus() {
+ return "true";
+ }
+
+ public String timeoutSeconds() {
+ return "25";
+ }
+
+ public String remoteMachineURLs() {
+ return "http://www.example.com:8081,http://www.example.com:8082";
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/DummyHttpRequest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/DummyHttpRequest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/DummyHttpRequest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,251 @@
+package net.jsunit;
+
+import javax.servlet.RequestDispatcher;
+import javax.servlet.ServletInputStream;
+import javax.servlet.http.Cookie;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.security.Principal;
+import java.util.Enumeration;
+import java.util.Locale;
+import java.util.Map;
+
+public class DummyHttpRequest implements HttpServletRequest {
+ protected Map parametersToValues;
+ private String ipAddress;
+ private String host;
+
+ public DummyHttpRequest(Map parametersToValues) {
+ this.parametersToValues = parametersToValues;
+ }
+
+ public String getAuthType() {
+ return null;
+ }
+
+ public Cookie[] getCookies() {
+ return null;
+ }
+
+ public long getDateHeader(String name) {
+ return 0;
+ }
+
+ public String getHeader(String name) {
+ return null;
+ }
+
+ public Enumeration getHeaders(String name) {
+ return null;
+ }
+
+ public Enumeration getHeaderNames() {
+ return null;
+ }
+
+ public int getIntHeader(String name) {
+ return 0;
+ }
+
+ public String getMethod() {
+ return null;
+ }
+
+ public String getPathInfo() {
+ return null;
+ }
+
+ public String getPathTranslated() {
+ return null;
+ }
+
+ public String getContextPath() {
+ return null;
+ }
+
+ public String getQueryString() {
+ return null;
+ }
+
+ public String getRemoteUser() {
+ return null;
+ }
+
+ public boolean isUserInRole(String role) {
+ return false;
+ }
+
+ public Principal getUserPrincipal() {
+ return null;
+ }
+
+ public String getRequestedSessionId() {
+ return null;
+ }
+
+ public String getRequestURI() {
+ return null;
+ }
+
+ public StringBuffer getRequestURL() {
+ return null;
+ }
+
+ public String getServletPath() {
+ return null;
+ }
+
+ public HttpSession getSession(boolean create) {
+ return null;
+ }
+
+ public HttpSession getSession() {
+ return null;
+ }
+
+ public boolean isRequestedSessionIdValid() {
+ return false;
+ }
+
+ public boolean isRequestedSessionIdFromCookie() {
+ return false;
+ }
+
+ public boolean isRequestedSessionIdFromURL() {
+ return false;
+ }
+
+ public Object getAttribute(String name) {
+ return null;
+ }
+
+ public Enumeration getAttributeNames() {
+ return null;
+ }
+
+ public String getCharacterEncoding() {
+ return null;
+ }
+
+ public void setCharacterEncoding(String env) throws UnsupportedEncodingException {
+ }
+
+ public int getContentLength() {
+ return 0;
+ }
+
+ public String getContentType() {
+ return null;
+ }
+
+ public ServletInputStream getInputStream() throws IOException {
+ return null;
+ }
+
+ public String getParameter(String name) {
+ Object object = parametersToValues.get(name);
+ if (object instanceof String) return (String) object;
+ if (object instanceof String[]) return ((String[]) object)[0];
+ return null;
+ }
+
+ public Enumeration getParameterNames() {
+ return null;
+ }
+
+ public String[] getParameterValues(String name) {
+ Object object = parametersToValues.get(name);
+ if (object instanceof String) return new String[]{(String) object};
+ if (object instanceof String[]) return (String[]) object;
+ return null;
+ }
+
+ public Map getParameterMap() {
+ return null;
+ }
+
+ public String getProtocol() {
+ return null;
+ }
+
+ public String getScheme() {
+ return null;
+ }
+
+ public String getServerName() {
+ return null;
+ }
+
+ public int getServerPort() {
+ return 0;
+ }
+
+ public BufferedReader getReader() throws IOException {
+ return null;
+ }
+
+ public String getRemoteAddr() {
+ return ipAddress;
+ }
+
+ public String getRemoteHost() {
+ return host;
+ }
+
+ public void setAttribute(String name, Object o) {
+ }
+
+ public void removeAttribute(String name) {
+ }
+
+ public Locale getLocale() {
+ return null;
+ }
+
+ public Enumeration getLocales() {
+ return null;
+ }
+
+ public boolean isSecure() {
+ return false;
+ }
+
+ public RequestDispatcher getRequestDispatcher(String path) {
+ return null;
+ }
+
+ public String getRealPath(String path) {
+ return null;
+ }
+
+ public boolean isRequestedSessionIdFromUrl() {
+ return false;
+ }
+
+ public int getRemotePort() {
+ return 0;
+ }
+
+ public String getLocalName() {
+ return null;
+ }
+
+ public String getLocalAddr() {
+ return null;
+ }
+
+ public int getLocalPort() {
+ return 0;
+ }
+
+ public void setIpAddress(String ipAddress) {
+ this.ipAddress = ipAddress;
+ }
+
+ public void setHost(String host) {
+ this.host = host;
+ }
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/EndToEndTestCase.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/EndToEndTestCase.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/EndToEndTestCase.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,14 @@
+package net.jsunit;
+
+import junit.framework.TestCase;
+
+public abstract class EndToEndTestCase extends TestCase {
+
+ protected int port;
+
+ public void setUp() throws Exception {
+ super.setUp();
+ port = new TestPortManager().newPort();
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/ExternallyShutDownStandaloneTestTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/ExternallyShutDownStandaloneTestTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/ExternallyShutDownStandaloneTestTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,58 @@
+package net.jsunit;
+
+import junit.framework.TestCase;
+import junit.framework.TestResult;
+import net.jsunit.configuration.ConfigurationSource;
+import net.jsunit.model.Browser;
+import net.jsunit.model.ResultType;
+
+public class ExternallyShutDownStandaloneTestTest extends TestCase {
+
+ public ExternallyShutDownStandaloneTestTest(String name) {
+ super(name);
+ }
+
+ protected ConfigurationSource configurationSource() {
+ return new StubConfigurationSource() {
+ public String browserFileNames() {
+ return Browser.DEFAULT_SYSTEM_BROWSER;
+ }
+
+ public String url() {
+ return "http://localhost:8080/jsunit/testRunner.html?" +
+ "testPage=http://localhost:8080/jsunit/tests/jsUnitTestSuite.html" +
+ "&autoRun=true&submitresults=true&resultId=foobar";
+ }
+ };
+ }
+
+ public void testBrowsersExternallyShutDown() throws Exception {
+ final StandaloneTest test = new StandaloneTest(configurationSource());
+ new Thread() {
+ public void run() {
+ try {
+ while (test.getServer() == null)
+ Thread.sleep(100);
+ while (test.getServer().getBrowserProcess() == null)
+ Thread.sleep(100);
+ } catch (InterruptedException e) {
+ fail();
+ }
+ Process process = test.getServer().getBrowserProcess();
+ process.destroy();
+ try {
+ process.waitFor();
+ } catch (InterruptedException e) {
+ fail();
+ }
+ }
+ }.start();
+
+ TestResult result = test.run();
+ assertFalse(result.wasSuccessful());
+ assertEquals(
+ ResultType.EXTERNALLY_SHUT_DOWN,
+ test.getServer().lastResult().getResultType());
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/FailedToLaunchBrowserStandaloneTestTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/FailedToLaunchBrowserStandaloneTestTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/FailedToLaunchBrowserStandaloneTestTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,34 @@
+package net.jsunit;
+
+import junit.framework.TestResult;
+import net.jsunit.configuration.ConfigurationSource;
+import net.jsunit.model.ResultType;
+
+public class FailedToLaunchBrowserStandaloneTestTest extends EndToEndTestCase {
+
+ protected ConfigurationSource configurationSource() {
+ return new StubConfigurationSource() {
+ public String browserFileNames() {
+ return "no_such_browser.exe";
+ }
+
+ public String url() {
+ return "http://localhost:"+port+"/jsunit/testRunner.html?" +
+ "testPage=http://localhost:"+port+"/jsunit/tests/jsUnitUtilityTests.html" +
+ "&autoRun=true&submitresults=true&resultId=foobar";
+ }
+
+ public String port() {
+ return String.valueOf(port);
+ }
+ };
+ }
+
+ public void testFailToLaunchBrowsers() throws Exception {
+ StandaloneTest test = new StandaloneTest(configurationSource());
+ TestResult result = test.run();
+ assertFalse(result.wasSuccessful());
+ assertEquals(ResultType.FAILED_TO_LAUNCH, test.getServer().lastResult().getResultType());
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/FarmServerFunctionalTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/FarmServerFunctionalTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/FarmServerFunctionalTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,38 @@
+package net.jsunit;
+
+import net.jsunit.configuration.Configuration;
+import net.jsunit.model.ResultType;
+import org.jdom.Document;
+
+import java.net.URLEncoder;
+
+public class FarmServerFunctionalTest extends FunctionalTestCase {
+
+ private JsUnitFarmServer farmServer;
+ private int otherPort;
+
+ public void setUp() throws Exception {
+ super.setUp();
+ otherPort = new TestPortManager().newPort();
+ farmServer = new JsUnitFarmServer(new Configuration(new FunctionalTestFarmConfigurationSource(otherPort, port)));
+ farmServer.start();
+ }
+
+ protected int webTesterPort() {
+ return otherPort;
+ }
+
+ public void testHitFarmRunner() throws Exception {
+ String url =
+ "/runner?url=" + URLEncoder.encode("http://localhost:" + port + "/jsunit/tests/jsUnitUtilityTests.html", "UTF-8");
+ webTester.beginAt(url);
+ Document document = responseXmlDocument();
+ assertEquals(ResultType.SUCCESS.name(), document.getRootElement().getAttribute("type").getValue());
+ }
+
+ public void tearDown() throws Exception {
+ farmServer.dispose();
+ super.tearDown();
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/FarmServerFunctionalTestSuite.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/FarmServerFunctionalTestSuite.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/FarmServerFunctionalTestSuite.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,14 @@
+package net.jsunit;
+
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class FarmServerFunctionalTestSuite extends TestCase {
+ public static TestSuite suite() {
+ TestSuite result = new TestSuite();
+// result.addTestSuite(FarmServerFunctionalTest.class);
+ result.addTestSuite(FarmServerLandingPageFunctionalTest.class);
+
+ return result;
+ }
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/FarmServerLandingPageFunctionalTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/FarmServerLandingPageFunctionalTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/FarmServerLandingPageFunctionalTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,45 @@
+package net.jsunit;
+
+import com.meterware.httpunit.HttpUnitOptions;
+import junit.framework.TestCase;
+import net.jsunit.configuration.Configuration;
+import net.sourceforge.jwebunit.WebTester;
+
+public class FarmServerLandingPageFunctionalTest extends TestCase {
+
+ static {
+ HttpUnitOptions.setScriptingEnabled(false);
+ }
+
+ private WebTester webTester;
+ private JsUnitFarmServer server;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ int port = new TestPortManager().newPort();
+ Configuration configuration = new Configuration(new FunctionalTestConfigurationSource(port));
+ server = new JsUnitFarmServer(configuration);
+ server.start();
+ webTester = new WebTester();
+ webTester.getTestContext().setBaseUrl("http://localhost:" + port + "/jsunit");
+ }
+
+ protected void tearDown() throws Exception {
+ server.dispose();
+ super.tearDown();
+ }
+
+ public void testSimple() throws Exception {
+ webTester.beginAt("/");
+ assertOnLandingPage();
+ webTester.assertLinkPresentWithText("runner");
+ webTester.assertLinkNotPresentWithText("displayer");
+ webTester.assertLinkPresentWithText("testRunner.html");
+ webTester.assertLinkPresentWithText("config");
+ }
+
+ private void assertOnLandingPage() {
+ webTester.assertTitleEquals("JsUnit Farm Server");
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/FunctionalTestCase.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/FunctionalTestCase.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/FunctionalTestCase.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,93 @@
+package net.jsunit;
+
+import com.meterware.httpunit.HttpUnitOptions;
+import junit.framework.TestCase;
+import net.jsunit.configuration.Configuration;
+import net.jsunit.model.BrowserResultWriter;
+import net.jsunit.model.ResultType;
+import net.sourceforge.jwebunit.WebTester;
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jdom.JDOMException;
+import org.jdom.input.SAXBuilder;
+
+import java.io.IOException;
+import java.io.Reader;
+import java.io.StringReader;
+import java.util.List;
+
+public abstract class FunctionalTestCase extends TestCase {
+
+ static {
+ HttpUnitOptions.setScriptingEnabled(false);
+ }
+
+ protected WebTester webTester;
+ protected JsUnitStandardServer server;
+ protected int port;
+ protected Configuration configuration;
+
+ public void setUp() throws Exception {
+ super.setUp();
+ port = new TestPortManager().newPort();
+ configuration = new Configuration(new FunctionalTestConfigurationSource(port));
+ server = new JsUnitStandardServer(configuration, new MockBrowserResultRepository(), true);
+ if (shouldMockOutProcessStarter())
+ server.setProcessStarter(new MockProcessStarter());
+ server.start();
+ webTester = new WebTester();
+ webTester.getTestContext().setBaseUrl("http://localhost:" + webTesterPort() + "/jsunit");
+ }
+
+ protected boolean shouldMockOutProcessStarter() {
+ return true;
+ }
+
+ protected int webTesterPort() {
+ return port;
+ }
+
+ public void tearDown() throws Exception {
+ if (server != null)
+ server.dispose();
+ super.tearDown();
+ }
+
+ protected Document responseXmlDocument() throws JDOMException, IOException {
+ String responseXml = webTester.getDialog().getResponseText();
+ SAXBuilder saxBuilder = new SAXBuilder("org.apache.xerces.parsers.SAXParser");
+ Reader stringReader = new StringReader(responseXml);
+ return saxBuilder.build(stringReader);
+ }
+
+ protected void assertConfigXml() throws JDOMException, IOException {
+ System.out.println(webTester.getDialog().getResponseText());
+ Document result = responseXmlDocument();
+ Element root = result.getRootElement();
+ assertEquals("configuration", root.getName());
+ }
+
+ protected void assertErrorResponse(Element rootElement, String message) {
+ assertEquals("error", rootElement.getName());
+ assertEquals(message, rootElement.getText());
+ }
+
+ protected void assertSuccessfulRunResult(Document result, ResultType expectedResultType, String expectedUrl, int expectedBrowserResultCount) {
+ Element root = result.getRootElement();
+ assertEquals("testRunResult", root.getName());
+ assertEquals(expectedBrowserResultCount, root.getChildren("browserResult").size());
+ assertEquals(expectedResultType.name(), root.getAttribute("type").getValue());
+ Element urlProperty = urlPropertyElement(root);
+ assertEquals(expectedUrl, urlProperty.getAttribute(BrowserResultWriter.PROPERTY_VALUE).getValue());
+ }
+
+ @SuppressWarnings("unchecked")
+ private Element urlPropertyElement(Element root) {
+ List<Element> children = root.getChild("browserResult").getChild(BrowserResultWriter.PROPERTIES).getChildren(BrowserResultWriter.PROPERTY);
+ for (Element child : children) {
+ if (child.getAttribute(BrowserResultWriter.PROPERTY_KEY).getValue().equals(BrowserResultWriter.URL))
+ return child;
+ }
+ return null;
+ }
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/FunctionalTestConfigurationSource.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/FunctionalTestConfigurationSource.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/FunctionalTestConfigurationSource.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,61 @@
+/**
+ *
+ */
+package net.jsunit;
+
+import net.jsunit.configuration.ConfigurationSource;
+import net.jsunit.model.Browser;
+
+public class FunctionalTestConfigurationSource implements ConfigurationSource {
+
+ private final int port;
+
+ public FunctionalTestConfigurationSource(int port) {
+ this.port = port;
+ }
+
+ public String resourceBase() {
+ return ".";
+ }
+
+ public String port() {
+ return String.valueOf(port);
+ }
+
+ public String logsDirectory() {
+ return "";
+ }
+
+ public String browserFileNames() {
+ return Browser.DEFAULT_SYSTEM_BROWSER + "," + Browser.DEFAULT_SYSTEM_BROWSER;
+ }
+
+ public String url() {
+ return "http://localhost:" + port + "/jsunit/testRunner.html?testPage=http://localhost:" + port + "/jsunit/tests/jsUnitUtilityTests.html&autoRun=true&submitresults=true";
+ }
+
+ public String ignoreUnresponsiveRemoteMachines() {
+ return "";
+ }
+
+ public String closeBrowsersAfterTestRuns() {
+ return String.valueOf(Boolean.TRUE);
+ }
+
+ public String description() {
+ return null;
+ }
+
+ public String logStatus() {
+ return String.valueOf(true);
+ }
+
+ public String timeoutSeconds() {
+ return "60";
+ }
+
+ public String remoteMachineURLs() {
+ return "http://www.example.com,http://www.example2.com";
+ }
+
+}
\ No newline at end of file
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/FunctionalTestFarmConfigurationSource.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/FunctionalTestFarmConfigurationSource.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/FunctionalTestFarmConfigurationSource.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,59 @@
+package net.jsunit;
+
+import net.jsunit.configuration.ConfigurationSource;
+
+public class FunctionalTestFarmConfigurationSource implements ConfigurationSource {
+
+ private int port;
+ private int remotePort;
+
+ public FunctionalTestFarmConfigurationSource(int port, int remotePort) {
+ this.port = port;
+ this.remotePort = remotePort;
+ }
+
+ public String resourceBase() {
+ return null;
+ }
+
+ public String port() {
+ return String.valueOf(port);
+ }
+
+ public String logsDirectory() {
+ return ".";
+ }
+
+ public String browserFileNames() {
+ return null;
+ }
+
+ public String url() {
+ return null;
+ }
+
+ public String ignoreUnresponsiveRemoteMachines() {
+ return null;
+ }
+
+ public String closeBrowsersAfterTestRuns() {
+ return null;
+ }
+
+ public String description() {
+ return null;
+ }
+
+ public String logStatus() {
+ return "true";
+ }
+
+ public String timeoutSeconds() {
+ return "60";
+ }
+
+ public String remoteMachineURLs() {
+ return "http://localhost:" + remotePort;
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/FunctionalTestSuite.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/FunctionalTestSuite.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/FunctionalTestSuite.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,25 @@
+package net.jsunit;
+
+import junit.framework.TestSuite;
+
+public class FunctionalTestSuite {
+
+ public static TestSuite suite() {
+ TestSuite result = new TestSuite();
+ result.addTestSuite(AcceptorFunctionalTest.class);
+ result.addTestSuite(ConfigurationFunctionalTest.class);
+ result.addTestSuite(DisplayerFunctionalTest.class);
+ result.addTestSuite(InvalidRemoteMachinesDistributedTestTest.class);
+ result.addTestSuite(FailedToLaunchBrowserStandaloneTestTest.class);
+ result.addTestSuite(ServerLandingPageFunctionalTest.class);
+ result.addTestSuite(OverrideURLDistributedTestTest.class);
+ result.addTestSuite(RemoteConfigurationSourceFunctionalTest.class);
+ result.addTestSuite(RunnerFunctionalTest.class);
+ result.addTestSuite(SpecificBrowserDistributedTestTest.class);
+ result.addTestSuite(SuccessfulStandaloneTestTest.class);
+ result.addTestSuite(TimedOutBrowserStandaloneTestTest.class);
+ result.addTestSuite(TwoValidLocalhostsDistributedTestTest.class);
+ result.addTestSuite(UrlOverrideStandaloneTestTest.class);
+ return result;
+ }
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/ImpureUnitTestSuite.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/ImpureUnitTestSuite.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/ImpureUnitTestSuite.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,55 @@
+package net.jsunit;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import net.jsunit.action.DistributedTestRunnerActionTest;
+import net.jsunit.action.FarmServerConfigurationActionTest;
+import net.jsunit.action.TestRunnerActionSimultaneousRunBlockingTest;
+import net.jsunit.action.TestRunnerActionTest;
+import net.jsunit.configuration.ConfigurationSourceResolutionTest;
+import net.jsunit.configuration.ConfigurationTest;
+import net.jsunit.configuration.EnvironmentVariablesConfigurationSourceTest;
+import net.jsunit.configuration.PropertiesConfigurationSourceTest;
+import net.jsunit.interceptor.BrowserResultInterceptorTest;
+import net.jsunit.interceptor.FarmServerInterceptorTest;
+import net.jsunit.interceptor.RequestSourceInterceptorTest;
+import net.jsunit.model.*;
+
+public class ImpureUnitTestSuite {
+
+ public static Test suite() {
+ TestSuite result = new TestSuite();
+ result.addTestSuite(BrowserResultInterceptorTest.class);
+ result.addTestSuite(BrowserResultTest.class);
+ result.addTestSuite(ClientServerInteractionTest.class);
+ result.addTestSuite(ClientServerConnectionTest.class);
+ result.addTestSuite(ConfigurationSourceResolutionTest.class);
+ result.addTestSuite(ConfigurationTest.class);
+ result.addTestSuite(DistributedTestRunResultBuilderTest.class);
+ result.addTestSuite(DistributedTestSuiteBuilderTest.class);
+ result.addTestSuite(EnvironmentVariablesConfigurationSourceTest.class);
+ result.addTestSuite(ExternallyShutDownBrowserResultTest.class);
+ result.addTestSuite(FailedToLaunchBrowserResultTest.class);
+ result.addTestSuite(FarmServerConfigurationActionTest.class);
+ result.addTestSuite(FarmServerInterceptorTest.class);
+ result.addTestSuite(DistributedTestRunManagerTest.class);
+ result.addTestSuite(DistributedTestRunnerActionTest.class);
+ result.addTestSuite(JsUnitFarmServerTest.class);
+ result.addTestSuite(JsUnitStandardServerTest.class);
+ result.addTestSuite(PropertiesConfigurationSourceTest.class);
+ result.addTestSuite(RemoteConfigurationSourceTest.class);
+ result.addTestSuite(RemoteMachineRunnerHitterTest.class);
+ result.addTestSuite(RemoteTestRunClientTest.class);
+ result.addTestSuite(RequestSourceInterceptorTest.class);
+ result.addTestSuite(ResultAcceptorTest.class);
+ result.addTestSuite(TestRunnerActionSimultaneousRunBlockingTest.class);
+ result.addTestSuite(TestRunNotifierServerTest.class);
+ result.addTestSuite(TestRunResultBuilderTest.class);
+ result.addTestSuite(TestRunManagerTest.class);
+ result.addTestSuite(TestRunResultTest.class);
+ result.addTestSuite(TestRunnerActionTest.class);
+ result.addTestSuite(TimeoutCheckerTest.class);
+ result.addTestSuite(TimedOutBrowerResultTest.class);
+ return result;
+ }
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/InvalidRemoteMachinesDistributedTestTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/InvalidRemoteMachinesDistributedTestTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/InvalidRemoteMachinesDistributedTestTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,39 @@
+package net.jsunit;
+
+import junit.framework.TestResult;
+import net.jsunit.configuration.ConfigurationSource;
+import net.jsunit.model.ResultType;
+
+public class InvalidRemoteMachinesDistributedTestTest extends EndToEndTestCase {
+
+ protected ConfigurationSource invalidRemoteMachinesFarmSource() {
+ return new StubConfigurationSource() {
+ public String remoteMachineURLs() {
+ return "http://invalid_machine1:8080, http://invalid_machine2:8080";
+ }
+
+ public String port() {
+ return String.valueOf(port);
+ }
+ };
+ }
+
+ protected ConfigurationSource serverSource() {
+ return new StubConfigurationSource() {
+ public String port() {
+ return String.valueOf(port);
+ }
+ };
+ }
+
+ public void testUnresponsive() {
+ DistributedTest test = new DistributedTest(serverSource(), invalidRemoteMachinesFarmSource());
+ TestResult testResult = test.run();
+ assertFalse(testResult.wasSuccessful());
+ assertEquals(
+ ResultType.UNRESPONSIVE,
+ test.getDistributedTestRunManager().getDistributedTestRunResult().getResultType()
+ );
+ }
+
+}
\ No newline at end of file
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/JsUnitFarmServerTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/JsUnitFarmServerTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/JsUnitFarmServerTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,20 @@
+package net.jsunit;
+
+import junit.framework.TestCase;
+import net.jsunit.configuration.Configuration;
+import net.jsunit.configuration.ServerType;
+
+public class JsUnitFarmServerTest extends TestCase {
+
+ private JsUnitFarmServer server;
+
+ public void setUp() throws Exception {
+ super.setUp();
+ server = new JsUnitFarmServer(new Configuration(new DummyFarmConfigurationSource()));
+ }
+
+ public void testStartTestRun() throws Exception {
+ assertEquals(ServerType.FARM, server.serverType());
+ }
+
+}
\ No newline at end of file
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/JsUnitStandardServerTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/JsUnitStandardServerTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/JsUnitStandardServerTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,163 @@
+package net.jsunit;
+
+import junit.framework.TestCase;
+import net.jsunit.configuration.Configuration;
+import net.jsunit.configuration.ConfigurationException;
+import net.jsunit.model.Browser;
+import net.jsunit.model.BrowserResult;
+
+public class JsUnitStandardServerTest extends TestCase {
+
+ private JsUnitStandardServer server;
+
+ public void setUp() throws Exception {
+ super.setUp();
+ server = new JsUnitStandardServer(new Configuration(new DummyConfigurationSource()), new MockBrowserResultRepository(), false);
+ }
+
+ public void testStartTestRun() throws Exception {
+ server.setProcessStarter(new MockProcessStarter());
+ MockTestRunListener listener = new MockTestRunListener();
+ server.addBrowserTestRunListener(listener);
+ Thread thread = new Thread() {
+ public void run() {
+ try {
+ server.startTestRun();
+ } catch (Exception e) {
+ fail(e.toString());
+ }
+ }
+ };
+ thread.start();
+ Thread.sleep(500);
+ assertTrue(thread.isAlive());
+ listener.isReady = true;
+ thread.join();
+ }
+
+ public void testLaunchingBrowser() {
+ MockProcessStarter starter = new MockProcessStarter();
+ server.setProcessStarter(starter);
+ MockTestRunListener listener = new MockTestRunListener();
+ server.addBrowserTestRunListener(listener);
+
+ server.launchBrowserTestRun(new BrowserLaunchSpecification(new Browser(DummyConfigurationSource.BROWSER_FILE_NAME, 0)));
+ assertTrue(listener.browserTestRunStartedCalled);
+ assertEquals(2, starter.commandPassed.length);
+ assertEquals("mybrowser.exe", starter.commandPassed[0]);
+ assertEquals(DummyConfigurationSource.DUMMY_URL, starter.commandPassed[1]);
+ assertFalse(listener.testRunFinishedCalled);
+ server.accept(new DummyBrowserResult(true, 0, 0));
+ assertTrue(listener.browserTestRunFinishedCalled);
+ }
+
+ public void testLaunchingBrowserCrashes() throws InterruptedException {
+ BlowingUpProcessStarter starter = new BlowingUpProcessStarter();
+ server.setProcessStarter(starter);
+ MockTestRunListener listener = new MockTestRunListener();
+ server.addBrowserTestRunListener(listener);
+
+ long launchTime = server.launchBrowserTestRun(new BrowserLaunchSpecification(new Browser(DummyConfigurationSource.BROWSER_FILE_NAME, 0)));
+ assertTrue(listener.browserTestRunStartedCalled);
+ assertTrue(listener.browserTestRunFinishedCalled);
+ assertTrue(listener.result.failedToLaunch());
+ assertTrue(server.hasReceivedResultSince(launchTime));
+ assertEquals(new Browser("mybrowser.exe", 0), listener.browser);
+ assertEquals("mybrowser.exe", listener.result.getBrowser().getFileName());
+ assertSame(listener.result, server.lastResult());
+
+ server.setProcessStarter(new MockProcessStarter());
+ listener.reset();
+ launchTime = server.launchBrowserTestRun(new BrowserLaunchSpecification(new Browser("mybrowser2.exe", 1)));
+ assertFalse(server.hasReceivedResultSince(launchTime));
+ assertTrue(listener.browserTestRunStartedCalled);
+ assertFalse(listener.browserTestRunFinishedCalled);
+ assertEquals(new Browser("mybrowser2.exe", 1), listener.browser);
+ }
+
+ public void testStartEnd() {
+ server.setProcessStarter(new MockProcessStarter());
+ MockTestRunListener listener = new MockTestRunListener();
+ listener.isReady = true;
+ server.addBrowserTestRunListener(listener);
+ server.startTestRun();
+ assertTrue(listener.testRunStartedCalled);
+ server.finishTestRun();
+ assertTrue(listener.testRunFinishedCalled);
+ }
+
+ public void testAcceptResult() {
+ server.setProcessStarter(new MockProcessStarter());
+ server.launchBrowserTestRun(new BrowserLaunchSpecification(new Browser("mybrowser.exe", 0)));
+ BrowserResult result = new BrowserResult();
+ server.accept(result);
+ assertEquals("mybrowser.exe", result.getBrowser().getFileName());
+ }
+
+ public void testOverrideUrl() {
+ MockProcessStarter starter = new MockProcessStarter();
+ server.setProcessStarter(starter);
+ MockTestRunListener listener = new MockTestRunListener();
+ server.addBrowserTestRunListener(listener);
+
+ String overrideUrl = "http://my.example.com:8080?submitResults=true&autoRun=true";
+ server.launchBrowserTestRun(new BrowserLaunchSpecification(new Browser("mybrowser.exe", 0), overrideUrl));
+ assertEquals(2, starter.commandPassed.length);
+ assertEquals("mybrowser.exe", starter.commandPassed[0]);
+ assertEquals(overrideUrl, starter.commandPassed[1]);
+ }
+
+ public void testAddingSubmitResultsAndAutoRunParameters() throws Exception {
+ MockProcessStarter starter = new MockProcessStarter();
+ server.setProcessStarter(starter);
+ MockTestRunListener listener = new MockTestRunListener();
+ server.addBrowserTestRunListener(listener);
+
+ String overrideUrlWithoutSubmitResults = "http://my.example.com:8080?param=value";
+ server.launchBrowserTestRun(new BrowserLaunchSpecification(new Browser("mybrowser.exe", 0), overrideUrlWithoutSubmitResults));
+ assertEquals(2, starter.commandPassed.length);
+ assertEquals("mybrowser.exe", starter.commandPassed[0]);
+ assertEquals(
+ overrideUrlWithoutSubmitResults + "&autoRun=true&submitResults=localhost:1234/jsunit/acceptor",
+ starter.commandPassed[1]
+ );
+ }
+
+ public void testNoURLSpecified() throws Exception {
+ server = new JsUnitStandardServer(new Configuration(new DummyConfigurationSource() {
+ public String url() {
+ return "";
+ }
+ }), new MockBrowserResultRepository(), false);
+ MockProcessStarter starter = new MockProcessStarter();
+ server.setProcessStarter(starter);
+ server.launchBrowserTestRun(new BrowserLaunchSpecification(new Browser("mybrowser.exe", 0)));
+ assertFalse(server.lastResult().wasSuccessful());
+ assertTrue(server.lastResult().getServerSideExceptionStackTrace().indexOf(NoUrlSpecifiedException.class.getName()) != -1);
+ }
+
+ public void testInvalidConfiguration() {
+ try {
+ server = new JsUnitStandardServer(new Configuration(new InvalidConfigurationSource()), false);
+ fail();
+ } catch (ConfigurationException e) {
+
+ }
+ }
+
+ public void testAwaitingBrowserSubmission() throws Exception {
+ server.setProcessStarter(new MockProcessStarter());
+ assertFalse(server.isAwaitingBrowserSubmission());
+ server.launchBrowserTestRun(new BrowserLaunchSpecification(new Browser("foo.exe", 1)));
+ assertTrue(server.isAwaitingBrowserSubmission());
+ }
+
+ static class InvalidConfigurationSource extends DummyConfigurationSource {
+
+ public String url() {
+ return "invalid url";
+ }
+
+ }
+
+}
\ No newline at end of file
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/MockBrowserResultRepository.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/MockBrowserResultRepository.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/MockBrowserResultRepository.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,21 @@
+package net.jsunit;
+
+import net.jsunit.logging.BrowserResultRepository;
+import net.jsunit.model.Browser;
+import net.jsunit.model.BrowserResult;
+
+public class MockBrowserResultRepository implements BrowserResultRepository {
+ public BrowserResult storedResult;
+ public String requestedId;
+ public Browser requestedBrowser;
+
+ public void store(BrowserResult result) {
+ this.storedResult = result;
+ }
+
+ public BrowserResult retrieve(String id, Browser browser) {
+ this.requestedId = id;
+ this.requestedBrowser = browser;
+ return null;
+ }
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/MockProcessStarter.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/MockProcessStarter.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/MockProcessStarter.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,14 @@
+package net.jsunit;
+
+import java.io.IOException;
+
+public class MockProcessStarter implements ProcessStarter {
+
+ public String[] commandPassed;
+
+ public Process execute(String[] command) throws IOException {
+ this.commandPassed = command;
+ return null;
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/MockRemoteServerHitter.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/MockRemoteServerHitter.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/MockRemoteServerHitter.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,24 @@
+/**
+ *
+ */
+package net.jsunit;
+
+import org.jdom.Document;
+
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class MockRemoteServerHitter implements RemoteServerHitter {
+
+ public List<String> urlsPassed = new ArrayList<String>();
+ public Map<String, Document> urlToDocument = new HashMap<String, Document>();
+
+ public Document hitURL(URL url) {
+ String urlString = url.toString();
+ urlsPassed.add(urlString);
+ return urlToDocument.get(urlString);
+ }
+}
\ No newline at end of file
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/OverrideURLDistributedTestTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/OverrideURLDistributedTestTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/OverrideURLDistributedTestTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,49 @@
+package net.jsunit;
+
+import junit.framework.TestResult;
+import net.jsunit.configuration.ConfigurationSource;
+import net.jsunit.model.Browser;
+import net.jsunit.model.ResultType;
+
+public class OverrideURLDistributedTestTest extends EndToEndTestCase {
+
+ protected ConfigurationSource farmSource() {
+ return new StubConfigurationSource() {
+ public String remoteMachineURLs() {
+ return "http://localhost:" + port;
+ }
+ };
+ }
+
+ protected ConfigurationSource serverSourceWithBadTestURL() {
+ return new StubConfigurationSource() {
+ public String browserFileNames() {
+ return Browser.DEFAULT_SYSTEM_BROWSER;
+ }
+
+ public String url() {
+ return "http://www.example.com";
+ }
+
+ public String port() {
+ return String.valueOf(port);
+ }
+ };
+ }
+
+ public void testOverrideURL() throws Throwable {
+ DistributedTest test = new DistributedTest(serverSourceWithBadTestURL(), farmSource());
+ test.getDistributedTestRunManager().setOverrideURL(
+ "http://localhost:" + port + "/jsunit/testRunner.html?" +
+ "testPage=http://localhost:" + port + "/jsunit/tests/jsUnitUtilityTests.html&autoRun=true&submitresults=true"
+ );
+ TestResult result = test.run();
+
+ assertEquals(
+ ResultType.SUCCESS,
+ test.getDistributedTestRunManager().getDistributedTestRunResult().getResultType()
+ );
+ assertTrue(result.wasSuccessful());
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/PureUnitTestSuite.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/PureUnitTestSuite.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/PureUnitTestSuite.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,37 @@
+package net.jsunit;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import net.jsunit.action.ErrorXmlRenderableTest;
+import net.jsunit.action.LatestVersionActionTest;
+import net.jsunit.action.ResultAcceptorActionTest;
+import net.jsunit.action.ResultDisplayerActionTest;
+import net.jsunit.configuration.ArgumentsConfigurationSourceTest;
+import net.jsunit.interceptor.BrowserTestRunnerInterceptorTest;
+import net.jsunit.interceptor.RemoteRunnerHitterInterceptorTest;
+import net.jsunit.interceptor.VersionGrabberInterceptorTest;
+import net.jsunit.model.BrowserTest;
+import net.jsunit.model.TestCaseResultTest;
+import net.jsunit.model.TestPageResultTest;
+
+public class PureUnitTestSuite {
+
+ public static Test suite() {
+ TestSuite result = new TestSuite();
+ result.addTestSuite(ArgumentsConfigurationSourceTest.class);
+ result.addTestSuite(BrowserLaunchSpecificationTest.class);
+ result.addTestSuite(BrowserResultLogWriterTest.class);
+ result.addTestSuite(BrowserTest.class);
+ result.addTestSuite(BrowserTestRunnerInterceptorTest.class);
+ result.addTestSuite(ErrorXmlRenderableTest.class);
+ result.addTestSuite(DistributedTestRunResultTest.class);
+ result.addTestSuite(LatestVersionActionTest.class);
+ result.addTestSuite(RemoteRunnerHitterInterceptorTest.class);
+ result.addTestSuite(ResultAcceptorActionTest.class);
+ result.addTestSuite(ResultDisplayerActionTest.class);
+ result.addTestSuite(TestCaseResultTest.class);
+ result.addTestSuite(TestPageResultTest.class);
+ result.addTestSuite(VersionGrabberInterceptorTest.class);
+ return result;
+ }
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/RemoteConfigurationSourceFunctionalTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/RemoteConfigurationSourceFunctionalTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/RemoteConfigurationSourceFunctionalTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,20 @@
+package net.jsunit;
+
+import net.jsunit.configuration.Configuration;
+import net.jsunit.configuration.ServerType;
+import net.jsunit.utility.XmlUtility;
+
+public class RemoteConfigurationSourceFunctionalTest extends FunctionalTestCase {
+
+ public void testSimple() throws Exception {
+ String remoteMachineURL = "http://localhost:" + port + "/jsunit";
+ RemoteConfigurationSource source = new RemoteConfigurationSource(new RemoteMachineServerHitter(), remoteMachineURL);
+ assertTrue(source.isInitialized());
+ Configuration remoteConfiguration = new Configuration(source);
+ assertEquals(
+ XmlUtility.asString(configuration.asXml(ServerType.STANDARD)),
+ XmlUtility.asString(remoteConfiguration.asXml(ServerType.STANDARD))
+ );
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/RemoteConfigurationSourceTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/RemoteConfigurationSourceTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/RemoteConfigurationSourceTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,36 @@
+package net.jsunit;
+
+import junit.framework.TestCase;
+import net.jsunit.configuration.Configuration;
+import net.jsunit.configuration.ServerType;
+import net.jsunit.utility.XmlUtility;
+import org.jdom.Document;
+
+public class RemoteConfigurationSourceTest extends TestCase {
+ private String baseURL;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ baseURL = "http://www.example.com:1234/jsunit";
+ }
+
+ public void testSimple() throws Exception {
+ Configuration configuration = new Configuration(new DummyConfigurationSource());
+ MockRemoteServerHitter mockHitter = new MockRemoteServerHitter();
+ mockHitter.urlToDocument.put(baseURL + "/config", new Document(configuration.asXml(ServerType.STANDARD)));
+
+ RemoteConfigurationSource remoteSource = new RemoteConfigurationSource(mockHitter, baseURL);
+ assertTrue(remoteSource.isInitialized());
+
+ Configuration remoteConfiguration = new Configuration(remoteSource);
+ assertEquals(XmlUtility.asString(configuration.asXml(ServerType.STANDARD)),
+ XmlUtility.asString(remoteConfiguration.asXml(ServerType.STANDARD))
+ );
+ }
+
+ public void testBlowingUpURL() throws Exception {
+ RemoteConfigurationSource remoteSource = new RemoteConfigurationSource(new BlowingUpRemoteServerHitter(), baseURL);
+ assertFalse(remoteSource.isInitialized());
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/RemoteMachineRunnerHitterTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/RemoteMachineRunnerHitterTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/RemoteMachineRunnerHitterTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,59 @@
+// Copyright 2005 Google Inc.
+// All Rights Reserved.
+package net.jsunit;
+
+import junit.framework.TestCase;
+import net.jsunit.utility.XmlUtility;
+import org.jdom.Document;
+
+import java.io.InputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+import java.net.URLStreamHandler;
+
+public class RemoteMachineRunnerHitterTest extends TestCase {
+
+ String xml = "<my_document><my_node value=\"1\">my text</my_node></my_document>";
+
+ public void testAllAtOnce() throws Exception {
+ RemoteMachineServerHitter hitter = new RemoteMachineServerHitter();
+ Document document = hitter.hitURL(createURL(xml, xml.length()));
+ assertDocumentHasXml(xml, document);
+ }
+
+ public void testAPieceAtATime() throws Exception {
+ RemoteMachineServerHitter hitter = new RemoteMachineServerHitter();
+ Document document = hitter.hitURL(createURL(xml, 3));
+ assertDocumentHasXml(xml, document);
+ }
+
+ private void assertDocumentHasXml(String expectedXML, Document document) {
+ assertEquals(expectedXML, XmlUtility.asString(document.getRootElement()));
+ }
+
+ private URL createURL(final String xml, final int byteCount) throws MalformedURLException {
+ return new URL("http", "www.example.com", 8080, "foo", new URLStreamHandler() {
+ protected URLConnection openConnection(URL u) {
+ return new URLConnection(u) {
+ public void connect() {
+ }
+
+ public InputStream getInputStream() {
+ return new InputStream() {
+
+ private int index = 0;
+
+ public int read() {
+ if (index >= xml.length())
+ return -1;
+ return xml.codePointAt(index++);
+ }
+ };
+ }
+ };
+ }
+ });
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/ResultAcceptorTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/ResultAcceptorTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/ResultAcceptorTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,116 @@
+package net.jsunit;
+
+import junit.framework.TestCase;
+import net.jsunit.configuration.Configuration;
+import net.jsunit.interceptor.BrowserResultInterceptor;
+import net.jsunit.model.Browser;
+import net.jsunit.model.BrowserResult;
+import net.jsunit.model.BrowserResultWriter;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.HashMap;
+import java.util.Map;
+
+public class ResultAcceptorTest extends TestCase {
+
+ protected Map<String, String[]> requestMap;
+ private JsUnitStandardServer server;
+ private MockBrowserResultRepository mockBrowserResultRepository;
+
+ public void setUp() throws Exception {
+ super.setUp();
+ Configuration configuration = new Configuration(new StubConfigurationSource() {
+
+ public String browserFileNames() {
+ return "browser1.exe,browser2.exe,browser3.exe";
+ }
+
+ public String logStatus() {
+ return String.valueOf(Boolean.FALSE);
+ }
+
+ public String url() {
+ return "http://bar";
+ }
+
+ });
+ mockBrowserResultRepository = new MockBrowserResultRepository();
+ server = new JsUnitStandardServer(configuration, mockBrowserResultRepository, false);
+ server.setProcessStarter(new MockProcessStarter());
+ requestMap = new HashMap<String, String[]>();
+ requestMap.put(BrowserResultWriter.ID, new String[]{"ID_foo"});
+ requestMap.put(BrowserResultWriter.USER_AGENT, new String[]{"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)"});
+ requestMap.put(BrowserResultWriter.TIME, new String[]{"4.3"});
+ requestMap.put(BrowserResultWriter.JSUNIT_VERSION, new String[]{"2.5"});
+ requestMap.put(BrowserResultWriter.TEST_CASES, dummyTestCaseStrings());
+ }
+
+ protected String[] dummyTestCaseStrings() {
+ return new String[]{"file:///dummy/path/dummyPage.html:testFoo|1.3|S||", "file:///dummy/path/dummyPage.html:testFoo|1.3|E|Test Error Message|", "file:///dummy/path/dummyPage.html:testFoo|1.3|F|Test Failure Message|"};
+ }
+
+ protected void submit() {
+ server.launchBrowserTestRun(new BrowserLaunchSpecification(new Browser("browser2.exe", 1)));
+ HttpServletRequest request = new DummyHttpRequest(requestMap);
+ server.accept(new BrowserResultInterceptor().build(request));
+ }
+
+ public void testSubmitResults() {
+ assertEquals(0, server.getResults().size());
+ submit();
+ assertEquals(1, server.getResults().size());
+ submit();
+ assertEquals(1, server.getResults().size());
+ }
+
+ public void testSubmittedResultHeaders() {
+ submit();
+ BrowserResult result = server.getResults().get(0);
+ assertEquals("ID_foo", result.getId());
+ assertEquals("Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)", result.getUserAgent());
+ assertEquals("2.5", result.getJsUnitVersion());
+ assertEquals(1, result.getErrorCount());
+ assertEquals(1, result.getFailureCount());
+ assertEquals(3, result.getTestCount());
+ assertEquals(4.3d, result.getTime(), .001d);
+ }
+
+ public void testSubmittedTestCaseResults() {
+ submit();
+ BrowserResult result = server.getResults().get(0);
+ assertEquals(3, result.getTestCaseResults().size());
+ }
+
+ public void testHasReceivedResultSinceDate() throws InterruptedException {
+ assertFalse(server.hasReceivedResultSince(System.currentTimeMillis()));
+ long time = System.currentTimeMillis();
+ Thread.sleep(100);
+ submit();
+ assertTrue(server.hasReceivedResultSince(time));
+ }
+
+ public void testFindResultByIdInMemoryOrOnDisk() throws InvalidBrowserIdException {
+ assertNull(server.findResultWithId("ID_foo", 1));
+ assertEquals("ID_foo", mockBrowserResultRepository.requestedId);
+ assertEquals(1, mockBrowserResultRepository.requestedBrowser.getId());
+ submit();
+ mockBrowserResultRepository.requestedId = null;
+ assertFalse(server.getResults().isEmpty());
+ assertNotNull(server.findResultWithId("ID_foo", 1));
+ assertNull(mockBrowserResultRepository.requestedId);
+ assertNull(server.findResultWithId("Invalid ID", 1));
+ assertEquals("Invalid ID", mockBrowserResultRepository.requestedId);
+ mockBrowserResultRepository.requestedId = null;
+ server.clearResults();
+ assertTrue(server.getResults().isEmpty());
+ server.findResultWithId("ID_foo", 1);
+ assertEquals("ID_foo", mockBrowserResultRepository.requestedId);
+ assertEquals(1, mockBrowserResultRepository.requestedBrowser.getId());
+ }
+
+ public void testLog() {
+ submit();
+ assertEquals("ID_foo", mockBrowserResultRepository.storedResult.getId());
+ }
+
+}
\ No newline at end of file
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/RunnerFunctionalTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/RunnerFunctionalTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/RunnerFunctionalTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,47 @@
+package net.jsunit;
+
+import net.jsunit.model.ResultType;
+import org.jdom.Document;
+
+import java.net.URLEncoder;
+
+public class RunnerFunctionalTest extends FunctionalTestCase {
+
+ public void testSimple() throws Exception {
+ webTester.beginAt("runner");
+ Document result = responseXmlDocument();
+ assertSuccessfulRunResult(
+ result,
+ ResultType.SUCCESS,
+ "http://localhost:" + port + "/jsunit/tests/jsUnitUtilityTests.html", 2);
+ }
+
+ public void testOverrideUrl() throws Exception {
+ webTester.beginAt("runner?url=" + URLEncoder.encode("http://127.0.0.1:" + port + "/jsunit/testRunner.html?testPage=http://127.0.0.1:" + port + "/jsunit/tests/jsUnitUtilityTests.html&autoRun=true&submitresults=true", "UTF-8"));
+ Document result = responseXmlDocument();
+ assertSuccessfulRunResult(
+ result,
+ ResultType.SUCCESS,
+ "http://127.0.0.1:" + port + "/jsunit/tests/jsUnitUtilityTests.html", 2);
+ }
+
+ public void testSpecifyBrowser() throws Exception {
+ webTester.beginAt("runner?browserId=0");
+ Document result = responseXmlDocument();
+ assertSuccessfulRunResult(
+ result,
+ ResultType.SUCCESS,
+ "http://localhost:" + port + "/jsunit/tests/jsUnitUtilityTests.html", 1);
+ }
+
+ public void testSpecifyInvalidBrowser() throws Exception {
+ webTester.beginAt("runner?browserId=23");
+ Document result = responseXmlDocument();
+ assertErrorResponse(result.getRootElement(), "Invalid browser ID: 23");
+ }
+
+ protected boolean shouldMockOutProcessStarter() {
+ return false;
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/ServerLandingPageFunctionalTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/ServerLandingPageFunctionalTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/ServerLandingPageFunctionalTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,81 @@
+package net.jsunit;
+
+import net.jsunit.model.Browser;
+import net.jsunit.model.BrowserResult;
+import net.jsunit.model.ResultType;
+import net.jsunit.utility.SystemUtility;
+import net.jsunit.utility.XmlUtility;
+import org.jdom.Document;
+
+public class ServerLandingPageFunctionalTest extends FunctionalTestCase {
+
+ public void testSlash() throws Exception {
+ webTester.beginAt("/");
+ assertOnLandingPage();
+ webTester.assertTextPresent(SystemUtility.osString());
+ webTester.assertTextPresent(SystemUtility.hostname());
+ webTester.assertTextPresent(SystemUtility.ipAddress());
+ webTester.assertLinkPresentWithText(new FunctionalTestConfigurationSource(port).url());
+ }
+
+ public void testIndexDotJsp() throws Exception {
+ webTester.beginAt("/index.jsp");
+ assertOnLandingPage();
+ }
+
+ public void testConfigLink() throws Exception {
+ webTester.beginAt("/");
+ webTester.clickLink("config");
+ assertConfigXml();
+ }
+
+ protected boolean shouldMockOutProcessStarter() {
+ return false;
+ }
+
+ public void testRunnerForParticularBrowser() throws Exception {
+ webTester.beginAt("/");
+ webTester.setWorkingForm("runnerForm");
+ webTester.selectOption("browserId", Browser.DEFAULT_SYSTEM_BROWSER);
+ webTester.setFormElement("url", "http://localhost:" + port + "/jsunit/testRunner.html?testPage=http://localhost:" + port + "/jsunit/tests/jsUnitAssertionTests.html");
+ webTester.submit();
+ assertSuccessfulRunResult(
+ responseXmlDocument(),
+ ResultType.SUCCESS,
+ "http://localhost:" + port + "/jsunit/tests/jsUnitAssertionTests.html",
+ 1
+ );
+ }
+
+ public void testRunnerForAllBrowsers() throws Exception {
+ webTester.beginAt("/");
+ webTester.setWorkingForm("runnerForm");
+ webTester.setFormElement("url", "http://localhost:" + port + "/jsunit/testRunner.html?testPage=http://localhost:" + port + "/jsunit/tests/jsUnitAssertionTests.html");
+ webTester.submit();
+ assertSuccessfulRunResult(
+ responseXmlDocument(),
+ ResultType.SUCCESS,
+ "http://localhost:" + port + "/jsunit/tests/jsUnitAssertionTests.html",
+ 2
+ );
+ }
+
+ public void testDisplayerForm() throws Exception {
+ server.launchBrowserTestRun(new BrowserLaunchSpecification(new Browser(Browser.DEFAULT_SYSTEM_BROWSER, 0)));
+ BrowserResult browserResult = new BrowserResult();
+ String id = String.valueOf(System.currentTimeMillis());
+ browserResult.setId(id);
+ server.accept(browserResult);
+ webTester.beginAt("/");
+ webTester.setWorkingForm("displayerForm");
+ webTester.setFormElement("id", id);
+ webTester.selectOption("browserId", Browser.DEFAULT_SYSTEM_BROWSER);
+ webTester.submit();
+ assertEquals(XmlUtility.asString(new Document(browserResult.asXml())), webTester.getDialog().getResponseText());
+ }
+
+ private void assertOnLandingPage() {
+ webTester.assertTitleEquals("JsUnit Server");
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/SpecificBrowserDistributedTestTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/SpecificBrowserDistributedTestTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/SpecificBrowserDistributedTestTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,54 @@
+package net.jsunit;
+
+import junit.framework.TestResult;
+import net.jsunit.configuration.ConfigurationSource;
+import net.jsunit.model.Browser;
+import net.jsunit.model.DistributedTestRunResult;
+import net.jsunit.model.ResultType;
+
+public class SpecificBrowserDistributedTestTest extends EndToEndTestCase {
+
+ protected ConfigurationSource farmSource() {
+ return new StubConfigurationSource() {
+ public String remoteMachineURLs() {
+ return "http://localhost:" + port;
+ }
+
+ public String port() {
+ return String.valueOf(port);
+ }
+
+ };
+ }
+
+ protected StubConfigurationSource serverSource() {
+ return new StubConfigurationSource() {
+
+ public String browserFileNames() {
+ return "invalid1.exe," + Browser.DEFAULT_SYSTEM_BROWSER + ",invalid2.exe";
+ }
+
+ public String url() {
+ return "http://localhost:" + port + "/jsunit/testRunner.html?"
+ + "testPage=http://localhost:" + port + "/jsunit/tests/jsUnitUtilityTests.html&autoRun=true&submitresults=true";
+ }
+
+ public String port() {
+ return String.valueOf(port);
+ }
+ };
+ }
+
+ public void testSuccessfulRun() {
+ DistributedTest test = new DistributedTest(serverSource(), farmSource());
+ test.limitToBrowser(new Browser(Browser.DEFAULT_SYSTEM_BROWSER, 1));
+ TestResult testResult = test.run();
+ assertTrue(testResult.wasSuccessful());
+ DistributedTestRunResult distributedTestRunResult = test.getDistributedTestRunManager().getDistributedTestRunResult();
+ assertEquals(ResultType.SUCCESS, distributedTestRunResult.getResultType());
+ assertEquals(1, distributedTestRunResult.getTestRunResults().size());
+
+ assertNull(test.getTemporaryStandardServer());
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/SuccessfulStandaloneTestTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/SuccessfulStandaloneTestTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/SuccessfulStandaloneTestTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,35 @@
+package net.jsunit;
+
+import junit.framework.TestResult;
+import net.jsunit.configuration.ConfigurationSource;
+import net.jsunit.model.Browser;
+
+public class SuccessfulStandaloneTestTest extends EndToEndTestCase {
+
+ protected ConfigurationSource configurationSource() {
+ return new StubConfigurationSource() {
+ public String browserFileNames() {
+ return Browser.DEFAULT_SYSTEM_BROWSER + "," + Browser.DEFAULT_SYSTEM_BROWSER;
+ }
+
+ public String url() {
+ return "http://localhost:" + port + "/jsunit/testRunner.html?" +
+ "testPage=http://localhost:" + port + "/jsunit/tests/jsUnitTestSuite.html" +
+ "&autoRun=true&submitresults=true&resultId=foobar";
+ }
+
+ public String port() {
+ return String.valueOf(port);
+ }
+
+ };
+ }
+
+ public void testSuccessfulRun() throws Exception {
+ StandaloneTest test = new StandaloneTest(configurationSource());
+ TestResult result = test.run();
+ assertTrue(result.wasSuccessful());
+ assertTrue(test.getServer().lastResult().wasSuccessful());
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/TestPortManager.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/TestPortManager.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/TestPortManager.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,15 @@
+package net.jsunit;
+
+public class TestPortManager {
+
+ /**
+ * Unassigned range from 48004 to 48555:
+ * @see <a href="http://www.iana.org/assignments/port-numbers">IANA Port Assignments</a>
+ */
+ private static int port = 48004;
+
+ public int newPort() {
+ return port++;
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/TestRunManagerTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/TestRunManagerTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/TestRunManagerTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,240 @@
+package net.jsunit;
+
+import junit.framework.TestCase;
+import net.jsunit.model.Browser;
+import net.jsunit.model.BrowserResult;
+import net.jsunit.model.TestRunResult;
+import net.jsunit.utility.SystemUtility;
+import org.jdom.Element;
+
+import java.util.Arrays;
+import java.util.List;
+
+public class TestRunManagerTest extends TestCase {
+
+ public void testDisposedDuringTestRun() throws InterruptedException {
+ KillableBrowserTestRunner runner = new KillableBrowserTestRunner();
+ final TestRunManager manager = new TestRunManager(runner);
+ Thread thread = new Thread() {
+ public void run() {
+ manager.runTests();
+ }
+ };
+ thread.start();
+ while (!runner.startTestRunCalled)
+ Thread.sleep(10);
+ runner.isAlive = false;
+ thread.join();
+ assertTrue(runner.finishTestRunCalled);
+ }
+
+ public void testOverrideUrl() {
+ MockBrowserTestRunner runner = new MockBrowserTestRunner();
+ runner.hasReceivedResult = true;
+ String overrideUrl = "http://my.override.url:8080/jsunit/testRunner.html?someParam=someValue&someOtherParam=someOtherValue";
+ TestRunManager manager = new TestRunManager(runner, overrideUrl);
+ manager.runTests();
+
+ assertEquals(2, runner.launchSpecs.size());
+ BrowserLaunchSpecification spec1 = runner.launchSpecs.get(0);
+ assertTrue(spec1.hasOverrideUrl());
+ assertEquals(overrideUrl, spec1.getOverrideUrl());
+ BrowserLaunchSpecification spec2 = runner.launchSpecs.get(1);
+ assertTrue(spec2.hasOverrideUrl());
+ assertEquals(overrideUrl, spec2.getOverrideUrl());
+ }
+
+ public void testNoOverrideUrl() {
+ MockBrowserTestRunner runner = new MockBrowserTestRunner();
+ runner.hasReceivedResult = true;
+ TestRunManager manager = new TestRunManager(runner, null);
+ manager.runTests();
+
+ assertEquals(2, runner.launchSpecs.size());
+ assertFalse(runner.launchSpecs.get(0).hasOverrideUrl());
+ assertFalse(runner.launchSpecs.get(1).hasOverrideUrl());
+ }
+
+ public void testPropertiesSet() throws Exception {
+ MockBrowserTestRunner runner = new MockBrowserTestRunner();
+ runner.hasReceivedResult = true;
+ TestRunManager manager = new TestRunManager(runner, null);
+ manager.runTests();
+ TestRunResult testRunResult = manager.getTestRunResult();
+ assertEquals(SystemUtility.osString(), testRunResult.getOsString());
+ assertEquals(SystemUtility.ipAddress(), testRunResult.getIpAddress());
+ assertEquals(SystemUtility.hostname(), testRunResult.getHostname());
+ }
+
+ static class SuccessfulBrowserTestRunner implements BrowserTestRunner {
+
+ public List<Browser> getBrowsers() {
+ return Arrays.asList(new Browser("browser1.exe", 0), new Browser("browser2.exe", 1));
+ }
+
+ public long launchBrowserTestRun(BrowserLaunchSpecification launchSpec) {
+ return 0;
+ }
+
+ public boolean hasReceivedResultSince(long launchTime) {
+ return true;
+ }
+
+ public BrowserResult lastResult() {
+ return new DummyBrowserResult(true, 0, 0);
+ }
+
+ public void accept(BrowserResult result) {
+ }
+
+ public void dispose() {
+ }
+
+ public BrowserResult findResultWithId(String id, int browserId) {
+ return null;
+ }
+
+ public Element asXml() {
+ return null;
+ }
+
+ public void startTestRun() {
+ }
+
+ public void finishTestRun() {
+ }
+
+ public void logStatus(String message) {
+ }
+
+ public int timeoutSeconds() {
+ return 0;
+ }
+
+ public boolean isAlive() {
+ return true;
+ }
+
+ }
+
+ static class FailingBrowserTestRunner implements BrowserTestRunner {
+
+ private Browser currentBrowser;
+
+ public List<Browser> getBrowsers() {
+ return Arrays.asList(
+ new Browser("browser1.exe", 0),
+ new Browser("browser2.exe", 1),
+ new Browser("browser3.exe", 2)
+ );
+ }
+
+ public long launchBrowserTestRun(BrowserLaunchSpecification launchSpec) {
+ currentBrowser = launchSpec.getBrowser();
+ return 0;
+ }
+
+ public boolean hasReceivedResultSince(long launchTime) {
+ return true;
+ }
+
+ public BrowserResult lastResult() {
+ if (currentBrowser.hasId(0))
+ return new DummyBrowserResult(false, 0, 1);
+ else if (currentBrowser.hasId(1))
+ return new DummyBrowserResult(false, 1, 0);
+ else
+ return new DummyBrowserResult(false, 2, 3);
+ }
+
+ public void accept(BrowserResult result) {
+ }
+
+ public void dispose() {
+ }
+
+ public BrowserResult findResultWithId(String id, int browserId) {
+ return null;
+ }
+
+ public Element asXml() {
+ return null;
+ }
+
+ public void startTestRun() {
+ }
+
+ public void finishTestRun() {
+ }
+
+ public void logStatus(String message) {
+ }
+
+ public int timeoutSeconds() {
+ return 0;
+ }
+
+ public boolean isAlive() {
+ return true;
+ }
+
+ }
+
+ static class KillableBrowserTestRunner implements BrowserTestRunner {
+
+ private boolean isAlive;
+ private boolean startTestRunCalled;
+ private boolean finishTestRunCalled;
+
+ public void startTestRun() {
+ startTestRunCalled = true;
+ }
+
+ public void finishTestRun() {
+ finishTestRunCalled = true;
+ }
+
+ public long launchBrowserTestRun(BrowserLaunchSpecification launchSpec) {
+ return 0;
+ }
+
+ public void accept(BrowserResult result) {
+ }
+
+ public boolean hasReceivedResultSince(long launchTime) {
+ return false;
+ }
+
+ public BrowserResult lastResult() {
+ return null;
+ }
+
+ public void dispose() {
+ }
+
+ public BrowserResult findResultWithId(String id, int browserId) {
+ return null;
+ }
+
+ public void logStatus(String message) {
+ }
+
+ public List<Browser> getBrowsers() {
+ return Arrays.asList(new Browser("browser1.exe", 0));
+ }
+
+ public int timeoutSeconds() {
+ return 0;
+ }
+
+ public boolean isAlive() {
+ return isAlive;
+ }
+
+ public Element asXml() {
+ return null;
+ }
+
+ }
+
+}
\ No newline at end of file
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/TimedOutBrowserStandaloneTestTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/TimedOutBrowserStandaloneTestTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/TimedOutBrowserStandaloneTestTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,40 @@
+package net.jsunit;
+
+import junit.framework.TestResult;
+import net.jsunit.configuration.ConfigurationSource;
+import net.jsunit.model.Browser;
+import net.jsunit.model.ResultType;
+
+public class TimedOutBrowserStandaloneTestTest extends EndToEndTestCase {
+
+ protected ConfigurationSource configurationSource() {
+ return new StubConfigurationSource() {
+ public String browserFileNames() {
+ return Browser.DEFAULT_SYSTEM_BROWSER;
+ }
+
+ public String url() {
+ return "http://localhost:" + port + "/jsunit/testRunner.html?" +
+ "testPage=http://localhost:" + port + "/jsunit/tests/jsUnitTestSuite.html" +
+ "&autoRun=true&submitresults=true&resultId=foobar";
+ }
+
+ public String timeoutSeconds() {
+ return "0";
+ }
+
+ public String port() {
+ return String.valueOf(port);
+ }
+
+ };
+ }
+
+ public void testBrowserTimesOut() throws Exception {
+ StandaloneTest test = new StandaloneTest(configurationSource());
+ TestResult result = test.run();
+ assertEquals(ResultType.TIMED_OUT, test.getServer().lastResult().getResultType());
+ assertFalse(result.wasSuccessful());
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/TimeoutCheckerTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/TimeoutCheckerTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/TimeoutCheckerTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,97 @@
+package net.jsunit;
+
+import junit.framework.TestCase;
+import net.jsunit.model.Browser;
+import net.jsunit.model.ResultType;
+
+import java.io.InputStream;
+import java.io.OutputStream;
+
+public class TimeoutCheckerTest extends TestCase {
+
+ private MockBrowserTestRunner mockRunner;
+ private TimeoutChecker checker;
+ private MockProcess mockProcess;
+
+ public void setUp() throws Exception {
+ super.setUp();
+ mockRunner = new MockBrowserTestRunner();
+ mockRunner.timeoutSeconds = Integer.MAX_VALUE;
+ mockProcess = new MockProcess();
+ checker = new TimeoutChecker(mockProcess, new Browser("mybrowser.exe", 0), 1, mockRunner, 1);
+ checker.start();
+ }
+
+ public void tearDown() throws Exception {
+ if (checker != null && checker.isAlive()) {
+ checker.die();
+ }
+ super.tearDown();
+ }
+
+ public void testInitialConditions() {
+ assertTrue(checker.isAlive());
+ }
+
+ public void testDie() throws InterruptedException {
+ checker.die();
+ Thread.sleep(10);
+ assertFalse(checker.isAlive());
+ }
+
+ public void testTimeOut() throws InterruptedException {
+ mockRunner.timeoutSeconds = 0;
+ while (mockRunner.acceptedResult == null)
+ Thread.sleep(10);
+ assertEquals(ResultType.TIMED_OUT, mockRunner.acceptedResult.getResultType());
+ }
+
+ public void testNotTimeOut() throws InterruptedException {
+ mockRunner.hasReceivedResult = true;
+ while (checker.isAlive())
+ Thread.sleep(10);
+ assertFalse(checker.isAlive());
+ }
+
+ public void xtestExternallyShutDown() throws InterruptedException {
+ assertFalse(mockRunner.hasReceivedResult);
+ mockProcess.done = true;
+ while (mockRunner.acceptedResult == null)
+ Thread.sleep(10);
+ assertTrue(mockRunner.acceptedResult.externallyShutDown());
+ assertFalse(checker.isAlive());
+ }
+
+ static class MockProcess extends Process {
+
+ private boolean done = false;
+
+ public OutputStream getOutputStream() {
+ return null;
+ }
+
+ public InputStream getInputStream() {
+ return null;
+ }
+
+ public InputStream getErrorStream() {
+ return null;
+ }
+
+ public int waitFor() throws InterruptedException {
+ return 0;
+ }
+
+ public int exitValue() {
+ if (!done)
+ throw new IllegalThreadStateException();
+ else
+ return 0;
+ }
+
+ public void destroy() {
+ }
+
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/TwoValidLocalhostsDistributedTestTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/TwoValidLocalhostsDistributedTestTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/TwoValidLocalhostsDistributedTestTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,87 @@
+package net.jsunit;
+
+import junit.framework.TestResult;
+import net.jsunit.configuration.Configuration;
+import net.jsunit.configuration.ConfigurationSource;
+import net.jsunit.model.Browser;
+import net.jsunit.model.DistributedTestRunResult;
+import net.jsunit.model.ResultType;
+
+public class TwoValidLocalhostsDistributedTestTest extends EndToEndTestCase {
+ private JsUnitStandardServer secondServer;
+ private int otherPort;
+
+ public void setUp() throws Exception {
+ super.setUp();
+ otherPort = new TestPortManager().newPort();
+ secondServer = new JsUnitStandardServer(new Configuration(secondServerSource()), false);
+ secondServer.start();
+ }
+
+ protected void tearDown() throws Exception {
+ if (secondServer != null)
+ secondServer.dispose();
+ super.tearDown();
+ }
+
+ protected ConfigurationSource farmSource() {
+ return new StubConfigurationSource() {
+ public String remoteMachineURLs() {
+ return "http://localhost:" + port + ", http://localhost:" + otherPort;
+ }
+
+ public String port() {
+ return String.valueOf(port);
+ }
+
+ };
+ }
+
+ protected StubConfigurationSource serverSource() {
+ return new StubConfigurationSource() {
+
+ public String browserFileNames() {
+ return Browser.DEFAULT_SYSTEM_BROWSER;
+ }
+
+ public String url() {
+ return "http://localhost:" + port + "/jsunit/testRunner.html?"
+ + "testPage=http://localhost:" + port + "/jsunit/tests/jsUnitUtilityTests.html&autoRun=true&submitresults=true";
+ }
+
+ public String port() {
+ return String.valueOf(port);
+ }
+ };
+ }
+
+ protected StubConfigurationSource secondServerSource() {
+ return new StubConfigurationSource() {
+
+ public String browserFileNames() {
+ return Browser.DEFAULT_SYSTEM_BROWSER;
+ }
+
+ public String url() {
+ return "http://localhost:" + port + "/jsunit/testRunner.html?"
+ + "testPage=http://localhost:" + port + "/jsunit/tests/jsUnitUtilityTests.html&autoRun=true&submitresults=true";
+ }
+
+ public String port() {
+ return String.valueOf(otherPort);
+ }
+ };
+ }
+
+ public void testSuccessfulRun() {
+ DistributedTest test = new DistributedTest(serverSource(), farmSource());
+ TestResult testResult = test.run();
+ assertTrue(testResult.wasSuccessful());
+ DistributedTestRunResult distributedTestRunResult = test.getDistributedTestRunManager().getDistributedTestRunResult();
+ assertEquals(ResultType.SUCCESS, distributedTestRunResult.getResultType());
+ assertEquals(2, distributedTestRunResult.getTestRunResults().size());
+
+ assertNull(test.getTemporaryStandardServer());
+ }
+
+}
\ No newline at end of file
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/UnitTestSuite.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/UnitTestSuite.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/UnitTestSuite.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,14 @@
+package net.jsunit;
+
+import junit.framework.TestSuite;
+
+public class UnitTestSuite {
+
+ public static TestSuite suite() {
+ TestSuite result = new TestSuite();
+ result.addTest(PureUnitTestSuite.suite());
+ result.addTest(ImpureUnitTestSuite.suite());
+ return result;
+ }
+
+}
\ No newline at end of file
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/UrlOverrideStandaloneTestTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/UrlOverrideStandaloneTestTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/UrlOverrideStandaloneTestTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,35 @@
+package net.jsunit;
+
+import junit.framework.TestResult;
+import net.jsunit.configuration.ConfigurationSource;
+import net.jsunit.model.Browser;
+
+public class UrlOverrideStandaloneTestTest extends EndToEndTestCase {
+
+ protected ConfigurationSource configurationSource() {
+ return new StubConfigurationSource() {
+ public String browserFileNames() {
+ return Browser.DEFAULT_SYSTEM_BROWSER;
+ }
+
+ public String url() {
+ return "http://www.example.com";
+ }
+
+ public String port() {
+ return String.valueOf(port);
+ }
+
+ };
+ }
+
+ public void testOverridenURL() throws Exception {
+ StandaloneTest test = new StandaloneTest(configurationSource());
+ test.setOverrideURL(
+ "http://localhost:" + port + "/jsunit/testRunner.html?testPage=http://localhost:" + port + "/jsunit/tests/jsUnitUtilityTests.html&autoRun=true&submitresults=true&resultId=foobar");
+ TestResult testResult = test.run();
+ assertTrue(testResult.wasSuccessful());
+ assertTrue(test.getServer().lastResult().wasSuccessful());
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/action/BlockingTestRunner.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/action/BlockingTestRunner.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/action/BlockingTestRunner.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,69 @@
+package net.jsunit.action;
+
+import net.jsunit.BrowserLaunchSpecification;
+import net.jsunit.BrowserTestRunner;
+import net.jsunit.model.Browser;
+import net.jsunit.model.BrowserResult;
+import org.jdom.Element;
+
+import java.util.Arrays;
+import java.util.List;
+
+public class BlockingTestRunner implements BrowserTestRunner {
+ public boolean blocked;
+
+ public Element asXml() {
+ return null;
+ }
+
+ public void startTestRun() {
+ blocked = true;
+ while (blocked) {
+ try {
+ Thread.sleep(10);
+ } catch (InterruptedException e) {
+ }
+ }
+ }
+
+ public void finishTestRun() {
+ }
+
+ public long launchBrowserTestRun(BrowserLaunchSpecification launchSpec) {
+ return 0;
+ }
+
+ public void accept(BrowserResult result) {
+ }
+
+ public boolean hasReceivedResultSince(long launchTime) {
+ return false;
+ }
+
+ public BrowserResult lastResult() {
+ return null;
+ }
+
+ public void dispose() {
+ }
+
+ public BrowserResult findResultWithId(String id, int browserId) {
+ return null;
+ }
+
+ public void logStatus(String message) {
+ }
+
+ public List<Browser> getBrowsers() {
+ return Arrays.asList(new Browser[]{new Browser("browser.exe", 0)});
+ }
+
+ public int timeoutSeconds() {
+ return 0;
+ }
+
+ public boolean isAlive() {
+ return false;
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/action/DistributedTestRunnerActionTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/action/DistributedTestRunnerActionTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/action/DistributedTestRunnerActionTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,44 @@
+package net.jsunit.action;
+
+import junit.framework.TestCase;
+import net.jsunit.DummyConfigurationSource;
+import net.jsunit.JsUnitFarmServer;
+import net.jsunit.RemoteServerHitter;
+import net.jsunit.configuration.Configuration;
+import net.jsunit.model.TestRunResult;
+import org.jdom.Document;
+
+import java.net.URL;
+
+public class DistributedTestRunnerActionTest extends TestCase {
+
+ private DistributedTestRunnerAction action;
+
+ public void setUp() throws Exception {
+ super.setUp();
+ action = new DistributedTestRunnerAction();
+ action.setFarmServer(new JsUnitFarmServer(new Configuration(new DummyConfigurationSource())));
+ action.setRemoteRunnerHitter(new SuccessfulRemoteServerHitter());
+ }
+
+ public void testSimple() throws Exception {
+ assertEquals(DistributedTestRunnerAction.SUCCESS, action.execute());
+ assertTrue(action.getTestRunManager().getDistributedTestRunResult().wasSuccessful());
+ assertNull(action.getTestRunManager().getOverrideURL());
+ }
+
+ public void testOverrideURL() throws Exception {
+ String overrideURL = "http://overrideurl.com:1234?foo=bar&bar=fo";
+ action.setUrl(overrideURL);
+ assertEquals(DistributedTestRunnerAction.SUCCESS, action.execute());
+ assertEquals(overrideURL, action.getTestRunManager().getOverrideURL());
+ }
+
+ static class SuccessfulRemoteServerHitter implements RemoteServerHitter {
+
+ public Document hitURL(URL url) {
+ return new Document(new TestRunResult().asXml());
+ }
+
+ }
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/action/ErrorXmlRenderableTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/action/ErrorXmlRenderableTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/action/ErrorXmlRenderableTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,12 @@
+package net.jsunit.action;
+
+import junit.framework.TestCase;
+import net.jsunit.utility.XmlUtility;
+
+public class ErrorXmlRenderableTest extends TestCase {
+
+ public void testSimple() throws Exception {
+ ErrorXmlRenderable renderable = new ErrorXmlRenderable("a message");
+ assertEquals("<error>a message</error>", XmlUtility.asString(renderable.asXml()));
+ }
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/action/FarmServerConfigurationActionTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/action/FarmServerConfigurationActionTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/action/FarmServerConfigurationActionTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,108 @@
+package net.jsunit.action;
+
+import junit.framework.TestCase;
+import net.jsunit.BlowingUpRemoteServerHitter;
+import net.jsunit.DummyConfigurationSource;
+import net.jsunit.JsUnitFarmServer;
+import net.jsunit.MockRemoteServerHitter;
+import net.jsunit.configuration.Configuration;
+import net.jsunit.configuration.ServerType;
+import net.jsunit.utility.XmlUtility;
+import org.jdom.CDATA;
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jdom.filter.Filter;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+public class FarmServerConfigurationActionTest extends TestCase {
+
+ private FarmServerConfigurationAction action;
+
+ public void setUp() throws Exception {
+ super.setUp();
+ action = new FarmServerConfigurationAction();
+ Configuration configuration = new Configuration(new DummyConfigurationSource());
+ JsUnitFarmServer server = new JsUnitFarmServer(configuration);
+ action.setFarmServer(server);
+ }
+
+ public void testSimple() throws Exception {
+ MockRemoteServerHitter mockHitter = new MockRemoteServerHitter();
+ Configuration configuration1 = configuration1();
+ Configuration configuration2 = configuration2();
+ mockHitter.urlToDocument.put(DummyConfigurationSource.REMOTE_URL_1 + "/config", new Document(configuration1.asXml(ServerType.FARM)));
+ mockHitter.urlToDocument.put(DummyConfigurationSource.REMOTE_URL_2 + "/config", new Document(configuration2.asXml(ServerType.FARM)));
+ action.setRemoteRunnerHitter(mockHitter);
+ action.execute();
+ assertEquals(2, mockHitter.urlsPassed.size());
+ String xml = XmlUtility.asString(action.getXmlRenderable().asXml());
+ assertEquals(
+ "<remoteConfigurations>" +
+ "<remoteConfiguration remoteMachineURL=\"" + DummyConfigurationSource.REMOTE_URL_1 + "\">" +
+ XmlUtility.asString(configuration1.asXml(ServerType.FARM)) +
+ "</remoteConfiguration>" +
+ "<remoteConfiguration remoteMachineURL=\"" + DummyConfigurationSource.REMOTE_URL_2 + "\">" +
+ XmlUtility.asString(configuration2.asXml(ServerType.FARM)) +
+ "</remoteConfiguration>" +
+ "</remoteConfigurations>",
+ xml
+ );
+ }
+
+ public void testCrashingRemoteURLs() throws Exception {
+ action.setRemoteRunnerHitter(new BlowingUpRemoteServerHitter());
+ action.execute();
+ Element rootElement = action.getXmlRenderable().asXml();
+ List<CDATA> stackTraceElements = getCDATAExceptionStackTracesUnder(rootElement);
+ assertEquals(2, stackTraceElements.size());
+ for (CDATA stackTraceElement : stackTraceElements)
+ stackTraceElement.detach();
+
+ String xml = XmlUtility.asString(rootElement);
+ assertEquals(
+ "<remoteConfigurations>" +
+ "<remoteConfiguration remoteMachineURL=\"" + DummyConfigurationSource.REMOTE_URL_1 + "\">" +
+ "<configuration failedToConnect=\"true\" />" +
+ "</remoteConfiguration>" +
+ "<remoteConfiguration remoteMachineURL=\"" + DummyConfigurationSource.REMOTE_URL_2 + "\">" +
+ "<configuration failedToConnect=\"true\" />" +
+ "</remoteConfiguration>" +
+ "</remoteConfigurations>",
+ xml
+ );
+ }
+
+ private List<CDATA> getCDATAExceptionStackTracesUnder(Element rootElement) {
+ Iterator it = rootElement.getDescendants(new Filter() {
+ public boolean matches(Object arg0) {
+ return arg0 instanceof CDATA;
+ }
+ });
+ List<CDATA> stackTraceElements = new ArrayList<CDATA>();
+ while (it.hasNext()) {
+ CDATA next = (CDATA) it.next();
+ stackTraceElements.add(next);
+ }
+ return stackTraceElements;
+ }
+
+ private Configuration configuration2() {
+ return new Configuration(new DummyConfigurationSource() {
+ public String url() {
+ return "http://www.2.example.com";
+ }
+ });
+ }
+
+ private Configuration configuration1() {
+ return new Configuration(new DummyConfigurationSource() {
+ public String url() {
+ return "http://www.1.example.com";
+ }
+ });
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/action/LatestVersionActionTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/action/LatestVersionActionTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/action/LatestVersionActionTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,26 @@
+package net.jsunit.action;
+
+import junit.framework.TestCase;
+import net.jsunit.version.MockVersionGrabber;
+import net.jsunit.version.BlowingUpVersionGrabber;
+
+public class LatestVersionActionTest extends TestCase {
+ private LatestVersionAction action;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ action = new LatestVersionAction();
+ }
+
+ public void testGetLatestVersion() throws Exception {
+ action.setVersionGrabber(new MockVersionGrabber(43.21));
+ assertEquals(LatestVersionAction.SUCCESS, action.execute());
+ assertEquals(43.21, action.getLatestVersion());
+ }
+
+ public void testBlowUp() throws Exception {
+ action.setVersionGrabber(new BlowingUpVersionGrabber());
+ assertEquals(LatestVersionAction.ERROR, action.execute());
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/action/ResultAcceptorActionTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/action/ResultAcceptorActionTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/action/ResultAcceptorActionTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,18 @@
+package net.jsunit.action;
+
+import junit.framework.TestCase;
+import net.jsunit.DummyBrowserResult;
+import net.jsunit.MockBrowserTestRunner;
+
+public class ResultAcceptorActionTest extends TestCase {
+
+ public void testSimple() throws Exception {
+ ResultAcceptorAction action = new ResultAcceptorAction();
+ DummyBrowserResult dummyResult = new DummyBrowserResult(false, 1, 2);
+ action.setBrowserResult(dummyResult);
+ MockBrowserTestRunner mockRunner = new MockBrowserTestRunner();
+ action.setBrowserTestRunner(mockRunner);
+ assertEquals(ResultAcceptorAction.SUCCESS, action.execute());
+ assertSame(dummyResult, mockRunner.acceptedResult);
+ }
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/action/ResultDisplayerActionTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/action/ResultDisplayerActionTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/action/ResultDisplayerActionTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,62 @@
+package net.jsunit.action;
+
+import junit.framework.TestCase;
+import net.jsunit.InvalidBrowserIdException;
+import net.jsunit.MockBrowserTestRunner;
+import net.jsunit.model.BrowserResult;
+import net.jsunit.utility.XmlUtility;
+
+public class ResultDisplayerActionTest extends TestCase {
+
+ private ResultDisplayerAction action;
+ private MockBrowserTestRunner mockRunner;
+
+ public void setUp() throws Exception {
+ super.setUp();
+ action = new ResultDisplayerAction();
+ mockRunner = new MockBrowserTestRunner();
+ action.setBrowserTestRunner(mockRunner);
+ action.setId("12345");
+ action.setBrowserId(8);
+ }
+
+ public void testResultFound() throws Exception {
+ mockRunner.resultToReturn = new BrowserResult();
+ assertEquals(ResultDisplayerAction.SUCCESS, action.execute());
+ assertEquals("12345", mockRunner.idPassed);
+ assertEquals(8, mockRunner.browserIdPassed.intValue());
+ assertEquals(mockRunner.resultToReturn, action.getXmlRenderable());
+ }
+
+ public void testResultNotFound() throws Exception {
+ assertEquals(ResultDisplayerAction.SUCCESS, action.execute());
+ assertEquals("12345", mockRunner.idPassed);
+ assertEquals(8, mockRunner.browserIdPassed.intValue());
+ assertEquals("<error>No Test Result has been submitted with ID '12345' for browser ID '8'</error>", XmlUtility.asString(action.getXmlRenderable().asXml()));
+ }
+
+ public void testIdNotGiven() throws Exception {
+ action.setId(null);
+ action.setBrowserId(null);
+ assertEquals(ResultDisplayerAction.ERROR, action.execute());
+ assertNull(mockRunner.idPassed);
+ assertNull(mockRunner.browserIdPassed);
+ assertEquals("<error>A Test Result ID and a browser ID must both be given</error>", XmlUtility.asString(action.getXmlRenderable().asXml()));
+ }
+
+ public void testInvalidBrowserId() throws Exception {
+ action.setId("54321");
+ action.setBrowserId(12345);
+ mockRunner = new MockBrowserTestRunner() {
+ public BrowserResult findResultWithId(String id, int browserId) throws InvalidBrowserIdException {
+ super.findResultWithId(id, browserId);
+ throw new InvalidBrowserIdException(browserId);
+ }
+ };
+ action.setBrowserTestRunner(mockRunner);
+ assertEquals(ResultDisplayerAction.ERROR, action.execute());
+ assertEquals("54321", this.mockRunner.idPassed);
+ assertEquals(12345, this.mockRunner.browserIdPassed.intValue());
+ assertEquals("<error>Invalid Browser ID '12345'</error>", XmlUtility.asString(action.getXmlRenderable().asXml()));
+ }
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/action/TestRunnerActionSimultaneousRunBlockingTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/action/TestRunnerActionSimultaneousRunBlockingTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/action/TestRunnerActionSimultaneousRunBlockingTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,60 @@
+package net.jsunit.action;
+
+import junit.framework.TestCase;
+
+public class TestRunnerActionSimultaneousRunBlockingTest extends TestCase {
+ private BlockingTestRunner runner;
+ private TestRunnerAction action1;
+ private TestRunnerAction action2;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+ runner = new BlockingTestRunner();
+ action1 = new TestRunnerAction();
+ action1.setBrowserTestRunner(runner);
+ action2 = new TestRunnerAction();
+ action2.setBrowserTestRunner(runner);
+ }
+
+ public void testSimultaneousRequestsAreQueued() throws Exception {
+ Executor executor1 = new Executor(action1);
+ executor1.start();
+ waitTillRunnerIsBlocked(runner);
+ Executor executor2 = new Executor(action2);
+ executor2.start();
+ runner.blocked = false;
+ waitTillExecutorIsDead(executor1);
+ waitTillRunnerIsBlocked(runner);
+ runner.blocked = false;
+ waitTillExecutorIsDead(executor2);
+ }
+
+ private void waitTillExecutorIsDead(Executor executor) throws InterruptedException {
+ while (executor.isAlive())
+ Thread.sleep(10);
+ }
+
+ private void waitTillRunnerIsBlocked(BlockingTestRunner runner) throws InterruptedException {
+ while (!runner.blocked) {
+ Thread.sleep(10);
+ }
+ }
+
+ class Executor extends Thread {
+
+ private TestRunnerAction action;
+
+ public Executor(TestRunnerAction action) {
+ this.action = action;
+
+ }
+
+ public void run() {
+ try {
+ action.execute();
+ } catch (Exception e) {
+ fail();
+ }
+ }
+ }
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/action/TestRunnerActionTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/action/TestRunnerActionTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/action/TestRunnerActionTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,98 @@
+package net.jsunit.action;
+
+import junit.framework.TestCase;
+import net.jsunit.BrowserLaunchSpecification;
+import net.jsunit.MockBrowserTestRunner;
+import net.jsunit.model.ResultType;
+import net.jsunit.utility.XmlUtility;
+
+public class TestRunnerActionTest extends TestCase {
+
+ private TestRunnerAction action;
+ private MockBrowserTestRunner mockRunner;
+
+ public void setUp() throws Exception {
+ super.setUp();
+ action = new TestRunnerAction();
+ mockRunner = new MockBrowserTestRunner();
+ mockRunner.hasReceivedResult = true;
+ action.setBrowserTestRunner(mockRunner);
+ }
+
+ public void testSuccess() throws Exception {
+ mockRunner.shouldSucceed = true;
+ assertEquals(TestRunnerAction.SUCCESS, action.execute());
+ String xmlString = XmlUtility.asString(action.getXmlRenderable().asXml());
+ assertTrue(xmlString.startsWith("<testRunResult type=\"" + ResultType.SUCCESS.name()));
+ }
+
+ public void testFailure() throws Exception {
+ mockRunner.shouldSucceed = false;
+ assertEquals(TestRunnerAction.SUCCESS, action.execute());
+ String xmlString = XmlUtility.asString(action.getXmlRenderable().asXml());
+ assertTrue(xmlString.startsWith("<testRunResult type=\"" + ResultType.FAILURE.name()));
+ }
+
+ public void testOverrideUrl() throws Exception {
+ String overrideUrl = "http://www.example.com:8954/jsunit/testRunner.html?testPage=http://www.example.com:8954/tests/myTests.html?autoRun=true&submitResults=http://www.example.com:8954/tests";
+ action.setUrl(overrideUrl);
+ assertEquals(TestRunnerAction.SUCCESS, action.execute());
+ assertEquals(2, mockRunner.launchSpecs.size());
+ BrowserLaunchSpecification spec1 = mockRunner.launchSpecs.get(0);
+ BrowserLaunchSpecification spec2 = mockRunner.launchSpecs.get(1);
+ assertTrue(spec1.hasOverrideUrl());
+ assertEquals(overrideUrl, spec1.getOverrideUrl());
+ assertTrue(spec2.hasOverrideUrl());
+ assertEquals(overrideUrl, spec2.getOverrideUrl());
+ }
+
+ public void testRequestIpAddressAndHostLogged() throws Exception {
+ action.execute();
+ assertEquals("Received request to run tests", mockRunner.logMessages.get(0));
+
+ mockRunner.logMessages.clear();
+ action.setRequestIPAddress("123.456.78.9");
+ action.execute();
+ assertEquals("Received request to run tests from 123.456.78.9", mockRunner.logMessages.get(0));
+
+ mockRunner.logMessages.clear();
+ action.setRequestHost("www.example.com");
+ action.execute();
+ assertEquals("Received request to run tests from www.example.com (123.456.78.9)", mockRunner.logMessages.get(0));
+
+ mockRunner.logMessages.clear();
+ action.setRequestIPAddress("");
+ action.execute();
+ assertEquals("Received request to run tests from www.example.com", mockRunner.logMessages.get(0));
+
+ mockRunner.logMessages.clear();
+ action.setRequestIPAddress("12.34.56.78");
+ action.setRequestHost("12.34.56.78");
+ action.execute();
+ assertEquals("Received request to run tests from 12.34.56.78", mockRunner.logMessages.get(0));
+ }
+
+ public void testLimitToParticularBrowser() throws Exception {
+ action.setBrowserId("1");
+ assertEquals(TestRunnerAction.SUCCESS, action.execute());
+ assertEquals(1, mockRunner.launchSpecs.size());
+ assertEquals("mybrowser2.exe", mockRunner.launchSpecs.get(0).getBrowser().getFileName());
+ }
+
+ public void testLimitToBrowserWithBadId() throws Exception {
+ action.setBrowserId("34");
+ action.execute();
+ assertEquals(TestRunnerAction.ERROR, action.execute());
+ assertTrue(mockRunner.launchSpecs.isEmpty());
+ assertEquals("<error>Invalid browser ID: 34</error>", XmlUtility.asString(action.getXmlRenderable().asXml()));
+ }
+
+ public void testLimitToBrowserWithNonIntegerId() throws Exception {
+ action.setBrowserId("foo");
+ action.execute();
+ assertEquals(TestRunnerAction.ERROR, action.execute());
+ assertTrue(mockRunner.launchSpecs.isEmpty());
+ assertEquals("<error>Invalid browser ID: foo</error>", XmlUtility.asString(action.getXmlRenderable().asXml()));
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/interceptor/BrowserResultInterceptorTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/interceptor/BrowserResultInterceptorTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/interceptor/BrowserResultInterceptorTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,56 @@
+package net.jsunit.interceptor;
+
+import com.opensymphony.webwork.ServletActionContext;
+import com.opensymphony.xwork.Action;
+import junit.framework.TestCase;
+import net.jsunit.DummyHttpRequest;
+import net.jsunit.action.BrowserResultAware;
+import net.jsunit.model.BrowserResult;
+import net.jsunit.model.BrowserResultWriter;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.HashMap;
+import java.util.Map;
+
+public class BrowserResultInterceptorTest extends TestCase {
+
+ public void setUp() throws Exception {
+ super.setUp();
+ Map<String, String[]> requestMap = new HashMap<String, String[]>();
+ requestMap.put(BrowserResultWriter.ID, new String[]{"ID_foo"});
+ requestMap.put(BrowserResultWriter.USER_AGENT, new String[]{"user agent"});
+ requestMap.put(BrowserResultWriter.TIME, new String[]{"4.3"});
+ requestMap.put(BrowserResultWriter.JSUNIT_VERSION, new String[]{"2.5"});
+ requestMap.put(BrowserResultWriter.TEST_CASES, new String[]{"file:///dummy/path/dummyPage.html:testFoo|1.3|S||"});
+ HttpServletRequest request = new DummyHttpRequest(requestMap);
+ ServletActionContext.setRequest(request);
+ }
+
+ public void tearDown() throws Exception {
+ ServletActionContext.setRequest(null);
+ super.tearDown();
+ }
+
+ public void testSimple() throws Exception {
+ BrowserResultInterceptor interceptor = new BrowserResultInterceptor();
+ MockAction action = new MockAction();
+ MockActionInvocation invocation = new MockActionInvocation(action);
+ interceptor.intercept(invocation);
+ assertEquals("ID_foo", action.result.getId());
+ }
+
+ static class MockAction implements Action, BrowserResultAware {
+
+ private BrowserResult result;
+
+ public String execute() throws Exception {
+ return null;
+ }
+
+ public void setBrowserResult(BrowserResult result) {
+ this.result = result;
+ }
+
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/interceptor/BrowserTestRunnerInterceptorTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/interceptor/BrowserTestRunnerInterceptorTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/interceptor/BrowserTestRunnerInterceptorTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,47 @@
+package net.jsunit.interceptor;
+
+import junit.framework.TestCase;
+import net.jsunit.BrowserTestRunner;
+import net.jsunit.MockBrowserTestRunner;
+import net.jsunit.XmlRenderable;
+import net.jsunit.action.JsUnitBrowserTestRunnerAction;
+
+public class BrowserTestRunnerInterceptorTest extends TestCase {
+
+ public void testSimple() throws Exception {
+ MockJsUnitAction action = new MockJsUnitAction();
+ final BrowserTestRunner mockRunner = new MockBrowserTestRunner();
+ BrowserTestRunnerInterceptor.setBrowserTestRunnerSource(new BrowserTestRunnerSource() {
+ public BrowserTestRunner getRunner() {
+ return mockRunner;
+ }
+
+ });
+ assertNull(action.getBrowserTestRunner());
+ BrowserTestRunnerInterceptor interceptor = new BrowserTestRunnerInterceptor();
+
+ MockActionInvocation mockInvocation = new MockActionInvocation(action);
+ interceptor.intercept(mockInvocation);
+
+ assertSame(mockRunner, action.getBrowserTestRunner());
+ assertTrue(mockInvocation.wasInvokeCalled);
+ }
+
+ public void tearDown() throws Exception {
+ BrowserTestRunnerInterceptor.setBrowserTestRunnerSource(new DefaultBrowserTestRunnerSource());
+ super.tearDown();
+ }
+
+ static class MockJsUnitAction extends JsUnitBrowserTestRunnerAction {
+
+ public String execute() throws Exception {
+ return null;
+ }
+
+ public XmlRenderable getXmlRenderable() {
+ return null;
+ }
+
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/interceptor/FarmServerInterceptorTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/interceptor/FarmServerInterceptorTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/interceptor/FarmServerInterceptorTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,37 @@
+package net.jsunit.interceptor;
+
+import com.opensymphony.xwork.Action;
+import junit.framework.TestCase;
+import net.jsunit.DummyConfigurationSource;
+import net.jsunit.JsUnitFarmServer;
+import net.jsunit.action.JsUnitServerAware;
+import net.jsunit.configuration.Configuration;
+
+public class FarmServerInterceptorTest extends TestCase {
+
+ public void testSimple() throws Exception {
+ MockAction action = new MockAction();
+ JsUnitFarmServer server = new JsUnitFarmServer(new Configuration(new DummyConfigurationSource()));
+ assertNull(action.farmServer);
+ FarmServerInterceptor interceptor = new FarmServerInterceptor();
+
+ MockActionInvocation mockInvocation = new MockActionInvocation(action);
+ interceptor.intercept(mockInvocation);
+
+ assertSame(server, action.farmServer);
+ assertTrue(mockInvocation.wasInvokeCalled);
+ }
+
+ static class MockAction implements Action, JsUnitServerAware {
+ public JsUnitFarmServer farmServer;
+
+ public String execute() throws Exception {
+ return null;
+ }
+
+ public void setFarmServer(JsUnitFarmServer farmServer) {
+ this.farmServer = farmServer;
+ }
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/interceptor/MockActionInvocation.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/interceptor/MockActionInvocation.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/interceptor/MockActionInvocation.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,59 @@
+package net.jsunit.interceptor;
+
+import com.opensymphony.xwork.*;
+import com.opensymphony.xwork.interceptor.PreResultListener;
+import com.opensymphony.xwork.util.OgnlValueStack;
+
+public class MockActionInvocation implements ActionInvocation {
+
+ private Action action;
+ public boolean wasInvokeCalled;
+
+ public MockActionInvocation(Action action) {
+ this.action = action;
+ }
+
+ public Action getAction() {
+ return action;
+ }
+
+ public boolean isExecuted() {
+ return false;
+ }
+
+ public ActionContext getInvocationContext() {
+ return null;
+ }
+
+ public ActionProxy getProxy() {
+ return null;
+ }
+
+ public Result getResult() throws Exception {
+ return null;
+ }
+
+ public String getResultCode() {
+ return null;
+ }
+
+ public void setResultCode(String string) {
+ }
+
+ public OgnlValueStack getStack() {
+ return null;
+ }
+
+ public void addPreResultListener(PreResultListener arg0) {
+ }
+
+ public String invoke() throws Exception {
+ wasInvokeCalled = true;
+ return null;
+ }
+
+ public String invokeActionOnly() throws Exception {
+ return null;
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/interceptor/RemoteRunnerHitterInterceptorTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/interceptor/RemoteRunnerHitterInterceptorTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/interceptor/RemoteRunnerHitterInterceptorTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,34 @@
+package net.jsunit.interceptor;
+
+import com.opensymphony.xwork.Action;
+import junit.framework.TestCase;
+import net.jsunit.RemoteMachineServerHitter;
+import net.jsunit.RemoteServerHitter;
+import net.jsunit.action.RemoteRunnerHitterAware;
+
+public class RemoteRunnerHitterInterceptorTest extends TestCase {
+
+ public void testSimple() throws Exception {
+ RemoteRunnerHitterInterceptor interceptor = new RemoteRunnerHitterInterceptor();
+ MockAction action = new MockAction();
+ MockActionInvocation invocation = new MockActionInvocation(action);
+ interceptor.intercept(invocation);
+ assertNotNull(action.hitter);
+ assertTrue(action.hitter instanceof RemoteMachineServerHitter);
+ }
+
+ static class MockAction implements RemoteRunnerHitterAware, Action {
+
+ private RemoteServerHitter hitter;
+
+ public String execute() throws Exception {
+ return null;
+ }
+
+ public void setRemoteRunnerHitter(RemoteServerHitter hitter) {
+ this.hitter = hitter;
+ }
+
+ }
+
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/interceptor/RequestSourceInterceptorTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/interceptor/RequestSourceInterceptorTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/interceptor/RequestSourceInterceptorTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,44 @@
+package net.jsunit.interceptor;
+
+import com.opensymphony.webwork.ServletActionContext;
+import com.opensymphony.xwork.Action;
+import junit.framework.TestCase;
+import net.jsunit.DummyHttpRequest;
+import net.jsunit.action.RequestSourceAware;
+
+import java.util.HashMap;
+
+public class RequestSourceInterceptorTest extends TestCase {
+
+ public void testSimple() throws Exception {
+ DummyHttpRequest request = new DummyHttpRequest(new HashMap());
+ request.setIpAddress("123.456.78.9");
+ request.setHost("www.example.com");
+ ServletActionContext.setRequest(request);
+ RequestSourceInterceptor interceptor = new RequestSourceInterceptor();
+ RequestSourceAction action = new RequestSourceAction();
+ MockActionInvocation invocation = new MockActionInvocation(action);
+ interceptor.intercept(invocation);
+ assertTrue(invocation.wasInvokeCalled);
+
+ assertEquals("123.456.78.9", action.ipAddress);
+ assertEquals("www.example.com", action.host);
+ }
+
+ static class RequestSourceAction implements RequestSourceAware, Action {
+ private String ipAddress;
+ private String host;
+
+ public void setRequestIPAddress(String ipAddress) {
+ this.ipAddress = ipAddress;
+ }
+
+ public void setRequestHost(String host) {
+ this.host = host;
+ }
+
+ public String execute() throws Exception {
+ return null;
+ }
+ }
+}
Added: branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/interceptor/VersionGrabberInterceptorTest.java
===================================================================
--- branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/interceptor/VersionGrabberInterceptorTest.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/java/tests_server/net/jsunit/interceptor/VersionGrabberInterceptorTest.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,32 @@
+package net.jsunit.interceptor;
+
+import junit.framework.TestCase;
+import com.opensymphony.xwork.Action;
+import net.jsunit.action.VersionGrabberAware;
+import net.jsunit.version.VersionGrabber;
+import net.jsunit.version.JsUnitWebsiteVersionGrabber;
+
+public class VersionGrabberInterceptorTest extends TestCase {
+
+ public void testSimple() throws Exception {
+ VersionGrabberInterceptor interceptor = new VersionGrabberInterceptor();
+ VersionGrabberAction action = new VersionGrabberAction();
+ MockActionInvocation invocation = new MockActionInvocation(action);
+ interceptor.intercept(invocation);
+ assertNotNull(action.versionGrabber);
+ assertTrue(action.versionGrabber instanceof JsUnitWebsiteVersionGrabber);
+ assertTrue(invocation.wasInvokeCalled);
+ }
+
+ static class VersionGrabberAction implements Action, VersionGrabberAware {
+ private VersionGrabber versionGrabber;
+
+ public String execute() throws Exception {
+ return null;
+ }
+
+ public void setVersionGrabber(VersionGrabber versionGrabber) {
+ this.versionGrabber = versionGrabber;
+ }
+ }
+}
Added: branches/tomek/portal-dnd/jsunit/jsunit.properties.sample
===================================================================
--- branches/tomek/portal-dnd/jsunit/jsunit.properties.sample 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/jsunit.properties.sample 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,35 @@
+
+
+ #Using jsunit.properties is one way to specify the various properties used by the JsUnitServer.
+ #It is deprecated in favor of using ant build files. See build.xml.
+ #To use this file, rename it to "jsunit.properties". You need to provide values for the mandatory properties.
+ #See the documentation at http://www.jsunit.net for more information.
+
+
+ #closeBrowsersAfterTestRuns determines whether to attempt to close browsers after test runs. This is not a mandatory property. The default is true. For example: 'true'
+ closeBrowsersAfterTestRuns=
+
+ #description is a human-readable description of a standard or farm server. This is not a mandatory property. The default is blank. For example: 'This is our Mac - it's only running Safari right now'
+ description=
+
+ #ignoreUnresponsiveRemoteMachines is a property used only by the JsUnit Farm Server and the distributed_test target. Its value is whether to ignore a remove machine that does not respond. If true, test runs will be green even if one or more remove machines fail to respond; if false, an unresponsive remove machine results in a failure. This is not a mandatory property. Its default is false. For example: 'true'
+ ignoreUnresponsiveRemoteMachines=
+
+ #logsDirectory is the directory in which the JsUnitStandardServer stores the XML logs produced from tests run. It can be specified relative to the working directory. This is not a mandatory property. If not specified, the directory called 'logs' inside resourceBase is assumed. For example: 'c:\jsunit\java\logs'
+ logsDirectory=
+
+ #port is the port on which the JsUnitStandardServer runs. This is not a mandatory property. If not specified, 8080 is assumed. For exapmle: '8080'
+ port=
+
+ #remoteMachineURLs is a property used only by the JsUnit Farm Server and the distributed_test target. Its value is the list of URLs of remove machines to which a request to run tests will be sent. For example: 'http://machine1.company.com:8080,http://localhost:8080,http://192.168.1.200:9090'
+ remoteMachineURLs=
+
+ #resourceBase is the directory that the JsUnitStandardServer considers to be its document root. It can be specified relative to the working directory. This is not a mandatory property. If not specified, the working directory is assumed. For example: 'c:\jsunit'
+ resourceBase=
+
+ #timeoutSeconds is the number of seconds to wait before timing out a browser during a test run. This is not a mandatory property. If not specified, 60 is assumed. For example: '60'
+ timeoutSeconds=
+
+ #url is the URL (HTTP or file protocol) to open in the browser. For a JsUnit Server, this is a mandatory property for a test run if the server is not passed the 'url' parameter. For example: 'file:///c:/jsunit/testRunner.html?testPage=c:/jsunit/tests/jsUnitTestSuite.html'
+ url=
+
\ No newline at end of file
Added: branches/tomek/portal-dnd/jsunit/licenses/JDOM_license.txt
===================================================================
--- branches/tomek/portal-dnd/jsunit/licenses/JDOM_license.txt 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/licenses/JDOM_license.txt 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,56 @@
+/*--
+
+ $Id: JDOM_license.txt 81 2003-07-24 04:44:54Z edwardhieatt $
+
+ Copyright (C) 2000-2003 Jason Hunter & Brett McLaughlin.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions
+ are met:
+
+ 1. Redistributions of source code must retain the above copyright
+ notice, this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions, and the disclaimer that follows
+ these conditions in the documentation and/or other materials
+ provided with the distribution.
+
+ 3. The name "JDOM" must not be used to endorse or promote products
+ derived from this software without prior written permission. For
+ written permission, please contact <license AT jdom DOT org>.
+
+ 4. Products derived from this software may not be called "JDOM", nor
+ may "JDOM" appear in their name, without prior written permission
+ from the JDOM Project Management <pm AT jdom DOT org>.
+
+ In addition, we request (but do not require) that you include in the
+ end-user documentation provided with the redistribution and/or in the
+ software itself an acknowledgement equivalent to the following:
+ "This product includes software developed by the
+ JDOM Project (http://www.jdom.org/)."
+ Alternatively, the acknowledgment may be graphical using the logos
+ available at http://www.jdom.org/images/logos.
+
+ THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE JDOM AUTHORS OR THE PROJECT
+ CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+ USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
+ OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ SUCH DAMAGE.
+
+ This software consists of voluntary contributions made by many
+ individuals on behalf of the JDOM Project and was originally
+ created by Jason Hunter <jhunter AT jdom DOT org> and
+ Brett McLaughlin <brett AT jdom DOT org>. For more information on
+ the JDOM Project, please see <http://www.jdom.org/>.
+
+ */
+
Added: branches/tomek/portal-dnd/jsunit/licenses/Jetty_license.html
===================================================================
--- branches/tomek/portal-dnd/jsunit/licenses/Jetty_license.html 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/licenses/Jetty_license.html 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,213 @@
+<HTML>
+<HEAD>
+ <TITLE>Jetty License</TITLE>
+</HEAD>
+
+<BODY BGCOLOR="#FFFFFF">
+<FONT FACE=ARIAL,HELVETICA>
+<CENTER><FONT SIZE=+3><B>Jetty License</B></FONT></CENTER>
+<CENTER><FONT SIZE=-1><B>$Revision$</B></FONT></CENTER>
+
+<B>Preamble:</B>
+
+<p>
+
+ The intent of this document is to state the conditions under which the
+ Jetty Package may be copied, such that the Copyright Holder maintains some
+ semblance of control over the development of the package, while giving the
+ users of the package the right to use, distribute and make reasonable
+ modifications to the Package in accordance with the goals and ideals of
+ the Open Source concept as described at
+ <A HREF="http://www.opensource.org">http://www.opensource.org</A>.
+
+<P>
+ It is the intent of this license to allow commercial usage of the Jetty
+ package, so long as the source code is distributed or suitable visible
+ credit given or other arrangements made with the copyright holders.
+
+<P><B>Definitions:</B>
+
+<P>
+
+<UL>
+ <LI> "Jetty" refers to the collection of Java classes that are
+ distributed as a HTTP server with servlet capabilities and
+ associated utilities.
+
+ <p>
+
+ <LI> "Package" refers to the collection of files distributed by the
+ Copyright Holder, and derivatives of that collection of files
+ created through textual modification.
+
+ <P>
+
+ <LI> "Standard Version" refers to such a Package if it has not been
+ modified, or has been modified in accordance with the wishes
+ of the Copyright Holder.
+
+ <P>
+
+ <LI> "Copyright Holder" is whoever is named in the copyright or
+ copyrights for the package. <BR>
+ Mort Bay Consulting Pty. Ltd. (Australia) is the "Copyright
+ Holder" for the Jetty package.
+
+ <P>
+
+ <LI> "You" is you, if you're thinking about copying or distributing
+ this Package.
+
+ <P>
+
+ <LI> "Reasonable copying fee" is whatever you can justify on the
+ basis of media cost, duplication charges, time of people involved,
+ and so on. (You will not be required to justify it to the
+ Copyright Holder, but only to the computing community at large
+ as a market that must bear the fee.)
+
+ <P>
+
+ <LI> "Freely Available" means that no fee is charged for the item
+ itself, though there may be fees involved in handling the item.
+ It also means that recipients of the item may redistribute it
+ under the same conditions they received it.
+
+ <P>
+</UL>
+
+0. The Jetty Package is Copyright (c) Mort Bay Consulting Pty. Ltd.
+(Australia) and others. Individual files in this package may contain
+additional copyright notices. The javax.servlet packages are copyright
+Sun Microsystems Inc. <P>
+
+ 1. The Standard Version of the Jetty package is
+ available from <A HREF=http://jetty.mortbay.org>http://jetty.mortbay.org</A>.
+
+<P>
+
+ 2. You may make and distribute verbatim copies of the source form
+ of the Standard Version of this Package without restriction, provided that
+ you include this license and all of the original copyright notices
+ and associated disclaimers.
+
+<P>
+
+ 3. You may make and distribute verbatim copies of the compiled form of the
+ Standard Version of this Package without restriction, provided that you
+ include this license.
+
+<P>
+
+ 4. You may apply bug fixes, portability fixes and other modifications
+ derived from the Public Domain or from the Copyright Holder. A Package
+ modified in such a way shall still be considered the Standard Version.
+
+<P>
+
+ 5. You may otherwise modify your copy of this Package in any way, provided
+ that you insert a prominent notice in each changed file stating how and
+ when you changed that file, and provided that you do at least ONE of the
+ following:
+
+<P>
+
+<BLOCKQUOTE>
+ a) Place your modifications in the Public Domain or otherwise make them
+ Freely Available, such as by posting said modifications to Usenet or
+ an equivalent medium, or placing the modifications on a major archive
+ site such as ftp.uu.net, or by allowing the Copyright Holder to include
+ your modifications in the Standard Version of the Package.<P>
+
+ b) Use the modified Package only within your corporation or organization.
+
+ <P>
+
+ c) Rename any non-standard classes so the names do not conflict
+ with standard classes, which must also be provided, and provide
+ a separate manual page for each non-standard class that clearly
+ documents how it differs from the Standard Version.
+
+ <P>
+
+ d) Make other arrangements with the Copyright Holder.
+
+ <P>
+</BLOCKQUOTE>
+
+6. You may distribute modifications or subsets of this Package in source
+code or compiled form, provided that you do at least ONE of the following:<P>
+
+<BLOCKQUOTE>
+ a) Distribute this license and all original copyright messages, together
+ with instructions (in the about dialog, manual page or equivalent) on where
+ to get the complete Standard Version.<P>
+
+ b) Accompany the distribution with the machine-readable source of
+ the Package with your modifications. The modified package must include
+ this license and all of the original copyright notices and associated
+ disclaimers, together with instructions on where to get the complete
+ Standard Version.
+
+ <P>
+
+ c) Make other arrangements with the Copyright Holder.
+
+ <P>
+</BLOCKQUOTE>
+
+7. You may charge a reasonable copying fee for any distribution of this
+Package. You may charge any fee you choose for support of this Package.
+You may not charge a fee for this Package itself. However,
+you may distribute this Package in aggregate with other (possibly
+commercial) programs as part of a larger (possibly commercial) software
+distribution provided that you meet the other distribution requirements
+of this license.<P>
+
+ 8. Input to or the output produced from the programs of this Package
+ do not automatically fall under the copyright of this Package, but
+ belong to whomever generated them, and may be sold commercially, and
+ may be aggregated with this Package.
+
+<P>
+
+ 9. Any program subroutines supplied by you and linked into this Package
+ shall not be considered part of this Package.
+
+<P>
+
+ 10. The name of the Copyright Holder may not be used to endorse or promote
+ products derived from this software without specific prior written
+ permission.
+
+<P>
+
+ 11. This license may change with each release of a Standard Version of
+ the Package. You may choose to use the license associated with version
+ you are using or the license of the latest Standard Version.
+
+<P>
+
+ 12. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
+ IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+
+<P>
+
+ 13. If any superior law implies a warranty, the sole remedy under such shall
+ be , at the Copyright Holders option either a) return of any price paid or
+ b) use or reasonable endeavours to repair or replace the software.
+
+<P>
+
+ 14. This license shall be read under the laws of Australia.
+
+<P>
+
+<center>The End</center>
+
+<center><FONT size=-1>This license was derived from the <I>Artistic</I> license published
+ on <a href=http://www.opensource.org>http://www.opensource.com</a></font></center>
+</FONT>
+
+
Added: branches/tomek/portal-dnd/jsunit/licenses/MPL-1.1.txt
===================================================================
--- branches/tomek/portal-dnd/jsunit/licenses/MPL-1.1.txt 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/licenses/MPL-1.1.txt 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,470 @@
+ MOZILLA PUBLIC LICENSE
+ Version 1.1
+
+ ---------------
+
+1. Definitions.
+
+ 1.0.1. "Commercial Use" means distribution or otherwise making the
+ Covered Code available to a third party.
+
+ 1.1. "Contributor" means each entity that creates or contributes to
+ the creation of Modifications.
+
+ 1.2. "Contributor Version" means the combination of the Original
+ Code, prior Modifications used by a Contributor, and the Modifications
+ made by that particular Contributor.
+
+ 1.3. "Covered Code" means the Original Code or Modifications or the
+ combination of the Original Code and Modifications, in each case
+ including portions thereof.
+
+ 1.4. "Electronic Distribution Mechanism" means a mechanism generally
+ accepted in the software development community for the electronic
+ transfer of data.
+
+ 1.5. "Executable" means Covered Code in any form other than Source
+ Code.
+
+ 1.6. "Initial Developer" means the individual or entity identified
+ as the Initial Developer in the Source Code notice required by Exhibit
+ A.
+
+ 1.7. "Larger Work" means a work which combines Covered Code or
+ portions thereof with code not governed by the terms of this License.
+
+ 1.8. "License" means this document.
+
+ 1.8.1. "Licensable" means having the right to grant, to the maximum
+ extent possible, whether at the time of the initial grant or
+ subsequently acquired, any and all of the rights conveyed herein.
+
+ 1.9. "Modifications" means any addition to or deletion from the
+ substance or structure of either the Original Code or any previous
+ Modifications. When Covered Code is released as a series of files, a
+ Modification is:
+ A. Any addition to or deletion from the contents of a file
+ containing Original Code or previous Modifications.
+
+ B. Any new file that contains any part of the Original Code or
+ previous Modifications.
+
+ 1.10. "Original Code" means Source Code of computer software code
+ which is described in the Source Code notice required by Exhibit A as
+ Original Code, and which, at the time of its release under this
+ License is not already Covered Code governed by this License.
+
+ 1.10.1. "Patent Claims" means any patent claim(s), now owned or
+ hereafter acquired, including without limitation, method, process,
+ and apparatus claims, in any patent Licensable by grantor.
+
+ 1.11. "Source Code" means the preferred form of the Covered Code for
+ making modifications to it, including all modules it contains, plus
+ any associated interface definition files, scripts used to control
+ compilation and installation of an Executable, or source code
+ differential comparisons against either the Original Code or another
+ well known, available Covered Code of the Contributor's choice. The
+ Source Code can be in a compressed or archival form, provided the
+ appropriate decompression or de-archiving software is widely available
+ for no charge.
+
+ 1.12. "You" (or "Your") means an individual or a legal entity
+ exercising rights under, and complying with all of the terms of, this
+ License or a future version of this License issued under Section 6.1.
+ For legal entities, "You" includes any entity which controls, is
+ controlled by, or is under common control with You. For purposes of
+ this definition, "control" means (a) the power, direct or indirect,
+ to cause the direction or management of such entity, whether by
+ contract or otherwise, or (b) ownership of more than fifty percent
+ (50%) of the outstanding shares or beneficial ownership of such
+ entity.
+
+2. Source Code License.
+
+ 2.1. The Initial Developer Grant.
+ The Initial Developer hereby grants You a world-wide, royalty-free,
+ non-exclusive license, subject to third party intellectual property
+ claims:
+ (a) under intellectual property rights (other than patent or
+ trademark) Licensable by Initial Developer to use, reproduce,
+ modify, display, perform, sublicense and distribute the Original
+ Code (or portions thereof) with or without Modifications, and/or
+ as part of a Larger Work; and
+
+ (b) under Patents Claims infringed by the making, using or
+ selling of Original Code, to make, have made, use, practice,
+ sell, and offer for sale, and/or otherwise dispose of the
+ Original Code (or portions thereof).
+
+ (c) the licenses granted in this Section 2.1(a) and (b) are
+ effective on the date Initial Developer first distributes
+ Original Code under the terms of this License.
+
+ (d) Notwithstanding Section 2.1(b) above, no patent license is
+ granted: 1) for code that You delete from the Original Code; 2)
+ separate from the Original Code; or 3) for infringements caused
+ by: i) the modification of the Original Code or ii) the
+ combination of the Original Code with other software or devices.
+
+ 2.2. Contributor Grant.
+ Subject to third party intellectual property claims, each Contributor
+ hereby grants You a world-wide, royalty-free, non-exclusive license
+
+ (a) under intellectual property rights (other than patent or
+ trademark) Licensable by Contributor, to use, reproduce, modify,
+ display, perform, sublicense and distribute the Modifications
+ created by such Contributor (or portions thereof) either on an
+ unmodified basis, with other Modifications, as Covered Code
+ and/or as part of a Larger Work; and
+
+ (b) under Patent Claims infringed by the making, using, or
+ selling of Modifications made by that Contributor either alone
+ and/or in combination with its Contributor Version (or portions
+ of such combination), to make, use, sell, offer for sale, have
+ made, and/or otherwise dispose of: 1) Modifications made by that
+ Contributor (or portions thereof); and 2) the combination of
+ Modifications made by that Contributor with its Contributor
+ Version (or portions of such combination).
+
+ (c) the licenses granted in Sections 2.2(a) and 2.2(b) are
+ effective on the date Contributor first makes Commercial Use of
+ the Covered Code.
+
+ (d) Notwithstanding Section 2.2(b) above, no patent license is
+ granted: 1) for any code that Contributor has deleted from the
+ Contributor Version; 2) separate from the Contributor Version;
+ 3) for infringements caused by: i) third party modifications of
+ Contributor Version or ii) the combination of Modifications made
+ by that Contributor with other software (except as part of the
+ Contributor Version) or other devices; or 4) under Patent Claims
+ infringed by Covered Code in the absence of Modifications made by
+ that Contributor.
+
+3. Distribution Obligations.
+
+ 3.1. Application of License.
+ The Modifications which You create or to which You contribute are
+ governed by the terms of this License, including without limitation
+ Section 2.2. The Source Code version of Covered Code may be
+ distributed only under the terms of this License or a future version
+ of this License released under Section 6.1, and You must include a
+ copy of this License with every copy of the Source Code You
+ distribute. You may not offer or impose any terms on any Source Code
+ version that alters or restricts the applicable version of this
+ License or the recipients' rights hereunder. However, You may include
+ an additional document offering the additional rights described in
+ Section 3.5.
+
+ 3.2. Availability of Source Code.
+ Any Modification which You create or to which You contribute must be
+ made available in Source Code form under the terms of this License
+ either on the same media as an Executable version or via an accepted
+ Electronic Distribution Mechanism to anyone to whom you made an
+ Executable version available; and if made available via Electronic
+ Distribution Mechanism, must remain available for at least twelve (12)
+ months after the date it initially became available, or at least six
+ (6) months after a subsequent version of that particular Modification
+ has been made available to such recipients. You are responsible for
+ ensuring that the Source Code version remains available even if the
+ Electronic Distribution Mechanism is maintained by a third party.
+
+ 3.3. Description of Modifications.
+ You must cause all Covered Code to which You contribute to contain a
+ file documenting the changes You made to create that Covered Code and
+ the date of any change. You must include a prominent statement that
+ the Modification is derived, directly or indirectly, from Original
+ Code provided by the Initial Developer and including the name of the
+ Initial Developer in (a) the Source Code, and (b) in any notice in an
+ Executable version or related documentation in which You describe the
+ origin or ownership of the Covered Code.
+
+ 3.4. Intellectual Property Matters
+ (a) Third Party Claims.
+ If Contributor has knowledge that a license under a third party's
+ intellectual property rights is required to exercise the rights
+ granted by such Contributor under Sections 2.1 or 2.2,
+ Contributor must include a text file with the Source Code
+ distribution titled "LEGAL" which describes the claim and the
+ party making the claim in sufficient detail that a recipient will
+ know whom to contact. If Contributor obtains such knowledge after
+ the Modification is made available as described in Section 3.2,
+ Contributor shall promptly modify the LEGAL file in all copies
+ Contributor makes available thereafter and shall take other steps
+ (such as notifying appropriate mailing lists or newsgroups)
+ reasonably calculated to inform those who received the Covered
+ Code that new knowledge has been obtained.
+
+ (b) Contributor APIs.
+ If Contributor's Modifications include an application programming
+ interface and Contributor has knowledge of patent licenses which
+ are reasonably necessary to implement that API, Contributor must
+ also include this information in the LEGAL file.
+
+ (c) Representations.
+ Contributor represents that, except as disclosed pursuant to
+ Section 3.4(a) above, Contributor believes that Contributor's
+ Modifications are Contributor's original creation(s) and/or
+ Contributor has sufficient rights to grant the rights conveyed by
+ this License.
+
+ 3.5. Required Notices.
+ You must duplicate the notice in Exhibit A in each file of the Source
+ Code. If it is not possible to put such notice in a particular Source
+ Code file due to its structure, then You must include such notice in a
+ location (such as a relevant directory) where a user would be likely
+ to look for such a notice. If You created one or more Modification(s)
+ You may add your name as a Contributor to the notice described in
+ Exhibit A. You must also duplicate this License in any documentation
+ for the Source Code where You describe recipients' rights or ownership
+ rights relating to Covered Code. You may choose to offer, and to
+ charge a fee for, warranty, support, indemnity or liability
+ obligations to one or more recipients of Covered Code. However, You
+ may do so only on Your own behalf, and not on behalf of the Initial
+ Developer or any Contributor. You must make it absolutely clear than
+ any such warranty, support, indemnity or liability obligation is
+ offered by You alone, and You hereby agree to indemnify the Initial
+ Developer and every Contributor for any liability incurred by the
+ Initial Developer or such Contributor as a result of warranty,
+ support, indemnity or liability terms You offer.
+
+ 3.6. Distribution of Executable Versions.
+ You may distribute Covered Code in Executable form only if the
+ requirements of Section 3.1-3.5 have been met for that Covered Code,
+ and if You include a notice stating that the Source Code version of
+ the Covered Code is available under the terms of this License,
+ including a description of how and where You have fulfilled the
+ obligations of Section 3.2. The notice must be conspicuously included
+ in any notice in an Executable version, related documentation or
+ collateral in which You describe recipients' rights relating to the
+ Covered Code. You may distribute the Executable version of Covered
+ Code or ownership rights under a license of Your choice, which may
+ contain terms different from this License, provided that You are in
+ compliance with the terms of this License and that the license for the
+ Executable version does not attempt to limit or alter the recipient's
+ rights in the Source Code version from the rights set forth in this
+ License. If You distribute the Executable version under a different
+ license You must make it absolutely clear that any terms which differ
+ from this License are offered by You alone, not by the Initial
+ Developer or any Contributor. You hereby agree to indemnify the
+ Initial Developer and every Contributor for any liability incurred by
+ the Initial Developer or such Contributor as a result of any such
+ terms You offer.
+
+ 3.7. Larger Works.
+ You may create a Larger Work by combining Covered Code with other code
+ not governed by the terms of this License and distribute the Larger
+ Work as a single product. In such a case, You must make sure the
+ requirements of this License are fulfilled for the Covered Code.
+
+4. Inability to Comply Due to Statute or Regulation.
+
+ If it is impossible for You to comply with any of the terms of this
+ License with respect to some or all of the Covered Code due to
+ statute, judicial order, or regulation then You must: (a) comply with
+ the terms of this License to the maximum extent possible; and (b)
+ describe the limitations and the code they affect. Such description
+ must be included in the LEGAL file described in Section 3.4 and must
+ be included with all distributions of the Source Code. Except to the
+ extent prohibited by statute or regulation, such description must be
+ sufficiently detailed for a recipient of ordinary skill to be able to
+ understand it.
+
+5. Application of this License.
+
+ This License applies to code to which the Initial Developer has
+ attached the notice in Exhibit A and to related Covered Code.
+
+6. Versions of the License.
+
+ 6.1. New Versions.
+ Netscape Communications Corporation ("Netscape") may publish revised
+ and/or new versions of the License from time to time. Each version
+ will be given a distinguishing version number.
+
+ 6.2. Effect of New Versions.
+ Once Covered Code has been published under a particular version of the
+ License, You may always continue to use it under the terms of that
+ version. You may also choose to use such Covered Code under the terms
+ of any subsequent version of the License published by Netscape. No one
+ other than Netscape has the right to modify the terms applicable to
+ Covered Code created under this License.
+
+ 6.3. Derivative Works.
+ If You create or use a modified version of this License (which you may
+ only do in order to apply it to code which is not already Covered Code
+ governed by this License), You must (a) rename Your license so that
+ the phrases "Mozilla", "MOZILLAPL", "MOZPL", "Netscape",
+ "MPL", "NPL" or any confusingly similar phrase do not appear in your
+ license (except to note that your license differs from this License)
+ and (b) otherwise make it clear that Your version of the license
+ contains terms which differ from the Mozilla Public License and
+ Netscape Public License. (Filling in the name of the Initial
+ Developer, Original Code or Contributor in the notice described in
+ Exhibit A shall not of themselves be deemed to be modifications of
+ this License.)
+
+7. DISCLAIMER OF WARRANTY.
+
+ COVERED CODE IS PROVIDED UNDER THIS LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
+ WITHOUT LIMITATION, WARRANTIES THAT THE COVERED CODE IS FREE OF
+ DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING.
+ THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED CODE
+ IS WITH YOU. SHOULD ANY COVERED CODE PROVE DEFECTIVE IN ANY RESPECT,
+ YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE
+ COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER
+ OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF
+ ANY COVERED CODE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER.
+
+8. TERMINATION.
+
+ 8.1. This License and the rights granted hereunder will terminate
+ automatically if You fail to comply with terms herein and fail to cure
+ such breach within 30 days of becoming aware of the breach. All
+ sublicenses to the Covered Code which are properly granted shall
+ survive any termination of this License. Provisions which, by their
+ nature, must remain in effect beyond the termination of this License
+ shall survive.
+
+ 8.2. If You initiate litigation by asserting a patent infringement
+ claim (excluding declatory judgment actions) against Initial Developer
+ or a Contributor (the Initial Developer or Contributor against whom
+ You file such action is referred to as "Participant") alleging that:
+
+ (a) such Participant's Contributor Version directly or indirectly
+ infringes any patent, then any and all rights granted by such
+ Participant to You under Sections 2.1 and/or 2.2 of this License
+ shall, upon 60 days notice from Participant terminate prospectively,
+ unless if within 60 days after receipt of notice You either: (i)
+ agree in writing to pay Participant a mutually agreeable reasonable
+ royalty for Your past and future use of Modifications made by such
+ Participant, or (ii) withdraw Your litigation claim with respect to
+ the Contributor Version against such Participant. If within 60 days
+ of notice, a reasonable royalty and payment arrangement are not
+ mutually agreed upon in writing by the parties or the litigation claim
+ is not withdrawn, the rights granted by Participant to You under
+ Sections 2.1 and/or 2.2 automatically terminate at the expiration of
+ the 60 day notice period specified above.
+
+ (b) any software, hardware, or device, other than such Participant's
+ Contributor Version, directly or indirectly infringes any patent, then
+ any rights granted to You by such Participant under Sections 2.1(b)
+ and 2.2(b) are revoked effective as of the date You first made, used,
+ sold, distributed, or had made, Modifications made by that
+ Participant.
+
+ 8.3. If You assert a patent infringement claim against Participant
+ alleging that such Participant's Contributor Version directly or
+ indirectly infringes any patent where such claim is resolved (such as
+ by license or settlement) prior to the initiation of patent
+ infringement litigation, then the reasonable value of the licenses
+ granted by such Participant under Sections 2.1 or 2.2 shall be taken
+ into account in determining the amount or value of any payment or
+ license.
+
+ 8.4. In the event of termination under Sections 8.1 or 8.2 above,
+ all end user license agreements (excluding distributors and resellers)
+ which have been validly granted by You or any distributor hereunder
+ prior to termination shall survive termination.
+
+9. LIMITATION OF LIABILITY.
+
+ UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT
+ (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL
+ DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED CODE,
+ OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR
+ ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY
+ CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL,
+ WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER
+ COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN
+ INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF
+ LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY
+ RESULTING FROM SUCH PARTY'S NEGLIGENCE TO THE EXTENT APPLICABLE LAW
+ PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE
+ EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO
+ THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU.
+
+10. U.S. GOVERNMENT END USERS.
+
+ The Covered Code is a "commercial item," as that term is defined in
+ 48 C.F.R. 2.101 (Oct. 1995), consisting of "commercial computer
+ software" and "commercial computer software documentation," as such
+ terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48
+ C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995),
+ all U.S. Government End Users acquire Covered Code with only those
+ rights set forth herein.
+
+11. MISCELLANEOUS.
+
+ This License represents the complete agreement concerning subject
+ matter hereof. If any provision of this License is held to be
+ unenforceable, such provision shall be reformed only to the extent
+ necessary to make it enforceable. This License shall be governed by
+ California law provisions (except to the extent applicable law, if
+ any, provides otherwise), excluding its conflict-of-law provisions.
+ With respect to disputes in which at least one party is a citizen of,
+ or an entity chartered or registered to do business in the United
+ States of America, any litigation relating to this License shall be
+ subject to the jurisdiction of the Federal Courts of the Northern
+ District of California, with venue lying in Santa Clara County,
+ California, with the losing party responsible for costs, including
+ without limitation, court costs and reasonable attorneys' fees and
+ expenses. The application of the United Nations Convention on
+ Contracts for the International Sale of Goods is expressly excluded.
+ Any law or regulation which provides that the language of a contract
+ shall be construed against the drafter shall not apply to this
+ License.
+
+12. RESPONSIBILITY FOR CLAIMS.
+
+ As between Initial Developer and the Contributors, each party is
+ responsible for claims and damages arising, directly or indirectly,
+ out of its utilization of rights under this License and You agree to
+ work with Initial Developer and Contributors to distribute such
+ responsibility on an equitable basis. Nothing herein is intended or
+ shall be deemed to constitute any admission of liability.
+
+13. MULTIPLE-LICENSED CODE.
+
+ Initial Developer may designate portions of the Covered Code as
+ "Multiple-Licensed". "Multiple-Licensed" means that the Initial
+ Developer permits you to utilize portions of the Covered Code under
+ Your choice of the NPL or the alternative licenses, if any, specified
+ by the Initial Developer in the file described in Exhibit A.
+
+EXHIBIT A -Mozilla Public License.
+
+ ``The contents of this file are subject to the Mozilla Public License
+ Version 1.1 (the "License"); you may not use this file except in
+ compliance with the License. You may obtain a copy of the License at
+ http://www.mozilla.org/MPL/
+
+ Software distributed under the License is distributed on an "AS IS"
+ basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ License for the specific language governing rights and limitations
+ under the License.
+
+ The Original Code is ______________________________________.
+
+ The Initial Developer of the Original Code is ________________________.
+ Portions created by ______________________ are Copyright (C) ______
+ _______________________. All Rights Reserved.
+
+ Contributor(s): ______________________________________.
+
+ Alternatively, the contents of this file may be used under the terms
+ of the _____ license (the "[___] License"), in which case the
+ provisions of [______] License are applicable instead of those
+ above. If you wish to allow use of your version of this file only
+ under the terms of the [____] License and not to allow others to use
+ your version of this file under the MPL, indicate your decision by
+ deleting the provisions above and replace them with the notice and
+ other provisions required by the [___] License. If you do not delete
+ the provisions above, a recipient may use your version of this file
+ under either the MPL or the [___] License."
+
+ [NOTE: The text of this Exhibit A may differ slightly from the text of
+ the notices in the Source Code files of the Original Code. You should
+ use the text of this Exhibit A rather than the text found in the
+ Original Code Source Code for Your Modifications.]
+
Added: branches/tomek/portal-dnd/jsunit/licenses/gpl-2.txt
===================================================================
--- branches/tomek/portal-dnd/jsunit/licenses/gpl-2.txt 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/licenses/gpl-2.txt 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,340 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users. This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it. (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.) You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+ To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have. You must make sure that they, too, receive or can get the
+source code. And you must show them these terms so they know their
+rights.
+
+ We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+ Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software. If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+ Finally, any free program is threatened constantly by software
+patents. We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary. To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License. The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language. (Hereinafter, translation is included without limitation in
+the term "modification".) Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+ 1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+ 2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) You must cause the modified files to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ b) You must cause any work that you distribute or publish, that in
+ whole or in part contains or is derived from the Program or any
+ part thereof, to be licensed as a whole at no charge to all third
+ parties under the terms of this License.
+
+ c) If the modified program normally reads commands interactively
+ when run, you must cause it, when started running for such
+ interactive use in the most ordinary way, to print or display an
+ announcement including an appropriate copyright notice and a
+ notice that there is no warranty (or else, saying that you provide
+ a warranty) and that users may redistribute the program under
+ these conditions, and telling the user how to view a copy of this
+ License. (Exception: if the Program itself is interactive but
+ does not normally print such an announcement, your work based on
+ the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+ a) Accompany it with the complete corresponding machine-readable
+ source code, which must be distributed under the terms of Sections
+ 1 and 2 above on a medium customarily used for software interchange; or,
+
+ b) Accompany it with a written offer, valid for at least three
+ years, to give any third party, for a charge no more than your
+ cost of physically performing source distribution, a complete
+ machine-readable copy of the corresponding source code, to be
+ distributed under the terms of Sections 1 and 2 above on a medium
+ customarily used for software interchange; or,
+
+ c) Accompany it with the information you received as to the offer
+ to distribute corresponding source code. (This alternative is
+ allowed only for noncommercial distribution and only if you
+ received the program in object code or executable form with such
+ an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable. However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License. Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+ 5. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Program or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+ 6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+ 7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all. For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded. In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+ 9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation. If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+ 10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission. For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this. Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+ Gnomovision version 69, Copyright (C) year name of author
+ Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+ `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+ <signature of Ty Coon>, 1 April 1989
+ Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs. If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library. If this is what you want to do, use the GNU Library General
+Public License instead of this License.
Added: branches/tomek/portal-dnd/jsunit/licenses/index.html
===================================================================
--- branches/tomek/portal-dnd/jsunit/licenses/index.html 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/licenses/index.html 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,141 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<!-- JsUnit -->
+<!-- ***** BEGIN LICENSE BLOCK *****
+ - Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ -
+ - The contents of this file are subject to the Mozilla Public License Version
+ - 1.1 (the "License"); you may not use this file except in compliance with
+ - the License. You may obtain a copy of the License at
+ - http://www.mozilla.org/MPL/
+ -
+ - Software distributed under the License is distributed on an "AS IS" basis,
+ - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ - for the specific language governing rights and limitations under the
+ - License.
+ -
+ - The Original Code is Edward Hieatt code.
+ -
+ - The Initial Developer of the Original Code is
+ - Edward Hieatt, edward at jsunit.net.
+ - Portions created by the Initial Developer are Copyright (C) 2001
+ - the Initial Developer. All Rights Reserved.
+ -
+ - Contributor(s):
+ - Edward Hieatt, edward at jsunit.net (original author)
+ - Bob Clary, bc at bclary.comn
+ -
+ - Alternatively, the contents of this file may be used under the terms of
+ - either the GNU General Public License Version 2 or later (the "GPL"), or
+ - the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ - in which case the provisions of the GPL or the LGPL are applicable instead
+ - of those above. If you wish to allow use of your version of this file only
+ - under the terms of either the GPL or the LGPL, and not to allow others to
+ - use your version of this file under the terms of the MPL, indicate your
+ - decision by deleting the provisions above and replace them with the notice
+ - and other provisions required by the LGPL or the GPL. If you do not delete
+ - the provisions above, a recipient may use your version of this file under
+ - the terms of any one of the MPL, the GPL or the LGPL.
+ -
+ - ***** END LICENSE BLOCK ***** -->
+
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>Licensing</title>
+ <link rel="stylesheet" type="text/css" href="../app/css/jsUnitStyle.css">
+</head>
+
+<body>
+<table width="100%" cellpadding="0" cellspacing="0" border="1" summary="jsUnit Information">
+ <tr>
+ <th align="center" valign="top"><h1>JsUnit Licenses</h1></th>
+
+ <td align="right" valign="top">
+ <a href="http://www.jsunit.net/" target="_blank">JsUnit Home</a><br>
+ <a href="mailto:edward at jsunit.net">edward at jsunit.net</a><br>
+ </tr>
+</table>
+
+<p><h2>Third-party licenses:</h2>
+ <ul>
+ <li>JDOM: Portions of this software are copyright Copyright (C) 2000-2003 Jason Hunter & Brett McLaughlin. All
+ rights reserved. See <a href="JDOM_license.txt">JDOM_license.txt</a>.
+ <li>Jetty: Portions of this software are copyright � Mort Bay Consulting Pty. Ltd. (Australia) and others. All
+ Rights Reserved. See <a href="Jetty_license.html">Jetty_license.html</a>.
+ <li>Individual files in this package may contain additional copyright notices. The javax.servlet packages are
+ copyright Sun Microsystems Inc. All Rights Reserved.
+ </ul>
+</p>
+
+<p><h2>JsUnit licenses:</h2>
+ JsUnit is licensed under 3 different licenses giving you the freedom
+ to use, modify and distribute JsUnit in a variety of fashions.
+</p>
+
+<ol>
+ <li>
+ <p><a href="MPL-1.1.txt">Mozilla Public License 1.1</a></p>
+
+ <p>See <a href="http://www.mozilla.org/MPL/">mozilla.org</a>
+ for more details.</p>
+ </li>
+
+ <li>
+ <p><a href="gpl-2.txt">GNU Public License 2</a></p>
+
+ <p>See <a href="http://www.gnu.org/licenses/licenses.html">www.gnu.org</a>
+ for more details.</p>
+ </li>
+
+ <li>
+ <p><a href="lgpl-2.1.txt">GNU Lesser Public License 2.1</a></p>
+
+ <p>See <a href="http://www.gnu.org/licenses/licenses.html">www.gnu.org</a>
+ for more details.</p>
+ </li>
+</ol>
+
+<p>
+ Every Java and JavaScript source file in this distribution should be considered to be under the following licensing
+ terms.
+ <pre>
+ ***** BEGIN LICENSE BLOCK *****
+ - Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ -
+ - The contents of this file are subject to the Mozilla Public License Version
+ - 1.1 (the "License"); you may not use this file except in compliance with
+ - the License. You may obtain a copy of the License at
+ - http://www.mozilla.org/MPL/
+ -
+ - Software distributed under the License is distributed on an "AS IS" basis,
+ - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ - for the specific language governing rights and limitations under the
+ - License.
+ -
+ - The Original Code is Edward Hieatt code.
+ -
+ - The Initial Developer of the Original Code is
+ - Edward Hieatt, edward at jsunit.net.
+ - Portions created by the Initial Developer are Copyright (C) 2003
+ - the Initial Developer. All Rights Reserved.
+ -
+ - Author Edward Hieatt, edward at jsunit.net
+ -
+ - Alternatively, the contents of this file may be used under the terms of
+ - either the GNU General Public License Version 2 or later (the "GPL"), or
+ - the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ - in which case the provisions of the GPL or the LGPL are applicable instead
+ - of those above. If you wish to allow use of your version of this file only
+ - under the terms of either the GPL or the LGPL, and not to allow others to
+ - use your version of this file under the terms of the MPL, indicate your
+ - decision by deleting the provisions above and replace them with the notice
+ - and other provisions required by the LGPL or the GPL. If you do not delete
+ - the provisions above, a recipient may use your version of this file under
+ - the terms of any one of the MPL, the GPL or the LGPL.
+ -
+ - ***** END LICENSE BLOCK *****
+ </pre>
+</p>
+</body>
+</html>
+
Added: branches/tomek/portal-dnd/jsunit/licenses/lgpl-2.1.txt
===================================================================
--- branches/tomek/portal-dnd/jsunit/licenses/lgpl-2.1.txt 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/licenses/lgpl-2.1.txt 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,504 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+ GNU LESSER GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+ 0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+ A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+ The "Library", below, refers to any such software library or work
+which has been distributed under these terms. A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language. (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+ "Source code" for a work means the preferred form of the work for
+making modifications to it. For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+ Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope. The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it). Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+ 1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+ You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+ 2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+ a) The modified work must itself be a software library.
+
+ b) You must cause the files modified to carry prominent notices
+ stating that you changed the files and the date of any change.
+
+ c) You must cause the whole of the work to be licensed at no
+ charge to all third parties under the terms of this License.
+
+ d) If a facility in the modified Library refers to a function or a
+ table of data to be supplied by an application program that uses
+ the facility, other than as an argument passed when the facility
+ is invoked, then you must make a good faith effort to ensure that,
+ in the event an application does not supply such function or
+ table, the facility still operates, and performs whatever part of
+ its purpose remains meaningful.
+
+ (For example, a function in a library to compute square roots has
+ a purpose that is entirely well-defined independent of the
+ application. Therefore, Subsection 2d requires that any
+ application-supplied function or table used by this function must
+ be optional: if the application does not supply it, the square
+ root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole. If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works. But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+ 3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library. To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License. (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.) Do not make any other change in
+these notices.
+
+ Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+ This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+ 4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+ If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+ 5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library". Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+ However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library". The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+ When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library. The
+threshold for this to be true is not precisely defined by law.
+
+ If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work. (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+ Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+ 6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+ You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License. You must supply a copy of this License. If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License. Also, you must do one
+of these things:
+
+ a) Accompany the work with the complete corresponding
+ machine-readable source code for the Library including whatever
+ changes were used in the work (which must be distributed under
+ Sections 1 and 2 above); and, if the work is an executable linked
+ with the Library, with the complete machine-readable "work that
+ uses the Library", as object code and/or source code, so that the
+ user can modify the Library and then relink to produce a modified
+ executable containing the modified Library. (It is understood
+ that the user who changes the contents of definitions files in the
+ Library will not necessarily be able to recompile the application
+ to use the modified definitions.)
+
+ b) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (1) uses at run time a
+ copy of the library already present on the user's computer system,
+ rather than copying library functions into the executable, and (2)
+ will operate properly with a modified version of the library, if
+ the user installs one, as long as the modified version is
+ interface-compatible with the version that the work was made with.
+
+ c) Accompany the work with a written offer, valid for at
+ least three years, to give the same user the materials
+ specified in Subsection 6a, above, for a charge no more
+ than the cost of performing this distribution.
+
+ d) If distribution of the work is made by offering access to copy
+ from a designated place, offer equivalent access to copy the above
+ specified materials from the same place.
+
+ e) Verify that the user has already received a copy of these
+ materials or that you have already sent this user a copy.
+
+ For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it. However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+ It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system. Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+ 7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+ a) Accompany the combined library with a copy of the same work
+ based on the Library, uncombined with any other library
+ facilities. This must be distributed under the terms of the
+ Sections above.
+
+ b) Give prominent notice with the combined library of the fact
+ that part of it is a work based on the Library, and explaining
+ where to find the accompanying uncombined form of the same work.
+
+ 8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License. Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License. However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+ 9. You are not required to accept this License, since you have not
+signed it. However, nothing else grants you permission to modify or
+distribute the Library or its derivative works. These actions are
+prohibited by law if you do not accept this License. Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+ 10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions. You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+ 11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all. For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices. Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+ 12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded. In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+ 13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number. If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation. If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+ 14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission. For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this. Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+ NO WARRANTY
+
+ 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Libraries
+
+ If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change. You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+ To apply these terms, attach the following notices to the library. It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the library's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary. Here is a sample; alter the names:
+
+ Yoyodyne, Inc., hereby disclaims all copyright interest in the
+ library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+ <signature of Ty Coon>, 1 April 1990
+ Ty Coon, President of Vice
+
+That's all there is to it!
+
+
Added: branches/tomek/portal-dnd/jsunit/licenses/mpl-tri-license-c.txt
===================================================================
--- branches/tomek/portal-dnd/jsunit/licenses/mpl-tri-license-c.txt 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/licenses/mpl-tri-license-c.txt 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,35 @@
+/* ***** BEGIN LICENSE BLOCK *****
+ * Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is __________________________________________.
+ *
+ * The Initial Developer of the Original Code is
+ * ____________________________________________.
+ * Portions created by the Initial Developer are Copyright (C) 2___
+ * the Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 2 or later (the "GPL"), or
+ * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the MPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the MPL, the GPL or the LGPL.
+ *
+ * ***** END LICENSE BLOCK ***** */
Added: branches/tomek/portal-dnd/jsunit/licenses/mpl-tri-license-html.txt
===================================================================
--- branches/tomek/portal-dnd/jsunit/licenses/mpl-tri-license-html.txt 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/licenses/mpl-tri-license-html.txt 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,35 @@
+<!-- ***** BEGIN LICENSE BLOCK *****
+ - Version: MPL 1.1/GPL 2.0/LGPL 2.1
+ -
+ - The contents of this file are subject to the Mozilla Public License Version
+ - 1.1 (the "License"); you may not use this file except in compliance with
+ - the License. You may obtain a copy of the License at
+ - http://www.mozilla.org/MPL/
+ -
+ - Software distributed under the License is distributed on an "AS IS" basis,
+ - WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ - for the specific language governing rights and limitations under the
+ - License.
+ -
+ - The Original Code is __________________________________________.
+ -
+ - The Initial Developer of the Original Code is
+ - ____________________________________________.
+ - Portions created by the Initial Developer are Copyright (C) 2___
+ - the Initial Developer. All Rights Reserved.
+ -
+ - Contributor(s):
+ -
+ - Alternatively, the contents of this file may be used under the terms of
+ - either the GNU General Public License Version 2 or later (the "GPL"), or
+ - the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ - in which case the provisions of the GPL or the LGPL are applicable instead
+ - of those above. If you wish to allow use of your version of this file only
+ - under the terms of either the GPL or the LGPL, and not to allow others to
+ - use your version of this file under the terms of the MPL, indicate your
+ - decision by deleting the provisions above and replace them with the notice
+ - and other provisions required by the LGPL or the GPL. If you do not delete
+ - the provisions above, a recipient may use your version of this file under
+ - the terms of any one of the MPL, the GPL or the LGPL.
+ -
+ - ***** END LICENSE BLOCK ***** -->
Added: branches/tomek/portal-dnd/jsunit/logging.properties
===================================================================
--- branches/tomek/portal-dnd/jsunit/logging.properties 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/logging.properties 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,12 @@
+.level=INFO
+
+handlers=java.util.logging.ConsoleHandler
+
+java.util.logging.ConsoleHandler.level=ALL
+java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
+
+net.jsunit.level=INFO
+org.mortbay.level=WARNING
+com.opensymphony.webwork.level=SEVERE
+com.opensymphony.xwork.level=SEVERE
+
Added: branches/tomek/portal-dnd/jsunit/readme.txt
===================================================================
--- branches/tomek/portal-dnd/jsunit/readme.txt 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/readme.txt 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,19 @@
+JsUnit
+Copyright (C) 2001-6 Edward Hieatt, edward at jsunit.net
+
+This program is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License
+as published by the Free Software Foundation; either version 2
+of the License, or (at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+Please see http://www.jsunit.net/ for JsUnit documentation and
+the "licenses" directory for license information.
\ No newline at end of file
Added: branches/tomek/portal-dnd/jsunit/testRunner.html
===================================================================
--- branches/tomek/portal-dnd/jsunit/testRunner.html 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/testRunner.html 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,167 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
+<html>
+
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>JsUnit Test Runner</title>
+<script language="JavaScript" type="text/javascript" src="app/xbDebug.js"></script>
+<script language="JavaScript" type="text/javascript" src="app/jsUnitCore.js"></script>
+<script language="JavaScript" type="text/javascript">
+ var DEFAULT_TEST_FRAME_HEIGHT = 250;
+
+ function jsUnitParseParms(string) {
+ var i;
+ var searchString = unescape(string);
+ var parameterHash = new Object();
+
+ if (!searchString) {
+ return parameterHash;
+ }
+
+ i = searchString.indexOf('?');
+ if (i != -1) {
+ searchString = searchString.substring(i + 1);
+ }
+
+ var parmList = searchString.split('&');
+ var a;
+ for (i = 0; i < parmList.length; i++) {
+ a = parmList[i].split('=');
+ a[0] = a[0].toLowerCase();
+ if (a.length > 1) {
+ parameterHash[a[0]] = a[1];
+ }
+ else {
+ parameterHash[a[0]] = true;
+ }
+ }
+ return parameterHash;
+ }
+
+ function jsUnitConstructTestParms() {
+ var p;
+ var parms = '';
+
+ for (p in jsUnitParmHash) {
+ var value = jsUnitParmHash[p];
+
+ if (!value ||
+ p == 'testpage' ||
+ p == 'autorun' ||
+ p == 'submitresults' ||
+ p == 'showtestframe' ||
+ p == 'resultid') {
+ continue;
+ }
+
+ if (parms) {
+ parms += '&';
+ }
+
+ parms += p;
+
+ if (typeof(value) != 'boolean') {
+ parms += '=' + value;
+ }
+ }
+ return escape(parms);
+ }
+
+ var jsUnitParmHash = jsUnitParseParms(document.location.search);
+
+ // set to true to turn debugging code on, false to turn it off.
+ xbDEBUG.on = jsUnitGetParm('debug') ? true : false;
+</script>
+
+<script language="JavaScript" type="text/javascript" src="app/jsUnitTestManager.js"></script>
+<script language="JavaScript" type="text/javascript" src="app/jsUnitTracer.js"></script>
+<script language="JavaScript" type="text/javascript" src="app/jsUnitTestSuite.js"></script>
+<script language="JavaScript" type="text/javascript">
+
+ var testManager;
+ var utility;
+ var tracer;
+
+
+ if (!Array.prototype.push) {
+ Array.prototype.push = function (anObject) {
+ this[this.length] = anObject;
+ }
+ }
+
+ if (!Array.prototype.pop) {
+ Array.prototype.pop = function () {
+ if (this.length > 0) {
+ delete this[this.length - 1];
+ this.length--;
+ }
+ }
+ }
+
+ function shouldKickOffTestsAutomatically() {
+ return jsUnitGetParm('autorun') == "true";
+ }
+
+ function shouldShowTestFrame() {
+ return jsUnitGetParm('showtestframe');
+ }
+
+ function shouldSubmitResults() {
+ return jsUnitGetParm('submitresults');
+ }
+
+ function getResultId() {
+ if (jsUnitGetParm('resultid'))
+ return jsUnitGetParm('resultid');
+ return "";
+ }
+
+ function submitResults() {
+ window.mainFrame.mainData.document.testRunnerForm.runButton.disabled = true;
+ window.mainFrame.mainResults.populateHeaderFields(getResultId(), navigator.userAgent, JSUNIT_VERSION, testManager.resolveUserEnteredTestFileName());
+ window.mainFrame.mainResults.submitResults();
+ }
+
+ function wasResultUrlSpecified() {
+ return shouldSubmitResults() && jsUnitGetParm('submitresults') != 'true';
+ }
+
+ function getSpecifiedResultUrl() {
+ return jsUnitGetParm('submitresults');
+ }
+
+ function init() {
+ var testRunnerFrameset = document.getElementById('testRunnerFrameset');
+ if (shouldShowTestFrame() && testRunnerFrameset) {
+ var testFrameHeight;
+ if (jsUnitGetParm('showtestframe') == 'true')
+ testFrameHeight = DEFAULT_TEST_FRAME_HEIGHT;
+ else
+ testFrameHeight = jsUnitGetParm('showtestframe');
+ testRunnerFrameset.rows = '*,0,' + testFrameHeight;
+ }
+ testManager = new jsUnitTestManager();
+ tracer = new JsUnitTracer(testManager);
+ if (shouldKickOffTestsAutomatically()) {
+ window.mainFrame.mainData.kickOffTests();
+ }
+ }
+
+
+</script>
+</head>
+
+<frameset id="testRunnerFrameset" rows="*,0,0" border="0" onload="init()">
+
+ <frame frameborder="0" name="mainFrame" src="./app/main-frame.html">
+ <frame frameborder="0" name="documentLoader" src="./app/main-loader.html">
+ <frame frameborder="0" name="testContainer" src="./app/testContainer.html">
+
+ <noframes>
+ <body>
+ <p>Sorry, JsUnit requires support for frames.</p>
+ </body>
+ </noframes>
+</frameset>
+
+</html>
\ No newline at end of file
Added: branches/tomek/portal-dnd/jsunit/tests/data/data.html
===================================================================
--- branches/tomek/portal-dnd/jsunit/tests/data/data.html 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/tests/data/data.html 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,218 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
+ "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>test</title>
+</head>
+
+<body>
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+
+<p>foo</p>
+</body>
+</html>
Added: branches/tomek/portal-dnd/jsunit/tests/data/staff.css
===================================================================
--- branches/tomek/portal-dnd/jsunit/tests/data/staff.css 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/tests/data/staff.css 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,30 @@
+staff {
+ display: table;
+ color: black;
+ background-color: white;
+ border: solid 1px black;
+}
+
+employee {
+ display: table-row;
+ border: solid 1px black;
+ padding: 1px;
+}
+
+employeeId, name, position, salary, gender, address {
+ display: table-cell;
+ border: solid 1px black;
+ padding: 1px;
+}
+
+address[domestic="Yes"] {
+ background-color: silver;
+}
+
+address[street="Yes"] {
+ color: green;
+}
+
+address[street="No"] {
+ color: red;
+}
Added: branches/tomek/portal-dnd/jsunit/tests/data/staff.dtd
===================================================================
--- branches/tomek/portal-dnd/jsunit/tests/data/staff.dtd 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/tests/data/staff.dtd 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,17 @@
+<!ELEMENT employeeId (#PCDATA)>
+<!ELEMENT name (#PCDATA)>
+<!ELEMENT position (#PCDATA)>
+<!ELEMENT salary (#PCDATA)>
+<!ELEMENT address (#PCDATA)>
+<!ELEMENT entElement ( #PCDATA ) >
+<!ELEMENT gender ( #PCDATA | entElement )* >
+<!ELEMENT employee (employeeId, name, position, salary, gender, address) >
+<!ELEMENT staff (employee)+>
+<!ATTLIST entElement
+attr1 CDATA "Attr">
+<!ATTLIST address
+domestic CDATA #IMPLIED
+street CDATA "Yes">
+<!ATTLIST entElement
+domestic CDATA "MALE" >
+
Added: branches/tomek/portal-dnd/jsunit/tests/data/staff.xml
===================================================================
--- branches/tomek/portal-dnd/jsunit/tests/data/staff.xml 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/tests/data/staff.xml 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,58 @@
+<?xml version="1.0"?><?TEST-STYLE PIDATA?>
+<!DOCTYPE staff SYSTEM "staff.dtd" [
+ <!ENTITY ent1 "es">
+ <!ENTITY ent2 "1900 Dallas Road">
+ <!ENTITY ent3 "Texas">
+ <!ENTITY ent4 "<entElement domestic='Yes'>Element data</entElement><?PItarget PIdata?>">
+ <!ENTITY ent5 PUBLIC "entityURI" "entityFile" NDATA notation1>
+ <!ENTITY ent1 "This entity should be discarded">
+ <!NOTATION notation1 PUBLIC "notation1File">
+ <!NOTATION notation2 SYSTEM "notation2File">
+ ]>
+<!-- This is comment number 1.-->
+<staff>
+ <employee>
+ <employeeId>EMP0001</employeeId>
+ <name>Margaret Martin</name>
+ <position>Accountant</position>
+ <salary>56,000</salary>
+ <gender>Female</gender>
+ <address domestic="Yes">1230 North Ave. Dallas, Texas 98551</address>
+ </employee>
+ <employee>
+ <employeeId>EMP0002</employeeId>
+ <name>Martha Raynolds<![CDATA[This is a CDATASection with EntityReference number 2 &ent2;]]>
+ <![CDATA[This is an adjacent CDATASection with a reference to a tab &tab;]]></name>
+ <position>Secretary</position>
+ <salary>35,000</salary>
+ <gender>Female</gender>
+ <address domestic="Yes" street="Yes">&ent2; Dallas, &ent3;
+ 98554</address>
+ </employee>
+ <employee>
+ <employeeId>EMP0003</employeeId>
+ <name>Roger
+ Jones</name>
+ <position>Department Manager</position>
+ <salary>100,000</salary>
+ <gender>&ent4;
+ </gender>
+ <address domestic="Yes" street="No">PO Box 27 Irving, texas 98553</address>
+ </employee>
+ <employee>
+ <employeeId>EMP0004</employeeId>
+ <name>Jeny Oconnor</name>
+ <position>Personnel Director</position>
+ <salary>95,000</salary>
+ <gender>Female</gender>
+ <address domestic="Yes" street="Y&ent1;">27 South Road. Dallas, Texas 98556</address>
+ </employee>
+ <employee>
+ <employeeId>EMP0005</employeeId>
+ <name>Robert Myers</name>
+ <position>Computer Specialist</position>
+ <salary>90,000</salary>
+ <gender>male</gender>
+ <address street="Yes">1821 Nordic. Road, Irving Texas 98558</address>
+ </employee>
+</staff>
Added: branches/tomek/portal-dnd/jsunit/tests/jsUnitAssertionTests.html
===================================================================
--- branches/tomek/portal-dnd/jsunit/tests/jsUnitAssertionTests.html 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/tests/jsUnitAssertionTests.html 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,405 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>JsUnit Assertion Tests</title>
+<link rel="stylesheet" type="text/css" href="../css/jsUnitStyle.css">
+<script language="JavaScript" type="text/javascript" src="../app/jsUnitCore.js"></script>
+<script language="JavaScript" type="text/javascript">
+
+function testAssert() {
+ assert("true should be true", true);
+ assert(true);
+}
+
+function testAssertTrue() {
+ assertTrue("true should be true", true);
+ assertTrue(true);
+}
+
+function testAssertFalse() {
+ assertFalse("false should be false", false);
+ assertFalse(false);
+}
+
+function testAssertEquals() {
+ assertEquals("1 should equal 1", 1, 1);
+ assertEquals(1, 1);
+}
+
+function testAssertNotEquals() {
+ assertNotEquals("1 should not equal 2", 1, 2);
+ assertNotEquals(1, 2);
+}
+
+function testAssertNull() {
+ assertNull("null should be null", null);
+ assertNull(null);
+}
+
+function testAssertNotNull() {
+ assertNotNull("1 should not be null", 1);
+ assertNotNull(1);
+}
+
+function testAssertUndefined() {
+ var myVar;
+ assertUndefined("A declared but unassigned variable should have the undefined value", myVar);
+ assertUndefined(myVar);
+}
+
+function testAssertNotUndefined() {
+ assertNotUndefined("1 should not be undefined", 1);
+ assertNotUndefined(1);
+}
+
+function testAssertNaN() {
+ assertNaN("a string should not be a number", "string");
+ assertNaN("string");
+}
+
+function testAssertNotNaN() {
+ assertNotNaN("1 should not be not a number", 1);
+ assertNotNaN(1);
+}
+
+function testFail() {
+ var excep = null;
+ try {
+ fail("Failure message");
+ } catch (e) {
+ excep = e;
+ }
+ assertJsUnitException("fail(string) should throw a JsUnitException", excep);
+}
+
+function testTooFewArguments() {
+ var excep = null;
+ try {
+ assert();
+ } catch (e1) {
+ excep = e1;
+ }
+ assertNonJsUnitException("Calling an assertion function with too few arguments should throw an exception", excep);
+}
+
+function testTooManyArguments() {
+ var excep = null;
+ try {
+ assertEquals("A comment", true, true, true);
+ } catch (e2) {
+ excep = e2;
+ }
+ assertNonJsUnitException("Calling an assertion function with too many arguments should throw an exception", excep);
+}
+
+function testInvalidCommentArgumentType() {
+ var excep = null;
+ try {
+ assertNull(1, true);
+ } catch (e3) {
+ excep = e3;
+ }
+ assertNonJsUnitException("Calling an assertion function with a non-string comment should throw an exception", excep);
+}
+
+function testInvalidArgumentType() {
+ var excep = null;
+ try {
+ assert("string");
+ } catch (e) {
+ excep = e;
+ }
+ assertNonJsUnitException("Calling an assertion function with an invalid argument should throw an exception", excep);
+}
+
+function testAssertArrayEquals() {
+ var array1 = Array();
+ array1[0] = "foo";
+ array1[1] = "bar";
+ array1[2] = "foobar";
+ var array2 = Array();
+ array2[0] = "foo";
+ array2[1] = "bar";
+ array2[2] = "foobar";
+ var array3 = Array();
+ array3[0] = "foo";
+ array3[1] = "bar";
+ var array4 = Array();
+ array4[0] = "bar";
+ array4[1] = "foo";
+ array4[2] = "foobar";
+
+ assertArrayEquals(array1, array1);
+ assertArrayEquals(array1, array2);
+ try {
+ assertArrayEquals(array1, array3);
+ fail("Should not be equal");
+ } catch (e) {
+ assertJsUnitException("Should be a JsUnitException", e);
+ if (e.comment == "Call to fail()")
+ fail(e.comment + e.jsUnitMessage); //tried fail is also caught
+ }
+ try {
+ assertArrayEquals(array1, array4);
+ fail("Should not be equal");
+ } catch (e) {
+ assertJsUnitException("Should be a JsUnitException", e);
+ if (e.comment == "Call to fail()")
+ fail(e.comment + e.jsUnitMessage); //tried fail is also caught
+ }
+ var array5 = ['foo', 'bar', ['nested', 'bar'], 'foobar'];
+ var array6 = ['foo', 'bar', ['nested', 'bar'], 'foobar'];
+ var array7 = ['foo', 'bar', ['nested', 'foo'], 'foobar'];
+ assertArrayEquals('Equal nested arrays', array5, array6);
+ try
+ {
+ assertArrayEquals(array5, array7);
+ var failure = 'Differing nested arrays found to be equal';
+ fail(failure);
+ }
+ catch (e)
+ {
+ assertJsUnitException("Should be a JsUnitException", e);
+ if (e.jsUnitMessage == failure)
+ fail(e.jsUnitMessage);
+ }
+}
+
+function testAssertObjectEquals()
+{
+ var failure;
+ var o1 = {foo:'bar'};
+ var o2 = {foo:'bar'};
+ assertObjectEquals('Single object', o1, o1);
+ assertObjectEquals('Same objects', o1, o2);
+ var o3 = {foo:'foo'};
+ var o4 = {foo:'foo',
+ bar: function () {
+ this.foo = 'bar';
+ delete this.bar
+ }};
+ var o5 = {foo:'foo',
+ bar: function () {
+ this.foo = 'foo';
+ delete this.bar
+ }};
+ try
+ {
+ assertObjectEquals(o1, o3);
+ fail(failure = 'Simple differing objects found to be the same');
+ }
+ catch (e)
+ {
+ assertJsUnitException("Should be a JsUnitException", e);
+ if (e.jsUnitMessage == failure)
+ fail(e.jsUnitMessage);
+ }
+ try
+ {
+ assertObjectEquals(o4, o5);
+ fail(failure = 'Objects with different methods found to be the same');
+ }
+ catch (e)
+ {
+ assertJsUnitException("Should be a JsUnitException", e);
+ if (e.jsUnitMessage == failure)
+ fail(e.jsUnitMessage);
+ }
+
+ o4.bar();
+ assertObjectEquals('Different objects, made to be the same', o1, o4);
+ try
+ {
+ assertObjectEquals({ts:new Date()}, {ts:new Date()});
+ fail(failure = 'Objects with different Date attributes found to be the same');
+ }
+ catch (e)
+ {
+ assertJsUnitException("Should be a JsUnitException", e);
+ if (e.jsUnitMessage == failure)
+ fail(e.jsUnitMessage);
+ }
+ try
+ {
+ assertObjectEquals(new Date(), new Date());
+ fail(failure = 'Different Date objects found to be the same');
+ }
+ catch (e)
+ {
+ assertJsUnitException("Should be a JsUnitException", e);
+ if (e.jsUnitMessage == failure)
+ fail(e.jsUnitMessage);
+ }
+ assertObjectEquals(/a/, new RegExp('a'));
+ assertObjectEquals(/a/i, new RegExp('a', 'i'));
+
+ try
+ {
+ assertObjectEquals(/a/i, new RegExp('a', 'g'));
+ fail(failure = 'RegExp with different flags found to be the same');
+ }
+ catch (e)
+ {
+ assertJsUnitException("Should be a JsUnitException", e);
+ if (e.jsUnitMessage == failure)
+ fail(e.jsUnitMessage);
+ }
+ try
+ {
+ assertObjectEquals(/a/, new RegExp('b'));
+ fail(failure = 'RegExp with different patterns found to be the same');
+ }
+ catch (e)
+ {
+ assertJsUnitException("Should be a JsUnitException", e);
+ if (e.jsUnitMessage == failure)
+ fail(e.jsUnitMessage);
+ }
+}
+
+function testAssertObjectEqualsOnStrings() {
+ var s1 = 'string1';
+ var s2 = 'string1';
+ var newS1 = new String('string1');
+ assertObjectEquals('Same Strings', s1, s2);
+ assertObjectEquals('Same Strings 1 with new', s1, newS1);
+}
+
+function testAssertObjectEqualsOnNumbers() {
+ var failure;
+ var n1 = 1;
+ var n2 = 1;
+ var newN1 = new Number(1);
+ assertObjectEquals('Same Numbers', n1, n2);
+ assertObjectEquals('Same Numbers 1 with new', n1, newN1);
+ var n3 = 2;
+ var newN3 = new Number(2);
+ try
+ {
+ assertObjectEquals(n1, n3);
+ fail(failure = 'Different Numbers');
+ }
+ catch (e)
+ {
+ assertJsUnitException("Should be a JsUnitException", e);
+ if (e.jsUnitMessage == failure)
+ fail(e.jsUnitMessage);
+ }
+ try
+ {
+ assertObjectEquals(newN1, newN3);
+ fail(failure = 'Different New Numbers');
+ }
+ catch (e)
+ {
+ assertJsUnitException("Should be a JsUnitException", e);
+ if (e.jsUnitMessage == failure)
+ fail(e.jsUnitMessage);
+ }
+
+}
+
+function testAssertEvaluatesToTrue() {
+ assertEvaluatesToTrue("foo");
+ assertEvaluatesToTrue(true);
+ assertEvaluatesToTrue(1);
+ try {
+ assertEvaluatesToTrue(null);
+ fail("Should have thrown a JsUnitException");
+ } catch (e) {
+ assertJsUnitException("Should be a JsUnitException", e);
+ }
+}
+
+function testAssertEvaluatesToFalse() {
+ assertEvaluatesToFalse("");
+ assertEvaluatesToFalse(null);
+ assertEvaluatesToFalse(false);
+ assertEvaluatesToFalse(0);
+ try {
+ assertEvaluatesToFalse("foo");
+ fail("Should have thrown a JsUnitException");
+ } catch (e) {
+ assertJsUnitException("Should be a JsUnitException", e);
+ }
+}
+
+function testAssertHTMLEquals() {
+ assertHTMLEquals("<div id=mydiv>foobar</div>", "<div id='mydiv'>foobar</div>");
+ assertHTMLEquals("<p/>", "<p></p>");
+ assertHTMLEquals("foo bar", "foo bar");
+ assertHTMLEquals("a comment", "<p id='foo'>foo bar</p>", "<p id=foo>foo bar</p>");
+}
+
+function testAssertHashEquals() {
+ var hash1 = new Array();
+ hash1["key1"] = "value1";
+ hash1["key2"] = "value2";
+
+ var hash2 = new Array();
+ try {
+ assertHashEquals(hash1, hash2);
+ fail();
+ } catch (e) {
+ assertJsUnitException("hash2 is empty", e);
+ }
+ hash2["key1"] = "value1";
+ try {
+ assertHashEquals(hash1, hash2);
+ fail();
+ } catch (e) {
+ assertJsUnitException("hash2 is a of a different size", e);
+ }
+ hash2["key2"] = "foo";
+ try {
+ assertHashEquals(hash1, hash2);
+ fail();
+ } catch (e) {
+ assertJsUnitException("hash2 has different values", e);
+ }
+ hash2["key2"] = "value2";
+ assertHashEquals(hash1, hash2);
+}
+
+function testAssertRoughlyEquals() {
+ assertRoughlyEquals(1, 1.1, 0.5);
+ assertRoughlyEquals(1, 5, 6);
+ assertRoughlyEquals(-4, -5, 2);
+ assertRoughlyEquals(-0.5, 0.1, 0.7);
+ try {
+ assertRoughlyEquals(1, 2, 0.5);
+ } catch (e) {
+ assertJsUnitException("1 and 2 are more than 0.5 apart", e);
+ }
+}
+
+function testAssertContains() {
+ assertContains("foo", "foobar");
+ assertContains("ooba", "foobar");
+ assertContains("bar", "foobar");
+}
+
+function assertJsUnitException(comment, allegedJsUnitException) {
+ assertNotNull(comment, allegedJsUnitException);
+ assert(comment, allegedJsUnitException.isJsUnitException);
+ assertNotUndefined(comment, allegedJsUnitException.comment);
+}
+
+function assertNonJsUnitException(comment, allegedNonJsUnitException) {
+ assertNotNull(comment, allegedNonJsUnitException);
+ assertUndefined(comment, allegedNonJsUnitException.isJsUnitException);
+ assertNotUndefined(comment, allegedNonJsUnitException.description);
+}
+</script>
+</head>
+
+<body>
+<h1>JsUnit Assertion Tests</h1>
+
+<p>This page contains tests for the JsUnit Assertion
+ functions. To see them, take a look at the source.</p>
+</body>
+</html>
Added: branches/tomek/portal-dnd/jsunit/tests/jsUnitFrameworkUtilityTests.html
===================================================================
--- branches/tomek/portal-dnd/jsunit/tests/jsUnitFrameworkUtilityTests.html 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/tests/jsUnitFrameworkUtilityTests.html 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,99 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>JsUnit StackTrace Tests</title>
+ <link rel="stylesheet" type="text/css" href="../css/jsUnitStyle.css">
+ <script language="JavaScript" type="text/javascript" src="../app/jsUnitCore.js"></script>
+
+ <script language="JavaScript" type="text/javascript">
+
+ function testStackTrace() {
+ doStackTraceTest(3, "testStackTrace");
+ }
+
+ function doStackTraceTest(numberLeft, testFunctionName) {
+ if (numberLeft > 0) {
+ doStackTraceTest(numberLeft - 1, testFunctionName);
+ return;
+ }
+ assertEquals("> doStackTraceTest\n> doStackTraceTest\n> doStackTraceTest\n> doStackTraceTest\n> " + testFunctionName + "\n", getStackTrace());
+ }
+
+ function testJsUnitTestSuiteClass() {
+ var aSuite = new top.jsUnitTestSuite();
+ aSuite.addTestPage("foo.html");
+ aSuite.addTestPage("bar.html");
+ assertEquals(2, aSuite.testPages.length);
+ assertEquals("foo.html", aSuite.testPages[0]);
+ assertEquals("bar.html", aSuite.testPages[1]);
+ var anotherSuite = new top.jsUnitTestSuite();
+ anotherSuite.addTestPage("foo2.html");
+ anotherSuite.addTestPage("bar2.html");
+ aSuite.addTestSuite(anotherSuite);
+ assertEquals(4, aSuite.testPages.length);
+ assertEquals("foo.html", aSuite.testPages[0]);
+ assertEquals("bar.html", aSuite.testPages[1]);
+ assertEquals("foo2.html", aSuite.testPages[2]);
+ assertEquals("bar2.html", aSuite.testPages[3]);
+ }
+
+ function testTracing() {
+ warn("This is warning 1", "foo");
+ warn("This is warning 2");
+ inform("This is info 1", "foo");
+ inform("This is info 2");
+ debug("This is debug 1", "foo");
+ debug("This is debug 2");
+ info("This is info 3", "foo");
+ info("This is info 4");
+ }
+
+ function testTracingWithUndefinedValue() {
+ inform(JSUNIT_UNDEFINED_VALUE);
+ inform("JSUNIT_UNDEFINED_VALUE", JSUNIT_UNDEFINED_VALUE);
+ }
+
+ function testTraceLevel() {
+ var levelA = new top.JsUnitTraceLevel(100, "foo");
+ var levelB = new top.JsUnitTraceLevel(200, "bar");
+ var levelC = new top.JsUnitTraceLevel(300, "foobar");
+ assertFalse(levelA.matches(levelB));
+ assertTrue(levelB.matches(levelB));
+ assertTrue(levelC.matches(levelB));
+ assertEquals("bar", levelB.getColor());
+ }
+
+ function testDisplayStringForNumber() {
+ assertEquals("<3> (Number)", _displayStringForValue(3));
+ }
+
+ function testDisplayStringForString() {
+ assertEquals("<foo> (String)", _displayStringForValue("foo"));
+ }
+
+ function testDisplayStringForNull() {
+ assertEquals("<null>", _displayStringForValue(null));
+ }
+
+ function testDisplayStringForUndefined() {
+ assertEquals("<undefined>", _displayStringForValue(JSUNIT_UNDEFINED_VALUE));
+ }
+
+ function testDisplayStringForArray() {
+ var anArray = new Array();
+ anArray[0] = "foo";
+ anArray[1] = "bar";
+ assertEquals("<foo,bar> (Array)", _displayStringForValue(anArray));
+ }
+
+ </script>
+</head>
+
+<body>
+<h1>JsUnit Utility Tests</h1>
+
+<p>This page contains tests for the JsUnit framework uses. To see them, take a look at the source.</p>
+</body>
+</html>
Added: branches/tomek/portal-dnd/jsunit/tests/jsUnitMockTimeoutTest.html
===================================================================
--- branches/tomek/portal-dnd/jsunit/tests/jsUnitMockTimeoutTest.html 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/tests/jsUnitMockTimeoutTest.html 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,180 @@
+<html>
+<head>
+<title>Tests for jsUnitMockTimeout.js</title>
+<script language="javascript" src="../app/jsUnitCore.js"></script>
+<script src="../app/jsUnitMockTimeout.js" type="text/javascript"></script>
+<script language="javascript">
+var clockLand;
+
+function setUp() {
+ Clock.reset();
+ clockLand = "";
+}
+
+function testSimpleClock() {
+ setTimeout(function() {
+ clockLand = 'A';
+ }, 1000);
+ setTimeout(function() {
+ clockLand = 'B';
+ }, 2000);
+ setTimeout(function() {
+ clockLand = 'C';
+ }, 3000);
+ Clock.tick(1000);
+ assertEquals('A', clockLand);
+ Clock.tick(1000);
+ assertEquals('B', clockLand);
+ Clock.tick(1000);
+ assertEquals('C', clockLand);
+}
+
+function testClockOutOfOrder() {
+ setTimeout(function() {
+ clockLand = 'A';
+ }, 2000);
+ setTimeout(function() {
+ clockLand = 'B';
+ }, 1000);
+ setTimeout(function() {
+ clockLand = 'C';
+ }, 3000);
+ Clock.tick(1000);
+ assertEquals('B', clockLand);
+ Clock.tick(1000);
+ assertEquals('A', clockLand);
+ Clock.tick(1000);
+ assertEquals('C', clockLand);
+}
+
+function testTimeoutsCanBeCleared() {
+ setTimeout(function() {
+ clockLand = 'A';
+ }, 1000);
+ var timeoutToClear = setTimeout(function() {
+ clockLand = 'B';
+ }, 2000);
+ setTimeout(function() {
+ clockLand = 'C';
+ }, 3000);
+ clearTimeout(timeoutToClear);
+ Clock.tick(1000);
+ assertEquals('A', clockLand);
+ Clock.tick(1000);
+ assertEquals('A', clockLand);
+ Clock.tick(1000);
+ assertEquals('C', clockLand);
+}
+
+function testTimeoutWithinTimeout() {
+ var timeoutFunction = function() {
+ clockLand = "A";
+ setTimeout(function() {
+ clockLand = "B";
+ }, 10)
+ };
+
+ setTimeout(timeoutFunction, 100);
+ Clock.tick(100);
+ assertEquals('A', clockLand);
+ Clock.tick(10);
+ assertEquals('B', clockLand);
+}
+
+function testTimeoutWithRecursion() {
+ var recursiveFunction = function() {
+ clockLand = "A";
+ setTimeout(
+ function() {
+ recursiveFunction();
+ clockLand = "B";
+ }, 10);
+ }
+ setTimeout(recursiveFunction, 100);
+ Clock.tick(100);
+ assertEquals("A", clockLand);
+ Clock.tick(10);
+ assertEquals("B", clockLand);
+}
+
+function testTimeoutWithRecursionWithinTick() {
+ var recursiveFunction = function() {
+ clockLand = "A";
+ setTimeout(
+ function() {
+ recursiveFunction();
+ clockLand = "B";
+ }, 10);
+ }
+ setTimeout(recursiveFunction, 100);
+ Clock.tick(110);
+ assertEquals("B", clockLand);
+}
+
+function testTimeoutWithDelayedRecursion() {
+ var recursiveFunction = function() {
+ clockLand = "A";
+ setTimeout(
+ function() {
+ recursiveFunction();
+ clockLand = "B";
+ }, 100);
+ }
+ setTimeout(recursiveFunction, 10);
+ Clock.tick(10);
+ assertEquals("A", clockLand);
+ Clock.tick(100);
+ assertEquals("B", clockLand);
+}
+
+function testComplicatedBigTickWithOutOfOrderTimeouts() {
+ setTimeout(function() {
+ clockLand = 'A';
+ }, 4000);
+ setTimeout(function() {
+ clockLand = 'B';
+ }, 1000);
+ setTimeout(function() {
+ setTimeout(function() {
+ clockLand = 'D';
+ }, 1000);
+ clockLand = 'C';
+ }, 2000);
+ Clock.tick(4000);
+ assertEquals('D', clockLand);
+}
+
+function testBigTickWithOutOfOrderTimeouts() {
+ setTimeout(function() {
+ clockLand = 'A';
+ }, 3000);
+ setTimeout(function() {
+ clockLand = 'B';
+ }, 1000);
+ setTimeout(function() {
+ clockLand = 'C';
+ }, 2000);
+ Clock.tick(3000);
+ assertEquals('A', clockLand);
+}
+
+function testInterval() {
+ var currentInterval = 0;
+ var intervalKey = setInterval(function () {
+ ++currentInterval;
+ }, 200);
+ Clock.tick(200);
+ assertEquals(1, currentInterval);
+ Clock.tick(400);
+ assertEquals(3, currentInterval);
+ clearInterval(intervalKey);
+ Clock.tick(400);
+ assertEquals(3, currentInterval);
+}
+</script>
+
+</head>
+
+<body>
+</body>
+</html>
\ No newline at end of file
Added: branches/tomek/portal-dnd/jsunit/tests/jsUnitOnLoadTests.html
===================================================================
--- branches/tomek/portal-dnd/jsunit/tests/jsUnitOnLoadTests.html 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/tests/jsUnitOnLoadTests.html 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,28 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>JsUnit OnLoad Tests</title>
+ <link rel="stylesheet" type="text/css" href="../css/jsUnitStyle.css">
+ <script language="JavaScript" type="text/javascript" src="../app/jsUnitCore.js"></script>
+ <script language="JavaScript" type="text/javascript">
+
+ var aVar = null;
+
+ function testOnLoadFired() {
+ assertEquals("foo", aVar);
+ }
+ function myOnLoadEvent() {
+ aVar = "foo";
+ }
+ </script>
+</head>
+
+<body onload="myOnLoadEvent()">
+<h1>JsUnit OnLoad Tests</h1>
+
+<p>This page contains tests for the JsUnit Framework. To see them, take a look at the source.</p>
+</body>
+</html>
Added: branches/tomek/portal-dnd/jsunit/tests/jsUnitRestoredHTMLDivTests.html
===================================================================
--- branches/tomek/portal-dnd/jsunit/tests/jsUnitRestoredHTMLDivTests.html 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/tests/jsUnitRestoredHTMLDivTests.html 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,42 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>JsUnit Framework tests</title>
+ <link rel="stylesheet" type="text/css" href="../css/jsUnitStyle.css">
+ <script language="JavaScript" type="text/javascript" src="../app/jsUnitCore.js"></script>
+ <script language="JavaScript" type="text/javascript">
+
+ function testOriginalHTMLPresent1() {
+ assertJsUnitjsUnitRestoredHTMLDivContainsOriginalHTML();
+ }
+
+ function testAlterOriginalHTML() {
+ var theDiv = document.getElementById("jsUnitRestoredHTML");
+ theDiv.innerHTML = "something <i>totally</i> different";
+ }
+
+ function testOriginalHTMLPresent2() {
+ assertJsUnitjsUnitRestoredHTMLDivContainsOriginalHTML();
+ }
+
+ function assertJsUnitjsUnitRestoredHTMLDivContainsOriginalHTML() {
+ var theDiv = document.getElementById("jsUnitRestoredHTML");
+ assertHTMLEquals(
+ '<b>foo</b><input type="text" name="bar" value="12345">',
+ theDiv.innerHTML);
+ }
+
+ </script>
+</head>
+
+<body>
+<h1>JsUnit Framework tests</h1>
+
+<p>This page contains tests for the JsUnit setUp and tearDown framework. To see them, take a look at the source.</p>
+
+<div id="jsUnitRestoredHTML"><b>foo</b><input type="text" name="bar" value="12345"></div>
+
+</body>
+</html>
Added: branches/tomek/portal-dnd/jsunit/tests/jsUnitSetUpTearDownTests.html
===================================================================
--- branches/tomek/portal-dnd/jsunit/tests/jsUnitSetUpTearDownTests.html 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/tests/jsUnitSetUpTearDownTests.html 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,48 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>JsUnit Framework tests</title>
+ <link rel="stylesheet" type="text/css" href="../css/jsUnitStyle.css">
+ <script language="JavaScript" type="text/javascript" src="../app/jsUnitCore.js"></script>
+ <script language="JavaScript" type="text/javascript">
+
+ var atLeastOneTestHasRun = false;
+ var aVariable = null;
+
+ function setUp() {
+ aVariable = "foo";
+ }
+
+ function tearDown() {
+ atLeastOneTestHasRun = true;
+ aVariable = null;
+ }
+
+ function testEmpty1() {
+ }
+
+ function testSetUp() {
+ assertEquals("foo", aVariable);
+ }
+
+ function testEmpty2() {
+ }
+
+ function testTearDown() {
+ assertTrue(atLeastOneTestHasRun);
+ }
+
+ function testEmpty3() {
+ }
+
+ </script>
+</head>
+
+<body>
+<h1>JsUnit Framework tests</h1>
+
+<p>This page contains tests for the JsUnit setUp and tearDown framework. To see them, take a look at the source.</p>
+</body>
+</html>
Added: branches/tomek/portal-dnd/jsunit/tests/jsUnitTestLoadData.html
===================================================================
--- branches/tomek/portal-dnd/jsunit/tests/jsUnitTestLoadData.html 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/tests/jsUnitTestLoadData.html 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,39 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>Test loading a local HTML Document</title>
+ <link rel="stylesheet" type="text/css" href="../css/jsUnitStyle.css">
+ <script language="JavaScript" type="text/javascript" src="../app/jsUnitCore.js"></script>
+ <script language="JavaScript" type="text/javascript">
+
+ var uri = 'tests/data/data.html';
+
+ function setUpPage() {
+ setUpPageStatus = 'running';
+ top.testManager.documentLoader.callback = setUpPageComplete;
+ top.testManager.documentLoader.load(uri);
+ }
+
+ function setUpPageComplete() {
+ if (setUpPageStatus == 'running')
+ setUpPageStatus = 'complete';
+ }
+
+ function testDocumentGetElementsByTagName() {
+ assertEquals(setUpPageStatus, 'complete');
+ var buffer = top.testManager.documentLoader.buffer();
+ var elms = buffer.document.getElementsByTagName('P');
+ assert('getElementsByTagName("P") returned is null', elms != null);
+ assert('getElementsByTagName("P") is empty', elms.length > 0);
+ }
+
+ </script>
+</head>
+
+<body>
+<h1>JsUnit Asynchronous Load Tests</h1>
+
+<p>This page tests loading data documents asynchronously. To see them, take a look at the source.</p>
+</body>
+</html>
Added: branches/tomek/portal-dnd/jsunit/tests/jsUnitTestLoadStaff.html
===================================================================
--- branches/tomek/portal-dnd/jsunit/tests/jsUnitTestLoadStaff.html 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/tests/jsUnitTestLoadStaff.html 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,56 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>Test loading a local XML Document</title>
+ <link rel="stylesheet" type="text/css" href="../css/jsUnitStyle.css">
+ <script language="JavaScript" type="text/javascript" src="../app/jsUnitCore.js"></script>
+ <script language="JavaScript" type="text/javascript">
+ function exposeTestFunctionNames() {
+ return ['test1', 'test2', 'test3'];
+ }
+
+ var uri = 'tests/data/staff.xml';
+
+ function setUpPage() {
+ setUpPageStatus = 'running';
+ top.testManager.documentLoader.callback = setUpPageComplete;
+ top.testManager.documentLoader.load(uri);
+ }
+
+ function setUpPageComplete() {
+ if (setUpPageStatus == 'running')
+ setUpPageStatus = 'complete';
+ }
+
+ function test1() {
+ assertEquals(setUpPageStatus, 'complete');
+ var buffer = top.testManager.documentLoader.buffer();
+ var elms = buffer.document.getElementsByTagName('*');
+ assert('getElementsByTagName("*") returned is null', elms != null);
+ assert('getElementsByTagName("*") is empty', elms.length > 0);
+ }
+
+ function test2() {
+ var buffer = top.testManager.documentLoader.buffer();
+ var elm = buffer.document.documentElement;
+ assert('expected documentElement.tagName == staff, found ' + elm.tagName, elm.tagName == 'staff');
+ }
+
+ function test3() {
+ var buffer = top.testManager.documentLoader.buffer();
+ var emps = buffer.document.getElementsByTagName('employee');
+ assert('expected 5 employee elements, found ' + emps.length, emps.length == 5);
+ var empid = emps[0].getElementsByTagName('employeeId');
+ assert('expected first employeeId EMP0001, found ' + empid[0].firstChild.data, empid[0].firstChild.data == 'EMP0001');
+ }
+ </script>
+</head>
+
+<body>
+<h1>JsUnit Load XML</h1>
+
+<p>This page tests loading XML. To see them, take a look at the source.</p>
+</body>
+</html>
Added: branches/tomek/portal-dnd/jsunit/tests/jsUnitTestSetUpPages.html
===================================================================
--- branches/tomek/portal-dnd/jsunit/tests/jsUnitTestSetUpPages.html 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/tests/jsUnitTestSetUpPages.html 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,37 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>Test loading a local HTML Document</title>
+ <link rel="stylesheet" type="text/css" href="../css/jsUnitStyle.css">
+ <script language="JavaScript" type="text/javascript" src="../app/jsUnitCore.js"></script>
+ <script language="JavaScript" type="text/javascript">
+
+ function setUpPage() {
+ inform('setUpPage()');
+ setUpPageStatus = 'running';
+ // test delayed setUpPage completion
+ setTimeout('setUpPageComplete()', 30);
+ }
+
+ function setUpPageComplete() {
+ if (setUpPageStatus == 'running')
+ setUpPageStatus = 'complete';
+ inform('setUpPageComplete()', setUpPageStatus);
+ }
+
+ function testDocumentGetElementsByTagName() {
+ assertEquals(setUpPageStatus, 'complete');
+ }
+
+ </script>
+</head>
+
+<body>
+<h1>JsUnit Asynchronous setUpPages</h1>
+
+<p>This page tests asynchronoush pre tests. To see them, take a look at the source.</p>
+<iframe name="documentBuffer"></iframe>
+</body>
+</html>
Added: branches/tomek/portal-dnd/jsunit/tests/jsUnitTestSetUpPagesSuite.html
===================================================================
--- branches/tomek/portal-dnd/jsunit/tests/jsUnitTestSetUpPagesSuite.html 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/tests/jsUnitTestSetUpPagesSuite.html 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,30 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>JsUnit Test Suite</title>
+ <link rel="stylesheet" type="text/css" href="../css/jsUnitStyle.css">
+ <script language="JavaScript" type="text/javascript" src="../app/jsUnitCore.js"></script>
+ <script language="JavaScript" type="text/javascript">
+
+ function setUpPagesTestSuite() {
+ var newsuite = new top.jsUnitTestSuite();
+ newsuite.addTestPage("tests/jsUnitTestSetUpPages.html");
+ return newsuite;
+ }
+
+ function suite() {
+ var newsuite = new top.jsUnitTestSuite();
+ newsuite.addTestSuite(setUpPagesTestSuite());
+ return newsuite;
+ }
+ </script>
+</head>
+
+<body>
+<h1>JsUnit Test Suite</h1>
+
+<p>This page contains a suite of tests for testing JsUnit's setUpPages functionality.</p>
+</body>
+</html>
Added: branches/tomek/portal-dnd/jsunit/tests/jsUnitTestSuite.html
===================================================================
--- branches/tomek/portal-dnd/jsunit/tests/jsUnitTestSuite.html 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/tests/jsUnitTestSuite.html 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,43 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>JsUnit Test Suite</title>
+ <link rel="stylesheet" type="text/css" href="../css/jsUnitStyle.css">
+ <script language="JavaScript" type="text/javascript" src="../app/jsUnitCore.js"></script>
+ <script language="JavaScript" type="text/javascript">
+
+ function coreSuite() {
+ var result = new top.jsUnitTestSuite();
+ result.addTestPage("tests/jsUnitAssertionTests.html");
+ result.addTestPage("tests/jsUnitSetUpTearDownTests.html");
+ result.addTestPage("tests/jsUnitRestoredHTMLDivTests.html");
+ result.addTestPage("tests/jsUnitFrameworkUtilityTests.html");
+ result.addTestPage("tests/jsUnitOnLoadTests.html");
+ result.addTestPage("tests/jsUnitUtilityTests.html");
+ result.addTestPage("tests/jsUnitVersionCheckTests.html");
+ return result;
+ }
+
+ function librariesSuite() {
+ var result = new top.jsUnitTestSuite();
+ result.addTestPage("tests/jsUnitMockTimeoutTest.html");
+ return result;
+ }
+
+ function suite() {
+ var newsuite = new top.jsUnitTestSuite();
+ newsuite.addTestSuite(coreSuite());
+ newsuite.addTestSuite(librariesSuite());
+ return newsuite;
+ }
+ </script>
+</head>
+
+<body>
+<h1>JsUnit Test Suite</h1>
+
+<p>This page contains a suite of tests for testing JsUnit.</p>
+</body>
+</html>
Added: branches/tomek/portal-dnd/jsunit/tests/jsUnitUtilityTests.html
===================================================================
--- branches/tomek/portal-dnd/jsunit/tests/jsUnitUtilityTests.html 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/tests/jsUnitUtilityTests.html 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,100 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>JsUnit Utility Tests</title>
+ <link rel="stylesheet" type="text/css" href="../css/jsUnitStyle.css">
+ <script language="JavaScript" type="text/javascript" src="../app/jsUnitCore.js"></script>
+ <script language="JavaScript" type="text/javascript">
+ function testTrim() {
+ assertEquals(null, trim(null));
+ assertEquals(null, trim(JSUNIT_UNDEFINED_VALUE));
+ assertEquals("", trim(""));
+ assertEquals("", trim(" "));
+ assertEquals("string", trim("string"));
+ assertEquals("str ing", trim("str ing"));
+ assertEquals("string", trim(" string "));
+ }
+
+ function testIsBlank() {
+ assert(!isBlank(" string "));
+ assert(isBlank(""));
+ assert(isBlank(" "));
+ }
+
+ function testPushAndPop() {
+ //the functions push(anArray, anObject) and pop(anArray) exist because the JavaScript Array.push(anObject) and Array.pop() functions are not available in IE 5.0
+ var anArray = Array();
+ anArray[0] = "element 0";
+ anArray[1] = "element 1";
+ push(anArray, "element 2");
+ push(anArray, "element 3");
+
+ assertEquals("There should be 4 elements after 2 are pushed onto an array of size 2", 4, anArray.length);
+ assertEquals("element 0", anArray[0]);
+ assertEquals("element 1", anArray[1]);
+ assertEquals("element 2", anArray[2]);
+ assertEquals("element 3", anArray[3]);
+
+ pop(anArray);
+ assertEquals("Should be 3 elements after popping 1 from an array of size 4", 3, anArray.length);
+ assertEquals("element 0", anArray[0]);
+ assertEquals("element 1", anArray[1]);
+ assertEquals("element 2", anArray[2]);
+ pop(anArray);
+ pop(anArray);
+ pop(anArray);
+ assertEquals("Should be 0 elements after popping 3 from an array of size 3", 0, anArray.length);
+ pop(anArray);
+ assertEquals("Should be 0 elements after trying to pop an array of size 0", 0, anArray.length);
+ }
+
+ function FooBarThingy() {
+ this.foo = 'bar';
+ }
+
+ FooBarThingy.prototype.bar = function() {
+ return this.foo;
+ }
+
+ function testTrueTypeOf() {
+ assertEquals('Boolean', _trueTypeOf(true));
+ assertEquals('Using new', 'Boolean', _trueTypeOf(new Boolean('1')));
+
+ assertEquals('Number', _trueTypeOf(1));
+ var GI = new Number(1);
+ assertEquals('Using new', 'Number', _trueTypeOf(GI));
+ assertEquals('Number', _trueTypeOf(1.5));
+
+ assertEquals('String', _trueTypeOf('foo'));
+ assertEquals('Using new', 'String', _trueTypeOf(new String('foo')));
+
+ assertEquals('Using new', 'Function', _trueTypeOf(new Function()));
+ assertEquals('Function', _trueTypeOf(function foo() {
+ }));
+ assertEquals('Function', _trueTypeOf(testTrueTypeOf));
+
+ assertEquals('RegExp', _trueTypeOf(/foo/));
+ assertEquals('Using new', 'RegExp', _trueTypeOf(new RegExp('foo')));
+
+ var o = {foo: 'bar'};
+ assertEquals('Object', _trueTypeOf(o));
+ var o = new FooBarThingy();
+ assertEquals('FooBarThingy', _trueTypeOf(o));
+ assertEquals('String', _trueTypeOf(o.foo));
+ assertEquals('String', _trueTypeOf(o.bar()));
+ assertEquals('Function', _trueTypeOf(o.bar));
+
+ assertEquals('Object without constructor', 'Object', _trueTypeOf(window));
+ }
+ </script>
+</head>
+
+<body>
+<h1>JsUnit Utility Tests</h1>
+
+<p>This page contains tests for the utility functions
+ that JsUnit uses. To see them, take a look at the source.</p>
+</body>
+</html>
Added: branches/tomek/portal-dnd/jsunit/tests/jsUnitVersionCheckTests.html
===================================================================
--- branches/tomek/portal-dnd/jsunit/tests/jsUnitVersionCheckTests.html 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/jsunit/tests/jsUnitVersionCheckTests.html 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,131 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+
+<html>
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title>JsUnit Version Check Tests</title>
+<link rel="stylesheet" type="text/css" href="../css/jsUnitStyle.css">
+<script language="JavaScript" type="text/javascript" src="../app/jsUnitCore.js"></script>
+<script language="JavaScript" type="text/javascript" src="../app/jsUnitVersionCheck.js"></script>
+<script language="JavaScript" type="text/javascript">
+
+var versionLatestCalled;
+var versionNotLatestCalled;
+var versionCheckErrorCalled;
+var latestVersion;
+
+MockXmlHttpRequest = function() {
+}
+
+MockXmlHttpRequest.prototype.open = function (method, url, isAsync, userName, password) {
+ this.method = method;
+ this.url = url;
+ this.isAsync = isAsync;
+ this.userName = userName;
+ this.password = password;
+}
+
+MockXmlHttpRequest.prototype.send = function (data) {
+ this.sendCalled = true;
+ this.data = data;
+}
+
+function setUp() {
+ versionRequest = new MockXmlHttpRequest();
+ versionLatestCalled = false;
+ versionNotLatestCalled = false;
+ versionCheckErrorCalled = false;
+ latestVersion = null;
+}
+
+function createXmlHttpRequest() {
+ return versionRequest;
+}
+
+function versionNotLatest(aVersion) {
+ versionNotLatestCalled = true;
+ latestVersion = aVersion;
+}
+
+function versionLatest() {
+ versionLatestCalled = true;
+}
+
+function versionCheckError() {
+ versionCheckErrorCalled = true;
+}
+
+function testIsOutOfDate() {
+ assertTrue(isOutOfDate("" + (JSUNIT_VERSION + 1)));
+ assertFalse(isOutOfDate("" + JSUNIT_VERSION));
+ assertFalse(isOutOfDate("" + (JSUNIT_VERSION - 1)));
+}
+
+function testSendRequestForLatestVersion() {
+ sendRequestForLatestVersion("http://www.example.com/foo/bar/version.txt");
+ assertEquals("GET", versionRequest.method);
+ assertEquals("http://www.example.com/foo/bar/version.txt", versionRequest.url);
+ assertTrue(versionRequest.isAsync);
+ assertUndefined(versionRequest.userName);
+ assertUndefined(versionRequest.password);
+
+ assertTrue(versionRequest.sendCalled);
+ assertNull(versionRequest.data);
+
+ assertEquals(requestStateChanged, versionRequest.onreadystatechange);
+}
+
+function testBadResponse() {
+ versionRequest.readyState = 999;
+ versionRequest.status = 404;
+ requestStateChanged();
+ assertFalse("both bad", versionNotLatestCalled);
+ assertFalse("both bad", versionLatestCalled);
+ assertFalse(versionCheckErrorCalled);
+
+ versionRequest.status = 200;
+ requestStateChanged();
+ assertFalse("readyState bad", versionNotLatestCalled);
+ assertFalse("readyState bad", versionLatestCalled);
+ assertFalse(versionCheckErrorCalled);
+
+ versionRequest.readyState = 4;
+ versionRequest.status = 404;
+ requestStateChanged();
+ assertFalse("status bad", versionNotLatestCalled);
+ assertFalse("status bad", versionLatestCalled);
+ assertTrue(versionCheckErrorCalled);
+}
+
+function testReceiveNewerLatestVersion() {
+ versionRequest.readyState = 4;
+ versionRequest.status = 200;
+ versionRequest.responseText = "" + (JSUNIT_VERSION + 1);
+ requestStateChanged();
+ assertTrue(versionNotLatestCalled);
+ assertFalse(versionLatestCalled);
+ assertEquals("" + (JSUNIT_VERSION + 1), latestVersion);
+}
+
+function testReceiveSameLatestVersion() {
+ versionRequest.readyState = 4;
+ versionRequest.status = 200;
+ versionRequest.responseText = "" + JSUNIT_VERSION;
+ requestStateChanged();
+ assertFalse(versionNotLatestCalled);
+ assertTrue(versionLatestCalled);
+}
+
+function enablePrivileges() {
+}
+
+</script>
+</head>
+
+<body>
+<h1>JsUnit Version Check Tests</h1>
+
+<p>This page contains tests for the version checking code in JsUnit that looks to see whether a newer version of JsUnit
+ is available. To see them, take a look at the source.</p>
+</body>
+</html>
Added: branches/tomek/portal-dnd/lib/portal-api-lib.jar
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/lib/portal-api-lib.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/lib/portal-common-lib.jar
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/lib/portal-common-lib.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/lib/portal-core-lib.jar
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/lib/portal-core-lib.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/lib/portal-theme-lib.jar
===================================================================
(Binary files differ)
Property changes on: branches/tomek/portal-dnd/lib/portal-theme-lib.jar
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/tomek/portal-dnd/src/java/org/jboss/portal/core/theme/render/impl/DnDDecorationRenderer.java
===================================================================
--- branches/tomek/portal-dnd/src/java/org/jboss/portal/core/theme/render/impl/DnDDecorationRenderer.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/src/java/org/jboss/portal/core/theme/render/impl/DnDDecorationRenderer.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.portal.core.theme.render.impl;
+
+import org.jboss.logging.Logger;
+import org.jboss.portal.theme.page.WindowContext;
+import org.jboss.portal.theme.page.WindowResult;
+import org.jboss.portal.theme.render.DecorationRenderer;
+import org.jboss.portal.theme.render.RenderContext;
+import org.jboss.portal.theme.render.RenderException;
+
+/**
+ * Implementation of a drag and drop decoration renderer.
+ *
+ * @author <a href="mailto:tomasz.szymanski at jboss.com">Tomasz Szymanski</a>
+ * @version $LastChangedRevision$, $LastChangedDate$
+ * @see org.jboss.portal.theme.render.DecorationRenderer
+ */
+public class DnDDecorationRenderer implements DecorationRenderer {
+ private static Logger log = Logger.getLogger(DnDDecorationRenderer.class);
+
+ private DecorationRenderer delegate;
+
+ public DnDDecorationRenderer() throws InstantiationException,
+ IllegalAccessException, ClassNotFoundException {
+ super();
+ delegate = (DecorationRenderer) DnDTools.getRendererClass(
+ DnDTools.DECOR_CLASS).newInstance();
+ }
+
+ /**
+ * @see org.jboss.portal.theme.render.Renderer#renderStart
+ */
+ public void renderStart(RenderContext ctx) {
+ delegate.renderStart(ctx);
+ }
+
+ /**
+ * @see org.jboss.portal.theme.render.Renderer#renderEnd
+ */
+ public void renderEnd(RenderContext ctx) {
+ delegate.renderEnd(ctx);
+ }
+
+ /**
+ * @see DecorationRenderer#render
+ */
+ public void render(RenderContext renderContext,
+ WindowContext portletContext, WindowResult result)
+ throws RenderException {
+
+ delegate.render(renderContext, portletContext, result);
+
+ }
+
+}
\ No newline at end of file
Added: branches/tomek/portal-dnd/src/java/org/jboss/portal/core/theme/render/impl/DnDPortletRenderer.java
===================================================================
--- branches/tomek/portal-dnd/src/java/org/jboss/portal/core/theme/render/impl/DnDPortletRenderer.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/src/java/org/jboss/portal/core/theme/render/impl/DnDPortletRenderer.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,70 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.portal.core.theme.render.impl;
+
+import org.jboss.portal.theme.page.WindowContext;
+import org.jboss.portal.theme.page.WindowResult;
+import org.jboss.portal.theme.render.PortletRenderer;
+import org.jboss.portal.theme.render.RenderContext;
+import org.jboss.portal.theme.render.RenderException;
+
+/**
+ * Implementation of a drag and drop Portlet renderer.
+ *
+ * @author <a href="mailto:tomasz.szymanski at jboss.com">Tomasz Szymanski</a>
+ * @version $LastChangedRevision$, $LastChangedDate$
+ * @see org.jboss.portal.theme.render.PortletRenderer
+ */
+public class DnDPortletRenderer implements PortletRenderer {
+
+ private PortletRenderer delegate;
+
+ public DnDPortletRenderer() throws InstantiationException,
+ IllegalAccessException, ClassNotFoundException {
+ super();
+ delegate = (PortletRenderer) DnDTools.getRendererClass(
+ DnDTools.PORLTET_CLASS).newInstance();
+ }
+ /**
+ * @see PortletRenderer#render
+ */
+ public void render(RenderContext renderContext, WindowContext state,
+ WindowResult result) throws RenderException {
+
+ delegate.render(renderContext, state, result);
+
+ }
+
+ /**
+ * @see org.jboss.portal.theme.render.Renderer#renderStart
+ */
+ public void renderStart(RenderContext ctx) {
+ delegate.renderStart(ctx);
+ }
+
+ /**
+ * @see org.jboss.portal.theme.render.Renderer#renderEnd
+ */
+ public void renderEnd(RenderContext ctx) {
+ delegate.renderEnd(ctx);
+ }
+}
Added: branches/tomek/portal-dnd/src/java/org/jboss/portal/core/theme/render/impl/DnDRegionRenderer.java
===================================================================
--- branches/tomek/portal-dnd/src/java/org/jboss/portal/core/theme/render/impl/DnDRegionRenderer.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/src/java/org/jboss/portal/core/theme/render/impl/DnDRegionRenderer.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,204 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.portal.core.theme.render.impl;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.jboss.logging.Logger;
+import org.jboss.portal.theme.page.Region;
+import org.jboss.portal.theme.render.RegionRenderer;
+import org.jboss.portal.theme.render.RenderContext;
+import org.jboss.portal.theme.render.RenderException;
+
+/**
+ * Implementation of a drag and drop Region renderer.
+ *
+ * @author <a href="mailto:tomasz.szymanski at jboss.com">Tomasz Szymanski</a>
+ * @version $LastChangedRevision$, $LastChangedDate$
+ * @see org.jboss.portal.theme.render.RegionRenderer
+ */
+public class DnDRegionRenderer implements RegionRenderer {
+
+ private Map<String, Integer> portletNumbers = new HashMap<String, Integer>();
+
+ private Map<String, String> windowIds = new HashMap<String, String>();
+
+ private final static Logger log = Logger.getLogger(DnDRegionRenderer.class);
+
+ private RegionRenderer delegate;
+
+ public DnDRegionRenderer() throws InstantiationException,
+ IllegalAccessException, ClassNotFoundException {
+ super();
+ delegate = (RegionRenderer) DnDTools.getRendererClass(
+ DnDTools.REGION_CLASS).newInstance();
+ }
+
+ /**
+ * @see RegionRenderer#render
+ */
+ public void render(RenderContext renderContext, Region region,
+ Map portletContexts, Map windowResults) throws RenderException {
+
+ if (renderContext.getLayoutRegionNames().get(0).equals(region.getId())) {
+ // add DND headers
+ renderContext.getMarkupFragment().append(DnDTools.DND_HEADERS);
+ }
+
+ renderContext.getMarkupFragment().append(
+ "<div id=\"regionDD" + renderContext.getRegionID() + "\">\n");
+
+ delegate.render(renderContext, region, portletContexts, windowResults);
+
+ renderContext.getMarkupFragment().append("</div>\n");
+
+ if (portletNumbers.get(renderContext.getRegionID()) != null
+ && portletNumbers.get(renderContext.getRegionID()) > 0) {
+ renderContext.getMarkupFragment().append(
+ "\n<script type='text/javascript'>\n");
+ renderContext.getMarkupFragment().append(
+ "YAHOO.example.DDApp" + renderContext.getRegionID()
+ + " = function() {\n");
+ renderContext.getMarkupFragment().append(" var ");
+ for (int i = 0; i < (portletNumbers
+ .get(renderContext.getRegionID())); i++) {
+ // add portlet vars
+ renderContext.getMarkupFragment().append(
+ "ddPortlet" + renderContext.getRegionID() + i + ", ");
+ }
+
+ // regionDD var
+ renderContext.getMarkupFragment().append(
+ "regionDrop" + renderContext.getRegionID() + ";\n");
+
+ renderContext.getMarkupFragment().append(
+ " var DDM = YAHOO.util.DDM;\n");
+ renderContext.getMarkupFragment().append(
+ " DDM.mode = DDM.POINT;\n");
+
+ renderContext.getMarkupFragment().append(" return {\n");
+ renderContext.getMarkupFragment().append(
+ " init: function() {\n");
+
+ // write regionDD var declaration
+ renderContext.getMarkupFragment().append(
+ " regionDrop" + renderContext.getRegionID()
+ + " = new YAHOO.util.PortalDD('regionDrop"
+ + renderContext.getRegionID() + "');\n");
+ renderContext.getMarkupFragment().append(
+ " regionDrop" + renderContext.getRegionID()
+ + ".setXConstraint(0, 0, 1);\n");
+ renderContext.getMarkupFragment().append(
+ " regionDrop" + renderContext.getRegionID()
+ + ".setYConstraint(0, 0, 1);\n");
+
+ for (int i = 0; i < portletNumbers.get(renderContext.getRegionID()); i++) {
+ // add new DnD objects
+
+ renderContext.getMarkupFragment().append(
+ " ddPortlet" + renderContext.getRegionID()
+ + i
+ + " = new YAHOO.util.PortalDD('portlet-dnd-"
+ + renderContext.getRegionID() + "-" + i
+ + "');\n");
+ renderContext.getMarkupFragment()
+ .append(
+ " ddPortlet"
+ + renderContext.getRegionID() + i
+ + ".windowId = \""+windowIds.get("portlet-dnd-"
+ + renderContext.getRegionID() + "-" + i)
+ + "\";\n");
+ /*
+ * renderContext.getMarkupFragment().append( " ddPortlet" +
+ * renderContext.getRegionID() + i + ".setXConstraint(1000,
+ * 1000, 1);\n"); renderContext.getMarkupFragment().append( "
+ * ddPortlet" + renderContext.getRegionID() + i +
+ * ".setYConstraint(1000, 1000, 1);\n");
+ */
+
+ /*
+ * renderContext.getMarkupFragment().append( " regionDD" +
+ * renderContext.getRegionID() + ".getDragEl().appendChild("+
+ * "ddPortlet" + renderContext.getRegionID() + i +
+ * ".getDragEl());\n");
+ */
+ }
+
+ // add this regiondrop id
+ renderContext.getMarkupFragment().append(
+ " ddPortlet" + renderContext.getRegionID() + "0"
+ + ".getEl().parentNode.dropToRegion = 'regionDrop"
+ + renderContext.getRegionID() + "';\n");
+
+ // add this region id
+ renderContext.getMarkupFragment().append(
+ " ddPortlet" + renderContext.getRegionID() + "0"
+ + ".getEl().parentNode.regionId = '"
+ + region.getId() + "';\n");
+
+ renderContext.getMarkupFragment().append(" }\n");
+ renderContext.getMarkupFragment().append(" };\n");
+ renderContext.getMarkupFragment().append("} ();\n");
+ renderContext.getMarkupFragment().append(
+ "YAHOO.util.Event.addListener(window, 'load', YAHOO.example.DDApp"
+ + renderContext.getRegionID() + ".init);\n");
+ renderContext.getMarkupFragment().append(
+ "YAHOO.util.Event.addListener(window, 'load', cleanUpDocument(\"regionDD" + renderContext.getRegionID() +"\"));\n");
+
+
+ renderContext.getMarkupFragment().append("</script>\n\n");
+
+ portletNumbers.put(renderContext.getRegionID(), 0);
+ }
+ }
+
+ /**
+ * @see org.jboss.portal.theme.render.Renderer#renderStart(org.jboss.portal.theme.render.RenderContext)
+ */
+ public void renderStart(RenderContext ctx) {
+ delegate.renderStart(ctx);
+ }
+
+ /**
+ * @see org.jboss.portal.theme.render.Renderer#renderEnd(org.jboss.portal.theme.render.RenderContext)
+ */
+ public void renderEnd(RenderContext ctx) {
+ delegate.renderEnd(ctx);
+ }
+
+ public int getPortletNumber(String regionId) {
+
+ int number = 0;
+ if (portletNumbers.get(regionId) != null) {
+ number = portletNumbers.get(regionId);
+ }
+
+ portletNumbers.put(regionId, ++number);
+
+ return number - 1;
+ }
+
+ public void setWindowId(String portletId, String windowId) {
+ windowIds.put(portletId, windowId);
+ }
+}
Added: branches/tomek/portal-dnd/src/java/org/jboss/portal/core/theme/render/impl/DnDTools.java
===================================================================
--- branches/tomek/portal-dnd/src/java/org/jboss/portal/core/theme/render/impl/DnDTools.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/src/java/org/jboss/portal/core/theme/render/impl/DnDTools.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,68 @@
+package org.jboss.portal.core.theme.render.impl;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+
+import org.jboss.logging.Logger;
+
+public class DnDTools {
+
+ public static final String DECOR_CLASS = "decorationRenderer.class";
+ public static final String PORLTET_CLASS = "portletRenderer.class";
+ public static final String REGION_CLASS = "regionRenderer.class";
+ public static final String WINDOW_CLASS = "windowRenderer.class";
+
+ public static final String DND_PROP_FILENAME = "/dnd.properties";
+
+ private static final Logger log = Logger.getLogger(DnDTools.class);
+
+ public static final String DND_HEADERS = "\n\n\n<script type='text/javascript' src='/dndRenderer/js/yahoo/yahoo.js' ></script>\n"
+ + "<script type='text/javascript' src='/dndRenderer/js/event/event.js' ></script>\n"
+ + "<script type='text/javascript' src='/dndRenderer/js/dom/dom.js'></script>\n"
+ + "<script type='text/javascript' src='/dndRenderer/js/logger/logger.js' ></script>\n"
+ + "<script type='text/javascript' src='/dndRenderer/js/dragdrop/dragdrop-debug.js' ></script>\n"
+ + "<script type='text/javascript' src='/dndRenderer/js/connection/connection.js' ></script>\n"
+ + "<script type='text/javascript' src='/dndRenderer/js/portal/PortalDD.js' ></script>\n\n\n"
+ // comment out everything under this if you don't wanna have the logger
+
+ /*+ "<script type='text/javascript'>"
+ + "var myLogReader1 = new YAHOO.widget.LogReader(null, { newestOnTop: true, height: \"400px\" });"
+ + "</script>\n\n"
+
+ + "<style type=\"text/css\">\n"
+ + "#yui-log {position:absolute;top:1em;right:1em;font-size:77%;text-align:left; width: 300px}\n"
+ + ".yui-log {background-color:#AAA;border:1px solid black;font-family:monospace;z-index:9000;}\n"
+ + ".yui-log p {margin:1px;padding:.1em;}\n"
+ + ".yui-log button {font-family:monospace;}\n"
+ + ".yui-log .yui-log-hd {padding:.5em;background-color:#575757;color:#FFF;}\n"
+ + ".yui-log .yui-log-bd {width:100%;height:20em;background-color:#FFF;border:1px solid gray;overflow:auto;}\n"
+ + ".yui-log .yui-log-ft {margin-top:.5em;margin-bottom:1em;}\n"
+ + ".yui-log .yui-log-ft .yui-log-categoryfilters {}\n"
+ + ".yui-log .yui-log-ft .yui-log-sourcefilters {width:100%;border-top:1px solid #575757;margin-top:.75em;padding-top:.75em;}\n"
+ + ".yui-log .yui-log-btns {position:relative;float:right;bottom:.25em;}\n"
+ + ".yui-log .yui-log-filtergrp {margin-right:.5em;}\n"
+ + ".yui-log .info {background-color:#A7CC25;} \n"
+ + ".yui-log .warn {background-color:#F58516;}\n"
+ + ".yui-log .error {background-color:#E32F0B;} \n"
+ + ".yui-log .time {background-color:#A6C9D7;} \n"
+ + ".yui-log .window {background-color:#F2E886;} \n"
+ + "</style>\n\n"*/;
+
+ public static Class getRendererClass(String className) throws ClassNotFoundException{
+ Properties props = new Properties();
+
+ InputStream is = DnDTools.class.getResourceAsStream(DND_PROP_FILENAME);
+ try {
+ props.load(is);
+
+ Class clas = Class.forName(props.getProperty(className));
+
+ return clas;
+ } catch (IOException e) {
+ log.error(e);
+ throw new ClassNotFoundException(e.getMessage());
+ }
+ }
+}
Added: branches/tomek/portal-dnd/src/java/org/jboss/portal/core/theme/render/impl/DnDWindowRenderer.java
===================================================================
--- branches/tomek/portal-dnd/src/java/org/jboss/portal/core/theme/render/impl/DnDWindowRenderer.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/src/java/org/jboss/portal/core/theme/render/impl/DnDWindowRenderer.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,97 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.portal.core.theme.render.impl;
+
+import org.jboss.logging.Logger;
+import org.jboss.portal.theme.impl.render.DivWindowRenderer;
+import org.jboss.portal.theme.page.WindowContext;
+import org.jboss.portal.theme.page.WindowResult;
+import org.jboss.portal.theme.render.RegionRenderer;
+import org.jboss.portal.theme.render.RenderContext;
+import org.jboss.portal.theme.render.RenderException;
+import org.jboss.portal.theme.render.WindowRenderer;
+
+/**
+ * Implementation of a drag and drop WindowRenderer.
+ *
+ * @author <a href="mailto:tomasz.szymanski at jboss.com">Tomasz Szymanski</a>
+ * @version $LastChangedRevision$, $LastChangedDate$
+ * @see org.jboss.portal.theme.render.WindowRenderer
+ */
+public class DnDWindowRenderer implements WindowRenderer {
+ private static Logger log = Logger.getLogger(DnDWindowRenderer.class);
+
+ private WindowRenderer delegate;
+
+ public DnDWindowRenderer() throws InstantiationException,
+ IllegalAccessException, ClassNotFoundException {
+ super();
+ delegate = (WindowRenderer) DnDTools.getRendererClass(
+ DnDTools.WINDOW_CLASS).newInstance();
+ }
+
+ /**
+ * @see WindowRenderer#render
+ */
+ public void render(RenderContext renderContext,
+ WindowContext portletContext, WindowResult result)
+ throws RenderException {
+ int portletNumber = ((DnDRegionRenderer) renderContext
+ .getRegionRenderer()).getPortletNumber(renderContext
+ .getRegionID());
+
+ ((DnDRegionRenderer) renderContext.getRegionRenderer()).setWindowId(
+ "portlet-dnd-" + renderContext.getRegionID() + "-"
+ + portletNumber, portletContext.getWindowName());
+
+ if (portletNumber == 0) {
+ renderContext
+ .getMarkupFragment()
+ .append(
+ "<div style='display: none; visibility: hidden; padding: 50px; margin: 10px; border: 1px dashed black;' id='regionDrop"
+ + renderContext.getRegionID()
+ + "'>Drop your portlets here</div>");
+ }
+
+ renderContext.getMarkupFragment().append(
+ "<div id=\"portlet-dnd-" + renderContext.getRegionID() + "-"
+ + portletNumber + "\">\n");
+
+ delegate.render(renderContext, portletContext, result);
+
+ renderContext.getMarkupFragment().append("</div>");
+ }
+
+ /**
+ * @see org.jboss.portal.theme.render.Renderer#renderStart(org.jboss.portal.theme.render.RenderContext)
+ */
+ public void renderStart(RenderContext ctx) {
+ delegate.renderStart(ctx);
+ }
+
+ /**
+ * @see org.jboss.portal.theme.render.Renderer#renderEnd(org.jboss.portal.theme.render.RenderContext)
+ */
+ public void renderEnd(RenderContext ctx) {
+ delegate.renderEnd(ctx);
+ }
+}
Added: branches/tomek/portal-dnd/src/java/org/jboss/portal/dnd/DnDAjaxServlet.java
===================================================================
--- branches/tomek/portal-dnd/src/java/org/jboss/portal/dnd/DnDAjaxServlet.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/src/java/org/jboss/portal/dnd/DnDAjaxServlet.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,102 @@
+package org.jboss.portal.dnd;
+
+import java.io.IOException;
+import java.util.Date;
+import java.util.Enumeration;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.jboss.logging.Logger;
+
+public class DnDAjaxServlet extends HttpServlet {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ private static final String PERSIST = "PERSIST";
+
+ private static final String TEST_MODE = "TEST_MODE";
+
+ private final static Logger log = Logger.getLogger(DnDAjaxServlet.class);
+
+ private DnDPersistance persistance = new DnDPersistanceImpl();
+
+ private boolean testMode = false;
+
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, IOException {
+ doPost(req, resp);
+ }
+
+ protected void doPost(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, IOException {
+ Enumeration<String> attNames = req.getAttributeNames();
+ while (attNames.hasMoreElements()) {
+ String name = attNames.nextElement();
+ log.info("Attribute: " + name + " = " + req.getAttribute(name));
+ }
+
+ Enumeration<String> paramNames = req.getParameterNames();
+ while (paramNames.hasMoreElements()) {
+ String name = paramNames.nextElement();
+ log.info("Parameter: " + name + " = " + req.getParameter(name));
+ }
+
+ if (req.getParameter("action") != null) {
+ if (req.getParameter("action").equals(PERSIST)) {
+ if (req.getParameter("positionNo") == null
+ || req.getParameter("windowId") == null
+ || req.getParameter("oldRegionId") == null
+ || req.getParameter("newRegionId") == null) {
+ resp.sendError(400, "Not enought parameters");
+ return;
+ }
+
+ if (!testMode) {
+ persistance.persistPosition(req.getParameter("positionNo"),
+ req.getParameter("windowId"), req
+ .getParameter("oldRegionId"), req
+ .getParameter("newRegionId"));
+ }
+
+ sendResp(resp, "Position persisted");
+ } else if (req.getParameter("action").equals(TEST_MODE)) {
+ if (req.getParameter("mode") != null) {
+ try {
+ testMode = Boolean.valueOf(req.getParameter("mode"))
+ .booleanValue();
+ } catch (RuntimeException e) {
+ resp.sendError(400, "Bad arguments");
+ return;
+ }
+
+ sendResp(resp, ((testMode) ? "Test mode ON" : "Test mode OFF"));
+
+ } else {
+ resp.sendError(400, "Not enought parameters");
+ return;
+ }
+ } else {
+ resp.sendError(400, "Unknown ajax call");
+ return;
+ }
+ }
+ }
+
+ private void sendResp(HttpServletResponse resp, String respData)
+ throws IOException {
+ resp.setHeader("Expires", "Mon, 26 Jul 1997 05:00:00 GMT");
+ resp.setDateHeader("Last-Modified", new Date().getTime());
+ resp.setHeader("Cache-Control", "no-store, no-cache, must-revalidate");
+ resp.addHeader("Cache-Control", "post-check=0, pre-check=0");
+ resp.setContentType("text/html");
+
+ resp.getWriter().write(respData);
+ }
+
+}
Added: branches/tomek/portal-dnd/src/java/org/jboss/portal/dnd/DnDPersistance.java
===================================================================
--- branches/tomek/portal-dnd/src/java/org/jboss/portal/dnd/DnDPersistance.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/src/java/org/jboss/portal/dnd/DnDPersistance.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,7 @@
+package org.jboss.portal.dnd;
+
+public interface DnDPersistance {
+
+ public void persistPosition(String positionNo, String windowId,
+ String oldRegionId, String newRegionId);
+}
Added: branches/tomek/portal-dnd/src/java/org/jboss/portal/dnd/DnDPersistanceImpl.java
===================================================================
--- branches/tomek/portal-dnd/src/java/org/jboss/portal/dnd/DnDPersistanceImpl.java 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/src/java/org/jboss/portal/dnd/DnDPersistanceImpl.java 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,14 @@
+package org.jboss.portal.dnd;
+
+import org.jboss.logging.Logger;
+
+public class DnDPersistanceImpl implements DnDPersistance {
+
+ private final static Logger log = Logger.getLogger(DnDPersistanceImpl.class);
+
+ public void persistPosition(String positionNo, String windowId,
+ String oldRegionId, String newRegionId) {
+ log.info("New position persistance call: " + positionNo + " "
+ + windowId + " " + oldRegionId + " " + newRegionId);
+ }
+}
Added: branches/tomek/portal-dnd/test/ajaxAsserts.js
===================================================================
--- branches/tomek/portal-dnd/test/ajaxAsserts.js 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/test/ajaxAsserts.js 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,218 @@
+var ajaxFailMsg;
+var ajaxFailComment;
+var ajaxFailed = false;
+
+function invokeTestAjax(postData, handleSuccess, handleFailure) {
+
+ var callback =
+ {
+ success:handleSuccess,
+ failure: handleFailure,
+ argument: []
+ };
+
+ var request = YAHOO.util.Connect.syncRequest('POST', host+ajaxURI, callback, postData);
+
+ handleAjaxError();
+}
+
+function isAjaxProcessed() {
+ return ajaxProcessed;
+}
+
+function handleAjaxError() {
+
+ if(ajaxFailed) {
+ ajaxFailed = false;
+ _assert(ajaxFailComment, false, ajaxFailMsg);
+ }
+}
+
+function _assertAjax(comment, booleanValue, failureMessage) {
+ if (!booleanValue) {
+ ajaxFailMsg = failureMessage;
+ ajaxFailComment = comment;
+ ajaxFailed = true;
+ }
+}
+
+function failAjax(failureMessage) {
+ _assertAjax("Call fail()", false, failureMessage);
+}
+
+
+function assertAjax() {
+ _validateArguments(1, arguments);
+ var booleanValue = nonCommentArg(1, 1, arguments);
+
+ if (typeof(booleanValue) != 'boolean')
+ error('Bad argument to assert(boolean)');
+
+ _assertAjax(commentArg(1, arguments), booleanValue === true, 'Call to assert(boolean) with false');
+}
+
+function assertTrueAjax() {
+ _validateArguments(1, arguments);
+ var booleanValue = nonCommentArg(1, 1, arguments);
+
+ if (typeof(booleanValue) != 'boolean')
+ error('Bad argument to assertTrue(boolean)');
+
+ _assertAjax(commentArg(1, arguments), booleanValue === true, 'Call to assertTrue(boolean) with false');
+}
+
+function assertFalseAjax() {
+ _validateArguments(1, arguments);
+ var booleanValue = nonCommentArg(1, 1, arguments);
+
+ if (typeof(booleanValue) != 'boolean')
+ error('Bad argument to assertFalse(boolean)');
+
+ _assertAjax(commentArg(1, arguments), booleanValue === false, 'Call to assertFalse(boolean) with true');
+}
+
+function assertEqualsAjax() {
+ _validateArguments(2, arguments);
+ var var1 = nonCommentArg(1, 2, arguments);
+ var var2 = nonCommentArg(2, 2, arguments);
+ _assertAjax(commentArg(2, arguments), var1 === var2, 'Expected ' + _displayStringForValue(var1) + ' but was ' + _displayStringForValue(var2));
+}
+
+function assertNotEqualsAjax() {
+ _validateArguments(2, arguments);
+ var var1 = nonCommentArg(1, 2, arguments);
+ var var2 = nonCommentArg(2, 2, arguments);
+ _assertAjax(commentArg(2, arguments), var1 !== var2, 'Expected not to be ' + _displayStringForValue(var2));
+}
+
+function assertNullAjax() {
+ _validateArguments(1, arguments);
+ var aVar = nonCommentArg(1, 1, arguments);
+ _assertAjax(commentArg(1, arguments), aVar === null, 'Expected ' + _displayStringForValue(null) + ' but was ' + _displayStringForValue(aVar));
+}
+
+function assertNotNullAjax() {
+ _validateArguments(1, arguments);
+ var aVar = nonCommentArg(1, 1, arguments);
+ _assertAjax(commentArg(1, arguments), aVar !== null, 'Expected not to be ' + _displayStringForValue(null));
+}
+
+function assertUndefinedAjax() {
+ _validateArguments(1, arguments);
+ var aVar = nonCommentArg(1, 1, arguments);
+ _assertAjax(commentArg(1, arguments), aVar === top.JSUNIT_UNDEFINED_VALUE, 'Expected ' + _displayStringForValue(top.JSUNIT_UNDEFINED_VALUE) + ' but was ' + _displayStringForValue(aVar));
+}
+
+function assertNotUndefinedAjax() {
+ _validateArguments(1, arguments);
+ var aVar = nonCommentArg(1, 1, arguments);
+ _assertAjax(commentArg(1, arguments), aVar !== top.JSUNIT_UNDEFINED_VALUE, 'Expected not to be ' + _displayStringForValue(top.JSUNIT_UNDEFINED_VALUE));
+}
+
+function assertNaNAjax() {
+ _validateArguments(1, arguments);
+ var aVar = nonCommentArg(1, 1, arguments);
+ _assertAjax(commentArg(1, arguments), isNaN(aVar), 'Expected NaN');
+}
+
+function assertNotNaNAjax() {
+ _validateArguments(1, arguments);
+ var aVar = nonCommentArg(1, 1, arguments);
+ _assertAjax(commentArg(1, arguments), !isNaN(aVar), 'Expected not NaN');
+}
+
+function assertObjectEqualsAjax() {
+ _validateArguments(2, arguments);
+ var var1 = nonCommentArg(1, 2, arguments);
+ var var2 = nonCommentArg(2, 2, arguments);
+ var type;
+ var msg = commentArg(2, arguments)?commentArg(2, arguments):'';
+ var isSame = (var1 === var2);
+ //shortpath for references to same object
+ var isEqual = ( (type = _trueTypeOf(var1)) == _trueTypeOf(var2) );
+ if (isEqual && !isSame) {
+ switch (type) {
+ case 'String':
+ case 'Number':
+ isEqual = (var1 == var2);
+ break;
+ case 'Boolean':
+ case 'Date':
+ isEqual = (var1 === var2);
+ break;
+ case 'RegExp':
+ case 'Function':
+ isEqual = (var1.toString() === var2.toString());
+ break;
+ default: //Object | Array
+ var i;
+ if (isEqual = (var1.length === var2.length))
+ for (i in var1)
+ assertObjectEqualsAjax(msg + ' found nested ' + type + '@' + i + '\n', var1[i], var2[i]);
+ }
+ _assertAjax(msg, isEqual, 'Expected ' + _displayStringForValue(var1) + ' but was ' + _displayStringForValue(var2));
+ }
+}
+
+assertArrayEquals = assertObjectEquals;
+
+function assertEvaluatesToTrueAjax() {
+ _validateArguments(1, arguments);
+ var value = nonCommentArg(1, 1, arguments);
+ if (!value)
+ failAjax(commentArg(1, arguments));
+}
+
+function assertEvaluatesToFalseAjax() {
+ _validateArguments(1, arguments);
+ var value = nonCommentArg(1, 1, arguments);
+ if (value)
+ failAjax(commentArg(1, arguments));
+}
+
+function assertHTMLEqualsAjax() {
+ _validateArguments(2, arguments);
+ var var1 = nonCommentArg(1, 2, arguments);
+ var var2 = nonCommentArg(2, 2, arguments);
+ var var1Standardized = standardizeHTML(var1);
+ var var2Standardized = standardizeHTML(var2);
+
+ _assertAjax(commentArg(2, arguments), var1Standardized === var2Standardized, 'Expected ' + _displayStringForValue(var1Standardized) + ' but was ' + _displayStringForValue(var2Standardized));
+}
+
+function assertHashEqualsAjax() {
+ _validateArguments(2, arguments);
+ var var1 = nonCommentArg(1, 2, arguments);
+ var var2 = nonCommentArg(2, 2, arguments);
+ for (var key in var1) {
+ assertNotUndefinedAjax("Expected hash had key " + key + " that was not found", var2[key]);
+ assertEqualsAjax(
+ "Value for key " + key + " mismatch - expected = " + var1[key] + ", actual = " + var2[key],
+ var1[key], var2[key]
+ );
+ }
+ for (var key in var2) {
+ assertNotUndefinedAjax("Actual hash had key " + key + " that was not expected", var1[key]);
+ }
+}
+
+function assertRoughlyEqualsAjax() {
+ _validateArguments(3, arguments);
+ var expected = nonCommentArg(1, 3, arguments);
+ var actual = nonCommentArg(2, 3, arguments);
+ var tolerance = nonCommentArg(3, 3, arguments);
+ assertTrueAjax(
+ "Expected " + expected + ", but got " + actual + " which was more than " + tolerance + " away",
+ Math.abs(expected - actual) < tolerance
+ );
+}
+
+function assertContainsAjax() {
+ _validateArguments(2, arguments);
+ var contained = nonCommentArg(1, 2, arguments);
+ var container = nonCommentArg(2, 2, arguments);
+ assertTrueAjax(
+ "Expected '" + container + "' to contain '" + contained + "'",
+ container.indexOf(contained) != -1
+ );
+}
Added: branches/tomek/portal-dnd/test/jsUnitCore.js
===================================================================
--- branches/tomek/portal-dnd/test/jsUnitCore.js 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/test/jsUnitCore.js 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,534 @@
+var JSUNIT_UNDEFINED_VALUE;
+var JSUNIT_VERSION = 2.2;
+var isTestPageLoaded = false;
+
+//hack for NS62 bug
+function jsUnitFixTop() {
+ var tempTop = top;
+ if (!tempTop) {
+ tempTop = window;
+ while (tempTop.parent) {
+ tempTop = tempTop.parent;
+ if (tempTop.top && tempTop.top.jsUnitTestSuite) {
+ tempTop = tempTop.top;
+ break;
+ }
+ }
+ }
+ try {
+ window.top = tempTop;
+ } catch (e) {
+ }
+}
+
+jsUnitFixTop();
+
+/**
+ + * A more functional typeof
+ + * @param Object o
+ + * @return String
+ + */
+function _trueTypeOf(something) {
+ var result = typeof something;
+ try {
+ switch (result) {
+ case 'string':
+ case 'boolean':
+ case 'number':
+ break;
+ case 'object':
+ case 'function':
+ switch (something.constructor)
+ {
+ case String:
+ result = 'String';
+ break;
+ case Boolean:
+ result = 'Boolean';
+ break;
+ case Number:
+ result = 'Number';
+ break;
+ case Array:
+ result = 'Array';
+ break;
+ case RegExp:
+ result = 'RegExp';
+ break;
+ case Function:
+ result = 'Function';
+ break;
+ default:
+ var m = something.constructor.toString().match(/function\s*([^( ]+)\(/);
+ if (m)
+ result = m[1];
+ else
+ break;
+ }
+ break;
+ }
+ }
+ finally {
+ result = result.substr(0, 1).toUpperCase() + result.substr(1);
+ return result;
+ }
+}
+
+function _displayStringForValue(aVar) {
+ var result = '<' + aVar + '>';
+ if (!(aVar === null || aVar === top.JSUNIT_UNDEFINED_VALUE)) {
+ result += ' (' + _trueTypeOf(aVar) + ')';
+ }
+ return result;
+}
+
+function fail(failureMessage) {
+ throw new JsUnitException("Call to fail()", failureMessage);
+}
+
+function error(errorMessage) {
+ var errorObject = new Object();
+ errorObject.description = errorMessage;
+ errorObject.stackTrace = getStackTrace();
+ throw errorObject;
+}
+
+function argumentsIncludeComments(expectedNumberOfNonCommentArgs, args) {
+ return args.length == expectedNumberOfNonCommentArgs + 1;
+}
+
+function commentArg(expectedNumberOfNonCommentArgs, args) {
+ if (argumentsIncludeComments(expectedNumberOfNonCommentArgs, args))
+ return args[0];
+
+ return null;
+}
+
+function nonCommentArg(desiredNonCommentArgIndex, expectedNumberOfNonCommentArgs, args) {
+ return argumentsIncludeComments(expectedNumberOfNonCommentArgs, args) ?
+ args[desiredNonCommentArgIndex] :
+ args[desiredNonCommentArgIndex - 1];
+}
+
+function _validateArguments(expectedNumberOfNonCommentArgs, args) {
+ if (!( args.length == expectedNumberOfNonCommentArgs ||
+ (args.length == expectedNumberOfNonCommentArgs + 1 && typeof(args[0]) == 'string') ))
+ error('Incorrect arguments passed to assert function');
+}
+
+function _assert(comment, booleanValue, failureMessage) {
+ if (!booleanValue)
+ throw new JsUnitException(comment, failureMessage);
+}
+
+function assert() {
+ _validateArguments(1, arguments);
+ var booleanValue = nonCommentArg(1, 1, arguments);
+
+ if (typeof(booleanValue) != 'boolean')
+ error('Bad argument to assert(boolean)');
+
+ _assert(commentArg(1, arguments), booleanValue === true, 'Call to assert(boolean) with false');
+}
+
+function assertTrue() {
+ _validateArguments(1, arguments);
+ var booleanValue = nonCommentArg(1, 1, arguments);
+
+ if (typeof(booleanValue) != 'boolean')
+ error('Bad argument to assertTrue(boolean)');
+
+ _assert(commentArg(1, arguments), booleanValue === true, 'Call to assertTrue(boolean) with false');
+}
+
+function assertFalse() {
+ _validateArguments(1, arguments);
+ var booleanValue = nonCommentArg(1, 1, arguments);
+
+ if (typeof(booleanValue) != 'boolean')
+ error('Bad argument to assertFalse(boolean)');
+
+ _assert(commentArg(1, arguments), booleanValue === false, 'Call to assertFalse(boolean) with true');
+}
+
+function assertEquals() {
+ _validateArguments(2, arguments);
+ var var1 = nonCommentArg(1, 2, arguments);
+ var var2 = nonCommentArg(2, 2, arguments);
+ _assert(commentArg(2, arguments), var1 === var2, 'Expected ' + _displayStringForValue(var1) + ' but was ' + _displayStringForValue(var2));
+}
+
+function assertNotEquals() {
+ _validateArguments(2, arguments);
+ var var1 = nonCommentArg(1, 2, arguments);
+ var var2 = nonCommentArg(2, 2, arguments);
+ _assert(commentArg(2, arguments), var1 !== var2, 'Expected not to be ' + _displayStringForValue(var2));
+}
+
+function assertNull() {
+ _validateArguments(1, arguments);
+ var aVar = nonCommentArg(1, 1, arguments);
+ _assert(commentArg(1, arguments), aVar === null, 'Expected ' + _displayStringForValue(null) + ' but was ' + _displayStringForValue(aVar));
+}
+
+function assertNotNull() {
+ _validateArguments(1, arguments);
+ var aVar = nonCommentArg(1, 1, arguments);
+ _assert(commentArg(1, arguments), aVar !== null, 'Expected not to be ' + _displayStringForValue(null));
+}
+
+function assertUndefined() {
+ _validateArguments(1, arguments);
+ var aVar = nonCommentArg(1, 1, arguments);
+ _assert(commentArg(1, arguments), aVar === top.JSUNIT_UNDEFINED_VALUE, 'Expected ' + _displayStringForValue(top.JSUNIT_UNDEFINED_VALUE) + ' but was ' + _displayStringForValue(aVar));
+}
+
+function assertNotUndefined() {
+ _validateArguments(1, arguments);
+ var aVar = nonCommentArg(1, 1, arguments);
+ _assert(commentArg(1, arguments), aVar !== top.JSUNIT_UNDEFINED_VALUE, 'Expected not to be ' + _displayStringForValue(top.JSUNIT_UNDEFINED_VALUE));
+}
+
+function assertNaN() {
+ _validateArguments(1, arguments);
+ var aVar = nonCommentArg(1, 1, arguments);
+ _assert(commentArg(1, arguments), isNaN(aVar), 'Expected NaN');
+}
+
+function assertNotNaN() {
+ _validateArguments(1, arguments);
+ var aVar = nonCommentArg(1, 1, arguments);
+ _assert(commentArg(1, arguments), !isNaN(aVar), 'Expected not NaN');
+}
+
+function assertObjectEquals() {
+ _validateArguments(2, arguments);
+ var var1 = nonCommentArg(1, 2, arguments);
+ var var2 = nonCommentArg(2, 2, arguments);
+ var type;
+ var msg = commentArg(2, arguments)?commentArg(2, arguments):'';
+ var isSame = (var1 === var2);
+ //shortpath for references to same object
+ var isEqual = ( (type = _trueTypeOf(var1)) == _trueTypeOf(var2) );
+ if (isEqual && !isSame) {
+ switch (type) {
+ case 'String':
+ case 'Number':
+ isEqual = (var1 == var2);
+ break;
+ case 'Boolean':
+ case 'Date':
+ isEqual = (var1 === var2);
+ break;
+ case 'RegExp':
+ case 'Function':
+ isEqual = (var1.toString() === var2.toString());
+ break;
+ default: //Object | Array
+ var i;
+ if (isEqual = (var1.length === var2.length))
+ for (i in var1)
+ assertObjectEquals(msg + ' found nested ' + type + '@' + i + '\n', var1[i], var2[i]);
+ }
+ _assert(msg, isEqual, 'Expected ' + _displayStringForValue(var1) + ' but was ' + _displayStringForValue(var2));
+ }
+}
+
+assertArrayEquals = assertObjectEquals;
+
+function assertEvaluatesToTrue() {
+ _validateArguments(1, arguments);
+ var value = nonCommentArg(1, 1, arguments);
+ if (!value)
+ fail(commentArg(1, arguments));
+}
+
+function assertEvaluatesToFalse() {
+ _validateArguments(1, arguments);
+ var value = nonCommentArg(1, 1, arguments);
+ if (value)
+ fail(commentArg(1, arguments));
+}
+
+function assertHTMLEquals() {
+ _validateArguments(2, arguments);
+ var var1 = nonCommentArg(1, 2, arguments);
+ var var2 = nonCommentArg(2, 2, arguments);
+ var var1Standardized = standardizeHTML(var1);
+ var var2Standardized = standardizeHTML(var2);
+
+ _assert(commentArg(2, arguments), var1Standardized === var2Standardized, 'Expected ' + _displayStringForValue(var1Standardized) + ' but was ' + _displayStringForValue(var2Standardized));
+}
+
+function assertHashEquals() {
+ _validateArguments(2, arguments);
+ var var1 = nonCommentArg(1, 2, arguments);
+ var var2 = nonCommentArg(2, 2, arguments);
+ for (var key in var1) {
+ assertNotUndefined("Expected hash had key " + key + " that was not found", var2[key]);
+ assertEquals(
+ "Value for key " + key + " mismatch - expected = " + var1[key] + ", actual = " + var2[key],
+ var1[key], var2[key]
+ );
+ }
+ for (var key in var2) {
+ assertNotUndefined("Actual hash had key " + key + " that was not expected", var1[key]);
+ }
+}
+
+function assertRoughlyEquals() {
+ _validateArguments(3, arguments);
+ var expected = nonCommentArg(1, 3, arguments);
+ var actual = nonCommentArg(2, 3, arguments);
+ var tolerance = nonCommentArg(3, 3, arguments);
+ assertTrue(
+ "Expected " + expected + ", but got " + actual + " which was more than " + tolerance + " away",
+ Math.abs(expected - actual) < tolerance
+ );
+}
+
+function assertContains() {
+ _validateArguments(2, arguments);
+ var contained = nonCommentArg(1, 2, arguments);
+ var container = nonCommentArg(2, 2, arguments);
+ assertTrue(
+ "Expected '" + container + "' to contain '" + contained + "'",
+ container.indexOf(contained) != -1
+ );
+}
+
+function standardizeHTML(html) {
+ var translator = document.createElement("DIV");
+ translator.innerHTML = html;
+ return translator.innerHTML;
+}
+
+function isLoaded() {
+ return isTestPageLoaded;
+}
+
+function setUp() {
+}
+
+function tearDown() {
+}
+
+function getFunctionName(aFunction) {
+ var regexpResult = aFunction.toString().match(/function(\s*)(\w*)/);
+ if (regexpResult && regexpResult.length >= 2 && regexpResult[2]) {
+ return regexpResult[2];
+ }
+ return 'anonymous';
+}
+
+function getStackTrace() {
+ var result = '';
+
+ if (typeof(arguments.caller) != 'undefined') { // IE, not ECMA
+ for (var a = arguments.caller; a != null; a = a.caller) {
+ result += '> ' + getFunctionName(a.callee) + '\n';
+ if (a.caller == a) {
+ result += '*';
+ break;
+ }
+ }
+ }
+ else { // Mozilla, not ECMA
+ // fake an exception so we can get Mozilla's error stack
+ var testExcp;
+ try
+ {
+ foo.bar;
+ }
+ catch(testExcp)
+ {
+ var stack = parseErrorStack(testExcp);
+ for (var i = 1; i < stack.length; i++)
+ {
+ result += '> ' + stack[i] + '\n';
+ }
+ }
+ }
+
+ return result;
+}
+
+function parseErrorStack(excp)
+{
+ var stack = [];
+ var name;
+
+ if (!excp || !excp.stack)
+ {
+ return stack;
+ }
+
+ var stacklist = excp.stack.split('\n');
+
+ for (var i = 0; i < stacklist.length - 1; i++)
+ {
+ var framedata = stacklist[i];
+
+ name = framedata.match(/^(\w*)/)[1];
+ if (!name) {
+ name = 'anonymous';
+ }
+
+ stack[stack.length] = name;
+ }
+ // remove top level anonymous functions to match IE
+
+ while (stack.length && stack[stack.length - 1] == 'anonymous')
+ {
+ stack.length = stack.length - 1;
+ }
+ return stack;
+}
+
+function JsUnitException(comment, message) {
+ this.isJsUnitException = true;
+ this.comment = comment;
+ this.jsUnitMessage = message;
+ this.stackTrace = getStackTrace();
+}
+
+function warn() {
+ if (top.tracer != null)
+ top.tracer.warn(arguments[0], arguments[1]);
+}
+
+function inform() {
+ if (top.tracer != null)
+ top.tracer.inform(arguments[0], arguments[1]);
+}
+
+function info() {
+ inform(arguments[0], arguments[1]);
+}
+
+function debug() {
+ if (top.tracer != null)
+ top.tracer.debug(arguments[0], arguments[1]);
+}
+
+function setJsUnitTracer(aJsUnitTracer) {
+ top.tracer = aJsUnitTracer;
+}
+
+function trim(str) {
+ if (str == null)
+ return null;
+
+ var startingIndex = 0;
+ var endingIndex = str.length - 1;
+
+ while (str.substring(startingIndex, startingIndex + 1) == ' ')
+ startingIndex++;
+
+ while (str.substring(endingIndex, endingIndex + 1) == ' ')
+ endingIndex--;
+
+ if (endingIndex < startingIndex)
+ return '';
+
+ return str.substring(startingIndex, endingIndex + 1);
+}
+
+function isBlank(str) {
+ return trim(str) == '';
+}
+
+// the functions push(anArray, anObject) and pop(anArray)
+// exist because the JavaScript Array.push(anObject) and Array.pop()
+// functions are not available in IE 5.0
+
+function push(anArray, anObject) {
+ anArray[anArray.length] = anObject;
+}
+function pop(anArray) {
+ if (anArray.length >= 1) {
+ delete anArray[anArray.length - 1];
+ anArray.length--;
+ }
+}
+
+function jsUnitGetParm(name)
+{
+ if (typeof(top.jsUnitParmHash[name]) != 'undefined')
+ {
+ return top.jsUnitParmHash[name];
+ }
+ return null;
+}
+
+if (top && typeof(top.xbDEBUG) != 'undefined' && top.xbDEBUG.on && top.testManager)
+{
+ top.xbDebugTraceObject('top.testManager.containerTestFrame', 'JSUnitException');
+ // asserts
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', '_displayStringForValue');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'error');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'argumentsIncludeComments');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'commentArg');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'nonCommentArg');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', '_validateArguments');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', '_assert');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'assert');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'assertTrue');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'assertEquals');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'assertNotEquals');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'assertNull');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'assertNotNull');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'assertUndefined');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'assertNotUndefined');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'assertNaN');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'assertNotNaN');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'isLoaded');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'setUp');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'tearDown');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'getFunctionName');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'getStackTrace');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'warn');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'inform');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'debug');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'setJsUnitTracer');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'trim');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'isBlank');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'newOnLoadEvent');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'push');
+ top.xbDebugTraceFunction('top.testManager.containerTestFrame', 'pop');
+}
+
+function newOnLoadEvent() {
+ isTestPageLoaded = true;
+}
+
+function jsUnitSetOnLoad(windowRef, onloadHandler)
+{
+ var isKonqueror = navigator.userAgent.indexOf('Konqueror/') != -1 ||
+ navigator.userAgent.indexOf('Safari/') != -1;
+
+ if (typeof(windowRef.attachEvent) != 'undefined') {
+ // Internet Explorer, Opera
+ windowRef.attachEvent("onload", onloadHandler);
+ } else if (typeof(windowRef.addEventListener) != 'undefined' && !isKonqueror) {
+ // Mozilla, Konqueror
+ // exclude Konqueror due to load issues
+ windowRef.addEventListener("load", onloadHandler, false);
+ } else if (typeof(windowRef.document.addEventListener) != 'undefined' && !isKonqueror) {
+ // DOM 2 Events
+ // exclude Mozilla, Konqueror due to load issues
+ windowRef.document.addEventListener("load", onloadHandler, false);
+ } else if (typeof(windowRef.onload) != 'undefined' && windowRef.onload) {
+ windowRef.jsunit_original_onload = windowRef.onload;
+ windowRef.onload = function() {
+ windowRef.jsunit_original_onload();
+ onloadHandler();
+ };
+ } else {
+ // browsers that do not support windowRef.attachEvent or
+ // windowRef.addEventListener will override a page's own onload event
+ windowRef.onload = onloadHandler;
+ }
+}
+
+jsUnitSetOnLoad(window, newOnLoadEvent);
\ No newline at end of file
Added: branches/tomek/portal-dnd/test/testPortletDrop.html
===================================================================
--- branches/tomek/portal-dnd/test/testPortletDrop.html 2006-08-30 20:34:08 UTC (rev 5124)
+++ branches/tomek/portal-dnd/test/testPortletDrop.html 2006-08-31 15:21:41 UTC (rev 5125)
@@ -0,0 +1,187 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
+<html>
+
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+ <title>Test loading a local HTML Document</title>
+ <!-- JSUnit lib -->
+ <script language="JavaScript" type="text/javascript" src="jsUnitCore.js"></script>
+
+ <!-- Ajax asserts -->
+ <script language="JavaScript" type="text/javascript" src="ajaxAsserts.js"></script>
+
+ <!-- All used YUI and portal ajax libs -->
+ <script language="JavaScript" type='text/javascript' src='/dndRenderer/js/yahoo/yahoo.js' ></script>
+ <script language="JavaScript" type='text/javascript' src='/dndRenderer/js/event/event.js' ></script>
+ <script language="JavaScript" type='text/javascript' src='/dndRenderer/js/dom/dom.js'></script>
+ <script language="JavaScript" type='text/javascript' src='/dndRenderer/js/logger/logger.js' ></script>
+ <script language="JavaScript" type='text/javascript' src='/dndRenderer/js/dragdrop/dragdrop-debug.js' ></script>
+ <script language="JavaScript" type='text/javascript' src='/dndRenderer/js/connection/connection.js' ></script>
+ <script language="JavaScript" type='text/javascript' src='/dndRenderer/js/portal/PortalDD.js' ></script>
+
+
+ <script language="JavaScript" type="text/javascript">
+
+ var ddPortletregionNumberOne0, ddPortletregionNumberOne1, regionDropregionNumberOne;
+ var ddPortletregionNumberTwo0, ddPortletregionNumberTwo1, regionDropregionNumberTwo;
+
+ YAHOO.example.DDAppregionNumberOne = function() {
+ var DDM = YAHOO.util.DDM;
+ DDM.mode = DDM.POINT;
+ return {
+ init: function() {
+ regionDropregionNumberOne = new YAHOO.util.PortalDD('regionDropregionNumberOne');
+ regionDropregionNumberOne.setXConstraint(0, 0, 1);
+ regionDropregionNumberOne.setYConstraint(0, 0, 1);
+ ddPortletregionNumberOne0 = new YAHOO.util.PortalDD('portlet-dnd-regionNumberOne-0');
+ ddPortletregionNumberOne0.windowId = "FirstPortletWindowNumberOne";
+ ddPortletregionNumberOne1 = new YAHOO.util.PortalDD('portlet-dnd-regionNumberOne-1');
+ ddPortletregionNumberOne1.windowId = "SecondPortletWindowNumberOne";
+
+ regionDropregionNumberOne.getEl().parentNode.dropToRegion = 'regionDropregionNumberOne';
+ regionDropregionNumberOne.getEl().parentNode.regionId = 'NumberOne';
+ }
+ };
+ } ();
+ YAHOO.util.Event.addListener(window, 'load', YAHOO.example.DDAppregionNumberOne.init);
+
+ YAHOO.example.DDAppregionNumberTwo = function() {
+ var DDM = YAHOO.util.DDM;
+ DDM.mode = DDM.POINT;
+ return {
+ init: function() {
+ regionDropregionNumberTwo = new YAHOO.util.PortalDD('regionDropregionNumberTwo');
+ regionDropregionNumberTwo.setXConstraint(0, 0, 1);
+ regionDropregionNumberTwo.setYConstraint(0, 0, 1);
+ ddPortletregionNumberTwo0 = new YAHOO.util.PortalDD('portlet-dnd-regionNumberTwo-0');
+ ddPortletregionNumberTwo0.windowId = "FirstPortletWindowNumberTwo";
+ ddPortletregionNumberTwo1 = new YAHOO.util.PortalDD('portlet-dnd-regionNumberTwo-1');
+ ddPortletregionNumberTwo1.windowId = "SecondPortletWindowNumberTwo";
+
+ regionDropregionNumberTwo.getEl().parentNode.dropToRegion = 'regionDropregionNumberTwo';
+ regionDropregionNumberTwo.getEl().parentNode.regionId = 'NumberTwo';
+ }
+ };
+ } ();
+ YAHOO.util.Event.addListener(window, 'load', YAHOO.example.DDAppregionNumberTwo.init);
+
+ function setUp() {
+ inform("setup");
+ enterTestMode();
+ }
+
+ function tearDown() {
+ inform("teardown");
+ leaveTestMode();
+ }
+
+ function testDragAndDrop() {
+ inform("test dnd");
+ // objects should have different parents
+ assertNotEquals("Parents do match", ddPortletregionNumberTwo0.getEl().parentNode, ddPortletregionNumberOne0.getEl().parentNode);
+
+ var e;
+ // execute drop
+ ddPortletregionNumberTwo0.onDragDrop(e, ddPortletregionNumberOne0.getEl().id);
+
+ // parents should match now
+ assertEquals("Parents don't match", ddPortletregionNumberTwo0.getEl().parentNode, ddPortletregionNumberOne0.getEl().parentNode);
+ }
+
+ // next tests need running instance of JBPortal with ajax servlet enabled
+
+
+ function testAjaxWrongParamsTestMode() {
+ inform("test test params");
+
+ var postdata = "action=TEST_MODE&mod=true";
+
+ var handle = function(o) {
+ failAjax("TEST MODE should return error");
+ }
+ var error = function(o) {
+ // do nothing - params are wrong - weverything is ok
+ }
+
+ invokeTestAjax(postdata, handle, error);
+ }
+
+ function testPersistData() {
+ inform("test persistance");
+
+ // try persistance with some test attributes
+ var postdata = "action=PERSIST&positionNo=0&windowId=testPortletWindow&oldRegionId=old&newRegionId=new";
+
+ var handle = function(o) {
+ assertEqualsAjax("Wrong response", o.responseText, "Position persisted");
+ }
+ var error = function(o) {
+ failAjax("Ajax call failed");
+ }
+
+ invokeTestAjax(postdata, handle, error);
+
+ // try persistance with wrong attributes
+
+ //(missing positionNo attribute)
+ postdata = "action=PERSIST&windowId=testPortletWindow&oldRegionId=old&newRegionId=new";
+
+ handle = function(o) {
+ failAjax("Persistance call should fail");
+ }
+ error = function(o) {
+ // do nothing - invocation failed
+ }
+
+ invokeTestAjax(postdata, handle, error);
+
+ }
+
+ function enterTestMode() {
+
+ // disable calling ajax in PortalDD
+ setAjaxEnabled(false);
+
+ var postdata = "action=TEST_MODE&mode=true";
+
+ var handle = function(o) {
+ assertEqualsAjax("Wrong response", o.responseText, "Test mode ON");
+ }
+ var error = function(o) {
+ failAjax("Ajax call failed");
+ }
+
+ invokeTestAjax(postdata, handle, error);
+ }
+
+ function leaveTestMode() {
+
+ // enable calling ajax in PortalDD
+ setAjaxEnabled(true);
+
+ var postdata = "action=TEST_MODE&mode=false";
+
+ var handle = function(o) {
+ assertEqualsAjax("Wrong response", o.responseText, "Test mode OFF");
+ }
+ var error = function(o) {
+ failAjax("Ajax call failed");
+ }
+
+ invokeTestAjax(postdata, handle, error);
+ }
+
+ </script>
+
+</head>
+
+<body>
+<h1>JsUnit test portlets DnD</h1>
+
+<div id='regionDDregionNumberOne'><div style='display: none; visibility: hidden; padding: 50px; margin: 10px; border: 1px dashed black;' id='regionDropregionNumberOne'>Drop your portlets here</div><div id='portlet-dnd-regionNumberOne-0'>Portlet No 1 (Region ONE)</div><div id='portlet-dnd-regionNumberOne-1'>Portlet No 2 (Region ONE)</div></div>
+<div id='regionDDregionNumberTwo'><div style='display: none; visibility: hidden; padding: 50px; margin: 10px; border: 1px dashed black;' id='regionDropregionNumberTwo'>Drop your portlets here</div><div id='portlet-dnd-regionNumberTwo-0'>Portlet No 1 (Region TWO)</div><div id='portlet-dnd-regionNumberTwo-1'>Portlet No 2 (Region TWO)</div></div>
+
+<p>This page tests DnD.</p>
+<iframe name="documentBuffer"></iframe>
+</body>
+</html>
More information about the jboss-svn-commits
mailing list